From 00f6785818f574cdcf317c4126348973ee543dc7 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Fri, 18 Aug 2023 12:25:44 +0530 Subject: [PATCH] Addressed PR comments --- app/console | 2 +- app/controllers/api/functions.php | 24 ++++-- app/controllers/api/proxy.php | 2 +- app/controllers/general.php | 2 +- app/workers/builds.php | 13 +-- composer.json | 2 +- composer.lock | 84 ++++++++----------- src/Appwrite/Utopia/Response/Filters/V12.php | 1 - src/Executor/Executor.php | 2 - .../unit/Utopia/Response/Filters/V15Test.php | 34 -------- 10 files changed, 60 insertions(+), 106 deletions(-) diff --git a/app/console b/app/console index c4331ea10..451e591a1 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit c4331ea10dce0cbf403cae9aec8273f2d003ba2e +Subproject commit 451e591a1d6c0843fdaef131f1064fd6cdbb2a3b diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index b3375340f..7ef5fb46e 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -165,7 +165,12 @@ App::post('/v1/functions') // build from template $template = new Document([]); - if (!empty($templateRepository) && !empty($templateOwner) && !empty($templateRootDirectory) && !empty($templateBranch)) { + if ( + !empty($templateRepository) + && !empty($templateOwner) + && !empty($templateRootDirectory) + && !empty($templateBranch) + ) { $template->setAttribute('repositoryName', $templateRepository) ->setAttribute('ownerName', $templateOwner) ->setAttribute('rootDirectory', $templateRootDirectory) @@ -1318,7 +1323,7 @@ App::post('/v1/functions/:functionId/executions') ->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', '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) + ->param('headers', [], new Assoc(), 'HTTP headers of execution. Defaults to empty.', true) ->inject('response') ->inject('project') ->inject('dbForProject') @@ -1476,11 +1481,9 @@ App::post('/v1/functions/:functionId/executions') $vars = []; // Shared vars - $varsShared = $project->getAttribute('variables', []); - $vars = \array_merge($vars, \array_reduce($varsShared, function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; - return $carry; - }, [])); + foreach ($project->getAttribute('variables', []) as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value', ''); + } // Function vars $vars = \array_merge($vars, array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { @@ -1825,7 +1828,12 @@ App::get('/v1/functions/:functionId/variables/:variableId') } $variable = $dbForProject->getDocument('variables', $variableId); - if ($variable === false || $variable->isEmpty() || $variable->getAttribute('resourceInternalId') !== $function->getInternalId() || $variable->getAttribute('resourceType') !== 'function') { + if ( + $variable === false || + $variable->isEmpty() || + $variable->getAttribute('resourceInternalId') !== $function->getInternalId() || + $variable->getAttribute('resourceType') !== 'function' + ) { throw new Exception(Exception::VARIABLE_NOT_FOUND); } diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 0a5153df0..c55dc0e4d 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -56,7 +56,7 @@ App::post('/v1/proxy/rules') $message .= '.'; } else { - $message = "Domain already assigned to different project."; + $message = 'Domain already assigned to different project.'; } throw new Exception(Exception::RULE_ALREADY_EXISTS, $message); diff --git a/app/controllers/general.php b/app/controllers/general.php index 11a83933e..7b3353446 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -204,7 +204,7 @@ App::init() Request::setRoute($route); if ($route === null) { - return $response->setStatusCode(404)->send("Not Found"); + return $response->setStatusCode(404)->send('Not Found'); } $requestFormat = $request->getHeader('x-appwrite-response-format', App::getEnv('_APP_SYSTEM_RESPONSE_FORMAT', '')); diff --git a/app/workers/builds.php b/app/workers/builds.php index 11ec44f12..f9fc66f2f 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -330,14 +330,15 @@ class BuildsV1 extends Worker $vars = []; - // global vars - $vars = \array_merge($vars, \array_reduce($dbForProject->find('variables', [ + // Global vars + $varsFromProject = $dbForProject->find('variables', [ Query::equal('resourceType', ['project']), Query::limit(APP_LIMIT_SUBQUERY) - ]), function (array $carry, Document $var) { - $carry[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; - return $carry; - }, [])); + ]); + + foreach ($varsFromProject as $var) { + $vars[$var->getAttribute('key')] = $var->getAttribute('value') ?? ''; + } // Function vars $vars = \array_merge($vars, array_reduce($function->getAttribute('vars', []), function (array $carry, Document $var) { diff --git a/composer.json b/composer.json index 85813760a..2a915f2d8 100644 --- a/composer.json +++ b/composer.json @@ -85,7 +85,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "dev-master as 0.33.99", + "appwrite/sdk-generator": "0.34.*", "ext-fileinfo": "*", "phpunit/phpunit": "9.5.20", "squizlabs/php_codesniffer": "^3.7", diff --git a/composer.lock b/composer.lock index dd63ef401..b154e1854 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a7de7a77dd4c58b74bc8fe9c0387979e", + "content-hash": "98cd1f694dc31ab2091b55110664a311", "packages": [ { "name": "adhocore/jwt", @@ -727,16 +727,16 @@ }, { "name": "matomo/device-detector", - "version": "6.1.4", + "version": "6.1.5", "source": { "type": "git", "url": "https://github.com/matomo-org/device-detector.git", - "reference": "74f6c4f6732b3ad6cdf25560746841d522969112" + "reference": "40ca2990dba2c1719e5c62168e822e0b86c167d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/74f6c4f6732b3ad6cdf25560746841d522969112", - "reference": "74f6c4f6732b3ad6cdf25560746841d522969112", + "url": "https://api.github.com/repos/matomo-org/device-detector/zipball/40ca2990dba2c1719e5c62168e822e0b86c167d4", + "reference": "40ca2990dba2c1719e5c62168e822e0b86c167d4", "shasum": "" }, "require": { @@ -792,7 +792,7 @@ "source": "https://github.com/matomo-org/matomo", "wiki": "https://dev.matomo.org/" }, - "time": "2023-08-02T08:48:53+00:00" + "time": "2023-08-17T16:17:41+00:00" }, { "name": "mongodb/mongodb", @@ -2564,6 +2564,12 @@ "url": "https://github.com/utopia-php/vcs.git", "reference": "fc9c38a3f84a4391470cc7184199dec6f953b144" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/fc9c38a3f84a4391470cc7184199dec6f953b144", + "reference": "fc9c38a3f84a4391470cc7184199dec6f953b144", + "shasum": "" + }, "require": { "adhocore/jwt": "^1.1", "php": ">=8.0", @@ -2582,25 +2588,7 @@ "Utopia\\Detector\\": "src/Detector" } }, - "autoload-dev": { - "psr-4": { - "Utopia\\Tests\\": "tests/VCS" - } - }, - "scripts": { - "lint": [ - "./vendor/bin/pint --test --config pint.json" - ], - "format": [ - "./vendor/bin/pint --config pint.json" - ], - "check": [ - "./vendor/bin/phpstan analyse --level 8 -c phpstan.neon src tests" - ], - "test": [ - "./vendor/bin/phpunit --configuration phpunit.xml --debug" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -2611,6 +2599,10 @@ "utopia", "vcs" ], + "support": { + "issues": "https://github.com/utopia-php/vcs/issues", + "source": "https://github.com/utopia-php/vcs/tree/0.1.0" + }, "time": "2023-08-09T20:48:51+00:00" }, { @@ -2798,7 +2790,7 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "dev-master", + "version": "0.34.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", @@ -2823,7 +2815,6 @@ "phpunit/phpunit": "^9.5.21", "squizlabs/php_codesniffer": "^3.6" }, - "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -2844,7 +2835,7 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/master" + "source": "https://github.com/appwrite/sdk-generator/tree/0.34.0" }, "time": "2023-07-25T01:15:31+00:00" }, @@ -3150,16 +3141,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.16.0", + "version": "v4.17.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/19526a33fb561ef417e822e85f08a00db4059c17", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -3200,9 +3191,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.16.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" }, - "time": "2023-06-25T14:52:30+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "phar-io/manifest", @@ -3427,16 +3418,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.2", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d" + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b2fe4d22a5426f38e014855322200b97b5362c0d", - "reference": "b2fe4d22a5426f38e014855322200b97b5362c0d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", "shasum": "" }, "require": { @@ -3479,9 +3470,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" }, - "time": "2023-05-30T18:13:47+00:00" + "time": "2023-08-12T11:01:26+00:00" }, { "name": "phpspec/prophecy", @@ -5409,18 +5400,9 @@ "time": "2023-07-26T07:16:09+00:00" } ], - "aliases": [ - { - "package": "appwrite/sdk-generator", - "version": "9999999-dev", - "alias": "0.33.99", - "alias_normalized": "0.33.99.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/sdk-generator": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Utopia/Response/Filters/V12.php b/src/Appwrite/Utopia/Response/Filters/V12.php index aaf885996..d9e4caacf 100644 --- a/src/Appwrite/Utopia/Response/Filters/V12.php +++ b/src/Appwrite/Utopia/Response/Filters/V12.php @@ -81,7 +81,6 @@ class V12 extends Filter case Response::MODEL_WEBHOOK_LIST: case Response::MODEL_KEY_LIST: case Response::MODEL_PLATFORM_LIST: - // case Response::MODEL_DOMAIN_LIST: case Response::MODEL_COUNTRY_LIST: case Response::MODEL_CONTINENT_LIST: case Response::MODEL_LANGUAGE_LIST: diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index cb817be31..4ee1625f8 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -100,8 +100,6 @@ class Executor } /** - * - * * Listen to realtime logs stream of a runtime * * @param string $deploymentId diff --git a/tests/unit/Utopia/Response/Filters/V15Test.php b/tests/unit/Utopia/Response/Filters/V15Test.php index 50fb654c4..e174a6c3c 100644 --- a/tests/unit/Utopia/Response/Filters/V15Test.php +++ b/tests/unit/Utopia/Response/Filters/V15Test.php @@ -562,40 +562,6 @@ class V15Test extends TestCase $this->assertEquals($expected, $result); } - // /** - // * @dataProvider createdAtUpdatedAtProvider - // */ - // public function testDomain(array $content, array $expected): void - // { - // $model = Response::MODEL_DOMAIN; - - // $result = $this->filter->parse($content, $model); - - // $this->assertEquals($expected, $result); - // } - - // /** - // * @dataProvider createdAtUpdatedAtProvider - // */ - // public function testDomainList(array $content, array $expected): void - // { - // $model = Response::MODEL_DOMAIN_LIST; - - // $content = [ - // 'domains' => [$content], - // 'total' => 1, - // ]; - - // $expected = [ - // 'domains' => [$expected], - // 'total' => 1, - // ]; - - // $result = $this->filter->parse($content, $model); - - // $this->assertEquals($expected, $result); - // } - public function executionProvider(): array { return [