Merge branch '1.9.x' of https://github.com/appwrite/appwrite into update-migration-processing

This commit is contained in:
fogelito
2026-05-26 09:57:42 +03:00
100 changed files with 676 additions and 1174 deletions
+49 -49
View File
@@ -8,6 +8,55 @@ return [
'enabled' => true, 'enabled' => true,
'beta' => false, 'beta' => false,
'sdks' => [ 'sdks' => [
[
'key' => 'web',
'name' => 'Web',
'version' => '22.4.0',
'url' => 'https://github.com/appwrite/sdk-for-web',
'package' => 'https://www.npmjs.com/package/appwrite',
'enabled' => true,
'beta' => false,
'dev' => false,
'hidden' => false,
'family' => APP_SDK_PLATFORM_CLIENT,
'prism' => 'javascript',
'source' => \realpath(__DIR__ . '/../sdks/client-web'),
'gitUrl' => 'git@github.com:appwrite/sdk-for-web.git',
'gitRepoName' => 'sdk-for-web',
'gitUserName' => 'appwrite',
'gitBranch' => 'dev',
'changelog' => \realpath(__DIR__ . '/../../docs/sdks/web/CHANGELOG.md'),
'demos' => [
[
'icon' => 'react.svg',
'name' => 'Todo App with React JS',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-react',
'url' => 'https://appwrite-todo-with-react.vercel.app/',
],
[
'icon' => 'vue.svg',
'name' => 'Todo App with Vue JS',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-vue',
'url' => 'https://appwrite-todo-with-vue.vercel.app/',
],
[
'icon' => 'angular.svg',
'name' => 'Todo App with Angular',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-angular',
'url' => 'https://appwrite-todo-with-angular.vercel.app/',
],
[
'icon' => 'svelte.svg',
'name' => 'Todo App with Svelte',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-svelte',
'url' => 'https://appwrite-todo-with-svelte.vercel.app/',
],
]
],
[ [
'key' => 'flutter', 'key' => 'flutter',
'name' => 'Flutter', 'name' => 'Flutter',
@@ -301,55 +350,6 @@ return [
'enabled' => true, 'enabled' => true,
'beta' => false, 'beta' => false,
'sdks' => [ 'sdks' => [
[
'key' => 'web',
'name' => 'Web',
'version' => '22.4.0',
'url' => 'https://github.com/appwrite/sdk-for-web',
'package' => 'https://www.npmjs.com/package/appwrite',
'enabled' => true,
'beta' => false,
'dev' => false,
'hidden' => false,
'family' => APP_SDK_PLATFORM_SERVER,
'prism' => 'javascript',
'source' => \realpath(__DIR__ . '/../sdks/client-web'),
'gitUrl' => 'git@github.com:appwrite/sdk-for-web.git',
'gitRepoName' => 'sdk-for-web',
'gitUserName' => 'appwrite',
'gitBranch' => 'dev',
'changelog' => \realpath(__DIR__ . '/../../docs/sdks/web/CHANGELOG.md'),
'demos' => [
[
'icon' => 'react.svg',
'name' => 'Todo App with React JS',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-react',
'url' => 'https://appwrite-todo-with-react.vercel.app/',
],
[
'icon' => 'vue.svg',
'name' => 'Todo App with Vue JS',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-vue',
'url' => 'https://appwrite-todo-with-vue.vercel.app/',
],
[
'icon' => 'angular.svg',
'name' => 'Todo App with Angular',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-angular',
'url' => 'https://appwrite-todo-with-angular.vercel.app/',
],
[
'icon' => 'svelte.svg',
'name' => 'Todo App with Svelte',
'description' => 'A simple Todo app that uses both the Appwrite account and database APIs.',
'source' => 'https://github.com/appwrite/todo-with-svelte',
'url' => 'https://appwrite-todo-with-svelte.vercel.app/',
],
]
],
[ [
'key' => 'nodejs', 'key' => 'nodejs',
'name' => 'Node.js', 'name' => 'Node.js',
+7 -5
View File
@@ -67,6 +67,7 @@ use Utopia\Emails\Email;
use Utopia\Emails\Validator\Email as EmailValidator; use Utopia\Emails\Validator\Email as EmailValidator;
use Utopia\Http\Http; use Utopia\Http\Http;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Enum;
use Utopia\Storage\Validator\FileName; use Utopia\Storage\Validator\FileName;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator; use Utopia\Validator;
@@ -1239,10 +1240,11 @@ Http::get('/v1/account/sessions/oauth2/:provider')
) )
], ],
contentType: ContentType::HTML, contentType: ContentType::HTML,
hide: [APP_SDK_PLATFORM_SERVER],
)) ))
->label('abuse-limit', 50) ->label('abuse-limit', 50)
->label('abuse-key', 'ip:{ip}') ->label('abuse-key', 'ip:{ip}')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('oAuthProviders'), fn ($node) => (!$node['mock'])))) . '.') ->param('provider', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('oAuthProviders'), fn ($node) => (!$node['mock'])))) . '.', enum: new Enum(name: 'OAuthProvider', exclude: ['mock', 'mock-unverified']))
->param('success', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator']) ->param('success', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator'])
->param('failure', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator']) ->param('failure', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator'])
->param('scopes', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) ->param('scopes', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
@@ -2008,7 +2010,7 @@ Http::get('/v1/account/tokens/oauth2/:provider')
)) ))
->label('abuse-limit', 50) ->label('abuse-limit', 50)
->label('abuse-key', 'ip:{ip}') ->label('abuse-key', 'ip:{ip}')
->param('provider', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('oAuthProviders'), fn ($node) => (!$node['mock'])))) . '.') ->param('provider', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders')), true), 'OAuth2 Provider. Currently, supported providers are: ' . \implode(', ', \array_keys(\array_filter(Config::getParam('oAuthProviders'), fn ($node) => (!$node['mock'])))) . '.', enum: new Enum(name: 'OAuthProvider', exclude: ['mock', 'mock-unverified']))
->param('success', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator']) ->param('success', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator'])
->param('failure', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator']) ->param('failure', '', fn ($redirectValidator) => $redirectValidator, 'URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project\'s 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, ['redirectValidator'])
->param('scopes', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) ->param('scopes', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true)
@@ -4514,7 +4516,7 @@ Http::post('/v1/account/targets/push')
group: 'pushTargets', group: 'pushTargets',
name: 'createPushTarget', name: 'createPushTarget',
description: '/docs/references/account/create-push-target.md', description: '/docs/references/account/create-push-target.md',
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::JWT], auth: [AuthType::ADMIN, AuthType::SESSION],
responses: [ responses: [
new SDKResponse( new SDKResponse(
code: Response::STATUS_CODE_CREATED, code: Response::STATUS_CODE_CREATED,
@@ -4598,7 +4600,7 @@ Http::put('/v1/account/targets/:targetId/push')
group: 'pushTargets', group: 'pushTargets',
name: 'updatePushTarget', name: 'updatePushTarget',
description: '/docs/references/account/update-push-target.md', description: '/docs/references/account/update-push-target.md',
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::JWT], auth: [AuthType::ADMIN, AuthType::SESSION],
responses: [ responses: [
new SDKResponse( new SDKResponse(
code: Response::STATUS_CODE_OK, code: Response::STATUS_CODE_OK,
@@ -4668,7 +4670,7 @@ Http::delete('/v1/account/targets/:targetId/push')
group: 'pushTargets', group: 'pushTargets',
name: 'deletePushTarget', name: 'deletePushTarget',
description: '/docs/references/account/delete-push-target.md', description: '/docs/references/account/delete-push-target.md',
auth: [AuthType::ADMIN, AuthType::SESSION, AuthType::JWT], auth: [AuthType::ADMIN, AuthType::SESSION],
responses: [ responses: [
new SDKResponse( new SDKResponse(
code: Response::STATUS_CODE_NOCONTENT, code: Response::STATUS_CODE_NOCONTENT,
+5 -4
View File
@@ -47,6 +47,7 @@ use Utopia\Database\Validator\UID;
use Utopia\Emails\Validator\Email; use Utopia\Emails\Validator\Email;
use Utopia\Http\Http; use Utopia\Http\Http;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Enum;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
@@ -364,7 +365,7 @@ Http::post('/v1/messaging/providers/smtp')
->param('port', 587, new Range(1, 65535), 'The default SMTP server port.', true) ->param('port', 587, new Range(1, 65535), 'The default SMTP server port.', true)
->param('username', '', new Text(0), 'Authentication username.', true) ->param('username', '', new Text(0), 'Authentication username.', true)
->param('password', '', new Text(0), 'Authentication password.', true) ->param('password', '', new Text(0), 'Authentication password.', true)
->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be omitted, \'ssl\', or \'tls\'', true) ->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be omitted, \'ssl\', or \'tls\'', true, enum: new Enum(name: 'SmtpEncryption'))
->param('autoTLS', true, new Boolean(), 'Enable SMTP AutoTLS feature.', true) ->param('autoTLS', true, new Boolean(), 'Enable SMTP AutoTLS feature.', true)
->param('mailer', '', new Text(0), 'The value to use for the X-Mailer header.', true) ->param('mailer', '', new Text(0), 'The value to use for the X-Mailer header.', true)
->param('fromName', '', new Text(128, 0), 'Sender Name.', true) ->param('fromName', '', new Text(128, 0), 'Sender Name.', true)
@@ -1602,7 +1603,7 @@ Http::patch('/v1/messaging/providers/smtp/:providerId')
->param('port', null, new Nullable(new Range(1, 65535)), 'SMTP port.', true) ->param('port', null, new Nullable(new Range(1, 65535)), 'SMTP port.', true)
->param('username', '', new Text(0), 'Authentication username.', true) ->param('username', '', new Text(0), 'Authentication username.', true)
->param('password', '', new Text(0), 'Authentication password.', true) ->param('password', '', new Text(0), 'Authentication password.', true)
->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be \'ssl\' or \'tls\'', true) ->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be \'ssl\' or \'tls\'', true, enum: new Enum(name: 'SmtpEncryption'))
->param('autoTLS', null, new Nullable(new Boolean()), 'Enable SMTP AutoTLS feature.', true) ->param('autoTLS', null, new Nullable(new Boolean()), 'Enable SMTP AutoTLS feature.', true)
->param('mailer', '', new Text(0), 'The value to use for the X-Mailer header.', true) ->param('mailer', '', new Text(0), 'The value to use for the X-Mailer header.', true)
->param('fromName', '', new Text(128), 'Sender Name.', true) ->param('fromName', '', new Text(128), 'Sender Name.', true)
@@ -3501,7 +3502,7 @@ Http::post('/v1/messaging/messages/push')
->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->param('contentAvailable', false, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) ->param('contentAvailable', false, new Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true)
->param('critical', false, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) ->param('critical', false, new Boolean(), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true)
->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification.', true) ->param('priority', 'high', new WhiteList(['normal', 'high']), 'Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification.', true, enum: new Enum(name: 'MessagePriority'))
->inject('queueForEvents') ->inject('queueForEvents')
->inject('dbForProject') ->inject('dbForProject')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -4388,7 +4389,7 @@ Http::patch('/v1/messaging/messages/push/:messageId')
->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true) ->param('scheduledAt', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.', true)
->param('contentAvailable', null, new Nullable(new Boolean()), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) ->param('contentAvailable', null, new Nullable(new Boolean()), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true)
->param('critical', null, new Nullable(new Boolean()), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true) ->param('critical', null, new Nullable(new Boolean()), 'If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform.', true)
->param('priority', null, new Nullable(new WhiteList(['normal', 'high'])), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true) ->param('priority', null, new Nullable(new WhiteList(['normal', 'high'])), 'Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification.', true, enum: new Enum(name: 'MessagePriority'))
->inject('queueForEvents') ->inject('queueForEvents')
->inject('dbForProject') ->inject('dbForProject')
->inject('dbForPlatform') ->inject('dbForPlatform')
+8 -1
View File
@@ -10,6 +10,7 @@ use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Datetime as DateTimeValidator; use Utopia\Database\Validator\Datetime as DateTimeValidator;
use Utopia\Http\Http; use Utopia\Http\Http;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
Http::get('/v1/project/usage') Http::get('/v1/project/usage')
@@ -31,7 +32,13 @@ Http::get('/v1/project/usage')
)) ))
->param('startDate', '', new DateTimeValidator(), 'Starting date for the usage') ->param('startDate', '', new DateTimeValidator(), 'Starting date for the usage')
->param('endDate', '', new DateTimeValidator(), 'End date for the usage') ->param('endDate', '', new DateTimeValidator(), 'End date for the usage')
->param('period', '1d', new WhiteList(['1h', '1d']), 'Period used', true) ->param('period', '1d', new WhiteList(['1h', '1d']), 'Period used', true, enum: new Enum(
name: 'ProjectUsageRange',
map: [
'1h' => 'OneHour',
'1d' => 'OneDay',
]
))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->inject('dbForProject') ->inject('dbForProject')
+5 -4
View File
@@ -63,6 +63,7 @@ use Utopia\Emails\Email;
use Utopia\Emails\Validator\Email as EmailValidator; use Utopia\Emails\Validator\Email as EmailValidator;
use Utopia\Http\Http; use Utopia\Http\Http;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Enum;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Assoc; use Utopia\Validator\Assoc;
@@ -432,7 +433,7 @@ Http::post('/v1/users/sha')
->param('userId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('userId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject'])
->param('email', '', new EmailValidator(), 'User email.') ->param('email', '', new EmailValidator(), 'User email.')
->param('password', '', new Password(), 'User password hashed using SHA.') ->param('password', '', new Password(), 'User password hashed using SHA.')
->param('passwordVersion', '', new WhiteList(['sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512']), "Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'", true) ->param('passwordVersion', '', new WhiteList(['sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512']), "Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'", true, enum: new Enum(name: 'PasswordHash'))
->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true)
->inject('response') ->inject('response')
->inject('project') ->inject('project')
@@ -606,7 +607,7 @@ Http::post('/v1/users/:userId/targets')
)) ))
->param('targetId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('targetId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject'])
->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject']) ->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject'])
->param('providerType', '', new WhiteList([MESSAGE_TYPE_EMAIL, MESSAGE_TYPE_SMS, MESSAGE_TYPE_PUSH]), 'The target provider type. Can be one of the following: `email`, `sms` or `push`.') ->param('providerType', '', new WhiteList([MESSAGE_TYPE_EMAIL, MESSAGE_TYPE_SMS, MESSAGE_TYPE_PUSH]), 'The target provider type. Can be one of the following: `email`, `sms` or `push`.', enum: new Enum(name: 'MessagingProviderType'))
->param('identifier', '', new Text(Database::LENGTH_KEY), 'The target identifier (token, email, phone etc.)') ->param('identifier', '', new Text(Database::LENGTH_KEY), 'The target identifier (token, email, phone etc.)')
->param('providerId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.', true, ['dbForProject']) ->param('providerId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.', true, ['dbForProject'])
->param('name', '', new Text(128), 'Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.', true) ->param('name', '', new Text(128), 'Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23.', true)
@@ -2318,7 +2319,7 @@ Http::delete('/v1/users/:userId/mfa/authenticators/:type')
) )
]) ])
->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject']) ->param('userId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'User ID.', false, ['dbForProject'])
->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.') ->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.', enum: new Enum(name: 'AuthenticatorType'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('queueForEvents') ->inject('queueForEvents')
@@ -2831,7 +2832,7 @@ Http::get('/v1/users/usage')
) )
] ]
)) ))
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(name: 'UsageRange'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
+2 -2
View File
@@ -67,7 +67,7 @@
"utopia-php/emails": "0.7.*", "utopia-php/emails": "0.7.*",
"utopia-php/dns": "1.7.*", "utopia-php/dns": "1.7.*",
"utopia-php/dsn": "0.2.1", "utopia-php/dsn": "0.2.1",
"utopia-php/http": "2.0.0-rc2", "utopia-php/http": "2.0.0-rc3",
"utopia-php/fetch": "^1.1", "utopia-php/fetch": "^1.1",
"utopia-php/validators": "0.2.*", "utopia-php/validators": "0.2.*",
"utopia-php/image": "0.8.*", "utopia-php/image": "0.8.*",
@@ -76,7 +76,7 @@
"utopia-php/logger": "0.8.*", "utopia-php/logger": "0.8.*",
"utopia-php/messaging": "0.22.*", "utopia-php/messaging": "0.22.*",
"utopia-php/migration": "1.*", "utopia-php/migration": "1.*",
"utopia-php/platform": "1.0.0-rc2", "utopia-php/platform": "1.0.0-rc3",
"utopia-php/pools": "1.*", "utopia-php/pools": "1.*",
"utopia-php/span": "1.1.*", "utopia-php/span": "1.1.*",
"utopia-php/preloader": "0.2.*", "utopia-php/preloader": "0.2.*",
Generated
+34 -34
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "b092fffec11494aea10b0c823b7837b8", "content-hash": "0f60e85b461aa1a57d624e97be0614bd",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@@ -3731,21 +3731,21 @@
}, },
{ {
"name": "utopia-php/cli", "name": "utopia-php/cli",
"version": "0.23.3", "version": "0.23.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/cli.git", "url": "https://github.com/utopia-php/cli.git",
"reference": "3c45ae5bcdcd3c7916e1909d74c60b8e771610db" "reference": "59f66e72ec1f8350968d8b95c0039faaac7a6d6d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/cli/zipball/3c45ae5bcdcd3c7916e1909d74c60b8e771610db", "url": "https://api.github.com/repos/utopia-php/cli/zipball/59f66e72ec1f8350968d8b95c0039faaac7a6d6d",
"reference": "3c45ae5bcdcd3c7916e1909d74c60b8e771610db", "reference": "59f66e72ec1f8350968d8b95c0039faaac7a6d6d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.4", "php": ">=7.4",
"utopia-php/servers": "0.4.0" "utopia-php/servers": "0.4.*"
}, },
"require-dev": { "require-dev": {
"laravel/pint": "1.2.*", "laravel/pint": "1.2.*",
@@ -3776,9 +3776,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/cli/issues", "issues": "https://github.com/utopia-php/cli/issues",
"source": "https://github.com/utopia-php/cli/tree/0.23.3" "source": "https://github.com/utopia-php/cli/tree/0.23.4"
}, },
"time": "2026-05-05T04:38:59+00:00" "time": "2026-05-21T14:42:15+00:00"
}, },
{ {
"name": "utopia-php/compression", "name": "utopia-php/compression",
@@ -4346,23 +4346,23 @@
}, },
{ {
"name": "utopia-php/http", "name": "utopia-php/http",
"version": "2.0.0-rc2", "version": "2.0.0-rc3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/http.git", "url": "https://github.com/utopia-php/http.git",
"reference": "17f3d5e966ada8a5c041717436f069f269aef2b3" "reference": "e1a51a2eb906a3d461378fb551a647ef01714f1c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/http/zipball/17f3d5e966ada8a5c041717436f069f269aef2b3", "url": "https://api.github.com/repos/utopia-php/http/zipball/e1a51a2eb906a3d461378fb551a647ef01714f1c",
"reference": "17f3d5e966ada8a5c041717436f069f269aef2b3", "reference": "e1a51a2eb906a3d461378fb551a647ef01714f1c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=8.3", "php": ">=8.3",
"utopia-php/compression": "0.1.*", "utopia-php/compression": "0.1.*",
"utopia-php/di": "0.3.*", "utopia-php/di": "0.3.*",
"utopia-php/servers": "0.4.0", "utopia-php/servers": "0.4.*",
"utopia-php/telemetry": "0.2.*", "utopia-php/telemetry": "0.2.*",
"utopia-php/validators": "0.2.*" "utopia-php/validators": "0.2.*"
}, },
@@ -4396,9 +4396,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/http/issues", "issues": "https://github.com/utopia-php/http/issues",
"source": "https://github.com/utopia-php/http/tree/2.0.0-rc2" "source": "https://github.com/utopia-php/http/tree/2.0.0-rc3"
}, },
"time": "2026-05-20T11:13:49+00:00" "time": "2026-05-21T14:42:41+00:00"
}, },
{ {
"name": "utopia-php/image", "name": "utopia-php/image",
@@ -4773,16 +4773,16 @@
}, },
{ {
"name": "utopia-php/platform", "name": "utopia-php/platform",
"version": "1.0.0-rc2", "version": "1.0.0-rc3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/platform.git", "url": "https://github.com/utopia-php/platform.git",
"reference": "a67e5037007ee7fdca5359ab4577b82917e55452" "reference": "674fd3cea6d1f8db660b01c5be89e8333dfb6de9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/platform/zipball/a67e5037007ee7fdca5359ab4577b82917e55452", "url": "https://api.github.com/repos/utopia-php/platform/zipball/674fd3cea6d1f8db660b01c5be89e8333dfb6de9",
"reference": "a67e5037007ee7fdca5359ab4577b82917e55452", "reference": "674fd3cea6d1f8db660b01c5be89e8333dfb6de9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -4818,9 +4818,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/platform/issues", "issues": "https://github.com/utopia-php/platform/issues",
"source": "https://github.com/utopia-php/platform/tree/1.0.0-rc2" "source": "https://github.com/utopia-php/platform/tree/1.0.0-rc3"
}, },
"time": "2026-05-15T06:19:20+00:00" "time": "2026-05-25T11:48:18+00:00"
}, },
{ {
"name": "utopia-php/pools", "name": "utopia-php/pools",
@@ -4976,16 +4976,16 @@
}, },
{ {
"name": "utopia-php/queue", "name": "utopia-php/queue",
"version": "0.18.3", "version": "0.18.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/queue.git", "url": "https://github.com/utopia-php/queue.git",
"reference": "141aad162b90728353f3aa834684b1f2affed045" "reference": "1323b52f39b899c580dbb7af8562fc53d4e13e62"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/queue/zipball/141aad162b90728353f3aa834684b1f2affed045", "url": "https://api.github.com/repos/utopia-php/queue/zipball/1323b52f39b899c580dbb7af8562fc53d4e13e62",
"reference": "141aad162b90728353f3aa834684b1f2affed045", "reference": "1323b52f39b899c580dbb7af8562fc53d4e13e62",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -4993,7 +4993,7 @@
"php-amqplib/php-amqplib": "^3.7", "php-amqplib/php-amqplib": "^3.7",
"utopia-php/di": "0.3.*", "utopia-php/di": "0.3.*",
"utopia-php/pools": "1.*", "utopia-php/pools": "1.*",
"utopia-php/servers": "0.4.0", "utopia-php/servers": "0.4.*",
"utopia-php/telemetry": "0.2.*", "utopia-php/telemetry": "0.2.*",
"utopia-php/validators": "0.2.*" "utopia-php/validators": "0.2.*"
}, },
@@ -5036,9 +5036,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/queue/issues", "issues": "https://github.com/utopia-php/queue/issues",
"source": "https://github.com/utopia-php/queue/tree/0.18.3" "source": "https://github.com/utopia-php/queue/tree/0.18.4"
}, },
"time": "2026-05-14T08:53:35+00:00" "time": "2026-05-21T14:43:24+00:00"
}, },
{ {
"name": "utopia-php/registry", "name": "utopia-php/registry",
@@ -5094,16 +5094,16 @@
}, },
{ {
"name": "utopia-php/servers", "name": "utopia-php/servers",
"version": "0.4.0", "version": "0.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/utopia-php/servers.git", "url": "https://github.com/utopia-php/servers.git",
"reference": "7db346ef377503efe0acafe0791085270cd9ed70" "reference": "6e9241f587a19c0e9e7a3587fe3b15ffb2d4c2a4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/utopia-php/servers/zipball/7db346ef377503efe0acafe0791085270cd9ed70", "url": "https://api.github.com/repos/utopia-php/servers/zipball/6e9241f587a19c0e9e7a3587fe3b15ffb2d4c2a4",
"reference": "7db346ef377503efe0acafe0791085270cd9ed70", "reference": "6e9241f587a19c0e9e7a3587fe3b15ffb2d4c2a4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -5142,9 +5142,9 @@
], ],
"support": { "support": {
"issues": "https://github.com/utopia-php/servers/issues", "issues": "https://github.com/utopia-php/servers/issues",
"source": "https://github.com/utopia-php/servers/tree/0.4.0" "source": "https://github.com/utopia-php/servers/tree/0.4.1"
}, },
"time": "2026-05-05T04:08:30+00:00" "time": "2026-05-21T13:08:45+00:00"
}, },
{ {
"name": "utopia-php/span", "name": "utopia-php/span",
@@ -6,6 +6,7 @@ use Appwrite\Auth\MFA\Type;
use Appwrite\Auth\MFA\Type\TOTP; use Appwrite\Auth\MFA\Type\TOTP;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -17,7 +18,7 @@ use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role; use Utopia\Database\Helpers\Role;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -77,7 +78,7 @@ class Create extends Action
contentType: ContentType::JSON contentType: ContentType::JSON
) )
]) ])
->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator. Must be `' . Type::TOTP . '`') ->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator. Must be `' . Type::TOTP . '`', enum: new Enum(name: 'AuthenticatorType'))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->inject('user') ->inject('user')
@@ -6,6 +6,7 @@ use Appwrite\Auth\MFA\Type;
use Appwrite\Auth\MFA\Type\TOTP; use Appwrite\Auth\MFA\Type\TOTP;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -14,7 +15,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -74,7 +75,7 @@ class Delete extends Action
contentType: ContentType::NONE contentType: ContentType::NONE
) )
]) ])
->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.') ->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.', enum: new Enum(name: 'AuthenticatorType'))
->inject('response') ->inject('response')
->inject('user') ->inject('user')
->inject('dbForProject') ->inject('dbForProject')
@@ -7,6 +7,7 @@ use Appwrite\Auth\MFA\Type;
use Appwrite\Auth\MFA\Type\TOTP; use Appwrite\Auth\MFA\Type\TOTP;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -15,7 +16,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Text; use Utopia\Validator\Text;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -76,7 +77,7 @@ class Update extends Action
contentType: ContentType::JSON contentType: ContentType::JSON
) )
]) ])
->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.') ->param('type', null, new WhiteList([Type::TOTP]), 'Type of authenticator.', enum: new Enum(name: 'AuthenticatorType'))
->param('otp', '', new Text(256), 'Valid verification token.') ->param('otp', '', new Text(256), 'Valid verification token.')
->inject('response') ->inject('response')
->inject('user') ->inject('user')
@@ -10,6 +10,7 @@ use Appwrite\Event\Message\Messaging as MessagingMessage;
use Appwrite\Event\Publisher\Mail as MailPublisher; use Appwrite\Event\Publisher\Mail as MailPublisher;
use Appwrite\Event\Publisher\Messaging as MessagingPublisher; use Appwrite\Event\Publisher\Messaging as MessagingPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -29,7 +30,7 @@ use Utopia\Database\Document;
use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role; use Utopia\Database\Helpers\Role;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Validator\FileName; use Utopia\Storage\Validator\FileName;
use Utopia\System\System; use Utopia\System\System;
@@ -94,7 +95,7 @@ class Create extends Action
]) ])
->label('abuse-limit', 10) ->label('abuse-limit', 10)
->label('abuse-key', 'url:{url},userId:{userId}') ->label('abuse-key', 'url:{url},userId:{userId}')
->param('factor', '', new WhiteList([Type::EMAIL, Type::PHONE, Type::TOTP, Type::RECOVERY_CODE]), 'Factor used for verification. Must be one of following: `' . Type::EMAIL . '`, `' . Type::PHONE . '`, `' . Type::TOTP . '`, `' . Type::RECOVERY_CODE . '`.') ->param('factor', '', new WhiteList([Type::EMAIL, Type::PHONE, Type::TOTP, Type::RECOVERY_CODE]), 'Factor used for verification. Must be one of following: `' . Type::EMAIL . '`, `' . Type::PHONE . '`, `' . Type::TOTP . '`, `' . Type::RECOVERY_CODE . '`.', enum: new Enum(name: 'AuthenticationFactor'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('user') ->inject('user')
@@ -11,6 +11,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Platform\Action as UtopiaAction; use Utopia\Platform\Action as UtopiaAction;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Range; use Utopia\Validator\Range;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -49,7 +50,10 @@ class Get extends Action
], ],
contentType: ContentType::IMAGE_PNG contentType: ContentType::IMAGE_PNG
)) ))
->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-browsers'))), 'Browser Code.') ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-browsers'))), 'Browser Code.', enum: new Enum(
name: 'Browser',
map: \array_map(fn (array $browser) => $browser['name'], Config::getParam('avatar-browsers')),
))
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true) ->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true)
@@ -11,6 +11,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Platform\Action as UtopiaAction; use Utopia\Platform\Action as UtopiaAction;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Range; use Utopia\Validator\Range;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -49,7 +50,10 @@ class Get extends Action
], ],
contentType: ContentType::IMAGE_PNG contentType: ContentType::IMAGE_PNG
)) ))
->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-credit-cards'))), 'Credit Card Code. Possible values: ' . \implode(', ', \array_keys(Config::getParam('avatar-credit-cards'))) . '.') ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-credit-cards'))), 'Credit Card Code. Possible values: ' . \implode(', ', \array_keys(Config::getParam('avatar-credit-cards'))) . '.', enum: new Enum(
name: 'CreditCard',
map: \array_map(fn (array $creditCard) => $creditCard['name'], Config::getParam('avatar-credit-cards')),
))
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true) ->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true)
@@ -11,6 +11,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Platform\Action as UtopiaAction; use Utopia\Platform\Action as UtopiaAction;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Range; use Utopia\Validator\Range;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -49,7 +50,10 @@ class Get extends Action
], ],
contentType: ContentType::IMAGE_PNG contentType: ContentType::IMAGE_PNG
)) ))
->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-flags'))), 'Country Code. ISO Alpha-2 country code format.') ->param('code', '', new WhiteList(\array_keys(Config::getParam('avatar-flags'))), 'Country Code. ISO Alpha-2 country code format.', enum: new Enum(
name: 'Flag',
map: \array_map(fn (array $flag) => $flag['name'], Config::getParam('avatar-flags')),
))
->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('width', 100, new Range(0, 2000), 'Image width. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true) ->param('height', 100, new Range(0, 2000), 'Image height. Pass an integer between 0 to 2000. Defaults to 100.', true)
->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true) ->param('quality', -1, new Range(-1, 100), 'Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true)
@@ -16,6 +16,7 @@ use Utopia\Domains\Domain;
use Utopia\Fetch\Client; use Utopia\Fetch\Client;
use Utopia\Image\Image; use Utopia\Image\Image;
use Utopia\Platform\Action as UtopiaAction; use Utopia\Platform\Action as UtopiaAction;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -68,21 +69,21 @@ class Get extends Action
->param('viewportWidth', 1280, new Range(1, 1920), 'Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280.', true, example: '1920') ->param('viewportWidth', 1280, new Range(1, 1920), 'Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280.', true, example: '1920')
->param('viewportHeight', 720, new Range(1, 1080), 'Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720.', true, example: '1080') ->param('viewportHeight', 720, new Range(1, 1080), 'Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720.', true, example: '1080')
->param('scale', 1, new Range(0.1, 3, Range::TYPE_FLOAT), 'Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1.', true, example: '2') ->param('scale', 1, new Range(0.1, 3, Range::TYPE_FLOAT), 'Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1.', true, example: '2')
->param('theme', 'light', new WhiteList(['light', 'dark']), 'Browser theme. Pass "light" or "dark". Defaults to "light".', true, example: 'dark') ->param('theme', 'light', new WhiteList(['light', 'dark']), 'Browser theme. Pass "light" or "dark". Defaults to "light".', true, example: 'dark', enum: new Enum(name: 'BrowserTheme'))
->param('userAgent', '', new Text(512), 'Custom user agent string. Defaults to browser default.', true, example: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15') ->param('userAgent', '', new Text(512), 'Custom user agent string. Defaults to browser default.', true, example: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15')
->param('fullpage', false, new Boolean(true), 'Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0.', true, example: 'true') ->param('fullpage', false, new Boolean(true), 'Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0.', true, example: 'true')
->param('locale', '', new Text(10), 'Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default.', true, example: 'en-US') ->param('locale', '', new Text(10), 'Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default.', true, example: 'en-US')
->param('timezone', '', new WhiteList(timezone_identifiers_list()), 'IANA timezone identifier (e.g., "America/New_York", "Europe/London"). Defaults to browser default.', true, example: 'America/New_York') ->param('timezone', '', new WhiteList(timezone_identifiers_list()), 'IANA timezone identifier (e.g., "America/New_York", "Europe/London"). Defaults to browser default.', true, example: 'America/New_York', enum: new Enum(name: 'Timezone'))
->param('latitude', 0, new Range(-90, 90, Range::TYPE_FLOAT), 'Geolocation latitude. Pass a number between -90 to 90. Defaults to 0.', true, example: '37.7749') ->param('latitude', 0, new Range(-90, 90, Range::TYPE_FLOAT), 'Geolocation latitude. Pass a number between -90 to 90. Defaults to 0.', true, example: '37.7749')
->param('longitude', 0, new Range(-180, 180, Range::TYPE_FLOAT), 'Geolocation longitude. Pass a number between -180 to 180. Defaults to 0.', true, example: '-122.4194') ->param('longitude', 0, new Range(-180, 180, Range::TYPE_FLOAT), 'Geolocation longitude. Pass a number between -180 to 180. Defaults to 0.', true, example: '-122.4194')
->param('accuracy', 0, new Range(0, 100000, Range::TYPE_FLOAT), 'Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0.', true, example: '100') ->param('accuracy', 0, new Range(0, 100000, Range::TYPE_FLOAT), 'Geolocation accuracy in meters. Pass a number between 0 to 100000. Defaults to 0.', true, example: '100')
->param('touch', false, new Boolean(true), 'Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0.', true, example: 'true') ->param('touch', false, new Boolean(true), 'Enable touch support. Pass 0 for no touch, or 1 for touch enabled. Defaults to 0.', true, example: 'true')
->param('permissions', [], new ArrayList(new WhiteList(['geolocation', 'camera', 'microphone', 'notifications', 'midi', 'push', 'clipboard-read', 'clipboard-write', 'payment-handler', 'usb', 'bluetooth', 'accelerometer', 'gyroscope', 'magnetometer', 'ambient-light-sensor', 'background-sync', 'persistent-storage', 'screen-wake-lock', 'web-share', 'xr-spatial-tracking'])), 'Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.', true, example: '["geolocation","notifications"]') ->param('permissions', [], new ArrayList(new WhiteList(['geolocation', 'camera', 'microphone', 'notifications', 'midi', 'push', 'clipboard-read', 'clipboard-write', 'payment-handler', 'usb', 'bluetooth', 'accelerometer', 'gyroscope', 'magnetometer', 'ambient-light-sensor', 'background-sync', 'persistent-storage', 'screen-wake-lock', 'web-share', 'xr-spatial-tracking'])), 'Browser permissions to grant. Pass an array of permission names like ["geolocation", "camera", "microphone"]. Defaults to empty.', true, example: '["geolocation","notifications"]', enum: new Enum(name: 'BrowserPermission'))
->param('sleep', 0, new Range(0, 10), 'Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0.', true, example: '3') ->param('sleep', 0, new Range(0, 10), 'Wait time in seconds before taking the screenshot. Pass an integer between 0 to 10. Defaults to 0.', true, example: '3')
->param('width', 0, new Range(0, 2000), 'Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).', true, example: '800') ->param('width', 0, new Range(0, 2000), 'Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).', true, example: '800')
->param('height', 0, new Range(0, 2000), 'Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).', true, example: '600') ->param('height', 0, new Range(0, 2000), 'Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).', true, example: '600')
->param('quality', -1, new Range(-1, 100), 'Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true, example: '85') ->param('quality', -1, new Range(-1, 100), 'Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true, example: '85')
->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true, example: 'jpeg') ->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true, example: 'jpeg', enum: new Enum(name: 'ImageFormat'))
->inject('response') ->inject('response')
->inject('usage') ->inject('usage')
->callback($this->action(...)); ->callback($this->action(...));
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Console\Http\Resources; namespace Appwrite\Platform\Modules\Console\Http\Resources;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -12,7 +13,7 @@ use Utopia\Database\Database;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Domains\Domain as Domain; use Utopia\Domains\Domain as Domain;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Domain as DomainValidator; use Utopia\Validator\Domain as DomainValidator;
@@ -56,7 +57,7 @@ class Get extends Action
->label('abuse-key', 'userId:{userId}, url:{url}') ->label('abuse-key', 'userId:{userId}, url:{url}')
->label('abuse-time', 60) ->label('abuse-time', 60)
->param('value', '', new Text(256), 'Resource value.') ->param('value', '', new Text(256), 'Resource value.')
->param('type', '', new WhiteList(['rules']), 'Resource type.') ->param('type', '', new WhiteList(['rules']), 'Resource type.', enum: new Enum(name: 'ConsoleResourceType'))
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
->inject('platform') ->inject('platform')
@@ -11,6 +11,7 @@ use Utopia\Config\Config;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -46,8 +47,8 @@ class Get extends Action
) )
] ]
)) ))
->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Email template type. Can be one of: ' . \implode(', ', Config::getParam('locale-templates')['email'] ?? [])) ->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Email template type. Can be one of: ' . \implode(', ', Config::getParam('locale-templates')['email'] ?? []), enum: new Enum(name: 'ProjectEmailTemplateId'))
->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes']) ->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes'], enum: new Enum(name: 'ProjectEmailTemplateLocale'))
->inject('response') ->inject('response')
->callback($this->action(...)); ->callback($this->action(...));
} }
@@ -17,6 +17,7 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -70,7 +71,7 @@ class Create extends Action
Database::RELATION_MANY_TO_ONE, Database::RELATION_MANY_TO_ONE,
Database::RELATION_MANY_TO_MANY, Database::RELATION_MANY_TO_MANY,
Database::RELATION_ONE_TO_MANY Database::RELATION_ONE_TO_MANY
], true), 'Relation type') ], true), 'Relation type', enum: new Enum(name: 'RelationshipType'))
->param('twoWay', false, new Boolean(), 'Is Two Way?', true) ->param('twoWay', false, new Boolean(), 'Is Two Way?', true)
->param('key', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Attribute Key.', true, ['dbForProject']) ->param('key', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Attribute Key.', true, ['dbForProject'])
->param('twoWayKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Two Way Attribute Key.', true, ['dbForProject']) ->param('twoWayKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Two Way Attribute Key.', true, ['dbForProject'])
@@ -78,7 +79,7 @@ class Create extends Action
Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_CASCADE,
Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_RESTRICT,
Database::RELATION_MUTATE_SET_NULL Database::RELATION_MUTATE_SET_NULL
], true), 'Constraints option', true) ], true), 'Constraints option', true, enum: new Enum(name: 'RelationMutate'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('publisherForDatabase') ->inject('publisherForDatabase')
@@ -16,6 +16,7 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -69,7 +70,7 @@ class Update extends Action
Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_CASCADE,
Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_RESTRICT,
Database::RELATION_MUTATE_SET_NULL Database::RELATION_MUTATE_SET_NULL
], true), 'Constraints option', true) ], true), 'Constraints option', true, enum: new Enum(name: 'RelationMutate'))
->param('newKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'New Attribute Key.', true, ['dbForProject']) ->param('newKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'New Attribute Key.', true, ['dbForProject'])
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -22,6 +22,7 @@ use Utopia\Database\Validator\Index as IndexValidator;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -72,9 +73,9 @@ class Create extends Action
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).', false, ['dbForProject']) ->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).', false, ['dbForProject'])
->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject']) ->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject'])
->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE, Database::INDEX_SPATIAL]), 'Index type.') ->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE, Database::INDEX_SPATIAL]), 'Index type.', enum: new Enum(name: 'DatabasesIndexType'))
->param('attributes', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.', false, ['dbForProject']) ->param('attributes', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.', false, ['dbForProject'])
->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true) ->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true, enum: new Enum(name: 'OrderBy'))
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true) ->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -17,6 +17,7 @@ use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends Action class Get extends Action
@@ -64,7 +65,14 @@ class Get extends Action
), ),
)) ))
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID.', false, ['dbForProject']) ->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID.', false, ['dbForProject'])
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Databases\Http\Databases\Usage; namespace Appwrite\Platform\Modules\Databases\Http\Databases\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -16,7 +17,7 @@ use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends Action class Get extends Action
@@ -36,7 +37,9 @@ class Get extends Action
default => DATABASE_TYPE_LEGACY, default => DATABASE_TYPE_LEGACY,
}; };
return parent::setHttpPath($path); parent::setHttpPath($path);
return $this;
} }
protected function getMetrics(): array protected function getMetrics(): array
@@ -93,7 +96,14 @@ class Get extends Action
) )
]) ])
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -2,6 +2,7 @@
namespace Appwrite\Platform\Modules\Databases\Http\Databases\Usage; namespace Appwrite\Platform\Modules\Databases\Http\Databases\Usage;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated; use Appwrite\SDK\Deprecated;
@@ -14,7 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class XList extends Action class XList extends Action
@@ -34,7 +35,9 @@ class XList extends Action
default => DATABASE_TYPE_LEGACY, default => DATABASE_TYPE_LEGACY,
}; };
return parent::setHttpPath($path); parent::setHttpPath($path);
return $this;
} }
protected function getMetrics(): array protected function getMetrics(): array
@@ -90,7 +93,14 @@ class XList extends Action
) )
), ),
]) ])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -12,6 +12,7 @@ use Utopia\Database\Database;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -58,9 +59,9 @@ class Create extends IndexCreate
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).', false, ['dbForProject']) ->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).', false, ['dbForProject'])
->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject']) ->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject'])
->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE]), 'Index type.') ->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE]), 'Index type.', enum: new Enum(name: 'DocumentsDBIndexType'))
->param('attributes', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.', false, ['dbForProject']) ->param('attributes', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.', false, ['dbForProject'])
->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true) ->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true, enum: new Enum(name: 'OrderBy'))
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true) ->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends CollectionUsageGet class Get extends CollectionUsageGet
@@ -54,7 +55,14 @@ class Get extends CollectionUsageGet
contentType: ContentType::JSON, contentType: ContentType::JSON,
)) ))
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID.', false, ['dbForProject']) ->param('collectionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Collection ID.', false, ['dbForProject'])
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends DatabaseUsageGet class Get extends DatabaseUsageGet
@@ -51,7 +52,14 @@ class Get extends DatabaseUsageGet
), ),
]) ])
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -9,6 +9,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response as UtopiaResponse; use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class XList extends DatabaseUsageXList class XList extends DatabaseUsageXList
@@ -48,7 +49,14 @@ class XList extends DatabaseUsageXList
contentType: ContentType::JSON contentType: ContentType::JSON
), ),
]) ])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->callback($this->action(...)); ->callback($this->action(...));
@@ -11,6 +11,7 @@ use Utopia\Database\Database;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -60,7 +61,7 @@ class Create extends RelationshipCreate
Database::RELATION_MANY_TO_ONE, Database::RELATION_MANY_TO_ONE,
Database::RELATION_MANY_TO_MANY, Database::RELATION_MANY_TO_MANY,
Database::RELATION_ONE_TO_MANY Database::RELATION_ONE_TO_MANY
], true), 'Relation type') ], true), 'Relation type', enum: new Enum(name: 'RelationshipType'))
->param('twoWay', false, new Boolean(), 'Is Two Way?', true) ->param('twoWay', false, new Boolean(), 'Is Two Way?', true)
->param('key', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Column Key.', true, ['dbForProject']) ->param('key', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Column Key.', true, ['dbForProject'])
->param('twoWayKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Two Way Column Key.', true, ['dbForProject']) ->param('twoWayKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'Two Way Column Key.', true, ['dbForProject'])
@@ -68,7 +69,7 @@ class Create extends RelationshipCreate
Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_CASCADE,
Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_RESTRICT,
Database::RELATION_MUTATE_SET_NULL Database::RELATION_MUTATE_SET_NULL
], true), 'Constraints option', true) ], true), 'Constraints option', true, enum: new Enum(name: 'RelationMutate'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('publisherForDatabase') ->inject('publisherForDatabase')
@@ -12,6 +12,7 @@ use Utopia\Database\Database;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -60,7 +61,7 @@ class Update extends RelationshipUpdate
Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_CASCADE,
Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_RESTRICT,
Database::RELATION_MUTATE_SET_NULL Database::RELATION_MUTATE_SET_NULL
], true)), 'Constraints option', true) ], true)), 'Constraints option', true, enum: new Enum(name: 'RelationMutate'))
->param('newKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'New Column Key.', true, ['dbForProject']) ->param('newKey', null, fn (Database $dbForProject) => new Nullable(new Key(false, $dbForProject->getAdapter()->getMaxUIDLength())), 'New Column Key.', true, ['dbForProject'])
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -12,6 +12,7 @@ use Utopia\Database\Database;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -58,9 +59,9 @@ class Create extends IndexCreate
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('tableId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).', false, ['dbForProject']) ->param('tableId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).', false, ['dbForProject'])
->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject']) ->param('key', null, fn (Database $dbForProject) => new Key(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Index Key.', false, ['dbForProject'])
->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE, Database::INDEX_SPATIAL]), 'Index type.') ->param('type', null, new WhiteList([Database::INDEX_KEY, Database::INDEX_FULLTEXT, Database::INDEX_UNIQUE, Database::INDEX_SPATIAL]), 'Index type.', enum: new Enum(name: 'TablesDBIndexType'))
->param('columns', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of columns to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' columns are allowed, each 32 characters long.', false, ['dbForProject']) ->param('columns', null, fn (Database $dbForProject) => new ArrayList(new Key(true, $dbForProject->getAdapter()->getMaxUIDLength()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of columns to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' columns are allowed, each 32 characters long.', false, ['dbForProject'])
->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true) ->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true, enum: new Enum(name: 'OrderBy'))
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true) ->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends CollectionUsageGet class Get extends CollectionUsageGet
@@ -49,7 +50,14 @@ class Get extends CollectionUsageGet
contentType: ContentType::JSON, contentType: ContentType::JSON,
)) ))
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->param('tableId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Table ID.', false, ['dbForProject']) ->param('tableId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Table ID.', false, ['dbForProject'])
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends DatabaseUsageGet class Get extends DatabaseUsageGet
@@ -46,7 +47,14 @@ class Get extends DatabaseUsageGet
), ),
]) ])
->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject']) ->param('databaseId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Database ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -9,6 +9,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response as UtopiaResponse; use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class XList extends DatabaseUsageXList class XList extends DatabaseUsageXList
@@ -43,7 +44,14 @@ class XList extends DatabaseUsageXList
contentType: ContentType::JSON contentType: ContentType::JSON
), ),
]) ])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -12,6 +12,7 @@ use Utopia\Database\Database;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -58,9 +59,9 @@ class Create extends IndexCreate
->param('databaseId', '', new UID(), 'Database ID.') ->param('databaseId', '', new UID(), 'Database ID.')
->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).') ->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).')
->param('key', null, new Key(), 'Index Key.') ->param('key', null, new Key(), 'Index Key.')
->param('type', null, new WhiteList([Database::INDEX_HNSW_EUCLIDEAN,Database::INDEX_HNSW_DOT, Database::INDEX_HNSW_COSINE, Database::INDEX_OBJECT, Database::INDEX_KEY, Database::INDEX_UNIQUE]), 'Index type.') ->param('type', null, new WhiteList([Database::INDEX_HNSW_EUCLIDEAN,Database::INDEX_HNSW_DOT, Database::INDEX_HNSW_COSINE, Database::INDEX_OBJECT, Database::INDEX_KEY, Database::INDEX_UNIQUE]), 'Index type.', enum: new Enum(name: 'VectorsDBIndexType'))
->param('attributes', null, new ArrayList(new Key(true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.') ->param('attributes', null, new ArrayList(new Key(true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attributes to index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' attributes are allowed, each 32 characters long.')
->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true) ->param('orders', [], new ArrayList(new WhiteList(['ASC', 'DESC'], false, Database::VAR_STRING), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index orders. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' orders are allowed.', true, enum: new Enum(name: 'OrderBy'))
->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true) ->param('lengths', [], new ArrayList(new Nullable(new Integer()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Length of index. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE, optional: true)
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -10,6 +10,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response as UtopiaResponse; use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends CollectionUsageGet class Get extends CollectionUsageGet
@@ -53,7 +54,14 @@ class Get extends CollectionUsageGet
contentType: ContentType::JSON, contentType: ContentType::JSON,
)) ))
->param('databaseId', '', new UID(), 'Database ID.') ->param('databaseId', '', new UID(), 'Database ID.')
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->param('collectionId', '', new UID(), 'Collection ID.') ->param('collectionId', '', new UID(), 'Collection ID.')
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -16,6 +16,7 @@ use Utopia\Database\Document;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Logger\Log; use Utopia\Logger\Log;
use Utopia\Logger\Logger; use Utopia\Logger\Logger;
use Utopia\Platform\Enum;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -74,7 +75,7 @@ class Create extends CreateDocumentAction
) )
]) ])
->param('texts', [], fn (array $plan) => new ArrayList(new Text(0), $plan['databasesMaxEmbeddingTexts'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of text to generate embeddings.', false, ['plan']) ->param('texts', [], fn (array $plan) => new ArrayList(new Text(0), $plan['databasesMaxEmbeddingTexts'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of text to generate embeddings.', false, ['plan'])
->param('model', Ollama::MODEL_EMBEDDING_GEMMA, new WhiteList(Ollama::MODELS), 'The embedding model to use for generating vector embeddings.', true) ->param('model', Ollama::MODEL_EMBEDDING_GEMMA, new WhiteList(Ollama::MODELS), 'The embedding model to use for generating vector embeddings.', true, enum: new Enum(name: 'EmbeddingModel'))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->inject('embeddingAgent') ->inject('embeddingAgent')
@@ -10,6 +10,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response as UtopiaResponse; use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends DatabaseUsageGet class Get extends DatabaseUsageGet
@@ -50,7 +51,14 @@ class Get extends DatabaseUsageGet
), ),
]) ])
->param('databaseId', '', new UID(), 'Database ID.') ->param('databaseId', '', new UID(), 'Database ID.')
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -9,6 +9,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response as UtopiaResponse; use Appwrite\Utopia\Response as UtopiaResponse;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse; use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class XList extends DatabaseUsageXList class XList extends DatabaseUsageXList
@@ -48,7 +49,14 @@ class XList extends DatabaseUsageXList
contentType: ContentType::JSON contentType: ContentType::JSON
), ),
]) ])
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->callback($this->action(...)); ->callback($this->action(...));
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Download; namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Download;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -12,7 +13,7 @@ use Appwrite\Utopia\Response;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Device; use Utopia\Storage\Device;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -55,7 +56,7 @@ class Get extends Action
)) ))
->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject']) ->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject'])
->param('deploymentId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Deployment ID.', false, ['dbForProject']) ->param('deploymentId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Deployment ID.', false, ['dbForProject'])
->param('type', 'source', new WhiteList(['source', 'output']), 'Deployment file to download. Can be: "source", "output".', true) ->param('type', 'source', new WhiteList(['source', 'output']), 'Deployment file to download. Can be: "source", "output".', true, enum: new Enum(name: 'DeploymentDownloadType'))
->inject('response') ->inject('response')
->inject('request') ->inject('request')
->inject('dbForProject') ->inject('dbForProject')
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
use Appwrite\Event\Message\Build as BuildMessage; use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Publisher\Build as BuildPublisher; use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -19,7 +20,7 @@ use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -68,7 +69,7 @@ class Create extends Base
->param('repository', '', new Text(128, 0), 'Repository name of the template.') ->param('repository', '', new Text(128, 0), 'Repository name of the template.')
->param('owner', '', new Text(128, 0), 'The name of the owner of the template.') ->param('owner', '', new Text(128, 0), 'The name of the owner of the template.')
->param('rootDirectory', '', new Text(128, 0), 'Path to function code in the template repo.') ->param('rootDirectory', '', new Text(128, 0), 'Path to function code in the template repo.')
->param('type', '', new WhiteList(['commit', 'branch', 'tag']), 'Type for the reference provided. Can be commit, branch, or tag') ->param('type', '', new WhiteList(['commit', 'branch', 'tag']), 'Type for the reference provided. Can be commit, branch, or tag', enum: new Enum(name: 'TemplateReferenceType'))
->param('reference', '', new Text(128, 0), 'Reference value, can be a commit hash, branch name, or release tag') ->param('reference', '', new Text(128, 0), 'Reference value, can be a commit hash, branch name, or release tag')
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
->inject('request') ->inject('request')
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Functions\Http\Deployments\Vcs;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Build as BuildPublisher; use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -14,7 +15,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -61,7 +62,7 @@ class Create extends Base
)) ))
->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject']) ->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject'])
// TODO: Support tag in future // TODO: Support tag in future
->param('type', '', new WhiteList(['branch', 'commit']), 'Type of reference passed. Allowed values are: branch, commit') ->param('type', '', new WhiteList(['branch', 'commit']), 'Type of reference passed. Allowed values are: branch, commit', enum: new Enum(name: 'VCSReferenceType'))
->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash') ->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash')
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
->inject('request') ->inject('request')
@@ -38,6 +38,7 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\AnyOf; use Utopia\Validator\AnyOf;
@@ -86,7 +87,7 @@ class Create extends Base
->param('body', '', new Text(10485760, 0), 'HTTP body of execution. Default value is empty string.', true) ->param('body', '', new Text(10485760, 0), 'HTTP body of execution. Default value is empty string.', true)
->param('async', false, new Boolean(true), 'Execute code in the background. Default value is false.', true) ->param('async', false, new Boolean(true), 'Execute code in the background. Default value is false.', true)
->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true) ->param('path', '/', new Text(2048), 'HTTP path of execution. Path can include query params. Default value is /', true)
->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'], true), 'HTTP method of execution. Default value is POST.', true) ->param('method', 'POST', new Whitelist(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD'], true), 'HTTP method of execution. Default value is POST.', true, enum: new Enum(name: 'ExecutionMethod'))
->param('headers', [], new AnyOf([new Assoc(), new Text(65535)], AnyOf::TYPE_MIXED), 'HTTP headers of execution. Defaults to empty.', true) ->param('headers', [], new AnyOf([new Assoc(), new Text(65535)], AnyOf::TYPE_MIXED), 'HTTP headers of execution. Defaults to empty.', true)
->param('scheduledAt', null, new Nullable(new Text(100)), 'Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.', true) ->param('scheduledAt', null, new Nullable(new Text(100)), 'Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.', true)
->inject('response') ->inject('response')
@@ -33,6 +33,7 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Roles; use Utopia\Database\Validator\Roles;
use Utopia\Http\Request; use Utopia\Http\Request;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -80,7 +81,7 @@ class Create extends Base
)) ))
->param('functionId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('functionId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject'])
->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.')
->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.') ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.', enum: new Enum(name: 'FunctionRuntime'))
->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true) ->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true)
->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true) ->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
@@ -89,7 +90,7 @@ class Create extends Base
->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true) ->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true)
->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true)
->param('commands', '', new Text(8192, 0), 'Build Commands.', true) ->param('commands', '', new Text(8192, 0), 'Build Commands.', true)
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true, enum: new Enum(name: 'ProjectKeyScopes'))
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the function.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the function.', true)
->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the function.', true) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the function.', true)
@@ -25,6 +25,7 @@ use Utopia\Database\Validator\Roles;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -72,7 +73,7 @@ class Update extends Base
)) ))
->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject']) ->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject'])
->param('name', '', new Text(128), 'Function name. Max length: 128 chars.') ->param('name', '', new Text(128), 'Function name. Max length: 128 chars.')
->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.', true) ->param('runtime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Execution runtime.', true, enum: new Enum(name: 'FunctionRuntime'))
->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true) ->param('execute', [], new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 64 characters long.', true)
->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true) ->param('events', [], new ArrayList(new FunctionEvent(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Events list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.', true)
->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true) ->param('schedule', '', new Cron(), 'Schedule CRON syntax.', true)
@@ -81,7 +82,7 @@ class Update extends Base
->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true) ->param('logging', true, new Boolean(), 'When disabled, executions will exclude logs and errors, and will be slightly faster.', true)
->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true) ->param('entrypoint', '', new Text(1028, 0), 'Entrypoint File. This path is relative to the "providerRootDirectory".', true)
->param('commands', '', new Text(8192, 0), 'Build Commands.', true) ->param('commands', '', new Text(8192, 0), 'Build Commands.', true)
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API Key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of scopes allowed for API Key auto-generated for every execution. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', true, enum: new Enum(name: 'ProjectKeyScopes'))
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Controle System) deployment.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Controle System) deployment.', true)
->param('providerRepositoryId', null, new Nullable(new Text(128, 0)), 'Repository ID of the repo linked to the function', true) ->param('providerRepositoryId', null, new Nullable(new Text(128, 0)), 'Repository ID of the repo linked to the function', true)
->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the function', true) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the function', true)
@@ -11,6 +11,7 @@ use FunctionUseCases;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
@@ -50,8 +51,8 @@ class XList extends Base
) )
] ]
)) ))
->param('runtimes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('runtimes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of runtimes allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' runtimes are allowed.', true) ->param('runtimes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('runtimes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of runtimes allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' runtimes are allowed.', true, enum: new Enum(name: 'FunctionRuntime'))
->param('useCases', [], new ArrayList(new WhiteList(FunctionUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) ->param('useCases', [], new ArrayList(new WhiteList(FunctionUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering function templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true, enum: new Enum(name: 'FunctionTemplateUseCase'))
->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true) ->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true)
->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true) ->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true)
->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true)
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Usage; namespace Appwrite\Platform\Modules\Functions\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -14,7 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -52,7 +53,14 @@ class Get extends Base
] ]
)) ))
->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject']) ->param('functionId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Function ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Functions\Http\Usage; namespace Appwrite\Platform\Modules\Functions\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -13,7 +14,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -50,7 +51,14 @@ class XList extends Base
) )
] ]
)) ))
->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -24,6 +24,7 @@ use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Enum;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -71,7 +72,7 @@ class Get extends Base
System::getEnv('_APP_SCREENSHOTS_QUEUE_NAME', Event::SCREENSHOTS_QUEUE_NAME), System::getEnv('_APP_SCREENSHOTS_QUEUE_NAME', Event::SCREENSHOTS_QUEUE_NAME),
System::getEnv('_APP_MESSAGING_QUEUE_NAME', Event::MESSAGING_QUEUE_NAME), System::getEnv('_APP_MESSAGING_QUEUE_NAME', Event::MESSAGING_QUEUE_NAME),
System::getEnv('_APP_MIGRATIONS_QUEUE_NAME', Event::MIGRATIONS_QUEUE_NAME), System::getEnv('_APP_MIGRATIONS_QUEUE_NAME', Event::MIGRATIONS_QUEUE_NAME),
]), 'The name of the queue') ]), 'The name of the queue', enum: new Enum(name: 'HealthQueueName'))
->param('threshold', 5000, new Integer(true), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.', true) ->param('threshold', 5000, new Integer(true), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.', true)
->inject('response') ->inject('response')
->inject('publisherForDatabase') ->inject('publisherForDatabase')
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Appwrite;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Message\Migration as MigrationMessage; use Appwrite\Event\Message\Migration as MigrationMessage;
use Appwrite\Event\Publisher\Migration as MigrationPublisher; use Appwrite\Event\Publisher\Migration as MigrationPublisher;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -15,7 +16,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Migration\Destinations\OnDuplicate; use Utopia\Migration\Destinations\OnDuplicate;
use Utopia\Migration\Sources\Appwrite as AppwriteSource; use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -54,11 +55,11 @@ class Create extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(AppwriteSource::getSupportedResources())), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(AppwriteSource::getSupportedResources())), 'List of resources to migrate', enum: new Enum(name: 'AppwriteMigrationResource'))
->param('endpoint', '', new URL(), 'Source Appwrite endpoint') ->param('endpoint', '', new URL(), 'Source Appwrite endpoint')
->param('projectId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Source Project ID', false, ['dbForProject']) ->param('projectId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Source Project ID', false, ['dbForProject'])
->param('apiKey', '', new Text(512), 'Source API Key') ->param('apiKey', '', new Text(512), 'Source API Key')
->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true) ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true, enum: new Enum(name: 'MigrationOnDuplicate'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('project') ->inject('project')
@@ -3,13 +3,14 @@
namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Appwrite\Report; namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Appwrite\Report;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Migration\Sources\Appwrite as AppwriteSource; use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -46,7 +47,7 @@ class Get extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(AppwriteSource::getSupportedResources())), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(AppwriteSource::getSupportedResources())), 'List of resources to migrate', enum: new Enum(name: 'AppwriteMigrationResource'))
->param('endpoint', '', new URL(), "Source's Appwrite Endpoint") ->param('endpoint', '', new URL(), "Source's Appwrite Endpoint")
->param('projectID', '', new Text(512), "Source's Project ID") ->param('projectID', '', new Text(512), "Source's Project ID")
->param('key', '', new Text(512), "Source's API Key") ->param('key', '', new Text(512), "Source's API Key")
@@ -26,6 +26,7 @@ use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Migration\Sources\CSV; use Utopia\Migration\Sources\CSV;
use Utopia\Migration\Transfer; use Utopia\Migration\Transfer;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Device; use Utopia\Storage\Device;
use Utopia\System\System; use Utopia\System\System;
@@ -69,7 +70,7 @@ class Create extends Action
->param('fileId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'File ID.', false, ['dbForProject']) ->param('fileId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'File ID.', false, ['dbForProject'])
->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.') ->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.')
->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true) ->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true)
->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true) ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true, enum: new Enum(name: 'MigrationOnDuplicate'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
use Appwrite\Event\Message\Migration as MigrationMessage; use Appwrite\Event\Message\Migration as MigrationMessage;
use Appwrite\Event\Publisher\Migration as MigrationPublisher; use Appwrite\Event\Publisher\Migration as MigrationPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -15,7 +16,7 @@ use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Migration\Sources\Appwrite as AppwriteSource; use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Migration\Sources\Firebase; use Utopia\Migration\Sources\Firebase;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -53,7 +54,7 @@ class Create extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(Firebase::getSupportedResources())), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(Firebase::getSupportedResources())), 'List of resources to migrate', enum: new Enum(name: 'FirebaseMigrationResource'))
->param('serviceAccount', '', new Text(65536), 'JSON of the Firebase service account credentials') ->param('serviceAccount', '', new Text(65536), 'JSON of the Firebase service account credentials')
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
@@ -3,13 +3,14 @@
namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Firebase\Report; namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Firebase\Report;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Migration\Sources\Firebase; use Utopia\Migration\Sources\Firebase;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -45,7 +46,7 @@ class Get extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(Firebase::getSupportedResources())), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(Firebase::getSupportedResources())), 'List of resources to migrate', enum: new Enum(name: 'FirebaseMigrationResource'))
->param('serviceAccount', '', new Text(65536), 'JSON of the Firebase service account credentials') ->param('serviceAccount', '', new Text(65536), 'JSON of the Firebase service account credentials')
->inject('response') ->inject('response')
->callback($this->action(...)); ->callback($this->action(...));
@@ -26,6 +26,7 @@ use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Migration\Sources\JSON as JSONSource; use Utopia\Migration\Sources\JSON as JSONSource;
use Utopia\Migration\Transfer; use Utopia\Migration\Transfer;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Device; use Utopia\Storage\Device;
use Utopia\System\System; use Utopia\System\System;
@@ -68,7 +69,7 @@ class Create extends Action
->param('fileId', '', new UID(), 'File ID.') ->param('fileId', '', new UID(), 'File ID.')
->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.') ->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database.')
->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true) ->param('internalFile', false, new Boolean(), 'Is the file stored in an internal bucket?', true)
->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true) ->param('onDuplicate', OnDuplicate::Fail->value, new WhiteList(OnDuplicate::values()), 'Behavior when a row with an existing $id is encountered. "fail" (default): abort on first conflict. "skip": silently ignore. "overwrite": replace existing row.', true, enum: new Enum(name: 'MigrationOnDuplicate'))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\NHost;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Message\Migration as MigrationMessage; use Appwrite\Event\Message\Migration as MigrationMessage;
use Appwrite\Event\Publisher\Migration as MigrationPublisher; use Appwrite\Event\Publisher\Migration as MigrationPublisher;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -14,7 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Migration\Sources\Appwrite as AppwriteSource; use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Migration\Sources\NHost; use Utopia\Migration\Sources\NHost;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
@@ -53,7 +54,7 @@ class Create extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(NHost::getSupportedResources())), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(NHost::getSupportedResources())), 'List of resources to migrate', enum: new Enum(name: 'NHostMigrationResource'))
->param('subdomain', '', new Text(512), 'Source\'s Subdomain') ->param('subdomain', '', new Text(512), 'Source\'s Subdomain')
->param('region', '', new Text(512), 'Source\'s Region') ->param('region', '', new Text(512), 'Source\'s Region')
->param('adminSecret', '', new Text(512), 'Source\'s Admin Secret') ->param('adminSecret', '', new Text(512), 'Source\'s Admin Secret')
@@ -3,13 +3,14 @@
namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\NHost\Report; namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\NHost\Report;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Migration\Sources\NHost; use Utopia\Migration\Sources\NHost;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
@@ -46,7 +47,7 @@ class Get extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(NHost::getSupportedResources())), 'List of resources to migrate.') ->param('resources', [], new ArrayList(new WhiteList(NHost::getSupportedResources())), 'List of resources to migrate.', enum: new Enum(name: 'NHostMigrationResource'))
->param('subdomain', '', new Text(512), 'Source\'s Subdomain.') ->param('subdomain', '', new Text(512), 'Source\'s Subdomain.')
->param('region', '', new Text(512), 'Source\'s Region.') ->param('region', '', new Text(512), 'Source\'s Region.')
->param('adminSecret', '', new Text(512), 'Source\'s Admin Secret.') ->param('adminSecret', '', new Text(512), 'Source\'s Admin Secret.')
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Supabase;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Message\Migration as MigrationMessage; use Appwrite\Event\Message\Migration as MigrationMessage;
use Appwrite\Event\Publisher\Migration as MigrationPublisher; use Appwrite\Event\Publisher\Migration as MigrationPublisher;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -14,7 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Migration\Sources\Appwrite as AppwriteSource; use Utopia\Migration\Sources\Appwrite as AppwriteSource;
use Utopia\Migration\Sources\Supabase; use Utopia\Migration\Sources\Supabase;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
@@ -54,7 +55,7 @@ class Create extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(Supabase::getSupportedResources(), true)), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(Supabase::getSupportedResources(), true)), 'List of resources to migrate', enum: new Enum(name: 'SupabaseMigrationResource'))
->param('endpoint', '', new URL(), 'Source\'s Supabase Endpoint') ->param('endpoint', '', new URL(), 'Source\'s Supabase Endpoint')
->param('apiKey', '', new Text(512), 'Source\'s API Key') ->param('apiKey', '', new Text(512), 'Source\'s API Key')
->param('databaseHost', '', new Text(512), 'Source\'s Database Host') ->param('databaseHost', '', new Text(512), 'Source\'s Database Host')
@@ -3,13 +3,14 @@
namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Supabase\Report; namespace Appwrite\Platform\Modules\Migrations\Http\Migrations\Supabase\Report;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Migration\Sources\Supabase; use Utopia\Migration\Sources\Supabase;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Integer; use Utopia\Validator\Integer;
@@ -47,7 +48,7 @@ class Get extends Action
) )
] ]
)) ))
->param('resources', [], new ArrayList(new WhiteList(Supabase::getSupportedResources(), true)), 'List of resources to migrate') ->param('resources', [], new ArrayList(new WhiteList(Supabase::getSupportedResources(), true)), 'List of resources to migrate', enum: new Enum(name: 'SupabaseMigrationResource'))
->param('endpoint', '', new URL(), 'Source\'s Supabase Endpoint.') ->param('endpoint', '', new URL(), 'Source\'s Supabase Endpoint.')
->param('apiKey', '', new Text(512), 'Source\'s API Key.') ->param('apiKey', '', new Text(512), 'Source\'s API Key.')
->param('databaseHost', '', new Text(512), 'Source\'s Database Host.') ->param('databaseHost', '', new Text(512), 'Source\'s Database Host.')
@@ -21,6 +21,7 @@ use Utopia\Database\Document;
use Utopia\Database\Exception\Duplicate; use Utopia\Database\Exception\Duplicate;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\DSN\DSN; use Utopia\DSN\DSN;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Pools\Group; use Utopia\Pools\Group;
use Utopia\System\System; use Utopia\System\System;
@@ -64,7 +65,7 @@ class Create extends Action
)) ))
->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.')
->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.')
->param('region', System::getEnv('_APP_REGION', 'default'), new WhiteList(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('region', System::getEnv('_APP_REGION', 'default'), new WhiteList(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true, enum: new Enum(name: 'Region'))
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
->inject('cache') ->inject('cache')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Presences\HTTP\Usage; namespace Appwrite\Platform\Modules\Presences\HTTP\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Action as PlatformAction; use Appwrite\Platform\Action as PlatformAction;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -13,7 +14,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
class Get extends PlatformAction class Get extends PlatformAction
@@ -45,7 +46,14 @@ class Get extends PlatformAction
), ),
], ],
)) ))
->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -12,6 +12,7 @@ use Utopia\Config\Config;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -53,7 +54,7 @@ class Update extends Action
], ],
)) ))
->param('methodId', '', new WhiteList(\array_keys(Config::getParam('auth')), true), 'Auth Method ID. Possible values: ' . implode(',', \array_keys(Config::getParam('auth'))), false) ->param('methodId', '', new WhiteList(\array_keys(Config::getParam('auth')), true), 'Auth Method ID. Possible values: ' . implode(',', \array_keys(Config::getParam('auth'))), false, enum: new Enum(name: 'ProjectAuthMethodId'))
->param('enabled', null, new Boolean(), 'Auth method status.') ->param('enabled', null, new Boolean(), 'Auth method status.')
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Keys;
use Appwrite\Event\Event as QueueEvent; use Appwrite\Event\Event as QueueEvent;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -17,7 +18,7 @@ use Utopia\Database\Exception\Duplicate as DuplicateException;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Datetime; use Utopia\Database\Validator\Datetime;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -64,7 +65,7 @@ class Create extends Base
)) ))
->param('keyId', '', fn (Database $dbForPlatform) => new CustomId(false, $dbForPlatform->getAdapter()->getMaxUIDLength()), 'Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForPlatform']) ->param('keyId', '', fn (Database $dbForPlatform) => new CustomId(false, $dbForPlatform->getAdapter()->getMaxUIDLength()), 'Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForPlatform'])
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false, enum: new Enum(name: 'ProjectKeyScopes'))
->param('expire', null, new Nullable(new Datetime()), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) ->param('expire', null, new Nullable(new Datetime()), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true)
->inject('response') ->inject('response')
->inject('queueForEvents') ->inject('queueForEvents')
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Keys\Ephemeral;
use Ahc\Jwt\JWT; use Ahc\Jwt\JWT;
use Appwrite\Event\Event as QueueEvent; use Appwrite\Event\Event as QueueEvent;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -13,7 +14,7 @@ use Utopia\Config\Config;
use Utopia\Database\DateTime as DatabaseDateTime; use Utopia\Database\DateTime as DatabaseDateTime;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -58,7 +59,7 @@ class Create extends Base
) )
], ],
)) ))
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false, enum: new Enum(name: 'ProjectKeyScopes'))
->param('duration', null, new Range(1, 3600), 'Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds.', optional: false, example: 600) ->param('duration', null, new Range(1, 3600), 'Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds.', optional: false, example: 600)
->inject('response') ->inject('response')
->inject('queueForEvents') ->inject('queueForEvents')
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Keys;
use Appwrite\Event\Event as QueueEvent; use Appwrite\Event\Event as QueueEvent;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -16,7 +17,7 @@ use Utopia\Database\Exception\Duplicate;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Datetime; use Utopia\Database\Validator\Datetime;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -60,7 +61,7 @@ class Update extends Base
)) ))
->param('keyId', '', fn (Database $dbForPlatform) => new UID($dbForPlatform->getAdapter()->getMaxUIDLength()), 'Key ID.', false, ['dbForPlatform']) ->param('keyId', '', fn (Database $dbForPlatform) => new UID($dbForPlatform->getAdapter()->getMaxUIDLength()), 'Key ID.', false, ['dbForPlatform'])
->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.')
->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false) ->param('scopes', [], new ArrayList(new WhiteList(array_keys(Config::getParam('projectScopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.', optional: false, enum: new Enum(name: 'ProjectKeyScopes'))
->param('expire', null, new Nullable(new Datetime()), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) ->param('expire', null, new Nullable(new Datetime()), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true)
->inject('response') ->inject('response')
->inject('queueForEvents') ->inject('queueForEvents')
@@ -10,6 +10,7 @@ use Appwrite\Utopia\Response;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -86,7 +87,7 @@ class Get extends Action
) )
] ]
)) ))
->param('providerId', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders', [])), true), 'OAuth2 provider key. For example: github, google, apple.', aliases: ['provider']) ->param('providerId', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders', [])), true), 'OAuth2 provider key. For example: github, google, apple.', aliases: ['provider'], enum: new Enum(name: 'ProjectOAuthProviderId', exclude: ['mock', 'mock-unverified']))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->callback($this->action(...)); ->callback($this->action(...));
@@ -14,6 +14,7 @@ use Appwrite\Utopia\Response;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Enum;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -108,7 +109,7 @@ class Update extends Base
)) ))
->param(static::getClientIdParamName(), null, new Nullable(new Text(256, 0)), static::getClientIdDescription(), optional: true) ->param(static::getClientIdParamName(), null, new Nullable(new Text(256, 0)), static::getClientIdDescription(), optional: true)
->param(static::getClientSecretParamName(), null, new Nullable(new Text(512, 0)), static::getClientSecretDescription(), optional: true) ->param(static::getClientSecretParamName(), null, new Nullable(new Text(512, 0)), static::getClientSecretDescription(), optional: true)
->param('prompt', null, new Nullable(new ArrayList(new WhiteList(['none', 'consent', 'select_account'], true), 3)), 'Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don\'t display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account.', optional: true) ->param('prompt', null, new Nullable(new ArrayList(new WhiteList(['none', 'consent', 'select_account'], true), 3)), 'Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don\'t display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account.', optional: true, enum: new Enum(name: 'ProjectOAuth2GooglePrompt'))
->param('enabled', null, new Nullable(new Boolean()), 'OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid.', true) ->param('enabled', null, new Nullable(new Boolean()), 'OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid.', true)
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -8,6 +8,7 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -63,7 +64,7 @@ class Get extends Action
'session-limit', 'session-limit',
'user-limit', 'user-limit',
'membership-privacy', 'membership-privacy',
], true), 'Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy.') ], true), 'Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy.', enum: new Enum(name: 'ProjectPolicyId'))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->callback($this->action(...)); ->callback($this->action(...));
@@ -12,6 +12,7 @@ use Utopia\Config\Config;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -53,7 +54,7 @@ class Update extends Action
) )
], ],
)) ))
->param('protocolId', '', new WhiteList(array_keys(Config::getParam('protocols')), true), 'Protocol name. Can be one of: ' . \implode(', ', array_keys(Config::getParam('protocols')))) ->param('protocolId', '', new WhiteList(array_keys(Config::getParam('protocols')), true), 'Protocol name. Can be one of: ' . \implode(', ', array_keys(Config::getParam('protocols'))), enum: new Enum(name: 'ProjectProtocolId'))
->param('enabled', null, new Boolean(), 'Protocol status.') ->param('enabled', null, new Boolean(), 'Protocol status.')
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -14,6 +14,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Emails\Validator\Email; use Utopia\Emails\Validator\Email;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Hostname; use Utopia\Validator\Hostname;
@@ -66,7 +67,7 @@ class Update extends Action
->param('senderName', null, new Nullable(new Text(256, 0)), 'Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value.', optional: true) ->param('senderName', null, new Nullable(new Text(256, 0)), 'Name shown in inbox as the sender of the email. Pass an empty string to clear a previously set value.', optional: true)
->param('replyToEmail', null, new Nullable(new Email(allowEmpty: true)), 'Email used when user replies to the email. Pass an empty string to clear a previously set value.', optional: true) ->param('replyToEmail', null, new Nullable(new Email(allowEmpty: true)), 'Email used when user replies to the email. Pass an empty string to clear a previously set value.', optional: true)
->param('replyToName', null, new Nullable(new Text(256, 0)), 'Name used when user replies to the email. Pass an empty string to clear a previously set value.', optional: true) ->param('replyToName', null, new Nullable(new Text(256, 0)), 'Name used when user replies to the email. Pass an empty string to clear a previously set value.', optional: true)
->param('secure', null, new Nullable(new WhiteList(['tls', 'ssl'], true)), 'Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption.', optional: true) ->param('secure', null, new Nullable(new WhiteList(['tls', 'ssl'], true)), 'Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption.', optional: true, enum: new Enum(name: 'ProjectSMTPSecure'))
->param('enabled', null, new Nullable(new Boolean()), 'Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates.', optional: true) ->param('enabled', null, new Nullable(new Boolean()), 'Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates.', optional: true)
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -12,6 +12,7 @@ use Utopia\Config\Config;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -53,7 +54,7 @@ class Update extends Action
) )
], ],
)) ))
->param('serviceId', '', new WhiteList(array_keys(array_filter(Config::getParam('services'), fn ($element) => $element['optional'])), true), 'Service name. Can be one of: '.\implode(', ', array_keys(array_filter(Config::getParam('services'), fn ($element) => $element['optional'])))) ->param('serviceId', '', new WhiteList(array_keys(array_filter(Config::getParam('services'), fn ($element) => $element['optional'])), true), 'Service name. Can be one of: '.\implode(', ', array_keys(array_filter(Config::getParam('services'), fn ($element) => $element['optional']))), enum: new Enum(name: 'ProjectServiceId'))
->param('enabled', null, new Boolean(), 'Service status.') ->param('enabled', null, new Boolean(), 'Service status.')
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -11,6 +11,7 @@ use Utopia\Config\Config;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Locale\Locale; use Utopia\Locale\Locale;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -47,8 +48,8 @@ class Get extends Action
) )
] ]
)) ))
->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Custom email template type. Can be one of: '.\implode(', ', Config::getParam('locale-templates')['email'] ?? [])) ->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Custom email template type. Can be one of: '.\implode(', ', Config::getParam('locale-templates')['email'] ?? []), enum: new Enum(name: 'ProjectEmailTemplateId'))
->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Custom email template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes']) ->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Custom email template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes'], enum: new Enum(name: 'ProjectEmailTemplateLocale'))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->callback($this->action(...)); ->callback($this->action(...));
@@ -14,6 +14,7 @@ use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Emails\Validator\Email; use Utopia\Emails\Validator\Email;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -56,8 +57,8 @@ class Update extends Action
) )
] ]
)) ))
->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Custom email template type. Can be one of: '.\implode(', ', Config::getParam('locale-templates')['email'] ?? [])) ->param('templateId', '', new WhiteList(Config::getParam('locale-templates')['email'] ?? [], true), 'Custom email template type. Can be one of: '.\implode(', ', Config::getParam('locale-templates')['email'] ?? []), enum: new Enum(name: 'ProjectEmailTemplateId'))
->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Custom email template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes']) ->param('locale', '', fn ($localeCodes) => new WhiteList($localeCodes), 'Custom email template locale. If left empty, the fallback locale (en) will be used.', optional: true, injections: ['localeCodes'], enum: new Enum(name: 'ProjectEmailTemplateLocale'))
->param('subject', null, new Nullable(new Text(255)), 'Subject of the email template. Can be up to 255 characters.', optional: true) ->param('subject', null, new Nullable(new Text(255)), 'Subject of the email template. Can be up to 255 characters.', optional: true)
->param('message', null, new Nullable(new Text(10485760)), 'Plain or HTML body of the email template message. Can be up to 10MB of content.', optional: true) ->param('message', null, new Nullable(new Text(10485760)), 'Plain or HTML body of the email template message. Can be up to 10MB of content.', optional: true)
->param('senderName', null, new Nullable(new Text(255, 0)), 'Name of the email sender.', optional: true) ->param('senderName', null, new Nullable(new Text(255, 0)), 'Name of the email sender.', optional: true)
@@ -20,6 +20,7 @@ use Utopia\Database\Exception\Duplicate;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\DSN\DSN; use Utopia\DSN\DSN;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Pools\Group; use Utopia\Pools\Group;
use Utopia\System\System; use Utopia\System\System;
@@ -54,7 +55,7 @@ class Create extends Action
->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.')
->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.')
->param('teamId', '', new UID(), 'Team unique ID.') ->param('teamId', '', new UID(), 'Team unique ID.')
->param('region', System::getEnv('_APP_REGION', 'default'), new WhiteList(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('region', System::getEnv('_APP_REGION', 'default'), new WhiteList(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true, enum: new Enum(name: 'Region'))
->inject('request') ->inject('request')
->inject('response') ->inject('response')
->inject('dbForPlatform') ->inject('dbForPlatform')
@@ -15,6 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\Duplicate as DuplicateException;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\JSON; use Utopia\Validator\JSON;
@@ -85,7 +86,7 @@ class Create extends Action
], ],
)) ))
->param('projectId', '', new UID(), 'Project unique ID.') ->param('projectId', '', new UID(), 'Project unique ID.')
->param('resourceType', '', new WhiteList($resourceTypes, true), 'The resource type for the schedule. Possible values: '.implode(', ', $resourceTypes).'.') ->param('resourceType', '', new WhiteList($resourceTypes, true), 'The resource type for the schedule. Possible values: '.implode(', ', $resourceTypes).'.', enum: new Enum(name: 'ScheduleResourceType'))
->param('resourceId', '', new UID(), 'The resource ID to associate with this schedule.') ->param('resourceId', '', new UID(), 'The resource ID to associate with this schedule.')
->param('schedule', '', new Cron(), 'Schedule CRON expression.') ->param('schedule', '', new Cron(), 'Schedule CRON expression.')
->param('active', false, new Boolean(), 'Whether the schedule is active.', true) ->param('active', false, new Boolean(), 'Whether the schedule is active.', true)
@@ -16,6 +16,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Logger\Log; use Utopia\Logger\Log;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Domain as ValidatorDomain; use Utopia\Validator\Domain as ValidatorDomain;
@@ -66,9 +67,23 @@ class Create extends Action
->label('abuse-time', 60) ->label('abuse-time', 60)
->param('domain', null, new ValidatorDomain(), 'Domain name.') ->param('domain', null, new ValidatorDomain(), 'Domain name.')
->param('url', null, new URL(), 'Target URL of redirection') ->param('url', null, new URL(), 'Target URL of redirection')
->param('statusCode', null, new WhiteList([301, 302, 307, 308]), 'Status code of redirection') ->param('statusCode', null, new WhiteList([301, 302, 307, 308]), 'Status code of redirection', enum: new Enum(
name: 'RedirectStatusCode',
map: [
'301' => 'MovedPermanently',
'302' => 'Found',
'307' => 'TemporaryRedirect',
'308' => 'PermanentRedirect',
]
))
->param('resourceId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'ID of parent resource.', false, ['dbForProject']) ->param('resourceId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'ID of parent resource.', false, ['dbForProject'])
->param('resourceType', '', new WhiteList(['site', 'function']), 'Type of parent resource.') ->param('resourceType', '', new WhiteList(['site', 'function']), 'Type of parent resource.', enum: new Enum(
name: 'ProxyResourceType',
map: [
'site' => 'Site',
'function' => 'Function',
]
))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->inject('publisherForCertificates') ->inject('publisherForCertificates')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Sites\Http\Deployments\Download; namespace Appwrite\Platform\Modules\Sites\Http\Deployments\Download;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\ContentType; use Appwrite\SDK\ContentType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -12,7 +13,7 @@ use Appwrite\Utopia\Response;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Device; use Utopia\Storage\Device;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -54,7 +55,7 @@ class Get extends Action
)) ))
->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject']) ->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject'])
->param('deploymentId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Deployment ID.', false, ['dbForProject']) ->param('deploymentId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Deployment ID.', false, ['dbForProject'])
->param('type', 'source', new WhiteList(['source', 'output']), 'Deployment file to download. Can be: "source", "output".', true) ->param('type', 'source', new WhiteList(['source', 'output']), 'Deployment file to download. Can be: "source", "output".', true, enum: new Enum(name: 'DeploymentDownloadType'))
->inject('response') ->inject('response')
->inject('request') ->inject('request')
->inject('dbForProject') ->inject('dbForProject')
@@ -6,6 +6,7 @@ use Appwrite\Event\Event;
use Appwrite\Event\Message\Build as BuildMessage; use Appwrite\Event\Message\Build as BuildMessage;
use Appwrite\Event\Publisher\Build as BuildPublisher; use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -19,7 +20,7 @@ use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
@@ -69,7 +70,7 @@ class Create extends Base
->param('repository', '', new Text(128, 0), 'Repository name of the template.') ->param('repository', '', new Text(128, 0), 'Repository name of the template.')
->param('owner', '', new Text(128, 0), 'The name of the owner of the template.') ->param('owner', '', new Text(128, 0), 'The name of the owner of the template.')
->param('rootDirectory', '', new Text(128, 0), 'Path to site code in the template repo.') ->param('rootDirectory', '', new Text(128, 0), 'Path to site code in the template repo.')
->param('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type for the reference provided. Can be commit, branch, or tag') ->param('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type for the reference provided. Can be commit, branch, or tag', enum: new Enum(name: 'TemplateReferenceType'))
->param('reference', '', new Text(128, 0), 'Reference value, can be a commit hash, branch name, or release tag') ->param('reference', '', new Text(128, 0), 'Reference value, can be a commit hash, branch name, or release tag')
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
->inject('request') ->inject('request')
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Sites\Http\Deployments\Vcs;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Publisher\Build as BuildPublisher; use Appwrite\Event\Publisher\Build as BuildPublisher;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -15,7 +16,7 @@ use Utopia\Database\Document;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\Boolean; use Utopia\Validator\Boolean;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -62,7 +63,7 @@ class Create extends Base
)) ))
->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject']) ->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject'])
// TODO: Support tag in future // TODO: Support tag in future
->param('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type of reference passed. Allowed values are: branch, commit') ->param('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type of reference passed. Allowed values are: branch, commit', enum: new Enum(name: 'VCSReferenceType'))
->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash') ->param('reference', '', new Text(255), 'VCS reference to create deployment from. Depending on type this can be: branch name, commit hash')
->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true) ->param('activate', false, new Boolean(), 'Automatically activate the deployment when it is finished building.', true)
->inject('request') ->inject('request')
@@ -17,6 +17,7 @@ use Utopia\Database\Document;
use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\Duplicate as DuplicateException;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -63,7 +64,7 @@ class Create extends Base
)) ))
->param('siteId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject']) ->param('siteId', '', fn (Database $dbForProject) => new CustomId(false, $dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.', false, ['dbForProject'])
->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.')
->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.') ->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.', enum: new Enum(name: 'SiteFramework'))
->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true)
->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true) ->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true)
->param('timeout', 30, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 30)), 'Maximum request time in seconds.', true) ->param('timeout', 30, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 30)), 'Maximum request time in seconds.', true)
@@ -71,8 +72,8 @@ class Create extends Base
->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true)
->param('startCommand', '', new Text(8192, 0), 'Custom start command. Leave empty to use default.', true) ->param('startCommand', '', new Text(8192, 0), 'Custom start command. Leave empty to use default.', true)
->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true)
->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.') ->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', enum: new Enum(name: 'SiteBuildRuntime'))
->param('adapter', '', new WhiteList(['static', 'ssr']), 'Framework adapter defining rendering strategy. Allowed values are: static, ssr', true) ->param('adapter', '', new WhiteList(['static', 'ssr']), 'Framework adapter defining rendering strategy. Allowed values are: static, ssr', true, enum: new Enum(name: 'SiteAdapter'))
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true) ->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true)
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true)
@@ -20,6 +20,7 @@ use Utopia\Database\Query;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
@@ -67,7 +68,7 @@ class Update extends Base
)) ))
->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject']) ->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject'])
->param('name', '', new Text(128), 'Site name. Max length: 128 chars.') ->param('name', '', new Text(128), 'Site name. Max length: 128 chars.')
->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.') ->param('framework', '', new WhiteList(\array_keys(Config::getParam('frameworks')), true), 'Sites framework.', enum: new Enum(name: 'SiteFramework'))
->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true) ->param('enabled', true, new Boolean(), 'Is site enabled? When set to \'disabled\', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled.', true)
->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true) ->param('logging', true, new Boolean(), 'When disabled, request logs will exclude logs and errors, and site responses will be slightly faster.', true)
->param('timeout', 30, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 30)), 'Maximum request time in seconds.', true) ->param('timeout', 30, new Range(1, (int) System::getEnv('_APP_SITES_TIMEOUT', 30)), 'Maximum request time in seconds.', true)
@@ -75,8 +76,8 @@ class Update extends Base
->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true) ->param('buildCommand', '', new Text(8192, 0), 'Build Command.', true)
->param('startCommand', '', new Text(8192, 0), 'Custom start command. Leave empty to use default.', true) ->param('startCommand', '', new Text(8192, 0), 'Custom start command. Leave empty to use default.', true)
->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true) ->param('outputDirectory', '', new Text(8192, 0), 'Output Directory for site.', true)
->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', true) ->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', true, enum: new Enum(name: 'SiteBuildRuntime'))
->param('adapter', '', new WhiteList(['static', 'ssr']), 'Framework adapter defining rendering strategy. Allowed values are: static, ssr', true) ->param('adapter', '', new WhiteList(['static', 'ssr']), 'Framework adapter defining rendering strategy. Allowed values are: static, ssr', true, enum: new Enum(name: 'SiteAdapter'))
->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true) ->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true)
->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true)
->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true)
@@ -11,6 +11,7 @@ use SiteUseCases;
use Utopia\Config\Config; use Utopia\Config\Config;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Range; use Utopia\Validator\Range;
@@ -49,8 +50,8 @@ class XList extends Base
) )
] ]
)) ))
->param('frameworks', [], new ArrayList(new WhiteList(\array_keys(Config::getParam('frameworks')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of frameworks allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' frameworks are allowed.', true) ->param('frameworks', [], new ArrayList(new WhiteList(\array_keys(Config::getParam('frameworks')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of frameworks allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' frameworks are allowed.', true, enum: new Enum(name: 'SiteFramework'))
->param('useCases', [], new ArrayList(new WhiteList(SiteUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true) ->param('useCases', [], new ArrayList(new WhiteList(SiteUseCases::getAll()), APP_LIMIT_ARRAY_PARAMS_SIZE), 'List of use cases allowed for filtering site templates. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' use cases are allowed.', true, enum: new Enum(name: 'SiteTemplateUseCase'))
->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true) ->param('limit', 25, new Range(1, 5000), 'Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.', true)
->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true) ->param('offset', 0, new Range(0, 5000), 'Offset the list of returned templates. Maximum offset is 5000.', true)
->inject('response') ->inject('response')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Sites\Http\Usage; namespace Appwrite\Platform\Modules\Sites\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -14,7 +15,7 @@ use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -52,7 +53,14 @@ class Get extends Base
] ]
)) ))
->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject']) ->param('siteId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'Site ID.', false, ['dbForProject'])
->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Sites\Http\Usage; namespace Appwrite\Platform\Modules\Sites\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Compute\Base; use Appwrite\Platform\Modules\Compute\Base;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
@@ -13,7 +14,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -50,7 +51,14 @@ class XList extends Base
) )
] ]
)) ))
->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -17,6 +17,7 @@ use Utopia\Database\Exception\Duplicate as DuplicateException;
use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Permission;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Storage; use Utopia\Storage\Storage;
use Utopia\System\System; use Utopia\System\System;
@@ -68,7 +69,7 @@ class Create extends Action
->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true)
->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan']) ->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan'])
->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true)
->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm chosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm chosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true, enum: new Enum(name: 'Compression'))
->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true)
->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true)
->param('transformations', true, new Boolean(true), 'Are image transformations enabled?', true) ->param('transformations', true, new Boolean(true), 'Are image transformations enabled?', true)
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Modules\Storage\Http\Buckets\Files\Preview;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\OpenSSL\OpenSSL; use Appwrite\OpenSSL\OpenSSL;
use Appwrite\Platform\Action;
use Appwrite\Platform\Modules\Storage\Config\CacheControl; use Appwrite\Platform\Modules\Storage\Config\CacheControl;
use Appwrite\Platform\Modules\Storage\Config\StorageCacheControl; use Appwrite\Platform\Modules\Storage\Config\StorageCacheControl;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
@@ -25,7 +26,7 @@ use Utopia\Database\Validator\Authorization\Input;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Request; use Utopia\Http\Adapter\Swoole\Request;
use Utopia\Image\Image; use Utopia\Image\Image;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Span\Span; use Utopia\Span\Span;
use Utopia\Storage\Device; use Utopia\Storage\Device;
@@ -76,7 +77,7 @@ class Get extends Action
->param('fileId', '', new UID(), 'File ID') ->param('fileId', '', new UID(), 'File ID')
->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true) ->param('width', 0, new Range(0, 4000), 'Resize preview image width, Pass an integer between 0 to 4000.', true)
->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true) ->param('height', 0, new Range(0, 4000), 'Resize preview image height, Pass an integer between 0 to 4000.', true)
->param('gravity', Image::GRAVITY_CENTER, new WhiteList(Image::getGravityTypes()), 'Image crop gravity. Can be one of ' . implode(",", Image::getGravityTypes()), true) ->param('gravity', Image::GRAVITY_CENTER, new WhiteList(Image::getGravityTypes()), 'Image crop gravity. Can be one of ' . implode(",", Image::getGravityTypes()), true, enum: new Enum(name: 'ImageGravity'))
->param('quality', -1, new Range(-1, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true) ->param('quality', -1, new Range(-1, 100), 'Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.', true)
->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true) ->param('borderWidth', 0, new Range(0, 100), 'Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.', true)
->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true) ->param('borderColor', '', new HexColor(), 'Preview image border color. Use a valid HEX color, no # is needed for prefix.', true)
@@ -84,7 +85,7 @@ class Get extends Action
->param('opacity', 1, new Range(0, 1, Range::TYPE_FLOAT), 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true) ->param('opacity', 1, new Range(0, 1, Range::TYPE_FLOAT), 'Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.', true)
->param('rotation', 0, new Range(-360, 360), 'Preview image rotation in degrees. Pass an integer between -360 and 360.', true) ->param('rotation', 0, new Range(-360, 360), 'Preview image rotation in degrees. Pass an integer between -360 and 360.', true)
->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('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) ->param('output', '', new WhiteList(\array_keys(Config::getParam('storage-outputs')), true), 'Output format type (jpeg, jpg, png, gif and webp).', true, enum: new Enum(name: 'ImageFormat'))
// NOTE: this is only for the sdk generator and is not used in the action below and is utilised in `resources.php` for `resourceToken`. // NOTE: this is only for the sdk generator and is not used in the action below and is utilised in `resources.php` for `resourceToken`.
->param('token', '', new Text(512), 'File token for accessing this file.', true) ->param('token', '', new Text(512), 'File token for accessing this file.', true)
->inject('request') ->inject('request')
@@ -14,6 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\Permissions;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Action;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Storage\Storage; use Utopia\Storage\Storage;
use Utopia\System\System; use Utopia\System\System;
@@ -65,7 +66,7 @@ class Update extends Action
->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true) ->param('enabled', true, new Boolean(true), 'Is bucket enabled? When set to \'disabled\', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.', true)
->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan']) ->param('maximumFileSize', fn (array $plan) => empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000, fn (array $plan) => new Range(1, empty($plan['fileSize']) ? (int) System::getEnv('_APP_STORAGE_LIMIT', 0) : $plan['fileSize'] * 1000 * 1000), 'Maximum file size allowed in bytes. Maximum allowed value is ' . Storage::human(System::getEnv('_APP_STORAGE_LIMIT', 0), 0) . '.', true, ['plan'])
->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true) ->param('allowedFileExtensions', [], new ArrayList(new Text(64), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Allowed file extensions. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' extensions are allowed, each 64 characters long.', true)
->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm chosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true) ->param('compression', Compression::NONE, new WhiteList([Compression::NONE, Compression::GZIP, Compression::ZSTD], true), 'Compression algorithm chosen for compression. Can be one of ' . Compression::NONE . ', [' . Compression::GZIP . '](https://en.wikipedia.org/wiki/Gzip), or [' . Compression::ZSTD . '](https://en.wikipedia.org/wiki/Zstd), For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' compression is skipped even if it\'s enabled', true, enum: new Enum(name: 'Compression'))
->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true) ->param('encryption', true, new Boolean(true), 'Is encryption enabled? For file size above ' . Storage::human(APP_STORAGE_READ_BUFFER, 0) . ' encryption is skipped even if it\'s enabled', true)
->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true) ->param('antivirus', true, new Boolean(true), 'Is virus scanning enabled? For file size above ' . Storage::human(APP_LIMIT_ANTIVIRUS, 0) . ' AntiVirus scanning is skipped even if it\'s enabled', true)
->param('transformations', true, new Boolean(true), 'Are image transformations enabled?', true) ->param('transformations', true, new Boolean(true), 'Are image transformations enabled?', true)
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Storage\Http\Usage; namespace Appwrite\Platform\Modules\Storage\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -13,7 +14,7 @@ use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -49,7 +50,14 @@ class Get extends Action
] ]
)) ))
->param('bucketId', '', new UID(), 'Bucket ID.') ->param('bucketId', '', new UID(), 'Bucket ID.')
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('project') ->inject('project')
->inject('dbForProject') ->inject('dbForProject')
@@ -3,6 +3,7 @@
namespace Appwrite\Platform\Modules\Storage\Http\Usage; namespace Appwrite\Platform\Modules\Storage\Http\Usage;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Platform\Action;
use Appwrite\SDK\AuthType; use Appwrite\SDK\AuthType;
use Appwrite\SDK\Method; use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse; use Appwrite\SDK\Response as SDKResponse;
@@ -12,7 +13,7 @@ use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Authorization;
use Utopia\Platform\Action; use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\Validator\WhiteList; use Utopia\Validator\WhiteList;
@@ -47,7 +48,14 @@ class XList extends Action
) )
] ]
)) ))
->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true, enum: new Enum(
name: 'UsageRange',
map: [
'24h' => 'Twenty Four Hours',
'30d' => 'Thirty Days',
'90d' => 'Ninety Days',
]
))
->inject('response') ->inject('response')
->inject('dbForProject') ->inject('dbForProject')
->inject('authorization') ->inject('authorization')
@@ -46,6 +46,7 @@ use Utopia\Detector\Detector\Framework;
use Utopia\Detector\Detector\Packager; use Utopia\Detector\Detector\Packager;
use Utopia\Detector\Detector\Runtime; use Utopia\Detector\Detector\Runtime;
use Utopia\Detector\Detector\Strategy; use Utopia\Detector\Detector\Strategy;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -91,7 +92,7 @@ class Create extends Action
)) ))
->param('installationId', '', new Text(256), 'Installation Id') ->param('installationId', '', new Text(256), 'Installation Id')
->param('providerRepositoryId', '', new Text(256), 'Repository Id') ->param('providerRepositoryId', '', new Text(256), 'Repository Id')
->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework') ->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework', enum: new Enum(name: 'VCSDetectionType'))
->param('providerRootDirectory', '', new Text(256, 0), 'Path to Root Directory', true) ->param('providerRootDirectory', '', new Text(256, 0), 'Path to Root Directory', true)
->inject('gitHub') ->inject('gitHub')
->inject('response') ->inject('response')
@@ -50,6 +50,7 @@ use Utopia\Detector\Detector\Framework;
use Utopia\Detector\Detector\Packager; use Utopia\Detector\Detector\Packager;
use Utopia\Detector\Detector\Runtime; use Utopia\Detector\Detector\Runtime;
use Utopia\Detector\Detector\Strategy; use Utopia\Detector\Detector\Strategy;
use Utopia\Platform\Enum;
use Utopia\Platform\Scope\HTTP; use Utopia\Platform\Scope\HTTP;
use Utopia\System\System; use Utopia\System\System;
use Utopia\Validator\Text; use Utopia\Validator\Text;
@@ -94,7 +95,7 @@ class XList extends Action
] ]
)) ))
->param('installationId', '', new Text(256), 'Installation Id') ->param('installationId', '', new Text(256), 'Installation Id')
->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework') ->param('type', '', new WhiteList(['runtime', 'framework']), 'Detector type. Must be one of the following: runtime, framework', enum: new Enum(name: 'VCSDetectionType'))
->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true)
->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true) ->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true)
->inject('gitHub') ->inject('gitHub')
+11 -739
View File
@@ -3,7 +3,6 @@
namespace Appwrite\SDK\Specification; namespace Appwrite\SDK\Specification;
use Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response\Model;
use Utopia\Config\Config;
use Utopia\DI\Container; use Utopia\DI\Container;
use Utopia\Http\Route; use Utopia\Http\Route;
@@ -41,78 +40,6 @@ abstract class Format
'license.url' => '', 'license.url' => '',
]; ];
/**
* @var list<array{namespace: string, methods: list<string>, parameter: string, excludeKeys?: list<string>, exclude?: bool}>
*/
private const array OAUTH_PROVIDER_BLACKLIST = [
[
'namespace' => 'account',
'methods' => [
'createOAuth2Session',
'createOAuth2Token',
'updateMagicURLSession'
],
'parameter' => 'provider',
'excludeKeys' => [
'mock',
'mock-unverified'
],
],
[
'namespace' => 'projects',
'methods' => [
'updateOAuth2'
],
'parameter' => 'provider',
'excludeKeys' => [
'mock',
'mock-unverified'
],
],
[
'namespace' => 'project',
'methods' => [
'getOAuth2Provider'
],
'parameter' => 'providerId',
'excludeKeys' => [
'mock',
'mock-unverified'
],
],
];
/**
* @var list<array{namespace: string, methods: list<string>, parameter: string, excludeKeys?: list<string>, exclude?: bool}>
*/
private const array PROVIDER_USAGE_BLACKLIST = [
[
'namespace' => 'users',
'methods' => [
'getUsage'
],
'parameter' => 'provider',
'exclude' => true, /* fully excluded */
],
];
/**
* @var list<array{namespace: string, methods: list<string>, parameter: string, required?: bool, nullable?: bool}>
*/
private const array REQUEST_PARAMETER_OVERRIDES = [
[
'namespace' => 'project',
'methods' => [
'createWebPlatform',
'updateWebPlatform',
],
'parameter' => 'hostname',
'required' => true,
],
];
protected array $enumBlacklist = [];
public function __construct(Container $container, array $services, array $routes, array $models, array $keys, int $authCount, string $platform) public function __construct(Container $container, array $services, array $routes, array $models, array $keys, int $authCount, string $platform)
{ {
$this->container = $container; $this->container = $container;
@@ -122,32 +49,6 @@ abstract class Format
$this->keys = $keys; $this->keys = $keys;
$this->authCount = $authCount; $this->authCount = $authCount;
$this->platform = $platform; $this->platform = $platform;
$this->enumBlacklist = $this->buildEnumBlacklist();
}
protected function buildEnumBlacklist(): array
{
$blacklist = [];
foreach ([...self::OAUTH_PROVIDER_BLACKLIST, ...self::PROVIDER_USAGE_BLACKLIST] as $config) {
foreach ($config['methods'] as $method) {
$entry = [
'namespace' => $config['namespace'],
'method' => $method,
'parameter' => $config['parameter'],
];
if (isset($config['excludeKeys'])) {
$entry['excludeKeys'] = $config['excludeKeys'];
}
if (isset($config['exclude'])) {
$entry['exclude'] = $config['exclude'];
}
$blacklist[] = $entry;
}
}
return $blacklist;
} }
/** /**
@@ -443,596 +344,6 @@ abstract class Format
]); ]);
} }
protected function getRequestEnumName(string $service, string $method, string $param): ?string
{
/* `$service` is `$namespace` */
switch ($service) {
case 'proxy':
switch ($method) {
case 'createRedirectRule':
switch ($param) {
case 'resourceType':
return 'ProxyResourceType';
}
break;
}
break;
case 'console':
switch ($method) {
case 'getResource':
switch ($param) {
case 'type':
return 'ConsoleResourceType';
case 'value':
return 'ConsoleResourceValue';
}
break;
case 'getEmailTemplate':
switch ($param) {
case 'templateId':
return 'ProjectEmailTemplateId';
case 'locale':
return 'ProjectEmailTemplateLocale';
}
break;
}
break;
case 'account':
switch ($method) {
case 'createOAuth2Session':
case 'createOAuth2Token':
switch ($param) {
case 'provider':
return 'OAuthProvider';
}
break;
case 'createMfaAuthenticator':
case 'updateMfaAuthenticator':
case 'deleteMfaAuthenticator':
switch ($param) {
case 'type':
return 'AuthenticatorType';
}
break;
case 'createMfaChallenge':
switch ($param) {
case 'factor':
return 'AuthenticationFactor';
}
break;
}
break;
case 'avatars':
switch ($method) {
case 'getBrowser':
return 'Browser';
case 'getCreditCard':
return 'CreditCard';
case 'getFlag':
return 'Flag';
case 'getScreenshot':
switch ($param) {
case 'permissions':
return 'BrowserPermission';
case 'output':
return 'ImageFormat';
}
break;
}
break;
case 'databases':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getCollectionUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createRelationshipAttribute':
switch ($param) {
case 'type':
return 'RelationshipType';
case 'onDelete':
return 'RelationMutate';
}
break;
case 'updateRelationshipAttribute':
switch ($param) {
case 'onDelete':
return 'RelationMutate';
}
break;
case 'createIndex':
switch ($param) {
case 'type':
return 'DatabasesIndexType';
case 'orders':
return 'OrderBy';
}
}
break;
case 'tablesDB':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getTableUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createRelationshipColumn':
switch ($param) {
case 'type':
return 'RelationshipType';
case 'onDelete':
return 'RelationMutate';
}
break;
case 'updateRelationshipColumn':
switch ($param) {
case 'onDelete':
return 'RelationMutate';
}
break;
case 'createIndex':
switch ($param) {
case 'type':
return 'TablesDBIndexType';
case 'orders':
return 'OrderBy';
}
}
break;
case 'documentsDB':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getCollectionUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createIndex':
switch ($param) {
case 'type':
return 'DocumentsDBIndexType';
case 'orders':
return 'OrderBy';
}
}
break;
case 'vectorsDB':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getCollectionUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createIndex':
switch ($param) {
case 'type':
return 'VectorsDBIndexType';
case 'orders':
return 'OrderBy';
}
}
break;
case 'functions':
switch ($method) {
case 'getUsage':
case 'listUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createExecution':
switch ($param) {
case 'method':
return 'ExecutionMethod';
}
break;
case 'getDeploymentDownload':
switch ($param) {
case 'type':
return 'DeploymentDownloadType';
}
break;
case 'createVcsDeployment':
switch ($param) {
case 'type':
return 'VCSReferenceType';
}
break;
case 'createTemplateDeployment':
switch ($param) {
case 'type':
return 'TemplateReferenceType';
}
break;
}
break;
case 'sites':
switch ($method) {
case 'getDeploymentDownload':
switch ($param) {
case 'type':
return 'DeploymentDownloadType';
}
break;
case 'getUsage':
case 'listUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createVcsDeployment':
switch ($param) {
case 'type':
return 'VCSReferenceType';
}
break;
case 'createTemplateDeployment':
switch ($param) {
case 'type':
return 'TemplateReferenceType';
}
break;
}
break;
case 'vcs':
switch ($method) {
case 'createRepositoryDetection':
case 'listRepositories':
switch ($param) {
case 'type':
return 'VCSDetectionType';
}
break;
}
break;
case 'messaging':
switch ($method) {
case 'getUsage':
switch ($param) {
case 'period':
return 'MessagingUsageRange';
}
break;
case 'createSms':
case 'createPush':
case 'createEmail':
case 'updateSms':
case 'updatePush':
case 'updateEmail':
switch ($param) {
case 'status':
return 'MessageStatus';
case 'priority':
return 'MessagePriority';
}
break;
case 'createSmtpProvider':
case 'updateSmtpProvider':
switch ($param) {
case 'encryption':
return 'SmtpEncryption';
}
break;
}
break;
case 'migrations':
switch ($method) {
case 'createAppwriteMigration':
case 'getAppwriteReport':
switch ($param) {
case 'resources':
return 'AppwriteMigrationResource';
}
break;
case 'createFirebaseMigration':
case 'getFirebaseReport':
switch ($param) {
case 'resources':
return 'FirebaseMigrationResource';
}
break;
case 'createSupabaseMigration':
case 'getSupabaseReport':
switch ($param) {
case 'resources':
return 'SupabaseMigrationResource';
}
break;
case 'createNHostMigration':
case 'getNHostReport':
switch ($param) {
case 'resources':
return 'NHostMigrationResource';
}
break;
}
break;
case 'project':
switch ($method) {
case 'updateAuthMethod':
switch ($param) {
case 'methodId':
return 'ProjectAuthMethodId';
}
break;
case 'getPolicy':
switch ($param) {
case 'policyId':
return 'ProjectPolicyId';
}
break;
case 'getOAuth2Provider':
switch ($param) {
case 'providerId':
return 'ProjectOAuthProviderId';
}
break;
case 'getEmailTemplate':
case 'updateEmailTemplate':
switch ($param) {
case 'templateId':
return 'ProjectEmailTemplateId';
case 'locale':
return 'ProjectEmailTemplateLocale';
}
break;
case 'getUsage':
switch ($param) {
case 'period':
return 'ProjectUsageRange';
}
break;
case 'updateProtocol':
switch ($param) {
case 'protocolId':
return 'ProjectProtocolId';
}
break;
case 'updateService':
switch ($param) {
case 'serviceId':
return 'ProjectServiceId';
}
break;
case 'updateSMTP':
case 'createSMTPTest':
switch ($param) {
case 'secure':
return 'ProjectSMTPSecure';
}
break;
case 'updateOAuth2Google':
switch ($param) {
case 'prompt':
return 'ProjectOAuth2GooglePrompt';
}
break;
case 'createKey':
case 'createEphemeralKey':
case 'updateKey':
switch ($param) {
case 'scopes':
return 'ProjectKeyScopes';
}
break;
}
break;
case 'projects':
switch ($method) {
case 'getEmailTemplate':
case 'updateEmailTemplate':
switch ($param) {
case 'type':
return 'EmailTemplateType';
case 'locale':
return 'EmailTemplateLocale';
}
break;
case 'createPlatform':
switch ($param) {
case 'type':
return 'PlatformType';
}
break;
case 'createSmtpTest':
case 'updateSmtp':
switch ($param) {
case 'secure':
return 'SMTPSecure';
}
break;
case 'updateOAuth2':
switch ($param) {
case 'provider':
return 'OAuthProvider';
}
break;
case 'updateAuthStatus':
switch ($param) {
case 'method':
return 'AuthMethod';
}
break;
case 'updateServiceStatus':
switch ($param) {
case 'service':
return 'ApiService';
}
break;
}
break;
case 'storage':
switch ($method) {
case 'getUsage':
case 'getBucketUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'getFilePreview':
switch ($param) {
case 'gravity':
return 'ImageGravity';
case 'output':
return 'ImageFormat';
}
break;
}
break;
case 'users':
switch ($method) {
case 'getUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
case 'createMfaAuthenticator':
case 'updateMfaAuthenticator':
case 'deleteMfaAuthenticator':
switch ($param) {
case 'type':
return 'AuthenticatorType';
}
break;
case 'createTarget':
switch ($param) {
case 'providerType':
return 'MessagingProviderType';
}
break;
case 'createSHAUser':
switch ($param) {
case 'passwordVersion':
return 'PasswordHash';
}
break;
}
break;
case 'presences':
switch ($method) {
case 'getUsage':
switch ($param) {
case 'range':
return 'UsageRange';
}
break;
}
break;
}
return null;
}
public function getRequestEnumKeys(string $service, string $method, string $param): array
{
$values = [];
switch ($service) {
case 'avatars':
switch ($method) {
case 'getBrowser':
$codes = Config::getParam('avatar-browsers');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
case 'getCreditCard':
$codes = Config::getParam('avatar-credit-cards');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
case 'getFlag':
$codes = Config::getParam('avatar-flags');
foreach ($codes as $code => $value) {
$values[] = $value['name'];
}
return $values;
}
break;
case 'databases':
case 'documentsDB':
case 'vectorsDB':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getCollectionUsage':
// Range Enum Keys
return ['Twenty Four Hours', 'Thirty Days', 'Ninety Days'];
}
break;
case 'tablesDB':
switch ($method) {
case 'getUsage':
case 'listUsage':
case 'getTableUsage':
// Range Enum Keys
return ['Twenty Four Hours', 'Thirty Days', 'Ninety Days'];
}
break;
case 'proxy':
switch ($method) {
case 'createRedirectRule':
switch ($param) {
case 'statusCode':
return ['Moved Permanently 301', 'Found 302', 'Temporary Redirect 307', 'Permanent Redirect 308'];
case 'resourceType':
return ['Site', 'Function'];
}
break;
}
break;
case 'sites':
case 'functions':
switch ($method) {
case 'getUsage':
case 'listUsage':
// Range Enum Keys
return ['Twenty Four Hours', 'Thirty Days', 'Ninety Days'];
}
break;
case 'users':
switch ($method) {
case 'getUsage':
// Range Enum Keys
if ($param == 'range') {
return ['Twenty Four Hours', 'Thirty Days', 'Ninety Days'];
}
}
break;
case 'storage':
switch ($method) {
case 'getUsage':
case 'getBucketUsage':
// Range Enum Keys
return ['Twenty Four Hours', 'Thirty Days', 'Ninety Days'];
}
break;
case 'project':
switch ($method) {
case 'getUsage':
// Range Enum Keys
return ['One Hour', 'One Day'];
}
break;
}
return $values;
}
protected function shouldEmitDefaultForSchema(mixed $default, array $schema): bool protected function shouldEmitDefaultForSchema(mixed $default, array $schema): bool
{ {
if (isset($schema['enum'])) { if (isset($schema['enum'])) {
@@ -1046,66 +357,27 @@ abstract class Format
return true; return true;
} }
protected function getRequestParameterConfig(string $service, string $method, string $param, bool $optional, bool $nullable, mixed $default): array protected function getRequestParameterConfig(bool $optional, bool $nullable, mixed $default, string $methodName = '', string $paramName = '')
{ {
$required = !$optional;
if (
$paramName === 'hostname'
&& \in_array($methodName, ['project.createWebPlatform', 'project.updateWebPlatform'], true)
) {
$required = true;
}
$config = [ $config = [
'required' => !$optional, 'required' => $required,
'nullable' => $nullable, 'nullable' => $nullable,
]; ];
foreach ($this->getRequestParameterOverrides() as $override) {
if (
$override['namespace'] !== $service
|| !\in_array($method, $override['methods'], true)
|| $override['parameter'] !== $param
) {
continue;
}
if (isset($override['required'])) {
$config['required'] = $override['required'];
}
if (isset($override['nullable'])) {
$config['nullable'] = $override['nullable'];
}
break;
}
$config['emitDefault'] = !$config['required'] && !\is_null($default); $config['emitDefault'] = !$config['required'] && !\is_null($default);
return $config; return $config;
} }
/**
* @return list<array{namespace: string, methods: list<string>, parameter: string, required?: bool, nullable?: bool}>
*/
private function getRequestParameterOverrides(): array
{
return self::REQUEST_PARAMETER_OVERRIDES;
}
public function getResponseEnumName(string $model, string $param, ?string $enumSDKName = null): ?string
{
if ($enumSDKName) {
return $enumSDKName;
}
if ($param === 'type' && \str_starts_with($model, 'platform') && $model !== 'platformList') {
return 'PlatformType';
}
if ($param !== 'status') {
return null;
}
return match (true) {
$model === 'healthStatus' => 'HealthCheckStatus',
str_starts_with($model, 'attribute') => 'AttributeStatus',
str_starts_with($model, 'column') => 'ColumnStatus',
default => null,
};
}
protected function getNestedModels(Model $model, array &$usedModels): void protected function getNestedModels(Model $model, array &$usedModels): void
{ {
foreach ($model->getRules() as $rule) { foreach ($model->getRules() as $rule) {
@@ -17,6 +17,7 @@ use Utopia\Database\Database;
use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role; use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\Spatial;
use Utopia\Platform\Enum;
use Utopia\Validator; use Utopia\Validator;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -68,9 +69,6 @@ class OpenAPI3 extends Format
], ],
], ],
], ],
'x-appwrite' => [
'endpointDocs' => $this->getParam('endpoint.docs', ''),
],
'paths' => [], 'paths' => [],
'tags' => $this->services, 'tags' => $this->services,
'components' => [ 'components' => [
@@ -149,7 +147,6 @@ class OpenAPI3 extends Format
'x-appwrite' => [ // Appwrite related metadata 'x-appwrite' => [ // Appwrite related metadata
'method' => $methodName, 'method' => $methodName,
'group' => $sdk->getGroup(), 'group' => $sdk->getGroup(),
'weight' => $route->getOrder(),
'cookies' => $route->getLabel('sdk.cookies', false), 'cookies' => $route->getLabel('sdk.cookies', false),
'type' => $sdk->getType()->value ?? '', 'type' => $sdk->getType()->value ?? '',
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodName) . '.md', 'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodName) . '.md',
@@ -412,12 +409,11 @@ class OpenAPI3 extends Format
$isNullable = $validator instanceof Nullable; $isNullable = $validator instanceof Nullable;
$parameter = $this->getRequestParameterConfig( $parameter = $this->getRequestParameterConfig(
$sdk->getNamespace(),
$methodName,
$name,
$param['optional'], $param['optional'],
$isNullable, $isNullable,
$param['default'], $param['default'],
$sdk->getNamespace() . '.' . $sdk->getMethodName(),
$name,
); );
$node = [ $node = [
@@ -629,51 +625,38 @@ class OpenAPI3 extends Format
$node['schema']['x-example'] = $param['example']; $node['schema']['x-example'] = $param['example'];
} }
// Iterate from the blackList. If it matches with the current one, then it is a blackList if ($validator->getType() === 'string') {
// Do not add the enum $enum = $param['enum'] ?? null;
$allowed = true;
$excludeKeys = null; if ($enum instanceof Enum) {
foreach ($this->enumBlacklist as $blacklist) { $enumValues = \array_values($validator->getList());
if (
$blacklist['namespace'] == $sdk->getNamespace() if (!empty($enum->exclude)) {
&& $blacklist['method'] == $methodName $keepIndices = [];
&& $blacklist['parameter'] == $name foreach ($enumValues as $index => $value) {
) { if (!\in_array($value, $enum->exclude, true)) {
// 'exclude' => true means full exclude $keepIndices[] = $index;
if (isset($blacklist['exclude']) && $blacklist['exclude'] === true) { }
$allowed = false; }
break;
$enumValues = \array_values(\array_intersect_key($enumValues, \array_flip($keepIndices)));
$node['description'] = $this->parseDescription($node['description'], $enum->exclude);
} }
if (isset($blacklist['excludeKeys'])) { $enumKeys = [];
$excludeKeys = $blacklist['excludeKeys']; if (!empty($enum->map)) {
} foreach ($enumValues as $enumValue) {
break; $enumKeys[] = $enum->map[$enumValue] ?? $enumValue;
}
}
if ($allowed && $validator->getType() === 'string') {
$allValues = \array_values($validator->getList());
$allKeys = $this->getRequestEnumKeys($sdk->getNamespace(), $methodName, $name);
if ($excludeKeys !== null) {
$keepIndices = [];
foreach ($allValues as $index => $value) {
if (!\in_array($value, $excludeKeys, true)) {
$keepIndices[] = $index;
} }
} }
$enumKeys = \array_values(\array_intersect_key($allKeys, \array_flip($keepIndices)));
$enumValues = \array_values(\array_intersect_key($allValues, \array_flip($keepIndices)));
} else {
$enumKeys = $allKeys;
$enumValues = $allValues;
}
$node['schema']['items']['enum'] = $enumValues;
$node['schema']['items']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace(), $methodName, $name);
$node['schema']['items']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) { $node['schema']['items']['enum'] = $enumValues;
$node['description'] = $this->parseDescription($node['description'], $excludeKeys); if (!empty($enum->name)) {
$node['schema']['items']['x-enum-name'] = $enum->name;
}
if (!empty($enumKeys)) {
$node['schema']['items']['x-enum-keys'] = $enumKeys;
}
} }
} }
if ($validator->getType() === 'integer') { if ($validator->getType() === 'integer') {
@@ -683,51 +666,38 @@ class OpenAPI3 extends Format
$node['schema']['type'] = $validator->getType(); $node['schema']['type'] = $validator->getType();
$node['schema']['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0]; $node['schema']['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
// Iterate from the blackList. If it matches with the current one, then it is a blackList if ($validator->getType() === 'string') {
// Do not add the enum $enum = $param['enum'] ?? null;
$allowed = true;
$excludeKeys = null; if ($enum instanceof Enum) {
foreach ($this->enumBlacklist as $blacklist) { $enumValues = \array_values($validator->getList());
if (
$blacklist['namespace'] == $sdk->getNamespace() if (!empty($enum->exclude)) {
&& $blacklist['method'] == $methodName $keepIndices = [];
&& $blacklist['parameter'] == $name foreach ($enumValues as $index => $value) {
) { if (!\in_array($value, $enum->exclude, true)) {
// 'exclude' => true means full exclude $keepIndices[] = $index;
if (isset($blacklist['exclude']) && $blacklist['exclude'] === true) { }
$allowed = false; }
break;
$enumValues = \array_values(\array_intersect_key($enumValues, \array_flip($keepIndices)));
$node['description'] = $this->parseDescription($node['description'], $enum->exclude);
} }
if (isset($blacklist['excludeKeys'])) { $enumKeys = [];
$excludeKeys = $blacklist['excludeKeys']; if (!empty($enum->map)) {
} foreach ($enumValues as $enumValue) {
break; $enumKeys[] = $enum->map[$enumValue] ?? $enumValue;
}
}
if ($allowed && $validator->getType() === 'string') {
$allValues = \array_values($validator->getList());
$allKeys = $this->getRequestEnumKeys($sdk->getNamespace(), $methodName, $name);
if ($excludeKeys !== null) {
$keepIndices = [];
foreach ($allValues as $index => $value) {
if (!\in_array($value, $excludeKeys, true)) {
$keepIndices[] = $index;
} }
} }
$enumKeys = \array_values(\array_intersect_key($allKeys, \array_flip($keepIndices)));
$enumValues = \array_values(\array_intersect_key($allValues, \array_flip($keepIndices)));
} else {
$enumKeys = $allKeys;
$enumValues = $allValues;
}
$node['schema']['enum'] = $enumValues;
$node['schema']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace(), $methodName, $name);
$node['schema']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) { $node['schema']['enum'] = $enumValues;
$node['description'] = $this->parseDescription($node['description'], $excludeKeys); if (!empty($enum->name)) {
$node['schema']['x-enum-name'] = $enum->name;
}
if (!empty($enumKeys)) {
$node['schema']['x-enum-keys'] = $enumKeys;
}
} }
} }
if ($validator->getType() === 'integer') { if ($validator->getType() === 'integer') {
@@ -808,9 +778,14 @@ class OpenAPI3 extends Format
$body['content'][$consumes[0]]['schema']['properties'][$name] = [ $body['content'][$consumes[0]]['schema']['properties'][$name] = [
'type' => $node['schema']['type'], 'type' => $node['schema']['type'],
'description' => $node['description'], 'description' => $node['description'],
'x-example' => $node['schema']['x-example'] ?? null
]; ];
if (\array_key_exists('default', $node['schema'])) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['default'] = $node['schema']['default'];
}
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-example'] = $node['schema']['x-example'] ?? null;
if (isset($node['schema']['format'])) { if (isset($node['schema']['format'])) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['format'] = $node['schema']['format']; $body['content'][$consumes[0]]['schema']['properties'][$name]['format'] = $node['schema']['format'];
} }
@@ -819,7 +794,9 @@ class OpenAPI3 extends Format
/// If the enum flag is Set, add the enum values to the body /// If the enum flag is Set, add the enum values to the body
$body['content'][$consumes[0]]['schema']['properties'][$name]['enum'] = $node['schema']['enum']; $body['content'][$consumes[0]]['schema']['properties'][$name]['enum'] = $node['schema']['enum'];
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-name'] = $node['schema']['x-enum-name'] ?? null; $body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-name'] = $node['schema']['x-enum-name'] ?? null;
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-keys'] = $node['schema']['x-enum-keys']; if (isset($node['schema']['x-enum-keys'])) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-enum-keys'] = $node['schema']['x-enum-keys'];
}
} }
if ($node['schema']['x-upload-id'] ?? false) { if ($node['schema']['x-upload-id'] ?? false) {
@@ -1022,15 +999,13 @@ class OpenAPI3 extends Format
if ($rule['type'] === 'enum' && !empty($rule['enum'])) { if ($rule['type'] === 'enum' && !empty($rule['enum'])) {
if ($rule['array']) { if ($rule['array']) {
$output['components']['schemas'][$model->getType()]['properties'][$name]['items']['enum'] = \array_values($rule['enum']); $output['components']['schemas'][$model->getType()]['properties'][$name]['items']['enum'] = \array_values($rule['enum']);
$enumName = $this->getResponseEnumName($model->getType(), $name, $rule['enumSDKName'] ?? null); if (!empty($rule['enumSDKName'])) {
if ($enumName) { $output['components']['schemas'][$model->getType()]['properties'][$name]['items']['x-enum-name'] = $rule['enumSDKName'];
$output['components']['schemas'][$model->getType()]['properties'][$name]['items']['x-enum-name'] = $enumName;
} }
} else { } else {
$output['components']['schemas'][$model->getType()]['properties'][$name]['enum'] = \array_values($rule['enum']); $output['components']['schemas'][$model->getType()]['properties'][$name]['enum'] = \array_values($rule['enum']);
$enumName = $this->getResponseEnumName($model->getType(), $name, $rule['enumSDKName'] ?? null); if (!empty($rule['enumSDKName'])) {
if ($enumName) { $output['components']['schemas'][$model->getType()]['properties'][$name]['x-enum-name'] = $rule['enumSDKName'];
$output['components']['schemas'][$model->getType()]['properties'][$name]['x-enum-name'] = $enumName;
} }
} }
} }
@@ -18,6 +18,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role; use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\Spatial;
use Utopia\Http\Route; use Utopia\Http\Route;
use Utopia\Platform\Enum;
use Utopia\Validator; use Utopia\Validator;
use Utopia\Validator\ArrayList; use Utopia\Validator\ArrayList;
use Utopia\Validator\Nullable; use Utopia\Validator\Nullable;
@@ -55,9 +56,6 @@ class Swagger2 extends Format
], ],
'host' => \parse_url($this->getParam('endpoint', ''), PHP_URL_HOST), 'host' => \parse_url($this->getParam('endpoint', ''), PHP_URL_HOST),
'x-host-docs' => \parse_url($this->getParam('endpoint.docs', ''), PHP_URL_HOST), 'x-host-docs' => \parse_url($this->getParam('endpoint.docs', ''), PHP_URL_HOST),
'x-appwrite' => [
'endpointDocs' => $this->getParam('endpoint.docs', ''),
],
'basePath' => \parse_url($this->getParam('endpoint', ''), PHP_URL_PATH), 'basePath' => \parse_url($this->getParam('endpoint', ''), PHP_URL_PATH),
'schemes' => [\parse_url($this->getParam('endpoint', ''), PHP_URL_SCHEME)], 'schemes' => [\parse_url($this->getParam('endpoint', ''), PHP_URL_SCHEME)],
'consumes' => ['application/json', 'multipart/form-data'], 'consumes' => ['application/json', 'multipart/form-data'],
@@ -109,8 +107,9 @@ class Swagger2 extends Format
$additionalMethods = null; $additionalMethods = null;
if (\is_array($sdk)) { if (\is_array($sdk)) {
$additionalMethods = $sdk; $additionalMethods = $sdk;
$sdkValues = \array_values($sdk);
/** @var Method $sdk */ /** @var Method $sdk */
$sdk = $sdk[0]; $sdk = $sdkValues[0];
} }
$consumes = []; $consumes = [];
@@ -144,7 +143,6 @@ class Swagger2 extends Format
'x-appwrite' => [ // Appwrite related metadata 'x-appwrite' => [ // Appwrite related metadata
'method' => $methodName, 'method' => $methodName,
'group' => $sdk->getGroup(), 'group' => $sdk->getGroup(),
'weight' => $route->getOrder(),
'cookies' => $route->getLabel('sdk.cookies', false), 'cookies' => $route->getLabel('sdk.cookies', false),
'type' => $sdk->getType()->value ?? '', 'type' => $sdk->getType()->value ?? '',
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodName) . '.md', 'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodName) . '.md',
@@ -402,12 +400,11 @@ class Swagger2 extends Format
$isNullable = $validator instanceof Nullable; $isNullable = $validator instanceof Nullable;
$parameter = $this->getRequestParameterConfig( $parameter = $this->getRequestParameterConfig(
$sdk->getNamespace(),
$methodName,
$name,
$param['optional'], $param['optional'],
$isNullable, $isNullable,
$param['default'], $param['default'],
$sdk->getNamespace() . '.' . $sdk->getMethodName(),
$name,
); );
$node = [ $node = [
@@ -595,45 +592,38 @@ class Swagger2 extends Format
$node['x-example'] = $param['example']; $node['x-example'] = $param['example'];
} }
$allowed = true; if ($validator->getType() === 'string') {
$excludeKeys = null; $enum = $param['enum'] ?? null;
foreach ($this->enumBlacklist as $blacklist) {
if ($blacklist['namespace'] == $namespace && $blacklist['method'] == $methodName && $blacklist['parameter'] == $name) { if ($enum instanceof Enum) {
// 'exclude' => true means full exclude $enumValues = \array_values($validator->getList());
if (isset($blacklist['exclude']) && $blacklist['exclude'] === true) {
$allowed = false; if (!empty($enum->exclude)) {
break; $keepIndices = [];
foreach ($enumValues as $index => $value) {
if (!\in_array($value, $enum->exclude, true)) {
$keepIndices[] = $index;
}
}
$enumValues = \array_values(\array_intersect_key($enumValues, \array_flip($keepIndices)));
$node['description'] = $this->parseDescription($node['description'], $enum->exclude);
} }
if (isset($blacklist['excludeKeys'])) { $enumKeys = [];
$excludeKeys = $blacklist['excludeKeys']; if (!empty($enum->map)) {
} foreach ($enumValues as $enumValue) {
break; $enumKeys[] = $enum->map[$enumValue] ?? $enumValue;
}
}
if ($allowed && $validator->getType() === 'string') {
$allValues = \array_values($validator->getList());
$allKeys = $this->getRequestEnumKeys($namespace, $methodName, $name);
if ($excludeKeys !== null) {
$keepIndices = [];
foreach ($allValues as $index => $value) {
if (!\in_array($value, $excludeKeys, true)) {
$keepIndices[] = $index;
} }
} }
$enumKeys = \array_values(\array_intersect_key($allKeys, \array_flip($keepIndices)));
$enumValues = \array_values(\array_intersect_key($allValues, \array_flip($keepIndices)));
} else {
$enumKeys = $allKeys;
$enumValues = $allValues;
}
$node['items']['enum'] = $enumValues;
$node['items']['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
$node['items']['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) { $node['items']['enum'] = $enumValues;
$node['description'] = $this->parseDescription($node['description'], $excludeKeys); if (!empty($enum->name)) {
$node['items']['x-enum-name'] = $enum->name;
}
if (!empty($enumKeys)) {
$node['items']['x-enum-keys'] = $enumKeys;
}
} }
} }
if ($validator->getType() === 'integer') { if ($validator->getType() === 'integer') {
@@ -643,45 +633,38 @@ class Swagger2 extends Format
$node['type'] = $validator->getType(); $node['type'] = $validator->getType();
$node['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0]; $node['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
$allowed = true; if ($validator->getType() === 'string') {
$excludeKeys = null; $enum = $param['enum'] ?? null;
foreach ($this->enumBlacklist as $blacklist) {
if ($blacklist['namespace'] == $namespace && $blacklist['method'] == $methodName && $blacklist['parameter'] == $name) { if ($enum instanceof Enum) {
// 'exclude' => true means full exclude $enumValues = \array_values($validator->getList());
if (isset($blacklist['exclude']) && $blacklist['exclude'] === true) {
$allowed = false; if (!empty($enum->exclude)) {
break; $keepIndices = [];
foreach ($enumValues as $index => $value) {
if (!\in_array($value, $enum->exclude, true)) {
$keepIndices[] = $index;
}
}
$enumValues = \array_values(\array_intersect_key($enumValues, \array_flip($keepIndices)));
$node['description'] = $this->parseDescription($node['description'], $enum->exclude);
} }
if (isset($blacklist['excludeKeys'])) { $enumKeys = [];
$excludeKeys = $blacklist['excludeKeys']; if (!empty($enum->map)) {
} foreach ($enumValues as $enumValue) {
break; $enumKeys[] = $enum->map[$enumValue] ?? $enumValue;
}
}
if ($allowed && $validator->getType() === 'string') {
$allValues = \array_values($validator->getList());
$allKeys = $this->getRequestEnumKeys($namespace, $methodName, $name);
if ($excludeKeys !== null) {
$keepIndices = [];
foreach ($allValues as $index => $value) {
if (!\in_array($value, $excludeKeys, true)) {
$keepIndices[] = $index;
} }
} }
$enumKeys = \array_values(\array_intersect_key($allKeys, \array_flip($keepIndices)));
$enumValues = \array_values(\array_intersect_key($allValues, \array_flip($keepIndices)));
} else {
$enumKeys = $allKeys;
$enumValues = $allValues;
}
$node['enum'] = $enumValues;
$node['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
$node['x-enum-keys'] = $enumKeys;
if (!empty($excludeKeys)) { $node['enum'] = $enumValues;
$node['description'] = $this->parseDescription($node['description'], $excludeKeys); if (!empty($enum->name)) {
$node['x-enum-name'] = $enum->name;
}
if (!empty($enumKeys)) {
$node['x-enum-keys'] = $enumKeys;
}
} }
} }
if ($validator->getType() === 'integer') { if ($validator->getType() === 'integer') {
@@ -770,13 +753,14 @@ class Swagger2 extends Format
$body['schema']['properties'][$name] = [ $body['schema']['properties'][$name] = [
'type' => $node['type'], 'type' => $node['type'],
'description' => $node['description'], 'description' => $node['description'],
'x-example' => $node['x-example'] ?? null,
]; ];
if (\array_key_exists('default', $node)) { if (\array_key_exists('default', $node)) {
$body['schema']['properties'][$name]['default'] = $node['default']; $body['schema']['properties'][$name]['default'] = $node['default'];
} }
$body['schema']['properties'][$name]['x-example'] = $node['x-example'] ?? null;
if (isset($node['format'])) { if (isset($node['format'])) {
$body['schema']['properties'][$name]['format'] = $node['format']; $body['schema']['properties'][$name]['format'] = $node['format'];
} }
@@ -785,7 +769,9 @@ class Swagger2 extends Format
/// If the enum flag is Set, add the enum values to the body /// If the enum flag is Set, add the enum values to the body
$body['schema']['properties'][$name]['enum'] = $node['enum']; $body['schema']['properties'][$name]['enum'] = $node['enum'];
$body['schema']['properties'][$name]['x-enum-name'] = $node['x-enum-name'] ?? null; $body['schema']['properties'][$name]['x-enum-name'] = $node['x-enum-name'] ?? null;
$body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys']; if (isset($node['x-enum-keys'])) {
$body['schema']['properties'][$name]['x-enum-keys'] = $node['x-enum-keys'];
}
} }
if ($parameter['nullable']) { if ($parameter['nullable']) {
@@ -1000,15 +986,13 @@ class Swagger2 extends Format
if ($rule['type'] === 'enum' && !empty($rule['enum'])) { if ($rule['type'] === 'enum' && !empty($rule['enum'])) {
if ($rule['array']) { if ($rule['array']) {
$output['definitions'][$model->getType()]['properties'][$name]['items']['enum'] = \array_values($rule['enum']); $output['definitions'][$model->getType()]['properties'][$name]['items']['enum'] = \array_values($rule['enum']);
$enumName = $this->getResponseEnumName($model->getType(), $name, $rule['enumSDKName'] ?? null); if (!empty($rule['enumSDKName'])) {
if ($enumName) { $output['definitions'][$model->getType()]['properties'][$name]['items']['x-enum-name'] = $rule['enumSDKName'];
$output['definitions'][$model->getType()]['properties'][$name]['items']['x-enum-name'] = $enumName;
} }
} else { } else {
$output['definitions'][$model->getType()]['properties'][$name]['enum'] = \array_values($rule['enum']); $output['definitions'][$model->getType()]['properties'][$name]['enum'] = \array_values($rule['enum']);
$enumName = $this->getResponseEnumName($model->getType(), $name, $rule['enumSDKName'] ?? null); if (!empty($rule['enumSDKName'])) {
if ($enumName) { $output['definitions'][$model->getType()]['properties'][$name]['x-enum-name'] = $rule['enumSDKName'];
$output['definitions'][$model->getType()]['properties'][$name]['x-enum-name'] = $enumName;
} }
} }
} }
@@ -28,6 +28,7 @@ class Attribute extends Model
'default' => '', 'default' => '',
'example' => 'available', 'example' => 'available',
'enum' => ['available', 'processing', 'deleting', 'stuck', 'failed'], 'enum' => ['available', 'processing', 'deleting', 'stuck', 'failed'],
'enumSDKName' => 'AttributeStatus',
]) ])
->addRule('error', [ ->addRule('error', [
'type' => self::TYPE_STRING, 'type' => self::TYPE_STRING,
@@ -28,6 +28,7 @@ class Column extends Model
'default' => '', 'default' => '',
'example' => 'available', 'example' => 'available',
'enum' => ['available', 'processing', 'deleting', 'stuck', 'failed'], 'enum' => ['available', 'processing', 'deleting', 'stuck', 'failed'],
'enumSDKName' => 'ColumnStatus',
]) ])
->addRule('error', [ ->addRule('error', [
'type' => self::TYPE_STRING, 'type' => self::TYPE_STRING,
@@ -28,6 +28,7 @@ class HealthStatus extends Model
'default' => '', 'default' => '',
'example' => 'pass', 'example' => 'pass',
'enum' => ['pass', 'fail'], 'enum' => ['pass', 'fail'],
'enumSDKName' => 'HealthCheckStatus',
]) ])
; ;
} }
@@ -51,6 +51,7 @@ abstract class PlatformBase extends Model
'default' => '', 'default' => '',
'example' => Platform::TYPE_WEB, 'example' => Platform::TYPE_WEB,
'enum' => self::getSupportedTypes(), 'enum' => self::getSupportedTypes(),
'enumSDKName' => 'PlatformType',
]) ])
; ;
} }
+1 -1
View File
@@ -101,7 +101,7 @@ class HTTPTest extends Scope
$body = $response['body']; $body = $response['body'];
$this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsString($body['server']); $this->assertIsString($body['server']);
$this->assertIsString($body['server-web']); $this->assertIsString($body['client-web']);
$this->assertIsString($body['client-flutter']); $this->assertIsString($body['client-flutter']);
$this->assertIsString($body['console-web']); $this->assertIsString($body['console-web']);
$this->assertIsString($body['server-nodejs']); $this->assertIsString($body['server-nodejs']);
+28 -15
View File
@@ -3,6 +3,13 @@
namespace Tests\Unit\SDK\Specification; namespace Tests\Unit\SDK\Specification;
use Appwrite\SDK\Specification\Format; use Appwrite\SDK\Specification\Format;
use Appwrite\Utopia\Response\Model\HealthStatus;
use Appwrite\Utopia\Response\Model\PlatformAndroid;
use Appwrite\Utopia\Response\Model\PlatformApple;
use Appwrite\Utopia\Response\Model\PlatformLinux;
use Appwrite\Utopia\Response\Model\PlatformList;
use Appwrite\Utopia\Response\Model\PlatformWeb;
use Appwrite\Utopia\Response\Model\PlatformWindows;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Utopia\DI\Container; use Utopia\DI\Container;
@@ -18,9 +25,9 @@ class TestFormat extends Format
return []; return [];
} }
public function requestParameterConfig(string $service, string $method, string $param, bool $optional, bool $nullable, mixed $default): array public function requestParameterConfig(bool $optional, bool $nullable, mixed $default, string $methodName = '', string $paramName = ''): array
{ {
return $this->getRequestParameterConfig($service, $method, $param, $optional, $nullable, $default); return $this->getRequestParameterConfig($optional, $nullable, $default, $methodName, $paramName);
} }
} }
@@ -37,9 +44,9 @@ class FormatTest extends TestCase
public function testProjectRequestParameterOverrides(): void public function testProjectRequestParameterOverrides(): void
{ {
$createWebPlatform = $this->format->requestParameterConfig('project', 'createWebPlatform', 'hostname', true, false, ''); $createWebPlatform = $this->format->requestParameterConfig(true, false, '', 'project.createWebPlatform', 'hostname');
$updateWebPlatform = $this->format->requestParameterConfig('project', 'updateWebPlatform', 'hostname', true, false, ''); $updateWebPlatform = $this->format->requestParameterConfig(true, false, '', 'project.updateWebPlatform', 'hostname');
$listPlatforms = $this->format->requestParameterConfig('project', 'listPlatforms', 'queries', true, false, []); $listPlatforms = $this->format->requestParameterConfig(true, false, [], 'project.listPlatforms', 'queries');
$this->assertTrue($createWebPlatform['required']); $this->assertTrue($createWebPlatform['required']);
$this->assertFalse($createWebPlatform['emitDefault']); $this->assertFalse($createWebPlatform['emitDefault']);
@@ -48,19 +55,25 @@ class FormatTest extends TestCase
$this->assertTrue($listPlatforms['emitDefault']); $this->assertTrue($listPlatforms['emitDefault']);
} }
public function testProjectPlatformResponseTypeUsesSharedEnumName(): void public function testProjectPlatformResponseTypeUsesSharedEnumMetadata(): void
{ {
$this->assertSame('PlatformType', $this->format->getResponseEnumName('platformAndroid', 'type')); $models = [
$this->assertSame('PlatformType', $this->format->getResponseEnumName('platformWeb', 'type')); new PlatformAndroid(),
$this->assertSame('PlatformType', $this->format->getResponseEnumName('platformApple', 'type')); new PlatformWeb(),
$this->assertSame('PlatformType', $this->format->getResponseEnumName('platformWindows', 'type')); new PlatformApple(),
$this->assertSame('PlatformType', $this->format->getResponseEnumName('platformLinux', 'type')); new PlatformWindows(),
$this->assertNull($this->format->getResponseEnumName('platformList', 'type')); new PlatformLinux(),
];
foreach ($models as $model) {
$this->assertSame('PlatformType', $model->getRules()['type']['enumSDKName']);
}
$this->assertArrayNotHasKey('enumSDKName', (new PlatformList())->getRules()['platforms']);
} }
public function testExistingResponseEnumMappingsRemainUnchanged(): void public function testExistingResponseEnumMetadataRemainsUnchanged(): void
{ {
$this->assertSame('HealthCheckStatus', $this->format->getResponseEnumName('healthStatus', 'status')); $this->assertSame('HealthCheckStatus', (new HealthStatus())->getRules()['status']['enumSDKName']);
$this->assertNull($this->format->getResponseEnumName('key', 'name'));
} }
} }