Merge branch '0.7.x' of github.com:appwrite/appwrite into feat-upgrade-php-version
This commit is contained in:
commit
608cf36d1f
100 changed files with 2135 additions and 1141 deletions
|
@ -39,4 +39,4 @@ script:
|
|||
- docker-compose logs appwrite
|
||||
- docker exec appwrite doctor
|
||||
- docker exec appwrite vars
|
||||
- docker exec appwrite test
|
||||
- docker exec appwrite test
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
## Breaking Changes (Read before upgrading!)
|
||||
- **Deprecated** `first` and `last` query params for documents list route in the database API
|
||||
- **Deprecated** Deprectaed Pubjabi Translations ('pn')
|
||||
- **Deprecated** `PATCH /account/prefs` is now updating the prefs payload and not just merging it
|
||||
- **Deprecated** `PATCH /users/:userId/prefs` is now updating the prefs payload and not just merging it
|
||||
- Switched order of limit and offset params in all the SDKs `listDocuments` method for better consistency
|
||||
- Default `limit` param value in all the SDKs `listDocuments` method is now 25 for better consistency
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ RUN chmod +x /usr/local/bin/doctor && \
|
|||
chmod +x /usr/local/bin/install && \
|
||||
chmod +x /usr/local/bin/migrate && \
|
||||
chmod +x /usr/local/bin/schedule && \
|
||||
chmod +x /usr/local/bin/sdks && \
|
||||
chmod +x /usr/local/bin/ssl && \
|
||||
chmod +x /usr/local/bin/test && \
|
||||
chmod +x /usr/local/bin/vars && \
|
||||
|
|
|
@ -55,4 +55,16 @@ return [
|
|||
'storage.files.delete' => [
|
||||
'description' => 'This event triggers when a storage file is deleted.',
|
||||
],
|
||||
'users.create' => [
|
||||
'description' => 'This event triggers when a user is created from the users API.',
|
||||
],
|
||||
'users.update.status' => [
|
||||
'description' => 'This event triggers when a user status is updated from the users API.',
|
||||
],
|
||||
'users.delete' => [
|
||||
'description' => 'This event triggers when a user is deleted from users API.',
|
||||
],
|
||||
'users.sessions.delete' => [
|
||||
'description' => 'This event triggers when a user session is deleted from users API.',
|
||||
],
|
||||
];
|
|
@ -55,8 +55,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $webhooks */
|
||||
|
@ -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,8 +261,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
|
||||
$protocol = $request->getProtocol();
|
||||
|
@ -306,8 +306,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$domain = $request->getHostname();
|
||||
$protocol = $request->getProtocol();
|
||||
|
@ -331,8 +331,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$domain = $request->getHostname();
|
||||
$protocol = $request->getProtocol();
|
||||
|
@ -357,8 +357,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @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 */
|
||||
|
@ -648,7 +648,6 @@ App::get('/v1/account/sessions')
|
|||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -669,7 +668,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 */
|
||||
|
@ -732,7 +731,6 @@ App::get('/v1/account/logs')
|
|||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -753,7 +751,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 +793,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 +839,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 +899,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 */
|
||||
|
@ -944,8 +942,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
@ -1007,8 +1005,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
@ -1071,8 +1069,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
@ -1129,8 +1127,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Utopia\Locale\Locale $locale */
|
||||
|
@ -1237,7 +1235,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 */
|
||||
|
||||
|
@ -1306,8 +1304,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
|
@ -1402,7 +1400,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 */
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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);
|
||||
|
@ -529,8 +529,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @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 */
|
||||
|
|
|
@ -352,7 +352,7 @@ App::get('/v1/functions/:functionId/tags/:tagId')
|
|||
|
||||
$tag = $projectDB->getDocument($tagId);
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found', 404);
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ App::delete('/v1/functions/:functionId/tags/:tagId')
|
|||
|
||||
$tag = $projectDB->getDocument($tagId);
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found', 404);
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -428,7 +428,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
|
||||
$tag = $projectDB->getDocument($function->getAttribute('tag'));
|
||||
|
||||
if($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($tag->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404);
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ App::post('/v1/functions/:functionId/executions')
|
|||
throw new Exception('Failed saving execution to DB', 500);
|
||||
}
|
||||
|
||||
if((bool)$async) {
|
||||
if ((bool)$async) {
|
||||
// Issue a TLS certificate when domain is verified
|
||||
Resque::enqueue('v1-functions', 'FunctionsV1', [
|
||||
'projectId' => $project->getId(),
|
||||
|
@ -527,7 +527,7 @@ App::get('/v1/functions/:functionId/executions/:executionId')
|
|||
|
||||
$execution = $projectDB->getDocument($executionId);
|
||||
|
||||
if($execution->getAttribute('functionId') !== $function->getId()) {
|
||||
if ($execution->getAttribute('functionId') !== $function->getId()) {
|
||||
throw new Exception('Execution not found', 404);
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -12,8 +12,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @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');
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -37,8 +37,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @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);
|
||||
|
@ -233,8 +233,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @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 */
|
||||
|
|
|
@ -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);
|
||||
|
@ -480,8 +480,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
@ -594,7 +594,6 @@ App::patch('/v1/teams/:teamId/memberships/:inviteId/status')
|
|||
'email' => $user->getAttribute('email'),
|
||||
'name' => $user->getAttribute('name'),
|
||||
])), Response::MODEL_MEMBERSHIP);
|
||||
|
||||
}, ['request', 'response', 'user', 'projectDB', 'audits']);
|
||||
|
||||
App::delete('/v1/teams/:teamId/memberships/:inviteId')
|
||||
|
@ -608,7 +607,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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
@ -279,7 +279,6 @@ App::get('/v1/users/:userId/sessions')
|
|||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$sessions[$index]['geo']['isoCode'] = '--';
|
||||
$sessions[$index]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -301,7 +300,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 */
|
||||
|
@ -365,14 +364,13 @@ App::get('/v1/users/:userId/logs')
|
|||
try {
|
||||
$record = $geodb->get($log['ip']);
|
||||
|
||||
if($record){
|
||||
if ($record) {
|
||||
$output[$i]['geo']['isoCode'] = \strtolower($record['country']['iso_code']);
|
||||
$output[$i]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown');
|
||||
} else{
|
||||
} else {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$output[$i]['geo']['isoCode'] = '--';
|
||||
$output[$i]['geo']['country'] = $locale->getText('locale.country.unknown');
|
||||
|
@ -393,7 +391,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 +441,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 +485,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 +518,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 +549,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 */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -16,13 +16,14 @@ use Appwrite\Database\Validator\Authorization;
|
|||
use Appwrite\Network\Validator\Origin;
|
||||
use Appwrite\Storage\Device\Local;
|
||||
use Appwrite\Storage\Storage;
|
||||
use Utopia\CLI\Console;
|
||||
|
||||
Config::setParam('domainVerification', false);
|
||||
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 */
|
||||
|
@ -44,7 +45,7 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
if(!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) {
|
||||
if (!empty($route->getLabel('sdk.platform', [])) && empty($project->getId()) && ($route->getLabel('scope', '') !== 'public')) {
|
||||
throw new Exception('Missing or unknown project ID', 400);
|
||||
}
|
||||
|
||||
|
@ -99,8 +100,8 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
* @see https://www.owasp.org/index.php/List_of_useful_HTTP_headers
|
||||
*/
|
||||
if (App::getEnv('_APP_OPTIONS_FORCE_HTTPS', 'disabled') === 'enabled') { // Force HTTPS
|
||||
if($request->getProtocol() !== 'https') {
|
||||
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
||||
if ($request->getProtocol() !== 'https') {
|
||||
return $response->redirect('https://'.$request->getHostname().$request->getURI());
|
||||
}
|
||||
|
||||
$response->addHeader('Strict-Transport-Security', 'max-age='.(60 * 60 * 24 * 126)); // 126 days
|
||||
|
@ -126,11 +127,11 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
$origin = $request->getOrigin($request->getReferer(''));
|
||||
$originValidator = new Origin(\array_merge($project->getAttribute('platforms', []), $console->getAttribute('platforms', [])));
|
||||
|
||||
if(!$originValidator->isValid($origin)
|
||||
if (!$originValidator->isValid($origin)
|
||||
&& \in_array($request->getMethod(), [Request::METHOD_POST, Request::METHOD_PUT, Request::METHOD_PATCH, Request::METHOD_DELETE])
|
||||
&& $route->getLabel('origin', false) !== '*'
|
||||
&& empty($request->getHeader('x-appwrite-key', ''))) {
|
||||
throw new Exception($originValidator->getDescription(), 403);
|
||||
throw new Exception($originValidator->getDescription(), 403);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -183,7 +184,10 @@ App::init(function ($utopia, $request, $response, $console, $project, $user, $lo
|
|||
Authorization::setDefaultStatus(false); // Cancel security segmentation for API keys.
|
||||
}
|
||||
|
||||
Authorization::setRole('user:'.$user->getId());
|
||||
if ($user->getId()) {
|
||||
Authorization::setRole('user:'.$user->getId());
|
||||
}
|
||||
|
||||
Authorization::setRole('role:'.$role);
|
||||
|
||||
\array_map(function ($node) {
|
||||
|
@ -246,8 +250,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Event\Event $webhooks */
|
||||
/** @var Appwrite\Event\Event $audits */
|
||||
|
@ -269,7 +273,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $webhooks, $audi
|
|||
|
||||
$route = $utopia->match($request);
|
||||
|
||||
if($project->getId()
|
||||
if ($project->getId()
|
||||
&& $mode !== APP_MODE_ADMIN
|
||||
&& !empty($route->getLabel('sdk.namespace', null))) { // Don't calculate console usage and admin mode
|
||||
|
||||
|
@ -282,7 +286,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,16 +304,21 @@ 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 */
|
||||
|
||||
if(php_sapi_name() === 'cli') {
|
||||
var_dump(get_class($error));
|
||||
var_dump($error->getMessage());
|
||||
var_dump($error->getFile());
|
||||
var_dump($error->getLine());
|
||||
$route = $utopia->match($request);
|
||||
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||
|
||||
if (php_sapi_name() === 'cli') {
|
||||
Console::error('[Error] Method: '.$route->getMethod());
|
||||
Console::error('[Error] URL: '.$route->getURL());
|
||||
Console::error('[Error] Type: '.get_class($error));
|
||||
Console::error('[Error] Message: '.$error->getMessage());
|
||||
Console::error('[Error] File: '.$error->getFile());
|
||||
Console::error('[Error] Line: '.$error->getLine());
|
||||
}
|
||||
|
||||
$version = App::getEnv('_APP_VERSION', 'UNKNOWN');
|
||||
|
@ -352,10 +361,7 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
|||
->addHeader('Pragma', 'no-cache')
|
||||
->setStatusCode($code)
|
||||
;
|
||||
|
||||
$route = $utopia->match($request);
|
||||
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||
|
||||
|
||||
if ($template) {
|
||||
$comp = new View($template);
|
||||
|
||||
|
@ -379,7 +385,6 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
|||
|
||||
$response->dynamic(new Document($output),
|
||||
$utopia->isDevelopment() ? Response::MODEL_ERROR_DEV : Response::MODEL_LOCALE);
|
||||
|
||||
}, ['error', 'utopia', 'request', 'response', 'layout', 'project']);
|
||||
|
||||
App::get('/manifest.json')
|
||||
|
@ -387,7 +392,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,
|
||||
|
@ -413,7 +418,7 @@ App::get('/robots.txt')
|
|||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->action(function ($response) {
|
||||
$template = new View(__DIR__.'/views/general/robots.phtml');
|
||||
$template = new View(__DIR__.'/../views/general/robots.phtml');
|
||||
$response->text($template->render(false));
|
||||
}, ['response']);
|
||||
|
||||
|
@ -422,7 +427,7 @@ App::get('/humans.txt')
|
|||
->label('scope', 'public')
|
||||
->label('docs', false)
|
||||
->action(function ($response) {
|
||||
$template = new View(__DIR__.'/views/general/humans.phtml');
|
||||
$template = new View(__DIR__.'/../views/general/humans.phtml');
|
||||
$response->text($template->render(false));
|
||||
}, ['response']);
|
||||
|
||||
|
@ -435,25 +440,25 @@ App::get('/.well-known/acme-challenge')
|
|||
$path = \str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
|
||||
$absolute = \realpath($base.'/.well-known/acme-challenge/'.$path);
|
||||
|
||||
if(!$base) {
|
||||
if (!$base) {
|
||||
throw new Exception('Storage error', 500);
|
||||
}
|
||||
|
||||
if(!$absolute) {
|
||||
if (!$absolute) {
|
||||
throw new Exception('Unknown path', 404);
|
||||
}
|
||||
|
||||
if(!\substr($absolute, 0, \strlen($base)) === $base) {
|
||||
if (!\substr($absolute, 0, \strlen($base)) === $base) {
|
||||
throw new Exception('Invalid path', 401);
|
||||
}
|
||||
|
||||
if(!\file_exists($absolute)) {
|
||||
if (!\file_exists($absolute)) {
|
||||
throw new Exception('Unknown path', 404);
|
||||
}
|
||||
|
||||
$content = @\file_get_contents($absolute);
|
||||
|
||||
if(!$content) {
|
||||
if (!$content) {
|
||||
throw new Exception('Failed to get contents', 500);
|
||||
}
|
||||
|
||||
|
@ -463,6 +468,6 @@ App::get('/.well-known/acme-challenge')
|
|||
include_once __DIR__ . '/shared/api.php';
|
||||
include_once __DIR__ . '/shared/web.php';
|
||||
|
||||
foreach(Config::getParam('services', []) as $service) {
|
||||
foreach (Config::getParam('services', []) as $service) {
|
||||
include_once $service['controller'];
|
||||
}
|
|
@ -7,8 +7,8 @@ use Utopia\Abuse\Adapters\TimeLimit;
|
|||
|
||||
App::init(function ($utopia, $request, $response, $project, $user, $register) {
|
||||
/** @var Utopia\App $utopia */
|
||||
/** @var Utopia\Request $request */
|
||||
/** @var Utopia\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Database\Document $user */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
|
|
|
@ -5,8 +5,8 @@ use Utopia\Config\Config;
|
|||
|
||||
App::init(function ($utopia, $request, $response, $layout) {
|
||||
/** @var Utopia\App $utopia */
|
||||
/** @var Utopia\Request $request */
|
||||
/** @var Utopia\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\View $layout */
|
||||
|
||||
/* AJAX check */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
@ -385,10 +385,9 @@ App::get('/console/version')
|
|||
try {
|
||||
$version = \json_decode(@\file_get_contents(App::getEnv('_APP_HOME', 'http://localhost').'/v1/health/version'), true);
|
||||
|
||||
if($version && isset($version['version'])) {
|
||||
if ($version && isset($version['version'])) {
|
||||
return $response->json(['version' => $version['version']]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Exception('Failed to check for a newer version', 500);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
|
|
@ -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']);
|
||||
|
@ -189,8 +189,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$security = [
|
||||
APP_PLATFORM_CLIENT => ['Project' => []],
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
use Appwrite\Swoole\Files;
|
||||
use Appwrite\Swoole\Request;
|
||||
use Appwrite\Swoole\Response;
|
||||
use Utopia\Swoole\Files;
|
||||
use Utopia\Swoole\Request;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Swoole\Process;
|
||||
use Swoole\Http\Server;
|
||||
use Swoole\Http\Request as SwooleRequest;
|
||||
|
|
22
app/init.php
22
app/init.php
|
@ -36,7 +36,7 @@ const APP_EMAIL_SECURITY = 'security@localhost.test'; // Default security email
|
|||
const APP_USERAGENT = APP_NAME.'-Server v%s. Please report abuse at %s';
|
||||
const APP_MODE_ADMIN = 'admin';
|
||||
const APP_PAGING_LIMIT = 12;
|
||||
const APP_CACHE_BUSTER = 127;
|
||||
const APP_CACHE_BUSTER = 138;
|
||||
const APP_VERSION_STABLE = '0.7.0';
|
||||
const APP_STORAGE_UPLOADS = '/storage/uploads';
|
||||
const APP_STORAGE_FUNCTIONS = '/storage/functions';
|
||||
|
@ -199,6 +199,9 @@ $register->set('smtp', function () {
|
|||
|
||||
return $mail;
|
||||
});
|
||||
$register->set('geodb', function () {
|
||||
return new Reader(__DIR__.'/db/DBIP/dbip-country-lite-2020-01.mmdb');
|
||||
});
|
||||
$register->set('queue-webhooks', function () {
|
||||
return new Event('v1-webhooks', 'WebhooksV1');
|
||||
});
|
||||
|
@ -361,8 +364,8 @@ 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\Response $response */
|
||||
/** @var Utopia\Swoole\Request $request */
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Appwrite\Database\Document $project */
|
||||
/** @var Appwrite\Database\Database $consoleDB */
|
||||
/** @var Appwrite\Database\Database $projectDB */
|
||||
|
@ -423,7 +426,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();
|
||||
|
@ -444,7 +447,6 @@ App::setResource('consoleDB', function($register) {
|
|||
$consoleDB = new Database();
|
||||
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||
$consoleDB->setNamespace('app_console'); // Should be replaced with param if we want to have parent projects
|
||||
|
||||
$consoleDB->setMocks(Config::getParam('collections', []));
|
||||
|
||||
return $consoleDB;
|
||||
|
@ -460,11 +462,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 */
|
||||
return new Reader(__DIR__.'/db/DBIP/dbip-country-lite-2020-01.mmdb');
|
||||
}, ['request']);
|
||||
App::setResource('geodb', function($register) {
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
return $register->get('geodb');
|
||||
}, ['register']);
|
||||
|
|
|
@ -213,7 +213,6 @@ $cli
|
|||
Console::error('🔴 ' . $message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Console::log('');
|
||||
|
@ -232,4 +231,4 @@ $cli
|
|||
} catch (\Throwable $th) {
|
||||
Console::error('Failed to check for a newer version'."\n");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,15 +7,18 @@ use Utopia\CLI\Console;
|
|||
use Appwrite\Database\Database;
|
||||
use Appwrite\Database\Document;
|
||||
use Appwrite\Database\Validator\Authorization;
|
||||
use Appwrite\Database\Adapter\MySQL as MySQLAdapter;
|
||||
use Appwrite\Database\Adapter\Redis as RedisAdapter;
|
||||
|
||||
$callbacks = [
|
||||
'0.4.0' => function() {
|
||||
Console::log('I got nothing to do.');
|
||||
},
|
||||
'0.5.0' => function($project) use ($register, $projectDB, $requset) {
|
||||
|
||||
'0.5.0' => function($project) use ($register, $projectDB) {
|
||||
$db = $register->get('db');
|
||||
|
||||
Console::log('Migrating project: '.$project->getId());
|
||||
Console::log('Migrating project: '.$project->getAttribute('name').' ('.$project->getId().')');
|
||||
|
||||
// Update all documents $uid -> $id
|
||||
|
||||
|
@ -46,6 +49,7 @@ $callbacks = [
|
|||
try {
|
||||
$new = $projectDB->overwriteDocument($document->getArrayCopy());
|
||||
} catch (\Throwable $th) {
|
||||
var_dump($document);
|
||||
Console::error('Failed to update document: '.$th->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
@ -107,6 +111,14 @@ function fixDocument(Document $document) {
|
|||
}
|
||||
}
|
||||
|
||||
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_WEBHOOKS){
|
||||
$document->setAttribute('security', ($document->getAttribute('security')) ? true : false);
|
||||
}
|
||||
|
||||
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_TASKS){
|
||||
$document->setAttribute('security', ($document->getAttribute('security')) ? true : false);
|
||||
}
|
||||
|
||||
if($document->getAttribute('$collection') === Database::SYSTEM_COLLECTION_USERS) {
|
||||
foreach($providers as $key => $provider) {
|
||||
if(!empty($document->getAttribute('oauth'.\ucfirst($key)))) {
|
||||
|
@ -165,26 +177,38 @@ function fixDocument(Document $document) {
|
|||
|
||||
$cli
|
||||
->task('migrate')
|
||||
->action(function () use ($console, $projectDB, $consoleDB, $callbacks) {
|
||||
->action(function () use ($register, $callbacks) {
|
||||
Console::success('Starting Data Migration');
|
||||
|
||||
$consoleDB = new Database();
|
||||
$consoleDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||
$consoleDB->setNamespace('app_console'); // Main DB
|
||||
$consoleDB->setMocks(Config::getParam('collections', []));
|
||||
|
||||
$projectDB = new Database();
|
||||
$projectDB->setAdapter(new RedisAdapter(new MySQLAdapter($register), $register));
|
||||
$projectDB->setMocks(Config::getParam('collections', []));
|
||||
|
||||
$console = $consoleDB->getDocument('console');
|
||||
|
||||
Authorization::disable();
|
||||
|
||||
$limit = 30;
|
||||
$sum = 30;
|
||||
$offset = 0;
|
||||
$projects = [$console];
|
||||
$count = 0;
|
||||
|
||||
while ($sum >= 30) {
|
||||
foreach($projects as $project) {
|
||||
|
||||
$projectDB->setNamespace('app_'.$project->getId());
|
||||
|
||||
try {
|
||||
$callbacks['0.5.0']($project);
|
||||
$callbacks['0.5.0']($project, $projectDB);
|
||||
} catch (\Throwable $th) {
|
||||
throw $th;
|
||||
Console::error('Failed to update project ("'.$project->getId().'") version with error: '.$th->getMessage());
|
||||
$projectDB->setNamespace('app_console');
|
||||
$projectDB->deleteDocument($project->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,8 +225,9 @@ $cli
|
|||
|
||||
$sum = \count($projects);
|
||||
$offset = $offset + $limit;
|
||||
$count = $count + $sum;
|
||||
|
||||
Console::log('Fetched '.$sum.' projects...');
|
||||
Console::log('Fetched '.$count.'/'.$consoleDB->getSum().' projects...');
|
||||
}
|
||||
|
||||
Console::success('Data Migration Completed');
|
||||
|
|
|
@ -183,24 +183,6 @@
|
|||
data-name="projects"
|
||||
data-scope="console"></div>
|
||||
|
||||
<div class=""
|
||||
data-service="locale.get"
|
||||
data-name="locale"
|
||||
data-event="load"
|
||||
data-scope="console"></div>
|
||||
|
||||
<div class=""
|
||||
data-service="locale.getCountries"
|
||||
data-name="locale-countries"
|
||||
data-event="load"
|
||||
data-scope="console"></div>
|
||||
|
||||
<div class=""
|
||||
data-service="locale.getCountriesPhones"
|
||||
data-name="locale-countries-phones"
|
||||
data-event="load"
|
||||
data-scope="console"></div>
|
||||
|
||||
<div class="load-screen" data-ls-ui-loader>
|
||||
<div class="animation"><div></div><div></div><div></div><div></div></div>
|
||||
<img src="/images/appwrite.svg" alt="Appwrite Light Logo" class="force-light" loading="lazy" />
|
||||
|
|
|
@ -501,7 +501,7 @@ $maxCells = 10;
|
|||
<script type="text/html" id="template-validation-document-array-true">
|
||||
<label data-ls-attrs="for=rule-list-{{rule.$id}}" class="margin-bottom">Allowed Collections</label>
|
||||
|
||||
<div data-ls-loop="project-collections.collections" data-ls-as="project" data-ls-key="$index2" class="tiles cell-3 margin-bottom-negative" style="visibility: hidden">
|
||||
<div data-ls-loop="project-collections.collections" data-ls-as="project" data-ls-key="$index2" class="tiles cell-3 margin-bottom-negative">
|
||||
<div class="margin-bottom" data-ls-if="{{project.$id}} != {{router.params.id}}">
|
||||
<input type="checkbox" name="list" data-ls-attrs="value={{project.$id}}" data-ls-bind="{{rule.list}}" /> <span data-ls-bind="{{project.name}}"></span>
|
||||
</div>
|
||||
|
@ -511,7 +511,7 @@ $maxCells = 10;
|
|||
<script type="text/html" id="template-validation-document-array-false">
|
||||
<label data-ls-attrs="for=rule-list-{{rule.$id}}" class="margin-bottom">Allowed Collection</label>
|
||||
|
||||
<div data-ls-loop="project-collections.collections" data-ls-as="project" data-ls-key="$index2" class="tiles cell-3 margin-bottom-negative" style="visibility: hidden">
|
||||
<div data-ls-loop="project-collections.collections" data-ls-as="project" data-ls-key="$index2" class="tiles cell-3 margin-bottom-negative">
|
||||
<div class="margin-bottom" data-ls-if="{{project.$id}} != {{router.params.id}}">
|
||||
<input type="radio" name="list" data-ls-attrs="value={{project.$id}}" data-ls-bind="{{rule.list|firstElement}}" data-cast-to="array" required /> <span data-ls-bind="{{project.name}}"></span>
|
||||
</div>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
</div>
|
||||
|
||||
<div data-ls-if="0 != {{project-collections.sum}}">
|
||||
<ul data-ls-loop="project-collections.collections" data-ls-as="collection" data-ls-append="" class="tiles cell-3 margin-bottom-small" style="visibility: hidden">
|
||||
<ul data-ls-loop="project-collections.collections" data-ls-as="collection" data-ls-append="" class="tiles cell-3 margin-bottom-small">
|
||||
<li class="margin-bottom">
|
||||
<a data-ls-attrs="href=/console/database/collection?id={{collection.$id}}&project={{router.params.project}}" class="box">
|
||||
<div data-ls-bind="{{collection.name}}" class="text-one-liner margin-bottom text-bold"> </div>
|
||||
|
|
|
@ -29,7 +29,7 @@ if($type === 'document') {
|
|||
<button type="button" class="link"><i class="icon-down-dir"></i> Move Down</button>
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" data-ls-ui-trigger="splice-<?php echo $this->escape($namespace); ?>-{{$index}}" class="link" data-debug="1"><i class="icon-cancel"></i> Remove</button>
|
||||
<button type="button" data-ls-ui-trigger="splice-<?php echo $this->escape($namespace); ?>-{{$index}}" class="link"><i class="icon-cancel"></i> Remove</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@ $home = $this->getParam('home', '');
|
|||
<p class="margin-bottom-no">No Projects Found, Create your first project now.</p>
|
||||
</div>
|
||||
|
||||
<ul data-ls-loop="console-projects.projects" data-ls-as="project" data-ls-append="" class="tiles cell-3" style="visibility: hidden">
|
||||
<ul data-ls-loop="console-projects.projects" data-ls-as="project" data-ls-append="" class="tiles cell-3">
|
||||
<li class="margin-bottom">
|
||||
<a data-ls-attrs="href=/console/home?project={{project.$id}}" class="box">
|
||||
<div data-ls-bind="{{project.name}}" class="text-one-liner margin-bottom-tiny text-bold"> </div>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<div class="margin-bottom-tiny text-one-liner">
|
||||
<span data-ls-attrs="title={{task.name}} ({{task.failures}} errors)" data-ls-bind="{{task.name}}"></span>
|
||||
|
||||
<span data-ls-if="false === {{task.security}}" data-debug="1">
|
||||
<span data-ls-if="false === {{task.security}}">
|
||||
<span class="text-danger">SSL/TLS Disabled</span>
|
||||
</span>
|
||||
<span data-ls-if="0 !== {{task.failures}}">
|
||||
|
|
|
@ -135,7 +135,7 @@ $events = array_keys($this->getParam('events', []));
|
|||
</form>
|
||||
|
||||
<span data-ls-bind="{{webhook.name}}"></span> (<span data-ls-bind="{{webhook.events.length}}"></span> events)
|
||||
<span data-ls-if="false === {{webhook.security}}" data-debug="1">
|
||||
<span data-ls-if="false === {{webhook.security}}">
|
||||
<small class="text-danger">(SSL/TLS Disabled)</small>
|
||||
</span>
|
||||
<div class="margin-top-tiny">
|
||||
|
|
|
@ -243,6 +243,9 @@ services:
|
|||
- _APP_REDIS_PORT
|
||||
- _APP_SMTP_HOST
|
||||
- _APP_SMTP_PORT
|
||||
- _APP_SMTP_SECURE
|
||||
- _APP_SMTP_USERNAME
|
||||
- _APP_SMTP_PASSWORD
|
||||
|
||||
appwrite-schedule:
|
||||
image: appwrite/appwrite:<?php echo $version."\n"; ?>
|
||||
|
@ -259,7 +262,7 @@ services:
|
|||
- _APP_REDIS_PORT
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.3 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
image: appwrite/mariadb:1.1.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mariadb
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
|
|
3
bin/sdks
Normal file
3
bin/sdks
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
php /usr/src/code/app/cli.php sdks $@
|
|
@ -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",
|
||||
|
|
|
@ -88,7 +88,7 @@ services:
|
|||
- _APP_SMTP_PORT=25
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.3 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
image: appwrite/mariadb:1.1.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mariadb
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
|
|
|
@ -138,6 +138,7 @@ services:
|
|||
depends_on:
|
||||
- redis
|
||||
- mariadb
|
||||
- request-catcher
|
||||
environment:
|
||||
- _APP_ENV
|
||||
- _APP_SYSTEM_SECURITY_EMAIL_ADDRESS
|
||||
|
@ -287,7 +288,7 @@ services:
|
|||
- _APP_REDIS_PORT
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.3 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
image: appwrite/mariadb:1.1.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mariadb
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
|
@ -301,10 +302,10 @@ services:
|
|||
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
||||
- MYSQL_USER=${_APP_DB_USER}
|
||||
- MYSQL_PASSWORD=${_APP_DB_PASS}
|
||||
command: 'mysqld --innodb-flush-method=fsync'
|
||||
command: 'mysqld --innodb-flush-method=fsync' # add ' --query_cache_size=0' for DB tests
|
||||
# command: mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bu && mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bu
|
||||
|
||||
maildev:
|
||||
maildev: # used mainly for dev tests
|
||||
image: djfarrelly/maildev
|
||||
container_name: appwrite-maildev
|
||||
restart: unless-stopped
|
||||
|
@ -313,6 +314,15 @@ services:
|
|||
networks:
|
||||
- appwrite
|
||||
|
||||
request-catcher: # used mainly for dev tests
|
||||
image: smarterdm/http-request-catcher
|
||||
container_name: appwrite-request-catcher
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '5000:5000'
|
||||
networks:
|
||||
- appwrite
|
||||
|
||||
# smtp:
|
||||
# image: appwrite/smtp:1.2.0
|
||||
# container_name: appwrite-smtp
|
||||
|
|
|
@ -9,9 +9,14 @@ use Appwrite\Auth\OAuth2;
|
|||
|
||||
class Box extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $endpoint = 'https://account.box.com/api/oauth2/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourceEndpoint = 'https://api.box.com/2.0/';
|
||||
|
||||
/**
|
||||
|
@ -19,6 +24,9 @@ class Box extends OAuth2
|
|||
*/
|
||||
protected $user = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
'manage_app_users',
|
||||
];
|
||||
|
@ -148,5 +156,4 @@ class Box extends OAuth2
|
|||
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
|
@ -125,7 +125,7 @@ class Github extends OAuth2
|
|||
* @return array
|
||||
*/
|
||||
protected function getUser(string $accessToken)
|
||||
{
|
||||
{
|
||||
if (empty($this->user)) {
|
||||
$this->user = \json_decode($this->request('GET', 'https://api.github.com/user', ['Authorization: token '.\urlencode($accessToken)]), true);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ class MySQL extends Adapter
|
|||
|
||||
// Handle array of relations
|
||||
if (self::DATA_TYPE_ARRAY === $type) {
|
||||
if(!is_array($value)) { // Property should be of type array, if not = skip
|
||||
if (!is_array($value)) { // Property should be of type array, if not = skip
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -459,6 +459,7 @@ class MySQL extends Adapter
|
|||
throw new Exception('Empty namespace');
|
||||
}
|
||||
|
||||
$unique = 'app_'.$namespace.'.database.unique';
|
||||
$documents = 'app_'.$namespace.'.database.documents';
|
||||
$properties = 'app_'.$namespace.'.database.properties';
|
||||
$relationships = 'app_'.$namespace.'.database.relationships';
|
||||
|
@ -466,6 +467,7 @@ class MySQL extends Adapter
|
|||
$abuse = 'app_'.$namespace.'.abuse.abuse';
|
||||
|
||||
try {
|
||||
$this->getPDO()->prepare('DROP TABLE `'.$unique.'`;')->execute();
|
||||
$this->getPDO()->prepare('DROP TABLE `'.$documents.'`;')->execute();
|
||||
$this->getPDO()->prepare('DROP TABLE `'.$properties.'`;')->execute();
|
||||
$this->getPDO()->prepare('DROP TABLE `'.$relationships.'`;')->execute();
|
||||
|
|
|
@ -158,7 +158,7 @@ class Database
|
|||
$results = $this->adapter->getCollection($options);
|
||||
|
||||
foreach ($results as &$node) {
|
||||
$node = new Document($node);
|
||||
$node = $this->decode(new Document($node));
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
@ -317,13 +317,19 @@ class Database
|
|||
throw new AuthorizationException($validator->getDescription()); // var_dump($validator->getDescription()); return false;
|
||||
}
|
||||
|
||||
$new = $this->encode($new);
|
||||
|
||||
$validator = new Structure($this);
|
||||
|
||||
if (!$validator->isValid($new)) { // Make sure updated structure still apply collection rules (if any)
|
||||
throw new StructureException($validator->getDescription()); // var_dump($validator->getDescription()); return false;
|
||||
}
|
||||
|
||||
return new Document($this->adapter->updateDocument($data));
|
||||
$new = new Document($this->adapter->updateDocument($new->getArrayCopy()));
|
||||
|
||||
$new = $this->decode($new);
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,7 +458,7 @@ class Database
|
|||
$filters = $rule->getAttribute('filter', null);
|
||||
$value = $document->getAttribute($key, null);
|
||||
|
||||
if(($value !== null) && is_array($filters)) {
|
||||
if (($value !== null) && is_array($filters)) {
|
||||
foreach ($filters as $filter) {
|
||||
$value = $this->encodeAttribute($filter, $value);
|
||||
$document->setAttribute($key, $value);
|
||||
|
@ -473,7 +479,7 @@ class Database
|
|||
$filters = $rule->getAttribute('filter', null);
|
||||
$value = $document->getAttribute($key, null);
|
||||
|
||||
if(($value !== null) && is_array($filters)) {
|
||||
if (($value !== null) && is_array($filters)) {
|
||||
foreach (array_reverse($filters) as $filter) {
|
||||
$value = $this->decodeAttribute($filter, $value);
|
||||
$document->setAttribute($key, $value);
|
||||
|
@ -492,7 +498,7 @@ class Database
|
|||
*/
|
||||
static protected function encodeAttribute(string $name, $value)
|
||||
{
|
||||
if(!isset(self::$filters[$name])) {
|
||||
if (!isset(self::$filters[$name])) {
|
||||
throw new Exception('Filter not found');
|
||||
}
|
||||
|
||||
|
@ -513,7 +519,7 @@ class Database
|
|||
*/
|
||||
static protected function decodeAttribute(string $name, $value)
|
||||
{
|
||||
if(!isset(self::$filters[$name])) {
|
||||
if (!isset(self::$filters[$name])) {
|
||||
throw new Exception('Filter not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ class Document extends ArrayObject
|
|||
{
|
||||
$array = parent::getArrayCopy();
|
||||
|
||||
$output = array();
|
||||
$output = [];
|
||||
|
||||
foreach ($array as $key => &$value) {
|
||||
if (!empty($whitelist) && !\in_array($key, $whitelist)) { // Export only whitelisted fields
|
||||
|
|
|
@ -157,7 +157,7 @@ class Structure extends Validator
|
|||
foreach ($array as $key => $value) {
|
||||
$rule = $collection->search('key', $key, $rules);
|
||||
|
||||
if(!$rule) {
|
||||
if (!$rule) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class UID extends Validator
|
|||
return false;
|
||||
}
|
||||
|
||||
if(mb_strlen($value) > 32) {
|
||||
if (mb_strlen($value) > 32) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class Compose
|
|||
*/
|
||||
public function getService(string $name): Service
|
||||
{
|
||||
if(!isset($this->compose['services'][$name])) {
|
||||
if (!isset($this->compose['services'][$name])) {
|
||||
throw new Exception('Service not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,14 @@ class Env
|
|||
*/
|
||||
public function __construct(string $data)
|
||||
{
|
||||
|
||||
$data = explode("\n", $data);
|
||||
|
||||
foreach($data as &$row) {
|
||||
foreach ($data as &$row) {
|
||||
$row = explode('=', $row);
|
||||
$key = (isset($row[0])) ? trim($row[0]) : null;
|
||||
$value = (isset($row[1])) ? trim($row[1]) : null;
|
||||
|
||||
if($key) {
|
||||
if ($key) {
|
||||
$this->vars[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,15 +73,15 @@ class PDOStatement extends PDOStatementNative
|
|||
$this->pdo = $this->pdo->reconnect();
|
||||
$this->PDOStatement = $this->pdo->prepare($this->PDOStatement->queryString, []);
|
||||
|
||||
foreach($this->values as $key => $set) {
|
||||
foreach ($this->values as $key => $set) {
|
||||
$this->PDOStatement->bindValue($key, $set['value'], $set['data_type']);
|
||||
}
|
||||
|
||||
foreach($this->params as $key => $set) {
|
||||
foreach ($this->params as $key => $set) {
|
||||
$this->PDOStatement->bindParam($key, $set['variable'], $set['data_type'], $set['length'], $set['driver_options']);
|
||||
}
|
||||
|
||||
foreach($this->columns as $key => $set) {
|
||||
foreach ($this->columns as $key => $set) {
|
||||
$this->PDOStatement->bindColumn($key, $set['param'], $set['type'], $set['maxlen'], $set['driverdata']);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class CNAME extends Validator
|
|||
*/
|
||||
public function isValid($domain)
|
||||
{
|
||||
if(!is_string($domain)) {
|
||||
if (!is_string($domain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ class Domain extends Validator
|
|||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if(empty($value)) {
|
||||
if (empty($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!is_string($value)) {
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class Origin extends Validator
|
|||
*/
|
||||
public function isValid($origin)
|
||||
{
|
||||
if(!is_string($origin)) {
|
||||
if (!is_string($origin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class Storage
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $devices = array();
|
||||
public static $devices = [];
|
||||
|
||||
/**
|
||||
* Set Device.
|
||||
|
|
|
@ -24,7 +24,7 @@ class FileName extends Validator
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!is_string($name)) {
|
||||
if (!is_string($name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class FileSize extends Validator
|
|||
*/
|
||||
public function isValid($fileSize)
|
||||
{
|
||||
if(!is_int($fileSize)) {
|
||||
if (!is_int($fileSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class Upload extends Validator
|
|||
*/
|
||||
public function isValid($path)
|
||||
{
|
||||
if(!is_string($path)) {
|
||||
if (!is_string($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,176 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Swoole;
|
||||
|
||||
use Exception;
|
||||
|
||||
class Files
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static protected $loaded = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
static protected $count = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static protected $mimeTypes = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static protected $extensions = [
|
||||
'css' => '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'];
|
||||
}
|
||||
}
|
|
@ -1,339 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Swoole;
|
||||
|
||||
use Utopia\Request as UtopiaRequest;
|
||||
use Swoole\Http\Request as SwooleRequest;
|
||||
|
||||
class Request extends UtopiaRequest
|
||||
{
|
||||
/**
|
||||
* Swoole Request Object
|
||||
*
|
||||
* @var SwooleRequest
|
||||
*/
|
||||
protected $swoole;
|
||||
|
||||
/**
|
||||
* Request constructor.
|
||||
*/
|
||||
public function __construct(SwooleRequest $request)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Swoole;
|
||||
|
||||
use Appwrite\Utopia\Response as UtopiaResponse;
|
||||
use Swoole\Http\Response as SwooleResponse;
|
||||
|
||||
class Response extends UtopiaResponse
|
||||
{
|
||||
/**
|
||||
* Swoole Response Object
|
||||
*
|
||||
* @var SwooleResponse
|
||||
*/
|
||||
protected $swoole;
|
||||
|
||||
/**
|
||||
* Mime Types
|
||||
* with compression support
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $compressed = [
|
||||
'text/plain' => 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;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ class Cron extends Validator
|
|||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if(empty($value)) {
|
||||
if (empty($value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +205,7 @@ class Response extends UtopiaResponse
|
|||
*/
|
||||
public function getModel(string $key): Model
|
||||
{
|
||||
if(!isset($this->models[$key])) {
|
||||
if (!isset($this->models[$key])) {
|
||||
throw new Exception('Undefined model: '.$key);
|
||||
}
|
||||
|
||||
|
@ -120,29 +224,36 @@ 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 = [];
|
||||
|
||||
foreach($model->getRules() as $key => $rule) {
|
||||
if(!$document->isSet($key)) {
|
||||
if(!is_null($rule['default'])) {
|
||||
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);
|
||||
} else {
|
||||
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');
|
||||
if ($rule['array']) {
|
||||
if (!is_array($data[$key])) {
|
||||
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 +262,8 @@ class Response extends UtopiaResponse
|
|||
$output[$key] = $data[$key];
|
||||
}
|
||||
|
||||
$this->payload = $output;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -168,7 +281,7 @@ class Response extends UtopiaResponse
|
|||
*/
|
||||
public function yaml(array $data): void
|
||||
{
|
||||
if(!extension_loaded('yaml')) {
|
||||
if (!extension_loaded('yaml')) {
|
||||
throw new Exception('Missing yaml extension. Learn more at: https://www.php.net/manual/en/book.yaml.php');
|
||||
}
|
||||
|
||||
|
@ -177,4 +290,12 @@ class Response extends UtopiaResponse
|
|||
->send(yaml_emit($data, YAML_UTF8_ENCODING))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPayload():array
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
34
src/Appwrite/Utopia/Response/Model/Any.php
Normal file
34
src/Appwrite/Utopia/Response/Model/Any.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Any extends Model
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $any = true;
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Any';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_ANY;
|
||||
}
|
||||
}
|
|
@ -5,17 +5,36 @@ namespace Appwrite\Utopia\Response\Model;
|
|||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
abstract class BaseList extends Model
|
||||
class BaseList extends Model
|
||||
{
|
||||
public function __construct()
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $name = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true)
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
68
src/Appwrite/Utopia/Response/Model/Collection.php
Normal file
68
src/Appwrite/Utopia/Response/Model/Collection.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Collection extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
45
src/Appwrite/Utopia/Response/Model/Continent.php
Normal file
45
src/Appwrite/Utopia/Response/Model/Continent.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Continent extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
45
src/Appwrite/Utopia/Response/Model/Country.php
Normal file
45
src/Appwrite/Utopia/Response/Model/Country.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
76
src/Appwrite/Utopia/Response/Model/Currency.php
Normal file
76
src/Appwrite/Utopia/Response/Model/Currency.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
60
src/Appwrite/Utopia/Response/Model/Domain.php
Normal file
60
src/Appwrite/Utopia/Response/Model/Domain.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Domain extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
80
src/Appwrite/Utopia/Response/Model/Execution.php
Normal file
80
src/Appwrite/Utopia/Response/Model/Execution.php
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Execution extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
108
src/Appwrite/Utopia/Response/Model/Func.php
Normal file
108
src/Appwrite/Utopia/Response/Model/Func.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Func extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
57
src/Appwrite/Utopia/Response/Model/Key.php
Normal file
57
src/Appwrite/Utopia/Response/Model/Key.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Key extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
50
src/Appwrite/Utopia/Response/Model/Language.php
Normal file
50
src/Appwrite/Utopia/Response/Model/Language.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Language extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class MembershipList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
47
src/Appwrite/Utopia/Response/Model/Permissions.php
Normal file
47
src/Appwrite/Utopia/Response/Model/Permissions.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Permissions extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
50
src/Appwrite/Utopia/Response/Model/Phone.php
Normal file
50
src/Appwrite/Utopia/Response/Model/Phone.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Phone extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
77
src/Appwrite/Utopia/Response/Model/Platform.php
Normal file
77
src/Appwrite/Utopia/Response/Model/Platform.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Platform extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
166
src/Appwrite/Utopia/Response/Model/Project.php
Normal file
166
src/Appwrite/Utopia/Response/Model/Project.php
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
use Utopia\Config\Config;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
83
src/Appwrite/Utopia/Response/Model/Rule.php
Normal file
83
src/Appwrite/Utopia/Response/Model/Rule.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Rule extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -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,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
60
src/Appwrite/Utopia/Response/Model/Tag.php
Normal file
60
src/Appwrite/Utopia/Response/Model/Tag.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
125
src/Appwrite/Utopia/Response/Model/Task.php
Normal file
125
src/Appwrite/Utopia/Response/Model/Task.php
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Task extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
|
||||
class TeamList extends BaseList
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -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',
|
||||
|
|
74
src/Appwrite/Utopia/Response/Model/Webhook.php
Normal file
74
src/Appwrite/Utopia/Response/Model/Webhook.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model;
|
||||
|
||||
class Webhook extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->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;
|
||||
}
|
||||
}
|
|
@ -218,7 +218,7 @@ class Client
|
|||
case 'application/json':
|
||||
$json = json_decode($responseBody, true);
|
||||
|
||||
if($json === null) {
|
||||
if ($json === null) {
|
||||
throw new Exception('Failed to parse response: '.$responseBody);
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class Client
|
|||
|
||||
$responseHeaders['status-code'] = $responseStatus;
|
||||
|
||||
if($responseStatus === 500) {
|
||||
if ($responseStatus === 500) {
|
||||
echo 'Server error('.$method.': '.$path.'. Params: '.json_encode($params).'): '.json_encode($responseBody)."\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -47,4 +47,49 @@ class HTTPTest extends Scope
|
|||
$this->assertEquals(404, $response['body']['code']);
|
||||
$this->assertEquals('dev', $response['body']['version']);
|
||||
}
|
||||
|
||||
public function testManifest()
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/manifest.json', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
'content-type' => 'application/json',
|
||||
]), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertEquals('Appwrite', $response['body']['name']);
|
||||
$this->assertEquals('Appwrite', $response['body']['short_name']);
|
||||
$this->assertEquals('.', $response['body']['start_url']);
|
||||
$this->assertEquals('.', $response['body']['start_url']);
|
||||
$this->assertEquals('https://appwrite.io/', $response['body']['url']);
|
||||
$this->assertEquals('standalone', $response['body']['display']);
|
||||
}
|
||||
|
||||
public function testHumans()
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/humans.txt', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
]), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString('# humanstxt.org/', $response['body']);
|
||||
}
|
||||
|
||||
public function testRobots()
|
||||
{
|
||||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/robots.txt', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
]), []);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertStringContainsString('# robotstxt.org/', $response['body']);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ trait ProjectCustom
|
|||
*/
|
||||
public function getProject(): array
|
||||
{
|
||||
if(!empty(self::$project)) {
|
||||
if (!empty(self::$project)) {
|
||||
return self::$project;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ abstract class Scope extends TestCase
|
|||
sleep(10);
|
||||
$emails = json_decode(file_get_contents('http://maildev/email'), true);
|
||||
|
||||
if($emails && is_array($emails)) {
|
||||
if ($emails && is_array($emails)) {
|
||||
return end($emails);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ abstract class Scope extends TestCase
|
|||
*/
|
||||
public function getRoot(): array
|
||||
{
|
||||
if((self::$root)) {
|
||||
if ((self::$root)) {
|
||||
return self::$root;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ abstract class Scope extends TestCase
|
|||
*/
|
||||
public function getUser(): array
|
||||
{
|
||||
if(isset(self::$user[$this->getProject()['$id']])) {
|
||||
if (isset(self::$user[$this->getProject()['$id']])) {
|
||||
return self::$user[$this->getProject()['$id']];
|
||||
}
|
||||
|
||||
|
|
|
@ -6,5 +6,4 @@ use Tests\E2E\Client;
|
|||
|
||||
trait HealthBase
|
||||
{
|
||||
|
||||
}
|
|
@ -6,5 +6,4 @@ use Tests\E2E\Client;
|
|||
|
||||
trait ProjectsBase
|
||||
{
|
||||
|
||||
}
|
|
@ -139,7 +139,7 @@ class ProjectsConsoleClientTest extends Scope
|
|||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +198,7 @@ class ProjectsConsoleClientTest extends Scope
|
|||
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
|
||||
return $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,7 +256,7 @@ class ProjectsConsoleClientTest extends Scope
|
|||
* Test for SUCCESS
|
||||
*/
|
||||
|
||||
foreach($providers as $key => $provider) {
|
||||
foreach ($providers as $key => $provider) {
|
||||
$response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/oauth2', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
|
@ -279,7 +279,7 @@ class ProjectsConsoleClientTest extends Scope
|
|||
$this->assertNotEmpty($response['body']);
|
||||
$this->assertEquals($id, $response['body']['$id']);
|
||||
|
||||
foreach($providers as $key => $provider) {
|
||||
foreach ($providers as $key => $provider) {
|
||||
$this->assertEquals('AppId-'.ucfirst($key), $response['body']['usersOauth2'.ucfirst($key).'Appid']);
|
||||
$this->assertEquals('Secret-'.ucfirst($key), $response['body']['usersOauth2'.ucfirst($key).'Secret']);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ trait TeamsBase
|
|||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,7 +171,7 @@ trait TeamsBase
|
|||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
return [];
|
||||
}
|
||||
|
||||
public function testUpdateTeam():array
|
||||
|
|
|
@ -32,7 +32,7 @@ trait TeamsBaseClient
|
|||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ trait TeamsBaseServer
|
|||
* Test for FAILURE
|
||||
*/
|
||||
|
||||
return [];
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ services:
|
|||
- _APP_REDIS_PORT
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.3 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
image: appwrite/mariadb:1.1.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
container_name: appwrite-mariadb
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
|
|
|
@ -18,7 +18,7 @@ class ComposeTest extends TestCase
|
|||
{
|
||||
$data = @file_get_contents(__DIR__.'/../../resources/docker/docker-compose.yml');
|
||||
|
||||
if($data === false) {
|
||||
if ($data === false) {
|
||||
throw new Exception('Failed to read compose file');
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class EnvTest extends TestCase
|
|||
{
|
||||
$data = @file_get_contents(__DIR__.'/../../resources/docker/.env');
|
||||
|
||||
if($data === false) {
|
||||
if ($data === false) {
|
||||
throw new Exception('Failed to read compose file');
|
||||
}
|
||||
|
||||
|
|
|
@ -35,32 +35,32 @@ class EventTest extends TestCase
|
|||
public function testParams()
|
||||
{
|
||||
$this->object
|
||||
->setParam('key1', 'value1')
|
||||
->setParam('key2', 'value2')
|
||||
->setParam('eventKey1', 'eventValue1')
|
||||
->setParam('eventKey2', 'eventValue2')
|
||||
;
|
||||
|
||||
$this->object->trigger();
|
||||
|
||||
$this->assertEquals(null, $this->object->getParam('key1'));
|
||||
$this->assertEquals(null, $this->object->getParam('key2'));
|
||||
$this->assertEquals(null, $this->object->getParam('key3'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey1'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey2'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey3'));
|
||||
$this->assertEquals(\Resque::size($this->queue), 1);
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$this->object
|
||||
->setParam('key1', 'value1')
|
||||
->setParam('key2', 'value2')
|
||||
->setParam('eventKey1', 'eventValue1')
|
||||
->setParam('eventKey2', 'eventValue2')
|
||||
;
|
||||
|
||||
$this->assertEquals('value1', $this->object->getParam('key1'));
|
||||
$this->assertEquals('value2', $this->object->getParam('key2'));
|
||||
$this->assertEquals('eventValue1', $this->object->getParam('eventKey1'));
|
||||
$this->assertEquals('eventValue2', $this->object->getParam('eventKey2'));
|
||||
|
||||
$this->object->reset();
|
||||
|
||||
$this->assertEquals(null, $this->object->getParam('key1'));
|
||||
$this->assertEquals(null, $this->object->getParam('key2'));
|
||||
$this->assertEquals(null, $this->object->getParam('key3'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey1'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey2'));
|
||||
$this->assertEquals(null, $this->object->getParam('eventKey3'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,5 @@ class OriginTest extends TestCase
|
|||
|
||||
$this->assertEquals($validator->isValid('appwrite-windows://com.company.appname'), false);
|
||||
$this->assertEquals($validator->getDescription(), 'Invalid Origin. Register your new client (com.company.appname) as a new Windows platform on your project console dashboard');
|
||||
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ class StorageTest extends TestCase
|
|||
try {
|
||||
get_class(Storage::getDevice('disk-c'));
|
||||
$this->fail("Expected exception not thrown");
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->assertEquals('The device "disk-c" is not listed', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Appwrite\Swoole\Files;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FilesTest extends TestCase
|
||||
{
|
||||
public function testParse()
|
||||
{
|
||||
Files::load(__DIR__.'/../../../public');
|
||||
|
||||
$this->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'));
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue