From c27fb0f000d69d564d0197c9ede22efa196a7569 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sat, 31 Jul 2021 07:58:33 +0300 Subject: [PATCH] work in progress --- app/config/services.php | 26 +++---- app/controllers/web/home.php | 2 +- composer.lock | 67 ++++++++++--------- src/Appwrite/Utopia/Response.php | 3 - .../Utopia/Response/Model/Project.php | 28 +++++--- .../Utopia/Response/Model/ServiceStatus.php | 51 -------------- 6 files changed, 66 insertions(+), 111 deletions(-) delete mode 100644 src/Appwrite/Utopia/Response/Model/ServiceStatus.php diff --git a/app/config/services.php b/app/config/services.php index af55d0d6e..e3af7fbe5 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -10,7 +10,7 @@ return [ 'docs' => false, 'tests' => false, ], - 'console/' => [ + 'console' => [ 'key' => 'console', 'name' => 'Console', 'controller' => 'web/console.php', @@ -18,7 +18,7 @@ return [ 'docs' => false, 'tests' => false, ], - 'v1/account' => [ + 'account' => [ 'key' => 'account', 'name' => 'Account', 'subtitle' => 'The Account service allows you to authenticate and manage a user account.', @@ -28,7 +28,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/avatars' => [ + 'avatars' => [ 'key' => 'avatars', 'name' => 'Avatars', 'subtitle'=> 'The Avatars service aims to help you complete everyday tasks related to your app image, icons, and avatars.', @@ -38,7 +38,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/database' => [ + 'database' => [ 'key' => 'database', 'name' => 'Database', 'subtitle' => 'The Database service allows you to create structured collections of documents, query and filter lists of documents', @@ -48,7 +48,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/locale' => [ + 'locale' => [ 'key' => 'locale', 'name' => 'Locale', 'subtitle' => 'The Locale service allows you to customize your app based on your users\' location.', @@ -58,7 +58,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/health' => [ + 'health' => [ 'key' => 'health', 'name' => 'Health', 'subtitle' => 'The Health service allows you to both validate and monitor your Appwrite server\'s health.', @@ -68,7 +68,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/projects' => [ + 'projects' => [ 'key' => 'projects', 'name' => 'Projects', 'subtitle' => 'The Project service allows you to manage all the projects in your Appwrite server.', @@ -77,7 +77,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/storage' => [ + 'storage' => [ 'key' => 'storage', 'name' => 'Storage', 'subtitle' => 'The Storage service allows you to manage your project files.', @@ -87,7 +87,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/teams' => [ + 'teams' => [ 'key' => 'teams', 'name' => 'Teams', 'subtitle' => 'The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources', @@ -97,7 +97,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/users' => [ + 'users' => [ 'key' => 'users', 'name' => 'Users', 'subtitle' => 'The Users service allows you to manage your project users.', @@ -107,7 +107,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/functions' => [ + 'functions' => [ 'key' => 'functions', 'name' => 'Functions', 'subtitle' => 'The Functions Service allows you view, create and manage your Cloud Functions.', @@ -117,7 +117,7 @@ return [ 'docs' => true, 'tests' => false, ], - 'v1/mock' => [ + 'mock' => [ 'key' => 'mock', 'name' => 'Mock', 'subtitle' => '', @@ -127,7 +127,7 @@ return [ 'docs' => false, 'tests' => true, ], - 'v1/graphql' => [ + 'graphql' => [ 'key' => 'graphql', 'name' => 'GraphQL', 'subtitle' => 'Appwrite\'s GraphQL Endpoint', diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index 938b14b6f..88ea95af2 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -395,7 +395,7 @@ App::get('/specs/:format') } } - foreach (Config::getParam('services', []) as $key => $service) { + foreach (Config::getParam('services', []) as $service) { if(!isset($service['docs']) // Skip service if not part of the public API || !isset($service['sdk']) || !$service['docs'] diff --git a/composer.lock b/composer.lock index 120590859..857c74dcb 100644 --- a/composer.lock +++ b/composer.lock @@ -1583,16 +1583,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0" + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0", - "reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", "shasum": "" }, "require": { @@ -1646,7 +1646,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" }, "funding": [ { @@ -1662,7 +1662,7 @@ "type": "tidelift" } ], - "time": "2021-02-19T12:13:01+00:00" + "time": "2021-07-28T13:41:28+00:00" }, { "name": "utopia-php/abuse", @@ -5298,16 +5298,16 @@ }, { "name": "symfony/console", - "version": "v5.3.2", + "version": "v5.3.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1" + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/649730483885ff2ca99ca0560ef0e5f6b03f2ac1", - "reference": "649730483885ff2ca99ca0560ef0e5f6b03f2ac1", + "url": "https://api.github.com/repos/symfony/console/zipball/51b71afd6d2dc8f5063199357b9880cea8d8bfe2", + "reference": "51b71afd6d2dc8f5063199357b9880cea8d8bfe2", "shasum": "" }, "require": { @@ -5315,11 +5315,12 @@ "symfony/deprecation-contracts": "^2.1", "symfony/polyfill-mbstring": "~1.0", "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.15", + "symfony/polyfill-php80": "^1.16", "symfony/service-contracts": "^1.1|^2", "symfony/string": "^5.1" }, "conflict": { + "psr/log": ">=3", "symfony/dependency-injection": "<4.4", "symfony/dotenv": "<5.1", "symfony/event-dispatcher": "<4.4", @@ -5327,10 +5328,10 @@ "symfony/process": "<4.4" }, "provide": { - "psr/log-implementation": "1.0" + "psr/log-implementation": "1.0|2.0" }, "require-dev": { - "psr/log": "~1.0", + "psr/log": "^1|^2", "symfony/config": "^4.4|^5.0", "symfony/dependency-injection": "^4.4|^5.0", "symfony/event-dispatcher": "^4.4|^5.0", @@ -5376,7 +5377,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.3.2" + "source": "https://github.com/symfony/console/tree/v5.3.6" }, "funding": [ { @@ -5392,7 +5393,7 @@ "type": "tidelift" } ], - "time": "2021-06-12T09:42:48+00:00" + "time": "2021-07-27T19:10:22+00:00" }, { "name": "symfony/deprecation-contracts", @@ -5463,16 +5464,16 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab" + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/24b72c6baa32c746a4d0840147c9715e42bb68ab", - "reference": "24b72c6baa32c746a4d0840147c9715e42bb68ab", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", + "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", "shasum": "" }, "require": { @@ -5524,7 +5525,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" }, "funding": [ { @@ -5540,7 +5541,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:17:38+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-intl-normalizer", @@ -5628,16 +5629,16 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.23.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1" + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2df51500adbaebdc4c38dea4c89a2e131c45c8a1", - "reference": "2df51500adbaebdc4c38dea4c89a2e131c45c8a1", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", "shasum": "" }, "require": { @@ -5688,7 +5689,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" }, "funding": [ { @@ -5704,7 +5705,7 @@ "type": "tidelift" } ], - "time": "2021-05-27T09:27:20+00:00" + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-php73", @@ -5949,16 +5950,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "75a63c33a8577608444246075ea0af0d052e452a" + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", - "reference": "75a63c33a8577608444246075ea0af0d052e452a", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "shasum": "" }, "require": { @@ -5987,7 +5988,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/master" + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" }, "funding": [ { @@ -5995,7 +5996,7 @@ "type": "github" } ], - "time": "2020-07-12T23:59:07+00:00" + "time": "2021-07-28T10:34:58+00:00" }, { "name": "twig/twig", diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index ab75b23a2..981d18f4b 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -44,7 +44,6 @@ use Appwrite\Utopia\Response\Model\Token; use Appwrite\Utopia\Response\Model\Webhook; use Appwrite\Utopia\Response\Model\Preferences; use Appwrite\Utopia\Response\Model\Mock; // Keep last -use Appwrite\Utopia\Response\Model\ServiceStatus; use stdClass; /** @@ -116,7 +115,6 @@ class Response extends SwooleResponse // Project const MODEL_PROJECT = 'project'; - const MODEL_SERVICE_STATUS = 'serviceStatus'; const MODEL_PROJECT_LIST = 'projectList'; const MODEL_WEBHOOK = 'webhook'; const MODEL_WEBHOOK_LIST = 'webhookList'; @@ -201,7 +199,6 @@ class Response extends SwooleResponse ->setModel(new Tag()) ->setModel(new Execution()) ->setModel(new Project()) - ->setModel(new ServiceStatus()) ->setModel(new Webhook()) ->setModel(new Key()) ->setModel(new Task()) diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php index 2dd7e2ec5..f74edb4e7 100644 --- a/src/Appwrite/Utopia/Response/Model/Project.php +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -2,9 +2,9 @@ namespace Appwrite\Utopia\Response\Model; +use stdClass; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; -use stdClass; use Utopia\Config\Config; class Project extends Model @@ -95,13 +95,6 @@ class Project extends Model 'default' => 0, 'example' => 100, ]) - ->addRule('statusForServices', [ - 'type' => Response::MODEL_PLATFORM, - 'description' => 'List of Platforms.', - 'default' => [], - 'example' => new stdClass, - 'array' => true, - ]) ->addRule('platforms', [ 'type' => Response::MODEL_PLATFORM, 'description' => 'List of Platforms.', @@ -110,8 +103,8 @@ class Project extends Model 'array' => true, ]) ->addRule('webhooks', [ - 'type' => Response::MODEL_ANY, - 'description' => 'List of service status.', + 'type' => Response::MODEL_WEBHOOK, + 'description' => 'List of Webhooks.', 'default' => [], 'example' => new stdClass, 'array' => true, @@ -139,6 +132,7 @@ class Project extends Model ]) ; + $services = Config::getParam('services', []); $providers = Config::getParam('providers', []); $auth = Config::getParam('auth', []); @@ -178,6 +172,20 @@ class Project extends Model ]) ; } + + foreach ($services as $index => $service) { + $name = $method['name'] ?? ''; + $key = $method['key'] ?? ''; + + $this + ->addRule($key, [ + 'type' => self::TYPE_BOOLEAN, + 'description' => $name.' auth method status', + 'example' => true, + 'default' => true, + ]) + ; + } } /** diff --git a/src/Appwrite/Utopia/Response/Model/ServiceStatus.php b/src/Appwrite/Utopia/Response/Model/ServiceStatus.php deleted file mode 100644 index 7d0758313..000000000 --- a/src/Appwrite/Utopia/Response/Model/ServiceStatus.php +++ /dev/null @@ -1,51 +0,0 @@ -addRule('service', [ - 'type' => self::TYPE_STRING, - 'description' => 'Service name.', - 'default' => '', - 'example' => 'teams', - ]) - ->addRule('status', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Status of the service', - 'default' => true, - 'example' => true, - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'ServiceStatus'; - } - - /** - * Get Collection - * - * @return string - */ - public function getType():string - { - return Response::MODEL_SERVICE_STATUS; - } -} \ No newline at end of file