From 0450604d27d858bf7d5fcff75bb938d5d4d79424 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 29 Oct 2020 15:07:56 +0200 Subject: [PATCH 1/3] Added external swoole lib and extended response class --- app/controllers/api/account.php | 22 +- app/controllers/api/database.php | 2 +- app/controllers/api/locale.php | 2 +- app/controllers/api/storage.php | 4 +- app/controllers/api/teams.php | 2 +- app/controllers/general.php | 10 +- app/controllers/shared/api.php | 2 +- app/controllers/shared/web.php | 2 +- app/controllers/web/home.php | 2 +- app/http.php | 4 +- app/init.php | 8 +- composer.json | 1 + src/Appwrite/Swoole/Files.php | 176 --------- src/Appwrite/Swoole/Request.php | 339 ------------------ src/Appwrite/Swoole/Response.php | 138 ------- src/Appwrite/Utopia/Response.php | 172 +++++++-- src/Appwrite/Utopia/Response/Model.php | 12 +- src/Appwrite/Utopia/Response/Model/Any.php | 34 ++ .../Utopia/Response/Model/BaseList.php | 35 +- .../Utopia/Response/Model/Collection.php | 68 ++++ .../Utopia/Response/Model/Continent.php | 45 +++ .../Utopia/Response/Model/Country.php | 45 +++ .../Utopia/Response/Model/Currency.php | 76 ++++ src/Appwrite/Utopia/Response/Model/Domain.php | 60 ++++ .../Utopia/Response/Model/Execution.php | 80 +++++ src/Appwrite/Utopia/Response/Model/File.php | 41 ++- src/Appwrite/Utopia/Response/Model/Func.php | 108 ++++++ src/Appwrite/Utopia/Response/Model/Key.php | 57 +++ .../Utopia/Response/Model/Language.php | 50 +++ src/Appwrite/Utopia/Response/Model/Log.php | 105 +++++- .../Utopia/Response/Model/MembershipList.php | 41 --- .../Utopia/Response/Model/Permissions.php | 47 +++ src/Appwrite/Utopia/Response/Model/Phone.php | 50 +++ .../Utopia/Response/Model/Platform.php | 77 ++++ .../Utopia/Response/Model/Project.php | 166 +++++++++ src/Appwrite/Utopia/Response/Model/Rule.php | 83 +++++ .../Utopia/Response/Model/Session.php | 96 ++++- src/Appwrite/Utopia/Response/Model/Tag.php | 60 ++++ src/Appwrite/Utopia/Response/Model/Task.php | 125 +++++++ .../Utopia/Response/Model/TeamList.php | 41 --- src/Appwrite/Utopia/Response/Model/User.php | 7 +- .../Utopia/Response/Model/Webhook.php | 74 ++++ tests/unit/Swoole/FilesTest.php | 48 --- 43 files changed, 1759 insertions(+), 858 deletions(-) delete mode 100644 src/Appwrite/Swoole/Files.php delete mode 100644 src/Appwrite/Swoole/Request.php delete mode 100644 src/Appwrite/Swoole/Response.php create mode 100644 src/Appwrite/Utopia/Response/Model/Any.php create mode 100644 src/Appwrite/Utopia/Response/Model/Collection.php create mode 100644 src/Appwrite/Utopia/Response/Model/Continent.php create mode 100644 src/Appwrite/Utopia/Response/Model/Country.php create mode 100644 src/Appwrite/Utopia/Response/Model/Currency.php create mode 100644 src/Appwrite/Utopia/Response/Model/Domain.php create mode 100644 src/Appwrite/Utopia/Response/Model/Execution.php create mode 100644 src/Appwrite/Utopia/Response/Model/Func.php create mode 100644 src/Appwrite/Utopia/Response/Model/Key.php create mode 100644 src/Appwrite/Utopia/Response/Model/Language.php delete mode 100644 src/Appwrite/Utopia/Response/Model/MembershipList.php create mode 100644 src/Appwrite/Utopia/Response/Model/Permissions.php create mode 100644 src/Appwrite/Utopia/Response/Model/Phone.php create mode 100644 src/Appwrite/Utopia/Response/Model/Platform.php create mode 100644 src/Appwrite/Utopia/Response/Model/Project.php create mode 100644 src/Appwrite/Utopia/Response/Model/Rule.php create mode 100644 src/Appwrite/Utopia/Response/Model/Tag.php create mode 100644 src/Appwrite/Utopia/Response/Model/Task.php delete mode 100644 src/Appwrite/Utopia/Response/Model/TeamList.php create mode 100644 src/Appwrite/Utopia/Response/Model/Webhook.php delete mode 100644 tests/unit/Swoole/FilesTest.php diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 9d6785309a..658b200ec6 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -55,7 +55,7 @@ App::post('/v1/account') ->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $webhooks, $audits) use ($oauth2Keys) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ @@ -160,7 +160,7 @@ App::post('/v1/account/sessions') ->param('email', '', new Email(), 'User email.') ->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.') ->action(function ($email, $password, $request, $response, $projectDB, $webhooks, $audits) { - /** @var Appwrite\Swoole\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ @@ -261,7 +261,7 @@ App::get('/v1/account/sessions/oauth2/:provider') ->param('failure', $oauthDefaultFailure, function ($clients) { return new Host($clients); }, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['clients']) ->param('scopes', [], new ArrayList(new Text(128)), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.', true) ->action(function ($provider, $success, $failure, $scopes, $request, $response, $project) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ @@ -306,7 +306,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->param('code', '', new Text(1024), 'OAuth2 code.') ->param('state', '', new Text(2048), 'Login state params.', true) ->action(function ($projectId, $provider, $code, $state, $request, $response) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ $domain = $request->getHostname(); @@ -331,7 +331,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->param('code', '', new Text(1024), 'OAuth2 code.') ->param('state', '', new Text(2048), 'Login state params.', true) ->action(function ($projectId, $provider, $code, $state, $request, $response) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ $domain = $request->getHostname(); @@ -357,7 +357,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->param('code', '', new Text(1024), 'OAuth2 code.') ->param('state', '', new Text(2048), 'OAuth2 state params.', true) ->action(function ($provider, $code, $state, $request, $response, $project, $user, $projectDB, $audits) use ($oauthDefaultSuccess) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ @@ -944,7 +944,7 @@ App::delete('/v1/account') ->label('sdk.method', 'delete') ->label('sdk.description', '/docs/references/account/delete.md') ->action(function ($request, $response, $user, $projectDB, $audits, $webhooks) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -1007,7 +1007,7 @@ App::delete('/v1/account/sessions/:sessionId') ->label('abuse-limit', 100) ->param('sessionId', null, new UID(), 'Session unique ID. Use the string \'current\' to delete the current device session.') ->action(function ($sessionId, $request, $response, $user, $projectDB, $audits, $webhooks) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -1071,7 +1071,7 @@ App::delete('/v1/account/sessions') ->label('sdk.description', '/docs/references/account/delete-sessions.md') ->label('abuse-limit', 100) ->action(function ($request, $response, $user, $projectDB, $audits, $webhooks) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -1129,7 +1129,7 @@ App::post('/v1/account/recovery') ->param('email', '', new Email(), 'User email.') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) ->action(function ($email, $url, $request, $response, $projectDB, $project, $locale, $mails, $audits) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Database\Document $project */ @@ -1306,7 +1306,7 @@ App::post('/v1/account/verification') ->label('abuse-key', 'url:{url},email:{param-email}') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add built-in confirm page ->action(function ($url, $request, $response, $project, $user, $projectDB, $locale, $audits, $mails) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index bd19935754..a24de80887 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -529,7 +529,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId') ->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') ->param('documentId', null, new UID(), 'Document unique ID.') ->action(function ($collectionId, $documentId, $request, $response, $projectDB) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index aa6fa92780..26b90cfea2 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -12,7 +12,7 @@ App::get('/v1/locale') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/locale/get-locale.md') ->action(function ($request, $response, $locale, $geodb) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 18cfb58f46..55ae740373 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -37,7 +37,7 @@ App::post('/v1/storage/files') ->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->action(function ($file, $read, $write, $request, $response, $user, $projectDB, $webhooks, $audits, $usage) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -233,7 +233,7 @@ App::get('/v1/storage/files/:fileId/preview') ->param('background', '', new HexColor(), 'Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.', true) ->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true) ->action(function ($fileId, $width, $height, $quality, $background, $output, $request, $response, $project, $projectDB) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ae9e44015f..ab0db7a259 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -480,7 +480,7 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status') ->param('userId', '', new UID(), 'User unique ID.') ->param('secret', '', new Text(256), 'Secret key.') ->action(function ($teamId, $inviteId, $userId, $secret, $request, $response, $user, $projectDB, $audits) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ diff --git a/app/controllers/general.php b/app/controllers/general.php index 5aae62ac3c..b83630a23d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -3,7 +3,7 @@ require_once __DIR__.'/../init.php'; use Utopia\App; -use Appwrite\Swoole\Request; +use Utopia\Swoole\Request; use Appwrite\Utopia\Response; use Utopia\View; use Utopia\Exception; @@ -22,7 +22,7 @@ Config::setParam('cookieDomain', 'localhost'); Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE); App::init(function ($utopia, $request, $response, $console, $project, $user, $locale, $webhooks, $audits, $usage, $clients) { - /** @var Appwrite\Swoole\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $console */ /** @var Appwrite\Database\Document $project */ @@ -246,7 +246,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audits, $usage, $deletes, $mode) { /** @var Utopia\App $utopia */ - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Event\Event $webhooks */ @@ -282,7 +282,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audi }, ['utopia', 'request', 'response', 'project', 'webhooks', 'audits', 'usage', 'deletes', 'mode']); App::options(function ($request, $response) { - /** @var Appwrite\Swoole\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ $origin = $request->getOrigin(); @@ -300,7 +300,7 @@ App::options(function ($request, $response) { App::error(function ($error, $utopia, $request, $response, $layout, $project) { /** @var Exception $error */ /** @var Utopia\App $utopia */ - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\View $layout */ /** @var Appwrite\Database\Document $project */ diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 3fdca7cf17..a1a4d6cf65 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -7,7 +7,7 @@ use Utopia\Abuse\Adapters\TimeLimit; App::init(function ($utopia, $request, $response, $project, $user, $register) { /** @var Utopia\App $utopia */ - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ diff --git a/app/controllers/shared/web.php b/app/controllers/shared/web.php index 3452cd3535..383685e0d0 100644 --- a/app/controllers/shared/web.php +++ b/app/controllers/shared/web.php @@ -5,7 +5,7 @@ use Utopia\Config\Config; App::init(function ($utopia, $request, $response, $layout) { /** @var Utopia\App $utopia */ - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Utopia\View $layout */ diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index a6c2491c0f..f2cf21ffd5 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -189,7 +189,7 @@ App::get('/open-api-2.json') ->param('tests', 0, new Range(0, 1), 'Include only test services.', true) ->action(function ($platform, $extensions, $tests, $utopia, $request, $response) { /** @var Utopia\App $utopia */ - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ $security = [ diff --git a/app/http.php b/app/http.php index 89b3d1f9e8..5bbdc87dfc 100644 --- a/app/http.php +++ b/app/http.php @@ -3,8 +3,8 @@ require_once __DIR__.'/../vendor/autoload.php'; use Appwrite\Swoole\Files; -use Appwrite\Swoole\Request; -use Appwrite\Swoole\Response; +use Utopia\Swoole\Request; +use Appwrite\Utopia\Response; use Swoole\Process; use Swoole\Http\Server; use Swoole\Http\Request as SwooleRequest; diff --git a/app/init.php b/app/init.php index d24ca9d281..8c3457dd3a 100644 --- a/app/init.php +++ b/app/init.php @@ -361,7 +361,7 @@ App::setResource('clients', function($console, $project) { }, ['console', 'project']); App::setResource('user', function($mode, $project, $console, $request, $response, $projectDB, $consoleDB) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $consoleDB */ @@ -423,7 +423,7 @@ App::setResource('user', function($mode, $project, $console, $request, $response }, ['mode', 'project', 'console', 'request', 'response', 'projectDB', 'consoleDB']); App::setResource('project', function($consoleDB, $request) { - /** @var Appwrite\Swoole\Request $request */ + /** @var Utopia\Swoole\Request $request */ /** @var Appwrite\Database\Database $consoleDB */ Authorization::disable(); @@ -460,11 +460,11 @@ App::setResource('projectDB', function($register, $project) { }, ['register', 'project']); App::setResource('mode', function($request) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ return $request->getParam('mode', $request->getHeader('x-appwrite-mode', 'default')); }, ['request']); App::setResource('geodb', function($request) { - /** @var Utopia\Request $request */ + /** @var Utopia\Swoole\Request $request */ return new Reader(__DIR__.'/db/DBIP/dbip-country-lite-2020-01.mmdb'); }, ['request']); diff --git a/composer.json b/composer.json index bf121686a8..1a60237d43 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,7 @@ "utopia-php/registry": "0.2.*", "utopia-php/preloader": "0.2.*", "utopia-php/domains": "0.2.*", + "utopia-php/swoole": "0.2.*", "resque/php-resque": "1.3.6", "piwik/device-detector": "3.13.0", diff --git a/src/Appwrite/Swoole/Files.php b/src/Appwrite/Swoole/Files.php deleted file mode 100644 index 7971beba2b..0000000000 --- a/src/Appwrite/Swoole/Files.php +++ /dev/null @@ -1,176 +0,0 @@ - 'text/css', - 'js' => 'text/javascript', - 'svg' => 'image/svg+xml', - ]; - - /** - * Add MimeType - * - * @var string $mimeType - * - * @return void - */ - public static function addMimeType(string $mimeType): void - { - self::$mimeTypes[$mimeType] = true; - } - - /** - * Remove MimeType - * - * @var string $mimeType - * - * @return void - */ - public static function removeMimeType(string $mimeType): void - { - if(isset(self::$mimeTypes[$mimeType])) { - unset(self::$mimeTypes[$mimeType]); - } - } - - /** - * Get MimeType List - * - * @return array - */ - public static function getMimeTypes(): array - { - return self::$mimeTypes; - } - - /** - * Get Files Loaded Count - * - * @return int - */ - public static function getCount(): int - { - return self::$count; - } - - /** - * Load - * - * @var string $path - * - * @return void - */ - public static function load(string $directory, string $root = null): void - { - if(!is_readable($directory)) { - throw new Exception('Failed to load directory: '.$directory); - } - - $directory = realpath($directory); - - $root = ($root) ? $root : $directory; - - $handle = opendir($directory); - - while ($path = readdir($handle)) { - $extension = pathinfo($path, PATHINFO_EXTENSION); - - if (in_array($path, ['.', '..'])) { - continue; - } - - if (in_array($extension, ['php', 'phtml'])) { - continue; - } - - if(substr($path, 0, 1) === '.') { - continue; - } - - if (is_dir($directory.'/'.$path)) { - self::load($directory.'/'.$path, $root); - continue; - } - - self::$count++; - - self::$loaded[substr($directory.'/'.$path , strlen($root))] = [ - 'contents' => file_get_contents($directory.'/'.$path), - 'mimeType' => (array_key_exists($extension, self::$extensions)) - ? self::$extensions[$extension] - : mime_content_type($directory.'/'.$path) - ]; - } - - closedir($handle); - - if($directory === $root) { - echo '[Static Files] Loadded '.self::$count.' files'.PHP_EOL; - } - } - - /** - * Is File Loaded - * - * @var string $uri - */ - public static function isFileLoaded(string $uri): bool - { - if(!array_key_exists($uri, self::$loaded)) { - return false; - } - - return true; - } - - /** - * Get File Contants - * - * @var string $uri - */ - public static function getFileContents(string $uri): string - { - if(!array_key_exists($uri, self::$loaded)) { - throw new Exception('File not found or not loaded: '.$uri); - } - - return self::$loaded[$uri]['contents']; - } - - /** - * Get File MimeType - * - * @var string $uri - */ - public static function getFileMimeType(string $uri): string - { - if(!array_key_exists($uri, self::$loaded)) { - throw new Exception('File not found or not loaded: '.$uri); - } - - return self::$loaded[$uri]['mimeType']; - } -} diff --git a/src/Appwrite/Swoole/Request.php b/src/Appwrite/Swoole/Request.php deleted file mode 100644 index 4535924686..0000000000 --- a/src/Appwrite/Swoole/Request.php +++ /dev/null @@ -1,339 +0,0 @@ -swoole = $request; - } - - /** - * Get Param - * - * Get param by current method name - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function getParam(string $key, $default = null) - { - switch($this->getMethod()) { - case self::METHOD_GET: - return $this->getQuery($key, $default); - break; - case self::METHOD_POST: - case self::METHOD_PUT: - case self::METHOD_PATCH: - case self::METHOD_DELETE: - return $this->getPayload($key, $default); - break; - default: - return $this->getQuery($key, $default); - } - } - - /** - * Get Params - * - * Get all params of current method - * - * @return array - */ - public function getParams(): array - { - switch($this->getMethod()) { - case self::METHOD_GET: - return (!empty($this->swoole->get)) ? $this->swoole->get : []; - break; - case self::METHOD_POST: - case self::METHOD_PUT: - case self::METHOD_PATCH: - case self::METHOD_DELETE: - return $this->generateInput(); - break; - default: - return (!empty($this->swoole->get)) ? $this->swoole->get : []; - } - - return []; - } - - /** - * Get Query - * - * Method for querying HTTP GET request parameters. If $key is not found $default value will be returned. - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function getQuery(string $key, $default = null) - { - return (isset($this->swoole->get[$key])) ? $this->swoole->get[$key] : $default; - } - - /** - * Get payload - * - * Method for querying HTTP request payload parameters. If $key is not found $default value will be returned. - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function getPayload(string $key, $default = null) - { - $payload = $this->generateInput(); - - return (isset($payload[$key])) ? $payload[$key] : $default; - } - - /** - * Get server - * - * Method for querying server parameters. If $key is not found $default value will be returned. - * - * @param string $key - * @param mixed $default - * @return mixed - */ - public function getServer(string $key, $default = null) - { - return (isset($this->swoole->server) && isset($this->swoole->server[$key])) ? $this->swoole->server[$key] : $default; - } - - /** - * Get IP - * - * Returns users IP address. - * Support HTTP_X_FORWARDED_FOR header usually return - * from different proxy servers or PHP default REMOTE_ADDR - */ - public function getIP(): string - { - return $this->getHeader('x-forwarded-for', $this->getServer('remote_addr', '0.0.0.0')); - } - - /** - * Get Protocol - * - * Returns request protocol. - * Support HTTP_X_FORWARDED_PROTO header usually return - * from different proxy servers or PHP default REQUEST_SCHEME - * - * @return string - */ - public function getProtocol(): string - { - $protocol = $this->getHeader('x-forwarded-proto', $this->getServer('server_protocol', 'https')); - - if($protocol === 'HTTP/1.1') { - return 'http'; - } - - return $protocol; - } - - /** - * Get Port - * - * Returns request port. - * - * @return string - */ - public function getPort(): string - { - return $this->getHeader('x-forwarded-port', (string)\parse_url($this->getProtocol().'://'.$this->getHeader('x-forwarded-host', $this->getHeader('host')), PHP_URL_PORT)); - } - - /** - * Get Hostname - * - * Returns request hostname. - * - * @return string - */ - public function getHostname(): string - { - return \parse_url($this->getProtocol().'://'.$this->getHeader('x-forwarded-host', $this->getHeader('host')), PHP_URL_HOST); - } - - /** - * Get Method - * - * Return HTTP request method - * - * @return string - */ - public function getMethod(): string - { - return $this->getServer('request_method', 'UNKNOWN'); - } - - /** - * Get URI - * - * Return HTTP request URI - * - * @return string - */ - public function getURI(): string - { - return $this->getServer('request_uri', ''); - } - - /** - * Get Referer - * - * Return HTTP referer header - * - * @return string - */ - public function getReferer(string $default = ''): string - { - return $this->getHeader('referer', ''); - } - - /** - * Get Origin - * - * Return HTTP origin header - * - * @return string - */ - public function getOrigin(string $default = ''): string - { - return $this->getHeader('origin', $default); - } - - /** - * Get User Agent - * - * Return HTTP user agent header - * - * @return string - */ - public function getUserAgent(string $default = ''): string - { - return $this->getHeader('user-agent', $default); - } - - /** - * Get Accept - * - * Return HTTP accept header - * - * @return string - */ - public function getAccept(string $default = ''): string - { - return $this->getHeader('accept', $default); - } - - /** - * Get files - * - * Method for querying upload files data. If $key is not found empty array will be returned. - * - * @param string $key - * @return array - */ - public function getFiles($key): array - { - $key = strtolower($key); - return (isset($this->swoole->files[$key])) ? $this->swoole->files[$key] : []; - } - - /** - * Get cookie - * - * Method for querying HTTP cookie parameters. If $key is not found $default value will be returned. - * - * @param string $key - * @param string $default - * - * @return string - */ - public function getCookie(string $key, string $default = ''): string - { - $key = strtolower($key); - return (isset($this->swoole->cookie[$key])) ? $this->swoole->cookie[$key] : $default; - } - - /** - * Get header - * - * Method for querying HTTP header parameters. If $key is not found $default value will be returned. - * - * @param string $key - * @param string $default - * @return string - */ - public function getHeader(string $key, string $default = ''): string - { - return (isset($this->swoole->header[$key])) ? $this->swoole->header[$key] : $default; - } - - /** - * Generate input - * - * Generate PHP input stream and parse it as an array in order to handle different content type of requests - * - * @return array - */ - protected function generateInput(): array - { - if (null === $this->payload) { - $contentType = $this->getHeader('content-type'); - - // Get content-type without the charset - $length = strpos($contentType, ';'); - $length = (empty($length)) ? strlen($contentType) : $length; - $contentType = substr($contentType, 0, $length); - - switch ($contentType) { - case 'application/json': - $this->payload = json_decode($this->swoole->rawContent(), true); - break; - - default: - $this->payload = $this->swoole->post; - break; - } - - if(empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed - $this->payload = []; - } - } - - return $this->payload; - } - - /** - * Generate headers - * - * Parse request headers as an array for easy querying using the getHeader method - * - * @return array - */ - protected function generateHeaders(): array - { - return $this->swoole->header; - } -} \ No newline at end of file diff --git a/src/Appwrite/Swoole/Response.php b/src/Appwrite/Swoole/Response.php deleted file mode 100644 index 7661011460..0000000000 --- a/src/Appwrite/Swoole/Response.php +++ /dev/null @@ -1,138 +0,0 @@ - true, - 'text/css' => true, - 'text/javascript' => true, - 'application/javascript' => true, - 'text/html' => true, - 'text/html; charset=UTF-8' => true, - 'application/json' => true, - 'application/json; charset=UTF-8' => true, - 'image/svg+xml' => true, - 'application/xml+rss' => true, - ]; - - /** - * Response constructor. - */ - public function __construct(SwooleResponse $response) - { - $this->swoole = $response; - parent::__construct(\microtime(true)); - } - - /** - * Output response - * - * Generate HTTP response output including the response header (+cookies) and body and prints them. - * - * @param string $body - * @param int $exit exit code or don't exit if code is null - * - * @return void - */ - public function send(string $body = '', int $exit = null): void - { - if(!$this->disablePayload) { - $this->addHeader('X-Debug-Speed', (string)(microtime(true) - $this->startTime)); - - $this - ->appendCookies() - ->appendHeaders() - ; - - $chunk = 2000000; // Max chunk of 2 mb - $length = strlen($body); - - $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length; - - if(array_key_exists( - $this->contentType, - $this->compressed - ) && ($length <= $chunk)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb - $this->swoole->end($body); - } - else { - for ($i=0; $i < ceil($length / $chunk); $i++) { - $this->swoole->write(substr($body, ($i * $chunk), min((($i * $chunk) + $chunk), $length))); - } - - $this->swoole->end(); - } - - $this->disablePayload(); - } - } - - /** - * Append headers - * - * Iterating over response headers to generate them using native PHP header function. - * This method is also responsible for generating the response and content type headers. - * - * @return self - */ - protected function appendHeaders(): self - { - // Send status code header - $this->swoole->status((string)$this->statusCode); - - // Send content type header - $this - ->addHeader('Content-Type', $this->contentType) - ; - - // Set application headers - foreach ($this->headers as $key => $value) { - $this->swoole->header($key, $value); - } - - return $this; - } - - /** - * Append cookies - * - * Iterating over response cookies to generate them using native PHP cookie function. - * - * @return self - */ - protected function appendCookies(): self - { - foreach ($this->cookies as $cookie) { - $this->swoole->cookie( - $cookie['name'], - $cookie['value'], - $cookie['expire'], - $cookie['path'], - $cookie['domain'], - $cookie['secure'], - $cookie['httponly'], - $cookie['samesite'], - ); - } - - return $this; - } -} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index b2a9f5b5dd..66d1eaf18a 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -3,46 +3,79 @@ namespace Appwrite\Utopia; use Exception; +use Utopia\Swoole\Response as SwooleResponse; +use Swoole\Http\Response as SwooleHTTPResponse; use Appwrite\Database\Document; use Appwrite\Utopia\Response\Model; +use Appwrite\Utopia\Response\Model\Any; +use Appwrite\Utopia\Response\Model\BaseList; +use Appwrite\Utopia\Response\Model\Collection; +use Appwrite\Utopia\Response\Model\Continent; +use Appwrite\Utopia\Response\Model\Country; +use Appwrite\Utopia\Response\Model\Currency; +use Appwrite\Utopia\Response\Model\Domain; use Appwrite\Utopia\Response\Model\Error; use Appwrite\Utopia\Response\Model\ErrorDev; +use Appwrite\Utopia\Response\Model\Execution; +use Appwrite\Utopia\Response\Model\File; +use Appwrite\Utopia\Response\Model\Func; +use Appwrite\Utopia\Response\Model\Key; +use Appwrite\Utopia\Response\Model\Language; use Appwrite\Utopia\Response\Model\User; use Appwrite\Utopia\Response\Model\Session; use Appwrite\Utopia\Response\Model\Team; -use Appwrite\Utopia\Response\Model\TeamList; use Appwrite\Utopia\Response\Model\Locale; +use Appwrite\Utopia\Response\Model\Log; use Appwrite\Utopia\Response\Model\Membership; -use Appwrite\Utopia\Response\Model\MembershipList; -use Utopia\Response as UtopiaResponse; +use Appwrite\Utopia\Response\Model\Phone; +use Appwrite\Utopia\Response\Model\Platform; +use Appwrite\Utopia\Response\Model\Project; +use Appwrite\Utopia\Response\Model\Rule; +use Appwrite\Utopia\Response\Model\Tag; +use Appwrite\Utopia\Response\Model\Task; +use Appwrite\Utopia\Response\Model\Webhook; -class Response extends UtopiaResponse +class Response extends SwooleResponse { // General - const MODEL_LOG = 'log'; // - Missing + const MODEL_ANY = 'any'; + const MODEL_LOG = 'log'; + const MODEL_LOG_LIST = 'logList'; const MODEL_ERROR = 'error'; const MODEL_ERROR_DEV = 'errorDev'; const MODEL_BASE_LIST = 'baseList'; + const MODEL_PERMISSIONS = 'permissions'; + // Database + const MODEL_COLLECTION = 'collection'; + const MODEL_COLLECTION_LIST = 'collectionList'; + const MODEL_RULE = 'rule'; + const MODEL_DOCUMENT_LIST = 'documentList'; + // Users const MODEL_USER = 'user'; + const MODEL_USER_LIST = 'userList'; const MODEL_SESSION = 'session'; + const MODEL_SESSION_LIST = 'sessionList'; const MODEL_TOKEN = 'token'; // - Missing - - // Database - const MODEL_COLLECTION = 'collection'; // - Missing + // Storage + const MODEL_FILE = 'file'; + const MODEL_FILE_LIST = 'fileList'; + const MODEL_BUCKET = 'bucket'; // - Missing + // Locale const MODEL_LOCALE = 'locale'; - const MODEL_COUNTRY = 'country'; // - Missing - const MODEL_CONTINENT = 'continent'; // - Missing - const MODEL_CURRENCY = 'currency'; // - Missing - const MODEL_LANGUAGE = 'langauge'; // - Missing - const MODEL_PHONE = 'phone'; // - Missing - - // Storage - const MODEL_FILE = 'file'; // - Missing - const MODEL_BUCKET = 'bucket'; // - Missing + const MODEL_COUNTRY = 'country'; + const MODEL_COUNTRY_LIST = 'countryList'; + const MODEL_CONTINENT = 'continent'; + const MODEL_CONTINENT_LIST = 'continentList'; + const MODEL_CURRENCY = 'currency'; + const MODEL_CURRENCY_LIST = 'currencyList'; + const MODEL_LANGUAGE = 'langauge'; + const MODEL_LANGUAGE_LIST = 'langaugeList'; + const MODEL_PHONE = 'phone'; + const MODEL_PHONE_LIST = 'phoneList'; // Teams const MODEL_TEAM = 'team'; @@ -50,26 +83,97 @@ class Response extends UtopiaResponse const MODEL_MEMBERSHIP = 'membership'; const MODEL_MEMBERSHIP_LIST = 'membershipList'; + // Functions + const MODEL_FUNCTION = 'function'; + const MODEL_FUNCTION_LIST = 'functionList'; + const MODEL_TAG = 'tag'; + const MODEL_TAG_LIST = 'tagList'; + const MODEL_EXECUTION = 'execution'; + const MODEL_EXECUTION_LIST = 'executionList'; + + // Project + const MODEL_PROJECT = 'project'; + const MODEL_PROJECT_LIST = 'projectsList'; + const MODEL_WEBHOOK = 'webhook'; + const MODEL_WEBHOOK_LIST = 'webhookList'; + const MODEL_KEY = 'key'; + const MODEL_KEY_LIST = 'keyList'; + const MODEL_TASK = 'task'; + const MODEL_TASK_LIST = 'taskList'; + const MODEL_PLATFORM = 'platform'; + const MODEL_PLATFORM_LIST = 'platformList'; + const MODEL_DOMAIN = 'domain'; + const MODEL_DOMAIN_LIST = 'domainList'; + + /** + * @var array + */ + protected $payload = []; + /** * Response constructor. * * @param float $time */ - public function __construct(float $time = 0) + public function __construct(SwooleHTTPResponse $response) { $this + // General ->setModel(new Error()) ->setModel(new ErrorDev()) + // Lists + ->setModel(new BaseList('Collections List', self::MODEL_COLLECTION_LIST, 'collections', self::MODEL_COLLECTION)) + ->setModel(new BaseList('Documents List', self::MODEL_DOCUMENT_LIST, 'documents', self::MODEL_ANY)) + ->setModel(new BaseList('Users List', self::MODEL_USER_LIST, 'users', self::MODEL_USER)) + ->setModel(new BaseList('Sessions List', self::MODEL_SESSION_LIST, 'sessions', self::MODEL_SESSION)) + ->setModel(new BaseList('Logs List', self::MODEL_LOG_LIST, 'logs', self::MODEL_LOG, false)) + ->setModel(new BaseList('Files List', self::MODEL_FILE_LIST, 'files', self::MODEL_FILE)) + ->setModel(new BaseList('Teams List', self::MODEL_TEAM_LIST, 'teams', self::MODEL_TEAM)) + ->setModel(new BaseList('Memberships List', self::MODEL_MEMBERSHIP_LIST, 'memberships', self::MODEL_MEMBERSHIP)) + ->setModel(new BaseList('Functions List', self::MODEL_FUNCTION_LIST, 'functions', self::MODEL_FUNCTION)) + ->setModel(new BaseList('Tags List', self::MODEL_TAG_LIST, 'tags', self::MODEL_TAG)) + ->setModel(new BaseList('Executions List', self::MODEL_EXECUTION_LIST, 'executions', self::MODEL_EXECUTION)) + ->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT)) + ->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK)) + ->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY)) + ->setModel(new BaseList('Tasks List', self::MODEL_TASK_LIST, 'tasks', self::MODEL_TASK)) + ->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM)) + ->setModel(new BaseList('Domains List', self::MODEL_DOMAIN_LIST, 'domains', self::MODEL_DOMAIN)) + ->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY)) + ->setModel(new BaseList('Continents List', self::MODEL_CONTINENT_LIST, 'continents', self::MODEL_CONTINENT)) + ->setModel(new BaseList('Languages List', self::MODEL_LANGUAGE_LIST, 'languages', self::MODEL_LANGUAGE)) + ->setModel(new BaseList('Currencies List', self::MODEL_CURRENCY_LIST, 'currencies', self::MODEL_CURRENCY)) + ->setModel(new BaseList('Phones List', self::MODEL_PHONE_LIST, 'phones', self::MODEL_PHONE)) + // Entities + ->setModel(new Any()) + ->setModel(new Collection()) + ->setModel(new Rule()) + ->setModel(new Log()) ->setModel(new User()) ->setModel(new Session()) ->setModel(new Locale()) + ->setModel(new File()) ->setModel(new Team()) - ->setModel(new TeamList()) ->setModel(new Membership()) - ->setModel(new MembershipList()) + ->setModel(new Func()) + ->setModel(new Tag()) + ->setModel(new Execution()) + ->setModel(new Project()) + ->setModel(new Webhook()) + ->setModel(new Key()) + ->setModel(new Task()) + ->setModel(new Domain()) + ->setModel(new Platform()) + ->setModel(new Country()) + ->setModel(new Continent()) + ->setModel(new Language()) + ->setModel(new Currency()) + ->setModel(new Phone()) + // Verification + // Recovery ; - parent::__construct($time); + parent::__construct($response); } /** @@ -120,29 +224,37 @@ class Response extends UtopiaResponse /** * Generate valid response object from document data */ - protected function output(Document $document, string $model): array + public function output(Document $document, string $model): array { $data = $document; $model = $this->getModel($model); $output = []; + if($model->isAny()) { + return $document->getArrayCopy(); + } + foreach($model->getRules() as $key => $rule) { if(!$document->isSet($key)) { if(!is_null($rule['default'])) { $document->setAttribute($key, $rule['default']); } else { - throw new Exception('Missing response key: '.$key); + throw new Exception('Model '.$model->getName().' is missing response key: '.$key); } } if($rule['array']) { if(!is_array($data[$key])) { - throw new Exception($key.' must be an array of '.$rule['type'].' types'); + throw new Exception($key.' must be an array of type '.$rule['type']); } foreach ($data[$key] as &$item) { - if(array_key_exists($rule['type'], $this->models) && $item instanceof Document) { + if($item instanceof Document) { + if(!array_key_exists($rule['type'], $this->models)) { + throw new Exception('Missing model for rule: '. $rule['type']); + } + $item = $this->output($item, $rule['type']); } } @@ -151,6 +263,8 @@ class Response extends UtopiaResponse $output[$key] = $data[$key]; } + $this->payload = $output; + return $output; } @@ -177,4 +291,12 @@ class Response extends UtopiaResponse ->send(yaml_emit($data, YAML_UTF8_ENCODING)) ; } + + /** + * @return array + */ + public function getPayload():array + { + return $this->payload; + } } diff --git a/src/Appwrite/Utopia/Response/Model.php b/src/Appwrite/Utopia/Response/Model.php index 36a2745e0e..225aa685b1 100644 --- a/src/Appwrite/Utopia/Response/Model.php +++ b/src/Appwrite/Utopia/Response/Model.php @@ -5,7 +5,12 @@ namespace Appwrite\Utopia\Response; abstract class Model { /** - * @return array + * @var bool + */ + protected $any = false; + + /** + * @var array */ protected $rules = []; @@ -48,4 +53,9 @@ abstract class Model return $this; } + + public function isAny(): bool + { + return $this->any; + } } \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Any.php b/src/Appwrite/Utopia/Response/Model/Any.php new file mode 100644 index 0000000000..1a5defec66 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Any.php @@ -0,0 +1,34 @@ +addRule('sum', [ + $this->name = $name; + $this->type = $type; + + if($paging) { + $this->addRule('sum', [ 'type' => 'integer', 'description' => 'Total sum of items in the list.', 'example' => '5', - ]) - ; + ]); + } + $this->addRule($key, [ + 'type' => $model, + 'description' => 'List of '.$key.'.', + 'example' => [], + 'array' => true, + ]); } /** @@ -25,7 +44,7 @@ abstract class BaseList extends Model */ public function getName():string { - return 'Base List'; + return $this->name; } /** @@ -35,6 +54,6 @@ abstract class BaseList extends Model */ public function getType():string { - return Response::MODEL_BASE_LIST; + return $this->type; } } \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Collection.php b/src/Appwrite/Utopia/Response/Model/Collection.php new file mode 100644 index 0000000000..9c6dd15d69 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Collection.php @@ -0,0 +1,68 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Collection ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('$permissions', [ + 'type' => Response::MODEL_PERMISSIONS, + 'description' => 'Collection permissions.', + 'example' => new \stdClass, + 'array' => false, + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Collection name.', + 'example' => 'Movies', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'Collection creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('dateUpdated', [ + 'type' => 'integer', + 'description' => 'Collection creation date in Unix timestamp.', + 'example' => 1592981550, + ]) + ->addRule('rules', [ + 'type' => Response::MODEL_RULE, + 'description' => 'Collection rules.', + 'example' => [], + 'default' => [], + 'array' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Collection'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_COLLECTION; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Continent.php b/src/Appwrite/Utopia/Response/Model/Continent.php new file mode 100644 index 0000000000..a42b39e9e9 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Continent.php @@ -0,0 +1,45 @@ +addRule('name', [ + 'type' => 'string', + 'description' => 'Continent name.', + 'example' => 'Europe', + ]) + ->addRule('code', [ + 'type' => 'string', + 'description' => 'Continent two letter code.', + 'example' => 'EU', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Continent'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_CONTINENT; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Country.php b/src/Appwrite/Utopia/Response/Model/Country.php new file mode 100644 index 0000000000..b5ba0f74f5 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Country.php @@ -0,0 +1,45 @@ +addRule('name', [ + 'type' => 'string', + 'description' => 'Country name.', + 'example' => 'United States', + ]) + ->addRule('code', [ + 'type' => 'string', + 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'example' => 'US', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Country'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_COUNTRY; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Currency.php b/src/Appwrite/Utopia/Response/Model/Currency.php new file mode 100644 index 0000000000..29b3d78f98 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Currency.php @@ -0,0 +1,76 @@ +addRule('symbol', [ + 'type' => 'string', + 'description' => 'Currency symbol.', + 'example' => '$', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Currency name.', + 'example' => 'US dollar', + ]) + ->addRule('symbolNative', [ + 'type' => 'string', + 'description' => 'Currency native symbol.', + 'example' => '$', + ]) + ->addRule('decimalDigits', [ + 'type' => 'integer', + 'description' => 'Number of decimal digits.', + 'example' => 2, + ]) + ->addRule('rounding', [ + 'type' => 'float', + 'description' => 'Currency digit rounding.', + 'example' => 0, + ]) + ->addRule('code', [ + 'type' => 'string', + 'description' => 'Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format.', + 'example' => 'USD', + ]) + ->addRule('namePlural', [ + 'type' => 'string', + 'description' => 'Currency plural name', + 'example' => 'US dollars', + ]) + // ->addRule('locations', [ + // 'type' => 'string', + // 'description' => 'Currency locations list. List of location in two-character ISO 3166-1 alpha code.', + // 'example' => ['US'], + // 'array' => true, + // ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Currency'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_CURRENCY; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Domain.php b/src/Appwrite/Utopia/Response/Model/Domain.php new file mode 100644 index 0000000000..f8273ff876 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Domain.php @@ -0,0 +1,60 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Domain ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('domain', [ + 'type' => 'string', + 'description' => 'Domain name.', + 'example' => 'appwrite.company.com', + ]) + ->addRule('registerable', [ + 'type' => 'string', + 'description' => 'Registerable domain name.', + 'example' => 'company.com', + ]) + ->addRule('tld', [ + 'type' => 'string', + 'description' => 'TLD name.', + 'example' => 'com', + ]) + ->addRule('verification', [ + 'type' => 'boolean', + 'description' => 'Verification process status.', + 'example' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Domain'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_DOMAIN; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Execution.php b/src/Appwrite/Utopia/Response/Model/Execution.php new file mode 100644 index 0000000000..92a00208dd --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Execution.php @@ -0,0 +1,80 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Execution ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('functionId', [ + 'type' => 'string', + 'description' => 'Function ID.', + 'example' => '5e5ea6g16897e', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'The execution creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('trigger', [ + 'type' => 'string', + 'description' => 'The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.', + 'example' => 'http', + ]) + ->addRule('status', [ + 'type' => 'string', + 'description' => 'The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.', + 'example' => 'processing', + ]) + ->addRule('exitCode', [ + 'type' => 'integer', + 'description' => 'The script exit code.', + 'example' => 0, + ]) + ->addRule('stdout', [ + 'type' => 'string', + 'description' => 'The script stdout output string.', + 'example' => '', + ]) + ->addRule('stderr', [ + 'type' => 'string', + 'description' => 'The script stderr output string.', + 'example' => '', + ]) + ->addRule('time', [ + 'type' => 'float', + 'description' => 'The script execution time in seconds.', + 'example' => 0.400, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Execution'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_EXECUTION; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/File.php b/src/Appwrite/Utopia/Response/Model/File.php index 875c6f4bd7..416a02ac53 100644 --- a/src/Appwrite/Utopia/Response/Model/File.php +++ b/src/Appwrite/Utopia/Response/Model/File.php @@ -9,7 +9,44 @@ class File extends Model { public function __construct() { - + $this + ->addRule('$id', [ + 'type' => 'string', + 'description' => 'File ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('$permissions', [ + 'type' => Response::MODEL_PERMISSIONS, + 'description' => 'File permissions.', + 'example' => new \stdClass, + 'array' => false, + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'File name.', + 'example' => 'Pink.png', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'File creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('signature', [ + 'type' => 'string', + 'description' => 'File MD5 signature.', + 'example' => '5d529fd02b544198ae075bd57c1762bb', + ]) + ->addRule('mimeType', [ + 'type' => 'string', + 'description' => 'File mime type.', + 'example' => 'image/png', + ]) + ->addRule('sizeOriginal', [ + 'type' => 'integer', + 'description' => 'File original size in bytes.', + 'example' => 17890, + ]) + ; } /** @@ -29,6 +66,6 @@ class File extends Model */ public function getType():string { - return Response::MODEL_LOCALE; + return Response::MODEL_FILE; } } \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php new file mode 100644 index 0000000000..e0d3595355 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -0,0 +1,108 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Function ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Function name.', + 'example' => 'My Function', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'Function creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('dateUpdated', [ + 'type' => 'integer', + 'description' => 'Function update date in Unix timestamp.', + 'example' => 1592981257, + ]) + ->addRule('status', [ + 'type' => 'string', + 'description' => 'Function status. Possible values: disabled, enabled', + 'example' => 'enabled', + ]) + ->addRule('env', [ + 'type' => 'string', + 'description' => 'Function execution environment.', + 'example' => 'python-3.8', + ]) + ->addRule('tag', [ + 'type' => 'string', + 'description' => 'Function active tag ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('vars', [ + 'type' => 'json', + 'description' => 'Function environment variables.', + 'default' => new \stdClass, + 'example' => ['key' => 'value'], + ]) + ->addRule('events', [ + 'type' => 'string', + 'description' => 'Function trigger events.', + 'default' => [], + 'example' => ['account.create'], + 'array' => true, + ]) + ->addRule('schedule', [ + 'type' => 'string', + 'description' => 'Function execution schedult in CRON format.', + 'default' => '', + 'example' => '5 4 * * *', + ]) + ->addRule('scheduleNext', [ + 'type' => 'integer', + 'description' => 'Function next scheduled execution date in Unix timestamp.', + 'example' => 1592981292, + 'default' => 0, + ]) + ->addRule('schedulePrevious', [ + 'type' => 'integer', + 'description' => 'Function next scheduled execution date in Unix timestamp.', + 'example' => 1592981237, + 'default' => 0, + ]) + ->addRule('timeout', [ + 'type' => 'integer', + 'description' => 'Function execution timeout in seconds.', + 'default' => 15, + 'example' => 1592981237, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Function'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_FUNCTION; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Key.php b/src/Appwrite/Utopia/Response/Model/Key.php new file mode 100644 index 0000000000..99abb38d5d --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Key.php @@ -0,0 +1,57 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Key ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Key name.', + 'example' => 'My API Key', + ]) + ->addRule('scopes', [ + 'type' => 'string', + 'description' => 'Allowed permission scopes.', + 'default' => [], + 'example' => ['users.read', 'documents.write'], + 'array' => true, + ]) + ->addRule('secret', [ + 'type' => 'string', + 'description' => 'Secret key.', + 'example' => '919c2d18fb5d4...a2ae413da83346ad2', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Key'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_KEY; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Language.php b/src/Appwrite/Utopia/Response/Model/Language.php new file mode 100644 index 0000000000..966efa7e72 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Language.php @@ -0,0 +1,50 @@ +addRule('name', [ + 'type' => 'string', + 'description' => 'Language name.', + 'example' => 'Italian', + ]) + ->addRule('code', [ + 'type' => 'string', + 'description' => 'Language two-character ISO 639-1 codes.', + 'example' => 'it', + ]) + ->addRule('nativeName', [ + 'type' => 'string', + 'description' => 'Language native name.', + 'example' => 'Italiano', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Language'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_LANGUAGE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Log.php b/src/Appwrite/Utopia/Response/Model/Log.php index 93e7e88efd..35040d018e 100644 --- a/src/Appwrite/Utopia/Response/Model/Log.php +++ b/src/Appwrite/Utopia/Response/Model/Log.php @@ -9,6 +9,107 @@ class Log extends Model { public function __construct() { + $this + ->addRule('event', [ + 'type' => 'string', + 'description' => 'Event name.', + 'example' => 'account.sessions.create', + ]) + ->addRule('ip', [ + 'type' => 'string', + 'description' => 'IP session in use when the session was created.', + 'example' => '127.0.0.1', + ]) + ->addRule('time', [ + 'type' => 'integer', + 'description' => 'Log creation time in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('osCode', [ + 'type' => 'string', + 'description' => 'Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('osName', [ + 'type' => 'string', + 'description' => 'Operating system name.', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('osVersion', [ + 'type' => 'string', + 'description' => 'Operating system version.', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('clientType', [ + 'type' => 'string', + 'description' => 'Client type.', + 'default' => '', + 'example' => 'browser', + ]) + ->addRule('clientCode', [ + 'type' => 'string', + 'description' => 'Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).', + 'default' => '', + 'example' => 'CM', + ]) + ->addRule('clientName', [ + 'type' => 'string', + 'description' => 'Client name.', + 'default' => '', + 'example' => 'Chrome Mobile iOS', + ]) + ->addRule('clientVersion', [ + 'type' => 'string', + 'description' => 'Client version.', + 'default' => '', + 'example' => '84.0', + ]) + ->addRule('clientEngine', [ + 'type' => 'string', + 'description' => 'Client engine name.', + 'default' => '', + 'example' => 'WebKit', + ]) + ->addRule('clientEngineVersion', [ + 'type' => 'string', + 'description' => 'Client engine name.', + 'default' => '', + 'example' => '605.1.15', + ]) + ->addRule('deviceName', [ + 'type' => 'string', + 'description' => 'Device name.', + 'default' => '', + 'example' => 'smartphone', + ]) + ->addRule('deviceBrand', [ + 'type' => 'string', + 'description' => 'Device brand name.', + 'default' => '', + 'example' => 'Google', + ]) + ->addRule('deviceModel', [ + 'type' => 'string', + 'description' => 'Device model name.', + 'default' => '', + 'example' => 'Nexus 5', + ]) + ->addRule('countryCode', [ + 'type' => 'string', + 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'default' => '', + 'example' => 'US', + ]) + ->addRule('countryName', [ + 'type' => 'string', + 'description' => 'Country name.', + 'default' => '', + 'example' => 'United States', + ]) + ; } /** @@ -18,7 +119,7 @@ class Log extends Model */ public function getName():string { - return 'Session'; + return 'Log'; } /** @@ -28,6 +129,6 @@ class Log extends Model */ public function getType():string { - return Response::MODEL_LOCALE; + return Response::MODEL_LOG; } } \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/MembershipList.php b/src/Appwrite/Utopia/Response/Model/MembershipList.php deleted file mode 100644 index 56937c8d33..0000000000 --- a/src/Appwrite/Utopia/Response/Model/MembershipList.php +++ /dev/null @@ -1,41 +0,0 @@ -addRule('memberships', [ - 'type' => Response::MODEL_MEMBERSHIP, - 'description' => 'List of memberships.', - 'example' => [], - 'array' => true, - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'Membership List'; - } - - /** - * Get Collection - * - * @return string - */ - public function getType():string - { - return Response::MODEL_MEMBERSHIP_LIST; - } -} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Permissions.php b/src/Appwrite/Utopia/Response/Model/Permissions.php new file mode 100644 index 0000000000..8f14ccb86a --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Permissions.php @@ -0,0 +1,47 @@ +addRule('read', [ + 'type' => 'string', + 'description' => 'Read permissions.', + 'example' => ['*', 'user:5e5ea5c16897e'], + 'array' => true, + ]) + ->addRule('write', [ + 'type' => 'string', + 'description' => 'Write permissions.', + 'example' => ['*', 'user:5e5ea5c16897e'], + 'array' => true, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Permissions'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_PERMISSIONS; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Phone.php b/src/Appwrite/Utopia/Response/Model/Phone.php new file mode 100644 index 0000000000..e0242981e9 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Phone.php @@ -0,0 +1,50 @@ +addRule('code', [ + 'type' => 'string', + 'description' => 'Phone code.', + 'example' => '+1', + ]) + ->addRule('countryCode', [ + 'type' => 'string', + 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'example' => 'US', + ]) + ->addRule('countryName', [ + 'type' => 'string', + 'description' => 'Country name.', + 'example' => 'United States', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Phone'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_PHONE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Platform.php b/src/Appwrite/Utopia/Response/Model/Platform.php new file mode 100644 index 0000000000..861300f887 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Platform.php @@ -0,0 +1,77 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Platform ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Platform name.', + 'example' => 'My Web App', + ]) + ->addRule('type', [ + 'type' => 'string', + 'description' => 'Platform type. Possible values are: web, flutter-ios, flutter-android, ios, android, and unity.', + 'example' => 'My Web App', + ]) + ->addRule('key', [ + 'type' => 'string', + 'description' => 'Platform Key. iOS bundle ID or Android package name. Empty string for other platforms.', + 'example' => 'com.company.appname', + ]) + // ->addRule('store', [ + // 'type' => 'string', + // 'description' => 'Link to platform store.', + // 'example' => '', + // ]) + ->addRule('hostname', [ + 'type' => 'string', + 'description' => 'Web app hostname. Empty string for other platforms.', + 'example' => true, + ]) + ->addRule('httpUser', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication username.', + 'default' => '', + 'example' => 'username', + ]) + ->addRule('httpPass', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication password.', + 'default' => '', + 'example' => 'password', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Platform'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_PLATFORM; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Project.php b/src/Appwrite/Utopia/Response/Model/Project.php new file mode 100644 index 0000000000..af5cad3ebe --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Project.php @@ -0,0 +1,166 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Project ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Project name.', + 'default' => '', + 'example' => 'New Project', + ]) + ->addRule('description', [ + 'type' => 'string', + 'description' => 'Project description.', + 'default' => '', + 'example' => 'This is a new project.', + ]) + ->addRule('teamId', [ + 'type' => 'string', + 'description' => 'Project team ID.', + 'example' => '1592981250', + ]) + ->addRule('logo', [ + 'type' => 'string', + 'description' => 'Project logo file ID.', + 'default' => '', + 'example' => '5f5c451b403cb', + ]) + ->addRule('url', [ + 'type' => 'string', + 'description' => 'Project website URL.', + 'default' => '', + 'example' => '5f5c451b403cb', + ]) + ->addRule('legalName', [ + 'type' => 'string', + 'description' => 'Company legal name.', + 'default' => '', + 'example' => 'Company LTD.', + ]) + ->addRule('legalCountry', [ + 'type' => 'string', + 'description' => 'Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format.', + 'default' => '', + 'example' => 'US', + ]) + ->addRule('legalState', [ + 'type' => 'string', + 'description' => 'State name.', + 'default' => '', + 'example' => 'New York', + ]) + ->addRule('legalCity', [ + 'type' => 'string', + 'description' => 'City name.', + 'default' => '', + 'example' => 'New York City.', + ]) + ->addRule('legalAddress', [ + 'type' => 'string', + 'description' => 'Company Address.', + 'default' => '', + 'example' => '620 Eighth Avenue, New York, NY 10018', + ]) + ->addRule('legalTaxId', [ + 'type' => 'string', + 'description' => 'Company Tax ID.', + 'default' => '', + 'example' => '131102020', + ]) + ->addRule('platforms', [ + 'type' => Response::MODEL_PLATFORM, + 'description' => 'List of Platforms.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('webhooks', [ + 'type' => Response::MODEL_WEBHOOK, + 'description' => 'List of Webhooks.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('keys', [ + 'type' => Response::MODEL_KEY, + 'description' => 'List of API Keys.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('domains', [ + 'type' => Response::MODEL_DOMAIN, + 'description' => 'List of Domains.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ->addRule('tasks', [ + 'type' => Response::MODEL_TASK, + 'description' => 'List of Tasks.', + 'default' => [], + 'example' => [], + 'array' => true, + ]) + ; + + $providers = Config::getParam('providers', []); + + foreach ($providers as $index => $provider) { + if (!$provider['enabled']) { + continue; + } + + $name = (isset($provider['name'])) ? $provider['name'] : 'Unknown'; + + $this + ->addRule('usersOauth2'.\ucfirst($index).'Appid', [ + 'type' => 'string', + 'description' => $name.' OAuth app ID.', + 'example' => '123247283472834787438', + 'default' => '', + ]) + ->addRule('usersOauth2'.\ucfirst($index).'Secret', [ + 'type' => 'string', + 'description' => $name.' OAuth secret ID.', + 'example' => 'djsgudsdsewe43434343dd34...', + 'default' => '', + ]) + ; + } + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Project'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_PROJECT; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Rule.php b/src/Appwrite/Utopia/Response/Model/Rule.php new file mode 100644 index 0000000000..234377c432 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Rule.php @@ -0,0 +1,83 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Rule ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('$collection', [ // TODO remove this from public response + 'type' => 'string', + 'description' => 'Rule Collection.', + 'example' => '5e5e66c16897e', + ]) + ->addRule('type', [ + 'type' => 'string', + 'description' => 'Rule type. Possible values: ', + 'example' => 'title', + ]) + ->addRule('key', [ + 'type' => 'string', + 'description' => 'Rule key.', + 'example' => 'title', + ]) + ->addRule('label', [ + 'type' => 'string', + 'description' => 'Rule label.', + 'example' => 'Title', + ]) + ->addRule('default', [ // TODO should be of mixed types + 'type' => 'string', + 'description' => 'Rule default value.', + 'example' => 'Movie Name', + 'default' => '', + ]) + ->addRule('array', [ + 'type' => 'boolean', + 'description' => 'Is array?', + 'example' => false, + ]) + ->addRule('required', [ + 'type' => 'boolean', + 'description' => 'Is required?', + 'example' => true, + ]) + ->addRule('list', [ + 'type' => 'string', + 'description' => 'List of allowed values', + 'array' => true, + 'default' => [], + 'example' => ['5e5ea5c168099'], + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Rule'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_RULE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Session.php b/src/Appwrite/Utopia/Response/Model/Session.php index 6146feb31d..2e22513fdf 100644 --- a/src/Appwrite/Utopia/Response/Model/Session.php +++ b/src/Appwrite/Utopia/Response/Model/Session.php @@ -16,15 +16,107 @@ class Session extends Model 'example' => '5e5ea5c16897e', ]) ->addRule('expire', [ - 'type' => 'string', + 'type' => 'integer', 'description' => 'Session expiration date in Unix timestamp.', + 'default' => 0, 'example' => 1592981250, ]) ->addRule('ip', [ 'type' => 'string', - 'description' => 'IP session in use when the session was created.', + 'description' => 'IP in use when the session was created.', + 'default' => '', 'example' => '127.0.0.1', ]) + ->addRule('osCode', [ + 'type' => 'string', + 'description' => 'Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('osName', [ + 'type' => 'string', + 'description' => 'Operating system name.', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('osVersion', [ + 'type' => 'string', + 'description' => 'Operating system version.', + 'default' => '', + 'example' => 'Mac', + ]) + ->addRule('clientType', [ + 'type' => 'string', + 'description' => 'Client type.', + 'default' => '', + 'example' => 'browser', + ]) + ->addRule('clientCode', [ + 'type' => 'string', + 'description' => 'Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).', + 'default' => '', + 'example' => 'CM', + ]) + ->addRule('clientName', [ + 'type' => 'string', + 'description' => 'Client name.', + 'default' => '', + 'example' => 'Chrome Mobile iOS', + ]) + ->addRule('clientVersion', [ + 'type' => 'string', + 'description' => 'Client version.', + 'default' => '', + 'example' => '84.0', + ]) + ->addRule('clientEngine', [ + 'type' => 'string', + 'description' => 'Client engine name.', + 'default' => '', + 'example' => 'WebKit', + ]) + ->addRule('clientEngineVersion', [ + 'type' => 'string', + 'description' => 'Client engine name.', + 'default' => '', + 'example' => '605.1.15', + ]) + ->addRule('deviceName', [ + 'type' => 'string', + 'description' => 'Device name.', + 'default' => '', + 'example' => 'smartphone', + ]) + ->addRule('deviceBrand', [ + 'type' => 'string', + 'description' => 'Device brand name.', + 'default' => '', + 'example' => 'Google', + ]) + ->addRule('deviceModel', [ + 'type' => 'string', + 'description' => 'Device model name.', + 'default' => '', + 'example' => 'Nexus 5', + ]) + ->addRule('countryCode', [ + 'type' => 'string', + 'description' => 'Country two-character ISO 3166-1 alpha code.', + 'default' => '', + 'example' => 'US', + ]) + ->addRule('countryName', [ + 'type' => 'string', + 'description' => 'Country name.', + 'default' => '', + 'example' => 'United States', + ]) + ->addRule('current', [ + 'type' => 'boolean', + 'description' => 'Returns true if this the current user session.', + 'default' => '', + 'example' => true, + ]) ; } diff --git a/src/Appwrite/Utopia/Response/Model/Tag.php b/src/Appwrite/Utopia/Response/Model/Tag.php new file mode 100644 index 0000000000..4b6facab82 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Tag.php @@ -0,0 +1,60 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Tag ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('functionId', [ + 'type' => 'string', + 'description' => 'Function ID.', + 'example' => '5e5ea6g16897e', + ]) + ->addRule('dateCreated', [ + 'type' => 'integer', + 'description' => 'The tag creation date in Unix timestamp.', + 'example' => 1592981250, + ]) + ->addRule('command', [ + 'type' => 'string', + 'description' => 'The entrypoint command in use to execute the tag code.', + 'example' => 'enabled', + ]) + ->addRule('size', [ + 'type' => 'string', + 'description' => 'The code size in bytes.', + 'example' => 'python-3.8', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Tag'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_TAG; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/Task.php b/src/Appwrite/Utopia/Response/Model/Task.php new file mode 100644 index 0000000000..e2ab652fe7 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Task.php @@ -0,0 +1,125 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Task ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Task name.', + 'example' => 'My Task', + ]) + ->addRule('security', [ + 'type' => 'boolean', + 'description' => 'Indicated if SSL / TLS Certificate verification is enabled.', + 'example' => true, + ]) + ->addRule('httpMethod', [ + 'type' => 'string', + 'description' => 'Task HTTP Method.', + 'example' => 'POST', + ]) + ->addRule('httpUrl', [ + 'type' => 'string', + 'description' => 'Task HTTP URL.', + 'example' => 'https://example.com/task', + ]) + ->addRule('httpHeaders', [ + 'type' => 'string', + 'description' => 'Task HTTP headers.', + 'default' => [], + 'example' => ['key:value'], + 'array' => true, + ]) + ->addRule('httpUser', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication username.', + 'default' => '', + 'example' => 'username', + ]) + ->addRule('httpPass', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication password.', + 'default' => '', + 'example' => 'password', + ]) + ->addRule('duration', [ + 'type' => 'float', + 'description' => 'Task duration in seconds.', + 'default' => 0, + 'example' => 1.2, + ]) + ->addRule('delay', [ + 'type' => 'float', + 'description' => 'Task delay time in seconds.', + 'default' => 0, + 'example' => 1.2, + ]) + ->addRule('failures', [ + 'type' => 'integer', + 'description' => 'Number of recurring task failures.', + 'default' => 0, + 'example' => 0, + ]) + ->addRule('schedule', [ + 'type' => 'string', + 'description' => 'Task schedule in CRON syntax.', + 'example' => '* * * * *', + ]) + ->addRule('status', [ + 'type' => 'string', + 'description' => 'Task status. Possible values: play, pause', // TODO - change to enabled disabled + 'example' => 'enabled', + ]) + ->addRule('updated', [ + 'type' => 'integer', + 'description' => 'Task last updated time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981250, + ]) + ->addRule('previous', [ + 'type' => 'integer', + 'description' => 'Task previous run time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981250, + ]) + ->addRule('next', [ + 'type' => 'integer', + 'description' => 'Task next run time in Unix timestamp.', + 'default' => 0, + 'example' => 1592981650, + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Task'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_TASK; + } +} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/TeamList.php b/src/Appwrite/Utopia/Response/Model/TeamList.php deleted file mode 100644 index c96e4cd0d4..0000000000 --- a/src/Appwrite/Utopia/Response/Model/TeamList.php +++ /dev/null @@ -1,41 +0,0 @@ -addRule('teams', [ - 'type' => Response::MODEL_TEAM, - 'description' => 'List of teams.', - 'example' => [], - 'array' => true, - ]) - ; - } - - /** - * Get Name - * - * @return string - */ - public function getName():string - { - return 'Team List'; - } - - /** - * Get Collection - * - * @return string - */ - public function getType():string - { - return Response::MODEL_TEAM_LIST; - } -} \ No newline at end of file diff --git a/src/Appwrite/Utopia/Response/Model/User.php b/src/Appwrite/Utopia/Response/Model/User.php index 56af2156cf..25b50cfa20 100644 --- a/src/Appwrite/Utopia/Response/Model/User.php +++ b/src/Appwrite/Utopia/Response/Model/User.php @@ -18,7 +18,6 @@ class User extends Model ->addRule('name', [ 'type' => 'string', 'description' => 'User name.', - 'default' => '', 'example' => 'John Doe', ]) ->addRule('registration', [ @@ -29,13 +28,11 @@ class User extends Model ->addRule('status', [ 'type' => 'integer', 'description' => 'User status. 0 for Unavtivated, 1 for active and 2 is blocked.', - 'default' => false, - 'example' => true, + 'example' => 0, ]) ->addRule('email', [ 'type' => 'string', 'description' => 'User email address.', - 'default' => '', 'example' => 'john@appwrite.io', ]) ->addRule('emailVerification', [ @@ -48,7 +45,7 @@ class User extends Model 'type' => 'json', 'description' => 'User preferences as a key-value object', 'default' => new \stdClass, - 'example' => ['theme' => 'dark', 'timezone' => 'UTC'], + 'example' => ['theme' => 'pink', 'timezone' => 'UTC'], ]) ->addRule('roles', [ 'type' => 'string', diff --git a/src/Appwrite/Utopia/Response/Model/Webhook.php b/src/Appwrite/Utopia/Response/Model/Webhook.php new file mode 100644 index 0000000000..e3fe565afb --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Webhook.php @@ -0,0 +1,74 @@ +addRule('$id', [ + 'type' => 'string', + 'description' => 'Webhook ID.', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('name', [ + 'type' => 'string', + 'description' => 'Webhook name.', + 'example' => 'My Webhook', + ]) + ->addRule('url', [ + 'type' => 'string', + 'description' => 'Webhook URL endpoint.', + 'example' => 'https://example.com/webhook', + ]) + ->addRule('events', [ + 'type' => 'string', + 'description' => 'Webhook trigger events.', + 'default' => [], + 'example' => ['database.collections.update', 'database.collections.delete'], + 'array' => true, + ]) + ->addRule('security', [ + 'type' => 'boolean', + 'description' => 'Indicated if SSL / TLS Certificate verification is enabled.', + 'example' => true, + ]) + ->addRule('httpUser', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication username.', + 'default' => '', + 'example' => 'username', + ]) + ->addRule('httpPass', [ + 'type' => 'string', + 'description' => 'HTTP basic authentication password.', + 'default' => '', + 'example' => 'password', + ]) + ; + } + + /** + * Get Name + * + * @return string + */ + public function getName():string + { + return 'Webhook'; + } + + /** + * Get Collection + * + * @return string + */ + public function getType():string + { + return Response::MODEL_WEBHOOK; + } +} \ No newline at end of file diff --git a/tests/unit/Swoole/FilesTest.php b/tests/unit/Swoole/FilesTest.php deleted file mode 100644 index adcf4b4fc0..0000000000 --- a/tests/unit/Swoole/FilesTest.php +++ /dev/null @@ -1,48 +0,0 @@ -assertGreaterThan(100, Files::getCount()); - $this->assertLessThan(250, Files::getCount()); - - $this->assertEquals(false, Files::isFileLoaded('/index.php')); - $this->assertEquals(false, Files::isFileLoaded('/unknown.jpg')); - $this->assertEquals(true, Files::isFileLoaded('/scripts/app.js')); - $this->assertEquals(true, Files::isFileLoaded('/styles/default.less')); - $this->assertEquals(true, Files::isFileLoaded('/dist/scripts/app.js')); - $this->assertEquals(true, Files::isFileLoaded('/dist/styles/default-ltr.css')); - $this->assertEquals(true, Files::isFileLoaded('/dist/styles/default-rtl.css')); - - $this->assertEquals('application/vnd.ms-fontobject', Files::getFileMimeType('/fonts/poppins-v9-latin-100.eot')); - $this->assertEquals('image/svg+xml', Files::getFileMimeType('/fonts/poppins-v9-latin-100.svg')); - $this->assertEquals('font/sfnt', Files::getFileMimeType('/fonts/poppins-v9-latin-100.ttf')); - $this->assertEquals('application/octet-stream', Files::getFileMimeType('/fonts/poppins-v9-latin-100.woff')); - $this->assertEquals('application/octet-stream', Files::getFileMimeType('/fonts/poppins-v9-latin-100.woff2')); - $this->assertEquals('image/png', Files::getFileMimeType('/images/apple.png')); - $this->assertEquals('text/javascript', Files::getFileMimeType('/dist/scripts/app.js')); - $this->assertEquals('text/javascript', Files::getFileMimeType('/dist/scripts/app.js')); - $this->assertEquals('text/css', Files::getFileMimeType('/dist/styles/default-ltr.css')); - $this->assertEquals('text/css', Files::getFileMimeType('/dist/styles/default-rtl.css')); - - $this->assertNotEmpty(Files::getFileContents('/fonts/poppins-v9-latin-100.eot')); - $this->assertNotEmpty(Files::getFileContents('/fonts/poppins-v9-latin-100.svg')); - $this->assertNotEmpty(Files::getFileContents('/fonts/poppins-v9-latin-100.ttf')); - $this->assertNotEmpty(Files::getFileContents('/fonts/poppins-v9-latin-100.woff')); - $this->assertNotEmpty(Files::getFileMimeType('/fonts/poppins-v9-latin-100.woff2')); - $this->assertNotEmpty(Files::getFileContents('/images/apple.png')); - $this->assertNotEmpty(Files::getFileContents('/dist/scripts/app.js')); - $this->assertNotEmpty(Files::getFileContents('/dist/scripts/app.js')); - $this->assertNotEmpty(Files::getFileContents('/dist/styles/default-ltr.css')); - $this->assertNotEmpty(Files::getFileContents('/dist/styles/default-rtl.css')); - - } -} \ No newline at end of file From afa210f4a25b37db36634980410ab8dac6047684 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 29 Oct 2020 15:18:21 +0200 Subject: [PATCH 2/3] Updated static files class --- app/http.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/http.php b/app/http.php index 5bbdc87dfc..07e0fff45e 100644 --- a/app/http.php +++ b/app/http.php @@ -2,7 +2,7 @@ require_once __DIR__.'/../vendor/autoload.php'; -use Appwrite\Swoole\Files; +use Utopia\Swoole\Files; use Utopia\Swoole\Request; use Appwrite\Utopia\Response; use Swoole\Process; From 07b79c31035e8a9cbd4d8c5f900f5f0a0e6800fb Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 29 Oct 2020 15:50:49 +0200 Subject: [PATCH 3/3] Updated docs --- app/controllers/api/account.php | 40 ++++++++++---------- app/controllers/api/avatars.php | 10 ++--- app/controllers/api/database.php | 20 +++++----- app/controllers/api/functions.php | 2 +- app/controllers/api/health.php | 28 +++++++------- app/controllers/api/locale.php | 14 +++---- app/controllers/api/projects.php | 62 +++++++++++++++---------------- app/controllers/api/storage.php | 16 ++++---- app/controllers/api/teams.php | 18 ++++----- app/controllers/api/users.php | 22 +++++------ app/controllers/general.php | 4 +- app/controllers/shared/api.php | 2 +- app/controllers/shared/web.php | 2 +- app/controllers/web/console.php | 4 +- app/controllers/web/home.php | 6 +-- app/init.php | 2 +- 16 files changed, 126 insertions(+), 126 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 658b200ec6..ac6d1a5501 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -56,7 +56,7 @@ App::post('/v1/account') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->action(function ($email, $password, $name, $request, $response, $project, $projectDB, $webhooks, $audits) use ($oauth2Keys) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ @@ -262,7 +262,7 @@ App::get('/v1/account/sessions/oauth2/:provider') ->param('scopes', [], new ArrayList(new Text(128)), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.', true) ->action(function ($provider, $success, $failure, $scopes, $request, $response, $project) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ $protocol = $request->getProtocol(); @@ -307,7 +307,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->param('state', '', new Text(2048), 'Login state params.', true) ->action(function ($projectId, $provider, $code, $state, $request, $response) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $domain = $request->getHostname(); $protocol = $request->getProtocol(); @@ -332,7 +332,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->param('state', '', new Text(2048), 'Login state params.', true) ->action(function ($projectId, $provider, $code, $state, $request, $response) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $domain = $request->getHostname(); $protocol = $request->getProtocol(); @@ -358,7 +358,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->param('state', '', new Text(2048), 'OAuth2 state params.', true) ->action(function ($provider, $code, $state, $request, $response, $project, $user, $projectDB, $audits) use ($oauthDefaultSuccess) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -553,7 +553,7 @@ App::get('/v1/account') ->label('sdk.description', '/docs/references/account/get.md') ->label('sdk.response', ['200' => 'user']) ->action(function ($response, $user) use ($oauth2Keys) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ $response->json(\array_merge($user->getArrayCopy(\array_merge( @@ -577,7 +577,7 @@ App::get('/v1/account/prefs') ->label('sdk.method', 'getPrefs') ->label('sdk.description', '/docs/references/account/get-prefs.md') ->action(function ($response, $user) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ $prefs = $user->getAttribute('prefs', '{}'); @@ -601,7 +601,7 @@ App::get('/v1/account/sessions') ->label('sdk.method', 'getSessions') ->label('sdk.description', '/docs/references/account/get-sessions.md') ->action(function ($response, $user, $locale, $geodb) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ @@ -669,7 +669,7 @@ App::get('/v1/account/logs') ->label('sdk.method', 'getLogs') ->label('sdk.description', '/docs/references/account/get-logs.md') ->action(function ($response, $register, $project, $user, $locale, $geodb) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Locale\Locale $locale */ @@ -753,7 +753,7 @@ App::patch('/v1/account/name') ->label('sdk.description', '/docs/references/account/update-name.md') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.') ->action(function ($name, $response, $user, $projectDB, $audits) use ($oauth2Keys) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -795,7 +795,7 @@ App::patch('/v1/account/password') ->param('password', '', new Password(), 'New user password. Must be between 6 to 32 chars.') ->param('oldPassword', '', new Password(), 'Old user password. Must be between 6 to 32 chars.') ->action(function ($password, $oldPassword, $response, $user, $projectDB, $audits) use ($oauth2Keys) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -841,7 +841,7 @@ App::patch('/v1/account/email') ->param('email', '', new Email(), 'User email.') ->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.') ->action(function ($email, $password, $response, $user, $projectDB, $audits) use ($oauth2Keys) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -901,7 +901,7 @@ App::patch('/v1/account/prefs') ->param('prefs', '', new Assoc(), 'Prefs key-value JSON object.') ->label('sdk.description', '/docs/references/account/update-prefs.md') ->action(function ($prefs, $response, $user, $projectDB, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -945,7 +945,7 @@ App::delete('/v1/account') ->label('sdk.description', '/docs/references/account/delete.md') ->action(function ($request, $response, $user, $projectDB, $audits, $webhooks) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -1008,7 +1008,7 @@ App::delete('/v1/account/sessions/:sessionId') ->param('sessionId', null, new UID(), 'Session unique ID. Use the string \'current\' to delete the current device session.') ->action(function ($sessionId, $request, $response, $user, $projectDB, $audits, $webhooks) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -1072,7 +1072,7 @@ App::delete('/v1/account/sessions') ->label('abuse-limit', 100) ->action(function ($request, $response, $user, $projectDB, $audits, $webhooks) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -1130,7 +1130,7 @@ App::post('/v1/account/recovery') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) ->action(function ($email, $url, $request, $response, $projectDB, $project, $locale, $mails, $audits) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Database\Document $project */ /** @var Utopia\Locale\Locale $locale */ @@ -1237,7 +1237,7 @@ App::put('/v1/account/recovery') ->param('password', '', new Password(), 'New password. Must be between 6 to 32 chars.') ->param('passwordAgain', '', new Password(), 'New password again. Must be between 6 to 32 chars.') ->action(function ($userId, $secret, $password, $passwordAgain, $response, $projectDB, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -1307,7 +1307,7 @@ App::post('/v1/account/verification') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add built-in confirm page ->action(function ($url, $request, $response, $project, $user, $projectDB, $locale, $audits, $mails) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -1402,7 +1402,7 @@ App::put('/v1/account/verification') ->param('userId', '', new UID(), 'User unique ID.') ->param('secret', '', new Text(256), 'Valid verification token.') ->action(function ($userId, $secret, $response, $user, $projectDB, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 5a3e9e48db..5b75073f20 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -17,7 +17,7 @@ use chillerlan\QRCode\QRCode; use chillerlan\QRCode\QROptions; $avatarCallback = function ($type, $code, $width, $height, $quality, $response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $code = \strtolower($code); $type = \strtolower($type); @@ -143,7 +143,7 @@ App::get('/v1/avatars/image') ->param('width', 400, new Range(0, 2000), 'Resize preview image width, Pass an integer between 0 to 2000.', true) ->param('height', 400, new Range(0, 2000), 'Resize preview image height, Pass an integer between 0 to 2000.', true) ->action(function ($url, $width, $height, $response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $quality = 80; $output = 'png'; @@ -207,7 +207,7 @@ App::get('/v1/avatars/favicon') ->label('sdk.description', '/docs/references/avatars/get-favicon.md') ->param('url', '', new URL(), 'Website URL which you want to fetch the favicon from.') ->action(function ($url, $response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $width = 56; $height = 56; @@ -360,7 +360,7 @@ App::get('/v1/avatars/qr') ->param('margin', 1, new Range(0, 10), 'Margin from edge. Pass an integer between 0 to 10. Defaults to 1.', true) ->param('download', false, new Boolean(true), 'Return resulting image with \'Content-Disposition: attachment \' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.', true) ->action(function ($text, $size, $margin, $download, $response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $download = ($download === '1' || $download === 'true' || $download === 1 || $download === true); $options = new QROptions([ @@ -396,7 +396,7 @@ App::get('/v1/avatars/initials') ->param('color', '', new HexColor(), 'Changes text color. By default a random color will be picked and stay will persistent to the given name.', true) ->param('background', '', new HexColor(), 'Changes background color. By default a random color will be picked and stay will persistent to the given name.', true) ->action(function ($name, $width, $height, $color, $background, $response, $user) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ $themes = [ diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index a24de80887..b535bb4899 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -35,7 +35,7 @@ App::post('/v1/database/collections') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', false, ['projectDB']) ->action(function ($name, $read, $write, $rules, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -111,7 +111,7 @@ App::get('/v1/database/collections') ->param('offset', 0, new Range(0, 40000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $results = $projectDB->getCollection([ @@ -139,7 +139,7 @@ App::get('/v1/database/collections/:collectionId') ->label('sdk.description', '/docs/references/database/get-collection.md') ->param('collectionId', '', new UID(), 'Collection unique ID.') ->action(function ($collectionId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $collection = $projectDB->getDocument($collectionId, false); @@ -231,7 +231,7 @@ App::put('/v1/database/collections/:collectionId') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('rules', [], function ($projectDB) { return new ArrayList(new Collection($projectDB, [Database::SYSTEM_COLLECTION_RULES], ['$collection' => Database::SYSTEM_COLLECTION_RULES, '$permissions' => ['read' => [], 'write' => []]])); }, 'Array of [rule objects](/docs/rules). Each rule define a collection field name, data type and validation.', true, ['projectDB']) ->action(function ($collectionId, $name, $read, $write, $rules, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -303,7 +303,7 @@ App::delete('/v1/database/collections/:collectionId') ->label('sdk.description', '/docs/references/database/delete-collection.md') ->param('collectionId', '', new UID(), 'Collection unique ID.') ->action(function ($collectionId, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -350,7 +350,7 @@ App::post('/v1/database/collections/:collectionId/documents') ->param('parentProperty', '', new Key(), 'Parent document property name. Use when you want your new document to be a child of a parent document.', true) ->param('parentPropertyType', Document::SET_TYPE_ASSIGN, new WhiteList([Document::SET_TYPE_ASSIGN, Document::SET_TYPE_APPEND, Document::SET_TYPE_PREPEND], true), 'Parent document property connection type. You can set this value to **assign**, **append** or **prepend**, default value is assign. Use when you want your new document to be a child of a parent document.', true) ->action(function ($collectionId, $data, $read, $write, $parentDocument, $parentProperty, $parentPropertyType, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -474,7 +474,7 @@ App::get('/v1/database/collections/:collectionId/documents') ->param('orderCast', 'string', new WhiteList(['int', 'string', 'date', 'time', 'datetime'], true), 'Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string.', true) ->param('search', '', new Text(256), 'Search query. Enter any free text search. The database will try to find a match against all document attributes and children. Max length: 256 chars.', true) ->action(function ($collectionId, $filters, $limit, $offset, $orderField, $orderType, $orderCast, $search, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $collection = $projectDB->getDocument($collectionId, false); @@ -530,7 +530,7 @@ App::get('/v1/database/collections/:collectionId/documents/:documentId') ->param('documentId', null, new UID(), 'Document unique ID.') ->action(function ($collectionId, $documentId, $request, $response, $projectDB) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $document = $projectDB->getDocument($documentId, false); @@ -581,7 +581,7 @@ App::patch('/v1/database/collections/:collectionId/documents/:documentId') ->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->action(function ($collectionId, $documentId, $data, $read, $write, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -661,7 +661,7 @@ App::delete('/v1/database/collections/:collectionId/documents/:documentId') ->param('collectionId', null, new UID(), 'Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).') ->param('documentId', null, new UID(), 'Document unique ID.') ->action(function ($collectionId, $documentId, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 039eeb3f55..d2e1c70791 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -416,7 +416,7 @@ App::post('/v1/functions/:functionId/executions') ->param('functionId', '', new UID(), 'Function unique ID.') ->param('async', 1, new Range(0, 1), 'Execute code asynchronously. Pass 1 for true, 0 for false. Default value is 1.', true) ->action(function ($functionId, $async, $response, $project, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 5ef4f2b9c8..8b146167da 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -15,7 +15,7 @@ App::get('/v1/health') ->label('sdk.method', 'get') ->label('sdk.description', '/docs/references/health/get.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['status' => 'OK']); }, ['response']); @@ -25,7 +25,7 @@ App::get('/v1/health/version') ->groups(['api', 'health']) ->label('scope', 'public') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['version' => APP_VERSION_STABLE]); }, ['response']); @@ -39,7 +39,7 @@ App::get('/v1/health/db') ->label('sdk.method', 'getDB') ->label('sdk.description', '/docs/references/health/get-db.md') ->action(function ($response, $register) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Registry\Registry $register */ $register->get('db'); /* @var $db PDO */ @@ -56,7 +56,7 @@ App::get('/v1/health/cache') ->label('sdk.method', 'getCache') ->label('sdk.description', '/docs/references/health/get-cache.md') ->action(function ($response, $register) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Registry\Registry $register */ $register->get('cache'); /* @var $cache Predis\Client */ @@ -72,7 +72,7 @@ App::get('/v1/health/time') ->label('sdk.method', 'getTime') ->label('sdk.description', '/docs/references/health/get-time.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /* * Code from: @see https://www.beliefmedia.com.au/query-ntp-time-server @@ -120,7 +120,7 @@ App::get('/v1/health/queue/webhooks') ->label('sdk.method', 'getQueueWebhooks') ->label('sdk.description', '/docs/references/health/get-queue-webhooks.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-webhooks')]); }, ['response']); @@ -134,7 +134,7 @@ App::get('/v1/health/queue/tasks') ->label('sdk.method', 'getQueueTasks') ->label('sdk.description', '/docs/references/health/get-queue-tasks.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-tasks')]); }, ['response']); @@ -148,7 +148,7 @@ App::get('/v1/health/queue/logs') ->label('sdk.method', 'getQueueLogs') ->label('sdk.description', '/docs/references/health/get-queue-logs.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-audit')]); }, ['response']); @@ -162,7 +162,7 @@ App::get('/v1/health/queue/usage') ->label('sdk.method', 'getQueueUsage') ->label('sdk.description', '/docs/references/health/get-queue-usage.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-usage')]); }, ['response']); @@ -176,7 +176,7 @@ App::get('/v1/health/queue/certificates') ->label('sdk.method', 'getQueueCertificates') ->label('sdk.description', '/docs/references/health/get-queue-certificates.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-certificates')]); }, ['response']); @@ -190,7 +190,7 @@ App::get('/v1/health/queue/functions') ->label('sdk.method', 'getQueueFunctions') ->label('sdk.description', '/docs/references/health/get-queue-functions.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json(['size' => Resque::size('v1-functions')]); }, ['response']); @@ -204,7 +204,7 @@ App::get('/v1/health/storage/local') ->label('sdk.method', 'getStorageLocal') ->label('sdk.description', '/docs/references/health/get-storage-local.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ foreach ([ 'Uploads' => APP_STORAGE_UPLOADS, @@ -235,7 +235,7 @@ App::get('/v1/health/anti-virus') ->label('sdk.method', 'getAntiVirus') ->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ if (App::getEnv('_APP_STORAGE_ANTIVIRUS') === 'disabled') { // Check if scans are enabled throw new Exception('Anitvirus is disabled'); @@ -258,7 +258,7 @@ App::get('/v1/health/stats') // Currently only used internally // ->label('sdk.method', 'getStats') ->label('docs', false) ->action(function ($response, $register) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Registry\Registry $register */ $device = Storage::getDevice('files'); diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index 26b90cfea2..7be2a5ce42 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -13,7 +13,7 @@ App::get('/v1/locale') ->label('sdk.description', '/docs/references/locale/get-locale.md') ->action(function ($request, $response, $locale, $geodb) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ @@ -69,7 +69,7 @@ App::get('/v1/locale/countries') ->label('sdk.method', 'getCountries') ->label('sdk.description', '/docs/references/locale/get-countries.md') ->action(function ($response, $locale) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ $list = $locale->getText('countries'); /* @var $list array */ @@ -88,7 +88,7 @@ App::get('/v1/locale/countries/eu') ->label('sdk.method', 'getCountriesEU') ->label('sdk.description', '/docs/references/locale/get-countries-eu.md') ->action(function ($response, $locale) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ $countries = $locale->getText('countries'); /* @var $countries array */ @@ -115,7 +115,7 @@ App::get('/v1/locale/countries/phones') ->label('sdk.method', 'getCountriesPhones') ->label('sdk.description', '/docs/references/locale/get-countries-phones.md') ->action(function ($response, $locale) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ $list = Config::getParam('locale-phones'); /* @var $list array */ @@ -142,7 +142,7 @@ App::get('/v1/locale/continents') ->label('sdk.method', 'getContinents') ->label('sdk.description', '/docs/references/locale/get-continents.md') ->action(function ($response, $locale) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Locale\Locale $locale */ $list = $locale->getText('continents'); /* @var $list array */ @@ -161,7 +161,7 @@ App::get('/v1/locale/currencies') ->label('sdk.method', 'getCurrencies') ->label('sdk.description', '/docs/references/locale/get-currencies.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $currencies = Config::getParam('locale-currencies'); @@ -178,7 +178,7 @@ App::get('/v1/locale/languages') ->label('sdk.method', 'getLanguages') ->label('sdk.description', '/docs/references/locale/get-languages.md') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $languages = Config::getParam('locale-languages'); diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 3f62a66c6a..5037624b2b 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -38,7 +38,7 @@ App::post('/v1/projects') ->param('legalAddress', '', new Text(256), 'Project legal Address. Max length: 256 chars.', true) ->param('legalTaxId', '', new Text(256), 'Project legal Tax ID. Max length: 256 chars.', true) ->action(function ($name, $teamId, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ /** @var Appwrite\Database\Database $projectDB */ @@ -96,7 +96,7 @@ App::get('/v1/projects') ->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($search, $limit, $offset, $orderType, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $results = $consoleDB->getCollection([ @@ -122,7 +122,7 @@ App::get('/v1/projects/:projectId') ->label('sdk.method', 'get') ->param('projectId', '', new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -143,7 +143,7 @@ App::get('/v1/projects/:projectId/usage') ->param('projectId', '', new UID(), 'Project unique ID.') ->param('range', 'last30', new WhiteList(['daily', 'monthly', 'last30', 'last90'], true), 'Date range.', true) ->action(function ($projectId, $range, $response, $consoleDB, $projectDB, $register) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ /** @var Appwrite\Database\Database $projectDB */ /** @var Utopia\Registry\Registry $register */ @@ -326,7 +326,7 @@ App::patch('/v1/projects/:projectId') ->param('legalAddress', '', new Text(256), 'Project legal address. Max length: 256 chars.', true) ->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true) ->action(function ($projectId, $name, $description, $logo, $url, $legalName, $legalCountry, $legalState, $legalCity, $legalAddress, $legalTaxId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -366,7 +366,7 @@ App::patch('/v1/projects/:projectId/oauth2') ->param('appId', '', new Text(256), 'Provider app ID. Max length: 256 chars.', true) ->param('secret', '', new text(512), 'Provider secret key. Max length: 512 chars.', true) ->action(function ($projectId, $provider, $appId, $secret, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -396,7 +396,7 @@ App::delete('/v1/projects/:projectId') ->param('projectId', '', new UID(), 'Project unique ID.') ->param('password', '', new UID(), 'Your user password for confirmation. Must be between 6 to 32 chars.') ->action(function ($projectId, $password, $response, $user, $consoleDB, $deletes) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $consoleDB */ /** @var Appwrite\Event\Event $deletes */ @@ -450,7 +450,7 @@ App::post('/v1/projects/:projectId/webhooks') ->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true) ->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true) ->action(function ($projectId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -501,7 +501,7 @@ App::get('/v1/projects/:projectId/webhooks') ->label('sdk.method', 'listWebhooks') ->param('projectId', '', new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -524,7 +524,7 @@ App::get('/v1/projects/:projectId/webhooks/:webhookId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('webhookId', null, new UID(), 'Webhook unique ID.') ->action(function ($projectId, $webhookId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -557,7 +557,7 @@ App::put('/v1/projects/:projectId/webhooks/:webhookId') ->param('httpUser', '', new Text(256), 'Webhook HTTP user. Max length: 256 chars.', true) ->param('httpPass', '', new Text(256), 'Webhook HTTP password. Max length: 256 chars.', true) ->action(function ($projectId, $webhookId, $name, $events, $url, $security, $httpUser, $httpPass, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -599,7 +599,7 @@ App::delete('/v1/projects/:projectId/webhooks/:webhookId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('webhookId', null, new UID(), 'Webhook unique ID.') ->action(function ($projectId, $webhookId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -633,7 +633,7 @@ App::post('/v1/projects/:projectId/keys') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list.') ->action(function ($projectId, $name, $scopes, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -679,7 +679,7 @@ App::get('/v1/projects/:projectId/keys') ->label('sdk.method', 'listKeys') ->param('projectId', null, new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -726,7 +726,7 @@ App::put('/v1/projects/:projectId/keys/:keyId') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('scopes', null, new ArrayList(new WhiteList(Config::getParam('scopes'), true)), 'Key scopes list') ->action(function ($projectId, $keyId, $name, $scopes, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -762,7 +762,7 @@ App::delete('/v1/projects/:projectId/keys/:keyId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('keyId', null, new UID(), 'Key unique ID.') ->action(function ($projectId, $keyId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -803,7 +803,7 @@ App::post('/v1/projects/:projectId/tasks') ->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true) ->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true) ->action(function ($projectId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -869,7 +869,7 @@ App::get('/v1/projects/:projectId/tasks') ->label('sdk.method', 'listTasks') ->param('projectId', '', new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -892,7 +892,7 @@ App::get('/v1/projects/:projectId/tasks/:taskId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('taskId', null, new UID(), 'Task unique ID.') ->action(function ($projectId, $taskId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -928,7 +928,7 @@ App::put('/v1/projects/:projectId/tasks/:taskId') ->param('httpUser', '', new Text(256), 'Task HTTP user. Max length: 256 chars.', true) ->param('httpPass', '', new Text(256), 'Task HTTP password. Max length: 256 chars.', true) ->action(function ($projectId, $taskId, $name, $status, $schedule, $security, $httpMethod, $httpUrl, $httpHeaders, $httpUser, $httpPass, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -982,7 +982,7 @@ App::delete('/v1/projects/:projectId/tasks/:taskId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('taskId', null, new UID(), 'Task unique ID.') ->action(function ($projectId, $taskId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1019,7 +1019,7 @@ App::post('/v1/projects/:projectId/platforms') ->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true) ->param('hostname', '', new Text(256), 'Platform client hostname. Max length: 256 chars.', true) ->action(function ($projectId, $type, $name, $key, $store, $hostname, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1069,7 +1069,7 @@ App::get('/v1/projects/:projectId/platforms') ->label('sdk.method', 'listPlatforms') ->param('projectId', '', new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1092,7 +1092,7 @@ App::get('/v1/projects/:projectId/platforms/:platformId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('platformId', null, new UID(), 'Platform unique ID.') ->action(function ($projectId, $platformId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1123,7 +1123,7 @@ App::put('/v1/projects/:projectId/platforms/:platformId') ->param('store', '', new Text(256), 'App store or Google Play store ID. Max length: 256 chars.', true) ->param('hostname', '', new Text(256), 'Platform client URL. Max length: 256 chars.', true) ->action(function ($projectId, $platformId, $name, $key, $store, $hostname, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1162,7 +1162,7 @@ App::delete('/v1/projects/:projectId/platforms/:platformId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('platformId', null, new UID(), 'Platform unique ID.') ->action(function ($projectId, $platformId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1195,7 +1195,7 @@ App::post('/v1/projects/:projectId/domains') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('domain', null, new DomainValidator(), 'Domain name.') ->action(function ($projectId, $domain, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1258,7 +1258,7 @@ App::get('/v1/projects/:projectId/domains') ->label('sdk.method', 'listDomains') ->param('projectId', '', new UID(), 'Project unique ID.') ->action(function ($projectId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1281,7 +1281,7 @@ App::get('/v1/projects/:projectId/domains/:domainId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('domainId', null, new UID(), 'Domain unique ID.') ->action(function ($projectId, $domainId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1308,7 +1308,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('domainId', null, new UID(), 'Domain unique ID.') ->action(function ($projectId, $domainId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); @@ -1366,7 +1366,7 @@ App::delete('/v1/projects/:projectId/domains/:domainId') ->param('projectId', null, new UID(), 'Project unique ID.') ->param('domainId', null, new UID(), 'Domain unique ID.') ->action(function ($projectId, $domainId, $response, $consoleDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $consoleDB */ $project = $consoleDB->getDocument($projectId); diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 55ae740373..2add12c612 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -38,7 +38,7 @@ App::post('/v1/storage/files') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->action(function ($file, $read, $write, $request, $response, $user, $projectDB, $webhooks, $audits, $usage) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ @@ -172,7 +172,7 @@ App::get('/v1/storage/files') ->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $results = $projectDB->getCollection([ @@ -204,7 +204,7 @@ App::get('/v1/storage/files/:fileId') ->label('sdk.description', '/docs/references/storage/get-file.md') ->param('fileId', '', new UID(), 'File unique ID.') ->action(function ($fileId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $file = $projectDB->getDocument($fileId); @@ -234,7 +234,7 @@ App::get('/v1/storage/files/:fileId/preview') ->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true) ->action(function ($fileId, $width, $height, $quality, $background, $output, $request, $response, $project, $projectDB) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ @@ -354,7 +354,7 @@ App::get('/v1/storage/files/:fileId/download') ->label('sdk.methodType', 'location') ->param('fileId', '', new UID(), 'File unique ID.') ->action(function ($fileId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $file = $projectDB->getDocument($fileId); @@ -410,7 +410,7 @@ App::get('/v1/storage/files/:fileId/view') ->param('fileId', '', new UID(), 'File unique ID.') ->param('as', '', new WhiteList(['pdf', /*'html',*/ 'text'], true), 'Choose a file format to convert your file to. Currently you can only convert word and pdf files to pdf or txt. This option is currently experimental only, use at your own risk.', true) ->action(function ($fileId, $as, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $file = $projectDB->getDocument($fileId); @@ -483,7 +483,7 @@ App::put('/v1/storage/files/:fileId') ->param('read', [], new ArrayList(new Text(64)), 'An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->param('write', [], new ArrayList(new Text(64)), 'An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.') ->action(function ($fileId, $read, $write, $response, $projectDB, $webhooks, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -529,7 +529,7 @@ App::delete('/v1/storage/files/:fileId') ->label('sdk.description', '/docs/references/storage/delete-file.md') ->param('fileId', '', new UID(), 'File unique ID.') ->action(function ($fileId, $response, $projectDB, $webhooks, $audits, $usage) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index ab0db7a259..75cfd0c067 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -30,7 +30,7 @@ App::post('/v1/teams') ->param('name', null, new Text(128), 'Team name. Max length: 128 chars.') ->param('roles', ['owner'], new ArrayList(new Key()), 'Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.', true) ->action(function ($name, $roles, $response, $user, $projectDB, $mode) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var bool $mode */ @@ -99,7 +99,7 @@ App::get('/v1/teams') ->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $results = $projectDB->getCollection([ @@ -127,7 +127,7 @@ App::get('/v1/teams/:teamId') ->label('sdk.description', '/docs/references/teams/get-team.md') ->param('teamId', '', new UID(), 'Team unique ID.') ->action(function ($teamId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $team = $projectDB->getDocument($teamId); @@ -150,7 +150,7 @@ App::put('/v1/teams/:teamId') ->param('teamId', '', new UID(), 'Team unique ID.') ->param('name', null, new Text(128), 'Team name. Max length: 128 chars.') ->action(function ($teamId, $name, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $team = $projectDB->getDocument($teamId); @@ -180,7 +180,7 @@ App::delete('/v1/teams/:teamId') ->label('sdk.description', '/docs/references/teams/delete-team.md') ->param('teamId', '', new UID(), 'Team unique ID.') ->action(function ($teamId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $team = $projectDB->getDocument($teamId); @@ -225,7 +225,7 @@ App::post('/v1/teams/:teamId/memberships') ->param('roles', [], new ArrayList(new Key()), 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.') ->param('url', '', function ($clients) { return new Host($clients); }, 'URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) // TODO add our own built-in confirm page ->action(function ($teamId, $email, $name, $roles, $url, $response, $project, $user, $projectDB, $locale, $audits, $mails, $mode) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ @@ -422,7 +422,7 @@ App::get('/v1/teams/:teamId/memberships') ->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($teamId, $search, $limit, $offset, $orderType, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $team = $projectDB->getDocument($teamId); @@ -481,7 +481,7 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status') ->param('secret', '', new Text(256), 'Secret key.') ->action(function ($teamId, $inviteId, $userId, $secret, $request, $response, $user, $projectDB, $audits) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $user */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ @@ -608,7 +608,7 @@ App::delete('/v1/teams/:teamId/memberships/:inviteId') ->param('teamId', '', new UID(), 'Team unique ID.') ->param('inviteId', '', new UID(), 'Invite unique ID.') ->action(function ($teamId, $inviteId, $response, $projectDB, $audits) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 741d0c6611..89e828018b 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -30,7 +30,7 @@ App::post('/v1/users') ->param('password', '', new Password(), 'User password. Must be between 6 to 32 chars.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->action(function ($email, $password, $name, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $profile = $projectDB->getCollectionFirst([ // Get user by email address @@ -101,7 +101,7 @@ App::get('/v1/users') ->param('offset', 0, new Range(0, 2000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->param('orderType', 'ASC', new WhiteList(['ASC', 'DESC'], true), 'Order result by ASC or DESC order.', true) ->action(function ($search, $limit, $offset, $orderType, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $results = $projectDB->getCollection([ @@ -154,7 +154,7 @@ App::get('/v1/users/:userId') ->label('sdk.description', '/docs/references/users/get-user.md') ->param('userId', '', new UID(), 'User unique ID.') ->action(function ($userId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -197,7 +197,7 @@ App::get('/v1/users/:userId/prefs') ->label('sdk.description', '/docs/references/users/get-user-prefs.md') ->param('userId', '', new UID(), 'User unique ID.') ->action(function ($userId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -228,7 +228,7 @@ App::get('/v1/users/:userId/sessions') ->label('sdk.description', '/docs/references/users/get-user-sessions.md') ->param('userId', '', new UID(), 'User unique ID.') ->action(function ($userId, $response, $projectDB, $locale, $geodb) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Utopia\Locale\Locale $locale */ /** @var MaxMind\Db\Reader $geodb */ @@ -301,7 +301,7 @@ App::get('/v1/users/:userId/logs') ->label('sdk.description', '/docs/references/users/get-user-logs.md') ->param('userId', '', new UID(), 'User unique ID.') ->action(function ($userId, $response, $register, $project, $projectDB, $locale, $geodb) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Registry\Registry $register */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $projectDB */ @@ -393,7 +393,7 @@ App::patch('/v1/users/:userId/status') ->param('userId', '', new UID(), 'User unique ID.') ->param('status', '', new WhiteList([Auth::USER_STATUS_ACTIVATED, Auth::USER_STATUS_BLOCKED, Auth::USER_STATUS_UNACTIVATED], true), 'User Status code. To activate the user pass '.Auth::USER_STATUS_ACTIVATED.', to block the user pass '.Auth::USER_STATUS_BLOCKED.' and for disabling the user pass '.Auth::USER_STATUS_UNACTIVATED) ->action(function ($userId, $status, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -443,7 +443,7 @@ App::patch('/v1/users/:userId/prefs') ->param('userId', '', new UID(), 'User unique ID.') ->param('prefs', '', new Assoc(), 'Prefs key-value JSON object.') ->action(function ($userId, $prefs, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -487,7 +487,7 @@ App::delete('/v1/users/:userId/sessions/:sessionId') ->param('userId', '', new UID(), 'User unique ID.') ->param('sessionId', null, new UID(), 'User unique session ID.') ->action(function ($userId, $sessionId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -520,7 +520,7 @@ App::delete('/v1/users/:userId/sessions') ->label('abuse-limit', 100) ->param('userId', '', new UID(), 'User unique ID.') ->action(function ($userId, $response, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ $user = $projectDB->getDocument($userId); @@ -551,7 +551,7 @@ App::delete('/v1/users/:userId') ->label('abuse-limit', 100) ->param('userId', '', function () {return new UID();}, 'User unique ID.') ->action(function ($userId, $response, $projectDB, $deletes) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $deletes */ diff --git a/app/controllers/general.php b/app/controllers/general.php index b83630a23d..0f283d3f5e 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -247,7 +247,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audits, $usage, $deletes, $mode) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Event\Event $webhooks */ /** @var Appwrite\Event\Event $audits */ @@ -387,7 +387,7 @@ App::get('/manifest.json') ->label('scope', 'public') ->label('docs', false) ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->json([ 'name' => APP_NAME, diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index a1a4d6cf65..d64c46a2cd 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -8,7 +8,7 @@ use Utopia\Abuse\Adapters\TimeLimit; App::init(function ($utopia, $request, $response, $project, $user, $register) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Document $user */ /** @var Utopia\Registry\Registry $register */ diff --git a/app/controllers/shared/web.php b/app/controllers/shared/web.php index 383685e0d0..42d2a18c55 100644 --- a/app/controllers/shared/web.php +++ b/app/controllers/shared/web.php @@ -6,7 +6,7 @@ use Utopia\Config\Config; App::init(function ($utopia, $request, $response, $layout) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\View $layout */ /* AJAX check */ diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 6c2f7ba44c..47e1848a6f 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -19,7 +19,7 @@ App::init(function ($layout) { }, ['layout'], 'console'); App::shutdown(function ($response, $layout) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\View $layout */ $header = new View(__DIR__.'/../../views/console/comps/header.phtml'); @@ -213,7 +213,7 @@ App::get('/console/database/collection') ->label('scope', 'console') ->param('id', '', new UID(), 'Collection unique ID.') ->action(function ($id, $response, $layout, $projectDB) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\View $layout */ /** @var Appwrite\Database\Database $projectDB */ diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index f2cf21ffd5..7f7f419708 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -28,7 +28,7 @@ App::init(function ($layout) { }, ['layout'], 'home'); App::shutdown(function ($response, $layout) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\View $layout */ $response->html($layout->render()); @@ -39,7 +39,7 @@ App::get('/') ->label('permission', 'public') ->label('scope', 'home') ->action(function ($response) { - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $response->redirect('/auth/signin'); }, ['response']); @@ -190,7 +190,7 @@ App::get('/open-api-2.json') ->action(function ($platform, $extensions, $tests, $utopia, $request, $response) { /** @var Utopia\App $utopia */ /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ $security = [ APP_PLATFORM_CLIENT => ['Project' => []], diff --git a/app/init.php b/app/init.php index 8c3457dd3a..d372c62e61 100644 --- a/app/init.php +++ b/app/init.php @@ -362,7 +362,7 @@ App::setResource('clients', function($console, $project) { App::setResource('user', function($mode, $project, $console, $request, $response, $projectDB, $consoleDB) { /** @var Utopia\Swoole\Request $request */ - /** @var Utopia\Response $response */ + /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Document $project */ /** @var Appwrite\Database\Database $consoleDB */ /** @var Appwrite\Database\Database $projectDB */