diff --git a/app/config/collections.php b/app/config/collections.php index bf3ddaf86c..6abdb081be 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -850,17 +850,6 @@ $collections = [ 'default' => null, 'array' => false, 'filters' => [], - ], - [ - '$id' => ID::custom('search'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 16384, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], ] ], 'indexes' => [ @@ -870,7 +859,42 @@ $collections = [ 'attributes' => ['domain'], 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], - ] + ], + [ + '$id' => ID::custom('_key_projectInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_resourceInternalId', + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_resourceId', + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => '_key_resourceType', + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceType'], + 'lengths' => [100], + 'orders' => [Database::ORDER_ASC], + ], ], ], @@ -2291,7 +2315,30 @@ $collections = [ 'array' => false, ], ], - 'indexes' => [], + 'indexes' => [ + + [ + '$id' => ID::custom('_key_projectInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_installationId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['installationId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], ], 'vcsRepos' => [ @@ -2347,7 +2394,7 @@ $collections = [ '$id' => ID::custom('repositoryId'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2365,11 +2412,12 @@ $collections = [ 'array' => false, 'filters' => [], ], + // TODO: Resource Internal ID? [ '$id' => ID::custom('resourceType'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2388,7 +2436,57 @@ $collections = [ 'filters' => [], ], ], - 'indexes' => [], + 'indexes' => [ + [ + '$id' => ID::custom('_key_vcsInstallationId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsInstallationId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_vcsInstallationInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsInstallationInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_repositoryId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['repositoryId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_resourceId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_resourceType'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['resourceType'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ] + ], ], 'vcsComments' => [ @@ -2444,7 +2542,7 @@ $collections = [ '$id' => ID::custom('repositoryId'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2455,7 +2553,7 @@ $collections = [ '$id' => ID::custom('commentId'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2466,7 +2564,7 @@ $collections = [ '$id' => ID::custom('pullRequestId'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2477,7 +2575,7 @@ $collections = [ '$id' => ID::custom('branch'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 128, + 'size' => Database::LENGTH_KEY, 'signed' => true, 'required' => true, 'default' => null, @@ -2485,7 +2583,57 @@ $collections = [ 'filters' => [] ], ], - 'indexes' => [], + 'indexes' => [ + [ + '$id' => ID::custom('_key_vcsInstallationId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsInstallationId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_vcsInstallationInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsInstallationInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_projectId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['projectId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_repositoryId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['repositoryId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_pullRequestId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['pullRequestId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_branch'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['branch'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + ], ], 'functions' => [ @@ -2812,6 +2960,20 @@ $collections = [ 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => ID::custom('_key_vcsInstallationInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsInstallationInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], + [ + '$id' => ID::custom('_key_vcsRepositoryId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsRepositoryId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], [ '$id' => ID::custom('_key_vcsRepositoryDocId'), 'type' => Database::INDEX_KEY, @@ -2819,6 +2981,13 @@ $collections = [ 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => ID::custom('_key_vcsRepositoryDocInternalId'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['vcsRepositoryDocInternalId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], [ '$id' => ID::custom('_key_runtime'), 'type' => Database::INDEX_KEY, @@ -2832,42 +3001,7 @@ $collections = [ 'attributes' => ['deployment'], 'lengths' => [], 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_schedule'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['schedule'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_timeout'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['timeout'], - 'lengths' => [], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_entrypoint'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['entrypoint'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_build_command'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['buildCommand'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], - [ - '$id' => ID::custom('_key_install_command'), - 'type' => Database::INDEX_KEY, - 'attributes' => ['installCommand'], - 'lengths' => [2048], - 'orders' => [Database::ORDER_ASC], - ], + ] ], ], diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0bcd3d00f9..8ae1ec4469 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -245,7 +245,6 @@ App::post('/v1/functions') 'resourceInternalId' => $function->getInternalId(), 'status' => 'verified', 'certificateId' => '', - 'search' => implode(' ', [$domain, $ruleId, $function->getId(), 'function']), ])) ); @@ -684,7 +683,7 @@ App::put('/v1/functions/:functionId') // Git disconnect logic if ($isConnected && empty($vcsRepositoryId)) { $repoDocs = $dbForConsole->find('vcsRepos', [ - Query::equal('projectId', [$project->getId()]), + Query::equal('projectInternalId', [$project->getInternalId()]), Query::equal('resourceId', [$functionId]), Query::equal('resourceType', ['function']), Query::limit(100), @@ -1336,7 +1335,7 @@ App::post('/v1/functions/:functionId/executions') ->param('body', '', new Text(8192), 'HTTP body of execution. Default value is empty string.', true) ->param('async', false, new Boolean(), 'Execute code in the background. Default value is false.', true) ->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true) - ->param('method', 'GET', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is GET.', true) + ->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], true), 'HTTP method of execution. Default value is GET.', true) ->param('headers', [], new Assoc(), 'HTP headers of execution. Defaults to empty.', true) ->inject('response') ->inject('project') diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 94d7f503e8..2b1cf3dad4 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -99,7 +99,6 @@ App::post('/v1/proxy/rules') 'resourceInternalId' => $resourceInternalId, 'status' => $status, 'certificateId' => '', - 'search' => implode(' ', [$domain->get(), $ruleId, $resourceId, $resourceType]), ])); $events->setParam('ruleId', $rule->getId()); diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 97bc93539a..97ebba6112 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -597,7 +597,7 @@ $createGitDeployments = function (GitHub $github, string $installationId, array } $contribution = new Document([]); - if($external) { + if ($external) { $pullRequestResponse = $github->getPullRequest($owner, $repositoryName, $pullRequest); $contribution->setAttribute('ownerName', $pullRequestResponse['head']['repo']['owner']['login']); @@ -673,7 +673,7 @@ App::post('/v1/vcs/github/incomingwebhook') foreach ($vcsInstallations as $installation) { $vcsRepos = $dbForConsole->find('vcsRepos', [ - Query::equal('vcsInstallationId', [$installation->getId()]), + Query::equal('vcsInstallationInternalId', [$installation->getInternalId()]), Query::limit(1000) ]); @@ -694,7 +694,7 @@ App::post('/v1/vcs/github/incomingwebhook') $external = $parsedPayload["external"]; // Ignore sync for non-external. We handle it in push webhook - if(!$external && $parsedPayload["action"] == "synchronize") { + if (!$external && $parsedPayload["action"] == "synchronize") { return $response->json($parsedPayload); } @@ -785,15 +785,15 @@ App::get('/v1/vcs/installations') $total = $dbForConsole->count('vcsInstallations', $filterQueries, APP_LIMIT_COUNT); if (\count($results) > 0) { - $installationIds = \array_map(fn ($result) => $result->getId(), $results); + $installationIds = \array_map(fn ($result) => $result->getInternalId(), $results); $functions = Authorization::skip(fn () => $dbForProject->find('functions', [ - Query::equal('vcsInstallationId', \array_unique($installationIds)), + Query::equal('vcsInstallationInternalId', \array_unique($installationIds)), Query::limit(APP_LIMIT_SUBQUERY) ])); foreach ($results as $result) { - $installationFunctions = \array_filter($functions, fn ($function) => $function->getAttribute('vcsInstallationId') === $result->getId()); + $installationFunctions = \array_filter($functions, fn ($function) => $function->getAttribute('vcsInstallationInternalId') === $result->getInternalId()); $result->setAttribute('functions', $installationFunctions); } @@ -833,7 +833,7 @@ App::get('/v1/vcs/installations/:installationId') } $functions = Authorization::skip(fn () => $dbForProject->find('functions', [ - Query::equal('vcsInstallationId', [$installation->getId()]), + Query::equal('vcsInstallationInternalId', [$installation->getInternalId()]), Query::limit(APP_LIMIT_SUBQUERY) ]));