diff --git a/Dockerfile b/Dockerfile index 3d03ce112c..d097edf0ca 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ RUN composer install --ignore-platform-reqs --optimize-autoloader \ --no-plugins --no-scripts --prefer-dist \ `if [ "$TESTING" != "true" ]; then echo "--no-dev"; fi` -FROM appwrite/base:0.10.4 AS final +FROM appwrite/base:0.10.5 AS final LABEL maintainer="team@appwrite.io" @@ -28,8 +28,6 @@ RUN \ apk add boost boost-dev; \ fi -RUN apk add libwebp - WORKDIR /usr/src/code COPY --from=composer /usr/local/src/vendor /usr/src/code/vendor diff --git a/app/cli.php b/app/cli.php index 71b6464cb9..0900926346 100644 --- a/app/cli.php +++ b/app/cli.php @@ -40,8 +40,6 @@ Config::setParam('runtimes', (new Runtimes('v5'))->getAll(supported: false)); // require controllers after overwriting runtimes require_once __DIR__ . '/controllers/general.php'; -Authorization::disable(); - CLI::setResource('register', fn () => $register); CLI::setResource('cache', function ($pools) { @@ -59,7 +57,13 @@ CLI::setResource('pools', function (Registry $register) { return $register->get('pools'); }, ['register']); -CLI::setResource('dbForPlatform', function ($pools, $cache) { +CLI::setResource('authorization', function () { + $authorization = new Authorization(); + $authorization->disable(); + return $authorization; +}, []); + +CLI::setResource('dbForPlatform', function ($pools, $cache, $authorization) { $sleep = 3; $maxAttempts = 5; $attempts = 0; @@ -73,6 +77,7 @@ CLI::setResource('dbForPlatform', function ($pools, $cache) { $dbForPlatform = new Database($adapter, $cache); $dbForPlatform + ->setAuthorization($authorization) ->setNamespace('_console') ->setMetadata('host', \gethostname()) ->setMetadata('project', 'console'); @@ -97,7 +102,7 @@ CLI::setResource('dbForPlatform', function ($pools, $cache) { } return $dbForPlatform; -}, ['pools', 'cache']); +}, ['pools', 'cache', 'authorization']); CLI::setResource('console', function () { return new Document(Config::getParam('console')); @@ -108,10 +113,10 @@ CLI::setResource( fn () => fn (Document $project, string $resourceType, ?string $resourceId) => false ); -CLI::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache) { +CLI::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache, $authorization) { $databases = []; // TODO: @Meldiron This should probably be responsibility of utopia-php/pools - return function (Document $project) use ($pools, $dbForPlatform, $cache, &$databases) { + return function (Document $project) use ($pools, $dbForPlatform, $cache, $authorization, &$databases) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -144,6 +149,7 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform $adapter = new DatabasePool($pools->get($dsn->getHost())); $database = new Database($adapter, $cache); + $databases[$dsn->getHost()] = $database; $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); @@ -160,17 +166,18 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform } $database + ->setAuthorization($authorization) ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()); return $database; }; -}, ['pools', 'dbForPlatform', 'cache']); +}, ['pools', 'dbForPlatform', 'cache', 'authorization']); -CLI::setResource('getLogsDB', function (Group $pools, Cache $cache) { +CLI::setResource('getLogsDB', function (Group $pools, Cache $cache, Authorization $authorization) { $database = null; - return function (?Document $project = null) use ($pools, $cache, $database) { + return function (?Document $project = null) use ($pools, $cache, $database, $authorization) { if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { $database->setTenant((int)$project->getSequence()); return $database; @@ -180,6 +187,7 @@ CLI::setResource('getLogsDB', function (Group $pools, Cache $cache) { $database = new Database($adapter, $cache); $database + ->setAuthorization($authorization) ->setSharedTables(true) ->setNamespace('logsV1') ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_TASK) @@ -192,7 +200,7 @@ CLI::setResource('getLogsDB', function (Group $pools, Cache $cache) { return $database; }; -}, ['pools', 'cache']); +}, ['pools', 'cache', 'authorization']); CLI::setResource('publisher', function (Group $pools) { return new BrokerPool(publisher: $pools->get('publisher')); }, ['pools']); diff --git a/app/config/collections/common.php b/app/config/collections/common.php index add08931d1..7bccfb19ce 100644 --- a/app/config/collections/common.php +++ b/app/config/collections/common.php @@ -364,6 +364,61 @@ return [ 'array' => false, 'filters' => ['datetime'], ], + [ + '$id' => ID::custom('emailCanonical'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 320, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('emailIsFree'), + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('emailIsDisposable'), + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('emailIsCorporate'), + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('emailIsCanonical'), + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], ], 'indexes' => [ [ diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index bf0cee3527..dae0337dc9 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -2345,7 +2345,7 @@ return [ '$id' => ID::custom('errors'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 65535, + 'size' => 1_000_000, 'signed' => true, 'required' => true, 'default' => null, diff --git a/app/config/frameworks.php b/app/config/frameworks.php index 0ab4a8a7db..47e26ac91e 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -273,7 +273,7 @@ return [ 'key' => 'flutter', 'name' => 'Flutter', 'screenshotSleep' => 5000, - 'buildRuntime' => 'flutter-3.29', + 'buildRuntime' => 'flutter-3.35', 'runtimes' => getVersions($templateRuntimes['FLUTTER']['versions'], 'flutter'), 'adapters' => [ 'static' => [ @@ -282,6 +282,7 @@ return [ 'installCommand' => 'flutter pub get', 'outputDirectory' => './build/web', 'startCommand' => 'bash helpers/server.sh', + 'fallbackFile' => 'index.html' ], ], ], diff --git a/app/config/platforms.php b/app/config/platforms.php index 361ec6b935..2b5c107648 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -60,7 +60,7 @@ return [ [ 'key' => 'flutter', 'name' => 'Flutter', - 'version' => '20.3.0', + 'version' => '20.3.1', 'url' => 'https://github.com/appwrite/sdk-for-flutter', 'package' => 'https://pub.dev/packages/appwrite', 'enabled' => true, @@ -226,7 +226,7 @@ return [ [ 'key' => 'cli', 'name' => 'Command Line', - 'version' => '11.1.0', + 'version' => '11.1.1', 'url' => 'https://github.com/appwrite/sdk-for-cli', 'package' => 'https://www.npmjs.com/package/appwrite-cli', 'enabled' => true, @@ -281,7 +281,7 @@ return [ [ 'key' => 'php', 'name' => 'PHP', - 'version' => '17.5.0', + 'version' => '18.0.1', 'url' => 'https://github.com/appwrite/sdk-for-php', 'package' => 'https://packagist.org/packages/appwrite/appwrite', 'enabled' => true, @@ -376,7 +376,7 @@ return [ [ 'key' => 'dart', 'name' => 'Dart', - 'version' => '19.3.0', + 'version' => '19.4.0', 'url' => 'https://github.com/appwrite/sdk-for-dart', 'package' => 'https://pub.dev/packages/dart_appwrite', 'enabled' => true, diff --git a/app/config/specs/open-api3-1.8.x-client.json b/app/config/specs/open-api3-1.8.x-client.json index dde8390820..9adb21d960 100644 --- a/app/config/specs/open-api3-1.8.x-client.json +++ b/app/config/specs/open-api3-1.8.x-client.json @@ -6313,7 +6313,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -6326,7 +6327,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -6583,12 +6585,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } }, "required": [ @@ -6701,12 +6705,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -6801,7 +6807,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -6920,12 +6927,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -7044,12 +7053,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -7251,7 +7262,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -8194,7 +8206,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -8360,7 +8373,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "" + "x-example": "", + "x-nullable": true }, "permissions": { "type": "array", @@ -8368,7 +8382,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -9500,7 +9515,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -9513,7 +9529,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -9763,12 +9780,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -9877,12 +9896,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -9976,7 +9997,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -10094,12 +10116,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -10217,12 +10241,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } diff --git a/app/config/specs/open-api3-1.8.x-console.json b/app/config/specs/open-api3-1.8.x-console.json index aa1e81dbeb..6b6ab7409f 100644 --- a/app/config/specs/open-api3-1.8.x-console.json +++ b/app/config/specs/open-api3-1.8.x-console.json @@ -7059,7 +7059,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -7245,7 +7246,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -7524,7 +7526,8 @@ "default": { "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7644,7 +7647,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7869,7 +7873,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7974,7 +7979,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -8094,7 +8100,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8207,7 +8214,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "array": { "type": "boolean", @@ -8336,7 +8344,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8442,17 +8451,20 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8566,12 +8578,14 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8582,7 +8596,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8687,17 +8702,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8811,12 +8829,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8827,7 +8847,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8932,7 +8953,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -9052,7 +9074,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9287,7 +9310,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9521,7 +9545,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9755,7 +9780,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9872,12 +9898,14 @@ "key": { "type": "string", "description": "Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9999,7 +10027,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "array": { "type": "boolean", @@ -10125,12 +10154,14 @@ "size": { "type": "integer", "description": "Maximum size of the string attribute.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10235,7 +10266,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -10355,7 +10387,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10656,12 +10689,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10945,7 +10980,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -10958,7 +10994,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -11089,7 +11126,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } }, "required": [ @@ -11195,7 +11233,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -11293,7 +11332,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -11550,12 +11590,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } }, "required": [ @@ -11668,12 +11710,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -11768,7 +11812,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -11984,12 +12029,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -12108,12 +12155,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -13105,6 +13154,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13131,7 +13181,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13746,6 +13797,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13772,7 +13824,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -14166,12 +14219,14 @@ "entrypoint": { "type": "string", "description": "Entrypoint File.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "commands": { "type": "string", "description": "Build Commands.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "code": { "type": "string", @@ -14959,7 +15014,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "" + "x-example": "", + "x-nullable": true } } } @@ -15488,12 +15544,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17599,7 +17657,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17685,7 +17744,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -17693,7 +17753,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -17701,27 +17762,32 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "subject": { "type": "string", "description": "Email Subject.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "" + "x-example": "", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", @@ -17729,7 +17795,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "bcc": { "type": "array", @@ -17737,12 +17804,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", @@ -17750,7 +17819,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -17855,7 +17925,8 @@ "data": { "type": "object", "description": "Additional key-value pair data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -17900,7 +17971,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -18005,7 +18077,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -18013,7 +18086,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -18021,77 +18095,92 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "title": { "type": "string", "description": "Title for push notification.", - "x-example": "" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -18102,7 +18191,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -18275,7 +18365,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -18426,7 +18517,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -18434,7 +18526,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -18442,22 +18535,26 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -19002,7 +19099,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19157,7 +19255,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -19182,7 +19281,8 @@ "sandbox": { "type": "boolean", "description": "Use APNS sandbox environment.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19320,12 +19420,14 @@ "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19472,12 +19574,14 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -19563,7 +19667,8 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19588,7 +19693,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19685,12 +19791,14 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19801,7 +19909,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19888,7 +19997,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -20004,7 +20114,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20091,7 +20202,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20217,7 +20329,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20304,7 +20417,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20551,7 +20665,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20724,7 +20839,8 @@ "port": { "type": "integer", "description": "SMTP port.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -20751,7 +20867,8 @@ "autoTLS": { "type": "boolean", "description": "Enable SMTP AutoTLS feature.", - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -20781,7 +20898,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -20872,7 +20990,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20959,7 +21078,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -21065,7 +21185,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21152,7 +21273,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -21258,7 +21380,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21345,7 +21468,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -21451,7 +21575,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21538,7 +21663,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -22146,7 +22272,8 @@ "name": { "type": "string", "description": "Topic Name.", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", @@ -22154,7 +22281,8 @@ "x-example": "[\"any\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -22898,7 +23026,7 @@ "tags": [ "migrations" ], - "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in an Appwrite Storage bucket.", + "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete.", "responses": { "202": { "description": "Migration", @@ -22948,11 +23076,6 @@ "description": "Composite ID in the format {databaseId:collectionId}, identifying a collection within a database to export.", "x-example": "<ID1:ID2>" }, - "bucketId": { - "type": "string", - "description": "Storage bucket unique ID where the exported CSV will be stored.", - "x-example": "<BUCKET_ID>" - }, "filename": { "type": "string", "description": "The name of the file to be created for the export, excluding the .csv extension.", @@ -23002,7 +23125,6 @@ }, "required": [ "resourceId", - "bucketId", "filename" ] } @@ -24227,12 +24349,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only projects can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -26552,12 +26676,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "expire": { "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26723,12 +26849,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "expire": { "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26918,17 +27046,20 @@ "appId": { "type": "string", "description": "Provider app ID. Max length: 256 chars.", - "x-example": "<APP_ID>" + "x-example": "<APP_ID>", + "x-nullable": true }, "secret": { "type": "string", "description": "Provider secret key. Max length: 512 chars.", - "x-example": "<SECRET>" + "x-example": "<SECRET>", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Provider status. Set to 'false' to disable new session creation.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -30954,6 +31085,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -30980,7 +31112,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31601,6 +31734,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31627,7 +31761,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31983,17 +32118,20 @@ "installCommand": { "type": "string", "description": "Install Commands.", - "x-example": "<INSTALL_COMMAND>" + "x-example": "<INSTALL_COMMAND>", + "x-nullable": true }, "buildCommand": { "type": "string", "description": "Build Commands.", - "x-example": "<BUILD_COMMAND>" + "x-example": "<BUILD_COMMAND>", + "x-nullable": true }, "outputDirectory": { "type": "string", "description": "Output Directory.", - "x-example": "<OUTPUT_DIRECTORY>" + "x-example": "<OUTPUT_DIRECTORY>", + "x-nullable": true }, "code": { "type": "string", @@ -33186,12 +33324,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -33418,7 +33558,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -33611,7 +33752,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -33902,7 +34044,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -34068,7 +34211,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", @@ -34076,7 +34220,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -35761,7 +35906,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -35945,7 +36091,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -36221,7 +36368,8 @@ "default": { "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -36340,7 +36488,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36563,7 +36712,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36667,7 +36817,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -36786,7 +36937,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36898,7 +37050,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -37026,7 +37179,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37131,17 +37285,20 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37254,12 +37411,14 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -37270,7 +37429,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37374,17 +37534,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37497,12 +37660,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -37513,7 +37678,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37617,7 +37783,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37736,7 +37903,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37969,7 +38137,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38201,7 +38370,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38433,7 +38603,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38549,12 +38720,14 @@ "key": { "type": "string", "description": "Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -38675,7 +38848,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -38800,12 +38974,14 @@ "size": { "type": "integer", "description": "Maximum size of the string column.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38909,7 +39085,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -39028,7 +39205,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -39326,12 +39504,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -40076,7 +40256,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -40089,7 +40270,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40215,7 +40397,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -40320,7 +40503,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40417,7 +40601,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40667,12 +40852,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40781,12 +40968,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40880,7 +41069,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41094,12 +41284,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41217,12 +41409,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -43091,12 +43285,14 @@ "email": { "type": "string", "description": "User email.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/open-api3-1.8.x-server.json b/app/config/specs/open-api3-1.8.x-server.json index c3df6ef373..8fc49b1db5 100644 --- a/app/config/specs/open-api3-1.8.x-server.json +++ b/app/config/specs/open-api3-1.8.x-server.json @@ -6521,7 +6521,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -6709,7 +6710,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -6991,7 +6993,8 @@ "default": { "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7112,7 +7115,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7339,7 +7343,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7445,7 +7450,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -7566,7 +7572,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7680,7 +7687,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -7810,7 +7818,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7917,17 +7926,20 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8042,12 +8054,14 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8058,7 +8072,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8164,17 +8179,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8289,12 +8307,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8305,7 +8325,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8411,7 +8432,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8532,7 +8554,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8769,7 +8792,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9005,7 +9029,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9241,7 +9266,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9359,12 +9385,14 @@ "key": { "type": "string", "description": "Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9487,7 +9515,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -9614,12 +9643,14 @@ "size": { "type": "integer", "description": "Maximum size of the string attribute.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9725,7 +9756,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -9846,7 +9878,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10150,12 +10183,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10445,7 +10480,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -10458,7 +10494,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10591,7 +10628,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -10698,7 +10736,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10797,7 +10836,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11059,12 +11099,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11179,12 +11221,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11281,7 +11325,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11402,12 +11447,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11528,12 +11575,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12127,6 +12176,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12153,7 +12203,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12529,6 +12580,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12555,7 +12607,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12953,12 +13006,14 @@ "entrypoint": { "type": "string", "description": "Entrypoint File.", - "x-example": "<ENTRYPOINT>" + "x-example": "<ENTRYPOINT>", + "x-nullable": true }, "commands": { "type": "string", "description": "Build Commands.", - "x-example": "<COMMANDS>" + "x-example": "<COMMANDS>", + "x-nullable": true }, "code": { "type": "string", @@ -13757,7 +13812,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -14211,12 +14267,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -16367,7 +16425,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -16454,7 +16513,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -16462,7 +16522,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -16470,27 +16531,32 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "subject": { "type": "string", "description": "Email Subject.", - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", @@ -16498,7 +16564,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "bcc": { "type": "array", @@ -16506,12 +16573,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", @@ -16519,7 +16588,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -16625,7 +16695,8 @@ "data": { "type": "object", "description": "Additional key-value pair data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -16670,7 +16741,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -16776,7 +16848,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -16784,7 +16857,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -16792,77 +16866,92 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "title": { "type": "string", "description": "Title for push notification.", - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -16873,7 +16962,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -17049,7 +17139,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17203,7 +17294,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -17211,7 +17303,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -17219,22 +17312,26 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -17787,7 +17884,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17945,7 +18043,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -17970,7 +18069,8 @@ "sandbox": { "type": "boolean", "description": "Use APNS sandbox environment.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -18111,12 +18211,14 @@ "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18266,12 +18368,14 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -18358,7 +18462,8 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18383,7 +18488,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18481,12 +18587,14 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18598,7 +18706,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18686,7 +18795,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -18803,7 +18913,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18891,7 +19002,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19018,7 +19130,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19106,7 +19219,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19356,7 +19470,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19532,7 +19647,8 @@ "port": { "type": "integer", "description": "SMTP port.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -19559,7 +19675,8 @@ "autoTLS": { "type": "boolean", "description": "Enable SMTP AutoTLS feature.", - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -19589,7 +19706,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19681,7 +19799,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19769,7 +19888,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -19876,7 +19996,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19964,7 +20085,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -20071,7 +20193,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20159,7 +20282,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -20266,7 +20390,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20354,7 +20479,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20970,7 +21096,8 @@ "name": { "type": "string", "description": "Topic Name.", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", @@ -20978,7 +21105,8 @@ "x-example": "[\"any\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -21703,6 +21831,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -21729,7 +21858,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22122,6 +22252,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -22148,7 +22279,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22508,17 +22640,20 @@ "installCommand": { "type": "string", "description": "Install Commands.", - "x-example": "<INSTALL_COMMAND>" + "x-example": "<INSTALL_COMMAND>", + "x-nullable": true }, "buildCommand": { "type": "string", "description": "Build Commands.", - "x-example": "<BUILD_COMMAND>" + "x-example": "<BUILD_COMMAND>", + "x-nullable": true }, "outputDirectory": { "type": "string", "description": "Output Directory.", - "x-example": "<OUTPUT_DIRECTORY>" + "x-example": "<OUTPUT_DIRECTORY>", + "x-nullable": true }, "code": { "type": "string", @@ -23643,12 +23778,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -23878,7 +24015,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -24073,7 +24211,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -24369,7 +24508,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -24539,7 +24679,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", @@ -24547,7 +24688,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -26008,7 +26150,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -26194,7 +26337,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -26473,7 +26617,8 @@ "default": { "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -26593,7 +26738,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26818,7 +26964,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26923,7 +27070,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -27043,7 +27191,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27156,7 +27305,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -27285,7 +27435,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27391,17 +27542,20 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27515,12 +27669,14 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -27531,7 +27687,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27636,17 +27793,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27760,12 +27920,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -27776,7 +27938,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27881,7 +28044,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -28001,7 +28165,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28236,7 +28401,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28470,7 +28636,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28704,7 +28871,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28821,12 +28989,14 @@ "key": { "type": "string", "description": "Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -28948,7 +29118,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -29074,12 +29245,14 @@ "size": { "type": "integer", "description": "Maximum size of the string column.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29184,7 +29357,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -29304,7 +29478,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29605,12 +29780,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -30279,7 +30456,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -30292,7 +30470,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30420,7 +30599,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -30526,7 +30706,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30624,7 +30805,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30879,12 +31061,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30995,12 +31179,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31096,7 +31282,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31216,12 +31403,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31341,12 +31530,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -32959,12 +33150,14 @@ "email": { "type": "string", "description": "User email.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index dde8390820..9adb21d960 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -6313,7 +6313,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -6326,7 +6327,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6583,12 +6585,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -6701,12 +6705,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6801,7 +6807,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6920,12 +6927,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7044,12 +7053,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7251,7 +7262,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -8194,7 +8206,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -8360,7 +8373,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", @@ -8368,7 +8382,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -9500,7 +9515,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -9513,7 +9529,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9763,12 +9780,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9877,12 +9896,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9976,7 +9997,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10094,12 +10116,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10217,12 +10241,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index aa1e81dbeb..12d2d30ab9 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -7059,7 +7059,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -7245,7 +7246,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -7524,7 +7526,8 @@ "default": { "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7644,7 +7647,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7869,7 +7873,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7974,7 +7979,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -8094,7 +8100,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8207,7 +8214,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -8336,7 +8344,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8442,17 +8451,20 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8566,12 +8578,14 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8582,7 +8596,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8687,17 +8702,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8811,12 +8829,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8827,7 +8847,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8932,7 +8953,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -9052,7 +9074,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9287,7 +9310,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9521,7 +9545,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9755,7 +9780,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9872,12 +9898,14 @@ "key": { "type": "string", "description": "Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9999,7 +10027,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -10125,12 +10154,14 @@ "size": { "type": "integer", "description": "Maximum size of the string attribute.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10235,7 +10266,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -10355,7 +10387,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10656,12 +10689,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10945,7 +10980,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -10958,7 +10994,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11089,7 +11126,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11195,7 +11233,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11293,7 +11332,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11550,12 +11590,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11668,12 +11710,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11768,7 +11812,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11984,12 +12029,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12108,12 +12155,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -13105,6 +13154,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13131,7 +13181,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13746,6 +13797,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13772,7 +13824,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -14166,12 +14219,14 @@ "entrypoint": { "type": "string", "description": "Entrypoint File.", - "x-example": "<ENTRYPOINT>" + "x-example": "<ENTRYPOINT>", + "x-nullable": true }, "commands": { "type": "string", "description": "Build Commands.", - "x-example": "<COMMANDS>" + "x-example": "<COMMANDS>", + "x-nullable": true }, "code": { "type": "string", @@ -14359,10 +14414,22 @@ "description": "Path to function code in the template repo.", "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the function template.", - "x-example": "<VERSION>" + "description": "Type for the reference provided. Can be commit, branch, or tag", + "x-example": "commit", + "enum": [ + "commit", + "branch", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -14374,7 +14441,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -14959,7 +15027,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -15488,12 +15557,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17599,7 +17670,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17685,7 +17757,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -17693,7 +17766,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -17701,27 +17775,32 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "subject": { "type": "string", "description": "Email Subject.", - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", @@ -17729,7 +17808,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "bcc": { "type": "array", @@ -17737,12 +17817,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", @@ -17750,7 +17832,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -17855,7 +17938,8 @@ "data": { "type": "object", "description": "Additional key-value pair data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -17900,7 +17984,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -18005,7 +18090,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -18013,7 +18099,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -18021,77 +18108,92 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "title": { "type": "string", "description": "Title for push notification.", - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -18102,7 +18204,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -18275,7 +18378,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -18426,7 +18530,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -18434,7 +18539,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -18442,22 +18548,26 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -19002,7 +19112,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19157,7 +19268,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -19182,7 +19294,8 @@ "sandbox": { "type": "boolean", "description": "Use APNS sandbox environment.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19320,12 +19433,14 @@ "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19472,12 +19587,14 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -19563,7 +19680,8 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19588,7 +19706,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19685,12 +19804,14 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19801,7 +19922,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19888,7 +20010,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -20004,7 +20127,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20091,7 +20215,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20217,7 +20342,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20304,7 +20430,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20551,7 +20678,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20724,7 +20852,8 @@ "port": { "type": "integer", "description": "SMTP port.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -20751,7 +20880,8 @@ "autoTLS": { "type": "boolean", "description": "Enable SMTP AutoTLS feature.", - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -20781,7 +20911,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -20872,7 +21003,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20959,7 +21091,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -21065,7 +21198,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21152,7 +21286,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -21258,7 +21393,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21345,7 +21481,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -21451,7 +21588,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21538,7 +21676,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -22146,7 +22285,8 @@ "name": { "type": "string", "description": "Topic Name.", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", @@ -22154,7 +22294,8 @@ "x-example": "[\"any\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -22898,7 +23039,7 @@ "tags": [ "migrations" ], - "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in an Appwrite Storage bucket.", + "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete.", "responses": { "202": { "description": "Migration", @@ -22948,11 +23089,6 @@ "description": "Composite ID in the format {databaseId:collectionId}, identifying a collection within a database to export.", "x-example": "<ID1:ID2>" }, - "bucketId": { - "type": "string", - "description": "Storage bucket unique ID where the exported CSV will be stored.", - "x-example": "<BUCKET_ID>" - }, "filename": { "type": "string", "description": "The name of the file to be created for the export, excluding the .csv extension.", @@ -23002,7 +23138,6 @@ }, "required": [ "resourceId", - "bucketId", "filename" ] } @@ -24227,12 +24362,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only projects can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -26552,12 +26689,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "expire": { "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26723,12 +26862,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "expire": { "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26918,17 +27059,20 @@ "appId": { "type": "string", "description": "Provider app ID. Max length: 256 chars.", - "x-example": "<APP_ID>" + "x-example": "<APP_ID>", + "x-nullable": true }, "secret": { "type": "string", "description": "Provider secret key. Max length: 512 chars.", - "x-example": "<SECRET>" + "x-example": "<SECRET>", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Provider status. Set to 'false' to disable new session creation.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -30954,6 +31098,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -30980,7 +31125,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31601,6 +31747,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31627,7 +31774,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31983,17 +32131,20 @@ "installCommand": { "type": "string", "description": "Install Commands.", - "x-example": "<INSTALL_COMMAND>" + "x-example": "<INSTALL_COMMAND>", + "x-nullable": true }, "buildCommand": { "type": "string", "description": "Build Commands.", - "x-example": "<BUILD_COMMAND>" + "x-example": "<BUILD_COMMAND>", + "x-nullable": true }, "outputDirectory": { "type": "string", "description": "Output Directory.", - "x-example": "<OUTPUT_DIRECTORY>" + "x-example": "<OUTPUT_DIRECTORY>", + "x-nullable": true }, "code": { "type": "string", @@ -32176,10 +32327,22 @@ "description": "Path to site code in the template repo.", "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the site template.", - "x-example": "<VERSION>" + "description": "Type for the reference provided. Can be commit, branch, or tag", + "x-example": "branch", + "enum": [ + "branch", + "commit", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -32191,7 +32354,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -33186,12 +33350,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -33418,7 +33584,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -33611,7 +33778,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -33902,7 +34070,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -34068,7 +34237,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", @@ -34076,7 +34246,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -35761,7 +35932,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -35945,7 +36117,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -36221,7 +36394,8 @@ "default": { "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -36340,7 +36514,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36563,7 +36738,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36667,7 +36843,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -36786,7 +36963,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36898,7 +37076,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -37026,7 +37205,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37131,17 +37311,20 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37254,12 +37437,14 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -37270,7 +37455,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37374,17 +37560,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37497,12 +37686,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -37513,7 +37704,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37617,7 +37809,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37736,7 +37929,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37969,7 +38163,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38201,7 +38396,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38433,7 +38629,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38549,12 +38746,14 @@ "key": { "type": "string", "description": "Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -38675,7 +38874,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -38800,12 +39000,14 @@ "size": { "type": "integer", "description": "Maximum size of the string column.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38909,7 +39111,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -39028,7 +39231,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -39326,12 +39530,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -40076,7 +40282,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -40089,7 +40296,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40215,7 +40423,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -40320,7 +40529,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40417,7 +40627,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40667,12 +40878,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40781,12 +40994,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40880,7 +41095,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41094,12 +41310,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41217,12 +41435,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -43091,12 +43311,14 @@ "email": { "type": "string", "description": "User email.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index c3df6ef373..b11c69442b 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -6521,7 +6521,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -6709,7 +6710,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documentSecurity": { "type": "boolean", @@ -6991,7 +6993,8 @@ "default": { "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7112,7 +7115,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7339,7 +7343,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7445,7 +7450,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -7566,7 +7572,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7680,7 +7687,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -7810,7 +7818,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7917,17 +7926,20 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8042,12 +8054,14 @@ "min": { "type": "number", "description": "Minimum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8058,7 +8072,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8164,17 +8179,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8289,12 +8307,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8305,7 +8325,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8411,7 +8432,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when attribute is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8532,7 +8554,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8769,7 +8792,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9005,7 +9029,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9241,7 +9266,8 @@ "newKey": { "type": "string", "description": "New attribute key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9359,12 +9385,14 @@ "key": { "type": "string", "description": "Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9487,7 +9515,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -9614,12 +9643,14 @@ "size": { "type": "integer", "description": "Maximum size of the string attribute.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9725,7 +9756,8 @@ "default": { "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -9846,7 +9878,8 @@ "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10150,12 +10183,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10445,7 +10480,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "documents": { "type": "array", @@ -10458,7 +10494,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10591,7 +10628,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -10698,7 +10736,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10797,7 +10836,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11059,12 +11099,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11179,12 +11221,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11281,7 +11325,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11402,12 +11447,14 @@ "min": { "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11528,12 +11575,14 @@ "max": { "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12127,6 +12176,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12153,7 +12203,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12529,6 +12580,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12555,7 +12607,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12953,12 +13006,14 @@ "entrypoint": { "type": "string", "description": "Entrypoint File.", - "x-example": "<ENTRYPOINT>" + "x-example": "<ENTRYPOINT>", + "x-nullable": true }, "commands": { "type": "string", "description": "Build Commands.", - "x-example": "<COMMANDS>" + "x-example": "<COMMANDS>", + "x-nullable": true }, "code": { "type": "string", @@ -13148,10 +13203,22 @@ "description": "Path to function code in the template repo.", "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the function template.", - "x-example": "<VERSION>" + "description": "Type for the reference provided. Can be commit, branch, or tag", + "x-example": "commit", + "enum": [ + "commit", + "branch", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -13163,7 +13230,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -13757,7 +13825,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -14211,12 +14280,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -16367,7 +16438,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -16454,7 +16526,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -16462,7 +16535,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -16470,27 +16544,32 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "subject": { "type": "string", "description": "Email Subject.", - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", @@ -16498,7 +16577,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "bcc": { "type": "array", @@ -16506,12 +16586,14 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", @@ -16519,7 +16601,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -16625,7 +16708,8 @@ "data": { "type": "object", "description": "Additional key-value pair data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -16670,7 +16754,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -16776,7 +16861,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -16784,7 +16870,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -16792,77 +16879,92 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "title": { "type": "string", "description": "Title for push notification.", - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -16873,7 +16975,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -17049,7 +17152,8 @@ "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17203,7 +17307,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "users": { "type": "array", @@ -17211,7 +17316,8 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "targets": { "type": "array", @@ -17219,22 +17325,26 @@ "x-example": null, "items": { "type": "string" - } + }, + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -17787,7 +17897,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17945,7 +18056,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -17970,7 +18082,8 @@ "sandbox": { "type": "boolean", "description": "Use APNS sandbox environment.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -18111,12 +18224,14 @@ "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18266,12 +18381,14 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -18358,7 +18475,8 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18383,7 +18501,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18481,12 +18600,14 @@ "isEuRegion": { "type": "boolean", "description": "Set as EU region.", - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18598,7 +18719,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18686,7 +18808,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -18803,7 +18926,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18891,7 +19015,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19018,7 +19143,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19106,7 +19232,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19356,7 +19483,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19532,7 +19660,8 @@ "port": { "type": "integer", "description": "SMTP port.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -19559,7 +19688,8 @@ "autoTLS": { "type": "boolean", "description": "Enable SMTP AutoTLS feature.", - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -19589,7 +19719,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19681,7 +19812,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19769,7 +19901,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -19876,7 +20009,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19964,7 +20098,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -20071,7 +20206,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20159,7 +20295,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -20266,7 +20403,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20354,7 +20492,8 @@ "enabled": { "type": "boolean", "description": "Set as enabled.", - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20970,7 +21109,8 @@ "name": { "type": "string", "description": "Topic Name.", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", @@ -20978,7 +21118,8 @@ "x-example": "[\"any\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -21703,6 +21844,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -21729,7 +21871,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22122,6 +22265,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -22148,7 +22292,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22508,17 +22653,20 @@ "installCommand": { "type": "string", "description": "Install Commands.", - "x-example": "<INSTALL_COMMAND>" + "x-example": "<INSTALL_COMMAND>", + "x-nullable": true }, "buildCommand": { "type": "string", "description": "Build Commands.", - "x-example": "<BUILD_COMMAND>" + "x-example": "<BUILD_COMMAND>", + "x-nullable": true }, "outputDirectory": { "type": "string", "description": "Output Directory.", - "x-example": "<OUTPUT_DIRECTORY>" + "x-example": "<OUTPUT_DIRECTORY>", + "x-nullable": true }, "code": { "type": "string", @@ -22703,10 +22851,22 @@ "description": "Path to site code in the template repo.", "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the site template.", - "x-example": "<VERSION>" + "description": "Type for the reference provided. Can be commit, branch, or tag", + "x-example": "branch", + "enum": [ + "branch", + "commit", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -22718,7 +22878,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -23643,12 +23804,14 @@ "value": { "type": "string", "description": "Variable value. Max length: 8192 chars.", - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -23878,7 +24041,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -24073,7 +24237,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "fileSecurity": { "type": "boolean", @@ -24369,7 +24534,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } }, "required": [ @@ -24539,7 +24705,8 @@ "name": { "type": "string", "description": "Name of the file", - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", @@ -24547,7 +24714,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true } } } @@ -26008,7 +26176,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -26194,7 +26363,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rowSecurity": { "type": "boolean", @@ -26473,7 +26643,8 @@ "default": { "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -26593,7 +26764,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26818,7 +26990,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26923,7 +27096,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -27043,7 +27217,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27156,7 +27331,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -27285,7 +27461,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27391,17 +27568,20 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27515,12 +27695,14 @@ "min": { "type": "number", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -27531,7 +27713,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27636,17 +27819,20 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27760,12 +27946,14 @@ "min": { "type": "integer", "description": "Minimum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -27776,7 +27964,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27881,7 +28070,8 @@ "default": { "type": "string", "description": "Default value. Cannot be set when column is required.", - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -28001,7 +28191,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28236,7 +28427,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28470,7 +28662,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28704,7 +28897,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28821,12 +29015,14 @@ "key": { "type": "string", "description": "Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -28948,7 +29144,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -29074,12 +29271,14 @@ "size": { "type": "integer", "description": "Maximum size of the string column.", - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29184,7 +29383,8 @@ "default": { "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -29304,7 +29504,8 @@ "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29605,12 +29806,14 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -30279,7 +30482,8 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "rows": { "type": "array", @@ -30292,7 +30496,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30420,7 +30625,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -30526,7 +30732,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30624,7 +30831,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30879,12 +31087,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30995,12 +31205,14 @@ "x-example": "[\"read(\"any\")\"]", "items": { "type": "string" - } + }, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31096,7 +31308,8 @@ "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31216,12 +31429,14 @@ "min": { "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31341,12 +31556,14 @@ "max": { "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -32959,12 +33176,14 @@ "email": { "type": "string", "description": "User email.", - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/swagger2-1.8.x-client.json b/app/config/specs/swagger2-1.8.x-client.json index a304a7cb1a..1594f816ef 100644 --- a/app/config/specs/swagger2-1.8.x-client.json +++ b/app/config/specs/swagger2-1.8.x-client.json @@ -6400,6 +6400,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6417,7 +6418,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6657,6 +6659,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6665,7 +6668,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -6771,6 +6775,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6779,7 +6784,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6870,7 +6876,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6982,13 +6989,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7100,13 +7109,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7305,7 +7316,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -8417,13 +8429,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9516,6 +9530,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9533,7 +9548,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9766,6 +9782,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9774,7 +9791,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9876,6 +9894,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9884,7 +9903,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9974,7 +9994,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10085,13 +10106,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10202,13 +10225,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } diff --git a/app/config/specs/swagger2-1.8.x-console.json b/app/config/specs/swagger2-1.8.x-console.json index 158b308f87..384011f2fd 100644 --- a/app/config/specs/swagger2-1.8.x-console.json +++ b/app/config/specs/swagger2-1.8.x-console.json @@ -7168,6 +7168,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7350,6 +7351,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7625,7 +7627,8 @@ "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7743,7 +7746,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7965,7 +7969,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8069,7 +8074,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -8187,7 +8193,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8300,7 +8307,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -8428,7 +8436,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8533,19 +8542,22 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8656,13 +8668,15 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8675,7 +8689,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8779,19 +8794,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8902,13 +8920,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8921,7 +8941,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9025,7 +9046,8 @@ "type": "string", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -9143,7 +9165,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9360,7 +9383,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9576,7 +9600,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9792,7 +9817,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9909,13 +9935,15 @@ "type": "string", "description": "Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -10038,7 +10066,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -10163,13 +10192,15 @@ "type": "integer", "description": "Maximum size of the string attribute.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10273,7 +10304,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -10391,7 +10423,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10679,13 +10712,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10955,6 +10990,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -10972,7 +11008,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11101,7 +11138,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11206,7 +11244,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11302,7 +11341,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11542,6 +11582,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11550,7 +11591,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11656,6 +11698,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11664,7 +11707,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11755,7 +11799,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11957,13 +12002,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12075,13 +12122,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -13041,6 +13090,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13067,7 +13117,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13683,6 +13734,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13709,7 +13761,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -14896,7 +14949,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -15409,13 +15463,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17532,7 +17588,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17615,6 +17672,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17624,6 +17682,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17633,6 +17692,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17641,31 +17701,36 @@ "type": "string", "description": "Email Subject.", "default": null, - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", "description": "Array of target IDs to be added as CC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17675,6 +17740,7 @@ "description": "Array of target IDs to be added as BCC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17683,13 +17749,15 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", "description": "Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17806,7 +17874,8 @@ "type": "object", "description": "Additional key-value pair data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -17860,7 +17929,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -17965,6 +18035,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17974,6 +18045,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17983,6 +18055,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17991,85 +18064,99 @@ "type": "string", "description": "Title for push notification.", "default": null, - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", "default": null, - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", "default": null, - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", "default": null, - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", "default": null, - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", "default": null, - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", "default": null, - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -18081,7 +18168,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -18263,7 +18351,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -18411,6 +18500,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18420,6 +18510,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18429,6 +18520,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18437,19 +18529,22 @@ "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -18989,7 +19084,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19144,7 +19240,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -19174,7 +19271,8 @@ "type": "boolean", "description": "Use APNS sandbox environment.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19317,13 +19415,15 @@ "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19470,13 +19570,15 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -19569,7 +19671,8 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19599,7 +19702,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19698,13 +19802,15 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19827,7 +19933,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19914,7 +20021,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -20043,7 +20151,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20130,7 +20239,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20271,7 +20381,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20358,7 +20469,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20626,7 +20738,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20800,7 +20913,8 @@ "type": "integer", "description": "SMTP port.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -20831,7 +20945,8 @@ "type": "boolean", "description": "Enable SMTP AutoTLS feature.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -20867,7 +20982,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -20966,7 +21082,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21053,7 +21170,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -21170,7 +21288,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21257,7 +21376,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -21374,7 +21494,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21461,7 +21582,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -21578,7 +21700,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21665,7 +21788,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -22265,13 +22389,15 @@ "type": "string", "description": "Topic Name.", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", "description": "An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https:\/\/appwrite.io\/docs\/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.", "default": null, "x-example": "[\"any\"]", + "x-nullable": true, "items": { "type": "string" } @@ -23001,7 +23127,7 @@ "tags": [ "migrations" ], - "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in an Appwrite Storage bucket.", + "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete.", "responses": { "202": { "description": "Migration", @@ -23049,12 +23175,6 @@ "default": null, "x-example": "<ID1:ID2>" }, - "bucketId": { - "type": "string", - "description": "Storage bucket unique ID where the exported CSV will be stored.", - "default": null, - "x-example": "<BUCKET_ID>" - }, "filename": { "type": "string", "description": "The name of the file to be created for the export, excluding the .csv extension.", @@ -23112,7 +23232,6 @@ }, "required": [ "resourceId", - "bucketId", "filename" ] } @@ -24332,13 +24451,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only projects can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -26651,6 +26772,7 @@ "description": "Key scopes list. Maximum of 100 scopes are allowed.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -26659,7 +26781,8 @@ "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26817,6 +26940,7 @@ "description": "Key scopes list. Maximum of 100 events are allowed.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -26825,7 +26949,8 @@ "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27015,19 +27140,22 @@ "type": "string", "description": "Provider app ID. Max length: 256 chars.", "default": null, - "x-example": "<APP_ID>" + "x-example": "<APP_ID>", + "x-nullable": true }, "secret": { "type": "string", "description": "Provider secret key. Max length: 512 chars.", "default": null, - "x-example": "<SECRET>" + "x-example": "<SECRET>", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Provider status. Set to 'false' to disable new session creation.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -31058,6 +31186,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31084,7 +31213,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31708,6 +31838,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31734,7 +31865,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -33273,13 +33405,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -33504,6 +33638,7 @@ "description": "An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -33702,6 +33837,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -34146,13 +34282,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -35796,6 +35934,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -35976,6 +36115,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -36248,7 +36388,8 @@ "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -36365,7 +36506,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36585,7 +36727,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36688,7 +36831,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -36805,7 +36949,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36917,7 +37062,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -37044,7 +37190,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37148,19 +37295,22 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37270,13 +37420,15 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -37289,7 +37441,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37392,19 +37545,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37514,13 +37670,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -37533,7 +37691,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37636,7 +37795,8 @@ "type": "string", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37753,7 +37913,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37968,7 +38129,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38182,7 +38344,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38396,7 +38559,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38512,13 +38676,15 @@ "type": "string", "description": "Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -38640,7 +38806,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -38764,13 +38931,15 @@ "type": "integer", "description": "Maximum size of the string column.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38873,7 +39042,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -38990,7 +39160,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -39275,13 +39446,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -39993,6 +40166,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40010,7 +40184,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40134,7 +40309,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -40238,7 +40414,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40333,7 +40510,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40566,6 +40744,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40574,7 +40753,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40676,6 +40856,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40684,7 +40865,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40774,7 +40956,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40974,13 +41157,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41091,13 +41276,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -42915,13 +43102,15 @@ "type": "string", "description": "User email.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", "default": null, - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/swagger2-1.8.x-server.json b/app/config/specs/swagger2-1.8.x-server.json index 8b972be590..af417d5788 100644 --- a/app/config/specs/swagger2-1.8.x-server.json +++ b/app/config/specs/swagger2-1.8.x-server.json @@ -6620,6 +6620,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6804,6 +6805,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7082,7 +7084,8 @@ "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7201,7 +7204,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7425,7 +7429,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7530,7 +7535,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -7649,7 +7655,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7763,7 +7770,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -7892,7 +7900,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7998,19 +8007,22 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8122,13 +8134,15 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8141,7 +8155,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8246,19 +8261,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8370,13 +8388,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8389,7 +8409,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8494,7 +8515,8 @@ "type": "string", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8613,7 +8635,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8832,7 +8855,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9050,7 +9074,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9268,7 +9293,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9386,13 +9412,15 @@ "type": "string", "description": "Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9516,7 +9544,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -9642,13 +9671,15 @@ "type": "integer", "description": "Maximum size of the string attribute.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9753,7 +9784,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -9872,7 +9904,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10163,13 +10196,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10445,6 +10480,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -10462,7 +10498,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10593,7 +10630,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -10699,7 +10737,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10796,7 +10835,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11041,6 +11081,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11049,7 +11090,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11157,6 +11199,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11165,7 +11208,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11258,7 +11302,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11372,13 +11417,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11492,13 +11539,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12078,6 +12127,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12104,7 +12154,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12493,6 +12544,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12519,7 +12571,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13721,7 +13774,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -14163,13 +14217,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -16331,7 +16387,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -16415,6 +16472,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16424,6 +16482,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16433,6 +16492,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16441,31 +16501,36 @@ "type": "string", "description": "Email Subject.", "default": null, - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", "description": "Array of target IDs to be added as CC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16475,6 +16540,7 @@ "description": "Array of target IDs to be added as BCC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16483,13 +16549,15 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", "description": "Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16607,7 +16675,8 @@ "type": "object", "description": "Additional key-value pair data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -16661,7 +16730,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -16767,6 +16837,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16776,6 +16847,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16785,6 +16857,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16793,85 +16866,99 @@ "type": "string", "description": "Title for push notification.", "default": null, - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", "default": null, - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", "default": null, - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", "default": null, - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", "default": null, - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", "default": null, - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", "default": null, - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -16883,7 +16970,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -17068,7 +17156,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17219,6 +17308,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17228,6 +17318,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17237,6 +17328,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17245,19 +17337,22 @@ "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -17805,7 +17900,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17963,7 +18059,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -17993,7 +18090,8 @@ "type": "boolean", "description": "Use APNS sandbox environment.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -18139,13 +18237,15 @@ "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18295,13 +18395,15 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -18395,7 +18497,8 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18425,7 +18528,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18525,13 +18629,15 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18655,7 +18761,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18743,7 +18850,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -18873,7 +18981,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18961,7 +19070,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19103,7 +19213,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19191,7 +19302,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19462,7 +19574,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19639,7 +19752,8 @@ "type": "integer", "description": "SMTP port.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -19670,7 +19784,8 @@ "type": "boolean", "description": "Enable SMTP AutoTLS feature.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -19706,7 +19821,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19806,7 +19922,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19894,7 +20011,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -20012,7 +20130,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20100,7 +20219,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -20218,7 +20338,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20306,7 +20427,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -20424,7 +20546,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20512,7 +20635,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -21120,13 +21244,15 @@ "type": "string", "description": "Topic Name.", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", "description": "An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https:\/\/appwrite.io\/docs\/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.", "default": null, "x-example": "[\"any\"]", + "x-nullable": true, "items": { "type": "string" } @@ -21845,6 +21971,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -21871,7 +21998,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22277,6 +22405,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -22303,7 +22432,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -23782,13 +23912,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -24016,6 +24148,7 @@ "description": "An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -24216,6 +24349,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -24669,13 +24803,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26103,6 +26239,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26285,6 +26422,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26560,7 +26698,8 @@ "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -26678,7 +26817,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26900,7 +27040,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27004,7 +27145,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -27122,7 +27264,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27235,7 +27378,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -27363,7 +27507,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27468,19 +27613,22 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27591,13 +27739,15 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -27610,7 +27760,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27714,19 +27865,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27837,13 +27991,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -27856,7 +28012,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27960,7 +28117,8 @@ "type": "string", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -28078,7 +28236,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28295,7 +28454,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28511,7 +28671,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28727,7 +28888,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28844,13 +29006,15 @@ "type": "string", "description": "Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -28973,7 +29137,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -29098,13 +29263,15 @@ "type": "integer", "description": "Maximum size of the string column.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29208,7 +29375,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -29326,7 +29494,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29614,13 +29783,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -30261,6 +30432,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30278,7 +30450,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30404,7 +30577,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -30509,7 +30683,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30605,7 +30780,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30843,6 +31019,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30851,7 +31028,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30955,6 +31133,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30963,7 +31142,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31055,7 +31235,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31168,13 +31349,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31287,13 +31470,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -32870,13 +33055,15 @@ "type": "string", "description": "User email.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", "default": null, - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index a304a7cb1a..1594f816ef 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -6400,6 +6400,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6417,7 +6418,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6657,6 +6659,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6665,7 +6668,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -6771,6 +6775,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6779,7 +6784,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6870,7 +6876,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -6982,13 +6989,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7100,13 +7109,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -7305,7 +7316,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -8417,13 +8429,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9516,6 +9530,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9533,7 +9548,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9766,6 +9782,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9774,7 +9791,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9876,6 +9894,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -9884,7 +9903,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -9974,7 +9994,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10085,13 +10106,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10202,13 +10225,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 158b308f87..efa5d9bdee 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -7168,6 +7168,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7350,6 +7351,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7625,7 +7627,8 @@ "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7743,7 +7746,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7965,7 +7969,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8069,7 +8074,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -8187,7 +8193,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8300,7 +8307,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -8428,7 +8436,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8533,19 +8542,22 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8656,13 +8668,15 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8675,7 +8689,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8779,19 +8794,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8902,13 +8920,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8921,7 +8941,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9025,7 +9046,8 @@ "type": "string", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -9143,7 +9165,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9360,7 +9383,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9576,7 +9600,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9792,7 +9817,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9909,13 +9935,15 @@ "type": "string", "description": "Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -10038,7 +10066,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -10163,13 +10192,15 @@ "type": "integer", "description": "Maximum size of the string attribute.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10273,7 +10304,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -10391,7 +10423,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10679,13 +10712,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10955,6 +10990,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -10972,7 +11008,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11101,7 +11138,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11206,7 +11244,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11302,7 +11341,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11542,6 +11582,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11550,7 +11591,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11656,6 +11698,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11664,7 +11707,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11755,7 +11799,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11957,13 +12002,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12075,13 +12122,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -13041,6 +13090,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13067,7 +13117,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13683,6 +13734,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -13709,7 +13761,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -14302,11 +14355,24 @@ "default": null, "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the function template.", + "description": "Type for the reference provided. Can be commit, branch, or tag", "default": null, - "x-example": "<VERSION>" + "x-example": "commit", + "enum": [ + "commit", + "branch", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "default": null, + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -14319,7 +14385,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -14896,7 +14963,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -15409,13 +15477,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17532,7 +17602,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17615,6 +17686,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17624,6 +17696,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17633,6 +17706,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17641,31 +17715,36 @@ "type": "string", "description": "Email Subject.", "default": null, - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", "description": "Array of target IDs to be added as CC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17675,6 +17754,7 @@ "description": "Array of target IDs to be added as BCC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17683,13 +17763,15 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", "description": "Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17806,7 +17888,8 @@ "type": "object", "description": "Additional key-value pair data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -17860,7 +17943,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -17965,6 +18049,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17974,6 +18059,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17983,6 +18069,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17991,85 +18078,99 @@ "type": "string", "description": "Title for push notification.", "default": null, - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", "default": null, - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", "default": null, - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", "default": null, - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", "default": null, - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", "default": null, - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", "default": null, - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -18081,7 +18182,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -18263,7 +18365,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -18411,6 +18514,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18420,6 +18524,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18429,6 +18534,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -18437,19 +18543,22 @@ "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -18989,7 +19098,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19144,7 +19254,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -19174,7 +19285,8 @@ "type": "boolean", "description": "Use APNS sandbox environment.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19317,13 +19429,15 @@ "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19470,13 +19584,15 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -19569,7 +19685,8 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19599,7 +19716,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19698,13 +19816,15 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -19827,7 +19947,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19914,7 +20035,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -20043,7 +20165,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20130,7 +20253,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20271,7 +20395,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20358,7 +20483,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -20626,7 +20752,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20800,7 +20927,8 @@ "type": "integer", "description": "SMTP port.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -20831,7 +20959,8 @@ "type": "boolean", "description": "Enable SMTP AutoTLS feature.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -20867,7 +20996,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -20966,7 +21096,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21053,7 +21184,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -21170,7 +21302,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21257,7 +21390,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -21374,7 +21508,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21461,7 +21596,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -21578,7 +21714,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -21665,7 +21802,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -22265,13 +22403,15 @@ "type": "string", "description": "Topic Name.", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", "description": "An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https:\/\/appwrite.io\/docs\/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.", "default": null, "x-example": "[\"any\"]", + "x-nullable": true, "items": { "type": "string" } @@ -23001,7 +23141,7 @@ "tags": [ "migrations" ], - "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in an Appwrite Storage bucket.", + "description": "Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete.", "responses": { "202": { "description": "Migration", @@ -23049,12 +23189,6 @@ "default": null, "x-example": "<ID1:ID2>" }, - "bucketId": { - "type": "string", - "description": "Storage bucket unique ID where the exported CSV will be stored.", - "default": null, - "x-example": "<BUCKET_ID>" - }, "filename": { "type": "string", "description": "The name of the file to be created for the export, excluding the .csv extension.", @@ -23112,7 +23246,6 @@ }, "required": [ "resourceId", - "bucketId", "filename" ] } @@ -24332,13 +24465,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only projects can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -26651,6 +26786,7 @@ "description": "Key scopes list. Maximum of 100 scopes are allowed.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -26659,7 +26795,8 @@ "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26817,6 +26954,7 @@ "description": "Key scopes list. Maximum of 100 events are allowed.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -26825,7 +26963,8 @@ "type": "string", "description": "Expiration time in [ISO 8601](https:\/\/www.iso.org\/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27015,19 +27154,22 @@ "type": "string", "description": "Provider app ID. Max length: 256 chars.", "default": null, - "x-example": "<APP_ID>" + "x-example": "<APP_ID>", + "x-nullable": true }, "secret": { "type": "string", "description": "Provider secret key. Max length: 512 chars.", "default": null, - "x-example": "<SECRET>" + "x-example": "<SECRET>", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Provider status. Set to 'false' to disable new session creation.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -31058,6 +31200,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31084,7 +31227,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -31708,6 +31852,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -31734,7 +31879,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -32284,11 +32430,24 @@ "default": null, "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the site template.", + "description": "Type for the reference provided. Can be commit, branch, or tag", "default": null, - "x-example": "<VERSION>" + "x-example": "branch", + "enum": [ + "branch", + "commit", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "default": null, + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -32301,7 +32460,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -33273,13 +33433,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -33504,6 +33666,7 @@ "description": "An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -33702,6 +33865,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -34146,13 +34310,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -35796,6 +35962,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -35976,6 +36143,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -36248,7 +36416,8 @@ "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -36365,7 +36534,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36585,7 +36755,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36688,7 +36859,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -36805,7 +36977,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -36917,7 +37090,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -37044,7 +37218,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37148,19 +37323,22 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37270,13 +37448,15 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -37289,7 +37469,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37392,19 +37573,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37514,13 +37698,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -37533,7 +37719,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37636,7 +37823,8 @@ "type": "string", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -37753,7 +37941,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -37968,7 +38157,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38182,7 +38372,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38396,7 +38587,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38512,13 +38704,15 @@ "type": "string", "description": "Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -38640,7 +38834,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -38764,13 +38959,15 @@ "type": "integer", "description": "Maximum size of the string column.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -38873,7 +39070,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -38990,7 +39188,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -39275,13 +39474,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -39993,6 +40194,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40010,7 +40212,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40134,7 +40337,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -40238,7 +40442,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40333,7 +40538,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40566,6 +40772,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40574,7 +40781,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40676,6 +40884,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -40684,7 +40893,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40774,7 +40984,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -40974,13 +41185,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -41091,13 +41304,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -42915,13 +43130,15 @@ "type": "string", "description": "User email.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", "default": null, - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 8b972be590..e48f00475a 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -6620,6 +6620,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -6804,6 +6805,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -7082,7 +7084,8 @@ "type": "boolean", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -7201,7 +7204,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7425,7 +7429,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7530,7 +7535,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -7649,7 +7655,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7763,7 +7770,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -7892,7 +7900,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -7998,19 +8007,22 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8122,13 +8134,15 @@ "type": "number", "description": "Minimum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -8141,7 +8155,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8246,19 +8261,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8370,13 +8388,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -8389,7 +8409,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8494,7 +8515,8 @@ "type": "string", "description": "Default value. Cannot be set when attribute is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -8613,7 +8635,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -8832,7 +8855,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9050,7 +9074,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9268,7 +9293,8 @@ "type": "string", "description": "New attribute key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9386,13 +9412,15 @@ "type": "string", "description": "Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -9516,7 +9544,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -9642,13 +9671,15 @@ "type": "integer", "description": "Maximum size of the string attribute.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -9753,7 +9784,8 @@ "type": "string", "description": "Default value for attribute when not provided. Cannot be set when attribute is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -9872,7 +9904,8 @@ "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -10163,13 +10196,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Attribute Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -10445,6 +10480,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -10462,7 +10498,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10593,7 +10630,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -10699,7 +10737,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -10796,7 +10835,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11041,6 +11081,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11049,7 +11090,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -11157,6 +11199,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -11165,7 +11208,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11258,7 +11302,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11372,13 +11417,15 @@ "type": "number", "description": "Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -11492,13 +11539,15 @@ "type": "number", "description": "Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -12078,6 +12127,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12104,7 +12154,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -12493,6 +12544,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -12519,7 +12571,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -13118,11 +13171,24 @@ "default": null, "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the function template.", + "description": "Type for the reference provided. Can be commit, branch, or tag", "default": null, - "x-example": "<VERSION>" + "x-example": "commit", + "enum": [ + "commit", + "branch", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "default": null, + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -13135,7 +13201,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -13721,7 +13788,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": "<SCHEDULED_AT>" + "x-example": "<SCHEDULED_AT>", + "x-nullable": true } } } @@ -14163,13 +14231,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only functions can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -16331,7 +16401,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -16415,6 +16486,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16424,6 +16496,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16433,6 +16506,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16441,31 +16515,36 @@ "type": "string", "description": "Email Subject.", "default": null, - "x-example": "<SUBJECT>" + "x-example": "<SUBJECT>", + "x-nullable": true }, "content": { "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "html": { "type": "boolean", "description": "Is content of type HTML", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "cc": { "type": "array", "description": "Array of target IDs to be added as CC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16475,6 +16554,7 @@ "description": "Array of target IDs to be added as BCC.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16483,13 +16563,15 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "attachments": { "type": "array", "description": "Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16607,7 +16689,8 @@ "type": "object", "description": "Additional key-value pair data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", @@ -16661,7 +16744,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", @@ -16767,6 +16851,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16776,6 +16861,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16785,6 +16871,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -16793,85 +16880,99 @@ "type": "string", "description": "Title for push notification.", "default": null, - "x-example": "<TITLE>" + "x-example": "<TITLE>", + "x-nullable": true }, "body": { "type": "string", "description": "Body for push notification.", "default": null, - "x-example": "<BODY>" + "x-example": "<BODY>", + "x-nullable": true }, "data": { "type": "object", "description": "Additional Data for push notification.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "action": { "type": "string", "description": "Action for push notification.", "default": null, - "x-example": "<ACTION>" + "x-example": "<ACTION>", + "x-nullable": true }, "image": { "type": "string", "description": "Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.", "default": null, - "x-example": "<ID1:ID2>" + "x-example": "<ID1:ID2>", + "x-nullable": true }, "icon": { "type": "string", "description": "Icon for push notification. Available only for Android and Web platforms.", "default": null, - "x-example": "<ICON>" + "x-example": "<ICON>", + "x-nullable": true }, "sound": { "type": "string", "description": "Sound for push notification. Available only for Android and iOS platforms.", "default": null, - "x-example": "<SOUND>" + "x-example": "<SOUND>", + "x-nullable": true }, "color": { "type": "string", "description": "Color for push notification. Available only for Android platforms.", "default": null, - "x-example": "<COLOR>" + "x-example": "<COLOR>", + "x-nullable": true }, "tag": { "type": "string", "description": "Tag for push notification. Available only for Android platforms.", "default": null, - "x-example": "<TAG>" + "x-example": "<TAG>", + "x-nullable": true }, "badge": { "type": "integer", "description": "Badge for push notification. Available only for iOS platforms.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "contentAvailable": { "type": "boolean", "description": "If set to true, the notification will be delivered in the background. Available only for iOS Platform.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "critical": { "type": "boolean", "description": "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.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "priority": { "type": "string", @@ -16883,7 +16984,8 @@ "high" ], "x-enum-name": "MessagePriority", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true } } } @@ -17068,7 +17170,8 @@ "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -17219,6 +17322,7 @@ "description": "List of Topic IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17228,6 +17332,7 @@ "description": "List of User IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17237,6 +17342,7 @@ "description": "List of Targets IDs.", "default": null, "x-example": null, + "x-nullable": true, "items": { "type": "string" } @@ -17245,19 +17351,22 @@ "type": "string", "description": "Email Content.", "default": null, - "x-example": "<CONTENT>" + "x-example": "<CONTENT>", + "x-nullable": true }, "draft": { "type": "boolean", "description": "Is message a draft", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "scheduledAt": { "type": "string", "description": "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.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -17805,7 +17914,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -17963,7 +18073,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "authKey": { "type": "string", @@ -17993,7 +18104,8 @@ "type": "boolean", "description": "Use APNS sandbox environment.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -18139,13 +18251,15 @@ "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18295,13 +18409,15 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "serviceAccountJSON": { "type": "object", "description": "FCM service account JSON.", "default": {}, - "x-example": "{}" + "x-example": "{}", + "x-nullable": true } } } @@ -18395,7 +18511,8 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18425,7 +18542,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18525,13 +18643,15 @@ "type": "boolean", "description": "Set as EU region.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "enabled": { "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "fromName": { "type": "string", @@ -18655,7 +18775,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18743,7 +18864,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "templateId": { "type": "string", @@ -18873,7 +18995,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -18961,7 +19084,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19103,7 +19227,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19191,7 +19316,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -19462,7 +19588,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19639,7 +19766,8 @@ "type": "integer", "description": "SMTP port.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "username": { "type": "string", @@ -19670,7 +19798,8 @@ "type": "boolean", "description": "Enable SMTP AutoTLS feature.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "mailer": { "type": "string", @@ -19706,7 +19835,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } } } @@ -19806,7 +19936,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -19894,7 +20025,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "customerId": { "type": "string", @@ -20012,7 +20144,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20100,7 +20233,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "username": { "type": "string", @@ -20218,7 +20352,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20306,7 +20441,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "accountSid": { "type": "string", @@ -20424,7 +20560,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -20512,7 +20649,8 @@ "type": "boolean", "description": "Set as enabled.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "apiKey": { "type": "string", @@ -21120,13 +21258,15 @@ "type": "string", "description": "Topic Name.", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "subscribe": { "type": "array", "description": "An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https:\/\/appwrite.io\/docs\/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.", "default": null, "x-example": "[\"any\"]", + "x-nullable": true, "items": { "type": "string" } @@ -21845,6 +21985,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -21871,7 +22012,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22277,6 +22419,7 @@ "dart-3.3", "dart-3.5", "dart-3.8", + "dart-3.9", "dotnet-6.0", "dotnet-7.0", "dotnet-8.0", @@ -22303,7 +22446,8 @@ "flutter-3.24", "flutter-3.27", "flutter-3.29", - "flutter-3.32" + "flutter-3.32", + "flutter-3.35" ], "x-enum-name": null, "x-enum-keys": [] @@ -22859,11 +23003,24 @@ "default": null, "x-example": "<ROOT_DIRECTORY>" }, - "version": { + "type": { "type": "string", - "description": "Version (tag) for the repo linked to the site template.", + "description": "Type for the reference provided. Can be commit, branch, or tag", "default": null, - "x-example": "<VERSION>" + "x-example": "branch", + "enum": [ + "branch", + "commit", + "tag" + ], + "x-enum-name": null, + "x-enum-keys": [] + }, + "reference": { + "type": "string", + "description": "Reference value, can be a commit hash, branch name, or release tag", + "default": null, + "x-example": "<REFERENCE>" }, "activate": { "type": "boolean", @@ -22876,7 +23033,8 @@ "repository", "owner", "rootDirectory", - "version" + "type", + "reference" ] } } @@ -23782,13 +23940,15 @@ "type": "string", "description": "Variable value. Max length: 8192 chars.", "default": null, - "x-example": "<VALUE>" + "x-example": "<VALUE>", + "x-nullable": true }, "secret": { "type": "boolean", "description": "Secret variables can be updated or deleted, but only sites can read them during build and runtime.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true } }, "required": [ @@ -24016,6 +24176,7 @@ "description": "An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -24216,6 +24377,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -24669,13 +24831,15 @@ "type": "string", "description": "Name of the file", "default": null, - "x-example": "<NAME>" + "x-example": "<NAME>", + "x-nullable": true }, "permissions": { "type": "array", "description": "An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26103,6 +26267,7 @@ "description": "An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26285,6 +26450,7 @@ "description": "An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -26560,7 +26726,8 @@ "type": "boolean", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": false + "x-example": false, + "x-nullable": true }, "array": { "type": "boolean", @@ -26678,7 +26845,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -26900,7 +27068,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27004,7 +27173,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -27122,7 +27292,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27235,7 +27406,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -27363,7 +27535,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27468,19 +27641,22 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", "description": "Default value. Cannot be set when required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27591,13 +27767,15 @@ "type": "number", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "number", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "number", @@ -27610,7 +27788,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27714,19 +27893,22 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -27837,13 +28019,15 @@ "type": "integer", "description": "Minimum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "max": { "type": "integer", "description": "Maximum value", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "default": { "type": "integer", @@ -27856,7 +28040,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -27960,7 +28145,8 @@ "type": "string", "description": "Default value. Cannot be set when column is required.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "array": { "type": "boolean", @@ -28078,7 +28264,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28295,7 +28482,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28511,7 +28699,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28727,7 +28916,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -28844,13 +29034,15 @@ "type": "string", "description": "Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "twoWayKey": { "type": "string", "description": "Two Way Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "onDelete": { "type": "string", @@ -28973,7 +29165,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "<DEFAULT>" + "x-example": "<DEFAULT>", + "x-nullable": true }, "array": { "type": "boolean", @@ -29098,13 +29291,15 @@ "type": "integer", "description": "Maximum size of the string column.", "default": null, - "x-example": 1 + "x-example": 1, + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29208,7 +29403,8 @@ "type": "string", "description": "Default value for column when not provided. Cannot be set when column is required.", "default": null, - "x-example": "https:\/\/example.com" + "x-example": "https:\/\/example.com", + "x-nullable": true }, "array": { "type": "boolean", @@ -29326,7 +29522,8 @@ "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } }, "required": [ @@ -29614,13 +29811,15 @@ "setNull" ], "x-enum-name": "RelationMutate", - "x-enum-keys": [] + "x-enum-keys": [], + "x-nullable": true }, "newKey": { "type": "string", "description": "New Column Key.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true } } } @@ -30261,6 +30460,7 @@ "description": "An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30278,7 +30478,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30404,7 +30605,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } }, "required": [ @@ -30509,7 +30711,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30605,7 +30808,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30843,6 +31047,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30851,7 +31056,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -30955,6 +31161,7 @@ "description": "An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https:\/\/appwrite.io\/docs\/permissions).", "default": null, "x-example": "[\"read(\"any\")\"]", + "x-nullable": true, "items": { "type": "string" } @@ -30963,7 +31170,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31055,7 +31263,8 @@ "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31168,13 +31377,15 @@ "type": "number", "description": "Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -31287,13 +31498,15 @@ "type": "number", "description": "Maximum value for the column. If the current value is greater than this value, an error will be thrown.", "default": null, - "x-example": null + "x-example": null, + "x-nullable": true }, "transactionId": { "type": "string", "description": "Transaction ID for staging the operation.", "default": null, - "x-example": "<TRANSACTION_ID>" + "x-example": "<TRANSACTION_ID>", + "x-nullable": true } } } @@ -32870,13 +33083,15 @@ "type": "string", "description": "User email.", "default": null, - "x-example": "email@example.com" + "x-example": "email@example.com", + "x-nullable": true }, "phone": { "type": "string", "description": "Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.", "default": null, - "x-example": "+12065550100" + "x-example": "+12065550100", + "x-nullable": true }, "password": { "type": "string", diff --git a/app/config/storage/resource_limits.php b/app/config/storage/resource_limits.php index cfbcea5a47..43ed2b8b05 100644 --- a/app/config/storage/resource_limits.php +++ b/app/config/storage/resource_limits.php @@ -3,4 +3,6 @@ use Utopia\Image\Image; use Utopia\System\System; -Image::setResourceLimit('memory', intval(System::getEnv('_APP_IMAGES_RESOURCE_LIMIT_MEMORY', 1024*1024*64))); +if (\class_exists('Imagick')) { + Image::setResourceLimit('memory', intval(System::getEnv('_APP_IMAGES_RESOURCE_LIMIT_MEMORY', 1024*1024*64))); +} diff --git a/app/config/template-runtimes.php b/app/config/template-runtimes.php index d1bb1a5b6a..04eaba2c44 100644 --- a/app/config/template-runtimes.php +++ b/app/config/template-runtimes.php @@ -14,7 +14,7 @@ return [ ], 'DART' => [ 'name' => 'dart', - 'versions' => ['3.8', '3.5', '3.3', '3.1', '3.0', '2.19', '2.18', '2.17', '2.16'] + 'versions' => ['3.9', '3.8', '3.5', '3.3', '3.1', '3.0', '2.19', '2.18', '2.17', '2.16'] ], 'GO' => [ 'name' => 'go', @@ -38,6 +38,6 @@ return [ ], 'FLUTTER' => [ 'name' => 'flutter', - 'versions' => ['3.32', '3.24'] + 'versions' => ['3.35', '3.32', '3.24'] ], ]; diff --git a/app/config/templates/site.php b/app/config/templates/site.php index f2396b66db..c8bb019123 100644 --- a/app/config/templates/site.php +++ b/app/config/templates/site.php @@ -84,7 +84,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => '', 'buildCommand' => 'flutter build web', 'outputDirectory' => './build/web', - 'buildRuntime' => 'flutter-3.29', + 'buildRuntime' => 'flutter-3.35', 'adapter' => 'static', 'fallbackFile' => '', ], diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 9d1987591e..b6e1ebcc61 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -20,7 +20,7 @@ use Appwrite\Event\Messaging; use Appwrite\Event\StatsUsage; use Appwrite\Extend\Exception; use Appwrite\Hooks\Hooks; -use Appwrite\Network\Validator\Email; +use Appwrite\Network\Validator\Email as EmailValidator; use Appwrite\Network\Validator\Redirect; use Appwrite\OpenSSL\OpenSSL; use Appwrite\SDK\AuthType; @@ -57,6 +57,7 @@ use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\Query\Limit; use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\UID; +use Utopia\Emails\Email; use Utopia\Locale\Locale; use Utopia\Storage\Validator\FileName; use Utopia\System\System; @@ -191,10 +192,10 @@ function sendSessionAlert(Locale $locale, Document $user, Document $project, Doc ; -$createSession = function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents, Mail $queueForMails) { +$createSession = function (string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents, Mail $queueForMails, Authorization $authorization) { /** @var Utopia\Database\Document $user */ - $userFromRequest = Authorization::skip(fn () => $dbForProject->getDocument('users', $userId)); + $userFromRequest = $authorization->skip(fn () => $dbForProject->getDocument('users', $userId)); if ($userFromRequest->isEmpty()) { throw new Exception(Exception::USER_INVALID_TOKEN); @@ -240,7 +241,7 @@ $createSession = function (string $userId, string $secret, Request $request, Res $detector->getDevice() )); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $session = $dbForProject->createDocument('sessions', $session ->setAttribute('$permissions', [ @@ -249,7 +250,7 @@ $createSession = function (string $userId, string $secret, Request $request, Res Permission::delete(Role::user($user->getId())), ])); - Authorization::skip(fn () => $dbForProject->deleteDocument('tokens', $verifiedToken->getId())); + $authorization->skip(fn () => $dbForProject->deleteDocument('tokens', $verifiedToken->getId())); $dbForProject->purgeCachedDocument('users', $user->getId()); // Magic URL + Email OTP @@ -337,7 +338,7 @@ App::post('/v1/account') )) ->label('abuse-limit', 10) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'New user password. Must be between 8 and 256 chars.', false, ['project', 'passwordsDictionary']) ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('request') @@ -345,8 +346,9 @@ App::post('/v1/account') ->inject('user') ->inject('project') ->inject('dbForProject') + ->inject('authorization') ->inject('hooks') - ->action(function (string $userId, string $email, string $password, string $name, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Hooks $hooks) { + ->action(function (string $userId, string $email, string $password, string $name, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Authorization $authorization, Hooks $hooks) { $email = \strtolower($email); if ('console' === $project->getId()) { @@ -394,6 +396,13 @@ App::post('/v1/account') $passwordHistory = $project->getAttribute('auths', [])['passwordHistory'] ?? 0; $password = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); + + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + try { $userId = $userId == 'unique()' ? ID::unique() : $userId; $user->setAttributes([ @@ -422,11 +431,17 @@ App::post('/v1/account') 'authenticators' => null, 'search' => implode(' ', [$userId, $email, $name]), 'accessedAt' => DateTime::now(), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]); + $user->removeAttribute('$sequence'); - $user = Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $user = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); try { - $target = Authorization::skip(fn () => $dbForProject->createDocument('targets', new Document([ + $target = $authorization->skip(fn () => $dbForProject->createDocument('targets', new Document([ '$permissions' => [ Permission::read(Role::user($user->getId())), Permission::update(Role::user($user->getId())), @@ -452,9 +467,9 @@ App::post('/v1/account') throw new Exception(Exception::USER_ALREADY_EXISTS); } - Authorization::unsetRole(Role::guests()->toString()); - Authorization::setRole(Role::user($user->getId())->toString()); - Authorization::setRole(Role::users()->toString()); + $authorization->removeRole(Role::guests()->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::users()->toString()); $response ->setStatusCode(Response::STATUS_CODE_CREATED) @@ -903,7 +918,7 @@ App::post('/v1/account/sessions/email') )) ->label('abuse-limit', 10) ->label('abuse-key', 'url:{url},email:{param-email}') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password. Must be at least 8 chars.') ->inject('request') ->inject('response') @@ -915,7 +930,8 @@ App::post('/v1/account/sessions/email') ->inject('queueForEvents') ->inject('queueForMails') ->inject('hooks') - ->action(function (string $email, string $password, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents, Mail $queueForMails, Hooks $hooks) { + ->inject('authorization') + ->action(function (string $email, string $password, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Reader $geodb, Event $queueForEvents, Mail $queueForMails, Hooks $hooks, Authorization $authorization) { $email = \strtolower($email); $protocol = $request->getProtocol(); @@ -958,7 +974,7 @@ App::post('/v1/account/sessions/email') $detector->getDevice() )); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); // Re-hash if not using recommended algo if ($user->getAttribute('hash') !== Auth::DEFAULT_ALGO) { @@ -1050,7 +1066,8 @@ App::post('/v1/account/sessions/anonymous') ->inject('dbForProject') ->inject('geodb') ->inject('queueForEvents') - ->action(function (Request $request, Response $response, Locale $locale, Document $user, Document $project, Database $dbForProject, Reader $geodb, Event $queueForEvents) { + ->inject('authorization') + ->action(function (Request $request, Response $response, Locale $locale, Document $user, Document $project, Database $dbForProject, Reader $geodb, Event $queueForEvents, Authorization $authorization) { $protocol = $request->getProtocol(); if ('console' === $project->getId()) { @@ -1095,7 +1112,7 @@ App::post('/v1/account/sessions/anonymous') 'accessedAt' => DateTime::now(), ]); $user->removeAttribute('$sequence'); - Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $user = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); // Create session token $duration = $project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG; @@ -1121,7 +1138,7 @@ App::post('/v1/account/sessions/anonymous') $detector->getDevice() )); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $session = $dbForProject->createDocument('sessions', $session->setAttribute('$permissions', [ Permission::read(Role::user($user->getId())), @@ -1194,6 +1211,7 @@ App::post('/v1/account/sessions/token') ->inject('geodb') ->inject('queueForEvents') ->inject('queueForMails') + ->inject('authorization') ->action($createSession); App::get('/v1/account/sessions/oauth2/:provider') @@ -1386,7 +1404,8 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->inject('dbForProject') ->inject('geodb') ->inject('queueForEvents') - ->action(function (string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response, Document $project, array $platforms, Document $devKey, Document $user, Database $dbForProject, Reader $geodb, Event $queueForEvents) use ($oauthDefaultSuccess) { + ->inject('authorization') + ->action(function (string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response, Document $project, array $platforms, Document $devKey, Document $user, Database $dbForProject, Reader $geodb, Event $queueForEvents, Authorization $authorization) use ($oauthDefaultSuccess) { $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $port = $request->getPort(); $callbackBase = $protocol . '://' . $request->getHostname(); @@ -1598,6 +1617,12 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') $failureRedirect(Exception::GENERAL_BAD_REQUEST); /** Return a generic bad request to prevent exposing existing accounts */ } + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + try { $userId = ID::unique(); $user->setAttributes([ @@ -1625,9 +1650,15 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') 'authenticators' => null, 'search' => implode(' ', [$userId, $email, $name]), 'accessedAt' => DateTime::now(), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]); + $user->removeAttribute('$sequence'); - $userDoc = Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $userDoc = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); $dbForProject->createDocument('targets', new Document([ '$permissions' => [ Permission::read(Role::user($user->getId())), @@ -1646,8 +1677,8 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') } } - Authorization::setRole(Role::user($user->getId())->toString()); - Authorization::setRole(Role::users()->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::users()->toString()); if (false === $user->getAttribute('status')) { // Account is blocked $failureRedirect(Exception::USER_BLOCKED); // User is in status blocked @@ -1696,6 +1727,18 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') if (empty($user->getAttribute('email'))) { $user->setAttribute('email', $oauth2->getUserEmail($accessToken)); + + try { + $emailCanonical = new Email($user->getAttribute('email')); + } catch (Throwable) { + $emailCanonical = null; + } + + $user->setAttribute('emailCanonical', $emailCanonical?->getCanonical()); + $user->setAttribute('emailIsCanonical', $emailCanonical?->isCanonicalSupported()); + $user->setAttribute('emailIsCorporate', $emailCanonical?->isCorporate()); + $user->setAttribute('emailIsDisposable', $emailCanonical?->isDisposable()); + $user->setAttribute('emailIsFree', $emailCanonical?->isFree()); } if (empty($user->getAttribute('name'))) { @@ -1706,7 +1749,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') $dbForProject->updateDocument('users', $user->getId(), $user); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $state['success'] = URLParser::parse($state['success']); $query = URLParser::parseQuery($state['success']['query']); @@ -1728,7 +1771,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $token = $dbForProject->createDocument('tokens', $token ->setAttribute('$permissions', [ @@ -1944,7 +1987,7 @@ App::post('/v1/account/tokens/magic-url') ->label('abuse-limit', 60) ->label('abuse-key', ['url:{url},email:{param-email}', 'url:{url},ip:{ip}']) ->param('userId', '', new CustomId(), 'Unique 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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('url', '', fn ($platforms, $devKey) => $devKey->isEmpty() ? new Redirect($platforms) : new URL(), 'URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', true, ['platforms', 'devKey']) ->param('phrase', false, new Boolean(), 'Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.', true) ->inject('request') @@ -1955,7 +1998,8 @@ App::post('/v1/account/tokens/magic-url') ->inject('locale') ->inject('queueForEvents') ->inject('queueForMails') - ->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { + ->inject('authorization') + ->action(function (string $userId, string $email, string $url, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails, Authorization $authorization) { if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } @@ -1990,6 +2034,12 @@ App::post('/v1/account/tokens/magic-url') $userId = $userId === 'unique()' ? ID::unique() : $userId; + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + $user->setAttributes([ '$id' => $userId, '$permissions' => [ @@ -2014,10 +2064,15 @@ App::post('/v1/account/tokens/magic-url') 'authenticators' => null, 'search' => implode(' ', [$userId, $email]), 'accessedAt' => DateTime::now(), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]); $user->removeAttribute('$sequence'); - Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $user = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); } $tokenSecret = Auth::tokenGenerator(Auth::TOKEN_LENGTH_MAGIC_URL); @@ -2034,7 +2089,7 @@ App::post('/v1/account/tokens/magic-url') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $token = $dbForProject->createDocument('tokens', $token ->setAttribute('$permissions', [ @@ -2197,7 +2252,7 @@ App::post('/v1/account/tokens/email') ->label('abuse-limit', 10) ->label('abuse-key', ['url:{url},email:{param-email}', 'url:{url},ip:{ip}']) ->param('userId', '', new CustomId(), '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. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('phrase', false, new Boolean(), 'Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.', true) ->inject('request') ->inject('response') @@ -2207,7 +2262,8 @@ App::post('/v1/account/tokens/email') ->inject('locale') ->inject('queueForEvents') ->inject('queueForMails') - ->action(function (string $userId, string $email, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { + ->inject('authorization') + ->action(function (string $userId, string $email, bool $phrase, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails, Authorization $authorization) { if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP disabled'); } @@ -2240,6 +2296,12 @@ App::post('/v1/account/tokens/email') $userId = $userId === 'unique()' ? ID::unique() : $userId; + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + $user->setAttributes([ '$id' => $userId, '$permissions' => [ @@ -2262,12 +2324,17 @@ App::post('/v1/account/tokens/email') 'memberships' => null, 'search' => implode(' ', [$userId, $email]), 'accessedAt' => DateTime::now(), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]); $user->removeAttribute('$sequence'); - $user = Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $user = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); try { - $target = Authorization::skip(fn () => $dbForProject->createDocument('targets', new Document([ + $target = $authorization->skip(fn () => $dbForProject->createDocument('targets', new Document([ '$permissions' => [ Permission::read(Role::user($user->getId())), Permission::update(Role::user($user->getId())), @@ -2305,7 +2372,7 @@ App::post('/v1/account/tokens/email') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $token = $dbForProject->createDocument('tokens', $token ->setAttribute('$permissions', [ @@ -2486,6 +2553,7 @@ App::put('/v1/account/sessions/magic-url') ->inject('geodb') ->inject('queueForEvents') ->inject('queueForMails') + ->inject('authorization') ->action($createSession); App::put('/v1/account/sessions/phone') @@ -2527,6 +2595,7 @@ App::put('/v1/account/sessions/phone') ->inject('geodb') ->inject('queueForEvents') ->inject('queueForMails') + ->inject('authorization') ->action($createSession); App::post('/v1/account/tokens/phone') @@ -2567,7 +2636,8 @@ App::post('/v1/account/tokens/phone') ->inject('timelimit') ->inject('queueForStatsUsage') ->inject('plan') - ->action(function (string $userId, string $phone, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Locale $locale, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan) { + ->inject('authorization') + ->action(function (string $userId, string $phone, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Locale $locale, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan, Authorization $authorization) { if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } @@ -2609,12 +2679,17 @@ App::post('/v1/account/tokens/phone') 'memberships' => null, 'search' => implode(' ', [$userId, $phone]), 'accessedAt' => DateTime::now(), + 'emailCanonical' => null, + 'emailIsCanonical' => null, + 'emailIsCorporate' => null, + 'emailIsDisposable' => null, + 'emailIsFree' => null, ]); $user->removeAttribute('$sequence'); - Authorization::skip(fn () => $dbForProject->createDocument('users', $user)); + $user = $authorization->skip(fn () => $dbForProject->createDocument('users', $user)); try { - $target = Authorization::skip(fn () => $dbForProject->createDocument('targets', new Document([ + $target = $authorization->skip(fn () => $dbForProject->createDocument('targets', new Document([ '$permissions' => [ Permission::read(Role::user($user->getId())), Permission::update(Role::user($user->getId())), @@ -2660,7 +2735,7 @@ App::post('/v1/account/tokens/phone') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $token = $dbForProject->createDocument('tokens', $token ->setAttribute('$permissions', [ @@ -3037,7 +3112,7 @@ App::patch('/v1/account/email') ], contentType: ContentType::JSON )) - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password. Must be at least 8 chars.') ->inject('requestTimestamp') ->inject('response') @@ -3046,7 +3121,8 @@ App::patch('/v1/account/email') ->inject('queueForEvents') ->inject('project') ->inject('hooks') - ->action(function (string $email, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Document $project, Hooks $hooks) { + ->inject('authorization') + ->action(function (string $email, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Document $project, Hooks $hooks, Authorization $authorization) { // passwordUpdate will be empty if the user has never set a password $passwordUpdate = $user->getAttribute('passwordUpdate'); @@ -3072,9 +3148,20 @@ App::patch('/v1/account/email') throw new Exception(Exception::GENERAL_BAD_REQUEST); /** Return a generic bad request to prevent exposing existing accounts */ } + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + $user ->setAttribute('email', $email) ->setAttribute('emailVerification', false) // After this user needs to confirm mail again + ->setAttribute('emailCanonical', $emailCanonical?->getCanonical()) + ->setAttribute('emailIsCanonical', $emailCanonical?->isCanonicalSupported()) + ->setAttribute('emailIsCorporate', $emailCanonical?->isCorporate()) + ->setAttribute('emailIsDisposable', $emailCanonical?->isDisposable()) + ->setAttribute('emailIsFree', $emailCanonical?->isFree()) ; if (empty($passwordUpdate)) { @@ -3085,7 +3172,7 @@ App::patch('/v1/account/email') ->setAttribute('passwordUpdate', DateTime::now()); } - $target = Authorization::skip(fn () => $dbForProject->findOne('targets', [ + $target = $authorization->skip(fn () => $dbForProject->findOne('targets', [ Query::equal('identifier', [$email]), ])); @@ -3101,7 +3188,7 @@ App::patch('/v1/account/email') $oldTarget = $user->find('identifier', $oldEmail, 'targets'); if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) { - Authorization::skip(fn () => $dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $email))); + $authorization->skip(fn () => $dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $email))); } $dbForProject->purgeCachedDocument('users', $user->getId()); } catch (Duplicate) { @@ -3143,7 +3230,8 @@ App::patch('/v1/account/phone') ->inject('queueForEvents') ->inject('project') ->inject('hooks') - ->action(function (string $phone, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Document $project, Hooks $hooks) { + ->inject('authorization') + ->action(function (string $phone, string $password, ?\DateTime $requestTimestamp, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Document $project, Hooks $hooks, Authorization $authorization) { // passwordUpdate will be empty if the user has never set a password $passwordUpdate = $user->getAttribute('passwordUpdate'); @@ -3156,7 +3244,7 @@ App::patch('/v1/account/phone') $hooks->trigger('passwordValidator', [$dbForProject, $project, $password, &$user, false]); - $target = Authorization::skip(fn () => $dbForProject->findOne('targets', [ + $target = $authorization->skip(fn () => $dbForProject->findOne('targets', [ Query::equal('identifier', [$phone]), ])); @@ -3187,7 +3275,7 @@ App::patch('/v1/account/phone') $oldTarget = $user->find('identifier', $oldPhone, 'targets'); if ($oldTarget instanceof Document && !$oldTarget->isEmpty()) { - Authorization::skip(fn () => $dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $phone))); + $authorization->skip(fn () => $dbForProject->updateDocument('targets', $oldTarget->getId(), $oldTarget->setAttribute('identifier', $phone))); } $dbForProject->purgeCachedDocument('users', $user->getId()); } catch (Duplicate $th) { @@ -3311,7 +3399,7 @@ App::post('/v1/account/recovery') )) ->label('abuse-limit', 10) ->label('abuse-key', ['url:{url},email:{param-email}', 'url:{url},ip:{ip}']) - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('url', '', fn ($platforms, $devKey) => $devKey->isEmpty() ? new Redirect($platforms) : new URL(), 'URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['platforms', 'devKey']) ->inject('request') ->inject('response') @@ -3321,7 +3409,8 @@ App::post('/v1/account/recovery') ->inject('locale') ->inject('queueForMails') ->inject('queueForEvents') - ->action(function (string $email, string $url, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Mail $queueForMails, Event $queueForEvents) { + ->inject('authorization') + ->action(function (string $email, string $url, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Locale $locale, Mail $queueForMails, Event $queueForEvents, Authorization $authorization) { if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled'); @@ -3357,7 +3446,7 @@ App::post('/v1/account/recovery') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($profile->getId())->toString()); + $authorization->addRole(Role::user($profile->getId())->toString()); $recovery = $dbForProject->createDocument('tokens', $recovery ->setAttribute('$permissions', [ @@ -3499,7 +3588,8 @@ App::put('/v1/account/recovery') ->inject('project') ->inject('queueForEvents') ->inject('hooks') - ->action(function (string $userId, string $secret, string $password, Response $response, Document $user, Database $dbForProject, Document $project, Event $queueForEvents, Hooks $hooks) { + ->inject('authorization') + ->action(function (string $userId, string $secret, string $password, Response $response, Document $user, Database $dbForProject, Document $project, Event $queueForEvents, Hooks $hooks, Authorization $authorization) { $profile = $dbForProject->getDocument('users', $userId); if ($profile->isEmpty()) { @@ -3513,7 +3603,7 @@ App::put('/v1/account/recovery') throw new Exception(Exception::USER_INVALID_TOKEN); } - Authorization::setRole(Role::user($profile->getId())->toString()); + $authorization->addRole(Role::user($profile->getId())->toString()); $newPassword = Auth::passwordHash($password, Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); @@ -3611,7 +3701,8 @@ App::post('/v1/account/verifications/email') ->inject('locale') ->inject('queueForEvents') ->inject('queueForMails') - ->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails) { + ->inject('authorization') + ->action(function (string $url, Request $request, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Event $queueForEvents, Mail $queueForMails, Authorization $authorization) { if (empty(System::getEnv('_APP_SMTP_HOST'))) { throw new Exception(Exception::GENERAL_SMTP_DISABLED, 'SMTP Disabled'); @@ -3640,7 +3731,7 @@ App::post('/v1/account/verifications/email') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $verification = $dbForProject->createDocument('tokens', $verification ->setAttribute('$permissions', [ @@ -3823,9 +3914,10 @@ App::put('/v1/account/verifications/email') ->inject('user') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) { + ->inject('authorization') + ->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Authorization $authorization) { - $profile = Authorization::skip(fn () => $dbForProject->getDocument('users', $userId)); + $profile = $authorization->skip(fn () => $dbForProject->getDocument('users', $userId)); if ($profile->isEmpty()) { throw new Exception(Exception::USER_NOT_FOUND); @@ -3838,7 +3930,7 @@ App::put('/v1/account/verifications/email') throw new Exception(Exception::USER_INVALID_TOKEN); } - Authorization::setRole(Role::user($profile->getId())->toString()); + $authorization->addRole(Role::user($profile->getId())->toString()); $profile = $dbForProject->updateDocument('users', $profile->getId(), $profile->setAttribute('emailVerification', true)); @@ -3897,7 +3989,8 @@ App::post('/v1/account/verifications/phone') ->inject('timelimit') ->inject('queueForStatsUsage') ->inject('plan') - ->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Document $project, Locale $locale, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan) { + ->inject('authorization') + ->action(function (Request $request, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Messaging $queueForMessaging, Document $project, Locale $locale, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan, Authorization $authorization) { if (empty(System::getEnv('_APP_SMS_PROVIDER'))) { throw new Exception(Exception::GENERAL_PHONE_DISABLED, 'Phone provider not configured'); } @@ -3936,7 +4029,7 @@ App::post('/v1/account/verifications/phone') 'ip' => $request->getIP(), ]); - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $verification = $dbForProject->createDocument('tokens', $verification ->setAttribute('$permissions', [ @@ -4041,9 +4134,10 @@ App::put('/v1/account/verifications/phone') ->inject('user') ->inject('dbForProject') ->inject('queueForEvents') - ->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) { + ->inject('authorization') + ->action(function (string $userId, string $secret, Response $response, Document $user, Database $dbForProject, Event $queueForEvents, Authorization $authorization) { - $profile = Authorization::skip(fn () => $dbForProject->getDocument('users', $userId)); + $profile = $authorization->skip(fn () => $dbForProject->getDocument('users', $userId)); if ($profile->isEmpty()) { throw new Exception(Exception::USER_NOT_FOUND); @@ -4055,7 +4149,7 @@ App::put('/v1/account/verifications/phone') throw new Exception(Exception::USER_INVALID_TOKEN); } - Authorization::setRole(Role::user($profile->getId())->toString()); + $authorization->addRole(Role::user($profile->getId())->toString()); $profile = $dbForProject->updateDocument('users', $profile->getId(), $profile->setAttribute('phoneVerification', true)); @@ -5043,12 +5137,13 @@ App::post('/v1/account/targets/push') ->inject('request') ->inject('response') ->inject('dbForProject') - ->action(function (string $targetId, string $identifier, string $providerId, Event $queueForEvents, Document $user, Request $request, Response $response, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $targetId, string $identifier, string $providerId, Event $queueForEvents, Document $user, Request $request, Response $response, Database $dbForProject, Authorization $authorization) { $targetId = $targetId == 'unique()' ? ID::unique() : $targetId; - $provider = Authorization::skip(fn () => $dbForProject->getDocument('providers', $providerId)); + $provider = $authorization->skip(fn () => $dbForProject->getDocument('providers', $providerId)); - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $targetId)); + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $targetId)); if (!$target->isEmpty()) { throw new Exception(Exception::USER_TARGET_ALREADY_EXISTS); @@ -5123,9 +5218,10 @@ App::put('/v1/account/targets/:targetId/push') ->inject('request') ->inject('response') ->inject('dbForProject') - ->action(function (string $targetId, string $identifier, Event $queueForEvents, Document $user, Request $request, Response $response, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $targetId, string $identifier, Event $queueForEvents, Document $user, Request $request, Response $response, Database $dbForProject, Authorization $authorization) { - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $targetId)); + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $targetId)); if ($target->isEmpty()) { throw new Exception(Exception::USER_TARGET_NOT_FOUND); @@ -5188,8 +5284,9 @@ App::delete('/v1/account/targets/:targetId/push') ->inject('request') ->inject('response') ->inject('dbForProject') - ->action(function (string $targetId, Event $queueForEvents, Delete $queueForDeletes, Document $user, Request $request, Response $response, Database $dbForProject) { - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $targetId)); + ->inject('authorization') + ->action(function (string $targetId, Event $queueForEvents, Delete $queueForDeletes, Document $user, Request $request, Response $response, Database $dbForProject, Authorization $authorization) { + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $targetId)); if ($target->isEmpty()) { throw new Exception(Exception::USER_TARGET_NOT_FOUND); diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index d0cb3e554c..544e22a0fa 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -70,9 +70,9 @@ $avatarCallback = function (string $type, string $code, int $width, int $height, unset($image); }; -$getUserGitHub = function (string $userId, Document $project, Database $dbForProject, Database $dbForPlatform, ?Logger $logger) { +$getUserGitHub = function (string $userId, Document $project, Database $dbForProject, Database $dbForPlatform, Authorization $authorization, ?Logger $logger) { try { - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); $sessions = $user->getAttribute('sessions', []); @@ -123,7 +123,7 @@ $getUserGitHub = function (string $userId, Document $project, Database $dbForPro ->setAttribute('providerRefreshToken', $refreshToken) ->setAttribute('providerAccessTokenExpiry', DateTime::addSeconds(new \DateTime(), (int)$oauth2->getAccessTokenExpiry(''))); - Authorization::skip(fn () => $dbForProject->updateDocument('sessions', $gitHubSession->getId(), $gitHubSession)); + $authorization->skip(fn () => $dbForProject->updateDocument('sessions', $gitHubSession->getId(), $gitHubSession)); $dbForProject->purgeCachedDocument('users', $user->getId()); } catch (Throwable $err) { @@ -131,7 +131,7 @@ $getUserGitHub = function (string $userId, Document $project, Database $dbForPro do { $previousAccessToken = $gitHubSession->getAttribute('providerAccessToken'); - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); $sessions = $user->getAttribute('sessions', []); $gitHubSession = new Document(); @@ -841,8 +841,9 @@ App::get('/v1/cards/cloud') ->inject('contributors') ->inject('employees') ->inject('logger') - ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger) use ($getUserGitHub) { - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + ->inject('authorization') + ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger, Authorization $authorization) use ($getUserGitHub) { + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); if ($user->isEmpty() && empty($mock)) { throw new Exception(Exception::USER_NOT_FOUND); @@ -853,7 +854,7 @@ App::get('/v1/cards/cloud') $email = $user->getAttribute('email', ''); $createdAt = new \DateTime($user->getCreatedAt()); - $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger); + $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization); $githubName = $gitHub['name'] ?? ''; $githubId = $gitHub['id'] ?? ''; @@ -1048,8 +1049,9 @@ App::get('/v1/cards/cloud-back') ->inject('contributors') ->inject('employees') ->inject('logger') - ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger) use ($getUserGitHub) { - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + ->inject('authorization') + ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger, Authorization $authorization) use ($getUserGitHub) { + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); if ($user->isEmpty() && empty($mock)) { throw new Exception(Exception::USER_NOT_FOUND); @@ -1059,7 +1061,7 @@ App::get('/v1/cards/cloud-back') $userId = $user->getId(); $email = $user->getAttribute('email', ''); - $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger); + $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization); $githubId = $gitHub['id'] ?? ''; $isHero = \array_key_exists($email, $heroes); @@ -1126,8 +1128,9 @@ App::get('/v1/cards/cloud-og') ->inject('contributors') ->inject('employees') ->inject('logger') - ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger) use ($getUserGitHub) { - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + ->inject('authorization') + ->action(function (string $userId, string $mock, int $width, int $height, Document $user, Document $project, Database $dbForProject, Database $dbForPlatform, Response $response, array $heroes, array $contributors, array $employees, ?Logger $logger, Authorization $authorization) use ($getUserGitHub) { + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); if ($user->isEmpty() && empty($mock)) { throw new Exception(Exception::USER_NOT_FOUND); @@ -1142,7 +1145,7 @@ App::get('/v1/cards/cloud-og') $email = $user->getAttribute('email', ''); $createdAt = new \DateTime($user->getCreatedAt()); - $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger); + $gitHub = $getUserGitHub($user->getId(), $project, $dbForProject, $dbForPlatform, $logger, $authorization); $githubName = $gitHub['name'] ?? ''; $githubId = $gitHub['id'] ?? ''; diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 482b38d698..d0480225da 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -28,11 +28,12 @@ use Utopia\Validator\Text; App::init() ->groups(['graphql']) ->inject('project') - ->action(function (Document $project) { + ->inject('authorization') + ->action(function (Document $project, Authorization $authorization) { if ( array_key_exists('graphql', $project->getAttribute('apis', [])) && !$project->getAttribute('apis', [])['graphql'] - && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles())) + && !(Auth::isPrivilegedUser($authorization->getRoles()) || Auth::isAppUser($authorization->getRoles())) ) { throw new AppwriteException(AppwriteException::GENERAL_API_DISABLED); } diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 5193d0b30f..dbbc667c94 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -36,6 +36,7 @@ use Utopia\Database\Exception\Query as QueryException; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\Datetime as DatetimeValidator; use Utopia\Database\Validator\Queries; use Utopia\Database\Validator\Query\Cursor; @@ -49,6 +50,7 @@ use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\Integer; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -80,12 +82,12 @@ App::post('/v1/messaging/providers/mailgun') ->param('name', '', new Text(128), 'Provider name.') ->param('apiKey', '', new Text(0), 'Mailgun API Key.', true) ->param('domain', '', new Text(0), 'Mailgun Domain.', true) - ->param('isEuRegion', null, new Boolean(), 'Set as EU region.', true) + ->param('isEuRegion', null, new Nullable(new Boolean()), 'Set as EU region.', true) ->param('fromName', '', new Text(128, 0), 'Sender Name.', true) ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128, 0), 'Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well.', true) ->param('replyToEmail', '', new Email(), 'Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -177,7 +179,7 @@ App::post('/v1/messaging/providers/sendgrid') ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128, 0), 'Name set in the reply to field for the mail. Default value is sender name.', true) ->param('replyToEmail', '', new Email(), 'Email set in the reply to field for the mail. Default value is sender email.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -259,7 +261,7 @@ App::post('/v1/messaging/providers/resend') ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128, 0), 'Name set in the reply to field for the mail. Default value is sender name.', true) ->param('replyToEmail', '', new Email(), 'Email set in the reply to field for the mail. Default value is sender email.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -366,7 +368,7 @@ App::post('/v1/messaging/providers/smtp') ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128, 0), 'Name set in the reply to field for the mail. Default value is sender name.', true) ->param('replyToEmail', '', new Email(), 'Email set in the reply to field for the mail. Default value is sender email.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -453,7 +455,7 @@ App::post('/v1/messaging/providers/msg91') ->param('templateId', '', new Text(0), 'Msg91 template ID', true) ->param('senderId', '', new Text(0), 'Msg91 sender ID.', true) ->param('authKey', '', new Text(0), 'Msg91 auth key.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -536,7 +538,7 @@ App::post('/v1/messaging/providers/telesign') ->param('from', '', new Phone(), 'Sender Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('customerId', '', new Text(0), 'Telesign customer ID.', true) ->param('apiKey', '', new Text(0), 'Telesign API key.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -620,7 +622,7 @@ App::post('/v1/messaging/providers/textmagic') ->param('from', '', new Phone(), 'Sender Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('username', '', new Text(0), 'Textmagic username.', true) ->param('apiKey', '', new Text(0), 'Textmagic apiKey.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -704,7 +706,7 @@ App::post('/v1/messaging/providers/twilio') ->param('from', '', new Phone(), 'Sender Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('accountSid', '', new Text(0), 'Twilio account secret ID.', true) ->param('authToken', '', new Text(0), 'Twilio authentication token.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -788,7 +790,7 @@ App::post('/v1/messaging/providers/vonage') ->param('from', '', new Phone(), 'Sender Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('apiKey', '', new Text(0), 'Vonage API key.', true) ->param('apiSecret', '', new Text(0), 'Vonage API secret.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -888,8 +890,8 @@ App::post('/v1/messaging/providers/fcm') ]) ->param('providerId', '', new CustomId(), 'Provider 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.') ->param('name', '', new Text(128), 'Provider name.') - ->param('serviceAccountJSON', null, new JSON(), 'FCM service account JSON.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('serviceAccountJSON', null, new Nullable(new JSON()), 'FCM service account JSON.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -982,7 +984,7 @@ App::post('/v1/messaging/providers/apns') ->param('teamId', '', new Text(0), 'APNS team ID.', true) ->param('bundleId', '', new Text(0), 'APNS bundle ID.', true) ->param('sandbox', false, new Boolean(), 'Use APNS sandbox environment.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -1069,8 +1071,9 @@ App::get('/v1/messaging/providers') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Response $response) { + ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Authorization $authorization, Response $response) { try { $queries = Query::parseQueries($queries); } catch (QueryException $e) { @@ -1096,7 +1099,7 @@ App::get('/v1/messaging/providers') } $providerId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('providers', $providerId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('providers', $providerId)); if ($cursorDocument->isEmpty()) { throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Provider '{$providerId}' for the 'cursor' value not found."); @@ -1270,8 +1273,8 @@ App::patch('/v1/messaging/providers/mailgun/:providerId') ->param('name', '', new Text(128), 'Provider name.', true) ->param('apiKey', '', new Text(0), 'Mailgun API Key.', true) ->param('domain', '', new Text(0), 'Mailgun Domain.', true) - ->param('isEuRegion', null, new Boolean(), 'Set as EU region.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('isEuRegion', null, new Nullable(new Boolean()), 'Set as EU region.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('fromName', '', new Text(128), 'Sender Name.', true) ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128), 'Name set in the reply to field for the mail. Default value is sender name.', true) @@ -1381,7 +1384,7 @@ App::patch('/v1/messaging/providers/sendgrid/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('apiKey', '', new Text(0), 'Sendgrid API key.', true) ->param('fromName', '', new Text(128), 'Sender Name.', true) ->param('fromEmail', '', new Email(), 'Sender email address.', true) @@ -1479,7 +1482,7 @@ App::patch('/v1/messaging/providers/resend/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('apiKey', '', new Text(0), 'Resend API key.', true) ->param('fromName', '', new Text(128), 'Sender Name.', true) ->param('fromEmail', '', new Email(), 'Sender email address.', true) @@ -1597,17 +1600,17 @@ App::patch('/v1/messaging/providers/smtp/:providerId') ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) ->param('host', '', new Text(0), 'SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order.', true) - ->param('port', null, 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('password', '', new Text(0), 'Authentication password.', true) ->param('encryption', '', new WhiteList(['none', 'ssl', 'tls']), 'Encryption type. Can be \'ssl\' or \'tls\'', true) - ->param('autoTLS', null, 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('fromName', '', new Text(128), 'Sender Name.', true) ->param('fromEmail', '', new Email(), 'Sender email address.', true) ->param('replyToName', '', new Text(128), 'Name set in the Reply To field for the mail. Default value is Sender Name.', true) ->param('replyToEmail', '', new Text(128), 'Email set in the Reply To field for the mail. Default value is Sender Email.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -1725,7 +1728,7 @@ App::patch('/v1/messaging/providers/msg91/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('templateId', '', new Text(0), 'Msg91 template ID.', true) ->param('senderId', '', new Text(0), 'Msg91 sender ID.', true) ->param('authKey', '', new Text(0), 'Msg91 auth key.', true) @@ -1812,7 +1815,7 @@ App::patch('/v1/messaging/providers/telesign/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('customerId', '', new Text(0), 'Telesign customer ID.', true) ->param('apiKey', '', new Text(0), 'Telesign API key.', true) ->param('from', '', new Text(256), 'Sender number.', true) @@ -1901,7 +1904,7 @@ App::patch('/v1/messaging/providers/textmagic/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('username', '', new Text(0), 'Textmagic username.', true) ->param('apiKey', '', new Text(0), 'Textmagic apiKey.', true) ->param('from', '', new Text(256), 'Sender number.', true) @@ -1990,7 +1993,7 @@ App::patch('/v1/messaging/providers/twilio/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('accountSid', '', new Text(0), 'Twilio account secret ID.', true) ->param('authToken', '', new Text(0), 'Twilio authentication token.', true) ->param('from', '', new Text(256), 'Sender number.', true) @@ -2079,7 +2082,7 @@ App::patch('/v1/messaging/providers/vonage/:providerId') )) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('apiKey', '', new Text(0), 'Vonage API key.', true) ->param('apiSecret', '', new Text(0), 'Vonage API secret.', true) ->param('from', '', new Text(256), 'Sender number.', true) @@ -2187,8 +2190,8 @@ App::patch('/v1/messaging/providers/fcm/:providerId') ]) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) - ->param('serviceAccountJSON', null, new JSON(), 'FCM service account JSON.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) + ->param('serviceAccountJSON', null, new Nullable(new JSON()), 'FCM service account JSON.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -2282,12 +2285,12 @@ App::patch('/v1/messaging/providers/apns/:providerId') ]) ->param('providerId', '', new UID(), 'Provider ID.') ->param('name', '', new Text(128), 'Provider name.', true) - ->param('enabled', null, new Boolean(), 'Set as enabled.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Set as enabled.', true) ->param('authKey', '', new Text(0), 'APNS authentication key.', true) ->param('authKeyId', '', new Text(0), 'APNS authentication key ID.', true) ->param('teamId', '', new Text(0), 'APNS team ID.', true) ->param('bundleId', '', new Text(0), 'APNS bundle ID.', true) - ->param('sandbox', null, new Boolean(), 'Use APNS sandbox environment.', true) + ->param('sandbox', null, new Nullable(new Boolean()), 'Use APNS sandbox environment.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -2476,8 +2479,9 @@ App::get('/v1/messaging/topics') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Response $response) { + ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Authorization $authorization, Response $response) { try { $queries = Query::parseQueries($queries); } catch (QueryException $e) { @@ -2503,7 +2507,7 @@ App::get('/v1/messaging/topics') } $topicId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('topics', $topicId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId)); if ($cursorDocument->isEmpty()) { throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Topic '{$topicId}' for the 'cursor' value not found."); @@ -2676,8 +2680,8 @@ App::patch('/v1/messaging/topics/:topicId') ] )) ->param('topicId', '', new UID(), 'Topic ID.') - ->param('name', null, new Text(128), 'Topic Name.', true) - ->param('subscribe', null, new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [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('name', null, new Nullable(new Text(128)), 'Topic Name.', true) + ->param('subscribe', null, new Nullable(new Roles(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [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) ->inject('queueForEvents') ->inject('dbForProject') ->inject('response') @@ -2779,29 +2783,27 @@ App::post('/v1/messaging/topics/:topicId/subscribers') ->param('targetId', '', new UID(), 'Target ID. The target ID to link to the specified Topic ID.') ->inject('queueForEvents') ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (string $subscriberId, string $topicId, string $targetId, Event $queueForEvents, Database $dbForProject, Response $response) { + ->action(function (string $subscriberId, string $topicId, string $targetId, Event $queueForEvents, Database $dbForProject, Authorization $authorization, Response $response) { $subscriberId = $subscriberId == 'unique()' ? ID::unique() : $subscriberId; - $topic = Authorization::skip(fn () => $dbForProject->getDocument('topics', $topicId)); + $topic = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId)); if ($topic->isEmpty()) { throw new Exception(Exception::TOPIC_NOT_FOUND); } - - $validator = new Authorization('subscribe'); - - if (!$validator->isValid($topic->getAttribute('subscribe'))) { - throw new Exception(Exception::USER_UNAUTHORIZED, $validator->getDescription()); + if (!$authorization->isValid(new Input('subscribe', $topic->getAttribute('subscribe')))) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $targetId)); + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $targetId)); if ($target->isEmpty()) { throw new Exception(Exception::USER_TARGET_NOT_FOUND); } - $user = Authorization::skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); + $user = $authorization->skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); $subscriber = new Document([ '$id' => $subscriberId, @@ -2834,7 +2836,7 @@ App::post('/v1/messaging/topics/:topicId/subscribers') default => throw new Exception(Exception::TARGET_PROVIDER_INVALID_TYPE), }; - Authorization::skip(fn () => $dbForProject->increaseDocumentAttribute( + $authorization->skip(fn () => $dbForProject->increaseDocumentAttribute( 'topics', $topicId, $totalAttribute, @@ -2879,8 +2881,9 @@ App::get('/v1/messaging/topics/:topicId/subscribers') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (string $topicId, array $queries, string $search, bool $includeTotal, Database $dbForProject, Response $response) { + ->action(function (string $topicId, array $queries, string $search, bool $includeTotal, Database $dbForProject, Authorization $authorization, Response $response) { try { $queries = Query::parseQueries($queries); } catch (QueryException $e) { @@ -2891,7 +2894,7 @@ App::get('/v1/messaging/topics/:topicId/subscribers') $queries[] = Query::search('search', $search); } - $topic = Authorization::skip(fn () => $dbForProject->getDocument('topics', $topicId)); + $topic = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId)); if ($topic->isEmpty()) { throw new Exception(Exception::TOPIC_NOT_FOUND); @@ -2914,7 +2917,7 @@ App::get('/v1/messaging/topics/:topicId/subscribers') } $subscriberId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('subscribers', $subscriberId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('subscribers', $subscriberId)); if ($cursorDocument->isEmpty()) { throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Subscriber '{$subscriberId}' for the 'cursor' value not found."); @@ -2928,10 +2931,10 @@ App::get('/v1/messaging/topics/:topicId/subscribers') throw new Exception(Exception::DATABASE_QUERY_ORDER_NULL, "The order attribute '{$e->getAttribute()}' had a null value. Cursor pagination requires all documents order attribute values are non-null."); } - $subscribers = batch(\array_map(function (Document $subscriber) use ($dbForProject) { - return function () use ($subscriber, $dbForProject) { - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $subscriber->getAttribute('targetId'))); - $user = Authorization::skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); + $subscribers = batch(\array_map(function (Document $subscriber) use ($dbForProject, $authorization) { + return function () use ($subscriber, $dbForProject, $authorization) { + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $subscriber->getAttribute('targetId'))); + $user = $authorization->skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); return $subscriber ->setAttribute('target', $target) @@ -3066,9 +3069,10 @@ App::get('/v1/messaging/topics/:topicId/subscribers/:subscriberId') ->param('topicId', '', new UID(), 'Topic ID. The topic ID subscribed to.') ->param('subscriberId', '', new UID(), 'Subscriber ID.') ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (string $topicId, string $subscriberId, Database $dbForProject, Response $response) { - $topic = Authorization::skip(fn () => $dbForProject->getDocument('topics', $topicId)); + ->action(function (string $topicId, string $subscriberId, Database $dbForProject, Authorization $authorization, Response $response) { + $topic = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId)); if ($topic->isEmpty()) { throw new Exception(Exception::TOPIC_NOT_FOUND); @@ -3080,8 +3084,8 @@ App::get('/v1/messaging/topics/:topicId/subscribers/:subscriberId') throw new Exception(Exception::SUBSCRIBER_NOT_FOUND); } - $target = Authorization::skip(fn () => $dbForProject->getDocument('targets', $subscriber->getAttribute('targetId'))); - $user = Authorization::skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); + $target = $authorization->skip(fn () => $dbForProject->getDocument('targets', $subscriber->getAttribute('targetId'))); + $user = $authorization->skip(fn () => $dbForProject->getDocument('users', $target->getAttribute('userId'))); $subscriber ->setAttribute('target', $target) @@ -3117,9 +3121,10 @@ App::delete('/v1/messaging/topics/:topicId/subscribers/:subscriberId') ->param('subscriberId', '', new UID(), 'Subscriber ID.') ->inject('queueForEvents') ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (string $topicId, string $subscriberId, Event $queueForEvents, Database $dbForProject, Response $response) { - $topic = Authorization::skip(fn () => $dbForProject->getDocument('topics', $topicId)); + ->action(function (string $topicId, string $subscriberId, Event $queueForEvents, Database $dbForProject, Authorization $authorization, Response $response) { + $topic = $authorization->skip(fn () => $dbForProject->getDocument('topics', $topicId)); if ($topic->isEmpty()) { throw new Exception(Exception::TOPIC_NOT_FOUND); @@ -3142,7 +3147,7 @@ App::delete('/v1/messaging/topics/:topicId/subscribers/:subscriberId') default => throw new Exception(Exception::TARGET_PROVIDER_INVALID_TYPE), }; - Authorization::skip(fn () => $dbForProject->decreaseDocumentAttribute( + $authorization->skip(fn () => $dbForProject->decreaseDocumentAttribute( 'topics', $topicId, $totalAttribute, @@ -3190,7 +3195,7 @@ App::post('/v1/messaging/messages/email') ->param('attachments', [], new ArrayList(new CompoundUID()), 'Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) ->param('html', false, new Boolean(), 'Is content of type HTML', true) - ->param('scheduledAt', null, 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) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForPlatform') @@ -3363,7 +3368,7 @@ App::post('/v1/messaging/messages/sms') ->param('users', [], new ArrayList(new UID()), 'List of User IDs.', true) ->param('targets', [], new ArrayList(new UID()), 'List of Targets IDs.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, 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) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForPlatform') @@ -3486,7 +3491,7 @@ App::post('/v1/messaging/messages/push') ->param('topics', [], new ArrayList(new UID()), 'List of Topic IDs.', true) ->param('users', [], new ArrayList(new UID()), 'List of User IDs.', true) ->param('targets', [], new ArrayList(new UID()), 'List of Targets IDs.', true) - ->param('data', null, new JSON(), 'Additional key-value pair data for push notification.', true) + ->param('data', null, new Nullable(new JSON()), 'Additional key-value pair data for push notification.', true) ->param('action', '', new Text(256), 'Action for push notification.', true) ->param('image', '', new CompoundUID(), 'Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.', true) ->param('icon', '', new Text(256), 'Icon for push notification. Available only for Android and Web Platform.', true) @@ -3495,7 +3500,7 @@ App::post('/v1/messaging/messages/push') ->param('tag', '', new Text(256), 'Tag for push notification. Available only for Android Platform.', true) ->param('badge', -1, new Integer(), 'Badge for push notification. Available only for iOS Platform.', true) ->param('draft', false, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, 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('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) @@ -3699,8 +3704,9 @@ App::get('/v1/messaging/messages') ->param('search', '', new Text(256), 'Search term to filter your list results. Max length: 256 chars.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('dbForProject') + ->inject('authorization') ->inject('response') - ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Response $response) { + ->action(function (array $queries, string $search, bool $includeTotal, Database $dbForProject, Authorization $authorization, Response $response) { try { $queries = Query::parseQueries($queries); } catch (QueryException $e) { @@ -3726,7 +3732,7 @@ App::get('/v1/messaging/messages') } $messageId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('messages', $messageId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('messages', $messageId)); if ($cursorDocument->isEmpty()) { throw new Exception(Exception::GENERAL_CURSOR_NOT_FOUND, "Message '{$messageId}' for the 'cursor' value not found."); @@ -3981,17 +3987,17 @@ App::patch('/v1/messaging/messages/email/:messageId') ] )) ->param('messageId', '', new UID(), 'Message ID.') - ->param('topics', null, new ArrayList(new UID()), 'List of Topic IDs.', true) - ->param('users', null, new ArrayList(new UID()), 'List of User IDs.', true) - ->param('targets', null, new ArrayList(new UID()), 'List of Targets IDs.', true) - ->param('subject', null, new Text(998), 'Email Subject.', true) - ->param('content', null, new Text(64230), 'Email Content.', true) - ->param('draft', null, new Boolean(), 'Is message a draft', true) - ->param('html', null, new Boolean(), 'Is content of type HTML', true) - ->param('cc', null, new ArrayList(new UID()), 'Array of target IDs to be added as CC.', true) - ->param('bcc', null, new ArrayList(new UID()), 'Array of target IDs to be added as BCC.', true) - ->param('scheduledAt', null, 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('attachments', null, new ArrayList(new CompoundUID()), 'Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.', true) + ->param('topics', null, new Nullable(new ArrayList(new UID())), 'List of Topic IDs.', true) + ->param('users', null, new Nullable(new ArrayList(new UID())), 'List of User IDs.', true) + ->param('targets', null, new Nullable(new ArrayList(new UID())), 'List of Targets IDs.', true) + ->param('subject', null, new Nullable(new Text(998)), 'Email Subject.', true) + ->param('content', null, new Nullable(new Text(64230)), 'Email Content.', true) + ->param('draft', null, new Nullable(new Boolean()), 'Is message a draft', true) + ->param('html', null, new Nullable(new Boolean()), 'Is content of type HTML', true) + ->param('cc', null, new Nullable(new ArrayList(new UID())), 'Array of target IDs to be added as CC.', true) + ->param('bcc', null, new Nullable(new ArrayList(new UID())), 'Array of target IDs to be added as BCC.', 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('attachments', null, new Nullable(new ArrayList(new CompoundUID())), 'Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.', true) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForPlatform') @@ -4207,12 +4213,12 @@ App::patch('/v1/messaging/messages/sms/:messageId') ) ]) ->param('messageId', '', new UID(), 'Message ID.') - ->param('topics', null, new ArrayList(new UID()), 'List of Topic IDs.', true) - ->param('users', null, new ArrayList(new UID()), 'List of User IDs.', true) - ->param('targets', null, new ArrayList(new UID()), 'List of Targets IDs.', true) - ->param('content', null, new Text(64230), 'Email Content.', true) - ->param('draft', null, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, 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('topics', null, new Nullable(new ArrayList(new UID())), 'List of Topic IDs.', true) + ->param('users', null, new Nullable(new ArrayList(new UID())), 'List of User IDs.', true) + ->param('targets', null, new Nullable(new ArrayList(new UID())), 'List of Targets IDs.', true) + ->param('content', null, new Nullable(new Text(64230)), 'Email Content.', true) + ->param('draft', null, new Nullable(new Boolean()), 'Is message a draft', 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) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForPlatform') @@ -4369,24 +4375,24 @@ App::patch('/v1/messaging/messages/push/:messageId') ] )) ->param('messageId', '', new UID(), 'Message ID.') - ->param('topics', null, new ArrayList(new UID()), 'List of Topic IDs.', true) - ->param('users', null, new ArrayList(new UID()), 'List of User IDs.', true) - ->param('targets', null, new ArrayList(new UID()), 'List of Targets IDs.', true) - ->param('title', null, new Text(256), 'Title for push notification.', true) - ->param('body', null, new Text(64230), 'Body for push notification.', true) - ->param('data', null, new JSON(), 'Additional Data for push notification.', true) - ->param('action', null, new Text(256), 'Action for push notification.', true) - ->param('image', null, new CompoundUID(), 'Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.', true) - ->param('icon', null, new Text(256), 'Icon for push notification. Available only for Android and Web platforms.', true) - ->param('sound', null, new Text(256), 'Sound for push notification. Available only for Android and iOS platforms.', true) - ->param('color', null, new Text(256), 'Color for push notification. Available only for Android platforms.', true) - ->param('tag', null, new Text(256), 'Tag for push notification. Available only for Android platforms.', true) - ->param('badge', null, new Integer(), 'Badge for push notification. Available only for iOS platforms.', true) - ->param('draft', null, new Boolean(), 'Is message a draft', true) - ->param('scheduledAt', null, 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 Boolean(), 'If set to true, the notification will be delivered in the background. Available only for iOS Platform.', true) - ->param('critical', null, 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 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('topics', null, new Nullable(new ArrayList(new UID())), 'List of Topic IDs.', true) + ->param('users', null, new Nullable(new ArrayList(new UID())), 'List of User IDs.', true) + ->param('targets', null, new Nullable(new ArrayList(new UID())), 'List of Targets IDs.', true) + ->param('title', null, new Nullable(new Text(256)), 'Title for push notification.', true) + ->param('body', null, new Nullable(new Text(64230)), 'Body for push notification.', true) + ->param('data', null, new Nullable(new JSON()), 'Additional Data for push notification.', true) + ->param('action', null, new Nullable(new Text(256)), 'Action for push notification.', true) + ->param('image', null, new Nullable(new CompoundUID()), 'Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.', true) + ->param('icon', null, new Nullable(new Text(256)), 'Icon for push notification. Available only for Android and Web platforms.', true) + ->param('sound', null, new Nullable(new Text(256)), 'Sound for push notification. Available only for Android and iOS platforms.', true) + ->param('color', null, new Nullable(new Text(256)), 'Color for push notification. Available only for Android platforms.', true) + ->param('tag', null, new Nullable(new Text(256)), 'Tag for push notification. Available only for Android platforms.', true) + ->param('badge', null, new Nullable(new Integer()), 'Badge for push notification. Available only for iOS platforms.', true) + ->param('draft', null, new Nullable(new Boolean()), 'Is message a draft', 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('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) ->inject('queueForEvents') ->inject('dbForProject') ->inject('dbForPlatform') diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 1d1e6e999c..f9d134db05 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -1,5 +1,6 @@ <?php +use Appwrite\Auth\Auth; use Appwrite\Event\Event; use Appwrite\Event\Migration; use Appwrite\Extend\Exception; @@ -334,26 +335,19 @@ App::post('/v1/migrations/csv/imports') ->inject('response') ->inject('dbForProject') ->inject('dbForPlatform') + ->inject('authorization') ->inject('project') ->inject('deviceForFiles') ->inject('deviceForMigrations') ->inject('queueForEvents') ->inject('queueForMigrations') - ->action(function ( - string $bucketId, - string $fileId, - string $resourceId, - bool $internalFile, - Response $response, - Database $dbForProject, - Database $dbForPlatform, - Document $project, - Device $deviceForFiles, - Device $deviceForMigrations, - Event $queueForEvents, - Migration $queueForMigrations - ) { - $bucket = Authorization::skip(function () use ($internalFile, $dbForPlatform, $dbForProject, $bucketId) { + ->action(function (string $bucketId, string $fileId, string $resourceId, bool $internalFile, Response $response, Database $dbForProject, Database $dbForPlatform, Authorization $authorization, Document $project, Device $deviceForFiles, Device $deviceForMigrations, Event $queueForEvents, Migration $queueForMigrations) { + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); + if ($internalFile && !$isPrivilegedUser) { + throw new Exception(Exception::USER_UNAUTHORIZED); + } + $bucket = $authorization->skip(function () use ($internalFile, $dbForPlatform, $dbForProject, $bucketId) { if ($internalFile) { return $dbForPlatform->getDocument('buckets', 'default'); } @@ -364,7 +358,7 @@ App::post('/v1/migrations/csv/imports') throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } - $file = Authorization::skip(fn () => $internalFile ? $dbForPlatform->getDocument('bucket_' . $bucket->getSequence(), $fileId) : $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $internalFile ? $dbForPlatform->getDocument('bucket_' . $bucket->getSequence(), $fileId) : $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); if ($file->isEmpty()) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } @@ -468,7 +462,6 @@ App::post('/v1/migrations/csv/exports') ] )) ->param('resourceId', null, new CompoundUID(), 'Composite ID in the format {databaseId:collectionId}, identifying a collection within a database to export.') - ->param('bucketId', '', new UID(), 'Storage bucket unique ID where the exported CSV will be stored.') ->param('filename', '', new Text(255), 'The name of the file to be created for the export, excluding the .csv extension.') ->param('columns', [], new ArrayList(new Text(Database::LENGTH_KEY)), 'List of attributes to export. If empty, all attributes will be exported. You can use the `*` wildcard to export all attributes from the collection.', true) ->param('queries', [], new ArrayList(new Text(0)), 'Array of query strings generated using the Query class provided by the SDK to filter documents to export. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) @@ -480,12 +473,13 @@ App::post('/v1/migrations/csv/exports') ->inject('user') ->inject('response') ->inject('dbForProject') + ->inject('dbForPlatform') + ->inject('authorization') ->inject('project') ->inject('queueForEvents') ->inject('queueForMigrations') ->action(function ( string $resourceId, - string $bucketId, string $filename, array $columns, array $queries, @@ -497,6 +491,8 @@ App::post('/v1/migrations/csv/exports') Document $user, Response $response, Database $dbForProject, + Database $dbForPlatform, + Authorization $authorization, Document $project, Event $queueForEvents, Migration $queueForMigrations @@ -507,7 +503,7 @@ App::post('/v1/migrations/csv/exports') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForPlatform->getDocument('buckets', 'default')); if ($bucket->isEmpty()) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } @@ -520,12 +516,12 @@ App::post('/v1/migrations/csv/exports') throw new Exception(Exception::COLLECTION_NOT_FOUND); } - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty()) { throw new Exception(Exception::COLLECTION_NOT_FOUND); } @@ -553,7 +549,7 @@ App::post('/v1/migrations/csv/exports') 'resourceData' => '{}', 'errors' => [], 'options' => [ - 'bucketId' => $bucketId, + 'bucketId' => 'default', // Always use internal bucket 'filename' => $filename, 'columns' => $columns, 'queries' => $queries, diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 390e88637a..cda03f923a 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -18,6 +18,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Datetime as DateTimeValidator; use Utopia\Database\Validator\UID; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -44,9 +45,10 @@ App::get('/v1/project/usage') ->inject('response') ->inject('project') ->inject('dbForProject') + ->inject('authorization') ->inject('getLogsDB') ->inject('smsRates') - ->action(function (string $startDate, string $endDate, string $period, Response $response, Document $project, Database $dbForProject, callable $getLogsDB, array $smsRates) { + ->action(function (string $startDate, string $endDate, string $period, Response $response, Document $project, Database $dbForProject, Authorization $authorization, callable $getLogsDB, array $smsRates) { $stats = $total = $usage = []; $format = 'Y-m-d 00:00:00'; $firstDay = (new DateTime($startDate))->format($format); @@ -101,7 +103,7 @@ App::get('/v1/project/usage') '1d' => 'Y-m-d\T00:00:00.000P', }; - Authorization::skip(function () use ($dbForProject, $dbForLogs, $firstDay, $lastDay, $period, $metrics, $limit, &$total, &$stats) { + $authorization->skip(function () use ($dbForProject, $dbForLogs, $firstDay, $lastDay, $period, $metrics, $limit, &$total, &$stats) { foreach ($metrics['total'] as $metric) { $db = ($metric === METRIC_FILES_IMAGES_TRANSFORMED) ? $dbForLogs : $dbForProject; @@ -285,7 +287,7 @@ App::get('/v1/project/usage') }, $dbForProject->find('functions')); // This total is includes free and paid SMS usage - $authPhoneTotal = Authorization::skip(fn () => $dbForProject->sum('stats', 'value', [ + $authPhoneTotal = $authorization->skip(fn () => $dbForProject->sum('stats', 'value', [ Query::equal('metric', [METRIC_AUTH_METHOD_PHONE]), Query::equal('period', ['1d']), Query::greaterThanEqual('time', $firstDay), @@ -293,7 +295,7 @@ App::get('/v1/project/usage') ])); // This estimate is only for paid SMS usage - $authPhoneMetrics = Authorization::skip(fn () => $dbForProject->find('stats', [ + $authPhoneMetrics = $authorization->skip(fn () => $dbForProject->find('stats', [ Query::startsWith('metric', METRIC_AUTH_METHOD_PHONE . '.'), Query::equal('period', ['1d']), Query::greaterThanEqual('time', $firstDay), @@ -526,8 +528,8 @@ App::put('/v1/project/variables/:variableId') )) ->param('variableId', '', new UID(), 'Variable unique ID.', false) ->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false) - ->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.', true) - ->param('secret', null, new Boolean(), 'Secret variables can be updated or deleted, but only projects can read them during build and runtime.', true) + ->param('value', null, new Nullable(new Text(8192, 0)), 'Variable value. Max length: 8192 chars.', true) + ->param('secret', null, new Nullable(new Boolean()), 'Secret variables can be updated or deleted, but only projects can read them during build and runtime.', true) ->inject('project') ->inject('response') ->inject('dbForProject') diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 2b30b1cd08..760a4f23a6 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -46,6 +46,7 @@ use Utopia\Validator\Boolean; use Utopia\Validator\Hostname; use Utopia\Validator\Integer; use Utopia\Validator\Multiple; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\URL; @@ -678,9 +679,9 @@ App::patch('/v1/projects/:projectId/oauth2') )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('provider', '', new WhiteList(\array_keys(Config::getParam('oAuthProviders')), true), 'Provider Name') - ->param('appId', null, new Text(256), 'Provider app ID. Max length: 256 chars.', true) - ->param('secret', null, new text(512), 'Provider secret key. Max length: 512 chars.', true) - ->param('enabled', null, new Boolean(), 'Provider status. Set to \'false\' to disable new session creation.', true) + ->param('appId', null, new Nullable(new Text(256)), 'Provider app ID. Max length: 256 chars.', true) + ->param('secret', null, new Nullable(new text(512)), 'Provider secret key. Max length: 512 chars.', true) + ->param('enabled', null, new Nullable(new Boolean()), 'Provider status. Set to \'false\' to disable new session creation.', true) ->inject('response') ->inject('dbForPlatform') ->action(function (string $projectId, string $provider, ?string $appId, ?string $secret, ?bool $enabled, Response $response, Database $dbForPlatform) { @@ -1476,8 +1477,8 @@ App::post('/v1/projects/:projectId/keys') )) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') - ->param('scopes', null, new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.') - ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) + ->param('scopes', null, new Nullable(new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' scopes are allowed.') + ->param('expire', null, new Nullable(new DatetimeValidator()), '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('dbForPlatform') ->action(function (string $projectId, string $name, array $scopes, ?string $expire, Response $response, Database $dbForPlatform) { @@ -1615,8 +1616,8 @@ App::put('/v1/projects/:projectId/keys/:keyId') ->param('projectId', '', new UID(), 'Project unique ID.') ->param('keyId', '', new UID(), 'Key unique ID.') ->param('name', null, new Text(128), 'Key name. Max length: 128 chars.') - ->param('scopes', null, new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.') - ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.', true) + ->param('scopes', null, new Nullable(new ArrayList(new WhiteList(array_keys(Config::getParam('scopes')), true), APP_LIMIT_ARRAY_PARAMS_SIZE)), 'Key scopes list. Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' events are allowed.') + ->param('expire', null, new Nullable(new DatetimeValidator()), '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('dbForPlatform') ->action(function (string $projectId, string $keyId, string $name, array $scopes, ?string $expire, Response $response, Database $dbForPlatform) { diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index a84b872e5a..df177bc8e5 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -32,6 +32,7 @@ use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\UID; @@ -50,6 +51,7 @@ use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; use Utopia\Validator\HexColor; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -77,7 +79,7 @@ App::post('/v1/storage/buckets') )) ->param('bucketId', '', new CustomId(), 'Unique 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.') ->param('name', '', new Text(128), 'Bucket name') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).', 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']) @@ -292,7 +294,7 @@ App::put('/v1/storage/buckets/:bucketId') )) ->param('bucketId', '', new UID(), 'Bucket unique ID.') ->param('name', null, new Text(128), 'Bucket name', false) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('fileSecurity', false, new Boolean(true), 'Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions).', 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']) @@ -423,7 +425,7 @@ App::post('/v1/storage/buckets/:bucketId/files') ->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).') ->param('fileId', '', new CustomId(), 'File 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.') ->param('file', [], new File(), 'Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file).', skipValidation: true) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->inject('request') ->inject('response') ->inject('dbForProject') @@ -432,20 +434,20 @@ App::post('/v1/storage/buckets/:bucketId/files') ->inject('mode') ->inject('deviceForFiles') ->inject('deviceForLocal') - ->action(function (string $bucketId, string $fileId, mixed $file, ?array $permissions, Request $request, Response $response, Database $dbForProject, Document $user, Event $queueForEvents, string $mode, Device $deviceForFiles, Device $deviceForLocal) { + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, mixed $file, ?array $permissions, Request $request, Response $response, Database $dbForProject, Document $user, Event $queueForEvents, string $mode, Device $deviceForFiles, Device $deviceForLocal, Authorization $authorization) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } - $validator = new Authorization(Database::PERMISSION_CREATE); - if (!$validator->isValid($bucket->getCreate())) { - throw new Exception(Exception::USER_UNAUTHORIZED); + if (!$authorization->isValid(new Input(Database::PERMISSION_CREATE, $bucket->getCreate()))) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } $allowedPermissions = [ @@ -468,7 +470,7 @@ App::post('/v1/storage/buckets/:bucketId/files') } // Users can only manage their own roles, API keys and Admin users can manage any - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach (Database::PERMISSIONS as $type) { foreach ($permissions as $permission) { @@ -481,7 +483,7 @@ App::post('/v1/storage/buckets/:bucketId/files') $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { + if (!$authorization->hasRole($role)) { throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $roles) . ')'); } } @@ -701,11 +703,10 @@ App::post('/v1/storage/buckets/:bucketId/files') * However as with chunk upload even if we are updating, we are essentially creating a file * adding it's new chunk so we validate create permission instead of update */ - $validator = new Authorization(Database::PERMISSION_CREATE); - if (!$validator->isValid($bucket->getCreate())) { - throw new Exception(Exception::USER_UNAUTHORIZED); + if (!$authorization->isValid(new Input(Database::PERMISSION_CREATE, $bucket->getCreate()))) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } - $file = Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); + $file = $authorization->skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); } } else { if ($file->isEmpty()) { @@ -744,13 +745,12 @@ App::post('/v1/storage/buckets/:bucketId/files') * However as with chunk upload even if we are updating, we are essentially creating a file * adding it's new chunk so we validate create permission instead of update */ - $validator = new Authorization(Database::PERMISSION_CREATE); - if (!$validator->isValid($bucket->getCreate())) { - throw new Exception(Exception::USER_UNAUTHORIZED); + if (!$authorization->isValid(new Input(Database::PERMISSION_CREATE, $bucket->getCreate()))) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } try { - $file = Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); + $file = $authorization->skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); } catch (NotFoundException) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } @@ -794,22 +794,22 @@ App::get('/v1/storage/buckets/:bucketId/files') ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->inject('mode') - ->action(function (string $bucketId, array $queries, string $search, bool $includeTotal, Response $response, Database $dbForProject, string $mode) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + ->action(function (string $bucketId, array $queries, string $search, bool $includeTotal, Response $response, Database $dbForProject, Authorization $authorization, string $mode) { + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } $queries = Query::parseQueries($queries); @@ -838,7 +838,7 @@ App::get('/v1/storage/buckets/:bucketId/files') if ($fileSecurity && !$valid) { $cursorDocument = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if ($cursorDocument->isEmpty()) { @@ -848,15 +848,13 @@ App::get('/v1/storage/buckets/:bucketId/files') $cursor->setValue($cursorDocument); } - $filterQueries = Query::groupByType($queries)['filters']; - try { if ($fileSecurity && !$valid) { $files = $dbForProject->find('bucket_' . $bucket->getSequence(), $queries); - $total = $includeTotal ? $dbForProject->count('bucket_' . $bucket->getSequence(), $filterQueries, APP_LIMIT_COUNT) : 0; + $total = $includeTotal ? $dbForProject->count('bucket_' . $bucket->getSequence(), $queries, APP_LIMIT_COUNT) : 0; } else { - $files = Authorization::skip(fn () => $dbForProject->find('bucket_' . $bucket->getSequence(), $queries)); - $total = $includeTotal ? Authorization::skip(fn () => $dbForProject->count('bucket_' . $bucket->getSequence(), $filterQueries, APP_LIMIT_COUNT)) : 0; + $files = $authorization->skip(fn () => $dbForProject->find('bucket_' . $bucket->getSequence(), $queries)); + $total = $includeTotal ? $authorization->skip(fn () => $dbForProject->count('bucket_' . $bucket->getSequence(), $queries, APP_LIMIT_COUNT)) : 0; } } catch (NotFoundException) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -895,28 +893,28 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId') ->param('fileId', '', new UID(), 'File ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->inject('mode') - ->action(function (string $bucketId, string $fileId, Response $response, Database $dbForProject, string $mode) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + ->action(function (string $bucketId, string $fileId, Response $response, Database $dbForProject, Authorization $authorization, string $mode) { + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($fileSecurity && !$valid) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if ($file->isEmpty()) { @@ -972,17 +970,18 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') ->inject('deviceForFiles') ->inject('deviceForLocal') ->inject('project') - ->action(function (string $bucketId, string $fileId, int $width, int $height, string $gravity, int $quality, int $borderWidth, string $borderColor, int $borderRadius, float $opacity, int $rotation, string $background, string $output, ?string $token, Request $request, Response $response, Database $dbForProject, Document $resourceToken, Device $deviceForFiles, Device $deviceForLocal, Document $project) { + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, int $width, int $height, string $gravity, int $quality, int $borderWidth, string $borderColor, int $borderRadius, float $opacity, int $rotation, string $background, string $output, ?string $token, Request $request, Response $response, Database $dbForProject, Document $resourceToken, Device $deviceForFiles, Device $deviceForLocal, Document $project, Authorization $authorization) { if (!\extension_loaded('imagick')) { throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Imagick extension is missing'); } /* @type Document $bucket */ - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAppUser = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAppUser = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAppUser && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -994,21 +993,20 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid && !$isToken) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($fileSecurity && !$valid && !$isToken) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { /* @type Document $file */ - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if (!$resourceToken->isEmpty() && $resourceToken->getAttribute('fileInternalId') !== $file->getSequence()) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($file->isEmpty()) { @@ -1126,11 +1124,11 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $contentType = (\array_key_exists($output, $outputs)) ? $outputs[$output] : $outputs['jpg']; //Do not update transformedAt if it's a console user - if (!Auth::isPrivilegedUser(Authorization::getRoles())) { + if (!Auth::isPrivilegedUser($authorization->getRoles())) { $transformedAt = $file->getAttribute('transformedAt', ''); if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $transformedAt) { $file->setAttribute('transformedAt', DateTime::now()); - Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $file->getAttribute('bucketInternalId'), $file->getId(), $file)); + $authorization->skip(fn () => $dbForProject->updateDocument('bucket_' . $file->getAttribute('bucketInternalId'), $file->getId(), $file)); } } @@ -1170,15 +1168,16 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') ->inject('request') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->inject('mode') ->inject('resourceToken') ->inject('deviceForFiles') - ->action(function (string $bucketId, string $fileId, ?string $token, Request $request, Response $response, Database $dbForProject, string $mode, Document $resourceToken, Device $deviceForFiles) { + ->action(function (string $bucketId, string $fileId, ?string $token, Request $request, Response $response, Database $dbForProject, Authorization $authorization, string $mode, Document $resourceToken, Device $deviceForFiles) { /* @type Document $bucket */ - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -1186,21 +1185,20 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid && !$isToken) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($fileSecurity && !$valid && !$isToken) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { /* @type Document $file */ - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if (!$resourceToken->isEmpty() && $resourceToken->getAttribute('fileInternalId') !== $file->getSequence()) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($file->isEmpty()) { @@ -1334,12 +1332,13 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') ->inject('mode') ->inject('resourceToken') ->inject('deviceForFiles') - ->action(function (string $bucketId, string $fileId, ?string $token, Response $response, Request $request, Database $dbForProject, string $mode, Document $resourceToken, Device $deviceForFiles) { + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, ?string $token, Response $response, Request $request, Database $dbForProject, string $mode, Document $resourceToken, Device $deviceForFiles, Authorization $authorization) { /* @type Document $bucket */ - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -1347,21 +1346,20 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid && !$isToken) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($fileSecurity && !$valid && !$isToken) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { /* @type Document $file */ - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if (!$resourceToken->isEmpty() && $resourceToken->getAttribute('fileInternalId') !== $file->getSequence()) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($file->isEmpty()) { @@ -1486,18 +1484,18 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') ->inject('response') ->inject('request') ->inject('dbForProject') + ->inject('dbForPlatform') ->inject('project') ->inject('mode') ->inject('deviceForFiles') - ->action(function (string $bucketId, string $fileId, string $jwt, Response $response, Request $request, Database $dbForProject, Document $project, string $mode, Device $deviceForFiles) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, string $jwt, Response $response, Request $request, Database $dbForProject, Database $dbForPlatform, Document $project, string $mode, Device $deviceForFiles, Authorization $authorization) { $decoder = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 3600, 0); try { $decoded = $decoder->decode($jwt); } catch (JWTException) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ( @@ -1505,18 +1503,21 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') $decoded['bucketId'] !== $bucketId || $decoded['fileId'] !== $fileId ) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isInternal = $decoded['internal'] ?? false; + $dbForProject = $isInternal ? $dbForPlatform : $dbForProject; + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); + + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); - + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); if ($file->isEmpty()) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } @@ -1524,7 +1525,6 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/push') $mimes = Config::getParam('storage-mimes'); $path = $file->getAttribute('path', ''); - if (!$deviceForFiles->exists($path)) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND, 'File not found in ' . $path); } @@ -1654,33 +1654,33 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') )) ->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).') ->param('fileId', '', new UID(), 'File unique ID.') - ->param('name', null, new Text(255), 'Name of the file', true) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('name', null, new Nullable(new Text(255)), 'Name of the file', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->inject('response') ->inject('dbForProject') ->inject('user') ->inject('mode') ->inject('queueForEvents') - ->action(function (string $bucketId, string $fileId, ?string $name, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $queueForEvents) { + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, ?string $name, ?array $permissions, Response $response, Database $dbForProject, Document $user, string $mode, Event $queueForEvents, Authorization $authorization) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_UPDATE); - $valid = $validator->isValid($bucket->getUpdate()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_UPDATE, $bucket->getUpdate())); if (!$fileSecurity && !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } // Read permission should not be required for update - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); if ($file->isEmpty()) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); @@ -1694,7 +1694,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') ]); // Users can only manage their own roles, API keys and Admin users can manage any - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles) && !\is_null($permissions)) { foreach (Database::PERMISSIONS as $type) { foreach ($permissions as $permission) { @@ -1707,7 +1707,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { + if (!$authorization->hasRole($role)) { throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $roles) . ')'); } } @@ -1728,7 +1728,7 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') if ($fileSecurity && !$valid) { $file = $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file); } else { - $file = Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); + $file = $authorization->skip(fn () => $dbForProject->updateDocument('bucket_' . $bucket->getSequence(), $fileId, $file)); } } catch (NotFoundException) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -1776,33 +1776,34 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') ->inject('mode') ->inject('deviceForFiles') ->inject('queueForDeletes') - ->action(function (string $bucketId, string $fileId, Response $response, Database $dbForProject, Event $queueForEvents, string $mode, Device $deviceForFiles, Delete $queueForDeletes) { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + ->inject('authorization') + ->action(function (string $bucketId, string $fileId, Response $response, Database $dbForProject, Event $queueForEvents, string $mode, Device $deviceForFiles, Delete $queueForDeletes, Authorization $authorization) { + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_DELETE); - $valid = $validator->isValid($bucket->getDelete()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_DELETE, $bucket->getDelete())); if (!$fileSecurity && !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } // Read permission should not be required for delete - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); if ($file->isEmpty()) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } // Make sure we don't delete the file before the document permission check occurs - if ($fileSecurity && !$valid && !$validator->isValid($file->getDelete())) { - throw new Exception(Exception::USER_UNAUTHORIZED); + $validFile = $authorization->isValid(new Input(Database::PERMISSION_DELETE, $file->getDelete())); + if ($fileSecurity && !$valid && !$validFile) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } $deviceDeleted = false; @@ -1826,7 +1827,7 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') if ($fileSecurity && !$valid) { $deleted = $dbForProject->deleteDocument('bucket_' . $bucket->getSequence(), $fileId); } else { - $deleted = Authorization::skip(fn () => $dbForProject->deleteDocument('bucket_' . $bucket->getSequence(), $fileId)); + $deleted = $authorization->skip(fn () => $dbForProject->deleteDocument('bucket_' . $bucket->getSequence(), $fileId)); } } catch (NotFoundException) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -1871,7 +1872,8 @@ App::get('/v1/storage/usage') ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') - ->action(function (string $range, Response $response, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $range, Response $response, Database $dbForProject, Authorization $authorization) { $periods = Config::getParam('usage', []); $stats = $usage = []; @@ -1883,7 +1885,7 @@ App::get('/v1/storage/usage') ]; $total = []; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats, &$total) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats, &$total) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), @@ -1961,7 +1963,8 @@ App::get('/v1/storage/:bucketId/usage') ->inject('project') ->inject('dbForProject') ->inject('getLogsDB') - ->action(function (string $bucketId, string $range, Response $response, Document $project, Database $dbForProject, callable $getLogsDB) { + ->inject('authorization') + ->action(function (string $bucketId, string $range, Response $response, Document $project, Database $dbForProject, callable $getLogsDB, Authorization $authorization) { $dbForLogs = call_user_func($getLogsDB, $project); $bucket = $dbForProject->getDocument('buckets', $bucketId); @@ -1979,7 +1982,7 @@ App::get('/v1/storage/:bucketId/usage') str_replace('{bucketInternalId}', $bucket->getSequence(), METRIC_BUCKET_ID_FILES_IMAGES_TRANSFORMED), ]; - Authorization::skip(function () use ($dbForProject, $dbForLogs, $bucket, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $dbForLogs, $bucket, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $db = ($metric === str_replace('{bucketInternalId}', $bucket->getSequence(), METRIC_BUCKET_ID_FILES_IMAGES_TRANSFORMED)) ? $dbForLogs diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 9fb5db0c5b..4b8c543e5d 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -10,7 +10,7 @@ use Appwrite\Event\Mail; use Appwrite\Event\Messaging; use Appwrite\Event\StatsUsage; use Appwrite\Extend\Exception; -use Appwrite\Network\Validator\Email; +use Appwrite\Network\Validator\Email as EmailValidator; use Appwrite\Network\Validator\Redirect; use Appwrite\Platform\Workers\Deletes; use Appwrite\SDK\AuthType; @@ -48,6 +48,7 @@ use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\Query\Limit; use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\UID; +use Utopia\Emails\Email; use Utopia\Locale\Locale; use Utopia\System\System; use Utopia\Validator\ArrayList; @@ -83,16 +84,17 @@ App::post('/v1/teams') ->inject('response') ->inject('user') ->inject('dbForProject') + ->inject('authorization') ->inject('queueForEvents') - ->action(function (string $teamId, string $name, array $roles, Response $response, Document $user, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $teamId, string $name, array $roles, Response $response, Document $user, Database $dbForProject, Authorization $authorization, Event $queueForEvents) { - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); - $isAppUser = Auth::isAppUser(Authorization::getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); + $isAppUser = Auth::isAppUser($authorization->getRoles()); $teamId = $teamId == 'unique()' ? ID::unique() : $teamId; try { - $team = Authorization::skip(fn () => $dbForProject->createDocument('teams', new Document([ + $team = $authorization->skip(fn () => $dbForProject->createDocument('teams', new Document([ '$id' => $teamId, '$permissions' => [ Permission::read(Role::team($teamId)), @@ -468,7 +470,7 @@ App::post('/v1/teams/:teamId/memberships') )) ->label('abuse-limit', 10) ->param('teamId', '', new UID(), 'Team ID.') - ->param('email', '', new Email(), 'Email of the new team member.', true) + ->param('email', '', new EmailValidator(), 'Email of the new team member.', true) ->param('userId', '', new UID(), 'ID of the user to be added to a team.', true) ->param('phone', '', new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('roles', [], function (Document $project) { @@ -488,6 +490,7 @@ App::post('/v1/teams/:teamId/memberships') ->inject('project') ->inject('user') ->inject('dbForProject') + ->inject('authorization') ->inject('locale') ->inject('queueForMails') ->inject('queueForMessaging') @@ -495,9 +498,9 @@ App::post('/v1/teams/:teamId/memberships') ->inject('timelimit') ->inject('queueForStatsUsage') ->inject('plan') - ->action(function (string $teamId, string $email, string $userId, string $phone, array $roles, string $url, string $name, Response $response, Document $project, Document $user, Database $dbForProject, Locale $locale, Mail $queueForMails, Messaging $queueForMessaging, Event $queueForEvents, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan) { - $isAppUser = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + ->action(function (string $teamId, string $email, string $userId, string $phone, array $roles, string $url, string $name, Response $response, Document $project, Document $user, Database $dbForProject, Authorization $authorization, Locale $locale, Mail $queueForMails, Messaging $queueForMessaging, Event $queueForEvents, callable $timelimit, StatsUsage $queueForStatsUsage, array $plan) { + $isAppUser = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); $url = htmlentities($url); if (empty($url)) { @@ -566,9 +569,15 @@ App::post('/v1/teams/:teamId/memberships') throw new Exception(Exception::USER_EMAIL_ALREADY_EXISTS); } + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + try { $userId = ID::unique(); - $invitee = Authorization::skip(fn () => $dbForProject->createDocument('users', new Document([ + $invitee = $authorization->skip(fn () => $dbForProject->createDocument('users', new Document([ '$id' => $userId, '$permissions' => [ Permission::read(Role::any()), @@ -598,13 +607,18 @@ App::post('/v1/teams/:teamId/memberships') 'tokens' => null, 'memberships' => null, 'search' => implode(' ', [$userId, $email, $name]), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]))); } catch (Duplicate $th) { throw new Exception(Exception::USER_ALREADY_EXISTS); } } - $isOwner = Authorization::isRole('team:' . $team->getId() . '/owner'); + $isOwner = $authorization->hasRole('team:' . $team->getId() . '/owner'); if (!$isOwner && !$isPrivilegedUser && !$isAppUser) { // Not owner, not admin, not app (server) throw new Exception(Exception::USER_UNAUTHORIZED, 'User is not allowed to send invitations for this team'); @@ -640,11 +654,11 @@ App::post('/v1/teams/:teamId/memberships') ]); $membership = ($isPrivilegedUser || $isAppUser) ? - Authorization::skip(fn () => $dbForProject->createDocument('memberships', $membership)) : + $authorization->skip(fn () => $dbForProject->createDocument('memberships', $membership)) : $dbForProject->createDocument('memberships', $membership); if ($isPrivilegedUser || $isAppUser) { - Authorization::skip(fn () => $dbForProject->increaseDocumentAttribute('teams', $team->getId(), 'total', 1)); + $authorization->skip(fn () => $dbForProject->increaseDocumentAttribute('teams', $team->getId(), 'total', 1)); } } elseif ($membership->getAttribute('confirm') === false) { @@ -657,7 +671,7 @@ App::post('/v1/teams/:teamId/memberships') } $membership = ($isPrivilegedUser || $isAppUser) ? - Authorization::skip(fn () => $dbForProject->updateDocument('memberships', $membership->getId(), $membership)) : + $authorization->skip(fn () => $dbForProject->updateDocument('memberships', $membership->getId(), $membership)) : $dbForProject->updateDocument('memberships', $membership->getId(), $membership); } else { throw new Exception(Exception::MEMBERSHIP_ALREADY_CONFIRMED); @@ -844,7 +858,8 @@ App::get('/v1/teams/:teamId/memberships') ->inject('response') ->inject('project') ->inject('dbForProject') - ->action(function (string $teamId, array $queries, string $search, bool $includeTotal, Response $response, Document $project, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $teamId, array $queries, string $search, bool $includeTotal, Response $response, Document $project, Database $dbForProject, Authorization $authorization) { $team = $dbForProject->getDocument('teams', $teamId); if ($team->isEmpty()) { @@ -914,7 +929,7 @@ App::get('/v1/teams/:teamId/memberships') 'mfa' => $project->getAttribute('auths', [])['membershipsMfa'] ?? true, ]; - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); $isPrivilegedUser = Auth::isPrivilegedUser($roles); $isAppUser = Auth::isAppUser($roles); @@ -985,7 +1000,8 @@ App::get('/v1/teams/:teamId/memberships/:membershipId') ->inject('response') ->inject('project') ->inject('dbForProject') - ->action(function (string $teamId, string $membershipId, Response $response, Document $project, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $teamId, string $membershipId, Response $response, Document $project, Database $dbForProject, Authorization $authorization) { $team = $dbForProject->getDocument('teams', $teamId); @@ -1005,7 +1021,7 @@ App::get('/v1/teams/:teamId/memberships/:membershipId') 'mfa' => $project->getAttribute('auths', [])['membershipsMfa'] ?? true, ]; - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); $isPrivilegedUser = Auth::isPrivilegedUser($roles); $isAppUser = Auth::isAppUser($roles); @@ -1084,8 +1100,9 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId') ->inject('user') ->inject('project') ->inject('dbForProject') + ->inject('authorization') ->inject('queueForEvents') - ->action(function (string $teamId, string $membershipId, array $roles, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $teamId, string $membershipId, array $roles, Request $request, Response $response, Document $user, Document $project, Database $dbForProject, Authorization $authorization, Event $queueForEvents) { $team = $dbForProject->getDocument('teams', $teamId); if ($team->isEmpty()) { @@ -1102,9 +1119,9 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId') throw new Exception(Exception::USER_NOT_FOUND); } - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); - $isAppUser = Auth::isAppUser(Authorization::getRoles()); - $isOwner = Authorization::isRole('team:' . $team->getId() . '/owner'); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); + $isAppUser = Auth::isAppUser($authorization->getRoles()); + $isOwner = $authorization->hasRole('team:' . $team->getId() . '/owner'); if ($project->getId() === 'console') { // Quick check: fetch up to 2 owners to determine if only one exists @@ -1185,10 +1202,11 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') ->inject('response') ->inject('user') ->inject('dbForProject') + ->inject('authorization') ->inject('project') ->inject('geodb') ->inject('queueForEvents') - ->action(function (string $teamId, string $membershipId, string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Document $project, Reader $geodb, Event $queueForEvents) { + ->action(function (string $teamId, string $membershipId, string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Authorization $authorization, Document $project, Reader $geodb, Event $queueForEvents) { $protocol = $request->getProtocol(); $membership = $dbForProject->getDocument('memberships', $membershipId); @@ -1197,7 +1215,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') throw new Exception(Exception::MEMBERSHIP_NOT_FOUND); } - $team = Authorization::skip(fn () => $dbForProject->getDocument('teams', $teamId)); + $team = $authorization->skip(fn () => $dbForProject->getDocument('teams', $teamId)); if ($team->isEmpty()) { throw new Exception(Exception::TEAM_NOT_FOUND); @@ -1233,11 +1251,11 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') ->setAttribute('confirm', true) ; - Authorization::skip(fn () => $dbForProject->updateDocument('users', $user->getId(), $user->setAttribute('emailVerification', true))); + $authorization->skip(fn () => $dbForProject->updateDocument('users', $user->getId(), $user->setAttribute('emailVerification', true))); // Create session for the user if not logged in if (!$hasSession) { - Authorization::setRole(Role::user($user->getId())->toString()); + $authorization->addRole(Role::user($user->getId())->toString()); $detector = new Detector($request->getUserAgent('UNKNOWN')); $record = $geodb->get($request->getIP()); @@ -1265,7 +1283,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') $session = $dbForProject->createDocument('sessions', $session); - Authorization::setRole(Role::user($userId)->toString()); + $authorization->addRole(Role::user($userId)->toString()); if (!Config::getParam('domainVerification')) { $response->addHeader('X-Fallback-Cookies', \json_encode([Auth::$cookieName => Auth::encodeSession($user->getId(), $secret)])); @@ -1298,7 +1316,7 @@ App::patch('/v1/teams/:teamId/memberships/:membershipId/status') $dbForProject->purgeCachedDocument('users', $user->getId()); - Authorization::skip(fn () => $dbForProject->increaseDocumentAttribute('teams', $team->getId(), 'total', 1)); + $authorization->skip(fn () => $dbForProject->increaseDocumentAttribute('teams', $team->getId(), 'total', 1)); $queueForEvents ->setParam('userId', $user->getId()) @@ -1342,8 +1360,9 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId') ->inject('project') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->inject('queueForEvents') - ->action(function (string $teamId, string $membershipId, Document $user, Document $project, Response $response, Database $dbForProject, Event $queueForEvents) { + ->action(function (string $teamId, string $membershipId, Document $user, Document $project, Response $response, Database $dbForProject, Authorization $authorization, Event $queueForEvents) { $membership = $dbForProject->getDocument('memberships', $membershipId); @@ -1401,7 +1420,7 @@ App::delete('/v1/teams/:teamId/memberships/:membershipId') $dbForProject->purgeCachedDocument('users', $profile->getId()); if ($membership->getAttribute('confirm')) { // Count only confirmed members - Authorization::skip(fn () => $dbForProject->decreaseDocumentAttribute('teams', $team->getId(), 'total', 1, 0)); + $authorization->skip(fn () => $dbForProject->decreaseDocumentAttribute('teams', $team->getId(), 'total', 1, 0)); } $queueForEvents diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 591a22705d..3fd570b03f 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -16,7 +16,7 @@ use Appwrite\Event\Delete; use Appwrite\Event\Event; use Appwrite\Extend\Exception; use Appwrite\Hooks\Hooks; -use Appwrite\Network\Validator\Email; +use Appwrite\Network\Validator\Email as EmailValidator; use Appwrite\SDK\AuthType; use Appwrite\SDK\ContentType; use Appwrite\SDK\Deprecated; @@ -49,12 +49,14 @@ use Utopia\Database\Validator\Query\Cursor; use Utopia\Database\Validator\Query\Limit; use Utopia\Database\Validator\Query\Offset; use Utopia\Database\Validator\UID; +use Utopia\Emails\Email; use Utopia\Locale\Locale; use Utopia\System\System; use Utopia\Validator\ArrayList; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; use Utopia\Validator\Integer; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -97,6 +99,12 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e } } + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + $password = (!empty($password)) ? ($hash === 'plaintext' ? Auth::passwordHash($password, $hash, $hashOptionsObject) : $password) : null; $user = new Document([ '$id' => $userId, @@ -124,6 +132,11 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e 'tokens' => null, 'memberships' => null, 'search' => implode(' ', [$userId, $email, $phone, $name]), + 'emailCanonical' => $emailCanonical?->getCanonical(), + 'emailIsCanonical' => $emailCanonical?->isCanonicalSupported(), + 'emailIsCorporate' => $emailCanonical?->isCorporate(), + 'emailIsDisposable' => $emailCanonical?->isDisposable(), + 'emailIsFree' => $emailCanonical?->isFree(), ]); if ($hash === 'plaintext') { @@ -208,8 +221,8 @@ App::post('/v1/users') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', null, new Email(), 'User email.', true) - ->param('phone', null, new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) + ->param('email', null, new Nullable(new EmailValidator()), 'User email.', true) + ->param('phone', null, new Nullable(new Phone()), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true) ->param('password', '', fn ($project, $passwordsDictionary) => new PasswordDictionary($passwordsDictionary, $project->getAttribute('auths', [])['passwordDictionary'] ?? false), 'Plain text user password. Must be at least 8 chars.', true, ['project', 'passwordsDictionary']) ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') @@ -243,7 +256,7 @@ App::post('/v1/users/bcrypt') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using Bcrypt.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') @@ -278,7 +291,7 @@ App::post('/v1/users/md5') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using MD5.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') @@ -313,7 +326,7 @@ App::post('/v1/users/argon2') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using Argon2.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') @@ -348,7 +361,7 @@ App::post('/v1/users/sha') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->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('name', '', new Text(128), 'User name. Max length: 128 chars.', true) @@ -390,7 +403,7 @@ App::post('/v1/users/phpass') ] )) ->param('userId', '', new CustomId(), 'User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. 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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using PHPass.') ->param('name', '', new Text(128), 'User name. Max length: 128 chars.', true) ->inject('response') @@ -425,7 +438,7 @@ App::post('/v1/users/scrypt') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using Scrypt.') ->param('passwordSalt', '', new Text(128), 'Optional salt used to hash password.') ->param('passwordCpu', 8, new Integer(), 'Optional CPU cost used to hash password.') @@ -473,7 +486,7 @@ App::post('/v1/users/scrypt-modified') ] )) ->param('userId', '', new CustomId(), '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.') - ->param('email', '', new Email(), 'User email.') + ->param('email', '', new EmailValidator(), 'User email.') ->param('password', '', new Password(), 'User password hashed using Scrypt Modified.') ->param('passwordSalt', '', new Text(128), 'Salt used to hash password.') ->param('passwordSaltSeparator', '', new Text(128), 'Salt separator used to hash password.') @@ -527,7 +540,7 @@ App::post('/v1/users/:userId/targets') switch ($providerType) { case 'email': - $validator = new Email(); + $validator = new EmailValidator(); if (!$validator->isValid($identifier)) { throw new Exception(Exception::GENERAL_INVALID_EMAIL); } @@ -1402,7 +1415,7 @@ App::patch('/v1/users/:userId/email') ] )) ->param('userId', '', new UID(), 'User ID.') - ->param('email', '', new Email(allowEmpty: true), 'User email.') + ->param('email', '', new EmailValidator(allowEmpty: true), 'User email.') ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') @@ -1437,9 +1450,20 @@ App::patch('/v1/users/:userId/email') $oldEmail = $user->getAttribute('email'); + try { + $emailCanonical = new Email($email); + } catch (Throwable) { + $emailCanonical = null; + } + $user ->setAttribute('email', $email) ->setAttribute('emailVerification', false) + ->setAttribute('emailCanonical', $emailCanonical?->getCanonical()) + ->setAttribute('emailIsCanonical', $emailCanonical?->isCanonicalSupported()) + ->setAttribute('emailIsCorporate', $emailCanonical?->isCorporate()) + ->setAttribute('emailIsDisposable', $emailCanonical?->isDisposable()) + ->setAttribute('emailIsFree', $emailCanonical?->isFree()) ; try { @@ -1700,7 +1724,7 @@ App::patch('/v1/users/:userId/targets/:targetId') switch ($providerType) { case 'email': - $validator = new Email(); + $validator = new EmailValidator(); if (!$validator->isValid($identifier)) { throw new Exception(Exception::GENERAL_INVALID_EMAIL); } @@ -2623,8 +2647,8 @@ App::get('/v1/users/usage') ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') - ->inject('register') - ->action(function (string $range, Response $response, Database $dbForProject) { + ->inject('authorization') + ->action(function (string $range, Response $response, Database $dbForProject, Authorization $authorization) { $periods = Config::getParam('usage', []); $stats = $usage = []; @@ -2634,7 +2658,7 @@ App::get('/v1/users/usage') METRIC_SESSIONS, ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $count => $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index a6e72bf476..4703e3a296 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -14,6 +14,7 @@ use Appwrite\Utopia\Database\Validator\Queries\Installations; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Appwrite\Vcs\Comment; +use Swoole\Coroutine\WaitGroup; use Utopia\App; use Utopia\CLI\Console; use Utopia\Config\Config; @@ -71,7 +72,7 @@ use Utopia\VCS\Exception\RepositoryNotFound; use function Swoole\Coroutine\batch; -$createGitDeployments = function (GitHub $github, string $providerInstallationId, array $repositories, string $providerBranch, string $providerBranchUrl, string $providerRepositoryName, string $providerRepositoryUrl, string $providerRepositoryOwner, string $providerCommitHash, string $providerCommitAuthor, string $providerCommitAuthorUrl, string $providerCommitMessage, string $providerCommitUrl, string $providerPullRequestId, bool $external, Database $dbForPlatform, Build $queueForBuilds, callable $getProjectDB, Request $request) { +$createGitDeployments = function (GitHub $github, string $providerInstallationId, array $repositories, string $providerBranch, string $providerBranchUrl, string $providerRepositoryName, string $providerRepositoryUrl, string $providerRepositoryOwner, string $providerCommitHash, string $providerCommitAuthor, string $providerCommitAuthorUrl, string $providerCommitMessage, string $providerCommitUrl, string $providerPullRequestId, bool $external, Database $dbForPlatform, Authorization $authorization, Build $queueForBuilds, callable $getProjectDB, Request $request) { $errors = []; foreach ($repositories as $repository) { try { @@ -82,12 +83,12 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId } $projectId = $repository->getAttribute('projectId'); - $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); + $project = $authorization->skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); $dbForProject = $getProjectDB($project); $resourceCollection = $resourceType === "function" ? 'functions' : 'sites'; $resourceId = $repository->getAttribute('resourceId'); - $resource = Authorization::skip(fn () => $dbForProject->getDocument($resourceCollection, $resourceId)); + $resource = $authorization->skip(fn () => $dbForProject->getDocument($resourceCollection, $resourceId)); $resourceInternalId = $resource->getSequence(); $deploymentId = ID::unique(); @@ -136,7 +137,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $latestCommentId = ''; if (!empty($providerPullRequestId) && $resource->getAttribute('providerSilentMode', false) === false) { - $latestComment = Authorization::skip(fn () => $dbForPlatform->findOne('vcsComments', [ + $latestComment = $authorization->skip(fn () => $dbForPlatform->findOne('vcsComments', [ Query::equal('providerRepositoryId', [$providerRepositoryId]), Query::equal('providerPullRequestId', [$providerPullRequestId]), Query::orderDesc('$createdAt'), @@ -175,7 +176,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $latestCommentId = \strval($github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment())); } finally { - Authorization::skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); + $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } } } else { @@ -186,7 +187,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId if (!empty($latestCommentId)) { $teamId = $project->getAttribute('teamId', ''); - $latestComment = Authorization::skip(fn () => $dbForPlatform->createDocument('vcsComments', new Document([ + $latestComment = $authorization->skip(fn () => $dbForPlatform->createDocument('vcsComments', new Document([ '$id' => ID::unique(), '$permissions' => [ Permission::read(Role::team(ID::custom($teamId))), @@ -207,7 +208,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId } } } elseif (!empty($providerBranch)) { - $latestComments = Authorization::skip(fn () => $dbForPlatform->find('vcsComments', [ + $latestComments = $authorization->skip(fn () => $dbForPlatform->find('vcsComments', [ Query::equal('providerRepositoryId', [$providerRepositoryId]), Query::equal('providerBranch', [$providerBranch]), Query::orderDesc('$createdAt'), @@ -246,7 +247,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $latestCommentId = \strval($github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment())); } finally { - Authorization::skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); + $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } } } @@ -289,7 +290,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $commands[] = $resource->getAttribute('commands', ''); } - $deployment = Authorization::skip(fn () => $dbForProject->createDocument('deployments', new Document([ + $deployment = $authorization->skip(fn () => $dbForProject->createDocument('deployments', new Document([ '$id' => $deploymentId, '$permissions' => [ Permission::read(Role::any()), @@ -329,7 +330,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId ->setAttribute('latestDeploymentInternalId', $deployment->getSequence()) ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); - Authorization::skip(fn () => $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource)); + $authorization->skip(fn () => $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource)); if ($resource->getCollection() === 'sites') { $projectId = $project->getId(); @@ -339,7 +340,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $domain = ID::unique() . "." . $sitesDomain; $ruleId = md5($domain); $previewRuleId = $ruleId; - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -372,7 +373,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $domain = "branch-{$branchPrefix}-{$resourceProjectHash}.{$sitesDomain}"; $ruleId = md5($domain); try { - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -403,7 +404,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $domain = "commit-" . substr($providerCommitHash, 0, 16) . ".{$sitesDomain}"; $ruleId = md5($domain); try { - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -455,7 +456,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId if ($lockAcquired) { // Wrap in try/finally to ensure lock file gets deleted try { - $rule = Authorization::skip(fn () => $dbForPlatform->getDocument('rules', $previewRuleId)); + $rule = $authorization->skip(fn () => $dbForPlatform->getDocument('rules', $previewRuleId)); $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; $previewUrl = !empty($rule) ? ("{$protocol}://" . $rule->getAttribute('domain', '')) : ''; @@ -467,7 +468,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId $github->updateComment($owner, $repositoryName, $latestCommentId, $comment->generateComment()); } } finally { - Authorization::skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); + $authorization->skip(fn () => $dbForPlatform->deleteDocument('vcsCommentLocks', $latestCommentId)); } } } @@ -963,6 +964,46 @@ App::post('/v1/vcs/github/installations/:installationId/detections') throw new Exception(Exception::FUNCTION_RUNTIME_NOT_DETECTED); } } + + $wg = new WaitGroup(); + $envs = []; + foreach ($files as $file) { + if (!(\str_starts_with($file, '.env'))) { + continue; + } + + $wg->add(); + go(function () use ($github, $owner, $repositoryName, $providerRootDirectory, $file, $wg, &$envs) { + try { + $contentResponse = $github->getRepositoryContent($owner, $repositoryName, \rtrim($providerRootDirectory, '/') . '/' . $file); + $envFile = $contentResponse['content'] ?? ''; + + $envLines = \explode("\n", $envFile); + foreach ($envLines as $line) { + $parts = \explode('=', $line, 2); + $envName = \trim($parts[0] ?? ''); + $envValue = \trim($parts[1] ?? ''); + if (!empty($envName)) { + $envs[$envName] = $envValue; + } + } + } finally { + $wg->done(); + } + }); + } + $wg->wait(); + + $variables = []; + foreach ($envs as $key => $value) { + $variables[] = [ + 'name' => $key, + 'value' => $value, + ]; + } + + $output->setAttribute('variables', $variables); + $response->dynamic($output, $type === 'framework' ? Response::MODEL_DETECTION_FRAMEWORK : Response::MODEL_DETECTION_RUNTIME); }); @@ -1137,6 +1178,44 @@ App::get('/v1/vcs/github/installations/:installationId/providerRepositories') $repo['runtime'] = $runtimeWithVersion ?? ''; } } + + $wg = new WaitGroup(); + $envs = []; + foreach ($files as $file) { + if (!(\str_starts_with($file, '.env'))) { + continue; + } + + $wg->add(); + go(function () use ($github, $repo, $file, $wg, &$envs) { + try { + $contentResponse = $github->getRepositoryContent($repo['organization'], $repo['name'], $file); + $envFile = $contentResponse['content'] ?? ''; + + $envLines = \explode("\n", $envFile); + foreach ($envLines as $line) { + $parts = \explode('=', $line, 2); + $envName = \trim($parts[0] ?? ''); + $envValue = \trim($parts[1] ?? ''); + if (!empty($envName)) { + $envs[$envName] = $envValue; + } + } + } finally { + $wg->done(); + } + }); + } + $wg->wait(); + + $repo['variables'] = []; + foreach ($envs as $key => $value) { + $repo['variables'][] = [ + 'name' => $key, + 'value' => $value, + ]; + } + return $repo; }; }, $repos)); @@ -1383,10 +1462,11 @@ App::post('/v1/vcs/github/events') ->inject('request') ->inject('response') ->inject('dbForPlatform') + ->inject('authorization') ->inject('getProjectDB') ->inject('queueForBuilds') ->action( - function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { + function (GitHub $github, Request $request, Response $response, Database $dbForPlatform, Authorization $authorization, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $payload = $request->getRawPayload(); $signatureRemote = $request->getHeader('x-hub-signature-256', ''); $signatureLocal = System::getEnv('_APP_VCS_GITHUB_WEBHOOK_SECRET', ''); @@ -1422,14 +1502,14 @@ App::post('/v1/vcs/github/events') $github->initializeVariables($providerInstallationId, $privateKey, $githubAppId); //find resourceId from relevant resources table - $repositories = Authorization::skip(fn () => $dbForPlatform->find('repositories', [ + $repositories = $authorization->skip(fn () => $dbForPlatform->find('repositories', [ Query::equal('providerRepositoryId', [$providerRepositoryId]), Query::limit(100), ])); // create new deployment only on push (not committed by us) and not when branch is created or deleted if ($providerCommitAuthorEmail !== APP_VCS_GITHUB_EMAIL && !$providerBranchCreated && !$providerBranchDeleted) { - $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerBranchUrl, $providerRepositoryName, $providerRepositoryUrl, $providerRepositoryOwner, $providerCommitHash, $providerCommitAuthorName, $providerCommitAuthorUrl, $providerCommitMessage, $providerCommitUrl, '', false, $dbForPlatform, $queueForBuilds, $getProjectDB, $request); + $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerBranchUrl, $providerRepositoryName, $providerRepositoryUrl, $providerRepositoryOwner, $providerCommitHash, $providerCommitAuthorName, $providerCommitAuthorUrl, $providerCommitMessage, $providerCommitUrl, '', false, $dbForPlatform, $authorization, $queueForBuilds, $getProjectDB, $request); } } elseif ($event == $github::EVENT_INSTALLATION) { if ($parsedPayload["action"] == "deleted") { @@ -1442,16 +1522,16 @@ App::post('/v1/vcs/github/events') ]); foreach ($installations as $installation) { - $repositories = Authorization::skip(fn () => $dbForPlatform->find('repositories', [ + $repositories = $authorization->skip(fn () => $dbForPlatform->find('repositories', [ Query::equal('installationInternalId', [$installation->getSequence()]), Query::limit(1000) ])); foreach ($repositories as $repository) { - Authorization::skip(fn () => $dbForPlatform->deleteDocument('repositories', $repository->getId())); + $authorization->skip(fn () => $dbForPlatform->deleteDocument('repositories', $repository->getId())); } - Authorization::skip(fn () => $dbForPlatform->deleteDocument('installations', $installation->getId())); + $authorization->skip(fn () => $dbForPlatform->deleteDocument('installations', $installation->getId())); } } } elseif ($event == $github::EVENT_PULL_REQUEST) { @@ -1480,12 +1560,12 @@ App::post('/v1/vcs/github/events') $providerCommitAuthor = $commitDetails["commitAuthor"] ?? ''; $providerCommitMessage = $commitDetails["commitMessage"] ?? ''; - $repositories = Authorization::skip(fn () => $dbForPlatform->find('repositories', [ + $repositories = $authorization->skip(fn () => $dbForPlatform->find('repositories', [ Query::equal('providerRepositoryId', [$providerRepositoryId]), Query::orderDesc('$createdAt') ])); - $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerBranchUrl, $providerRepositoryName, $providerRepositoryUrl, $providerRepositoryOwner, $providerCommitHash, $providerCommitAuthor, $providerCommitAuthorUrl, $providerCommitMessage, $providerCommitUrl, $providerPullRequestId, $external, $dbForPlatform, $queueForBuilds, $getProjectDB, $request); + $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerBranchUrl, $providerRepositoryName, $providerRepositoryUrl, $providerRepositoryOwner, $providerCommitHash, $providerCommitAuthor, $providerCommitAuthorUrl, $providerCommitMessage, $providerCommitUrl, $providerPullRequestId, $external, $dbForPlatform, $authorization, $queueForBuilds, $getProjectDB, $request); } elseif ($parsedPayload["action"] == "closed") { // Allowed external contributions cleanup @@ -1494,7 +1574,7 @@ App::post('/v1/vcs/github/events') $external = $parsedPayload["external"] ?? true; if ($external) { - $repositories = Authorization::skip(fn () => $dbForPlatform->find('repositories', [ + $repositories = $authorization->skip(fn () => $dbForPlatform->find('repositories', [ Query::equal('providerRepositoryId', [$providerRepositoryId]), Query::orderDesc('$createdAt') ])); @@ -1505,7 +1585,7 @@ App::post('/v1/vcs/github/events') if (\in_array($providerPullRequestId, $providerPullRequestIds)) { $providerPullRequestIds = \array_diff($providerPullRequestIds, [$providerPullRequestId]); $repository = $repository->setAttribute('providerPullRequestIds', $providerPullRequestIds); - $repository = Authorization::skip(fn () => $dbForPlatform->updateDocument('repositories', $repository->getId(), $repository)); + $repository = $authorization->skip(fn () => $dbForPlatform->updateDocument('repositories', $repository->getId(), $repository)); } } } @@ -1693,16 +1773,17 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor ->inject('response') ->inject('project') ->inject('dbForPlatform') + ->inject('authorization') ->inject('getProjectDB') ->inject('queueForBuilds') - ->action(function (string $installationId, string $repositoryId, string $providerPullRequestId, GitHub $github, Request $request, Response $response, Document $project, Database $dbForPlatform, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { + ->action(function (string $installationId, string $repositoryId, string $providerPullRequestId, GitHub $github, Request $request, Response $response, Document $project, Database $dbForPlatform, Authorization $authorization, callable $getProjectDB, Build $queueForBuilds) use ($createGitDeployments) { $installation = $dbForPlatform->getDocument('installations', $installationId); if ($installation->isEmpty()) { throw new Exception(Exception::INSTALLATION_NOT_FOUND); } - $repository = Authorization::skip(fn () => $dbForPlatform->getDocument('repositories', $repositoryId, [ + $repository = $authorization->skip(fn () => $dbForPlatform->getDocument('repositories', $repositoryId, [ Query::equal('projectInternalId', [$project->getSequence()]) ])); @@ -1719,7 +1800,7 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor // TODO: Delete from array when PR is closed - $repository = Authorization::skip(fn () => $dbForPlatform->updateDocument('repositories', $repository->getId(), $repository)); + $repository = $authorization->skip(fn () => $dbForPlatform->updateDocument('repositories', $repository->getId(), $repository)); $privateKey = System::getEnv('_APP_VCS_GITHUB_PRIVATE_KEY'); $githubAppId = System::getEnv('_APP_VCS_GITHUB_APP_ID'); @@ -1743,7 +1824,7 @@ App::patch('/v1/vcs/github/installations/:installationId/repositories/:repositor $providerBranch = \explode(':', $pullRequestResponse['head']['label'])[1] ?? ''; $providerCommitHash = $pullRequestResponse['head']['sha'] ?? ''; - $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, $providerCommitHash, $providerPullRequestId, true, $dbForPlatform, $queueForBuilds, $getProjectDB, $request); + $createGitDeployments($github, $providerInstallationId, $repositories, $providerBranch, '', '', '', '', $providerCommitHash, '', '', '', '', $providerPullRequestId, true, $dbForPlatform, $authorization, $queueForBuilds, $getProjectDB, $request); $response->noContent(); }); diff --git a/app/controllers/general.php b/app/controllers/general.php index 07de95a38f..6790d3c67d 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -23,6 +23,7 @@ use Appwrite\Utopia\Request\Filters\V17 as RequestV17; use Appwrite\Utopia\Request\Filters\V18 as RequestV18; use Appwrite\Utopia\Request\Filters\V19 as RequestV19; use Appwrite\Utopia\Request\Filters\V20 as RequestV20; +use Appwrite\Utopia\Request\Filters\V21 as RequestV21; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Filters\V16 as ResponseV16; use Appwrite\Utopia\Response\Filters\V17 as ResponseV17; @@ -56,7 +57,7 @@ Config::setParam('domainVerification', false); Config::setParam('cookieDomain', 'localhost'); Config::setParam('cookieSamesite', Response::COOKIE_SAMESITE_NONE); -function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, ?Key $apiKey) +function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, Authorization $authorization, ?Key $apiKey) { $host = $request->getHostname() ?? ''; if (!empty($previewHostname)) { @@ -65,9 +66,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw // TODO: @christyjacob remove once we migrate the rules in 1.7.x if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { - $rule = Authorization::skip(fn () => $dbForPlatform->getDocument('rules', md5($host))); + $rule = $authorization->skip(fn () => $dbForPlatform->getDocument('rules', md5($host))); } else { - $rule = Authorization::skip( + $rule = $authorization->skip( fn () => $dbForPlatform->find('rules', [ Query::equal('domain', [$host]), Query::limit(1) @@ -108,7 +109,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw } $projectId = $rule->getAttribute('projectId'); - $project = Authorization::skip( + $project = $authorization->skip( fn () => $dbForPlatform->getDocument('projects', $projectId) ); @@ -116,7 +117,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $accessedAt = $project->getAttribute('accessedAt', 0); if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $accessedAt) { $project->setAttribute('accessedAt', DateTime::now()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $project)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $project)); } /** @@ -155,7 +156,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw /** @var Document $deployment */ if (!empty($rule->getAttribute('deploymentId', ''))) { - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); + $deployment = $authorization->skip(fn () => $dbForProject->getDocument('deployments', $rule->getAttribute('deploymentId'))); } else { // 1.6.x DB schema compatibility // TODO: Make sure deploymentId is never empty, and remove this code @@ -169,15 +170,15 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw // Document of site or function $resource = $resourceType === 'function' ? - Authorization::skip(fn () => $dbForProject->getDocument('functions', $resourceId)) : - Authorization::skip(fn () => $dbForProject->getDocument('sites', $resourceId)); + $authorization->skip(fn () => $dbForProject->getDocument('functions', $resourceId)) : + $authorization->skip(fn () => $dbForProject->getDocument('sites', $resourceId)); // ID of active deployments // Attempts to use attribute from both schemas (1.6 and 1.7) $activeDeploymentId = $resource->getAttribute('deploymentId', $resource->getAttribute('deployment', '')); // Get deployment document, as intended originally - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $activeDeploymentId)); + $deployment = $authorization->skip(fn () => $dbForProject->getDocument('deployments', $activeDeploymentId)); } if ($deployment->getAttribute('resourceType', '') === 'functions') { @@ -196,8 +197,8 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw } $resource = $type === 'function' ? - Authorization::skip(fn () => $dbForProject->getDocument('functions', $deployment->getAttribute('resourceId', ''))) : - Authorization::skip(fn () => $dbForProject->getDocument('sites', $deployment->getAttribute('resourceId', ''))); + $authorization->skip(fn () => $dbForProject->getDocument('functions', $deployment->getAttribute('resourceId', ''))) : + $authorization->skip(fn () => $dbForProject->getDocument('sites', $deployment->getAttribute('resourceId', ''))); $isPreview = $type === 'function' ? false : ($rule->getAttribute('trigger', '') !== 'manual'); @@ -239,7 +240,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw $userExists = false; $userId = $payload['userId'] ?? ''; if (!empty($userId)) { - $user = Authorization::skip(fn () => $dbForPlatform->getDocument('users', $userId)); + $user = $authorization->skip(fn () => $dbForPlatform->getDocument('users', $userId)); if (!$user->isEmpty() && $user->getAttribute('status', false)) { $userExists = true; } @@ -252,7 +253,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw } $membershipExists = false; - $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); + $project = $authorization->skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); if (!$project->isEmpty() && isset($user)) { $teamId = $project->getAttribute('teamId', ''); $membership = $user->find('teamId', $teamId, 'memberships'); @@ -863,7 +864,8 @@ App::init() ->inject('apiKey') ->inject('httpReferrer') ->inject('httpReferrerSafe') - ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Document $console, Document $project, Database $dbForPlatform, callable $getProjectDB, Locale $locale, array $localeCodes, array $platforms, Reader $geodb, StatsUsage $queueForStatsUsage, Event $queueForEvents, Certificate $queueForCertificates, Func $queueForFunctions, Executor $executor, callable $isResourceBlocked, string $previewHostname, Document $devKey, ?Key $apiKey, string $httpReferrer, string $httpReferrerSafe) { + ->inject('authorization') + ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Document $console, Document $project, Database $dbForPlatform, callable $getProjectDB, Locale $locale, array $localeCodes, array $platforms, Reader $geodb, StatsUsage $queueForStatsUsage, Event $queueForEvents, Certificate $queueForCertificates, Func $queueForFunctions, Executor $executor, callable $isResourceBlocked, string $previewHostname, Document $devKey, ?Key $apiKey, string $httpReferrer, string $httpReferrerSafe, Authorization $authorization) { /* * Appwrite Router */ @@ -871,7 +873,7 @@ App::init() $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { - if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $apiKey)) { + if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $authorization, $apiKey)) { $utopia->getRoute()?->label('router', true); } } @@ -906,6 +908,9 @@ App::init() $dbForProject = $getProjectDB($project); $request->addFilter(new RequestV20($dbForProject, $route->getPathValues($request))); } + if (version_compare($requestFormat, '1.9.0', '<')) { + $request->addFilter(new RequestV21()); + } } $domain = $request->getHostname(); @@ -919,7 +924,7 @@ App::init() } elseif (str_starts_with($request->getURI(), '/.well-known/acme-challenge')) { Console::warning('Skipping SSL certificates generation on ACME challenge.'); } else { - Authorization::disable(); + $authorization->disable(); $envDomain = System::getEnv('_APP_DOMAIN', ''); $mainDomain = null; @@ -989,7 +994,7 @@ App::init() } $domains[$domain->get()] = true; - Authorization::reset(); // ensure authorization is re-enabled + $authorization->reset(); // ensure authorization is re-enabled } Config::setParam('domains', $domains); } @@ -1125,7 +1130,8 @@ App::options() ->inject('project') ->inject('devKey') ->inject('apiKey') - ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, Document $project, Document $devKey, ?Key $apiKey) { + ->inject('authorization') + ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, Document $project, Document $devKey, ?Key $apiKey, Authorization $authorization) { /* * Appwrite Router */ @@ -1133,7 +1139,7 @@ App::options() $mainDomain = System::getEnv('_APP_DOMAIN', ''); // Only run Router when external domain if ($host !== $mainDomain || !empty($previewHostname)) { - if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $apiKey)) { + if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $authorization, $apiKey)) { $utopia->getRoute()?->label('router', true); } } @@ -1174,7 +1180,8 @@ App::error() ->inject('log') ->inject('queueForStatsUsage') ->inject('devKey') - ->action(function (Throwable $error, App $utopia, Request $request, Response $response, Document $project, ?Logger $logger, Log $log, StatsUsage $queueForStatsUsage) { + ->inject('authorization') + ->action(function (Throwable $error, App $utopia, Request $request, Response $response, Document $project, ?Logger $logger, Log $log, StatsUsage $queueForStatsUsage, Document $devKey, Authorization $authorization) { $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); $route = $utopia->getRoute(); $class = \get_class($error); @@ -1256,7 +1263,7 @@ App::error() * If not a publishable error, track usage stats. Publishable errors are >= 500 or those explicitly marked as publish=true in errors.php */ if (!$publish && $project->getId() !== 'console') { - if (!Auth::isPrivilegedUser(Authorization::getRoles())) { + if (!Auth::isPrivilegedUser($authorization->getRoles())) { $fileSize = 0; $file = $request->getFiles('file'); if (!empty($file)) { @@ -1318,7 +1325,7 @@ App::error() $log->addExtra('file', $error->getFile()); $log->addExtra('line', $error->getLine()); $log->addExtra('trace', $error->getTraceAsString()); - $log->addExtra('roles', Authorization::getRoles()); + $log->addExtra('roles', $authorization->getRoles()); $action = 'UNKNOWN_NAMESPACE.UNKNOWN.METHOD'; if (!empty($sdk)) { @@ -1441,7 +1448,8 @@ App::get('/robots.txt') ->inject('isResourceBlocked') ->inject('previewHostname') ->inject('apiKey') - ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, ?Key $apiKey) { + ->inject('authorization') + ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, ?Key $apiKey, Authorization $authorization) { $host = $request->getHostname() ?? ''; $consoleDomain = System::getEnv('_APP_CONSOLE_DOMAIN', ''); $mainDomain = System::getEnv('_APP_DOMAIN', ''); @@ -1450,7 +1458,7 @@ App::get('/robots.txt') $template = new View(__DIR__ . '/../views/general/robots.phtml'); $response->text($template->render(false)); } else { - if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $apiKey)) { + if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $authorization, $apiKey)) { $utopia->getRoute()?->label('router', true); } } @@ -1475,7 +1483,8 @@ App::get('/humans.txt') ->inject('isResourceBlocked') ->inject('previewHostname') ->inject('apiKey') - ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, ?Key $apiKey) { + ->inject('authorization') + ->action(function (App $utopia, SwooleRequest $swooleRequest, Request $request, Response $response, Log $log, Database $dbForPlatform, callable $getProjectDB, Event $queueForEvents, StatsUsage $queueForStatsUsage, Func $queueForFunctions, Executor $executor, Reader $geodb, callable $isResourceBlocked, string $previewHostname, ?Key $apiKey, Authorization $authorization) { $host = $request->getHostname() ?? ''; $consoleDomain = System::getEnv('_APP_CONSOLE_DOMAIN', ''); $mainDomain = System::getEnv('_APP_DOMAIN', ''); @@ -1484,7 +1493,7 @@ App::get('/humans.txt') $template = new View(__DIR__ . '/../views/general/humans.phtml'); $response->text($template->render(false)); } else { - if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $apiKey)) { + if (router($utopia, $dbForPlatform, $getProjectDB, $swooleRequest, $request, $response, $log, $queueForEvents, $queueForStatsUsage, $queueForFunctions, $executor, $geodb, $isResourceBlocked, $previewHostname, $authorization, $apiKey)) { $utopia->getRoute()?->label('router', true); } } @@ -1568,7 +1577,8 @@ App::get('/v1/ping') ->inject('project') ->inject('dbForPlatform') ->inject('queueForEvents') - ->action(function (Response $response, Document $project, Database $dbForPlatform, Event $queueForEvents) { + ->inject('authorization') + ->action(function (Response $response, Document $project, Database $dbForPlatform, Event $queueForEvents, Authorization $authorization) { if ($project->isEmpty() || $project->getId() === 'console') { throw new AppwriteException(AppwriteException::PROJECT_NOT_FOUND); } @@ -1580,7 +1590,7 @@ App::get('/v1/ping') ->setAttribute('pingCount', $pingCount) ->setAttribute('pingedAt', $pingedAt); - Authorization::skip(function () use ($dbForPlatform, $project) { + $authorization->skip(function () use ($dbForPlatform, $project) { $dbForPlatform->updateDocument('projects', $project->getId(), $project); }); diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index b2ccf8d711..911c8b110d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -29,6 +29,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Queue\Publisher; use Utopia\System\System; use Utopia\Telemetry\Adapter as Telemetry; @@ -232,9 +233,12 @@ App::init() ->inject('mode') ->inject('team') ->inject('apiKey') - ->action(function (App $utopia, Request $request, Database $dbForPlatform, Database $dbForProject, Audit $queueForAudits, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey) { + ->inject('authorization') + ->action(function (App $utopia, Request $request, Database $dbForPlatform, Database $dbForProject, Audit $queueForAudits, Document $project, Document $user, ?Document $session, array $servers, string $mode, Document $team, ?Key $apiKey, Authorization $authorization) { $route = $utopia->getRoute(); - + if (System::getEnv('_APP_EDITION', 'self-hosted') === 'self-hosted' && str_starts_with($route->getPath(), '/v1/backups')) { + throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Database Backups are available on Appwrite Cloud'); + } if ($project->isEmpty()) { throw new Exception(Exception::PROJECT_NOT_FOUND); } @@ -262,7 +266,7 @@ App::init() if ($apiKey->getRole() === Auth::USER_ROLE_APPS) { // Disable authorization checks for API keys - Authorization::setDefaultStatus(false); + $authorization->setDefaultStatus(false); $user = new Document([ '$id' => '', @@ -335,14 +339,14 @@ App::init() $scopes = \array_merge($scopes, $roles[$role]['scopes']); } - Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. + $authorization->setDefaultStatus(false); // Cancel security segmentation for admin users. } $scopes = \array_unique($scopes); - Authorization::setRole($role); - foreach (Auth::getRoles($user) as $authRole) { - Authorization::setRole($authRole); + $authorization->addRole($role); + foreach (Auth::getRoles($user, $authorization) as $authRole) { + $authorization->addRole($authRole); } // Update project last activity @@ -350,7 +354,7 @@ App::init() $accessedAt = $project->getAttribute('accessedAt', 0); if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $accessedAt) { $project->setAttribute('accessedAt', DateTime::now()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $project)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $project)); } } @@ -385,7 +389,7 @@ App::init() if ( array_key_exists($namespace, $project->getAttribute('services', [])) && !$project->getAttribute('services', [])[$namespace] - && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles())) + && !(Auth::isPrivilegedUser($authorization->getRoles()) || Auth::isAppUser($authorization->getRoles())) ) { throw new Exception(Exception::GENERAL_SERVICE_DISABLED); } @@ -445,14 +449,15 @@ App::init() ->inject('plan') ->inject('devKey') ->inject('telemetry') - ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Publisher $publisher, Publisher $publisherFunctions, Publisher $publisherWebhooks, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, StatsUsage $queueForStatsUsage, Database $dbForProject, callable $timelimit, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Document $devKey, Telemetry $telemetry) use ($usageDatabaseListener, $eventDatabaseListener) { + ->inject('authorization') + ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Publisher $publisher, Publisher $publisherFunctions, Publisher $publisherWebhooks, Event $queueForEvents, Messaging $queueForMessaging, Audit $queueForAudits, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, StatsUsage $queueForStatsUsage, Database $dbForProject, callable $timelimit, Document $resourceToken, string $mode, ?Key $apiKey, array $plan, Document $devKey, Telemetry $telemetry, Authorization $authorization) use ($usageDatabaseListener, $eventDatabaseListener) { $route = $utopia->getRoute(); if ( array_key_exists('rest', $project->getAttribute('apis', [])) && !$project->getAttribute('apis', [])['rest'] - && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles())) + && !(Auth::isPrivilegedUser($authorization->getRoles()) || Auth::isAppUser($authorization->getRoles())) ) { throw new AppwriteException(AppwriteException::GENERAL_API_DISABLED); } @@ -482,7 +487,7 @@ App::init() $closestLimit = null; - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); $isPrivilegedUser = Auth::isPrivilegedUser($roles); $isAppUser = Auth::isAppUser($roles); @@ -582,10 +587,10 @@ App::init() if ($useCache) { $route = $utopia->match($request); $isImageTransformation = $route->getPath() === '/v1/storage/buckets/:bucketId/files/:fileId/preview'; - $isDisabled = isset($plan['imageTransformations']) && $plan['imageTransformations'] === -1 && !Auth::isPrivilegedUser(Authorization::getRoles()); + $isDisabled = isset($plan['imageTransformations']) && $plan['imageTransformations'] === -1 && !Auth::isPrivilegedUser($authorization->getRoles()); $key = $request->cacheIdentifier(); - $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); + $cacheLog = $authorization->skip(fn () => $dbForProject->getDocument('cache', $key)); $cache = new Cache( new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()) ); @@ -602,10 +607,10 @@ App::init() if ($type === 'bucket' && (!$isImageTransformation || !$isDisabled)) { $bucketId = $parts[1] ?? null; - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAppUser && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); @@ -616,8 +621,7 @@ App::init() } $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); + $valid = $authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead())); if (!$fileSecurity && !$valid && !$isToken) { throw new Exception(Exception::USER_UNAUTHORIZED); } @@ -628,7 +632,7 @@ App::init() if ($fileSecurity && !$valid && !$isToken) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if (!$resourceToken->isEmpty() && $resourceToken->getAttribute('fileInternalId') !== $file->getSequence()) { @@ -639,11 +643,11 @@ App::init() throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } //Do not update transformedAt if it's a console user - if (!Auth::isPrivilegedUser(Authorization::getRoles())) { + if (!Auth::isPrivilegedUser($authorization->getRoles())) { $transformedAt = $file->getAttribute('transformedAt', ''); if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $transformedAt) { $file->setAttribute('transformedAt', DateTime::now()); - Authorization::skip(fn () => $dbForProject->updateDocument('bucket_' . $file->getAttribute('bucketInternalId'), $file->getId(), $file)); + $authorization->skip(fn () => $dbForProject->updateDocument('bucket_' . $file->getAttribute('bucketInternalId'), $file->getId(), $file)); } } } @@ -739,7 +743,8 @@ App::shutdown() ->inject('queueForWebhooks') ->inject('queueForRealtime') ->inject('dbForProject') - ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, StatsUsage $queueForStatsUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Func $queueForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject) use ($parseLabel) { + ->inject('authorization') + ->action(function (App $utopia, Request $request, Response $response, Document $project, Document $user, Event $queueForEvents, Audit $queueForAudits, StatsUsage $queueForStatsUsage, Delete $queueForDeletes, EventDatabase $queueForDatabase, Build $queueForBuilds, Messaging $queueForMessaging, Func $queueForFunctions, Event $queueForWebhooks, Realtime $queueForRealtime, Database $dbForProject, Authorization $authorization) use ($parseLabel) { $responsePayload = $response->getPayload(); @@ -865,11 +870,11 @@ App::shutdown() $key = $request->cacheIdentifier(); $signature = md5($data['payload']); - $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); + $cacheLog = $authorization->skip(fn () => $dbForProject->getDocument('cache', $key)); $accessedAt = $cacheLog->getAttribute('accessedAt', 0); $now = DateTime::now(); if ($cacheLog->isEmpty()) { - Authorization::skip(fn () => $dbForProject->createDocument('cache', new Document([ + $authorization->skip(fn () => $dbForProject->createDocument('cache', new Document([ '$id' => $key, 'resource' => $resource, 'resourceType' => $resourceType, @@ -879,7 +884,7 @@ App::shutdown() ]))); } elseif (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_CACHE_UPDATE)) > $accessedAt) { $cacheLog->setAttribute('accessedAt', $now); - Authorization::skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog)); + $authorization->skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog)); // Overwrite the file every APP_CACHE_UPDATE seconds to update the file modified time that is used in the TTL checks in cache->load() $cache->save($key, $data['payload']); } @@ -891,7 +896,7 @@ App::shutdown() } if ($project->getId() !== 'console') { - if (!Auth::isPrivilegedUser(Authorization::getRoles())) { + if (!Auth::isPrivilegedUser($authorization->getRoles())) { $fileSize = 0; $file = $request->getFiles('file'); if (!empty($file)) { diff --git a/app/controllers/shared/api/auth.php b/app/controllers/shared/api/auth.php index ecabc641ec..0e3c89c19a 100644 --- a/app/controllers/shared/api/auth.php +++ b/app/controllers/shared/api/auth.php @@ -36,7 +36,8 @@ App::init() ->inject('request') ->inject('project') ->inject('geodb') - ->action(function (App $utopia, Request $request, Document $project, Reader $geodb) { + ->inject('authorization') + ->action(function (App $utopia, Request $request, Document $project, Reader $geodb, Authorization $authorization) { $denylist = System::getEnv('_APP_CONSOLE_COUNTRIES_DENYLIST', ''); if (!empty($denylist && $project->getId() === 'console')) { $countries = explode(',', $denylist); @@ -49,8 +50,8 @@ App::init() $route = $utopia->match($request); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); - $isAppUser = Auth::isAppUser(Authorization::getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); + $isAppUser = Auth::isAppUser($authorization->getRoles()); if ($isAppUser || $isPrivilegedUser) { // Skip limits for app and console devs return; diff --git a/app/http.php b/app/http.php index 1bd3e97e69..568571fad2 100644 --- a/app/http.php +++ b/app/http.php @@ -25,7 +25,6 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\Logger\Log; use Utopia\Logger\Log\User; use Utopia\Pools\Group; @@ -259,7 +258,9 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg createDatabase($app, 'getLogsDB', 'logs', $collections['logs'], $pools); // create appwrite database, `dbForPlatform` is a direct access call. - createDatabase($app, 'dbForPlatform', 'appwrite', $collections['console'], $pools, function (Database $dbForPlatform) use ($collections) { + createDatabase($app, 'dbForPlatform', 'appwrite', $collections['console'], $pools, function (Database $dbForPlatform) use ($collections, $app) { + $authorization = $app->getResource('authorization'); + if ($dbForPlatform->getCollection(Audit::COLLECTION)->isEmpty()) { $audit = new Audit($dbForPlatform); $audit->setup(); @@ -318,9 +319,9 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg $dbForPlatform->createCollection('bucket_' . $bucket->getSequence(), $attributes, $indexes); } - if (Authorization::skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')->isEmpty())) { + if ($authorization->skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')->isEmpty())) { Console::info(" └── Creating screenshots bucket..."); - Authorization::skip(fn () => $dbForPlatform->createDocument('buckets', new Document([ + $authorization->skip(fn () => $dbForPlatform->createDocument('buckets', new Document([ '$id' => ID::custom('screenshots'), '$collection' => ID::custom('buckets'), 'name' => 'Screenshots', @@ -335,7 +336,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg 'search' => 'buckets Screenshots', ]))); - $bucket = Authorization::skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')); + $bucket = $authorization->skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')); Console::info(" └── Creating files collection for screenshots bucket..."); $files = $collections['buckets']['files'] ?? []; @@ -363,7 +364,7 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg 'orders' => $index['orders'], ]), $files['indexes']); - Authorization::skip(fn () => $dbForPlatform->createCollection('bucket_' . $bucket->getSequence(), $attributes, $indexes)); + $authorization->skip(fn () => $dbForPlatform->createCollection('bucket_' . $bucket->getSequence(), $attributes, $indexes)); } }); @@ -454,8 +455,12 @@ $http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, Swool App::setResource('pools', fn () => $pools); try { - Authorization::cleanRoles(); - Authorization::setRole(Role::any()->toString()); + $authorization = $app->getResource('authorization'); + + $request->setAuthorization($authorization); + $response->setAuthorization($authorization); + $authorization->cleanRoles(); + $authorization->addRole(Role::any()->toString()); $app->run($request, $response); } catch (\Throwable $th) { @@ -497,7 +502,7 @@ $http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, Swool $log->addExtra('file', $th->getFile()); $log->addExtra('line', $th->getLine()); $log->addExtra('trace', $th->getTraceAsString()); - $log->addExtra('roles', Authorization::getRoles()); + $log->addExtra('roles', isset($authorization) ? $authorization->getRoles() : []); $sdk = $route->getLabel("sdk", false); @@ -556,7 +561,7 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) { /** @var Utopia\Database\Database $dbForPlatform */ $dbForPlatform = $app->getResource('dbForPlatform'); - Timer::tick(DOMAIN_SYNC_TIMER * 1000, function () use ($dbForPlatform, $domains, &$lastSyncUpdate) { + Timer::tick(DOMAIN_SYNC_TIMER * 1000, function () use ($dbForPlatform, $domains, &$lastSyncUpdate, $app) { try { $time = DateTime::now(); $limit = 1000; @@ -573,7 +578,8 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) { } $results = []; try { - $results = Authorization::skip(fn () => $dbForPlatform->find('rules', $queries)); + $authorization = $app->getResource('authorization'); + $results = $authorization->skip(fn () => $dbForPlatform->find('rules', $queries)); } catch (Throwable $th) { Console::error($th->getMessage()); } diff --git a/app/init/constants.php b/app/init/constants.php index 3b81785690..e11fdf9a54 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -138,6 +138,7 @@ const DELETE_TYPE_TOPIC = 'topic'; const DELETE_TYPE_TARGET = 'target'; const DELETE_TYPE_EXPIRED_TARGETS = 'invalid_targets'; const DELETE_TYPE_SESSION_TARGETS = 'session_targets'; +const DELETE_TYPE_CSV_EXPORTS = 'csv_exports'; const DELETE_TYPE_MAINTENANCE = 'maintenance'; // Message types diff --git a/app/init/database/filters.php b/app/init/database/filters.php index c4cfd1ac81..c065bf0d82 100644 --- a/app/init/database/filters.php +++ b/app/init/database/filters.php @@ -4,7 +4,6 @@ use Appwrite\OpenSSL\OpenSSL; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\System\System; Database::addFilter( @@ -176,7 +175,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database->find('sessions', [ + return $database->getAuthorization()->skip(fn () => $database->find('sessions', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), ])); @@ -189,7 +188,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database + return $database->getAuthorization()->skip(fn () => $database ->find('tokens', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), @@ -203,7 +202,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database + return $database->getAuthorization()->skip(fn () => $database ->find('challenges', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), @@ -217,7 +216,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database + return $database->getAuthorization()->skip(fn () => $database ->find('authenticators', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), @@ -231,7 +230,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database + return $database->getAuthorization()->skip(fn () => $database ->find('memberships', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), @@ -331,7 +330,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - return Authorization::skip(fn () => $database + return $database->getAuthorization()->skip(fn () => $database ->find('targets', [ Query::equal('userInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY) @@ -345,7 +344,7 @@ Database::addFilter( return; }, function (mixed $value, Document $document, Database $database) { - $targetIds = Authorization::skip(fn () => \array_map( + $targetIds = $database->getAuthorization()->skip(fn () => \array_map( fn ($document) => $document->getAttribute('targetInternalId'), $database->find('subscribers', [ Query::equal('topicInternalId', [$document->getSequence()]), diff --git a/app/init/resources.php b/app/init/resources.php index 0892da8a82..8b111e950c 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -152,7 +152,7 @@ App::setResource('queueForMigrations', function (Publisher $publisher) { App::setResource('queueForStatsResources', function (Publisher $publisher) { return new StatsResources($publisher); }, ['publisher']); -App::setResource('platforms', function (Request $request, Document $console, Document $project, Database $dbForPlatform) { +App::setResource('platforms', function (Request $request, Document $console, Document $project, Database $dbForPlatform, Authorization $authorization) { $console->setAttribute('platforms', [ // Always allow current host '$collection' => ID::custom('platforms'), 'name' => 'Current Host', @@ -200,9 +200,9 @@ App::setResource('platforms', function (Request $request, Document $console, Doc // Safe if rule with same project ID exists if (!empty($origin)) { if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { - $rule = Authorization::skip(fn () => $dbForPlatform->getDocument('rules', md5($origin ?? ''))); + $rule = $authorization->skip(fn () => $dbForPlatform->getDocument('rules', md5($origin ?? ''))); } else { - $rule = Authorization::skip( + $rule = $authorization->skip( fn () => $dbForPlatform->find('rules', [ Query::equal('domain', [$origin]), Query::limit(1) @@ -224,17 +224,18 @@ App::setResource('platforms', function (Request $request, Document $console, Doc ...$console->getAttribute('platforms', []), ...$project->getAttribute('platforms', []), ]; -}, ['request', 'console', 'project', 'dbForPlatform']); +}, ['request', 'console', 'project', 'dbForPlatform', 'authorization']); -App::setResource('user', function ($mode, $project, $console, $request, $response, $dbForProject, $dbForPlatform) { +App::setResource('user', function ($mode, $project, $console, $request, $response, $dbForProject, $dbForPlatform, $authorization) { /** @var Appwrite\Utopia\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Document $project */ /** @var Utopia\Database\Database $dbForProject */ /** @var Utopia\Database\Database $dbForPlatform */ + /** @var Utopia\Database\Authorization $authorization */ /** @var string $mode */ - Authorization::setDefaultStatus(true); + $authorization->setDefaultStatus(true); Auth::setCookieName('a_session_' . $project->getId()); @@ -298,7 +299,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons // if (APP_MODE_ADMIN === $mode) { // if ($user->find('teamInternalId', $project->getAttribute('teamInternalId'), 'memberships')) { - // Authorization::setDefaultStatus(false); // Cancel security segmentation for admin users. + // $authorization->setDefaultStatus(false); // Cancel security segmentation for admin users. // } else { // $user = new Document([]); // } @@ -336,9 +337,9 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons $dbForPlatform->setMetadata('user', $user->getId()); return $user; -}, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform']); +}, ['mode', 'project', 'console', 'request', 'response', 'dbForProject', 'dbForPlatform', 'authorization']); -App::setResource('project', function ($dbForPlatform, $request, $console) { +App::setResource('project', function ($dbForPlatform, $request, $console, $authorization) { /** @var Appwrite\Utopia\Request $request */ /** @var Utopia\Database\Database $dbForPlatform */ /** @var Utopia\Database\Document $console */ @@ -349,10 +350,10 @@ App::setResource('project', function ($dbForPlatform, $request, $console) { return $console; } - $project = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); + $project = $authorization->skip(fn () => $dbForPlatform->getDocument('projects', $projectId)); return $project; -}, ['dbForPlatform', 'request', 'console']); +}, ['dbForPlatform', 'request', 'console', 'authorization']); App::setResource('session', function (Document $user) { if ($user->isEmpty()) { @@ -379,7 +380,11 @@ App::setResource('console', function () { return new Document(Config::getParam('console')); }, []); -App::setResource('dbForProject', function (Group $pools, Database $dbForPlatform, Cache $cache, Document $project) { +App::setResource('authorization', function () { + return new Authorization(); +}, []); + +App::setResource('dbForProject', function (Group $pools, Database $dbForPlatform, Cache $cache, Document $project, Authorization $authorization) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -395,6 +400,7 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForPlatform $database = new Database($adapter, $cache); $database + ->setAuthorization($authorization) ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_API) @@ -415,13 +421,15 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForPlatform } return $database; -}, ['pools', 'dbForPlatform', 'cache', 'project']); +}, ['pools', 'dbForPlatform', 'cache', 'project', 'authorization']); + +App::setResource('dbForPlatform', function (Group $pools, Cache $cache, Authorization $authorization) { -App::setResource('dbForPlatform', function (Group $pools, Cache $cache) { $adapter = new DatabasePool($pools->get('console')); $database = new Database($adapter, $cache); $database + ->setAuthorization($authorization) ->setNamespace('_console') ->setMetadata('host', \gethostname()) ->setMetadata('project', 'console') @@ -429,12 +437,12 @@ App::setResource('dbForPlatform', function (Group $pools, Cache $cache) { ->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES); return $database; -}, ['pools', 'cache']); +}, ['pools', 'cache', 'authorization']); -App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache) { +App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache, Authorization $authorization) { $databases = []; - return function (Document $project) use ($pools, $dbForPlatform, $cache, &$databases) { + return function (Document $project) use ($pools, $dbForPlatform, $cache, $authorization, &$databases) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -446,8 +454,9 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform $dsn = new DSN('mysql://' . $project->getAttribute('database')); } - $configure = (function (Database $database) use ($project, $dsn) { + $configure = (function (Database $database) use ($project, $dsn, $authorization) { $database + ->setAuthorization($authorization) ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_API) @@ -481,12 +490,12 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform return $database; }; -}, ['pools', 'dbForPlatform', 'cache']); +}, ['pools', 'dbForPlatform', 'cache', 'authorization']); -App::setResource('getLogsDB', function (Group $pools, Cache $cache) { +App::setResource('getLogsDB', function (Group $pools, Cache $cache, Authorization $authorization) { $database = null; - return function (?Document $project = null) use ($pools, $cache, &$database) { + return function (?Document $project = null) use ($pools, $cache, $authorization, &$database) { if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { $database->setTenant((int) $project->getSequence()); return $database; @@ -496,6 +505,7 @@ App::setResource('getLogsDB', function (Group $pools, Cache $cache) { $database = new Database($adapter, $cache); $database + ->setAuthorization($authorization) ->setSharedTables(true) ->setNamespace('logsV1') ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_API) @@ -508,7 +518,7 @@ App::setResource('getLogsDB', function (Group $pools, Cache $cache) { return $database; }; -}, ['pools', 'cache']); +}, ['pools', 'cache', 'authorization']); App::setResource('telemetry', fn () => new NoTelemetry()); @@ -702,7 +712,7 @@ App::setResource('promiseAdapter', function ($register) { return $register->get('promiseAdapter'); }, ['register']); -App::setResource('schema', function ($utopia, $dbForProject) { +App::setResource('schema', function ($utopia, $dbForProject, $authorization) { $complexity = function (int $complexity, array $args) { $queries = Query::parseQueries($args['queries'] ?? []); @@ -712,8 +722,8 @@ App::setResource('schema', function ($utopia, $dbForProject) { return $complexity * $limit; }; - $attributes = function (int $limit, int $offset) use ($dbForProject) { - $attrs = Authorization::skip(fn () => $dbForProject->find('attributes', [ + $attributes = function (int $limit, int $offset) use ($dbForProject, $authorization) { + $attrs = $authorization->skip(fn () => $dbForProject->find('attributes', [ Query::limit($limit), Query::offset($offset), ])); @@ -787,7 +797,7 @@ App::setResource('schema', function ($utopia, $dbForProject) { $urls, $params, ); -}, ['utopia', 'dbForProject']); +}, ['utopia', 'dbForProject', 'authorization']); App::setResource('contributors', function () { $path = 'app/config/contributors.json'; @@ -833,7 +843,7 @@ App::setResource('smsRates', function () { return []; }); -App::setResource('devKey', function (Request $request, Document $project, array $servers, Database $dbForPlatform) { +App::setResource('devKey', function (Request $request, Document $project, array $servers, Database $dbForPlatform, Authorization $authorization) { $devKey = $request->getHeader('x-appwrite-dev-key', $request->getParam('devKey', '')); // Check if given key match project's development keys @@ -852,7 +862,7 @@ App::setResource('devKey', function (Request $request, Document $project, array $accessedAt = $key->getAttribute('accessedAt', 0); if (empty($accessedAt) || DatabaseDateTime::formatTz(DatabaseDateTime::addSeconds(new \DateTime(), -APP_KEY_ACCESS)) > $accessedAt) { $key->setAttribute('accessedAt', DatabaseDateTime::now()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('devKeys', $key->getId(), $key)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('devKeys', $key->getId(), $key)); $dbForPlatform->purgeCachedDocument('projects', $project->getId()); } @@ -869,14 +879,14 @@ App::setResource('devKey', function (Request $request, Document $project, array /** Update access time as well */ $key->setAttribute('accessedAt', DatabaseDateTime::now()); - $key = Authorization::skip(fn () => $dbForPlatform->updateDocument('devKeys', $key->getId(), $key)); + $key = $authorization->skip(fn () => $dbForPlatform->updateDocument('devKeys', $key->getId(), $key)); $dbForPlatform->purgeCachedDocument('projects', $project->getId()); } } return $key; -}, ['request', 'project', 'servers', 'dbForPlatform']); +}, ['request', 'project', 'servers', 'dbForPlatform', 'authorization']); -App::setResource('team', function (Document $project, Database $dbForPlatform, App $utopia, Request $request) { +App::setResource('team', function (Document $project, Database $dbForPlatform, App $utopia, Request $request, Authorization $authorization) { $teamInternalId = ''; if ($project->getId() !== 'console') { $teamInternalId = $project->getAttribute('teamInternalId', ''); @@ -886,7 +896,7 @@ App::setResource('team', function (Document $project, Database $dbForPlatform, A if (str_starts_with($path, '/v1/projects/:projectId')) { $uri = $request->getURI(); $pid = explode('/', $uri)[3]; - $p = Authorization::skip(fn () => $dbForPlatform->getDocument('projects', $pid)); + $p = $authorization->skip(fn () => $dbForPlatform->getDocument('projects', $pid)); $teamInternalId = $p->getAttribute('teamInternalId', ''); } elseif ($path === '/v1/projects') { $teamId = $request->getParam('teamId', ''); @@ -895,7 +905,7 @@ App::setResource('team', function (Document $project, Database $dbForPlatform, A return new Document([]); } - $team = Authorization::skip(fn () => $dbForPlatform->getDocument('teams', $teamId)); + $team = $authorization->skip(fn () => $dbForPlatform->getDocument('teams', $teamId)); return $team; } } @@ -904,14 +914,14 @@ App::setResource('team', function (Document $project, Database $dbForPlatform, A return new Document([]); } - $team = Authorization::skip(function () use ($dbForPlatform, $teamInternalId) { + $team = $authorization->skip(function () use ($dbForPlatform, $teamInternalId) { return $dbForPlatform->findOne('teams', [ Query::equal('$sequence', [$teamInternalId]), ]); }); return $team; -}, ['project', 'dbForPlatform', 'utopia', 'request']); +}, ['project', 'dbForPlatform', 'utopia', 'request', 'authorization']); App::setResource( 'isResourceBlocked', @@ -949,7 +959,7 @@ App::setResource('apiKey', function (Request $request, Document $project): ?Key App::setResource('executor', fn () => new Executor()); -App::setResource('resourceToken', function ($project, $dbForProject, $request) { +App::setResource('resourceToken', function ($project, $dbForProject, $request, Authorization $authorization) { $tokenJWT = $request->getParam('token'); if (!empty($tokenJWT) && !$project->isEmpty()) { // JWT authentication @@ -966,7 +976,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { return new Document([]); } - $token = Authorization::skip(fn () => $dbForProject->getDocument('resourceTokens', $tokenId)); + $token = $authorization->skip(fn () => $dbForProject->getDocument('resourceTokens', $tokenId)); if ($token->isEmpty()) { return new Document([]); @@ -984,7 +994,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { } return match ($token->getAttribute('resourceType')) { - TOKENS_RESOURCE_TYPE_FILES => (function () use ($token, $dbForProject) { + TOKENS_RESOURCE_TYPE_FILES => (function () use ($token, $dbForProject, $authorization) { $sequences = explode(':', $token->getAttribute('resourceInternalId')); $ids = explode(':', $token->getAttribute('resourceId')); @@ -995,7 +1005,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { $accessedAt = $token->getAttribute('accessedAt', 0); if (empty($accessedAt) || DatabaseDateTime::formatTz(DatabaseDateTime::addSeconds(new \DateTime(), -APP_RESOURCE_TOKEN_ACCESS)) > $accessedAt) { $token->setAttribute('accessedAt', DatabaseDateTime::now()); - Authorization::skip(fn () => $dbForProject->updateDocument('resourceTokens', $token->getId(), $token)); + $authorization->skip(fn () => $dbForProject->updateDocument('resourceTokens', $token->getId(), $token)); } return new Document([ @@ -1010,7 +1020,7 @@ App::setResource('resourceToken', function ($project, $dbForProject, $request) { }; } return new Document([]); -}, ['project', 'dbForProject', 'request']); +}, ['project', 'dbForProject', 'request', 'authorization']); App::setResource('httpReferrer', function (Request $request): string { $referrer = $request->getReferer(); @@ -1043,6 +1053,6 @@ App::setResource('httpReferrerSafe', function (Request $request, string $httpRef return $referrer; }, ['request', 'httpReferrer', 'platforms', 'dbForPlatform', 'project', 'utopia']); -App::setResource('transactionState', function (Database $dbForProject) { - return new TransactionState($dbForProject); -}, ['dbForProject']); +App::setResource('transactionState', function (Database $dbForProject, Authorization $authorization) { + return new TransactionState($dbForProject, $authorization); +}, ['dbForProject', 'authorization']); diff --git a/app/realtime.php b/app/realtime.php index e18ab8e10d..75aa625348 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -28,7 +28,6 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\DSN\DSN; use Utopia\Logger\Log; use Utopia\Pools\Group; @@ -299,7 +298,7 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume 'value' => '{}' ]); - $statsDocument = Authorization::skip(fn () => $database->createDocument('realtime', $document)); + $statsDocument = $database->getAuthorization()->skip(fn () => $database->createDocument('realtime', $document)); break; } catch (Throwable) { Console::warning("Collection not ready. Retrying connection ({$attempts})..."); @@ -329,7 +328,7 @@ $server->onStart(function () use ($stats, $register, $containerId, &$statsDocume ->setAttribute('timestamp', DateTime::now()) ->setAttribute('value', json_encode($payload)); - Authorization::skip(fn () => $database->updateDocument('realtime', $statsDocument->getId(), $statsDocument)); + $database->getAuthorization()->skip(fn () => $database->updateDocument('realtime', $statsDocument->getId(), $statsDocument)); } catch (Throwable $th) { $logError($th, "updateWorkerDocument"); } @@ -360,7 +359,7 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, $payload = []; - $list = Authorization::skip(fn () => $database->find('realtime', [ + $list = $database->getAuthorization()->skip(fn () => $database->find('realtime', [ Query::greaterThan('timestamp', DateTime::addSeconds(new \DateTime(), -15)), ])); @@ -454,12 +453,11 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats, if ($realtime->hasSubscriber($projectId, 'user:' . $userId)) { $connection = array_key_first(reset($realtime->subscriptions[$projectId]['user:' . $userId])); $consoleDatabase = getConsoleDB(); - $project = Authorization::skip(fn () => $consoleDatabase->getDocument('projects', $projectId)); + $project = $consoleDatabase->getAuthorization()->skip(fn () => $consoleDatabase->getDocument('projects', $projectId)); $database = getProjectDB($project); $user = $database->getDocument('users', $userId); - - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $database->getAuthorization()); $channels = $realtime->connections[$connection]['channels']; $realtime->unsubscribe($connection); @@ -515,6 +513,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, try { /** @var Document $project */ $project = $app->getResource('project'); + $authorization = $app->getResource('authorization'); /* * Project Check @@ -526,7 +525,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, if ( array_key_exists('realtime', $project->getAttribute('apis', [])) && !$project->getAttribute('apis', [])['realtime'] - && !(Auth::isPrivilegedUser(Authorization::getRoles()) || Auth::isAppUser(Authorization::getRoles())) + && !(Auth::isPrivilegedUser($authorization->getRoles()) || Auth::isAppUser($authorization->getRoles())) ) { throw new AppwriteException(AppwriteException::GENERAL_API_DISABLED); } @@ -563,7 +562,7 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, throw new Exception(Exception::REALTIME_POLICY_VIOLATION, $originValidator->getDescription()); } - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $authorization); $channels = Realtime::convertChannels($request->getQuery('channels', []), $user->getId()); @@ -637,8 +636,8 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re $database = getConsoleDB(); if ($projectId !== 'console') { - $project = Authorization::skip(fn () => $database->getDocument('projects', $projectId)); - $database = getProjectDB($project); + $project = $database->getAuthorization()->skip(fn () => $database->getDocument('projects', $projectId)); + $database = getProjectDB($project, $database->getAuthorization()); } else { $project = null; } @@ -692,7 +691,7 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re throw new Exception(Exception::REALTIME_MESSAGE_FORMAT_INVALID, 'Session is not valid.'); } - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $database->getAuthorization()); $channels = Realtime::convertChannels(array_flip($realtime->connections[$connection]['channels']), $user->getId()); $realtime->subscribe($realtime->connections[$connection]['projectId'], $connection, $roles, $channels); diff --git a/app/worker.php b/app/worker.php index 60f44ab33f..ef04ffec05 100644 --- a/app/worker.php +++ b/app/worker.php @@ -45,19 +45,28 @@ use Utopia\System\System; use Utopia\Telemetry\Adapter as Telemetry; use Utopia\Telemetry\Adapter\None as NoTelemetry; -Authorization::disable(); Runtime::enableCoroutine(); Server::setResource('register', fn () => $register); -Server::setResource('dbForPlatform', function (Cache $cache, Registry $register) { +Server::setResource('authorization', function () { + $authorization = new Authorization(); + $authorization->disable(); + return $authorization; +}, []); + +Server::setResource('dbForPlatform', function (Cache $cache, Registry $register, Authorization $authorization) { $pools = $register->get('pools'); $adapter = new DatabasePool($pools->get('console')); $dbForPlatform = new Database($adapter, $cache); - $dbForPlatform->setNamespace('_console'); + + $dbForPlatform + ->setAuthorization($authorization) + ->setNamespace('_console'); + return $dbForPlatform; -}, ['cache', 'register']); +}, ['cache', 'register', 'authorization']); Server::setResource('project', function (Message $message, Database $dbForPlatform) { $payload = $message->getPayload() ?? []; @@ -70,7 +79,7 @@ Server::setResource('project', function (Message $message, Database $dbForPlatfo return $dbForPlatform->getDocument('projects', $project->getId()); }, ['message', 'dbForPlatform']); -Server::setResource('dbForProject', function (Cache $cache, Registry $register, Message $message, Document $project, Database $dbForPlatform) { +Server::setResource('dbForProject', function (Cache $cache, Registry $register, Message $message, Document $project, Database $dbForPlatform, Authorization $authorization) { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -101,15 +110,17 @@ Server::setResource('dbForProject', function (Cache $cache, Registry $register, ->setNamespace('_' . $project->getSequence()); } - $database->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER); + $database + ->setAuthorization($authorization) + ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER); return $database; -}, ['cache', 'register', 'message', 'project', 'dbForPlatform']); +}, ['cache', 'register', 'message', 'project', 'dbForPlatform', 'authorization']); -Server::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache) { +Server::setResource('getProjectDB', function (Group $pools, Database $dbForPlatform, $cache, Authorization $authorization) { $databases = []; // TODO: @Meldiron This should probably be responsibility of utopia-php/pools - return function (Document $project) use ($pools, $dbForPlatform, $cache, &$databases): Database { + return function (Document $project) use ($pools, $dbForPlatform, $cache, $authorization, &$databases): Database { if ($project->isEmpty() || $project->getId() === 'console') { return $dbForPlatform; } @@ -123,7 +134,7 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForPlatf if (isset($databases[$dsn->getHost()])) { $database = $databases[$dsn->getHost()]; - + $database->setAuthorization($authorization); $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); if (\in_array($dsn->getHost(), $sharedTables)) { @@ -160,15 +171,17 @@ Server::setResource('getProjectDB', function (Group $pools, Database $dbForPlatf ->setNamespace('_' . $project->getSequence()); } - $database->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER); + $database + ->setAuthorization($authorization) + ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER); return $database; }; -}, ['pools', 'dbForPlatform', 'cache']); +}, ['pools', 'dbForPlatform', 'cache', 'authorization']); -Server::setResource('getLogsDB', function (Group $pools, Cache $cache) { +Server::setResource('getLogsDB', function (Group $pools, Cache $cache, Authorization $authorization) { $database = null; - return function (?Document $project = null) use ($pools, $cache, $database) { + return function (?Document $project = null) use ($pools, $cache, $database, $authorization) { if ($database !== null && $project !== null && !$project->isEmpty() && $project->getId() !== 'console') { $database->setTenant((int)$project->getSequence()); return $database; @@ -178,6 +191,7 @@ Server::setResource('getLogsDB', function (Group $pools, Cache $cache) { $database = new Database($adapter, $cache); $database + ->setAuthorization($authorization) ->setSharedTables(true) ->setNamespace('logsV1') ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS_WORKER) @@ -190,7 +204,7 @@ Server::setResource('getLogsDB', function (Group $pools, Cache $cache) { return $database; }; -}, ['pools', 'cache']); +}, ['pools', 'cache', 'authorization']); Server::setResource('abuseRetention', function () { return time() - (int) System::getEnv('_APP_MAINTENANCE_RETENTION_ABUSE', 86400); // 1 day @@ -478,7 +492,8 @@ $worker ->inject('log') ->inject('pools') ->inject('project') - ->action(function (Throwable $error, ?Logger $logger, Log $log, Group $pools, Document $project) use ($worker, $queueName) { + ->inject('authorization') + ->action(function (Throwable $error, ?Logger $logger, Log $log, Group $pools, Document $project, Authorization $authorization) use ($worker, $queueName) { $version = System::getEnv('_APP_VERSION', 'UNKNOWN'); if ($logger) { @@ -494,7 +509,7 @@ $worker $log->addExtra('file', $error->getFile()); $log->addExtra('line', $error->getLine()); $log->addExtra('trace', $error->getTraceAsString()); - $log->addExtra('roles', Authorization::getRoles()); + $log->addExtra('roles', $authorization->getRoles()); $isProduction = System::getEnv('_APP_ENV', 'development') === 'production'; $log->setEnvironment($isProduction ? Log::ENVIRONMENT_PRODUCTION : Log::ENVIRONMENT_STAGING); diff --git a/composer.json b/composer.json index 62abce9ca2..1cff497d08 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.13.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "3.*", + "utopia-php/database": "4.*", "utopia-php/detector": "0.2.*", "utopia-php/domains": "0.9.*", "utopia-php/emails": "0.6.*", diff --git a/composer.lock b/composer.lock index 87eaf28a3e..afbbaa516d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad28b7155175986191bd19bbcd13d623", + "content-hash": "3b502f78f5e31f2ea7b4c69e3301283a", "packages": [ { "name": "adhocore/jwt", @@ -161,16 +161,16 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.19.1", + "version": "0.19.2", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "7bd0cc3cb97de625d7b07230bd91b121f88e72ae" + "reference": "e5c142519df5aced37de9c302971c29c079ce3d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/runtimes/zipball/7bd0cc3cb97de625d7b07230bd91b121f88e72ae", - "reference": "7bd0cc3cb97de625d7b07230bd91b121f88e72ae", + "url": "https://api.github.com/repos/appwrite/runtimes/zipball/e5c142519df5aced37de9c302971c29c079ce3d9", + "reference": "e5c142519df5aced37de9c302971c29c079ce3d9", "shasum": "" }, "require": { @@ -210,9 +210,9 @@ ], "support": { "issues": "https://github.com/appwrite/runtimes/issues", - "source": "https://github.com/appwrite/runtimes/tree/0.19.1" + "source": "https://github.com/appwrite/runtimes/tree/0.19.2" }, - "time": "2025-05-27T07:12:56+00:00" + "time": "2025-11-11T13:44:44+00:00" }, { "name": "beberlei/assert", @@ -756,16 +756,16 @@ }, { "name": "google/protobuf", - "version": "v4.33.0", + "version": "v4.33.1", "source": { "type": "git", "url": "https://github.com/protocolbuffers/protobuf-php.git", - "reference": "b50269e23204e5ae859a326ec3d90f09efe3047d" + "reference": "0cd73ccf0cd26c3e72299cce1ea6144091a57e12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/b50269e23204e5ae859a326ec3d90f09efe3047d", - "reference": "b50269e23204e5ae859a326ec3d90f09efe3047d", + "url": "https://api.github.com/repos/protocolbuffers/protobuf-php/zipball/0cd73ccf0cd26c3e72299cce1ea6144091a57e12", + "reference": "0cd73ccf0cd26c3e72299cce1ea6144091a57e12", "shasum": "" }, "require": { @@ -794,9 +794,9 @@ "proto" ], "support": { - "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.0" + "source": "https://github.com/protocolbuffers/protobuf-php/tree/v4.33.1" }, - "time": "2025-10-15T20:10:28+00:00" + "time": "2025-11-12T21:58:05+00:00" }, { "name": "league/csv", @@ -961,16 +961,16 @@ }, { "name": "mongodb/mongodb", - "version": "2.1.1", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/mongodb/mongo-php-library.git", - "reference": "f399d24905dd42f97dfe0af9706129743ef247ac" + "reference": "0a2472ba9cbb932f7e43a8770aedb2fc30612a67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/f399d24905dd42f97dfe0af9706129743ef247ac", - "reference": "f399d24905dd42f97dfe0af9706129743ef247ac", + "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/0a2472ba9cbb932f7e43a8770aedb2fc30612a67", + "reference": "0a2472ba9cbb932f7e43a8770aedb2fc30612a67", "shasum": "" }, "require": { @@ -986,7 +986,7 @@ "require-dev": { "doctrine/coding-standard": "^12.0", "phpunit/phpunit": "^10.5.35", - "rector/rector": "^1.2", + "rector/rector": "^2.1.4", "squizlabs/php_codesniffer": "^3.7", "vimeo/psalm": "6.5.*" }, @@ -1032,9 +1032,9 @@ ], "support": { "issues": "https://github.com/mongodb/mongo-php-library/issues", - "source": "https://github.com/mongodb/mongo-php-library/tree/2.1.1" + "source": "https://github.com/mongodb/mongo-php-library/tree/2.1.2" }, - "time": "2025-08-13T20:50:05+00:00" + "time": "2025-10-06T12:12:40+00:00" }, { "name": "mustangostang/spyc", @@ -2673,16 +2673,16 @@ }, { "name": "symfony/http-client", - "version": "v7.3.4", + "version": "v7.3.6", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "4b62871a01c49457cf2a8e560af7ee8a94b87a62" + "reference": "3c0a55a2c8e21e30a37022801c11c7ab5a6cb2de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/4b62871a01c49457cf2a8e560af7ee8a94b87a62", - "reference": "4b62871a01c49457cf2a8e560af7ee8a94b87a62", + "url": "https://api.github.com/repos/symfony/http-client/zipball/3c0a55a2c8e21e30a37022801c11c7ab5a6cb2de", + "reference": "3c0a55a2c8e21e30a37022801c11c7ab5a6cb2de", "shasum": "" }, "require": { @@ -2749,7 +2749,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.3.4" + "source": "https://github.com/symfony/http-client/tree/v7.3.6" }, "funding": [ { @@ -2769,7 +2769,7 @@ "type": "tidelift" } ], - "time": "2025-09-11T10:12:26+00:00" + "time": "2025-11-05T17:41:46+00:00" }, { "name": "symfony/http-client-contracts", @@ -3176,16 +3176,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.6.0", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4" + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4", - "reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43", + "reference": "45112560a3ba2d715666a509a0bc9521d10b6c43", "shasum": "" }, "require": { @@ -3239,7 +3239,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.6.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.6.1" }, "funding": [ { @@ -3250,12 +3250,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-25T09:37:31+00:00" + "time": "2025-07-15T11:30:57+00:00" }, { "name": "tbachert/spi", @@ -3547,21 +3551,21 @@ }, { "name": "utopia-php/audit", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "8c17065c2473d4ca799f65585ca74eb53e1be211" + "reference": "15656acfddb9d6f03c395b73673fc66c793c10a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/8c17065c2473d4ca799f65585ca74eb53e1be211", - "reference": "8c17065c2473d4ca799f65585ca74eb53e1be211", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/15656acfddb9d6f03c395b73673fc66c793c10a5", + "reference": "15656acfddb9d6f03c395b73673fc66c793c10a5", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "*" + "utopia-php/database": "4.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3588,9 +3592,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/1.0.2" + "source": "https://github.com/utopia-php/audit/tree/1.0.3" }, - "time": "2025-10-20T07:14:26+00:00" + "time": "2025-11-04T11:27:42+00:00" }, { "name": "utopia-php/cache", @@ -3840,16 +3844,16 @@ }, { "name": "utopia-php/database", - "version": "3.1.5", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "76568b81f25d89fc1e0c53f0370f139130eeb939" + "reference": "fe7a1326ad623609e65587fe8c01a630a7075fee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/76568b81f25d89fc1e0c53f0370f139130eeb939", - "reference": "76568b81f25d89fc1e0c53f0370f139130eeb939", + "url": "https://api.github.com/repos/utopia-php/database/zipball/fe7a1326ad623609e65587fe8c01a630a7075fee", + "reference": "fe7a1326ad623609e65587fe8c01a630a7075fee", "shasum": "" }, "require": { @@ -3892,9 +3896,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/3.1.5" + "source": "https://github.com/utopia-php/database/tree/4.3.0" }, - "time": "2025-11-05T10:17:55+00:00" + "time": "2025-11-14T03:43:10+00:00" }, { "name": "utopia-php/detector", @@ -3943,22 +3947,24 @@ }, { "name": "utopia-php/dns", - "version": "1.1.0", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/dns.git", - "reference": "d6eca184883262bdcb4261e57491c91b16079b9a" + "reference": "1e6b4bac735329c9e5ec69a6a5d899ec2d050707" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/dns/zipball/d6eca184883262bdcb4261e57491c91b16079b9a", - "reference": "d6eca184883262bdcb4261e57491c91b16079b9a", + "url": "https://api.github.com/repos/utopia-php/dns/zipball/1e6b4bac735329c9e5ec69a6a5d899ec2d050707", + "reference": "1e6b4bac735329c9e5ec69a6a5d899ec2d050707", "shasum": "" }, "require": { "php": ">=8.3", "utopia-php/console": "0.0.*", - "utopia-php/telemetry": "0.1.*" + "utopia-php/domains": "0.9.*", + "utopia-php/telemetry": "0.1.*", + "utopia-php/validators": "^0.0.2" }, "require-dev": { "laravel/pint": "1.25.*", @@ -3992,9 +3998,9 @@ ], "support": { "issues": "https://github.com/utopia-php/dns/issues", - "source": "https://github.com/utopia-php/dns/tree/1.1.0" + "source": "https://github.com/utopia-php/dns/tree/1.1.3" }, - "time": "2025-11-03T22:49:02+00:00" + "time": "2025-11-06T19:08:29+00:00" }, { "name": "utopia-php/domains", @@ -4206,16 +4212,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.28", + "version": "0.33.29", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "5aaa94d406577b0059ad28c78022606890dc6de0" + "reference": "6e63939fdb33b847f92839499cd6e8df626c278d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/5aaa94d406577b0059ad28c78022606890dc6de0", - "reference": "5aaa94d406577b0059ad28c78022606890dc6de0", + "url": "https://api.github.com/repos/utopia-php/http/zipball/6e63939fdb33b847f92839499cd6e8df626c278d", + "reference": "6e63939fdb33b847f92839499cd6e8df626c278d", "shasum": "" }, "require": { @@ -4247,9 +4253,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.28" + "source": "https://github.com/utopia-php/http/tree/0.33.29" }, - "time": "2025-09-25T10:44:24+00:00" + "time": "2025-11-14T06:33:29+00:00" }, { "name": "utopia-php/image", @@ -4454,16 +4460,16 @@ }, { "name": "utopia-php/migration", - "version": "1.3.3", + "version": "1.3.4", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "731b3a963c58c30e0b2368695d57a7e8fcb7455c" + "reference": "81e1be6ff3257d4768aa7483cf64628836244a09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/731b3a963c58c30e0b2368695d57a7e8fcb7455c", - "reference": "731b3a963c58c30e0b2368695d57a7e8fcb7455c", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/81e1be6ff3257d4768aa7483cf64628836244a09", + "reference": "81e1be6ff3257d4768aa7483cf64628836244a09", "shasum": "" }, "require": { @@ -4472,7 +4478,7 @@ "ext-openssl": "*", "php": ">=8.1", "utopia-php/console": "0.0.*", - "utopia-php/database": "3.*", + "utopia-php/database": "4.*", "utopia-php/dsn": "0.2.*", "utopia-php/storage": "0.18.*" }, @@ -4503,9 +4509,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/1.3.3" + "source": "https://github.com/utopia-php/migration/tree/1.3.4" }, - "time": "2025-10-28T04:02:08+00:00" + "time": "2025-11-04T11:28:50+00:00" }, { "name": "utopia-php/mongo", @@ -5377,16 +5383,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "1.5.1", + "version": "1.5.5", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "cd712674e34136f706e9170641ed6f4ce160e772" + "reference": "1f3686e41a2d10829220b74f54c80a770e9f968a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/cd712674e34136f706e9170641ed6f4ce160e772", - "reference": "cd712674e34136f706e9170641ed6f4ce160e772", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/1f3686e41a2d10829220b74f54c80a770e9f968a", + "reference": "1f3686e41a2d10829220b74f54c80a770e9f968a", "shasum": "" }, "require": { @@ -5422,9 +5428,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/1.5.1" + "source": "https://github.com/appwrite/sdk-generator/tree/1.5.5" }, - "time": "2025-11-04T09:55:47+00:00" + "time": "2025-11-14T05:56:33+00:00" }, { "name": "doctrine/annotations", @@ -6077,24 +6083,24 @@ }, { "name": "phpbench/container", - "version": "2.2.2", + "version": "2.2.3", "source": { "type": "git", "url": "https://github.com/phpbench/container.git", - "reference": "a59b929e00b87b532ca6d0edd8eca0967655af33" + "reference": "0c7b2d36c1ea53fe27302fb8873ded7172047196" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/container/zipball/a59b929e00b87b532ca6d0edd8eca0967655af33", - "reference": "a59b929e00b87b532ca6d0edd8eca0967655af33", + "url": "https://api.github.com/repos/phpbench/container/zipball/0c7b2d36c1ea53fe27302fb8873ded7172047196", + "reference": "0c7b2d36c1ea53fe27302fb8873ded7172047196", "shasum": "" }, "require": { "psr/container": "^1.0|^2.0", - "symfony/options-resolver": "^4.2 || ^5.0 || ^6.0 || ^7.0" + "symfony/options-resolver": "^4.2 || ^5.0 || ^6.0 || ^7.0 || ^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.16", + "php-cs-fixer/shim": "^3.89", "phpstan/phpstan": "^0.12.52", "phpunit/phpunit": "^8" }, @@ -6122,22 +6128,22 @@ "description": "Simple, configurable, service container.", "support": { "issues": "https://github.com/phpbench/container/issues", - "source": "https://github.com/phpbench/container/tree/2.2.2" + "source": "https://github.com/phpbench/container/tree/2.2.3" }, - "time": "2023-10-30T13:38:26+00:00" + "time": "2025-11-06T09:05:13+00:00" }, { "name": "phpbench/phpbench", - "version": "1.4.2", + "version": "1.4.3", "source": { "type": "git", "url": "https://github.com/phpbench/phpbench.git", - "reference": "bb61ae6c54b3d58642be154eb09f4e73c3511018" + "reference": "b641dde59d969ea42eed70a39f9b51950bc96878" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpbench/phpbench/zipball/bb61ae6c54b3d58642be154eb09f4e73c3511018", - "reference": "bb61ae6c54b3d58642be154eb09f4e73c3511018", + "url": "https://api.github.com/repos/phpbench/phpbench/zipball/b641dde59d969ea42eed70a39f9b51950bc96878", + "reference": "b641dde59d969ea42eed70a39f9b51950bc96878", "shasum": "" }, "require": { @@ -6152,26 +6158,26 @@ "phpbench/container": "^2.2", "psr/log": "^1.1 || ^2.0 || ^3.0", "seld/jsonlint": "^1.1", - "symfony/console": "^6.1 || ^7.0", - "symfony/filesystem": "^6.1 || ^7.0", - "symfony/finder": "^6.1 || ^7.0", - "symfony/options-resolver": "^6.1 || ^7.0", - "symfony/process": "^6.1 || ^7.0", + "symfony/console": "^6.1 || ^7.0 || ^8.0", + "symfony/filesystem": "^6.1 || ^7.0 || ^8.0", + "symfony/finder": "^6.1 || ^7.0 || ^8.0", + "symfony/options-resolver": "^6.1 || ^7.0 || ^8.0", + "symfony/process": "^6.1 || ^7.0 || ^8.0", "webmozart/glob": "^4.6" }, "require-dev": { "dantleech/invoke": "^2.0", "ergebnis/composer-normalize": "^2.39", - "friendsofphp/php-cs-fixer": "^3.0", "jangregor/phpstan-prophecy": "^1.0", + "php-cs-fixer/shim": "^3.9", "phpspec/prophecy": "^1.22", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^10.4 || ^11.0", "rector/rector": "^1.2", - "symfony/error-handler": "^6.1 || ^7.0", - "symfony/var-dumper": "^6.1 || ^7.0" + "symfony/error-handler": "^6.1 || ^7.0 || ^8.0", + "symfony/var-dumper": "^6.1 || ^7.0 || ^8.0" }, "suggest": { "ext-xdebug": "For Xdebug profiling extension." @@ -6214,7 +6220,7 @@ ], "support": { "issues": "https://github.com/phpbench/phpbench/issues", - "source": "https://github.com/phpbench/phpbench/tree/1.4.2" + "source": "https://github.com/phpbench/phpbench/tree/1.4.3" }, "funding": [ { @@ -6222,7 +6228,7 @@ "type": "github" } ], - "time": "2025-10-26T14:21:59+00:00" + "time": "2025-11-06T19:07:31+00:00" }, { "name": "phpstan/phpstan", @@ -7871,16 +7877,16 @@ }, { "name": "symfony/console", - "version": "v7.3.5", + "version": "v7.3.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cdb80fa5869653c83cfe1a9084a673b6daf57ea7" + "reference": "c28ad91448f86c5f6d9d2c70f0cf68bf135f252a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cdb80fa5869653c83cfe1a9084a673b6daf57ea7", - "reference": "cdb80fa5869653c83cfe1a9084a673b6daf57ea7", + "url": "https://api.github.com/repos/symfony/console/zipball/c28ad91448f86c5f6d9d2c70f0cf68bf135f252a", + "reference": "c28ad91448f86c5f6d9d2c70f0cf68bf135f252a", "shasum": "" }, "require": { @@ -7945,7 +7951,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.3.5" + "source": "https://github.com/symfony/console/tree/v7.3.6" }, "funding": [ { @@ -7965,20 +7971,20 @@ "type": "tidelift" } ], - "time": "2025-10-14T15:46:26+00:00" + "time": "2025-11-04T01:21:42+00:00" }, { "name": "symfony/filesystem", - "version": "v7.3.2", + "version": "v7.3.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd" + "reference": "e9bcfd7837928ab656276fe00464092cc9e1826a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/edcbb768a186b5c3f25d0643159a787d3e63b7fd", - "reference": "edcbb768a186b5c3f25d0643159a787d3e63b7fd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/e9bcfd7837928ab656276fe00464092cc9e1826a", + "reference": "e9bcfd7837928ab656276fe00464092cc9e1826a", "shasum": "" }, "require": { @@ -8015,7 +8021,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v7.3.2" + "source": "https://github.com/symfony/filesystem/tree/v7.3.6" }, "funding": [ { @@ -8035,7 +8041,7 @@ "type": "tidelift" } ], - "time": "2025-07-07T08:17:47+00:00" + "time": "2025-11-05T09:52:27+00:00" }, { "name": "symfony/finder", @@ -8712,16 +8718,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + "reference": "d74205c497bfbca49f34d4bc4c19c17e22db4ebb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/d74205c497bfbca49f34d4bc4c19c17e22db4ebb", + "reference": "d74205c497bfbca49f34d4bc4c19c17e22db4ebb", "shasum": "" }, "require": { @@ -8750,7 +8756,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + "source": "https://github.com/theseer/tokenizer/tree/1.3.0" }, "funding": [ { @@ -8758,7 +8764,7 @@ "type": "github" } ], - "time": "2024-03-03T12:36:25+00:00" + "time": "2025-11-13T13:44:09+00:00" }, { "name": "twig/twig", @@ -8891,7 +8897,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8915,5 +8921,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/docs/examples/1.8.x/client-android/java/avatars/get-screenshot.md b/docs/examples/1.8.x/client-android/java/avatars/get-screenshot.md new file mode 100644 index 0000000000..077716f523 --- /dev/null +++ b/docs/examples/1.8.x/client-android/java/avatars/get-screenshot.md @@ -0,0 +1,41 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; + +Client client = new Client(context) + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>"); // Your project ID + +Avatars avatars = new Avatars(client); + +avatars.getScreenshot( + "https://example.com", // url + mapOf( "a" to "b" ), // headers (optional) + 1, // viewportWidth (optional) + 1, // viewportHeight (optional) + 0.1, // scale (optional) + theme.LIGHT, // theme (optional) + "<USER_AGENT>", // userAgent (optional) + false, // fullpage (optional) + "<LOCALE>", // locale (optional) + timezone.AFRICA_ABIDJAN, // timezone (optional) + -90, // latitude (optional) + -180, // longitude (optional) + 0, // accuracy (optional) + false, // touch (optional) + listOf(), // permissions (optional) + 0, // sleep (optional) + 0, // width (optional) + 0, // height (optional) + -1, // quality (optional) + output.JPG, // output (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/1.8.x/client-android/kotlin/avatars/get-screenshot.md b/docs/examples/1.8.x/client-android/kotlin/avatars/get-screenshot.md new file mode 100644 index 0000000000..014ca90fd8 --- /dev/null +++ b/docs/examples/1.8.x/client-android/kotlin/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Avatars + +val client = Client(context) + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + +val avatars = Avatars(client) + +val result = avatars.getScreenshot( + url = "https://example.com", + headers = mapOf( "a" to "b" ), // (optional) + viewportWidth = 1, // (optional) + viewportHeight = 1, // (optional) + scale = 0.1, // (optional) + theme = theme.LIGHT, // (optional) + userAgent = "<USER_AGENT>", // (optional) + fullpage = false, // (optional) + locale = "<LOCALE>", // (optional) + timezone = timezone.AFRICA_ABIDJAN, // (optional) + latitude = -90, // (optional) + longitude = -180, // (optional) + accuracy = 0, // (optional) + touch = false, // (optional) + permissions = listOf(), // (optional) + sleep = 0, // (optional) + width = 0, // (optional) + height = 0, // (optional) + quality = -1, // (optional) + output = output.JPG, // (optional) +) \ No newline at end of file diff --git a/docs/examples/1.8.x/client-apple/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-apple/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..7f4ef5da5c --- /dev/null +++ b/docs/examples/1.8.x/client-apple/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + +let avatars = Avatars(client) + +let bytes = try await avatars.getScreenshot( + url: "https://example.com", + headers: [:], // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .light, // optional + userAgent: "<USER_AGENT>", // optional + fullpage: false, // optional + locale: "<LOCALE>", // optional + timezone: .africaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .jpg // optional +) + diff --git a/docs/examples/1.8.x/client-flutter/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-flutter/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..768cb8f271 --- /dev/null +++ b/docs/examples/1.8.x/client-flutter/examples/avatars/get-screenshot.md @@ -0,0 +1,65 @@ +import 'package:appwrite/appwrite.dart'; + +Client client = Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +Avatars avatars = Avatars(client); + +// Downloading file +UInt8List bytes = await avatars.getScreenshot( + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .light, // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: .africaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .jpg, // optional +) + +final file = File('path_to_file/filename.ext'); +file.writeAsBytesSync(bytes); + +// Displaying image preview +FutureBuilder( + future: avatars.getScreenshot( + url:'https://example.com' , + headers:{} , // optional + viewportWidth:1 , // optional + viewportHeight:1 , // optional + scale:0.1 , // optional + theme: .light, // optional + userAgent:'<USER_AGENT>' , // optional + fullpage:false , // optional + locale:'<LOCALE>' , // optional + timezone: .africaAbidjan, // optional + latitude:-90 , // optional + longitude:-180 , // optional + accuracy:0 , // optional + touch:false , // optional + permissions:[] , // optional + sleep:0 , // optional + width:0 , // optional + height:0 , // optional + quality:-1 , // optional + output: .jpg, // optional +), // Works for both public file and private file, for private files you need to be logged in + builder: (context, snapshot) { + return snapshot.hasData && snapshot.data != null + ? Image.memory(snapshot.data) + : CircularProgressIndicator(); + } +); diff --git a/docs/examples/1.8.x/client-graphql/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-graphql/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/examples/1.8.x/client-react-native/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-react-native/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..7482b4cf0e --- /dev/null +++ b/docs/examples/1.8.x/client-react-native/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import { Client, Avatars, , , } from "react-native-appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const avatars = new Avatars(client); + +const result = avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .Light, // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: .AfricaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .Jpg // optional +}); + +console.log(result); diff --git a/docs/examples/1.8.x/client-rest/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-rest/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..b4c31ca100 --- /dev/null +++ b/docs/examples/1.8.x/client-rest/examples/avatars/get-screenshot.md @@ -0,0 +1,6 @@ +GET /v1/avatars/screenshots HTTP/1.1 +Host: cloud.appwrite.io +X-Appwrite-Response-Format: 1.8.0 +X-Appwrite-Project: <YOUR_PROJECT_ID> +X-Appwrite-Session: +X-Appwrite-JWT: <YOUR_JWT> diff --git a/docs/examples/1.8.x/client-web/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/client-web/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..c4722be633 --- /dev/null +++ b/docs/examples/1.8.x/client-web/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import { Client, Avatars, , , } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const avatars = new Avatars(client); + +const result = avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .Light, // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: .AfricaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .Jpg // optional +}); + +console.log(result); diff --git a/docs/examples/1.8.x/console-cli/examples/migrations/create-csv-export.md b/docs/examples/1.8.x/console-cli/examples/migrations/create-csv-export.md index e56afae786..61eceabcd8 100644 --- a/docs/examples/1.8.x/console-cli/examples/migrations/create-csv-export.md +++ b/docs/examples/1.8.x/console-cli/examples/migrations/create-csv-export.md @@ -1,4 +1,3 @@ appwrite migrations create-csv-export \ --resource-id <ID1:ID2> \ - --bucket-id <BUCKET_ID> \ --filename <FILENAME> diff --git a/docs/examples/1.8.x/console-web/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/console-web/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..3a9437515d --- /dev/null +++ b/docs/examples/1.8.x/console-web/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +import { Client, Avatars, , , } from "@appwrite.io/console"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const avatars = new Avatars(client); + +const result = avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .Light, // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: .AfricaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .Jpg // optional +}); + +console.log(result); diff --git a/docs/examples/1.8.x/console-web/examples/migrations/create-csv-export.md b/docs/examples/1.8.x/console-web/examples/migrations/create-csv-export.md index e1b909a852..89f779fc4c 100644 --- a/docs/examples/1.8.x/console-web/examples/migrations/create-csv-export.md +++ b/docs/examples/1.8.x/console-web/examples/migrations/create-csv-export.md @@ -8,7 +8,6 @@ const migrations = new Migrations(client); const result = await migrations.createCSVExport({ resourceId: '<ID1:ID2>', - bucketId: '<BUCKET_ID>', filename: '<FILENAME>', columns: [], // optional queries: [], // optional diff --git a/docs/examples/1.8.x/server-dart/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-dart/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..7630648f98 --- /dev/null +++ b/docs/examples/1.8.x/server-dart/examples/avatars/get-screenshot.md @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +Avatars avatars = Avatars(client); + +UInt8List result = await avatars.getScreenshot( + url: 'https://example.com', + headers: {}, // (optional) + viewportWidth: 1, // (optional) + viewportHeight: 1, // (optional) + scale: 0.1, // (optional) + theme: .light, // (optional) + userAgent: '<USER_AGENT>', // (optional) + fullpage: false, // (optional) + locale: '<LOCALE>', // (optional) + timezone: .africaAbidjan, // (optional) + latitude: -90, // (optional) + longitude: -180, // (optional) + accuracy: 0, // (optional) + touch: false, // (optional) + permissions: [], // (optional) + sleep: 0, // (optional) + width: 0, // (optional) + height: 0, // (optional) + quality: -1, // (optional) + output: .jpg, // (optional) +); diff --git a/docs/examples/1.8.x/server-dotnet/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-dotnet/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..f5c3542a97 --- /dev/null +++ b/docs/examples/1.8.x/server-dotnet/examples/avatars/get-screenshot.md @@ -0,0 +1,34 @@ +using Appwrite; +using Appwrite.Enums; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("<YOUR_PROJECT_ID>") // Your project ID + .SetSession(""); // The user session to authenticate with + +Avatars avatars = new Avatars(client); + +byte[] result = await avatars.GetScreenshot( + url: "https://example.com", + headers: [object], // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .Light, // optional + userAgent: "<USER_AGENT>", // optional + fullpage: false, // optional + locale: "<LOCALE>", // optional + timezone: .AfricaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: new List<string>(), // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .Jpg // optional +); \ No newline at end of file diff --git a/docs/examples/1.8.x/server-go/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-go/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..ac425fbc4f --- /dev/null +++ b/docs/examples/1.8.x/server-go/examples/avatars/get-screenshot.md @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "github.com/appwrite/sdk-for-go/client" + "github.com/appwrite/sdk-for-go/avatars" +) + +client := client.New( + client.WithEndpoint("https://<REGION>.cloud.appwrite.io/v1") + client.WithProject("<YOUR_PROJECT_ID>") + client.WithSession("") +) + +service := avatars.New(client) + +response, error := service.GetScreenshot( + "https://example.com", + avatars.WithGetScreenshotHeaders(map[string]interface{}{}), + avatars.WithGetScreenshotViewportWidth(1), + avatars.WithGetScreenshotViewportHeight(1), + avatars.WithGetScreenshotScale(0.1), + avatars.WithGetScreenshotTheme("light"), + avatars.WithGetScreenshotUserAgent("<USER_AGENT>"), + avatars.WithGetScreenshotFullpage(false), + avatars.WithGetScreenshotLocale("<LOCALE>"), + avatars.WithGetScreenshotTimezone("africa/abidjan"), + avatars.WithGetScreenshotLatitude(-90), + avatars.WithGetScreenshotLongitude(-180), + avatars.WithGetScreenshotAccuracy(0), + avatars.WithGetScreenshotTouch(false), + avatars.WithGetScreenshotPermissions([]interface{}{}), + avatars.WithGetScreenshotSleep(0), + avatars.WithGetScreenshotWidth(0), + avatars.WithGetScreenshotHeight(0), + avatars.WithGetScreenshotQuality(-1), + avatars.WithGetScreenshotOutput("jpg"), +) diff --git a/docs/examples/1.8.x/server-graphql/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-graphql/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/examples/1.8.x/server-kotlin/java/avatars/get-screenshot.md b/docs/examples/1.8.x/server-kotlin/java/avatars/get-screenshot.md new file mode 100644 index 0000000000..cf734af3b2 --- /dev/null +++ b/docs/examples/1.8.x/server-kotlin/java/avatars/get-screenshot.md @@ -0,0 +1,42 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Avatars; + +Client client = new Client() + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setSession(""); // The user session to authenticate with + +Avatars avatars = new Avatars(client); + +avatars.getScreenshot( + "https://example.com", // url + mapOf( "a" to "b" ), // headers (optional) + 1, // viewportWidth (optional) + 1, // viewportHeight (optional) + 0.1, // scale (optional) + .LIGHT, // theme (optional) + "<USER_AGENT>", // userAgent (optional) + false, // fullpage (optional) + "<LOCALE>", // locale (optional) + .AFRICA_ABIDJAN, // timezone (optional) + -90, // latitude (optional) + -180, // longitude (optional) + 0, // accuracy (optional) + false, // touch (optional) + listOf(), // permissions (optional) + 0, // sleep (optional) + 0, // width (optional) + 0, // height (optional) + -1, // quality (optional) + .JPG, // output (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + System.out.println(result); + }) +); + diff --git a/docs/examples/1.8.x/server-kotlin/kotlin/avatars/get-screenshot.md b/docs/examples/1.8.x/server-kotlin/kotlin/avatars/get-screenshot.md new file mode 100644 index 0000000000..96032bb8a4 --- /dev/null +++ b/docs/examples/1.8.x/server-kotlin/kotlin/avatars/get-screenshot.md @@ -0,0 +1,33 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Avatars + +val client = Client() + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setSession("") // The user session to authenticate with + +val avatars = Avatars(client) + +val result = avatars.getScreenshot( + url = "https://example.com", + headers = mapOf( "a" to "b" ), // optional + viewportWidth = 1, // optional + viewportHeight = 1, // optional + scale = 0.1, // optional + theme = "light", // optional + userAgent = "<USER_AGENT>", // optional + fullpage = false, // optional + locale = "<LOCALE>", // optional + timezone = "africa/abidjan", // optional + latitude = -90, // optional + longitude = -180, // optional + accuracy = 0, // optional + touch = false, // optional + permissions = listOf(), // optional + sleep = 0, // optional + width = 0, // optional + height = 0, // optional + quality = -1, // optional + output = "jpg" // optional +) diff --git a/docs/examples/1.8.x/server-nodejs/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-nodejs/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..5f7b40cece --- /dev/null +++ b/docs/examples/1.8.x/server-nodejs/examples/avatars/get-screenshot.md @@ -0,0 +1,31 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>') // Your project ID + .setSession(''); // The user session to authenticate with + +const avatars = new sdk.Avatars(client); + +const result = await avatars.getScreenshot({ + url: 'https://example.com', + headers: {}, // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: sdk..Light, // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: sdk..AfricaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: sdk..Jpg // optional +}); diff --git a/docs/examples/1.8.x/server-php/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-php/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..b9dfd23862 --- /dev/null +++ b/docs/examples/1.8.x/server-php/examples/avatars/get-screenshot.md @@ -0,0 +1,37 @@ +<?php + +use Appwrite\Client; +use Appwrite\Services\Avatars; +use Appwrite\Enums\Theme; +use Appwrite\Enums\Timezone; +use Appwrite\Enums\Output; + +$client = (new Client()) + ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('<YOUR_PROJECT_ID>') // Your project ID + ->setSession(''); // The user session to authenticate with + +$avatars = new Avatars($client); + +$result = $avatars->getScreenshot( + url: 'https://example.com', + headers: [], // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: Theme::LIGHT(), // optional + userAgent: '<USER_AGENT>', // optional + fullpage: false, // optional + locale: '<LOCALE>', // optional + timezone: Timezone::AFRICAABIDJAN(), // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: Output::JPG() // optional +); \ No newline at end of file diff --git a/docs/examples/1.8.x/server-php/examples/databases/create-relationship-attribute.md b/docs/examples/1.8.x/server-php/examples/databases/create-relationship-attribute.md index caccd36031..551fe17a9d 100644 --- a/docs/examples/1.8.x/server-php/examples/databases/create-relationship-attribute.md +++ b/docs/examples/1.8.x/server-php/examples/databases/create-relationship-attribute.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\Databases; use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/databases/update-relationship-attribute.md b/docs/examples/1.8.x/server-php/examples/databases/update-relationship-attribute.md index 01783cf3bf..a4d6888711 100644 --- a/docs/examples/1.8.x/server-php/examples/databases/update-relationship-attribute.md +++ b/docs/examples/1.8.x/server-php/examples/databases/update-relationship-attribute.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Databases; +use Appwrite\Enums\RelationMutate; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/functions/create-execution.md b/docs/examples/1.8.x/server-php/examples/functions/create-execution.md index cd11b5ea6e..9c12e87374 100644 --- a/docs/examples/1.8.x/server-php/examples/functions/create-execution.md +++ b/docs/examples/1.8.x/server-php/examples/functions/create-execution.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; +use Appwrite\Enums\ExecutionMethod; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/functions/create.md b/docs/examples/1.8.x/server-php/examples/functions/create.md index 3d37b8068e..f7176871bd 100644 --- a/docs/examples/1.8.x/server-php/examples/functions/create.md +++ b/docs/examples/1.8.x/server-php/examples/functions/create.md @@ -2,7 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; -use Appwrite\Enums\; +use Appwrite\Enums\Runtime; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,7 +14,7 @@ $functions = new Functions($client); $result = $functions->create( functionId: '<FUNCTION_ID>', name: '<NAME>', - runtime: ::NODE145(), + runtime: Runtime::NODE145(), execute: ["any"], // optional events: [], // optional schedule: '', // optional diff --git a/docs/examples/1.8.x/server-php/examples/functions/get-deployment-download.md b/docs/examples/1.8.x/server-php/examples/functions/get-deployment-download.md index 7b3e18751e..a06f97b662 100644 --- a/docs/examples/1.8.x/server-php/examples/functions/get-deployment-download.md +++ b/docs/examples/1.8.x/server-php/examples/functions/get-deployment-download.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; +use Appwrite\Enums\DeploymentDownloadType; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/functions/update.md b/docs/examples/1.8.x/server-php/examples/functions/update.md index ea8d863ae5..da5ee88931 100644 --- a/docs/examples/1.8.x/server-php/examples/functions/update.md +++ b/docs/examples/1.8.x/server-php/examples/functions/update.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; +use Appwrite\Enums\Runtime; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,7 +14,7 @@ $functions = new Functions($client); $result = $functions->update( functionId: '<FUNCTION_ID>', name: '<NAME>', - runtime: ::NODE145(), // optional + runtime: Runtime::NODE145(), // optional execute: ["any"], // optional events: [], // optional schedule: '', // optional diff --git a/docs/examples/1.8.x/server-php/examples/health/get-failed-jobs.md b/docs/examples/1.8.x/server-php/examples/health/get-failed-jobs.md index 02959db3b5..63bc1c83f2 100644 --- a/docs/examples/1.8.x/server-php/examples/health/get-failed-jobs.md +++ b/docs/examples/1.8.x/server-php/examples/health/get-failed-jobs.md @@ -2,7 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Health; -use Appwrite\Enums\; +use Appwrite\Enums\Name; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,6 +12,6 @@ $client = (new Client()) $health = new Health($client); $result = $health->getFailedJobs( - name: ::V1DATABASE(), + name: Name::V1DATABASE(), threshold: null // optional ); \ No newline at end of file diff --git a/docs/examples/1.8.x/server-php/examples/messaging/create-push.md b/docs/examples/1.8.x/server-php/examples/messaging/create-push.md index 51fc0d0a92..614c758c80 100644 --- a/docs/examples/1.8.x/server-php/examples/messaging/create-push.md +++ b/docs/examples/1.8.x/server-php/examples/messaging/create-push.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Messaging; +use Appwrite\Enums\MessagePriority; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/messaging/create-smtp-provider.md b/docs/examples/1.8.x/server-php/examples/messaging/create-smtp-provider.md index 017f20cc15..953bbcf44f 100644 --- a/docs/examples/1.8.x/server-php/examples/messaging/create-smtp-provider.md +++ b/docs/examples/1.8.x/server-php/examples/messaging/create-smtp-provider.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Messaging; +use Appwrite\Enums\SmtpEncryption; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/messaging/update-push.md b/docs/examples/1.8.x/server-php/examples/messaging/update-push.md index 05a51783c9..0fea9a135f 100644 --- a/docs/examples/1.8.x/server-php/examples/messaging/update-push.md +++ b/docs/examples/1.8.x/server-php/examples/messaging/update-push.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Messaging; +use Appwrite\Enums\MessagePriority; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/messaging/update-smtp-provider.md b/docs/examples/1.8.x/server-php/examples/messaging/update-smtp-provider.md index 3bc80d2789..495f332131 100644 --- a/docs/examples/1.8.x/server-php/examples/messaging/update-smtp-provider.md +++ b/docs/examples/1.8.x/server-php/examples/messaging/update-smtp-provider.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Messaging; +use Appwrite\Enums\SmtpEncryption; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/sites/create.md b/docs/examples/1.8.x/server-php/examples/sites/create.md index 4a1c3a4fcb..6f1fc5ac27 100644 --- a/docs/examples/1.8.x/server-php/examples/sites/create.md +++ b/docs/examples/1.8.x/server-php/examples/sites/create.md @@ -2,8 +2,9 @@ use Appwrite\Client; use Appwrite\Services\Sites; -use Appwrite\Enums\; -use Appwrite\Enums\; +use Appwrite\Enums\Framework; +use Appwrite\Enums\BuildRuntime; +use Appwrite\Enums\Adapter; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint @@ -15,15 +16,15 @@ $sites = new Sites($client); $result = $sites->create( siteId: '<SITE_ID>', name: '<NAME>', - framework: ::ANALOG(), - buildRuntime: ::NODE145(), + framework: Framework::ANALOG(), + buildRuntime: BuildRuntime::NODE145(), enabled: false, // optional logging: false, // optional timeout: 1, // optional installCommand: '<INSTALL_COMMAND>', // optional buildCommand: '<BUILD_COMMAND>', // optional outputDirectory: '<OUTPUT_DIRECTORY>', // optional - adapter: ::STATIC(), // optional + adapter: Adapter::STATIC(), // optional installationId: '<INSTALLATION_ID>', // optional fallbackFile: '<FALLBACK_FILE>', // optional providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional diff --git a/docs/examples/1.8.x/server-php/examples/sites/get-deployment-download.md b/docs/examples/1.8.x/server-php/examples/sites/get-deployment-download.md index 91c6b6e52a..61fad0bd74 100644 --- a/docs/examples/1.8.x/server-php/examples/sites/get-deployment-download.md +++ b/docs/examples/1.8.x/server-php/examples/sites/get-deployment-download.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Sites; +use Appwrite\Enums\DeploymentDownloadType; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/sites/update.md b/docs/examples/1.8.x/server-php/examples/sites/update.md index f2ca54a987..d2a6c9d256 100644 --- a/docs/examples/1.8.x/server-php/examples/sites/update.md +++ b/docs/examples/1.8.x/server-php/examples/sites/update.md @@ -2,7 +2,9 @@ use Appwrite\Client; use Appwrite\Services\Sites; -use Appwrite\Enums\; +use Appwrite\Enums\Framework; +use Appwrite\Enums\BuildRuntime; +use Appwrite\Enums\Adapter; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,15 +16,15 @@ $sites = new Sites($client); $result = $sites->update( siteId: '<SITE_ID>', name: '<NAME>', - framework: ::ANALOG(), + framework: Framework::ANALOG(), enabled: false, // optional logging: false, // optional timeout: 1, // optional installCommand: '<INSTALL_COMMAND>', // optional buildCommand: '<BUILD_COMMAND>', // optional outputDirectory: '<OUTPUT_DIRECTORY>', // optional - buildRuntime: ::NODE145(), // optional - adapter: ::STATIC(), // optional + buildRuntime: BuildRuntime::NODE145(), // optional + adapter: Adapter::STATIC(), // optional fallbackFile: '<FALLBACK_FILE>', // optional installationId: '<INSTALLATION_ID>', // optional providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional diff --git a/docs/examples/1.8.x/server-php/examples/storage/create-bucket.md b/docs/examples/1.8.x/server-php/examples/storage/create-bucket.md index 2e7cc1d15c..3d4f717e4d 100644 --- a/docs/examples/1.8.x/server-php/examples/storage/create-bucket.md +++ b/docs/examples/1.8.x/server-php/examples/storage/create-bucket.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Storage; +use Appwrite\Enums\Compression; use Appwrite\Permission; use Appwrite\Role; @@ -20,7 +21,7 @@ $result = $storage->createBucket( enabled: false, // optional maximumFileSize: 1, // optional allowedFileExtensions: [], // optional - compression: ::NONE(), // optional + compression: Compression::NONE(), // optional encryption: false, // optional antivirus: false // optional ); \ No newline at end of file diff --git a/docs/examples/1.8.x/server-php/examples/storage/get-file-preview.md b/docs/examples/1.8.x/server-php/examples/storage/get-file-preview.md index 0b65fc326a..aaa15a22fb 100644 --- a/docs/examples/1.8.x/server-php/examples/storage/get-file-preview.md +++ b/docs/examples/1.8.x/server-php/examples/storage/get-file-preview.md @@ -2,6 +2,8 @@ use Appwrite\Client; use Appwrite\Services\Storage; +use Appwrite\Enums\ImageGravity; +use Appwrite\Enums\ImageFormat; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/storage/update-bucket.md b/docs/examples/1.8.x/server-php/examples/storage/update-bucket.md index 819798cb95..77f4262c2d 100644 --- a/docs/examples/1.8.x/server-php/examples/storage/update-bucket.md +++ b/docs/examples/1.8.x/server-php/examples/storage/update-bucket.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Storage; +use Appwrite\Enums\Compression; use Appwrite\Permission; use Appwrite\Role; @@ -20,7 +21,7 @@ $result = $storage->updateBucket( enabled: false, // optional maximumFileSize: 1, // optional allowedFileExtensions: [], // optional - compression: ::NONE(), // optional + compression: Compression::NONE(), // optional encryption: false, // optional antivirus: false // optional ); \ No newline at end of file diff --git a/docs/examples/1.8.x/server-php/examples/tablesdb/create-relationship-column.md b/docs/examples/1.8.x/server-php/examples/tablesdb/create-relationship-column.md index 031d1fd1aa..7f9a06cc03 100644 --- a/docs/examples/1.8.x/server-php/examples/tablesdb/create-relationship-column.md +++ b/docs/examples/1.8.x/server-php/examples/tablesdb/create-relationship-column.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\TablesDB; use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/tablesdb/update-relationship-column.md b/docs/examples/1.8.x/server-php/examples/tablesdb/update-relationship-column.md index 834dc18cee..cc2e2ccaef 100644 --- a/docs/examples/1.8.x/server-php/examples/tablesdb/update-relationship-column.md +++ b/docs/examples/1.8.x/server-php/examples/tablesdb/update-relationship-column.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\TablesDB; +use Appwrite\Enums\RelationMutate; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-php/examples/users/create-sha-user.md b/docs/examples/1.8.x/server-php/examples/users/create-sha-user.md index 0b9a27ed8e..812bcd5eb5 100644 --- a/docs/examples/1.8.x/server-php/examples/users/create-sha-user.md +++ b/docs/examples/1.8.x/server-php/examples/users/create-sha-user.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Users; +use Appwrite\Enums\PasswordHash; $client = (new Client()) ->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint diff --git a/docs/examples/1.8.x/server-python/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-python/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..34bdf8ac7a --- /dev/null +++ b/docs/examples/1.8.x/server-python/examples/avatars/get-screenshot.md @@ -0,0 +1,32 @@ +from appwrite.client import Client +from appwrite.services.avatars import Avatars + +client = Client() +client.set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint +client.set_project('<YOUR_PROJECT_ID>') # Your project ID +client.set_session('') # The user session to authenticate with + +avatars = Avatars(client) + +result = avatars.get_screenshot( + url = 'https://example.com', + headers = {}, # optional + viewport_width = 1, # optional + viewport_height = 1, # optional + scale = 0.1, # optional + theme = .LIGHT, # optional + user_agent = '<USER_AGENT>', # optional + fullpage = False, # optional + locale = '<LOCALE>', # optional + timezone = .AFRICA_ABIDJAN, # optional + latitude = -90, # optional + longitude = -180, # optional + accuracy = 0, # optional + touch = False, # optional + permissions = [], # optional + sleep = 0, # optional + width = 0, # optional + height = 0, # optional + quality = -1, # optional + output = .JPG # optional +) diff --git a/docs/examples/1.8.x/server-rest/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-rest/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..0ab16b59e6 --- /dev/null +++ b/docs/examples/1.8.x/server-rest/examples/avatars/get-screenshot.md @@ -0,0 +1,7 @@ +GET /v1/avatars/screenshots HTTP/1.1 +Host: cloud.appwrite.io +X-Appwrite-Response-Format: 1.8.0 +X-Appwrite-Project: <YOUR_PROJECT_ID> +X-Appwrite-Session: +X-Appwrite-Key: <YOUR_API_KEY> +X-Appwrite-JWT: <YOUR_JWT> diff --git a/docs/examples/1.8.x/server-ruby/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-ruby/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..f2af537fe8 --- /dev/null +++ b/docs/examples/1.8.x/server-ruby/examples/avatars/get-screenshot.md @@ -0,0 +1,33 @@ +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://<REGION>.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('<YOUR_PROJECT_ID>') # Your project ID + .set_session('') # The user session to authenticate with + +avatars = Avatars.new(client) + +result = avatars.get_screenshot( + url: 'https://example.com', + headers: {}, # optional + viewport_width: 1, # optional + viewport_height: 1, # optional + scale: 0.1, # optional + theme: ::LIGHT, # optional + user_agent: '<USER_AGENT>', # optional + fullpage: false, # optional + locale: '<LOCALE>', # optional + timezone: ::AFRICA_ABIDJAN, # optional + latitude: -90, # optional + longitude: -180, # optional + accuracy: 0, # optional + touch: false, # optional + permissions: [], # optional + sleep: 0, # optional + width: 0, # optional + height: 0, # optional + quality: -1, # optional + output: ::JPG # optional +) diff --git a/docs/examples/1.8.x/server-swift/examples/avatars/get-screenshot.md b/docs/examples/1.8.x/server-swift/examples/avatars/get-screenshot.md new file mode 100644 index 0000000000..3aa1661093 --- /dev/null +++ b/docs/examples/1.8.x/server-swift/examples/avatars/get-screenshot.md @@ -0,0 +1,33 @@ +import Appwrite +import AppwriteEnums + +let client = Client() + .setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("<YOUR_PROJECT_ID>") // Your project ID + .setSession("") // The user session to authenticate with + +let avatars = Avatars(client) + +let bytes = try await avatars.getScreenshot( + url: "https://example.com", + headers: [:], // optional + viewportWidth: 1, // optional + viewportHeight: 1, // optional + scale: 0.1, // optional + theme: .light, // optional + userAgent: "<USER_AGENT>", // optional + fullpage: false, // optional + locale: "<LOCALE>", // optional + timezone: .africaAbidjan, // optional + latitude: -90, // optional + longitude: -180, // optional + accuracy: 0, // optional + touch: false, // optional + permissions: [], // optional + sleep: 0, // optional + width: 0, // optional + height: 0, // optional + quality: -1, // optional + output: .jpg // optional +) + diff --git a/docs/references/migrations/migration-csv-export.md b/docs/references/migrations/migration-csv-export.md index 866faed2d2..069dda895e 100644 --- a/docs/references/migrations/migration-csv-export.md +++ b/docs/references/migrations/migration-csv-export.md @@ -1 +1 @@ -Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in an Appwrite Storage bucket. \ No newline at end of file +Export documents to a CSV file from your Appwrite database. This endpoint allows you to export documents to a CSV file stored in a secure internal bucket. You'll receive an email with a download link when the export is complete. \ No newline at end of file diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index ac1624401c..8e50441769 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 11.1.1 + +* Fix duplicate `enums` during type generation by prefixing them with table name. For example, `enum MyEnum` will now be generated as `enum MyTableMyEnum` to avoid conflicts. + ## 11.1.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/docs/sdks/dart/CHANGELOG.md b/docs/sdks/dart/CHANGELOG.md index 1a2cd6a5be..7fd7227f15 100644 --- a/docs/sdks/dart/CHANGELOG.md +++ b/docs/sdks/dart/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 19.4.0 + +* Add `getScreenshot` method to `Avatars` service +* Add enums `Theme`, `Output` and `Timezone` +* Update runtime enums to add support for `dart39` and `flutter335` runtimes +* Fix passing of `null` values and stripping only non-nullable optional parameters from the request body + ## 19.3.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/docs/sdks/flutter/CHANGELOG.md b/docs/sdks/flutter/CHANGELOG.md index 5ab7d3269a..2f26f34edd 100644 --- a/docs/sdks/flutter/CHANGELOG.md +++ b/docs/sdks/flutter/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 20.3.1 + +* Fix passing of `null` values and stripping only non-nullable optional parameters from the request body + ## 20.3.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/docs/sdks/php/CHANGELOG.md b/docs/sdks/php/CHANGELOG.md index 6e8d4d7545..14a26e441d 100644 --- a/docs/sdks/php/CHANGELOG.md +++ b/docs/sdks/php/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 18.0.1 + +* Fix `TablesDB` service to use correct file name + +## 18.0.0 + +* Fix duplicate methods issue (e.g., `updateMFA` and `updateMfa`) causing build and runtime errors +* Add support for `getScreenshot` method to `Avatars` service +* Add `Output`, `Theme` and `Timezone` enums + ## 17.5.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/docs/tutorials/release-sdks.md b/docs/tutorials/release-sdks.md index 0e03beca71..99c0fa4fd3 100644 --- a/docs/tutorials/release-sdks.md +++ b/docs/tutorials/release-sdks.md @@ -26,27 +26,34 @@ Before releasing SDKs, you need to: To enable SDK releases via GitHub, you need to mount SSH keys and configure GitHub authentication in your Docker environment. -#### Update docker-compose.override.yml +#### Update Dockerfile -Update `docker-compose.override.yml` to mount SSH keys and set environment variables for the `appwrite` service: +Add the following configuration to your `Dockerfile`: + +```dockerfile +ARG GH_TOKEN +ENV GH_TOKEN=your_github_token_here +RUN git config --global user.email "your-email@example.com" +RUN apk add --update --no-cache openssh-client github-cli +``` + +Replace: +- `your_github_token_here` with your GitHub personal access token (with appropriate permissions) +- `your-email@example.com` with your Git email address + +#### Update docker-compose.yml + +Add the SSH key volume mount to the `appwrite` service in `docker-compose.yml`: ```yaml services: appwrite: volumes: - ~/.ssh:/root/.ssh - environment: - - GH_TOKEN=your_github_token_here - - GIT_EMAIL=your-email@example.com + # ... other volumes ``` -Uncomment the volumes section. - -Replace: -- `your_github_token_here` with your GitHub personal access token (with appropriate permissions) -- `your-email@example.com` with your Git email address - -This mounts your SSH keys from the host machine and sets the GitHub token and email as environment variables, allowing the container to authenticate with GitHub. The git configuration is handled automatically at runtime. +This mounts your SSH keys from the host machine, allowing the container to authenticate with GitHub. ### Updating Specs diff --git a/phpunit.xml b/phpunit.xml index 4c4e55ea4e..a8578995c1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -31,6 +31,7 @@ <directory>./tests/e2e/Services/Locale</directory> <directory>./tests/e2e/Services/Projects</directory> <directory>./tests/e2e/Services/Storage</directory> + <directory>./tests/e2e/Services/Tokens</directory> <directory>./tests/e2e/Services/Webhooks</directory> <directory>./tests/e2e/Services/Messaging</directory> <directory>./tests/e2e/Services/Migrations</directory> diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 9af5045fa4..b6676a2843 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -453,11 +453,11 @@ class Auth * @param Document $user * @return array<string> */ - public static function getRoles(Document $user): array + public static function getRoles(Document $user, Authorization $authorization): array { $roles = []; - if (!self::isPrivilegedUser(Authorization::getRoles()) && !self::isAppUser(Authorization::getRoles())) { + if (!self::isPrivilegedUser($authorization->getRoles()) && !self::isAppUser($authorization->getRoles())) { if ($user->getId()) { $roles[] = Role::user($user->getId())->toString(); $roles[] = Role::users()->toString(); diff --git a/src/Appwrite/Databases/TransactionState.php b/src/Appwrite/Databases/TransactionState.php index 23dc6fc2e9..8e098774e6 100644 --- a/src/Appwrite/Databases/TransactionState.php +++ b/src/Appwrite/Databases/TransactionState.php @@ -20,10 +20,12 @@ use Utopia\Database\Validator\Authorization; class TransactionState { private Database $dbForProject; - - public function __construct(Database $dbForProject) + private Authorization $authorization; + /** @var Authorization $authorization */ + public function __construct(Database $dbForProject, Authorization $authorization) { $this->dbForProject = $dbForProject; + $this->authorization = $authorization; } @@ -342,12 +344,12 @@ class TransactionState */ private function getTransactionState(string $transactionId): array { - $transaction = Authorization::skip(fn () => $this->dbForProject->getDocument('transactions', $transactionId)); + $transaction = $this->authorization->skip(fn () => $this->dbForProject->getDocument('transactions', $transactionId)); if ($transaction->isEmpty() || $transaction->getAttribute('status') !== 'pending') { return []; } - $operations = Authorization::skip(fn () => $this->dbForProject->find('transactionLogs', [ + $operations = $this->authorization->skip(fn () => $this->dbForProject->find('transactionLogs', [ Query::equal('transactionInternalId', [$transaction->getSequence()]), Query::orderAsc(), Query::limit(PHP_INT_MAX) diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 588b193df4..4d2db6a3dc 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -99,8 +99,6 @@ abstract class Migration public function __construct() { - Authorization::disable(); - Authorization::setDefaultStatus(false); $this->collections = Config::getParam('collections', []); @@ -128,6 +126,7 @@ abstract class Migration Document $project, Database $dbForProject, Database $dbForPlatform, + Authorization $authorization, ?callable $getProjectDB = null ): self { $this->project = $project; @@ -135,6 +134,9 @@ abstract class Migration $this->dbForPlatform = $dbForPlatform; $this->getProjectDB = $getProjectDB; + $authorization->disable(); + $authorization->setDefaultStatus(false); + return $this; } diff --git a/src/Appwrite/Migration/Version/V23.php b/src/Appwrite/Migration/Version/V23.php index bed744700a..c7be832626 100644 --- a/src/Appwrite/Migration/Version/V23.php +++ b/src/Appwrite/Migration/Version/V23.php @@ -6,6 +6,7 @@ use Appwrite\Migration\Migration; use Exception; use Throwable; use Utopia\CLI\Console; +use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Conflict; @@ -132,6 +133,13 @@ class V23 extends Migration } $this->dbForProject->purgeCachedCollection($id); break; + case 'migrations': + try { + $this->updateMigrateErrorSize(); + } catch (\Throwable $th) { + Console::warning("Failed to migration error attribute size in collection {$id}: {$th->getMessage()}"); + } + case 'buckets': try { $this->createAttributeFromCollection($this->dbForProject, $id, 'transformations'); @@ -209,4 +217,46 @@ class V23 extends Migration } return $document; } + + /** + * Update migration attribute size + * @return void + */ + private function updateMigrateErrorSize(): void + { + + if ($this->project->getId() === 'console') { + return; + } + + // Read-modify-write from the live schema to avoid overwriting unrelated changes. + $migration = $this->dbForProject->getCollection('migrations'); + $attributes = $migration->getAttribute('attributes', []); + $attrsArray = \array_map(fn (Document $doc) => $doc->getArrayCopy(), $attributes); + $errorsIdx = \array_search('errors', \array_column($attrsArray, '$id')); + + if ($errorsIdx === false) { + Console::warning("Skipping: 'errors' attribute not found in migrations collection for project {$this->project->getId()}"); + return; + } + + $desiredSize = 1_000_000; + $migrationAttributes = Config::getParam('collections', [])['projects']['migrations']['attributes'] ?? []; + $migrationIndex = \array_search('errors', \array_column($migrationAttributes, '$id')); + + if ($migrationIndex !== false && isset($migrationAttributes[$migrationIndex]['size'])) { + $desiredSize = (int) $migrationAttributes[$migrationIndex]['size']; + } + + $currentSize = (int) ($attributes[$errorsIdx]['size'] ?? 0); + + if ($currentSize === $desiredSize) { + Console::warning("Skipping: 'errors' attribute already of desired size {$desiredSize} in migrations collection for project {$this->project->getId()}"); + return; + } + $attributes[$errorsIdx]['size'] = $desiredSize; + $migration->setAttribute('attributes', $attributes); + $this->dbForProject->updateDocument($migration->getCollection(), $migration->getId(), $migration); + $this->dbForProject->purgeCachedCollection('migrations'); + } } diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index a538eb1497..8ff5d88dd4 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -142,7 +142,7 @@ class Base extends Action return $deployment; } - public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, Build $queueForBuilds, Document $template, GitHub $github, bool $activate, string $referenceType = 'branch', string $reference = ''): Document + public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, Build $queueForBuilds, Document $template, GitHub $github, bool $activate, Authorization $authorization, string $referenceType = 'branch', string $reference = ''): Document { $deploymentId = ID::unique(); $providerInstallationId = $installation->getAttribute('providerInstallationId', ''); @@ -238,7 +238,7 @@ class Base extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -264,7 +264,7 @@ class Base extends Action $domain = "commit-" . substr($commitDetails['commitHash'], 0, 16) . ".{$sitesDomain}"; $ruleId = md5($domain); try { - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -301,7 +301,7 @@ class Base extends Action $domain = "branch-{$branchPrefix}-{$resourceProjectHash}.{$sitesDomain}"; $ruleId = md5($domain); try { - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php index b67a42adb1..a0f8e9421e 100644 --- a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php +++ b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php @@ -59,6 +59,7 @@ class Get extends Action ->param('type', '', new WhiteList(['rules']), 'Resource type.') ->inject('response') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -66,7 +67,8 @@ class Get extends Action string $value, string $type, Response $response, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { if ($type === 'rules') { $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); @@ -124,7 +126,7 @@ class Get extends Action throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Domain may not start with http:// or https://.'); } - $document = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [ + $document = $authorization->skip(fn () => $dbForPlatform->findOne('rules', [ Query::equal('domain', [$value]), ])); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php index 884b9c5589..728e732cc5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php @@ -2,9 +2,13 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases; -use Utopia\Platform\Action as UtopiaAction; +use Appwrite\Extend\Exception; +use Appwrite\Platform\Action as AppwriteAction; +use Utopia\Database\Database; +use Utopia\Database\Document; +use Utopia\Database\Operator; -class Action extends UtopiaAction +class Action extends AppwriteAction { private string $context = 'legacy'; @@ -13,11 +17,81 @@ class Action extends UtopiaAction return $this->context; } - public function setHttpPath(string $path): UtopiaAction + public function setHttpPath(string $path): AppwriteAction { if (\str_contains($path, '/tablesdb')) { $this->context = 'tablesdb'; } return parent::setHttpPath($path); } + + /** + * Parse operator strings in data array and convert them to Operator objects. + * + * @param array $data The data array that may contain operator JSON strings or arrays + * @param Document $collection The collection document to check for relationship attributes + * @return array The data array with operators converted to Operator objects + * @throws Exception If an operator string is invalid + */ + protected function parseOperators(array $data, Document $collection): array + { + $relationshipKeys = []; + foreach ($collection->getAttribute('attributes', []) as $attribute) { + if ($attribute->getAttribute('type') === Database::VAR_RELATIONSHIP) { + $relationshipKeys[$attribute->getAttribute('key')] = true; + } + } + + foreach ($data as $key => $value) { + if (!\is_string($key)) { + if (\is_array($value)) { + $data[$key] = $this->parseOperators($value, $collection); + } + continue; + } + + if (\str_starts_with($key, '$')) { + continue; + } + + if (isset($relationshipKeys[$key])) { + continue; + } + + // Handle operator as JSON string (from API requests) + if (\is_string($value)) { + $decoded = \json_decode($value, true); + + if ( + \is_array($decoded) && + isset($decoded['method']) && + \is_string($decoded['method']) && + Operator::isMethod($decoded['method']) + ) { + try { + $data[$key] = Operator::parse($value); + } catch (\Exception $e) { + throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid operator for attribute "' . $key . '": ' . $e->getMessage()); + } + } + } + // Handle operator as array (from transaction logs after serialization) + elseif ( + \is_array($value) && + isset($value['method']) && + \is_string($value['method']) && + Operator::isMethod($value['method']) + ) { + try { + $data[$key] = Operator::parseOperator($value); + } catch (\Exception $e) { + throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid operator for attribute "' . $key . '": ' . $e->getMessage()); + } + } elseif (\is_array($value)) { + $data[$key] = $this->parseOperators($value, $collection); + } + } + + return $data; + } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php index 48124e2a11..6c5305f299 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php @@ -292,7 +292,7 @@ abstract class Action extends UtopiaAction }; } - protected function createAttribute(string $databaseId, string $collectionId, Document $attribute, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): Document + protected function createAttribute(string $databaseId, string $collectionId, Document $attribute, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): Document { $key = $attribute->getAttribute('key'); $type = $attribute->getAttribute('type', ''); @@ -310,7 +310,7 @@ abstract class Action extends UtopiaAction throw new Exception($this->getSpatialTypeNotSupportedException()); } - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -371,7 +371,7 @@ abstract class Action extends UtopiaAction \in_array($attribute->getAttribute('type'), Database::SPATIAL_TYPES) && $attribute->getAttribute('required') ) { - $hasData = !Authorization::skip(fn () => $dbForProject + $hasData = !$authorization->skip(fn () => $dbForProject ->findOne('database_' . $db->getSequence() . '_collection_' . $collection->getSequence())) ->isEmpty(); @@ -472,9 +472,9 @@ abstract class Action extends UtopiaAction return $attribute; } - protected function updateAttribute(string $databaseId, string $collectionId, string $key, Database $dbForProject, Event $queueForEvents, string $type, int $size = null, string $filter = null, string|bool|int|float|array $default = null, bool $required = null, int|float|null $min = null, int|float|null $max = null, array $elements = null, array $options = [], string $newKey = null): Document + protected function updateAttribute(string $databaseId, string $collectionId, string $key, Database $dbForProject, Event $queueForEvents, Authorization $authorization, string $type, int $size = null, string $filter = null, string|bool|int|float|array $default = null, bool $required = null, int|float|null $min = null, int|float|null $max = null, array $elements = null, array $options = [], string $newKey = null): Document { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php index 6c8e5dcf3d..4f233fcdb4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php @@ -12,10 +12,12 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends Action { @@ -62,16 +64,17 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Boolean(), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new Boolean()), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, @@ -80,7 +83,7 @@ class Create extends Action 'required' => $required, 'default' => $default, 'array' => $array, - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php index d4724ea551..27a3622fe2 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -64,14 +65,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Boolean()), 'Default value for attribute when not provided. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New attribute key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New attribute key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?bool $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -79,6 +81,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_BOOLEAN, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Create.php index 1f2098e7af..d96314855c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Create.php @@ -12,11 +12,13 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Datetime as DatetimeValidator; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends Action { @@ -63,16 +65,17 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection).') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, fn (Database $dbForProject) => new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime()), 'Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required.', true, ['dbForProject']) + ->param('default', null, fn (Database $dbForProject) => new Nullable(new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime())), 'Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required.', true, ['dbForProject']) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute( $databaseId, @@ -89,7 +92,8 @@ class Create extends Action $response, $dbForProject, $queueForDatabase, - $queueForEvents + $queueForEvents, + $authorization ); $response diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Update.php index cb4d0d924b..bdf38a5087 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Datetime/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Datetime as DatetimeValidator; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, fn (Database $dbForProject) => new Nullable(new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime())), 'Default value for attribute when not provided. Cannot be set when attribute is required.', injections: ['dbForProject']) - ->param('newKey', null, new Key(), 'New attribute key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New attribute key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_DATETIME, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php index eb51044323..07ab604a5a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php @@ -67,12 +67,13 @@ class Delete extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php index cbfd66e4d9..eed105e583 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Create.php @@ -13,10 +13,12 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends Action { @@ -63,16 +65,17 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Email(), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new Email()), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute( $databaseId, @@ -89,7 +92,8 @@ class Create extends Action $response, $dbForProject, $queueForDatabase, - $queueForEvents + $queueForEvents, + $authorization ); $response diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php index 2446722f7a..d9cbb5ba80 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Email/Update.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Email()), 'Default value for attribute when not provided. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_STRING, filter: APP_DATABASE_ATTRIBUTE_EMAIL, default: $default, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Create.php index 98ed83861d..fb82dfd478 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Create.php @@ -13,11 +13,13 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends Action @@ -66,16 +68,17 @@ class Create extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('elements', [], new ArrayList(new Text(Database::LENGTH_KEY), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of enum values.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Text(0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new Text(0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, array $elements, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, array $elements, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { if (!is_null($default) && !\in_array($default, $elements, true)) { throw new Exception($this->getInvalidValueException(), 'Default value not found in elements'); @@ -97,7 +100,8 @@ class Create extends Action $response, $dbForProject, $queueForDatabase, - $queueForEvents + $queueForEvents, + $authorization ); $response diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Update.php index 23dc807360..31984d5f43 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Enum/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -67,14 +68,15 @@ class Update extends Action ->param('elements', null, new ArrayList(new Text(Database::LENGTH_KEY), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Updated list of enum values.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Text(0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?array $elements, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?array $elements, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -82,6 +84,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_STRING, filter: APP_DATABASE_ATTRIBUTE_ENUM, default: $default, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Create.php index 83deb92edc..6cd158631f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Create.php @@ -13,11 +13,13 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\FloatValidator; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; class Create extends Action @@ -65,18 +67,19 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('min', null, new FloatValidator(), 'Minimum value.', true) - ->param('max', null, new FloatValidator(), 'Maximum value.', true) - ->param('default', null, new FloatValidator(), 'Default value. Cannot be set when required.', true) + ->param('min', null, new Nullable(new FloatValidator()), 'Minimum value.', true) + ->param('max', null, new Nullable(new FloatValidator()), 'Maximum value.', true) + ->param('default', null, new Nullable(new FloatValidator()), 'Default value. Cannot be set when required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $min ??= -PHP_FLOAT_MAX; $max ??= PHP_FLOAT_MAX; @@ -99,7 +102,7 @@ class Create extends Action 'array' => $array, 'format' => APP_DATABASE_ATTRIBUTE_FLOAT_RANGE, 'formatOptions' => ['min' => $min, 'max' => $max], - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $formatOptions = $attribute->getAttribute('formatOptions', []); if (!empty($formatOptions)) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Update.php index 7f295a1a94..6d7d22caf8 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Float/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -64,17 +65,18 @@ class Update extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('min', null, new FloatValidator(), 'Minimum value.', true) - ->param('max', null, new FloatValidator(), 'Maximum value.', true) + ->param('min', null, new Nullable(new FloatValidator()), 'Minimum value.', true) + ->param('max', null, new Nullable(new FloatValidator()), 'Maximum value.', true) ->param('default', null, new Nullable(new FloatValidator()), 'Default value. Cannot be set when required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?float $min, ?float $max, ?float $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -82,6 +84,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_FLOAT, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php index 91fa3582f7..d31b17667e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php @@ -68,12 +68,13 @@ class Get extends Action ->param('key', '', new Key(), 'Attribute Key.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Create.php index 6e6264466c..9c5e3707d5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Create.php @@ -12,11 +12,13 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\IP; +use Utopia\Validator\Nullable; class Create extends Action { @@ -63,16 +65,17 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new IP(), 'Default value. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new IP()), 'Default value. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute( $databaseId, @@ -89,7 +92,8 @@ class Create extends Action $response, $dbForProject, $queueForDatabase, - $queueForEvents + $queueForEvents, + $authorization ); $response diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Update.php index 6cedf10760..2ee0f1a35b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/IP/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new IP()), 'Default value. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?string $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_STRING, filter: APP_DATABASE_ATTRIBUTE_IP, default: $default, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php index 090d63c403..99492c6950 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Create.php @@ -13,11 +13,13 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\Integer; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; class Create extends Action @@ -65,18 +67,19 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('min', null, new Integer(), 'Minimum value', true) - ->param('max', null, new Integer(), 'Maximum value', true) - ->param('default', null, new Integer(), 'Default value. Cannot be set when attribute is required.', true) + ->param('min', null, new Nullable(new Integer()), 'Minimum value', true) + ->param('max', null, new Nullable(new Integer()), 'Maximum value', true) + ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, bool $array, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $min ??= \PHP_INT_MIN; $max ??= \PHP_INT_MAX; @@ -101,7 +104,7 @@ class Create extends Action 'array' => $array, 'format' => APP_DATABASE_ATTRIBUTE_INT_RANGE, 'formatOptions' => ['min' => $min, 'max' => $max], - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $formatOptions = $attribute->getAttribute('formatOptions', []); if (!empty($formatOptions)) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php index b6ae79bd8a..419f09a4b3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -64,17 +65,18 @@ class Update extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('min', null, new Integer(), 'Minimum value', true) - ->param('max', null, new Integer(), 'Maximum value', true) + ->param('min', null, new Nullable(new Integer()), 'Minimum value', true) + ->param('max', null, new Nullable(new Integer()), 'Maximum value', true) ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?int $min, ?int $max, ?int $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -82,6 +84,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_INTEGER, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Create.php index f691fc29cf..7a92b3e13d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Create.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -69,17 +70,18 @@ class Create extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, 'type' => Database::VAR_LINESTRING, 'required' => $required, 'default' => $default - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Update.php index 52f04ba5bc..904209443f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Line/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_LINESTRING)), 'Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required.', true) - ->param('newKey', null, new Key(), 'New attribute key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New attribute key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_LINESTRING, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Create.php index aae715ba1e..9aff7cba34 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Create.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -69,17 +70,18 @@ class Create extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, 'type' => Database::VAR_POINT, 'required' => $required, 'default' => $default, - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Update.php index 73964ab461..55cadc4ca8 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Point/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_POINT)), 'Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required.', true) - ->param('newKey', null, new Key(), 'New attribute key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New attribute key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_POINT, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Create.php index 6fbbd46d2c..bc3dd75ace 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Create.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -69,17 +70,18 @@ class Create extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, 'type' => Database::VAR_POLYGON, 'required' => $required, 'default' => $default, - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Update.php index 23eb06f45d..1dcca49d99 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Polygon/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Spatial; use Utopia\Database\Validator\UID; @@ -65,14 +66,15 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_POLYGON)), 'Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required.', true) - ->param('newKey', null, new Key(), 'New attribute key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New attribute key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, ?bool $required, ?array $default, ?string $newKey, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -80,6 +82,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_POLYGON, default: $default, required: $required, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php index 75471b826c..30c49911b0 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php @@ -18,6 +18,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\WhiteList; class Create extends Action @@ -71,8 +72,8 @@ class Create extends Action Database::RELATION_ONE_TO_MANY ], true), 'Relation type') ->param('twoWay', false, new Boolean(), 'Is Two Way?', true) - ->param('key', null, new Key(), 'Attribute Key.', true) - ->param('twoWayKey', null, new Key(), 'Two Way Attribute Key.', true) + ->param('key', null, new Nullable(new Key()), 'Attribute Key.', true) + ->param('twoWayKey', null, new Nullable(new Key()), 'Two Way Attribute Key.', true) ->param('onDelete', Database::RELATION_MUTATE_RESTRICT, new WhiteList([ Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_RESTRICT, @@ -82,15 +83,16 @@ class Create extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $relatedCollectionId, string $type, bool $twoWay, ?string $key, ?string $twoWayKey, string $onDelete, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $relatedCollectionId, string $type, bool $twoWay, ?string $key, ?string $twoWayKey, string $onDelete, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { $key ??= $relatedCollectionId; $twoWayKey ??= $collectionId; - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } @@ -149,7 +151,7 @@ class Create extends Action 'twoWayKey' => $twoWayKey, 'onDelete' => $onDelete, ] - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); foreach ($attribute->getAttribute('options', []) as $k => $option) { $attribute->setAttribute($k, $option); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Update.php index 897cbd434f..8623f7cb17 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Update.php @@ -11,9 +11,11 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\WhiteList; class Update extends Action @@ -61,15 +63,16 @@ class Update extends Action ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') - ->param('onDelete', null, new WhiteList([ + ->param('onDelete', null, new Nullable(new WhiteList([ Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_SET_NULL - ], true), 'Constraints option', true) - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ], true)), 'Constraints option', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } @@ -81,7 +84,8 @@ class Update extends Action ?string $newKey, UtopiaResponse $response, Database $dbForProject, - Event $queueForEvents + Event $queueForEvents, + Authorization $authorization ): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -89,6 +93,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_RELATIONSHIP, required: false, options: [ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Create.php index 1527c4d1d9..0712b9f2e5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Create.php @@ -14,11 +14,13 @@ use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\App; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; @@ -68,7 +70,7 @@ class Create extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER), 'Attribute size for text attributes, in number of characters.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new Text(0, 0), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new Text(0, 0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->param('encrypt', false, new Boolean(), 'Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried.', true) ->inject('response') @@ -76,6 +78,7 @@ class Create extends Action ->inject('queueForDatabase') ->inject('queueForEvents') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } @@ -92,7 +95,8 @@ class Create extends Action Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, - array $plan + array $plan, + Authorization $authorization ): void { if (!App::isDevelopment() && $encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Encrypted string ' . $this->getSDKGroup() . ' are not available on your plan. Please upgrade to create encrypted string ' . $this->getSDKGroup() . '.'); @@ -131,7 +135,8 @@ class Create extends Action $response, $dbForProject, $queueForDatabase, - $queueForEvents + $queueForEvents, + $authorization ); $attribute->setAttribute('encrypt', $encrypt); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Update.php index 8614dfb202..096481198c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/String/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -67,11 +68,12 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new Text(0, 0)), 'Default value for attribute when not provided. Cannot be set when attribute is required.') - ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER), 'Maximum size of the string attribute.', true) - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('size', null, new Nullable(new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER)), 'Maximum size of the string attribute.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } @@ -85,7 +87,8 @@ class Update extends Action ?string $newKey, UtopiaResponse $response, Database $dbForProject, - Event $queueForEvents + Event $queueForEvents, + Authorization $authorization ): void { $attribute = $this->updateAttribute( databaseId: $databaseId, @@ -93,6 +96,7 @@ class Update extends Action key: $key, dbForProject: $dbForProject, queueForEvents: $queueForEvents, + authorization: $authorization, type: Database::VAR_STRING, size: $size, default: $default, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Create.php index ce0175966b..31b012754d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Create.php @@ -12,10 +12,12 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\URL; class Create extends Action @@ -63,12 +65,13 @@ class Create extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') - ->param('default', null, new URL(), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) + ->param('default', null, new Nullable(new URL()), 'Default value for attribute when not provided. Cannot be set when attribute is required.', true) ->param('array', false, new Boolean(), 'Is attribute an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } @@ -82,7 +85,8 @@ class Create extends Action UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, - Event $queueForEvents + Event $queueForEvents, + Authorization $authorization ): void { $attribute = $this->createAttribute($databaseId, $collectionId, new Document([ 'key' => $key, @@ -92,7 +96,7 @@ class Create extends Action 'default' => $default, 'array' => $array, 'format' => APP_DATABASE_ATTRIBUTE_URL, - ]), $response, $dbForProject, $queueForDatabase, $queueForEvents); + ]), $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); $response ->setStatusCode(SwooleResponse::STATUS_CODE_ACCEPTED) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Update.php index 7ba12ad98a..46f2ec3acd 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/URL/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -65,10 +66,11 @@ class Update extends Action ->param('key', '', new Key(), 'Attribute Key.') ->param('required', null, new Boolean(), 'Is attribute required?') ->param('default', null, new Nullable(new URL()), 'Default value for attribute when not provided. Cannot be set when attribute is required.') - ->param('newKey', null, new Key(), 'New Attribute Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Attribute Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } @@ -81,7 +83,8 @@ class Update extends Action ?string $newKey, UtopiaResponse $response, Database $dbForProject, - Event $queueForEvents + Event $queueForEvents, + Authorization $authorization ): void { $attribute = $this->updateAttribute( $databaseId, @@ -89,6 +92,7 @@ class Update extends Action $key, $dbForProject, $queueForEvents, + $authorization, type: Database::VAR_STRING, filter: APP_DATABASE_ATTRIBUTE_URL, default: $default, diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php index c2af3ac945..be61b260b3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php @@ -64,12 +64,13 @@ class XList extends Action ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, array $queries, bool $includeTotal, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $collectionId, array $queries, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php index b810ce602f..93812585ea 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php @@ -24,6 +24,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends Action @@ -71,18 +72,19 @@ class Create extends Action ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new CustomId(), 'Unique 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.') ->param('name', '', new Text(128), 'Collection name. Max length: 128 chars.') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('documentSecurity', false, new Boolean(true), 'Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php index d124a47289..67f53fa33a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php @@ -64,12 +64,13 @@ class Delete extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php index c4c169b77c..14b09777a8 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php @@ -4,13 +4,12 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Documen use Appwrite\Event\Event; use Appwrite\Extend\Exception; -use Appwrite\Platform\Action as AppwriteAction; +use Appwrite\Platform\Modules\Databases\Http\Databases\Action as DatabasesAction; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\Operator; use Utopia\Database\Validator\Authorization; -abstract class Action extends AppwriteAction +abstract class Action extends DatabasesAction { /** * @var string|null The current context (either 'row' or 'document') @@ -22,7 +21,7 @@ abstract class Action extends AppwriteAction */ abstract protected function getResponseModel(): string; - public function setHttpPath(string $path): AppwriteAction + public function setHttpPath(string $path): DatabasesAction { if (str_contains($path, '/tablesdb/')) { $this->context = ROWS; @@ -259,9 +258,9 @@ abstract class Action extends AppwriteAction Document $collection, Document $document, Database $dbForProject, - /* options */ array &$collectionsCache, + Authorization $authorization, ?int &$operations = null, ): bool { @@ -298,7 +297,7 @@ abstract class Action extends AppwriteAction $relatedCollectionId = $relationship->getAttribute('relatedCollection'); if (!isset($collectionsCache[$relatedCollectionId])) { - $relatedCollectionDoc = Authorization::skip( + $relatedCollectionDoc = $authorization->skip( fn () => $dbForProject->getDocument( 'database_' . $database->getSequence(), $relatedCollectionId @@ -324,7 +323,8 @@ abstract class Action extends AppwriteAction document: $relation, dbForProject: $dbForProject, collectionsCache: $collectionsCache, - operations: $operations + operations: $operations, + authorization: $authorization ); } } @@ -339,53 +339,6 @@ abstract class Action extends AppwriteAction return true; } - /** - * Parse operator strings in data array and convert them to Operator objects. - * - * @param array $data The data array that may contain operator JSON strings - * @param Document $collection The collection document to check for relationship attributes - * @return array The data array with operators converted to Operator objects - * @throws Exception If an operator string is invalid - */ - protected function parseOperators(array $data, Document $collection): array - { - $relationshipKeys = []; - foreach ($collection->getAttribute('attributes', []) as $attribute) { - if ($attribute->getAttribute('type') === Database::VAR_RELATIONSHIP) { - $relationshipKeys[$attribute->getAttribute('key')] = true; - } - } - - foreach ($data as $key => $value) { - if (\str_starts_with($key, '$')) { - continue; - } - - if (isset($relationshipKeys[$key])) { - continue; - } - - if (\is_string($value)) { - $decoded = \json_decode($value, true); - - if ( - \is_array($decoded) && - isset($decoded['method']) && - \is_string($decoded['method']) && - Operator::isMethod($decoded['method']) - ) { - try { - $data[$key] = Operator::parse($value); - } catch (\Exception $e) { - throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid operator for attribute "' . $key . '": ' . $e->getMessage()); - } - } - } - } - - return $data; - } - /** * For triggering different queues for each document for a bulk documents * @param string $event diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php index 0b3d0e9fb4..158a44c1b3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php @@ -25,6 +25,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\Numeric; class Decrement extends Action @@ -77,27 +78,28 @@ class Decrement extends Action ->param('documentId', '', new UID(), 'Document ID.') ->param('attribute', '', new Key(), 'Attribute key.') ->param('value', 1, new Numeric(), 'Value to increment the attribute by. The value must be a number.', true) - ->param('min', null, new Numeric(), 'Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('min', null, new Nullable(new Numeric()), 'Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') ->inject('queueForStatsUsage') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $min, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, array $plan): void + public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $min, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, array $plan, Authorization $authorization): void { - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty()) { throw new Exception($this->getParentNotFoundException()); } @@ -105,7 +107,7 @@ class Decrement extends Action // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty() || $transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or non‑pending transaction'); @@ -152,6 +154,8 @@ class Decrement extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually decrementing $groupId = $this->getGroupId(); $mockDocument = new Document([ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php index ef64099fa8..9045954789 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php @@ -25,6 +25,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\Numeric; class Increment extends Action @@ -77,27 +78,28 @@ class Increment extends Action ->param('documentId', '', new UID(), 'Document ID.') ->param('attribute', '', new Key(), 'Attribute key.') ->param('value', 1, new Numeric(), 'Value to increment the attribute by. The value must be a number.', true) - ->param('max', null, new Numeric(), 'Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('max', null, new Nullable(new Numeric()), 'Maximum value for the attribute. If the current value is greater than this value, an error will be thrown.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') ->inject('queueForStatsUsage') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $max, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, array $plan): void + public function action(string $databaseId, string $collectionId, string $documentId, string $attribute, int|float $value, int|float|null $max, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, array $plan, Authorization $authorization): void { - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty()) { throw new Exception($this->getParentNotFoundException()); } @@ -105,7 +107,7 @@ class Increment extends Action // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty() || $transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or non‑pending transaction'); @@ -152,6 +154,8 @@ class Increment extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually incrementing $groupId = $this->getGroupId(); $mockDocument = new Document([ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php index 4b1251e016..fdc4c96fe4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php @@ -22,6 +22,7 @@ use Utopia\Database\Query; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Delete extends Action @@ -71,7 +72,7 @@ class Delete extends Action ->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('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -150,6 +151,8 @@ class Delete extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually deleting documents $response->dynamic(new Document([ $this->getSDKGroup() => [], diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php index 2152534efe..4adf11311e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php @@ -25,6 +25,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends Action @@ -75,7 +76,7 @@ class Update extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('data', [], new JSON(), 'Document data as JSON object. Include only attribute and value pairs to be updated.', true) ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -107,7 +108,9 @@ class Update extends Action throw new Exception($this->getParentNotFoundException()); } - $data = $this->parseOperators($data, $collection); + if ($transactionId === null) { + $data = $this->parseOperators($data, $collection); + } $hasRelationships = \array_filter( $collection->getAttribute('attributes', []), @@ -174,6 +177,8 @@ class Update extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually updating documents $response->dynamic(new Document([ $this->getSDKGroup() => [], diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php index 6c869723a7..d30135de75 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php @@ -23,6 +23,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Upsert extends Action { @@ -73,7 +74,7 @@ class Upsert extends Action ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new UID(), 'Collection ID.') ->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of document data as JSON objects. May contain partial documents.', false, ['plan']) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -107,7 +108,9 @@ class Upsert extends Action } foreach ($documents as $key => $document) { - $document = $this->parseOperators($document, $collection); + if ($transactionId === null) { + $document = $this->parseOperators($document, $collection); + } $document = $this->removeReadonlyAttributes($document, privileged: true); $documents[$key] = new Document($document); } @@ -149,6 +152,8 @@ class Upsert extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually upserting documents $response->dynamic(new Document([ $this->getSDKGroup() => [], diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php index 521190d3dc..ec3db59668 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php @@ -24,11 +24,13 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Create extends Action { @@ -119,9 +121,9 @@ class Create extends Action ->param('documentId', '', new CustomId(), 'Document 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.', true) ->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). Make sure to define attributes before creating documents.') ->param('data', [], new JSON(), 'Document data as JSON object.', true, example: '{"username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O\'Brien","age":30,"isAdmin":false}') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('documents', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of documents data as JSON objects.', true, ['plan']) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('user') @@ -131,9 +133,10 @@ class Create extends Action ->inject('queueForFunctions') ->inject('queueForWebhooks') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, ?array $documents, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Document $user, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan): void + public function action(string $databaseId, string $documentId, string $collectionId, string|array $data, ?array $permissions, ?array $documents, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, Document $user, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, array $plan, Authorization $authorization): void { $data = \is_string($data) ? \json_decode($data, true) @@ -177,19 +180,19 @@ class Create extends Action $documents = [$data]; } - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($isBulk && !$isAPIKey && !$isPrivilegedUser) { throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE); } - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); } @@ -203,7 +206,7 @@ class Create extends Action throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Bulk create is not supported for ' . $this->getSDKNamespace() .' with relationship ' . $this->getStructureContext()); } - $setPermissions = function (Document $document, ?array $permissions) use ($user, $isAPIKey, $isPrivilegedUser, $isBulk) { + $setPermissions = function (Document $document, ?array $permissions) use ($user, $isAPIKey, $isPrivilegedUser, $isBulk, $dbForProject, $authorization) { $allowedPermissions = [ Database::PERMISSION_READ, Database::PERMISSION_UPDATE, @@ -246,8 +249,8 @@ class Create extends Action $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { - throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', Authorization::getRoles()) . ')'); + if (!$authorization->hasRole($role)) { + throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $authorization->getRoles()) . ')'); } } } @@ -258,21 +261,25 @@ class Create extends Action $operations = 0; - $checkPermissions = function (Document $collection, Document $document, string $permission) use ($isAPIKey, $isPrivilegedUser, &$checkPermissions, $dbForProject, $database, &$operations) { + $checkPermissions = function (Document $collection, Document $document, string $permission) use ($isAPIKey, $isPrivilegedUser, &$checkPermissions, $dbForProject, $database, &$operations, $authorization) { $operations++; $documentSecurity = $collection->getAttribute('documentSecurity', false); - $validator = new Authorization($permission); - $valid = $validator->isValid($collection->getPermissionsByType($permission)); - if (($permission === Database::PERMISSION_UPDATE && !$documentSecurity) || !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + $validCollection = $authorization->isValid( + new Input($permission, $collection->getPermissionsByType($permission)) + ); + if (($permission === Database::PERMISSION_UPDATE && !$documentSecurity) || !$validCollection) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } if ($permission === Database::PERMISSION_UPDATE) { - $valid = $valid || $validator->isValid($document->getUpdate()); + $validDocument = $authorization->isValid( + new Input($permission, $document->getUpdate()) + ); + $valid = $validCollection || $validDocument; if ($documentSecurity && !$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } } @@ -297,7 +304,7 @@ class Create extends Action } $relatedCollectionId = $relationship->getAttribute('relatedCollection'); - $relatedCollection = Authorization::skip( + $relatedCollection = $authorization->skip( fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $relatedCollectionId) ); @@ -313,7 +320,7 @@ class Create extends Action if ($relation instanceof Document) { $relation = $this->removeReadonlyAttributes($relation, $isAPIKey || $isPrivilegedUser); - $current = Authorization::skip( + $current = $authorization->skip( fn () => $dbForProject->getDocument('database_' . $database->getSequence() . '_collection_' . $relatedCollection->getSequence(), $relation->getId()) ); @@ -368,7 +375,7 @@ class Create extends Action // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -412,6 +419,8 @@ class Create extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually creating documents if ($isBulk) { $response->dynamic(new Document([ @@ -465,6 +474,7 @@ class Create extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, + authorization: $authorization ); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php index a4cef59e5f..93ad7dc2a8 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php @@ -21,6 +21,7 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; class Delete extends Action { @@ -74,7 +75,7 @@ class Delete extends Action ->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('documentId', '', new UID(), 'Document ID.') - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') @@ -82,6 +83,7 @@ class Delete extends Action ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } @@ -96,18 +98,19 @@ class Delete extends Action Event $queueForEvents, StatsUsage $queueForStatsUsage, TransactionState $transactionState, - array $plan + array $plan, + Authorization $authorization ): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); @@ -120,7 +123,7 @@ class Delete extends Action // Use transaction-aware document retrieval to see changes from same transaction $document = $transactionState->getDocument($collectionTableId, $documentId, $transactionId); } else { - $document = Authorization::skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); + $document = $authorization->skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); } if ($document->isEmpty()) { @@ -130,7 +133,7 @@ class Delete extends Action // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -176,6 +179,8 @@ class Delete extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually deleting document $response->noContent(); return; @@ -202,6 +207,7 @@ class Delete extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, + authorization: $authorization ); $queueForStatsUsage diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php index 3d8cd9198c..fa89d5fa32 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php @@ -19,6 +19,7 @@ use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Get extends Action @@ -64,25 +65,26 @@ class Get extends Action ->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('documentId', '', new UID(), 'Document ID.') ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID to read uncommitted changes within the transaction.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID to read uncommitted changes within the transaction.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') ->inject('transactionState') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, array $queries, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, StatsUsage $queueForStatsUsage, TransactionState $transactionState): void + public function action(string $databaseId, string $collectionId, string $documentId, array $queries, ?string $transactionId, UtopiaResponse $response, Database $dbForProject, StatsUsage $queueForStatsUsage, TransactionState $transactionState, Authorization $authorization): void { - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); @@ -124,6 +126,7 @@ class Get extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, + authorization: $authorization, operations: $operations ); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php index 241b0c4ede..68fd41221d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php @@ -73,12 +73,13 @@ class XList extends Action ->inject('dbForProject') ->inject('locale') ->inject('geodb') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, array $queries, UtopiaResponse $response, Database $dbForProject, Locale $locale, Reader $geodb): void + public function action(string $databaseId, string $collectionId, string $documentId, array $queries, UtopiaResponse $response, Database $dbForProject, Locale $locale, Reader $geodb, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php index ed83f3fdd3..0aca4a08c3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php @@ -27,6 +27,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Update extends Action { @@ -77,8 +78,8 @@ class Update extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('documentId', '', new UID(), 'Document ID.') ->param('data', [], new JSON(), 'Document data as JSON object. Include only attribute and value pairs to be updated.', true) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') @@ -86,10 +87,11 @@ class Update extends Action ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?string $transactionId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, TransactionState $transactionState, array $plan): void + public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?string $transactionId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, TransactionState $transactionState, array $plan, Authorization $authorization): void { $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array @@ -97,22 +99,24 @@ class Update extends Action throw new Exception($this->getMissingPayloadException()); } - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); } - $data = $this->parseOperators($data, $collection); + if ($transactionId === null) { + $data = $this->parseOperators($data, $collection); + } // Read permission should not be required for update /** @var Document $document */ @@ -122,7 +126,7 @@ class Update extends Action // Use transaction-aware document retrieval to see changes from same transaction $document = $transactionState->getDocument($collectionTableId, $documentId, $transactionId); } else { - $document = Authorization::skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); + $document = $authorization->skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); } if ($document->isEmpty()) { @@ -137,7 +141,7 @@ class Update extends Action ]); // Users can only manage their own roles, API keys and Admin users can manage any - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); if (!$isAPIKey && !$isPrivilegedUser && !\is_null($permissions)) { foreach (Database::PERMISSIONS as $type) { foreach ($permissions as $permission) { @@ -150,7 +154,7 @@ class Update extends Action $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { + if (!$authorization->hasRole($role)) { throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $roles) . ')'); } } @@ -168,7 +172,7 @@ class Update extends Action $operations = 0; - $setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $database, &$operations) { + $setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $database, &$operations, $authorization) { $operations++; $relationships = \array_filter( @@ -192,7 +196,7 @@ class Update extends Action } $relatedCollectionId = $relationship->getAttribute('relatedCollection'); - $relatedCollection = Authorization::skip( + $relatedCollection = $authorization->skip( fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $relatedCollectionId) ); @@ -209,7 +213,7 @@ class Update extends Action if ($relation instanceof Document) { $relation = $this->removeReadonlyAttributes($relation, $isAPIKey || $isPrivilegedUser); - $oldDocument = Authorization::skip(fn () => $dbForProject->getDocument( + $oldDocument = $authorization->skip(fn () => $dbForProject->getDocument( 'database_' . $database->getSequence() . '_collection_' . $relatedCollection->getSequence(), $relation->getId() )); @@ -243,11 +247,10 @@ class Update extends Action ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, max($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations); - // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -302,6 +305,9 @@ class Update extends Action ...$document->getArrayCopy(), ...$data ]); + + $queueForEvents->reset(); + $response ->setStatusCode(SwooleResponse::STATUS_CODE_OK) ->dynamic($mockDocument, $this->getResponseModel()); @@ -335,6 +341,7 @@ class Update extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, + authorization: $authorization, ); $response->dynamic($document, $this->getResponseModel()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php index 8d47410649..5ec455b947 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php @@ -28,6 +28,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Upsert extends Action { @@ -80,8 +81,8 @@ class Upsert extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->param('documentId', '', new CustomId(), 'Document ID.') ->param('data', [], new JSON(), 'Document data as JSON object. Include all required attributes of the document to be created or updated.') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('user') @@ -90,10 +91,11 @@ class Upsert extends Action ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?string $transactionId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Document $user, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, TransactionState $transactionState, array $plan): void + public function action(string $databaseId, string $collectionId, string $documentId, string|array $data, ?array $permissions, ?string $transactionId, ?\DateTime $requestTimestamp, UtopiaResponse $response, Document $user, Database $dbForProject, Event $queueForEvents, StatsUsage $queueForStatsUsage, TransactionState $transactionState, array $plan, Authorization $authorization): void { $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array @@ -105,20 +107,22 @@ class Upsert extends Action throw new Exception($this->getMissingPayloadException()); } - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); } - $data = $this->parseOperators($data, $collection); + if ($transactionId === null) { + $data = $this->parseOperators($data, $collection); + } $allowedPermissions = [ Database::PERMISSION_READ, @@ -136,7 +140,7 @@ class Upsert extends Action // Use transaction-aware document retrieval to see changes from same transaction $oldDocument = $transactionState->getDocument($collectionTableId, $documentId, $transactionId); } else { - $oldDocument = Authorization::skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); + $oldDocument = $authorization->skip(fn () => $dbForProject->getDocument($collectionTableId, $documentId)); } if ($oldDocument->isEmpty()) { if (!empty($user->getId())) { @@ -152,7 +156,7 @@ class Upsert extends Action } // Users can only manage their own roles, API keys and Admin users can manage any - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); if (!$isAPIKey && !$isPrivilegedUser && !\is_null($permissions)) { foreach (Database::PERMISSIONS as $type) { foreach ($permissions as $permission) { @@ -165,7 +169,7 @@ class Upsert extends Action $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { + if (!$authorization->hasRole($role)) { throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $roles) . ')'); } } @@ -178,7 +182,7 @@ class Upsert extends Action $newDocument = new Document($data); $operations = 0; - $setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $database, &$operations) { + $setCollection = (function (Document $collection, Document $document) use ($isAPIKey, $isPrivilegedUser, &$setCollection, $dbForProject, $database, &$operations, $authorization) { $operations++; $relationships = \array_filter( @@ -202,7 +206,7 @@ class Upsert extends Action } $relatedCollectionId = $relationship->getAttribute('relatedCollection'); - $relatedCollection = Authorization::skip( + $relatedCollection = $authorization->skip( fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $relatedCollectionId) ); @@ -219,7 +223,7 @@ class Upsert extends Action if ($relation instanceof Document) { $relation = $this->removeReadonlyAttributes($relation, $isAPIKey || $isPrivilegedUser); - $oldDocument = Authorization::skip(fn () => $dbForProject->getDocument( + $oldDocument = $authorization->skip(fn () => $dbForProject->getDocument( 'database_' . $database->getSequence() . '_collection_' . $relatedCollection->getSequence(), $relation->getId() )); @@ -256,7 +260,7 @@ class Upsert extends Action // Handle transaction staging if ($transactionId !== null) { $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -302,6 +306,8 @@ class Upsert extends Action ); }); + $queueForEvents->reset(); + // Return successful response without actually upserting document $groupId = $this->getGroupId(); $mockDocument = new Document([ @@ -356,6 +362,7 @@ class Upsert extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, + authorization: $authorization ); $relationships = \array_map( diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index f159043531..a5a3ac0eb4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -23,6 +23,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class XList extends Action @@ -67,26 +68,27 @@ class XList extends Action ->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('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID to read uncommitted changes within the transaction.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID to read uncommitted changes within the transaction.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') ->inject('transactionState') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, array $queries, ?string $transactionId, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, StatsUsage $queueForStatsUsage, TransactionState $transactionState): void + public function action(string $databaseId, string $collectionId, array $queries, ?string $transactionId, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, StatsUsage $queueForStatsUsage, TransactionState $transactionState, Authorization $authorization): void { - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } - $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); + $collection = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception($this->getParentNotFoundException()); } @@ -114,7 +116,7 @@ class XList extends Action $documentId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId)); + $cursorDocument = $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId)); if ($cursorDocument->isEmpty()) { $type = ucfirst($this->getContext()); @@ -160,7 +162,8 @@ class XList extends Action document: $document, dbForProject: $dbForProject, collectionsCache: $collectionsCache, - operations: $operations, + authorization: $authorization, + operations: $operations ); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php index 89739570c7..725b53ff9e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php @@ -57,12 +57,13 @@ class Get extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $collectionId, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php index 9fb438d577..6afc29a265 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php @@ -79,12 +79,13 @@ class Create extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders, array $lengths, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, string $type, array $attributes, array $orders, array $lengths, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php index 2bccfdfb52..89d79ef353 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php @@ -70,12 +70,13 @@ class Delete extends Action ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void { - $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $db = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php index 3d118d1922..27e0767f88 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php @@ -59,12 +59,13 @@ class Get extends Action ->param('key', null, new Key(), 'Index Key.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $collectionId, string $key, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php index 88b3a32e0b..d6e59dc4fa 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php @@ -66,13 +66,14 @@ class XList extends Action ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, array $queries, bool $includeTotal, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $collectionId, array $queries, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { /** @var Document $database */ - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -112,7 +113,7 @@ class XList extends Action } $indexId = $cursor->getValue(); - $cursorDocument = Authorization::skip(fn () => $dbForProject->find('indexes', [ + $cursorDocument = $authorization->skip(fn () => $dbForProject->find('indexes', [ Query::equal('collectionInternalId', [$collection->getSequence()]), Query::equal('databaseInternalId', [$database->getSequence()]), Query::equal('key', [$indexId]), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php index b202120bad..f193c15299 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php @@ -72,12 +72,13 @@ class XList extends Action ->inject('dbForProject') ->inject('locale') ->inject('geodb') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, Locale $locale, Reader $geodb): void + public function action(string $databaseId, string $collectionId, array $queries, UtopiaResponse $response, Database $dbForProject, Locale $locale, Reader $geodb, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); @@ -115,9 +116,9 @@ class XList extends Action $detector = new Detector($log['userAgent']); $detector->skipBotDetection(); // OPTIONAL: If called, bot detection will completely be skipped (bots will be detected as regular devices then) - $os = $detector->getOS(); - $client = $detector->getClient(); - $device = $detector->getDevice(); + $os = $detector->getOS() ?: []; + $client = $detector->getClient() ?: []; + $device = $detector->getDevice() ?: []; $output[$i] = new Document([ 'event' => $log['event'], @@ -125,20 +126,20 @@ class XList extends Action 'userEmail' => $log['data']['userEmail'] ?? null, 'userName' => $log['data']['userName'] ?? null, 'mode' => $log['data']['mode'] ?? null, - 'ip' => $log['ip'], - 'time' => $log['time'], - 'osCode' => $os['osCode'], - 'osName' => $os['osName'], - 'osVersion' => $os['osVersion'], - 'clientType' => $client['clientType'], - 'clientCode' => $client['clientCode'], - 'clientName' => $client['clientName'], - 'clientVersion' => $client['clientVersion'], - 'clientEngine' => $client['clientEngine'], - 'clientEngineVersion' => $client['clientEngineVersion'], - 'deviceName' => $device['deviceName'], - 'deviceBrand' => $device['deviceBrand'], - 'deviceModel' => $device['deviceModel'] + 'ip' => $log['ip'] ?? null, + 'time' => $log['time'] ?? null, + 'osCode' => $os['osCode'] ?? null, + 'osName' => $os['osName'] ?? null, + 'osVersion' => $os['osVersion'] ?? null, + 'clientType' => $client['clientType'] ?? null, + 'clientCode' => $client['clientCode'] ?? null, + 'clientName' => $client['clientName'] ?? null, + 'clientVersion' => $client['clientVersion'] ?? null, + 'clientEngine' => $client['clientEngine'] ?? null, + 'clientEngineVersion' => $client['clientEngineVersion'] ?? null, + 'deviceName' => $device['deviceName'] ?? null, + 'deviceBrand' => $device['deviceBrand'] ?? null, + 'deviceModel' => $device['deviceModel'] ?? null ]); $record = $geodb->get($log['ip']); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php index 49870002ce..c26a68c068 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php @@ -17,6 +17,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends Action @@ -64,18 +65,19 @@ class Update extends Action ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new UID(), 'Collection ID.') ->param('name', null, new Text(128), 'Collection name. Max length: 128 chars.') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('documentSecurity', false, new Boolean(true), 'Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $databaseId, string $collectionId, string $name, ?array $permissions, bool $documentSecurity, bool $enabled, UtopiaResponse $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php index 9cf7b85267..beca779bf6 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php @@ -63,10 +63,11 @@ class Get extends Action ->param('collectionId', '', new UID(), 'Collection ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $range, string $collectionId, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $range, string $collectionId, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { $database = $dbForProject->getDocument('databases', $databaseId); $collectionDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); @@ -83,7 +84,7 @@ class Get extends Action str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getSequence(), $collectionDocument->getSequence()], METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS), ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php index 286e48420a..11b60e35a7 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php @@ -67,12 +67,13 @@ class XList extends Action ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, array $queries, string $search, bool $includeTotal, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, array $queries, string $search, bool $includeTotal, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { - $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); + $database = $authorization->skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { throw new Exception(Exception::DATABASE_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Action.php index 8915ae6141..e2a4491736 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Action.php @@ -2,16 +2,16 @@ namespace Appwrite\Platform\Modules\Databases\Http\Databases\Transactions; -use Utopia\Platform\Action as UtopiaAction; +use Appwrite\Platform\Modules\Databases\Http\Databases\Action as DatabasesAction; -abstract class Action extends UtopiaAction +abstract class Action extends DatabasesAction { /** * The current API context (either 'table' or 'collection'). */ private ?string $context = COLLECTIONS; - public function setHttpPath(string $path): UtopiaAction + public function setHttpPath(string $path): DatabasesAction { if (\str_contains($path, '/tablesdb')) { $this->context = TABLES; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Create.php index c4c5bf8b51..41d3f3022a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Create.php @@ -55,10 +55,11 @@ class Create extends Action ->inject('response') ->inject('dbForProject') ->inject('user') + ->inject('authorization') ->callback($this->action(...)); } - public function action(int $ttl, UtopiaResponse $response, Database $dbForProject, Document $user): void + public function action(int $ttl, UtopiaResponse $response, Database $dbForProject, Document $user, Authorization $authorization): void { $permissions = []; if (!empty($user->getId())) { @@ -73,7 +74,7 @@ class Create extends Action } } - $transaction = Authorization::skip(fn () => $dbForProject->createDocument('transactions', new Document([ + $transaction = $authorization->skip(fn () => $dbForProject->createDocument('transactions', new Document([ '$id' => ID::unique(), '$permissions' => $permissions, 'status' => 'pending', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php index bd94c1c7eb..98a0708f66 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php @@ -18,6 +18,7 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; @@ -63,21 +64,22 @@ class Create extends Action ->inject('dbForProject') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $transactionId, array $operations, UtopiaResponse $response, Database $dbForProject, TransactionState $transactionState, array $plan): void + public function action(string $transactionId, array $operations, UtopiaResponse $response, Database $dbForProject, TransactionState $transactionState, array $plan, Authorization $authorization): void { if (empty($operations)) { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Operations array cannot be empty'); } - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); // API keys and admins can read any transaction, regular users need permissions $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -113,13 +115,13 @@ class Create extends Action throw new Exception(Exception::USER_UNAUTHORIZED); } - $database = $databases[$operation['databaseId']] ??= Authorization::skip(fn () => $dbForProject->getDocument('databases', $operation['databaseId'])); + $database = $databases[$operation['databaseId']] ??= $authorization->skip(fn () => $dbForProject->getDocument('databases', $operation['databaseId'])); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::DATABASE_NOT_FOUND); } $collection = $collections[$operation[$this->getGroupId()]] ??= - Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $operation[$this->getGroupId()])); + $authorization->skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $operation[$this->getGroupId()])); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::COLLECTION_NOT_FOUND); @@ -165,14 +167,20 @@ class Create extends Action // For individual operations, enforce permissions unless using API key/admin if (!$isAPIKey && !$isPrivilegedUser) { $documentSecurity = $collection->getAttribute('documentSecurity', false); - $validator = new Authorization($permissionType); - $collectionValid = $validator->isValid($collection->getPermissionsByType($permissionType)); + + $collectionValid = $authorization->isValid( + new Input($permissionType, $collection->getPermissionsByType($permissionType)) + ); $documentValid = false; if ($document !== null && !$document->isEmpty() && $documentSecurity) { if ($permissionType === Database::PERMISSION_UPDATE) { - $documentValid = $validator->isValid($document->getUpdate()); + $documentValid = $authorization->isValid( + new Input(Database::PERMISSION_UPDATE, $document->getUpdate()) + ); } elseif ($permissionType === Database::PERMISSION_DELETE) { - $documentValid = $validator->isValid($document->getDelete()); + $documentValid = $authorization->isValid( + new Input(Database::PERMISSION_DELETE, $document->getDelete()) + ); } } @@ -189,7 +197,7 @@ class Create extends Action // Users can only set permissions for roles they have if (isset($operation['data']['$permissions'])) { $permissions = $operation['data']['$permissions']; - $roles = Authorization::getRoles(); + $roles = $authorization->getRoles(); foreach (Database::PERMISSIONS as $type) { foreach ($permissions as $permission) { $permission = Permission::parse($permission); @@ -201,7 +209,7 @@ class Create extends Action $permission->getIdentifier(), $permission->getDimension() ))->toString(); - if (!Authorization::isRole($role)) { + if (!$authorization->hasRole($role)) { throw new Exception(Exception::USER_UNAUTHORIZED, 'Permissions must be one of: (' . \implode(', ', $roles) . ')'); } } @@ -230,7 +238,7 @@ class Create extends Action } } - $transaction = Authorization::skip(fn () => $dbForProject->withTransaction(function () use ($dbForProject, $transactionId, $staged, $existing, $operations) { + $transaction = $authorization->skip(fn () => $dbForProject->withTransaction(function () use ($dbForProject, $transactionId, $staged, $existing, $operations) { $dbForProject->createDocuments('transactionLogs', $staged); return $dbForProject->increaseDocumentAttribute( 'transactions', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php index 6e2bd63827..ec5f0e4c04 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php @@ -76,6 +76,7 @@ class Update extends Action ->inject('queueForRealtime') ->inject('queueForFunctions') ->inject('queueForWebhooks') + ->inject('authorization') ->callback($this->action(...)); } @@ -102,7 +103,7 @@ class Update extends Action * @throws Structure * @throws \Utopia\Exception */ - public function action(string $transactionId, bool $commit, bool $rollback, UtopiaResponse $response, Database $dbForProject, Document $user, TransactionState $transactionState, Delete $queueForDeletes, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks): void + public function action(string $transactionId, bool $commit, bool $rollback, UtopiaResponse $response, Database $dbForProject, Document $user, TransactionState $transactionState, Delete $queueForDeletes, Event $queueForEvents, StatsUsage $queueForStatsUsage, Event $queueForRealtime, Event $queueForFunctions, Event $queueForWebhooks, Authorization $authorization): void { if (!$commit && !$rollback) { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Either commit or rollback must be true'); @@ -111,11 +112,11 @@ class Update extends Action throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Cannot commit and rollback at the same time'); } - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); $transaction = ($isAPIKey || $isPrivilegedUser) - ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) + ? $authorization->skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { throw new Exception(Exception::TRANSACTION_NOT_FOUND); @@ -137,18 +138,19 @@ class Update extends Action $databaseOperations = []; try { - $dbForProject->withTransaction(function () use ($dbForProject, $transactionState, $queueForDeletes, $transactionId, &$transaction, &$operations, &$totalOperations, &$databaseOperations, $queueForEvents, $queueForStatsUsage, $queueForRealtime, $queueForFunctions, $queueForWebhooks) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $dbForProject->withTransaction(function () use ($dbForProject, $transactionState, $queueForDeletes, $transactionId, &$transaction, &$operations, &$totalOperations, &$databaseOperations, $queueForEvents, $queueForStatsUsage, $queueForRealtime, $queueForFunctions, $queueForWebhooks, $authorization) { + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'committing', ]))); - $operations = Authorization::skip(fn () => $dbForProject->find('transactionLogs', [ + $operations = $authorization->skip(fn () => $dbForProject->find('transactionLogs', [ Query::equal('transactionInternalId', [$transaction->getSequence()]), Query::orderAsc(), Query::limit(PHP_INT_MAX), ])); $state = []; + $collections = []; foreach ($operations as $operation) { $databaseInternalId = $operation['databaseInternalId']; @@ -159,6 +161,21 @@ class Update extends Action $action = $operation['action']; $data = $operation['data']; + if ($data instanceof Document) { + $data = $data->getArrayCopy(); + } + + if (!isset($collections[$collectionId])) { + $collections[$collectionId] = $authorization->skip( + fn () => $dbForProject->getCollection($collectionId) + ); + } + $collection = $collections[$collectionId]; + + if (\is_array($data) && !empty($data)) { + $data = $this->parseOperators($data, $collection); + } + if ($action === 'delete' && $documentId && empty($data)) { $doc = $dbForProject->getDocument($collectionId, $documentId); if (!$doc->isEmpty()) { @@ -172,10 +189,6 @@ class Update extends Action $databaseOperations[$databaseInternalId] = ($databaseOperations[$databaseInternalId] ?? 0) + 1; } - if ($data instanceof Document) { - $data = $data->getArrayCopy(); - } - switch ($action) { case 'create': $this->handleCreateOperation($dbForProject, $collectionId, $documentId, $data, $createdAt, $state); @@ -218,7 +231,7 @@ class Update extends Action } } - $transaction = Authorization::skip(fn () => $dbForProject->updateDocument( + $transaction = $authorization->skip(fn () => $dbForProject->updateDocument( 'transactions', $transactionId, new Document(['status' => 'committed']) @@ -230,32 +243,32 @@ class Update extends Action }); } catch (NotFoundException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::DOCUMENT_NOT_FOUND, previous: $e); } catch (DuplicateException|ConflictException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::TRANSACTION_CONFLICT, previous: $e); } catch (StructureException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage()); } catch (LimitException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, $e->getMessage()); } catch (TransactionException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::TRANSACTION_FAILED, $e->getMessage()); } catch (QueryException $e) { - Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ + $authorization->skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', ]))); throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); @@ -283,11 +296,11 @@ class Update extends Action $data = $data->getArrayCopy(); } - $database = Authorization::skip(fn () => $dbForProject->findOne('databases', [ + $database = $authorization->skip(fn () => $dbForProject->findOne('databases', [ Query::equal('$sequence', [$databaseInternalId]) ])); - $collection = Authorization::skip(fn () => $dbForProject->findOne('database_' . $databaseInternalId, [ + $collection = $authorization->skip(fn () => $dbForProject->findOne('database_' . $databaseInternalId, [ Query::equal('$sequence', [$collectionInternalId]) ])); @@ -379,7 +392,7 @@ class Update extends Action } if ($rollback) { - $transaction = Authorization::skip(fn () => $dbForProject->updateDocument( + $transaction = $authorization->skip(fn () => $dbForProject->updateDocument( 'transactions', $transactionId, new Document(['status' => 'failed']) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php index c9de9d5217..7668ad0a79 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php @@ -59,10 +59,11 @@ class Get extends Action ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $databaseId, string $range, UtopiaResponse $response, Database $dbForProject): void + public function action(string $databaseId, string $range, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { $database = $dbForProject->getDocument('databases', $databaseId); @@ -81,7 +82,7 @@ class Get extends Action str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES) ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/XList.php index c13149cfc7..757f845c68 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/XList.php @@ -56,10 +56,11 @@ class XList extends Action ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $range, UtopiaResponse $response, Database $dbForProject): void + public function action(string $range, UtopiaResponse $response, Database $dbForProject, Authorization $authorization): void { $periods = Config::getParam('usage', []); @@ -74,7 +75,7 @@ class XList extends Action METRIC_DATABASES_OPERATIONS_WRITES, ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Create.php index 039964b2c6..44674b68ca 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Create.php @@ -11,6 +11,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends BooleanCreate { @@ -53,12 +54,13 @@ class Create extends BooleanCreate ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new Boolean(), 'Default value for column when not provided. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new Boolean()), 'Default value for column when not provided. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Update.php index 7df901a1cc..b3643b0e18 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Boolean/Update.php @@ -57,10 +57,11 @@ class Update extends BooleanUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Boolean()), 'Default value for column when not provided. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Create.php index db5a3059f1..5a5970c3bb 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Create.php @@ -13,6 +13,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends DatetimeCreate { @@ -55,12 +56,13 @@ class Create extends DatetimeCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, fn (Database $dbForProject) => new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime()), 'Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required.', true, ['dbForProject']) + ->param('default', null, fn (Database $dbForProject) => new Nullable(new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime())), 'Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required.', true, ['dbForProject']) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Update.php index 151422af75..08bb04b4e5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Datetime/Update.php @@ -59,10 +59,11 @@ class Update extends DatetimeUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, fn (Database $dbForProject) => new Nullable(new DatetimeValidator($dbForProject->getAdapter()->getMinDateTime(), $dbForProject->getAdapter()->getMaxDateTime())), 'Default value for column when not provided. Cannot be set when column is required.', injections: ['dbForProject']) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Delete.php index 26f4ffa898..62152453fe 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Delete.php @@ -58,6 +58,7 @@ class Delete extends AttributesDelete ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php index 3a8d492e4e..050e031591 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; class Create extends EmailCreate { @@ -54,12 +55,13 @@ class Create extends EmailCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new Email(), 'Default value for column when not provided. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new Email()), 'Default value for column when not provided. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php index 4d32489357..c58257c8e1 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Email/Update.php @@ -58,10 +58,11 @@ class Update extends EmailUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Email()), 'Default value for column when not provided. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Create.php index 68dc2f8e08..cc2c109f6a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Create.php @@ -13,6 +13,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends EnumCreate @@ -57,12 +58,13 @@ class Create extends EnumCreate ->param('key', '', new Key(), 'Column Key.') ->param('elements', [], new ArrayList(new Text(Database::LENGTH_KEY), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of enum values.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new Text(0), 'Default value for column when not provided. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new Text(0)), 'Default value for column when not provided. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Update.php index 3b611a5fde..bdb32de1ab 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Enum/Update.php @@ -61,10 +61,11 @@ class Update extends EnumUpdate ->param('elements', null, new ArrayList(new Text(Database::LENGTH_KEY), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Updated list of enum values.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Text(0)), 'Default value for column when not provided. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Create.php index 9fe6987cab..acc82f406b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\FloatValidator; +use Utopia\Validator\Nullable; class Create extends FloatCreate { @@ -54,14 +55,15 @@ class Create extends FloatCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('min', null, new FloatValidator(), 'Minimum value', true) - ->param('max', null, new FloatValidator(), 'Maximum value', true) - ->param('default', null, new FloatValidator(), 'Default value. Cannot be set when required.', true) + ->param('min', null, new Nullable(new FloatValidator()), 'Minimum value', true) + ->param('max', null, new Nullable(new FloatValidator()), 'Maximum value', true) + ->param('default', null, new Nullable(new FloatValidator()), 'Default value. Cannot be set when required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Update.php index 023e2e834e..f53cd711e0 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Float/Update.php @@ -57,13 +57,14 @@ class Update extends FloatUpdate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('min', null, new FloatValidator(), 'Minimum value', true) - ->param('max', null, new FloatValidator(), 'Maximum value', true) + ->param('min', null, new Nullable(new FloatValidator()), 'Minimum value', true) + ->param('max', null, new Nullable(new FloatValidator()), 'Maximum value', true) ->param('default', null, new Nullable(new FloatValidator()), 'Default value. Cannot be set when required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php index c20ef58a39..0e7e079a02 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php @@ -61,6 +61,7 @@ class Get extends AttributesGet ->param('key', '', new Key(), 'Column Key.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Create.php index 81ca8da81f..804ebc6e14 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\IP; +use Utopia\Validator\Nullable; class Create extends IPCreate { @@ -54,12 +55,13 @@ class Create extends IPCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new IP(), 'Default value. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new IP()), 'Default value. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Update.php index 0db95b0206..e600c0a349 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/IP/Update.php @@ -58,10 +58,11 @@ class Update extends IPUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new IP()), 'Default value. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php index dfca51a6c5..1980234536 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\Integer; +use Utopia\Validator\Nullable; class Create extends IntegerCreate { @@ -54,14 +55,15 @@ class Create extends IntegerCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('min', null, new Integer(), 'Minimum value', true) - ->param('max', null, new Integer(), 'Maximum value', true) - ->param('default', null, new Integer(), 'Default value. Cannot be set when column is required.', true) + ->param('min', null, new Nullable(new Integer()), 'Minimum value', true) + ->param('max', null, new Nullable(new Integer()), 'Maximum value', true) + ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php index a1568d069b..cbf574010c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php @@ -57,13 +57,14 @@ class Update extends IntegerUpdate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('min', null, new Integer(), 'Minimum value', true) - ->param('max', null, new Integer(), 'Maximum value', true) + ->param('min', null, new Nullable(new Integer()), 'Minimum value', true) + ->param('max', null, new Nullable(new Integer()), 'Maximum value', true) ->param('default', null, new Nullable(new Integer()), 'Default value. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Create.php index 4aa173707b..469fb6851f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Create.php @@ -61,6 +61,7 @@ class Create extends LineCreate ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Update.php index d3823445a2..b6a1336c00 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Line/Update.php @@ -59,10 +59,11 @@ class Update extends LineUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_LINESTRING)), 'Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required.', true) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Create.php index b8ae563def..715348e1f4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Create.php @@ -61,6 +61,7 @@ class Create extends PointCreate ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Update.php index 3c855e137c..c0c4c10689 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Point/Update.php @@ -59,10 +59,11 @@ class Update extends PointUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_POINT)), 'Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required.', true) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Create.php index e0a2cf32cd..38c9eaf284 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Create.php @@ -61,6 +61,7 @@ class Create extends PolygonCreate ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Update.php index 866bbaf8b0..12d6b95a72 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Polygon/Update.php @@ -59,10 +59,11 @@ class Update extends PolygonUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Spatial(Database::VAR_POLYGON)), 'Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required.', true) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Create.php index 0a6c76d8c5..84c2123f4d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\WhiteList; class Create extends RelationshipCreate @@ -61,8 +62,8 @@ class Create extends RelationshipCreate Database::RELATION_ONE_TO_MANY ], true), 'Relation type') ->param('twoWay', false, new Boolean(), 'Is Two Way?', true) - ->param('key', null, new Key(), 'Column Key.', true) - ->param('twoWayKey', null, new Key(), 'Two Way Column Key.', true) + ->param('key', null, new Nullable(new Key()), 'Column Key.', true) + ->param('twoWayKey', null, new Nullable(new Key()), 'Two Way Column Key.', true) ->param('onDelete', Database::RELATION_MUTATE_RESTRICT, new WhiteList([ Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_RESTRICT, @@ -72,6 +73,7 @@ class Create extends RelationshipCreate ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Update.php index b645454be1..b87fc3d33a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Relationship/Update.php @@ -12,6 +12,7 @@ use Utopia\Database\Database; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\WhiteList; class Update extends RelationshipUpdate @@ -55,15 +56,16 @@ class Update extends RelationshipUpdate ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') - ->param('onDelete', null, new WhiteList([ + ->param('onDelete', null, new Nullable(new WhiteList([ Database::RELATION_MUTATE_CASCADE, Database::RELATION_MUTATE_RESTRICT, Database::RELATION_MUTATE_SET_NULL - ], true), 'Constraints option', true) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ], true)), 'Constraints option', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Create.php index 6fe9fd679c..02a04a2da0 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Create.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Range; use Utopia\Validator\Text; @@ -57,7 +58,7 @@ class Create extends StringCreate ->param('key', '', new Key(), 'Column Key.') ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER), 'Column size for text columns, in number of characters.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new Text(0, 0), 'Default value for column when not provided. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new Text(0, 0)), 'Default value for column when not provided. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->param('encrypt', false, new Boolean(), 'Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried.', true) ->inject('response') @@ -65,6 +66,7 @@ class Create extends StringCreate ->inject('queueForDatabase') ->inject('queueForEvents') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Update.php index 5ec9b78dda..9270d7d7c7 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/String/Update.php @@ -60,11 +60,12 @@ class Update extends StringUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new Text(0, 0)), 'Default value for column when not provided. Cannot be set when column is required.') - ->param('size', null, new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER), 'Maximum size of the string column.', true) - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('size', null, new Nullable(new Range(1, APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH, Validator::TYPE_INTEGER)), 'Maximum size of the string column.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Create.php index 99ec36b721..051e8cbbbb 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Create.php @@ -11,6 +11,7 @@ use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\URL; class Create extends URLCreate @@ -54,12 +55,13 @@ class Create extends URLCreate ->param('tableId', '', new UID(), 'Table ID.') ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') - ->param('default', null, new URL(), 'Default value for column when not provided. Cannot be set when column is required.', true) + ->param('default', null, new Nullable(new URL()), 'Default value for column when not provided. Cannot be set when column is required.', true) ->param('array', false, new Boolean(), 'Is column an array?', true) ->inject('response') ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Update.php index 51168b0383..8854e701ef 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/URL/Update.php @@ -58,10 +58,11 @@ class Update extends URLUpdate ->param('key', '', new Key(), 'Column Key.') ->param('required', null, new Boolean(), 'Is column required?') ->param('default', null, new Nullable(new URL()), 'Default value for column when not provided. Cannot be set when column is required.') - ->param('newKey', null, new Key(), 'New Column Key.', true) + ->param('newKey', null, new Nullable(new Key()), 'New Column Key.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php index 1e0b641b32..950d38f8a7 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php @@ -52,6 +52,7 @@ class XList extends AttributesXList ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Create.php index 4f62200d7c..5b598b1a12 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Create.php @@ -13,6 +13,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends CollectionCreate @@ -56,12 +57,13 @@ class Create extends CollectionCreate ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new CustomId(), 'Unique 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.') ->param('name', '', new Text(128), 'Table name. Max length: 128 chars.') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('rowSecurity', false, new Boolean(true), 'Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Delete.php index de068d5b29..79b9e7beef 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Delete.php @@ -55,6 +55,7 @@ class Delete extends CollectionDelete ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php index be6ec5d9e7..e264ec0411 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php @@ -50,6 +50,7 @@ class Get extends CollectionGet ->param('tableId', '', new UID(), 'Table ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Create.php index 3802ee32b8..165f014320 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Create.php @@ -2,6 +2,8 @@ namespace Appwrite\Platform\Modules\Databases\Http\TablesDB\Tables\Indexes; +use Appwrite\Event\Database as EventDatabase; +use Appwrite\Event\Event; use Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Indexes\Create as IndexCreate; use Appwrite\SDK\AuthType; use Appwrite\SDK\ContentType; @@ -9,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; @@ -66,6 +69,15 @@ class Create extends IndexCreate ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } + + public function action(string $databaseId, string $tableId, string $key, string $type, array $columns, array $orders, array $lengths, UtopiaResponse $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, Authorization $authorization): void + { + // Map TablesDB parameters to Collections API parameters + // tableId -> collectionId + // columns -> attributes + parent::action($databaseId, $tableId, $key, $type, $columns, $orders, $lengths, $response, $dbForProject, $queueForDatabase, $queueForEvents, $authorization); + } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Delete.php index 57ab466ee8..cb552a086c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Delete.php @@ -61,6 +61,7 @@ class Delete extends IndexDelete ->inject('dbForProject') ->inject('queueForDatabase') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php index 271d842631..3c01f1b64d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php @@ -52,6 +52,7 @@ class Get extends IndexGet ->param('key', null, new Key(), 'Index Key.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php index 0ea52eaf1b..a6206f06dd 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php @@ -54,6 +54,7 @@ class XList extends IndexXList ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Logs/XList.php index 0680649544..f9111287c3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Logs/XList.php @@ -50,6 +50,7 @@ class XList extends CollectionLogXList ->inject('dbForProject') ->inject('locale') ->inject('geodb') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Delete.php index 86e9a48f63..b9896d282d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Delete.php @@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Delete extends DocumentsDelete @@ -56,7 +57,7 @@ class Delete extends DocumentsDelete ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).') ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -65,6 +66,7 @@ class Delete extends DocumentsDelete ->inject('queueForFunctions') ->inject('queueForWebhooks') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php index 5005ab4f41..e3bf1f9eef 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends DocumentsUpdate @@ -58,7 +59,7 @@ class Update extends DocumentsUpdate ->param('tableId', '', new UID(), 'Table ID.') ->param('data', [], new JSON(), 'Row data as JSON object. Include only column and value pairs to be updated.', true) ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -67,6 +68,7 @@ class Update extends DocumentsUpdate ->inject('queueForFunctions') ->inject('queueForWebhooks') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Upsert.php index d0a1f08003..69a687d92f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Upsert.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Upsert extends DocumentsUpsert { @@ -58,7 +59,7 @@ class Upsert extends DocumentsUpsert ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID.') ->param('rows', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of row data as JSON objects. May contain partial rows.', false, ['plan']) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') @@ -67,6 +68,7 @@ class Upsert extends DocumentsUpsert ->inject('queueForFunctions') ->inject('queueForWebhooks') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Decrement.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Decrement.php index d42cf5e9eb..a660b008e1 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Decrement.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Decrement.php @@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\Numeric; class Decrement extends DecrementDocumentAttribute @@ -59,13 +60,14 @@ class Decrement extends DecrementDocumentAttribute ->param('rowId', '', new UID(), 'Row ID.') ->param('column', '', new Key(), 'Column key.') ->param('value', 1, new Numeric(), 'Value to increment the column by. The value must be a number.', true) - ->param('min', null, new Numeric(), 'Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('min', null, new Nullable(new Numeric()), 'Minimum value for the column. If the current value is lesser than this value, an exception will be thrown.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') ->inject('queueForStatsUsage') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Increment.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Increment.php index c58e16c8e3..c2b69429ce 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Increment.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Column/Increment.php @@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; use Utopia\Validator\Numeric; class Increment extends IncrementDocumentAttribute @@ -59,13 +60,14 @@ class Increment extends IncrementDocumentAttribute ->param('rowId', '', new UID(), 'Row ID.') ->param('column', '', new Key(), 'Column key.') ->param('value', 1, new Numeric(), 'Value to increment the column by. The value must be a number.', true) - ->param('max', null, new Numeric(), 'Maximum value for the column. If the current value is greater than this value, an error will be thrown.', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('max', null, new Nullable(new Numeric()), 'Maximum value for the column. If the current value is greater than this value, an error will be thrown.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') ->inject('queueForStatsUsage') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Create.php index bfc832f2b5..4fe7c2f9f6 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Create.php @@ -16,6 +16,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Create extends DocumentCreate { @@ -98,9 +99,9 @@ class Create extends DocumentCreate ->param('rowId', '', new CustomId(), 'Row 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.', true) ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows.') ->param('data', [], new JSON(), 'Row data as JSON object.', true, example: '{"username":"walter.obrien","email":"walter.obrien@example.com","fullName":"Walter O\'Brien","age":30,"isAdmin":false}') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('rows', [], fn (array $plan) => new ArrayList(new JSON(), $plan['databasesBatchSize'] ?? APP_LIMIT_DATABASE_BATCH), 'Array of rows data as JSON objects.', true, ['plan']) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('response') ->inject('dbForProject') ->inject('user') @@ -110,6 +111,7 @@ class Create extends DocumentCreate ->inject('queueForFunctions') ->inject('queueForWebhooks') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Delete.php index 687b1c8c11..d76a907186 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Delete.php @@ -10,6 +10,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; +use Utopia\Validator\Nullable; class Delete extends DocumentDelete { @@ -61,7 +62,7 @@ class Delete extends DocumentDelete ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).') ->param('rowId', '', new UID(), 'Row ID.') - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') @@ -69,6 +70,7 @@ class Delete extends DocumentDelete ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php index f8b70516b6..ebc751a8e6 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php @@ -11,6 +11,7 @@ use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Get extends DocumentGet @@ -52,11 +53,12 @@ class Get extends DocumentGet ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable).') ->param('rowId', '', new UID(), 'Row ID.') ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID to read uncommitted changes within the transaction.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID to read uncommitted changes within the transaction.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') ->inject('transactionState') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Logs/XList.php index 5f1efa2953..5117e77ea9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Logs/XList.php @@ -51,6 +51,7 @@ class XList extends DocumentLogXList ->inject('dbForProject') ->inject('locale') ->inject('geodb') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php index cb1d5888cf..6265451b57 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php @@ -13,6 +13,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Update extends DocumentUpdate { @@ -59,8 +60,8 @@ class Update extends DocumentUpdate ->param('tableId', '', new UID(), 'Table ID.') ->param('rowId', '', new UID(), 'Row ID.') ->param('data', [], new JSON(), 'Row data as JSON object. Include only columns and value pairs to be updated.', true) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') @@ -68,6 +69,7 @@ class Update extends DocumentUpdate ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php index 0bc373cc93..105750ddbd 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php @@ -13,6 +13,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\JSON; +use Utopia\Validator\Nullable; class Upsert extends DocumentUpsert { @@ -61,8 +62,8 @@ class Upsert extends DocumentUpsert ->param('tableId', '', new UID(), 'Table ID.') ->param('rowId', '', new UID(), 'Row ID.') ->param('data', [], new JSON(), 'Row data as JSON object. Include all required columns of the row to be created or updated.', true) - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE]), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - ->param('transactionId', null, new UID(), 'Transaction ID for staging the operation.', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE, [Database::PERMISSION_READ, Database::PERMISSION_UPDATE, Database::PERMISSION_DELETE, Database::PERMISSION_WRITE])), 'An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID for staging the operation.', true) ->inject('requestTimestamp') ->inject('response') ->inject('user') @@ -71,6 +72,7 @@ class Upsert extends DocumentUpsert ->inject('queueForStatsUsage') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php index b96e84b722..9486a8abeb 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\ArrayList; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class XList extends DocumentXList @@ -52,12 +53,13 @@ class XList extends DocumentXList ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table).') ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) - ->param('transactionId', null, new UID(), 'Transaction ID to read uncommitted changes within the transaction.', true) + ->param('transactionId', null, new Nullable(new UID()), 'Transaction ID to read uncommitted changes within the transaction.', true) ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForStatsUsage') ->inject('transactionState') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php index 8424b37a6d..aea590168d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php @@ -12,6 +12,7 @@ use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\UID; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends CollectionUpdate @@ -55,12 +56,13 @@ class Update extends CollectionUpdate ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID.') ->param('name', null, new Text(128), 'Table name. Max length: 128 chars.') - ->param('permissions', null, new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) - ->param('rowSecurity', false, new Boolean(true), 'Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) + ->param('rowSecurity', false, new Boolean(true), 'Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions).', true) ->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Usage/Get.php index 0fb44ee94a..b8be7edd56 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Usage/Get.php @@ -52,6 +52,7 @@ class Get extends CollectionUsageGet ->param('tableId', '', new UID(), 'Table ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/XList.php index 5e8fcfc3c8..eafb291037 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/XList.php @@ -55,6 +55,7 @@ class XList extends CollectionXList ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Create.php index bc79b86ca3..1c6f0f95ca 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Create.php @@ -50,6 +50,7 @@ class Create extends TransactionsCreate ->inject('response') ->inject('dbForProject') ->inject('user') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Operations/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Operations/Create.php index 5a98f22f37..2e3b73e395 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Operations/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Operations/Create.php @@ -54,6 +54,7 @@ class Create extends OperationsCreate ->inject('dbForProject') ->inject('transactionState') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Update.php index 4d55af93a4..250c9e0bc4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Transactions/Update.php @@ -60,6 +60,7 @@ class Update extends TransactionsUpdate ->inject('queueForRealtime') ->inject('queueForFunctions') ->inject('queueForWebhooks') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/Get.php index 89b9fbd8c2..87be8a9eab 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/Get.php @@ -48,6 +48,7 @@ class Get extends DatabaseUsageGet ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/XList.php index 0bd96fc40a..2cde337f5f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Usage/XList.php @@ -46,6 +46,7 @@ class XList extends DatabaseUsageXList ->param('range', '30d', new WhiteList(['24h', '30d', '90d'], true), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index f64a960507..d53324b27f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -28,6 +28,7 @@ use Utopia\Storage\Validator\Upload; use Utopia\Swoole\Request; use Utopia\System\System; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends Action @@ -74,8 +75,8 @@ class Create extends Action packaging: true, )) ->param('functionId', '', new UID(), 'Function ID.') - ->param('entrypoint', null, new Text(1028), 'Entrypoint File.', true) - ->param('commands', null, new Text(8192, 0), 'Build Commands.', true) + ->param('entrypoint', null, new Nullable(new Text(1028)), 'Entrypoint File.', true) + ->param('commands', null, new Nullable(new Text(8192, 0)), 'Build Commands.', true) ->param('code', [], new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', skipValidation: true) ->param('activate', false, new Boolean(true), 'Automatically activate the deployment when it is finished building.') ->inject('request') diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php index bbe84c56ee..00c29d6bba 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php @@ -21,6 +21,7 @@ use Utopia\Platform\Scope\HTTP; use Utopia\Swoole\Request; use Utopia\Validator\Boolean; use Utopia\Validator\Text; +use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; class Create extends Base @@ -65,7 +66,8 @@ class Create extends Base ->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('rootDirectory', '', new Text(128, 0), 'Path to function code in the template repo.') - ->param('version', '', new Text(128, 0), 'Version (tag) for the repo linked to the function template.') + ->param('type', '', new WhiteList(['commit', 'branch', 'tag']), 'Type for the reference provided. Can be commit, branch, or 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) ->inject('request') ->inject('response') @@ -83,7 +85,8 @@ class Create extends Base string $repository, string $owner, string $rootDirectory, - string $version, + string $type, + string $reference, bool $activate, Request $request, Response $response, @@ -100,11 +103,16 @@ class Create extends Base throw new Exception(Exception::FUNCTION_NOT_FOUND); } + $branchUrl = "https://github.com/$owner/$repository/blob/$reference"; + + $repositoryUrl = "https://github.com/$owner/$repository"; + $template = new Document([ 'repositoryName' => $repository, 'ownerName' => $owner, 'rootDirectory' => $rootDirectory, - 'version' => $version + 'referenceType' => $type, + 'referenceValue' => $reference, ]); if (!empty($function->getAttribute('providerRepositoryId'))) { @@ -146,7 +154,12 @@ class Create extends Base 'resourceType' => 'functions', 'entrypoint' => $function->getAttribute('entrypoint', ''), 'buildCommands' => $function->getAttribute('commands', ''), - 'type' => 'manual', + 'providerRepositoryName' => $repository, + 'providerRepositoryOwner' => $owner, + 'providerRepositoryUrl' => $repositoryUrl, + 'providerBranchUrl' => $branchUrl, + 'providerBranch' => $type == GitHub::CLONE_TYPE_BRANCH ? $reference : '', + 'type' => 'vcs', 'activate' => $activate, ])); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php index 69af3b7d04..593c3dde55 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php @@ -27,6 +27,7 @@ use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\Datetime as DatetimeValidator; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; @@ -36,6 +37,7 @@ use Utopia\System\System; use Utopia\Validator\AnyOf; use Utopia\Validator\Assoc; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; use Utopia\Validator\WhiteList; @@ -81,7 +83,7 @@ class Create extends Base ->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('headers', [], new AnyOf([new Assoc(), new Text(65535)], AnyOf::TYPE_MIXED), 'HTTP headers of execution. Defaults to empty.', true) - ->param('scheduledAt', null, 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('request') ->inject('project') @@ -93,6 +95,7 @@ class Create extends Base ->inject('queueForFunctions') ->inject('geodb') ->inject('executor') + ->inject('authorization') ->callback($this->action(...)); } @@ -114,7 +117,8 @@ class Create extends Base StatsUsage $queueForStatsUsage, Func $queueForFunctions, Reader $geodb, - Executor $executor + Executor $executor, + Authorization $authorization ) { $async = \strval($async) === 'true' || \strval($async) === '1'; @@ -152,10 +156,10 @@ class Create extends Base throw new Exception($validator->getDescription(), 400); } - $function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId)); + $function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($function->isEmpty() || (!$function->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::FUNCTION_NOT_FOUND); @@ -171,7 +175,7 @@ class Create extends Base throw new Exception(Exception::FUNCTION_RUNTIME_UNSUPPORTED, 'Runtime "' . $function->getAttribute('runtime', '') . '" is not supported'); } - $deployment = Authorization::skip(fn () => $dbForProject->getDocument('deployments', $function->getAttribute('deploymentId', ''))); + $deployment = $authorization->skip(fn () => $dbForProject->getDocument('deployments', $function->getAttribute('deploymentId', ''))); if ($deployment->getAttribute('resourceId') !== $function->getId()) { throw new Exception(Exception::DEPLOYMENT_NOT_FOUND, 'Deployment not found. Create a deployment before trying to execute a function'); @@ -185,10 +189,8 @@ class Create extends Base throw new Exception(Exception::BUILD_NOT_READY); } - $validator = new Authorization('execute'); - - if (!$validator->isValid($function->getAttribute('execute'))) { // Check if user has write access to execute function - throw new Exception(Exception::USER_UNAUTHORIZED, $validator->getDescription()); + if (!$authorization->isValid(new Input('execute', $function->getAttribute('execute')))) { // Check if user has write access to execute function + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } $jwt = ''; // initialize @@ -286,7 +288,7 @@ class Create extends Base if ($async) { if (is_null($scheduledAt)) { - $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + $execution = $authorization->skip(fn () => $dbForProject->createDocument('executions', $execution)); $queueForFunctions ->setType('http') ->setExecution($execution) @@ -327,7 +329,7 @@ class Create extends Base ->setAttribute('scheduleInternalId', $schedule->getSequence()) ->setAttribute('scheduledAt', $scheduledAt); - $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + $execution = $authorization->skip(fn () => $dbForProject->createDocument('executions', $execution)); } return $response @@ -480,7 +482,7 @@ class Create extends Base ->addMetric(str_replace(['{resourceType}', '{resourceInternalId}'], [RESOURCE_TYPE_FUNCTIONS, $function->getSequence()], METRIC_RESOURCE_TYPE_ID_EXECUTIONS_MB_SECONDS), (int)(($spec['memory'] ?? APP_COMPUTE_MEMORY_DEFAULT) * $execution->getAttribute('duration', 0) * ($spec['cpus'] ?? APP_COMPUTE_CPUS_DEFAULT))) ; - $execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', $execution)); + $execution = $authorization->skip(fn () => $dbForProject->createDocument('executions', $execution)); } $executionResponse['headers']['x-appwrite-execution-id'] = $execution->getId(); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Delete.php index 666cb8310c..ccf345dbb5 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Delete.php @@ -61,6 +61,7 @@ class Delete extends Base ->inject('dbForProject') ->inject('dbForPlatform') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } @@ -70,7 +71,8 @@ class Delete extends Base Response $response, Database $dbForProject, Database $dbForPlatform, - Event $queueForEvents + Event $queueForEvents, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -108,7 +110,7 @@ class Delete extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('active', false); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); } } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php index 42d78f8ca8..69c4080f8a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Get.php @@ -52,6 +52,7 @@ class Get extends Base ->param('executionId', '', new UID(), 'Execution ID.') ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } @@ -59,12 +60,13 @@ class Get extends Base string $functionId, string $executionId, Response $response, - Database $dbForProject + Database $dbForProject, + Authorization $authorization ) { - $function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId)); + $function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($function->isEmpty() || (!$function->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::FUNCTION_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/XList.php index 3d5ec06ace..52562aadf8 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/XList.php @@ -60,6 +60,7 @@ class XList extends Base ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } @@ -68,12 +69,13 @@ class XList extends Base array $queries, bool $includeTotal, Response $response, - Database $dbForProject + Database $dbForProject, + Authorization $authorization ) { - $function = Authorization::skip(fn () => $dbForProject->getDocument('functions', $functionId)); + $function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($function->isEmpty() || (!$function->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::FUNCTION_NOT_FOUND); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index ec2a4baac5..182f39e274 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -115,6 +115,7 @@ class Create extends Base ->inject('dbForPlatform') ->inject('request') ->inject('gitHub') + ->inject('authorization') ->callback($this->action(...)); } @@ -152,7 +153,8 @@ class Create extends Base Func $queueForFunctions, Database $dbForPlatform, Request $request, - GitHub $github + GitHub $github, + Authorization $authorization ) { // Temporary abuse check @@ -237,7 +239,7 @@ class Create extends Base throw new Exception(Exception::FUNCTION_ALREADY_EXISTS); } - $schedule = Authorization::skip( + $schedule = $authorization->skip( fn () => $dbForPlatform->createDocument('schedules', new Document([ 'region' => $project->getAttribute('region'), 'resourceType' => SCHEDULE_RESOURCE_TYPE_FUNCTION, @@ -365,7 +367,7 @@ class Create extends Base // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); - $rule = Authorization::skip( + $rule = $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Delete.php index 72d5589252..6c9c9c3c6f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Delete.php @@ -61,6 +61,7 @@ class Delete extends Base ->inject('queueForDeletes') ->inject('queueForEvents') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -70,7 +71,8 @@ class Delete extends Base Database $dbForProject, DeleteEvent $queueForDeletes, Event $queueForEvents, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -87,7 +89,7 @@ class Delete extends Base $schedule ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('active', false); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $queueForDeletes ->setType(DELETE_TYPE_DOCUMENT) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php index 8846329d27..b913848a13 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Deployment/Update.php @@ -62,6 +62,7 @@ class Update extends Base ->inject('dbForProject') ->inject('queueForEvents') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -72,7 +73,8 @@ class Update extends Base Response $response, Database $dbForProject, Event $queueForEvents, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); $deployment = $dbForProject->getDocument('deployments', $deploymentId); @@ -101,7 +103,7 @@ class Update extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $queries = [ Query::equal('trigger', ['manual']), @@ -112,12 +114,12 @@ class Update extends Base Query::equal('projectInternalId', [$project->getSequence()]) ]; - Authorization::skip(fn () => $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { + $authorization->skip(fn () => $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment, $authorization) { $rule = $rule ->setAttribute('deploymentId', $deployment->getId()) ->setAttribute('deploymentInternalId', $deployment->getSequence()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), $rule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), $rule)); }, $queries)); $queueForEvents diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php index 318c2a2032..d182bb67ea 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php @@ -104,6 +104,7 @@ class Update extends Base ->inject('dbForPlatform') ->inject('gitHub') ->inject('executor') + ->inject('authorization') ->callback($this->action(...)); } @@ -134,7 +135,8 @@ class Update extends Base Build $queueForBuilds, Database $dbForPlatform, GitHub $github, - Executor $executor + Executor $executor, + Authorization $authorization ) { // TODO: If only branch changes, re-deploy $function = $dbForProject->getDocument('functions', $functionId); @@ -282,7 +284,7 @@ class Update extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $queueForEvents->setParam('functionId', $function->getId()); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php b/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php index acb6995d6f..1fa65d0cc9 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Usage/Get.php @@ -55,10 +55,11 @@ class Get extends Base ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $functionId, string $range, Response $response, Database $dbForProject) + public function action(string $functionId, string $range, Response $response, Database $dbForProject, Authorization $authorization) { $function = $dbForProject->getDocument('functions', $functionId); @@ -83,7 +84,7 @@ class Get extends Base str_replace(['{resourceType}', '{resourceInternalId}'], [RESOURCE_TYPE_FUNCTIONS, $function->getSequence()], METRIC_RESOURCE_TYPE_ID_BUILDS_FAILED), ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Usage/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Usage/XList.php index 6a4ded4db7..38a95d4469 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Usage/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Usage/XList.php @@ -52,10 +52,11 @@ class XList extends Base ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $range, Response $response, Database $dbForProject) + public function action(string $range, Response $response, Database $dbForProject, Authorization $authorization) { $periods = Config::getParam('usage', []); $stats = $usage = []; @@ -75,7 +76,7 @@ class XList extends Base str_replace("{resourceType}", RESOURCE_TYPE_FUNCTIONS, METRIC_RESOURCE_TYPE_BUILDS_FAILED), ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Create.php index 815d364dad..ae74bfa98a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Create.php @@ -65,6 +65,7 @@ class Create extends Base ->inject('dbForProject') ->inject('dbForPlatform') ->inject('project') + ->inject('authorization') ->callback($this->action(...)); } @@ -76,7 +77,8 @@ class Create extends Base Response $response, Database $dbForProject, Database $dbForPlatform, - Document $project + Document $project, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -119,7 +121,7 @@ class Create extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $response ->setStatusCode(Response::STATUS_CODE_CREATED) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Delete.php index 35f9618edb..dcb80e4c8c 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Delete.php @@ -57,6 +57,7 @@ class Delete extends Base ->inject('response') ->inject('dbForProject') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -65,7 +66,8 @@ class Delete extends Base string $variableId, Response $response, Database $dbForProject, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -92,7 +94,7 @@ class Delete extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $response->noContent(); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php index 639b1c74d5..959e2608d4 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Variables/Update.php @@ -16,6 +16,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends Base @@ -56,11 +57,12 @@ class Update extends Base ->param('functionId', '', new UID(), 'Function unique ID.', false) ->param('variableId', '', new UID(), 'Variable unique ID.', false) ->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false) - ->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.', true) - ->param('secret', null, new Boolean(), 'Secret variables can be updated or deleted, but only functions can read them during build and runtime.', true) + ->param('value', null, new Nullable(new Text(8192, 0)), 'Variable value. Max length: 8192 chars.', true) + ->param('secret', null, new Nullable(new Boolean()), 'Secret variables can be updated or deleted, but only functions can read them during build and runtime.', true) ->inject('response') ->inject('dbForProject') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -72,7 +74,8 @@ class Update extends Base ?bool $secret, Response $response, Database $dbForProject, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { $function = $dbForProject->getDocument('functions', $functionId); @@ -109,7 +112,7 @@ class Update extends Base ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); $response->dynamic($variable, Response::MODEL_VARIABLE); } diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index f9aa60db5f..0a7a35d2e8 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -27,7 +27,6 @@ use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\Detector\Detection\Rendering\SSR; use Utopia\Detector\Detection\Rendering\XStatic; use Utopia\Detector\Detector\Rendering; @@ -310,20 +309,23 @@ class Builds extends Action // Non-VCS + Template $templateRepositoryName = $template->getAttribute('repositoryName', ''); $templateOwnerName = $template->getAttribute('ownerName', ''); - $templateVersion = $template->getAttribute('version', ''); + $templateReferenceType = $template->getAttribute('referenceType', ''); + $templateReferenceValue = $template->getAttribute('referenceValue', ''); $templateRootDirectory = $template->getAttribute('rootDirectory', ''); $templateRootDirectory = \rtrim($templateRootDirectory, '/'); $templateRootDirectory = \ltrim($templateRootDirectory, '.'); $templateRootDirectory = \ltrim($templateRootDirectory, '/'); - if (!empty($templateRepositoryName) && !empty($templateOwnerName) && !empty($templateVersion)) { + if (!empty($templateRepositoryName) && !empty($templateOwnerName) && !empty($templateReferenceType) && !empty($templateReferenceValue)) { $stdout = ''; $stderr = ''; // Clone template repo $tmpTemplateDirectory = '/tmp/builds/' . $deploymentId . '-template'; - $gitCloneCommandForTemplate = $github->generateCloneCommand($templateOwnerName, $templateRepositoryName, $templateVersion, GitHub::CLONE_TYPE_TAG, $tmpTemplateDirectory, $templateRootDirectory); + + $gitCloneCommandForTemplate = $github->generateCloneCommand($templateOwnerName, $templateRepositoryName, $templateReferenceValue, $templateReferenceType, $tmpTemplateDirectory, $templateRootDirectory); + $exit = Console::execute($gitCloneCommandForTemplate, '', $stdout, $stderr); if ($exit !== 0) { @@ -922,11 +924,11 @@ class Builds extends Action ->trigger(); try { - $rule = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [ + $rule = $dbForPlatform->findOne('rules', [ Query::equal("projectInternalId", [$project->getSequence()]), Query::equal("type", ["deployment"]), Query::equal('deploymentInternalId', [$deployment->getSequence()]), - ])); + ]); if ($rule->isEmpty()) { throw new \Exception("Rule for build not found"); @@ -936,7 +938,7 @@ class Builds extends Action $client->setTimeout(\intval($resource->getAttribute('timeout', '15'))); $client->addHeader('content-type', FetchClient::CONTENT_TYPE_APPLICATION_JSON); - $bucket = Authorization::skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')); + $bucket = $dbForPlatform->getDocument('buckets', 'screenshots'); $configs = [ 'screenshotLight' => [ @@ -1058,7 +1060,7 @@ class Builds extends Action 'metadata' => ['content_type' => $mimeType], ]); - Authorization::skip(fn () => $dbForPlatform->createDocument('bucket_' . $bucket->getSequence(), $file)); + $dbForPlatform->createDocument('bucket_' . $bucket->getSequence(), $file); $deployment->setAttribute($key, $fileId); } @@ -1281,7 +1283,7 @@ class Builds extends Action ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $resource->getAttribute('schedule')) ->setAttribute('active', !empty($resource->getAttribute('schedule')) && !empty($resource->getAttribute('deploymentId'))); - Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule)); + $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule); } Console::info('Deployment action finished'); @@ -1488,7 +1490,6 @@ class Builds extends Action * @return void * @throws Structure * @throws \Utopia\Database\Exception - * @throws Authorization * @throws Conflict * @throws Restricted */ @@ -1576,11 +1577,11 @@ class Builds extends Action default => throw new \Exception('Invalid resource type') }; - $rule = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [ + $rule = $dbForPlatform->findOne('rules', [ Query::equal("projectInternalId", [$project->getSequence()]), Query::equal("type", ["deployment"]), Query::equal("deploymentInternalId", [$deployment->getSequence()]), - ])); + ]); $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; $previewUrl = match($resource->getCollection()) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index 4bd3afa1f5..107c7b1389 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -29,6 +29,7 @@ use Utopia\Storage\Validator\Upload; use Utopia\Swoole\Request; use Utopia\System\System; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Create extends Action @@ -71,9 +72,9 @@ class Create extends Action packaging: true, )) ->param('siteId', '', new UID(), 'Site ID.') - ->param('installCommand', null, new Text(8192, 0), 'Install Commands.', true) - ->param('buildCommand', null, new Text(8192, 0), 'Build Commands.', true) - ->param('outputDirectory', null, new Text(8192, 0), 'Output Directory.', true) + ->param('installCommand', null, new Nullable(new Text(8192, 0)), 'Install Commands.', true) + ->param('buildCommand', null, new Nullable(new Text(8192, 0)), 'Build Commands.', true) + ->param('outputDirectory', null, new Nullable(new Text(8192, 0)), 'Output Directory.', true) ->param('code', [], new File(), 'Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.', skipValidation: true) ->param('activate', false, new Boolean(true), 'Automatically activate the deployment when it is finished building.') ->inject('request') @@ -86,6 +87,7 @@ class Create extends Action ->inject('deviceForLocal') ->inject('queueForBuilds') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } @@ -105,7 +107,8 @@ class Create extends Action Device $deviceForSites, Device $deviceForLocal, Build $queueForBuilds, - array $plan + array $plan, + Authorization $authorization ) { $activate = \strval($activate) === 'true' || \strval($activate) === '1'; @@ -274,7 +277,7 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), @@ -339,7 +342,7 @@ class Create extends Action $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; $ruleId = md5($domain); - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 065dd13e88..21f86aea35 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -65,6 +65,7 @@ class Create extends Action ->inject('queueForEvents') ->inject('queueForBuilds') ->inject('deviceForSites') + ->inject('authorization') ->callback($this->action(...)); } @@ -78,7 +79,8 @@ class Create extends Action Database $dbForPlatform, Event $queueForEvents, Build $queueForBuilds, - Device $deviceForSites + Device $deviceForSites, + Authorization $authorization ) { $site = $dbForProject->getDocument('sites', $siteId); @@ -146,7 +148,7 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index dc90045b0c..4da3e9b34f 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -23,6 +23,7 @@ use Utopia\Swoole\Request; use Utopia\System\System; use Utopia\Validator\Boolean; use Utopia\Validator\Text; +use Utopia\Validator\WhiteList; use Utopia\VCS\Adapter\Git\GitHub; class Create extends Base @@ -67,7 +68,8 @@ class Create extends Base ->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('rootDirectory', '', new Text(128, 0), 'Path to site code in the template repo.') - ->param('version', '', new Text(128, 0), 'Version (tag) for the repo linked to the site template.') + ->param('type', '', new WhiteList(['branch', 'commit', 'tag']), 'Type for the reference provided. Can be commit, branch, or 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) ->inject('request') ->inject('response') @@ -77,6 +79,7 @@ class Create extends Base ->inject('queueForEvents') ->inject('queueForBuilds') ->inject('gitHub') + ->inject('authorization') ->callback($this->action(...)); } @@ -85,7 +88,8 @@ class Create extends Base string $repository, string $owner, string $rootDirectory, - string $version, + string $type, + string $reference, bool $activate, Request $request, Response $response, @@ -94,7 +98,8 @@ class Create extends Base Document $project, Event $queueForEvents, Build $queueForBuilds, - GitHub $github + GitHub $github, + Authorization $authorization ) { $site = $dbForProject->getDocument('sites', $siteId); @@ -102,11 +107,15 @@ class Create extends Base throw new Exception(Exception::SITE_NOT_FOUND); } + $branchUrl = "https://github.com/$owner/$repository/blob/$reference"; + $repositoryUrl = "https://github.com/$owner/$repository"; + $template = new Document([ 'repositoryName' => $repository, 'ownerName' => $owner, 'rootDirectory' => $rootDirectory, - 'version' => $version + 'referenceType' => $type, + 'referenceValue' => $reference ]); if (!empty($site->getAttribute('providerRepositoryId'))) { @@ -123,6 +132,7 @@ class Create extends Base template: $template, github: $github, activate: $activate, + authorization: $authorization, ); $queueForEvents @@ -157,9 +167,14 @@ class Create extends Base 'resourceType' => 'sites', 'buildCommands' => \implode(' && ', $commands), 'buildOutput' => $site->getAttribute('outputDirectory', ''), + 'providerRepositoryName' => $repository, + 'providerRepositoryOwner' => $owner, + 'providerRepositoryUrl' => $repositoryUrl, + 'providerBranchUrl' => $branchUrl, + 'providerBranch' => $type == GitHub::CLONE_TYPE_BRANCH ? $reference : '', 'adapter' => $site->getAttribute('adapter', ''), 'fallbackFile' => $site->getAttribute('fallbackFile', ''), - 'type' => 'manual', + 'type' => 'vcs', 'activate' => $activate, ])); @@ -176,7 +191,7 @@ class Create extends Base // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain) : ID::unique(); - Authorization::skip( + $authorization->skip( fn () => $dbForPlatform->createDocument('rules', new Document([ '$id' => $ruleId, 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php index ddad5d793a..09dc4a1618 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Vcs/Create.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; @@ -72,6 +73,7 @@ class Create extends Base ->inject('queueForEvents') ->inject('queueForBuilds') ->inject('gitHub') + ->inject('authorization') ->callback($this->action(...)); } @@ -87,7 +89,8 @@ class Create extends Base Document $project, Event $queueForEvents, Build $queueForBuilds, - GitHub $github + GitHub $github, + Authorization $authorization ) { $site = $dbForProject->getDocument('sites', $siteId); @@ -110,6 +113,7 @@ class Create extends Base template: $template, github: $github, activate: $activate, + authorization: $authorization, reference: $reference, referenceType: $type ); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php index bb6bd4f632..e3cab865a9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Deployment/Update.php @@ -60,6 +60,7 @@ class Update extends Base ->inject('dbForProject') ->inject('queueForEvents') ->inject('dbForPlatform') + ->inject('authorization') ->callback($this->action(...)); } @@ -70,7 +71,8 @@ class Update extends Base Response $response, Database $dbForProject, Event $queueForEvents, - Database $dbForPlatform + Database $dbForPlatform, + Authorization $authorization ) { $site = $dbForProject->getDocument('sites', $siteId); $deployment = $dbForProject->getDocument('deployments', $deploymentId); @@ -104,12 +106,12 @@ class Update extends Base Query::equal('projectInternalId', [$project->getSequence()]) ]; - Authorization::skip(fn () => $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { + $authorization->skip(fn () => $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment, $authorization) { $rule = $rule ->setAttribute('deploymentId', $deployment->getId()) ->setAttribute('deploymentInternalId', $deployment->getSequence()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), $rule)); + $authorization->skip(fn () => $dbForPlatform->updateDocument('rules', $rule->getId(), $rule)); }, $queries)); $queueForEvents diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Usage/Get.php b/src/Appwrite/Platform/Modules/Sites/Http/Usage/Get.php index af96c10457..5c274d6a20 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Usage/Get.php @@ -55,6 +55,7 @@ class Get extends Base ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } @@ -62,7 +63,8 @@ class Get extends Base string $siteId, string $range, Response $response, - Database $dbForProject + Database $dbForProject, + Authorization $authorization ) { $site = $dbForProject->getDocument('sites', $siteId); @@ -91,7 +93,7 @@ class Get extends Base ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php index d36cc56ae5..a90cb0cab9 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Usage/XList.php @@ -52,10 +52,11 @@ class XList extends Base ->param('range', '30d', new WhiteList(['24h', '30d', '90d']), 'Date range.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $range, Response $response, Database $dbForProject) + public function action(string $range, Response $response, Database $dbForProject, Authorization $authorization) { $periods = Config::getParam('usage', []); $stats = $usage = []; @@ -78,7 +79,7 @@ class XList extends Base METRIC_SITES_OUTBOUND, ]; - Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { + $authorization->skip(function () use ($dbForProject, $days, $metrics, &$stats) { foreach ($metrics as $metric) { $result = $dbForProject->findOne('stats', [ Query::equal('metric', [$metric]), diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php index 3cf2e2f85f..6f4ea35eea 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Variables/Update.php @@ -14,6 +14,7 @@ use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Boolean; +use Utopia\Validator\Nullable; use Utopia\Validator\Text; class Update extends Base @@ -54,8 +55,8 @@ class Update extends Base ->param('siteId', '', new UID(), 'Site unique ID.', false) ->param('variableId', '', new UID(), 'Variable unique ID.', false) ->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false) - ->param('value', null, new Text(8192, 0), 'Variable value. Max length: 8192 chars.', true) - ->param('secret', null, new Boolean(), 'Secret variables can be updated or deleted, but only sites can read them during build and runtime.', true) + ->param('value', null, new Nullable(new Text(8192, 0)), 'Variable value. Max length: 8192 chars.', true) + ->param('secret', null, new Nullable(new Boolean()), 'Secret variables can be updated or deleted, but only sites can read them during build and runtime.', true) ->inject('response') ->inject('dbForProject') ->callback($this->action(...)); diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Action.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Action.php index 5708f1b83b..e05418b90d 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Action.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Action.php @@ -6,32 +6,31 @@ use Appwrite\Auth\Auth; use Appwrite\Extend\Exception; use Utopia\Database\Database; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Platform\Action as UtopiaAction; class Action extends UtopiaAction { - protected function getFileAndBucket(Database $dbForProject, string $bucketId, string $fileId): array + protected function getFileAndBucket(Database $dbForProject, Authorization $authorization, string $bucketId, string $fileId): array { - $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); + $bucket = $authorization->skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); - $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); + $isAPIKey = Auth::isAppUser($authorization->getRoles()); + $isPrivilegedUser = Auth::isPrivilegedUser($authorization->getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAPIKey && !$isPrivilegedUser)) { throw new Exception(Exception::STORAGE_BUCKET_NOT_FOUND); } - $validator = new Authorization(Database::PERMISSION_READ); - $valid = $validator->isValid($bucket->getRead()); - if (!$valid) { - throw new Exception(Exception::USER_UNAUTHORIZED); + if (!$authorization->isValid(new Input(Database::PERMISSION_READ, $bucket->getRead()))) { + throw new Exception(Exception::USER_UNAUTHORIZED, $authorization->getDescription()); } $fileSecurity = $bucket->getAttribute('fileSecurity', false); if ($fileSecurity) { $file = $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId); } else { - $file = Authorization::skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); + $file = $authorization->skip(fn () => $dbForProject->getDocument('bucket_' . $bucket->getSequence(), $fileId)); } if ($file->isEmpty()) { diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php index fe7a0187e9..4760fef97f 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/Create.php @@ -14,6 +14,7 @@ use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Validator\Authorization; +use Utopia\Database\Validator\Authorization\Input; use Utopia\Database\Validator\Datetime as DatetimeValidator; use Utopia\Database\Validator\UID; use Utopia\Platform\Scope\HTTP; @@ -61,28 +62,27 @@ class Create extends Action )) ->param('bucketId', '', new UID(), 'Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).') ->param('fileId', '', new UID(), 'File unique ID.') - ->param('expire', null, new Nullable(new DatetimeValidator()), 'Token expiry date', true) + ->param('expire', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'Token expiry date', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $bucketId, string $fileId, ?string $expire, Response $response, Database $dbForProject, Event $queueForEvents): void + public function action(string $bucketId, string $fileId, ?string $expire, Response $response, Database $dbForProject, Event $queueForEvents, Authorization $authorization): void { - /** * @var Document $bucket * @var Document $file */ - ['bucket' => $bucket, 'file' => $file] = $this->getFileAndBucket($dbForProject, $bucketId, $fileId); + ['bucket' => $bucket, 'file' => $file] = $this->getFileAndBucket($dbForProject, $authorization, $bucketId, $fileId); $fileSecurity = $bucket->getAttribute('fileSecurity', false); - $validator = new Authorization(Database::PERMISSION_UPDATE); - $bucketPermission = $validator->isValid($bucket->getUpdate()); + $bucketPermission = $authorization->isValid(new Input(Database::PERMISSION_UPDATE, $bucket->getUpdate())); if ($fileSecurity) { - $filePermission = $validator->isValid($file->getUpdate()); + $filePermission = $authorization->isValid(new Input(Database::PERMISSION_UPDATE, $file->getUpdate())); if (!$bucketPermission && !$filePermission) { throw new Exception(Exception::USER_UNAUTHORIZED); } diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php index 8a9301713b..13da92cbc6 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Buckets/Files/XList.php @@ -13,6 +13,7 @@ use Exception; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; +use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\UID; use Utopia\Platform\Scope\HTTP; use Utopia\Validator\Boolean; @@ -57,12 +58,13 @@ class XList extends Action ->param('total', true, new Boolean(true), 'When set to false, the total count returned will be 0 and will not be calculated.', true) ->inject('response') ->inject('dbForProject') + ->inject('authorization') ->callback($this->action(...)); } - public function action(string $bucketId, string $fileId, array $queries, bool $includeTotal, Response $response, Database $dbForProject) + public function action(string $bucketId, string $fileId, array $queries, bool $includeTotal, Response $response, Database $dbForProject, Authorization $authorization) { - ['bucket' => $bucket, 'file' => $file] = $this->getFileAndBucket($dbForProject, $bucketId, $fileId); + ['bucket' => $bucket, 'file' => $file] = $this->getFileAndBucket($dbForProject, $authorization, $bucketId, $fileId); $queries = Query::parseQueries($queries); $queries[] = Query::equal('resourceType', [TOKENS_RESOURCE_TYPE_FILES]); diff --git a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Update.php b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Update.php index 7a15708011..fef2c38a81 100644 --- a/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Update.php +++ b/src/Appwrite/Platform/Modules/Tokens/Http/Tokens/Update.php @@ -57,7 +57,7 @@ class Update extends Action contentType: ContentType::JSON )) ->param('tokenId', '', new UID(), 'Token unique ID.') - ->param('expire', null, new Nullable(new DatetimeValidator()), 'File token expiry date', true) + ->param('expire', null, new Nullable(new DatetimeValidator(requireDateInFuture: true)), 'File token expiry date', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index 036e8783d4..f5785d0bb4 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -95,6 +95,7 @@ class Maintenance extends Action $this->renewCertificates($dbForPlatform, $queueForCertificates); $this->notifyDeleteCache($cacheRetention, $queueForDeletes); $this->notifyDeleteSchedules($schedulesDeletionRetention, $queueForDeletes); + $this->notifyDeleteCSVExports($queueForDeletes); }, $interval, $delay); } @@ -106,6 +107,13 @@ class Maintenance extends Action ->trigger(); } + private function notifyDeleteCSVExports(Delete $queueForDeletes): void + { + $queueForDeletes + ->setType(DELETE_TYPE_CSV_EXPORTS) + ->trigger(); + } + private function renewCertificates(Database $dbForPlatform, Certificate $queueForCertificate): void { $time = DatabaseDateTime::now(); diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index 3e35c1c1fa..cc6981fa1b 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -31,6 +31,7 @@ class Migrate extends Action ->inject('dbForPlatform') ->inject('getProjectDB') ->inject('register') + ->inject('authorisation') ->callback($this->action(...)); } @@ -47,8 +48,8 @@ class Migrate extends Action Database $dbForPlatform, callable $getProjectDB, Registry $register, + Authorization $authorization ): void { - Authorization::disable(); if (!\array_key_exists($version, Migration::$versions)) { Console::error("No migration found for version $version."); @@ -66,14 +67,14 @@ class Migrate extends Action $count = 0; $total = $dbForPlatform->count('projects') + 1; - $dbForPlatform->foreach('projects', function (Document $project) use ($dbForPlatform, $getProjectDB, $register, $migration, &$count, $total) { + $dbForPlatform->foreach('projects', function (Document $project) use ($dbForPlatform, $getProjectDB, $register, $migration, &$count, $total, $authorization) { /** @var Database $dbForProject */ $dbForProject = $getProjectDB($project); $dbForProject->disableValidation(); try { $migration - ->setProject($project, $dbForProject, $dbForPlatform, $getProjectDB) + ->setProject($project, $dbForProject, $dbForPlatform, $authorization, $getProjectDB) ->setPDO($register->get('db', true)) ->execute(); } catch (\Throwable $th) { @@ -88,7 +89,7 @@ class Migrate extends Action try { $migration - ->setProject($console, $getProjectDB($console), $dbForPlatform, $getProjectDB) + ->setProject($console, $getProjectDB($console), $dbForPlatform, $authorization, $getProjectDB) ->setPDO($register->get('db', true)) ->execute(); } catch (\Throwable $th) { diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index cf4f107e8e..d3c605655f 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -259,8 +259,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND } if ($createRelease) { - Console::execute('git config --global user.email "$GIT_EMAIL"', stdin: '', stdout: '', stderr: ''); - $releaseVersion = $language['version']; $repoName = $language['gitUserName'] . '/' . $language['gitRepoName']; @@ -429,16 +427,21 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND mkdir -p ' . $target . ' && \ cd ' . $target . ' && \ git init && \ + git config core.ignorecase false && \ + git config pull.rebase false && \ git remote add origin ' . $gitUrl . ' && \ git fetch origin && \ - git checkout ' . $repoBranch . ' || git checkout -b ' . $repoBranch . ' && \ + (git checkout -f ' . $repoBranch . ' 2>/dev/null || git checkout -b ' . $repoBranch . ') && \ git pull origin ' . $repoBranch . ' && \ - git checkout ' . $gitBranch . ' || git checkout -b ' . $gitBranch . ' && \ - git fetch origin ' . $gitBranch . ' || git push -u origin ' . $gitBranch . ' && \ - git pull origin ' . $gitBranch . ' && \ - find . -mindepth 1 ! -path "./.git*" -delete && \ + (git checkout -f ' . $gitBranch . ' 2>/dev/null || git checkout -b ' . $gitBranch . ') && \ + (git fetch origin ' . $gitBranch . ' 2>/dev/null || git push -u origin ' . $gitBranch . ') && \ + git reset --hard origin/' . $gitBranch . ' 2>/dev/null || true && \ + (test -d .github && cp -r .github /tmp/.github-backup-$$ || true) && \ + git rm -rf --cached . && \ + git clean -fdx -e .git -e .github && \ cp -r ' . $result . '/. ' . $target . '/ && \ - git add . && \ + (test -d /tmp/.github-backup-$$ && cp -r /tmp/.github-backup-$$/.github . && rm -rf /tmp/.github-backup-$$ || true) && \ + git add -A && \ git commit -m "' . $message . '" && \ git push -u origin ' . $gitBranch . ' '); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index e9a0e1d333..33a01346a8 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -9,7 +9,6 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\Platform\Action; use Utopia\Queue\Broker\Pool as BrokerPool; use Utopia\System\System; @@ -62,7 +61,7 @@ abstract class ScheduleBase extends Action $accessedAt = $project->getAttribute('accessedAt', 0); if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_PROJECT_ACCESS)) > $accessedAt) { $project->setAttribute('accessedAt', DateTime::now()); - Authorization::skip(fn () => $dbForPlatform->updateDocument('projects', $project->getId(), $project)); + $dbForPlatform->updateDocument('projects', $project->getId(), $project); } } } diff --git a/src/Appwrite/Platform/Tasks/StatsResources.php b/src/Appwrite/Platform/Tasks/StatsResources.php index b64dd61f86..87d4858351 100644 --- a/src/Appwrite/Platform/Tasks/StatsResources.php +++ b/src/Appwrite/Platform/Tasks/StatsResources.php @@ -8,7 +8,6 @@ use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; use Utopia\System\System; /** @@ -45,6 +44,7 @@ class StatsResources extends Action ->inject('dbForPlatform') ->inject('logError') ->inject('queueForStatsResources') + ->inject('authorization') ->callback($this->action(...)); } @@ -61,9 +61,7 @@ class StatsResources extends Action $interval = (int) System::getEnv('_APP_STATS_RESOURCES_INTERVAL', '3600'); - Console::loop(function () use ($queue) { - Authorization::disable(); - Authorization::setDefaultStatus(false); + Console::loop(function () use ($queue, $dbForPlatform) { $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours')); /** diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 331a2668a3..808adabb24 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -19,12 +19,10 @@ use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; -use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization as ValidatorAuthorization; use Utopia\DSN\DSN; use Utopia\Logger\Log; use Utopia\Platform\Action; @@ -179,6 +177,9 @@ class Deletes extends Action case DELETE_TYPE_SESSION_TARGETS: $this->deleteSessionTargets($project, $getProjectDB, $document); break; + case DELETE_TYPE_CSV_EXPORTS: + $this->deleteOldCSVExports($dbForPlatform, $deviceForFiles); + break; case DELETE_TYPE_MAINTENANCE: $this->deleteExpiredTargets($project, $getProjectDB); $this->deleteExecutionLogs($project, $getProjectDB, $executionRetention); @@ -198,7 +199,6 @@ class Deletes extends Action * @param string $datetime * @param Document|null $document * @return void - * @throws Authorization * @throws Conflict * @throws Restricted * @throws Structure @@ -720,6 +720,41 @@ class Deletes extends Action ], $dbForProject); } + /** + * @param Database $dbForPlatform + * @param Device $deviceForFiles + * @return void + * @throws Exception|Throwable + */ + private function deleteOldCSVExports(Database $dbForPlatform, Device $deviceForFiles): void + { + $bucket = $dbForPlatform->getDocument('buckets', 'default'); + + if ($bucket->isEmpty()) { + Console::warning('Default bucket not found, skipping CSV export cleanup'); + return; + } + + $oneWeekAgo = DateTime::addSeconds(new \DateTime(), -1 * 60 * 60 * 24 * 7); // 1 week + + Console::info("Deleting CSV export files older than " . $oneWeekAgo); + + $this->deleteByGroup('bucket_' . $bucket->getSequence(), [ + Query::select([...$this->selects, '$createdAt', 'name', 'path']), + Query::equal('bucketId', ['default']), + Query::createdBefore($oneWeekAgo), + Query::endsWith('name', ['.csv']), + Query::orderDesc('$createdAt'), + Query::orderDesc(), + ], $dbForPlatform, function (Document $file) use ($deviceForFiles) { + $path = $file->getAttribute('path'); + if ($deviceForFiles->exists($path)) { + $deviceForFiles->delete($path); + Console::success('Deleted CSV file: ' . $file->getAttribute('name')); + } + }); + } + /** * @param Database $dbForPlatform * @param string $datetime @@ -954,14 +989,14 @@ class Deletes extends Action } Console::info("Deleting screenshots for deployment " . $deployment->getId()); - $bucket = ValidatorAuthorization::skip(fn () => $dbForPlatform->getDocument('buckets', 'screenshots')); + $bucket = $dbForPlatform->getDocument('buckets', 'screenshots'); if ($bucket->isEmpty()) { Console::error('Failed to get bucket for deployment screenshots'); return; } foreach ($screenshotIds as $id) { - $file = ValidatorAuthorization::skip(fn () => $dbForPlatform->getDocument('bucket_' . $bucket->getSequence(), $id)); + $file = $dbForPlatform->getDocument('bucket_' . $bucket->getSequence(), $id); if ($file->isEmpty()) { Console::error('Failed to get deployment screenshot: ' . $id); diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index df1833ad33..8ed95ac2fc 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -15,7 +15,6 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; @@ -326,7 +325,6 @@ class Functions extends Action * @param string|null $eventData * @param string|null $executionId * @return void - * @throws Authorization * @throws Structure * @throws \Utopia\Database\Exception * @throws Conflict diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index fc7949e783..08782fd825 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -11,12 +11,15 @@ use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; -use Utopia\Database\Exception\Authorization; +use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Conflict; use Utopia\Database\Exception\Restricted; use Utopia\Database\Exception\Structure; use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; use Utopia\Database\Query; +use Utopia\Database\Validator\Authorization; use Utopia\Locale\Locale; use Utopia\Migration\Destination; use Utopia\Migration\Destinations\Appwrite as DestinationAppwrite; @@ -81,6 +84,7 @@ class Migrations extends Action ->inject('deviceForFiles') ->inject('queueForMails') ->inject('plan') + ->inject('authorization') ->callback($this->action(...)); } @@ -98,6 +102,7 @@ class Migrations extends Action Device $deviceForFiles, Mail $queueForMails, array $plan, + Authorization $authorization, ): void { $payload = $message->getPayload() ?? []; $this->deviceForMigrations = $deviceForMigrations; @@ -124,7 +129,7 @@ class Migrations extends Action return; } - $this->processMigration($migration, $queueForRealtime, $queueForMails); + $this->processMigration($migration, $queueForRealtime, $queueForMails, $authorization); } /** @@ -223,7 +228,7 @@ class Migrations extends Action } /** - * @throws Authorization + * @throws AuthorizationException * @throws Structure * @throws Conflict * @throws \Utopia\Database\Exception @@ -282,7 +287,7 @@ class Migrations extends Action } /** - * @throws Authorization + * @throws AuthorizationException * @throws Conflict * @throws Restricted * @throws Structure @@ -293,6 +298,7 @@ class Migrations extends Action Document $migration, Realtime $queueForRealtime, Mail $queueForMails, + Authorization $authorization, ): void { $project = $this->dbForPlatform->getDocument('projects', $this->project->getId()); $tempAPIKey = $this->generateAPIKey($project); @@ -408,7 +414,7 @@ class Migrations extends Action $source?->success(); if ($migration->getAttribute('destination') === DestinationCSV::getName()) { - $this->handleCSVExportComplete($project, $migration, $queueForMails); + $this->handleCSVExportComplete($project, $migration, $queueForMails, $authorization); } } } @@ -421,7 +427,7 @@ class Migrations extends Action * @param Document $migration * @param Mail $queueForMails * @return void - * @throws Authorization + * @throws AuthorizationException * @throws Structure * @throws \Utopia\Database\Exception * @throws Exception @@ -429,16 +435,24 @@ class Migrations extends Action protected function handleCSVExportComplete( Document $project, Document $migration, - Mail $queueForMails + Mail $queueForMails, + Authorization $authorization, ): void { $options = $migration->getAttribute('options', []); - $bucketId = $options['bucketId'] ?? null; + $bucketId = 'default'; // Always use platform default bucket $filename = $options['filename'] ?? 'export_' . \time(); $userInternalId = $options['userInternalId'] ?? ''; + $user = $this->dbForPlatform->findOne('users', [ + Query::equal('$sequence', [$userInternalId]) + ]); - $bucket = $this->dbForProject->getDocument('buckets', $bucketId); + if ($user->isEmpty()) { + throw new \Exception('User ' . $userInternalId . ' not found'); + } + + $bucket = $authorization->skip(fn () => $this->dbForPlatform->getDocument('buckets', $bucketId)); if ($bucket->isEmpty()) { - throw new \Exception("Bucket not found: $bucketId"); + throw new \Exception('Bucket not found'); } $path = $this->deviceForFiles->getPath($bucketId . '/' . $this->sanitizeFilename($filename) . '.csv'); @@ -469,7 +483,7 @@ class Migrations extends Action $this->sendCSVEmail( success: false, project: $project, - userInternalId: $userInternalId, + user: $user, options: $options, queueForMails: $queueForMails, sizeMB: $sizeMB @@ -479,9 +493,11 @@ class Migrations extends Action } } - $this->dbForProject->createDocument('bucket_' . $bucket->getSequence(), new Document([ + $this->dbForPlatform->createDocument('bucket_' . $bucket->getSequence(), new Document([ '$id' => $fileId, - '$permissions' => [], + '$permissions' => [ + Permission::read(Role::user($user->getId())), + ], 'bucketId' => $bucket->getId(), 'bucketInternalId' => $bucket->getSequence(), 'name' => $filename, @@ -511,6 +527,7 @@ class Migrations extends Action 'bucketId' => $bucketId, 'fileId' => $fileId, 'projectId' => $project->getId(), + 'internal' => true, ]); // Generate download URL with JWT @@ -521,7 +538,7 @@ class Migrations extends Action $this->sendCSVEmail( success: true, project: $project, - userInternalId: $userInternalId, + user: $user, options: $options, queueForMails: $queueForMails, downloadUrl: $downloadUrl @@ -533,7 +550,7 @@ class Migrations extends Action * * @param bool $success Whether the export was successful * @param Document $project - * @param string $userInternalId Internal ID of the user + * @param Document $user The user who triggered the operation * @param array $options Migration options * @param Mail $queueForMails * @param string $downloadUrl Download URL for successful exports @@ -544,7 +561,7 @@ class Migrations extends Action protected function sendCSVEmail( bool $success, Document $project, - string $userInternalId, + Document $user, array $options, Mail $queueForMails, string $downloadUrl = '', @@ -554,12 +571,8 @@ class Migrations extends Action return; } - $user = $this->dbForPlatform->findOne('users', [ - Query::equal('$sequence', [$userInternalId]) - ]); - if ($user->isEmpty()) { - Console::warning("User not found for CSV export notification: $userInternalId"); + Console::warning("User not found for CSV export notification: {$user->getInternalId()}"); return; } diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 38613313db..0ab16d306b 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -255,10 +255,21 @@ class OpenAPI3 extends Format } foreach ($methodObj->getResponses() as $response) { - if (\is_array($response->getModel())) { + /** @var Response|array $response */ + $responseModel = $response->getModel(); + + if (\is_array($responseModel)) { + foreach ($responseModel as $modelName) { + foreach ($this->models as $value) { + if ($value->getType() === $modelName) { + $usedModels[] = $modelName; + break; + } + } + } $additionalMethod['responses'][] = [ 'code' => $response->getCode(), - 'model' => \array_map(fn ($m) => '#/components/schemas/' . $m, $response->getModel()) + 'model' => \array_map(fn ($m) => '#/components/schemas/' . $m, $responseModel) ]; } else { $responseData = [ @@ -267,7 +278,13 @@ class OpenAPI3 extends Format // lets not assume stuff here! if ($response->getCode() !== 204) { - $responseData['model'] = '#/components/schemas/' . $response->getModel(); + $responseData['model'] = '#/components/schemas/' . $responseModel; + foreach ($this->models as $value) { + if ($value->getType() === $responseModel) { + $usedModels[] = $responseModel; + break; + } + } } $additionalMethod['responses'][] = $responseData; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index d497369b9a..7606c48750 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -264,11 +264,20 @@ class Swagger2 extends Format } foreach ($methodObj->getResponses() as $response) { - /** @var Response $response */ - if (\is_array($response->getModel())) { + /** @var Response|array $response */ + $responseModel = $response->getModel(); + if (\is_array($responseModel)) { + foreach ($responseModel as $modelName) { + foreach ($this->models as $value) { + if ($value->getType() === $modelName) { + $usedModels[] = $modelName; + break; + } + } + } $additionalMethod['responses'][] = [ 'code' => $response->getCode(), - 'model' => \array_map(fn ($m) => '#/definitions/' . $m, $response->getModel()) + 'model' => \array_map(fn ($m) => '#/definitions/' . $m, $responseModel) ]; } else { $responseData = [ @@ -277,7 +286,13 @@ class Swagger2 extends Format // lets not assume stuff here! if ($response->getCode() !== 204) { - $responseData['model'] = '#/definitions/' . $response->getModel(); + $responseData['model'] = '#/definitions/' . $responseModel; + foreach ($this->models as $value) { + if ($value->getType() === $responseModel) { + $usedModels[] = $responseModel; + break; + } + } } $additionalMethod['responses'][] = $responseData; diff --git a/src/Appwrite/Utopia/Request.php b/src/Appwrite/Utopia/Request.php index 558f0cdf09..76d87e2012 100644 --- a/src/Appwrite/Utopia/Request.php +++ b/src/Appwrite/Utopia/Request.php @@ -210,7 +210,7 @@ class Request extends UtopiaRequest { $forwardedUserAgent = $this->getHeader('x-forwarded-user-agent'); if (!empty($forwardedUserAgent)) { - $roles = Authorization::getRoles(); + $roles = $this->authorization->getRoles() ?? []; $isAppUser = Auth::isAppUser($roles); if ($isAppUser) { @@ -233,4 +233,11 @@ class Request extends UtopiaRequest ksort($params); return md5($this->getURI() . '*' . serialize($params) . '*' . APP_CACHE_BUSTER); } + + private ?Authorization $authorization = null; + + public function setAuthorization(Authorization $authorization): void + { + $this->authorization = $authorization; + } } diff --git a/src/Appwrite/Utopia/Request/Filter.php b/src/Appwrite/Utopia/Request/Filter.php index 56fed746d9..6d47d4d150 100644 --- a/src/Appwrite/Utopia/Request/Filter.php +++ b/src/Appwrite/Utopia/Request/Filter.php @@ -10,7 +10,7 @@ abstract class Filter private array $params; private ?Database $dbForProject; - public function __construct(Database $dbForProject = null, array $params = []) + public function __construct(?Database $dbForProject = null, array $params = []) { $this->params = $params; $this->dbForProject = $dbForProject; diff --git a/src/Appwrite/Utopia/Request/Filters/V20.php b/src/Appwrite/Utopia/Request/Filters/V20.php index 69e7da6b7a..e130178083 100644 --- a/src/Appwrite/Utopia/Request/Filters/V20.php +++ b/src/Appwrite/Utopia/Request/Filters/V20.php @@ -7,7 +7,6 @@ use Appwrite\Utopia\Request\Filter; use Utopia\Database\Database; use Utopia\Database\Exception\Query as QueryException; use Utopia\Database\Query; -use Utopia\Database\Validator\Authorization; class V20 extends Filter { @@ -138,7 +137,7 @@ class V20 extends Filter } try { - $database = Authorization::skip(fn () => $dbForProject->getDocument( + $database = $dbForProject->getAuthorization()->skip(fn () => $dbForProject->getDocument( 'databases', $databaseId )); @@ -150,10 +149,10 @@ class V20 extends Filter } try { - $collection = Authorization::skip(fn () => $dbForProject->getDocument( + $collection = $dbForProject->getDocument( 'database_' . $database->getSequence(), $collectionId - )); + ); if ($collection->isEmpty()) { return []; } diff --git a/src/Appwrite/Utopia/Request/Filters/V21.php b/src/Appwrite/Utopia/Request/Filters/V21.php new file mode 100644 index 0000000000..3ef0becf1d --- /dev/null +++ b/src/Appwrite/Utopia/Request/Filters/V21.php @@ -0,0 +1,34 @@ +<?php + +namespace Appwrite\Utopia\Request\Filters; + +use Appwrite\Utopia\Request\Filter; + +class V21 extends Filter +{ + // Convert 1.8.0 params to 1.8.1 + public function parse(array $content, string $model): array + { + switch ($model) { + case 'functions.createTemplateDeployment': + case 'sites.createTemplateDeployment': + $content = $this->convertVersionToTypeAndReference($content); + break; + } + return $content; + } + + /** + * Convert version parameter to type and reference for backwards compatibility + * with 1.8.0 template deployment endpoints + */ + protected function convertVersionToTypeAndReference(array $content): array + { + if (!empty($content['version'])) { + $content['type'] = 'tag'; + $content['reference'] = $content['version']; + unset($content['version']); + } + return $content; + } +} diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index b391f0ea72..962ac37aa9 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -59,6 +59,7 @@ use Appwrite\Utopia\Response\Model\Database; use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Utopia\Response\Model\DetectionFramework; use Appwrite\Utopia\Response\Model\DetectionRuntime; +use Appwrite\Utopia\Response\Model\DetectionVariable; use Appwrite\Utopia\Response\Model\DevKey; use Appwrite\Utopia\Response\Model\Document as ModelDocument; use Appwrite\Utopia\Response\Model\Error; @@ -316,6 +317,7 @@ class Response extends SwooleResponse public const MODEL_BRANCH = 'branch'; public const MODEL_BRANCH_LIST = 'branchList'; public const MODEL_DETECTION_FRAMEWORK = 'detectionFramework'; + public const MODEL_DETECTION_VARIABLE = 'detectionVariable'; public const MODEL_DETECTION_RUNTIME = 'detectionRuntime'; public const MODEL_VCS_CONTENT = 'vcsContent'; public const MODEL_VCS_CONTENT_LIST = 'vcsContentList'; @@ -563,6 +565,7 @@ class Response extends SwooleResponse ->setModel(new ProviderRepositoryRuntime()) ->setModel(new DetectionFramework()) ->setModel(new DetectionRuntime()) + ->setModel(new DetectionVariable()) ->setModel(new VcsContent()) ->setModel(new Branch()) ->setModel(new Runtime()) @@ -809,7 +812,7 @@ class Response extends SwooleResponse } if ($rule['sensitive']) { - $roles = Authorization::getRoles(); + $roles = $this->authorization->getRoles() ?? []; $isPrivilegedUser = Auth::isPrivilegedUser($roles); $isAppUser = Auth::isAppUser($roles); @@ -977,4 +980,11 @@ class Response extends SwooleResponse self::$showSensitive = false; } } + + private ?Authorization $authorization = null; + + public function setAuthorization(Authorization $authorization): void + { + $this->authorization = $authorization; + } } diff --git a/src/Appwrite/Utopia/Response/Model/Detection.php b/src/Appwrite/Utopia/Response/Model/Detection.php new file mode 100644 index 0000000000..007182d1e9 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/Detection.php @@ -0,0 +1,22 @@ +<?php + +namespace Appwrite\Utopia\Response\Model; + +use Appwrite\Utopia\Response; +use Appwrite\Utopia\Response\Model; + +abstract class Detection extends Model +{ + public function __construct() + { + $this + ->addRule('variables', [ + 'type' => Response::MODEL_DETECTION_VARIABLE, + 'description' => 'Environment variables found in .env files', + 'required' => false, + 'default' => [], + 'example' => new \stdClass(), + 'array' => true, + ]); + } +} diff --git a/src/Appwrite/Utopia/Response/Model/DetectionFramework.php b/src/Appwrite/Utopia/Response/Model/DetectionFramework.php index 9aeb885f76..4cdf37bbcf 100644 --- a/src/Appwrite/Utopia/Response/Model/DetectionFramework.php +++ b/src/Appwrite/Utopia/Response/Model/DetectionFramework.php @@ -3,12 +3,13 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; -use Appwrite\Utopia\Response\Model; -class DetectionFramework extends Model +class DetectionFramework extends Detection { public function __construct() { + parent::__construct(); + $this ->addRule('framework', [ 'type' => self::TYPE_STRING, diff --git a/src/Appwrite/Utopia/Response/Model/DetectionRuntime.php b/src/Appwrite/Utopia/Response/Model/DetectionRuntime.php index 1c7c0be16b..1e63929092 100644 --- a/src/Appwrite/Utopia/Response/Model/DetectionRuntime.php +++ b/src/Appwrite/Utopia/Response/Model/DetectionRuntime.php @@ -3,12 +3,13 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; -use Appwrite\Utopia\Response\Model; -class DetectionRuntime extends Model +class DetectionRuntime extends Detection { public function __construct() { + parent::__construct(); + $this ->addRule('runtime', [ 'type' => self::TYPE_STRING, diff --git a/src/Appwrite/Utopia/Response/Model/DetectionVariable.php b/src/Appwrite/Utopia/Response/Model/DetectionVariable.php new file mode 100644 index 0000000000..a5a2d2acc0 --- /dev/null +++ b/src/Appwrite/Utopia/Response/Model/DetectionVariable.php @@ -0,0 +1,46 @@ +<?php + +namespace Appwrite\Utopia\Response\Model; + +use Appwrite\Utopia\Response; +use Appwrite\Utopia\Response\Model; + +class DetectionVariable extends Model +{ + public function __construct() + { + $this + ->addRule('name', [ + 'type' => self::TYPE_STRING, + 'description' => 'Name of environment variable', + 'default' => '', + 'example' => 'NODE_ENV', + ]) + ->addRule('value', [ + 'type' => self::TYPE_STRING, + 'description' => 'Value of environment variable', + 'default' => '', + 'example' => 'production', + ]); + } + + /** + * Get Name + * + * @return string + */ + public function getName(): string + { + return 'DetectionVariable'; + } + + /** + * Get Type + * + * @return string + */ + public function getType(): string + { + return Response::MODEL_DETECTION_VARIABLE; + } +} diff --git a/src/Appwrite/Utopia/Response/Model/ProviderRepository.php b/src/Appwrite/Utopia/Response/Model/ProviderRepository.php index eee058a05b..ddad0b059c 100644 --- a/src/Appwrite/Utopia/Response/Model/ProviderRepository.php +++ b/src/Appwrite/Utopia/Response/Model/ProviderRepository.php @@ -53,6 +53,13 @@ class ProviderRepository extends Model 'default' => APP_DATABASE_ATTRIBUTE_DATETIME, 'example' => APP_DATABASE_ATTRIBUTE_DATETIME, 'array' => false, + ]) + ->addRule('variables', [ + 'type' => self::TYPE_STRING, + 'description' => 'Environment variables found in .env files', + 'default' => [], + 'array' => true, + 'example' => ['PORT', 'NODE_ENV'], ]); } diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 8f5477331a..dc49d27aea 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -28,6 +28,7 @@ class UsageTest extends Scope FunctionsBase::createVariable insteadof SitesBase; FunctionsBase::getVariable insteadof SitesBase; FunctionsBase::listVariables insteadof SitesBase; + FunctionsBase::helperGetLatestCommit insteadof SitesBase; FunctionsBase::updateVariable insteadof SitesBase; FunctionsBase::deleteVariable insteadof SitesBase; FunctionsBase::getDeployment insteadof SitesBase; diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index b2f85637a8..9f35932700 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -41,6 +41,11 @@ trait AccountBase $this->assertNotEmpty($response['body']['accessedAt']); $this->assertArrayHasKey('targets', $response['body']); $this->assertEquals($email, $response['body']['targets'][0]['identifier']); + $this->assertArrayNotHasKey('emailCanonical', $response['body']); + $this->assertArrayNotHasKey('emailIsFree', $response['body']); + $this->assertArrayNotHasKey('emailIsDisposable', $response['body']); + $this->assertArrayNotHasKey('emailIsCorporate', $response['body']); + $this->assertArrayNotHasKey('emailIsCanonical', $response['body']); /** * Test for FAILURE diff --git a/tests/e2e/Services/Databases/Legacy/Permissions/DatabasesPermissionsGuestTest.php b/tests/e2e/Services/Databases/Legacy/Permissions/DatabasesPermissionsGuestTest.php index 6496aa285a..0c9854160e 100644 --- a/tests/e2e/Services/Databases/Legacy/Permissions/DatabasesPermissionsGuestTest.php +++ b/tests/e2e/Services/Databases/Legacy/Permissions/DatabasesPermissionsGuestTest.php @@ -17,6 +17,19 @@ class DatabasesPermissionsGuestTest extends Scope use SideClient; use DatabasesPermissionsScope; + private $authorization; + + public function getAuthorization(): Authorization + { + if (isset($this->authorization)) { + return $this->authorization; + } + + $this->authorization = new Authorization(); + + return $this->authorization; + } + public function createCollection(): array { $database = $this->client->call(Client::METHOD_POST, '/databases', array_merge([ @@ -111,8 +124,8 @@ class DatabasesPermissionsGuestTest extends Scope $this->assertEquals(201, $publicResponse['headers']['status-code']); $this->assertEquals(201, $privateResponse['headers']['status-code']); - $roles = Authorization::getRoles(); - Authorization::cleanRoles(); + $roles = $this->getAuthorization()->getRoles(); + $this->getAuthorization()->cleanRoles(); $publicDocuments = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $publicCollectionId . '/documents', [ 'content-type' => 'application/json', @@ -134,7 +147,7 @@ class DatabasesPermissionsGuestTest extends Scope } foreach ($roles as $role) { - Authorization::setRole($role); + $this->getAuthorization()->addRole($role); } } @@ -145,8 +158,8 @@ class DatabasesPermissionsGuestTest extends Scope $privateCollectionId = $data['privateCollectionId']; $databaseId = $data['databaseId']; - $roles = Authorization::getRoles(); - Authorization::cleanRoles(); + $roles = $this->getAuthorization()->getRoles(); + $this->getAuthorization()->cleanRoles(); $publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $publicCollectionId . '/documents', [ 'content-type' => 'application/json', @@ -222,7 +235,7 @@ class DatabasesPermissionsGuestTest extends Scope $this->assertEquals(401, $privateDocument['headers']['status-code']); foreach ($roles as $role) { - Authorization::setRole($role); + $this->getAuthorization()->addRole($role); } } diff --git a/tests/e2e/Services/Databases/TablesDB/Permissions/DatabasesPermissionsGuestTest.php b/tests/e2e/Services/Databases/TablesDB/Permissions/DatabasesPermissionsGuestTest.php index 2f69c037d0..84cb4bce3a 100644 --- a/tests/e2e/Services/Databases/TablesDB/Permissions/DatabasesPermissionsGuestTest.php +++ b/tests/e2e/Services/Databases/TablesDB/Permissions/DatabasesPermissionsGuestTest.php @@ -17,6 +17,19 @@ class DatabasesPermissionsGuestTest extends Scope use SideClient; use DatabasesPermissionsScope; + private $authorization; + + public function getAuthorization(): Authorization + { + if (isset($this->authorization)) { + return $this->authorization; + } + + $this->authorization = new Authorization(); + return $this->authorization; + } + + public function createTable(): array { $database = $this->client->call(Client::METHOD_POST, '/tablesdb', array_merge([ @@ -111,8 +124,8 @@ class DatabasesPermissionsGuestTest extends Scope $this->assertEquals(201, $publicResponse['headers']['status-code']); $this->assertEquals(201, $privateResponse['headers']['status-code']); - $roles = Authorization::getRoles(); - Authorization::cleanRoles(); + $roles = $this->getAuthorization()->getRoles(); + $this->getAuthorization()->cleanRoles(); $publicRows = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $publicTableId . '/rows', [ 'content-type' => 'application/json', @@ -134,7 +147,7 @@ class DatabasesPermissionsGuestTest extends Scope } foreach ($roles as $role) { - Authorization::setRole($role); + $this->getAuthorization()->addRole($role); } } @@ -145,8 +158,8 @@ class DatabasesPermissionsGuestTest extends Scope $privateTableId = $data['privateTableId']; $databaseId = $data['databaseId']; - $roles = Authorization::getRoles(); - Authorization::cleanRoles(); + $roles = $this->getAuthorization()->getRoles(); + $this->getAuthorization()->cleanRoles(); $publicResponse = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $publicTableId . '/rows', [ 'content-type' => 'application/json', @@ -222,7 +235,7 @@ class DatabasesPermissionsGuestTest extends Scope $this->assertEquals(401, $privateRow['headers']['status-code']); foreach ($roles as $role) { - Authorization::setRole($role); + $this->getAuthorization()->addRole($role); } } diff --git a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php index efa3b52cef..488dc60239 100644 --- a/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php +++ b/tests/e2e/Services/Databases/TablesDB/Transactions/TransactionsBase.php @@ -6,6 +6,7 @@ use Tests\E2E\Client; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; +use Utopia\Database\Operator; use Utopia\Database\Query; trait TransactionsBase @@ -5561,4 +5562,395 @@ trait TransactionsBase $this->assertEquals('Updated after upsert', $response['body']['name']); $this->assertEquals(20, $response['body']['counter']); } + + /** + * Test array operators in transactions using updateRow with transactionId + * This tests the fix for operators not being parsed when stored in transaction logs + */ + public function testArrayOperatorsWithUpdateRow(): void + { + // Create database + $database = $this->client->call(Client::METHOD_POST, '/tablesdb', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'databaseId' => ID::unique(), + 'name' => 'ArrayOperatorsTestDB' + ]); + + $this->assertEquals(201, $database['headers']['status-code']); + $databaseId = $database['body']['$id']; + + // Create table with array column + $table = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'tableId' => ID::unique(), + 'name' => 'Items', + 'permissions' => [ + Permission::create(Role::any()), + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + + $this->assertEquals(201, $table['headers']['status-code']); + $tableId = $table['body']['$id']; + + // Create array column + $column = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/columns/string", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'key' => 'items', + 'size' => 255, + 'required' => false, + 'array' => true, + ]); + + $this->assertEquals(202, $column['headers']['status-code']); + sleep(2); // Wait for column to be created + + // Create initial row with some items + $row = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/rows", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'rowId' => 'test-row', + 'data' => [ + 'items' => ['item1', 'item2', 'item3', 'item4'] + ] + ]); + + $this->assertEquals(201, $row['headers']['status-code']); + $this->assertEquals(['item1', 'item2', 'item3', 'item4'], $row['body']['items']); + + // Create transaction + $transaction = $this->client->call(Client::METHOD_POST, '/tablesdb/transactions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(201, $transaction['headers']['status-code']); + $transactionId = $transaction['body']['$id']; + + // Test arrayRemove operator + $updateResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/test-row", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'transactionId' => $transactionId, + 'data' => [ + 'items' => Operator::arrayRemove('item2')->toString() + ] + ]); + + $this->assertEquals(200, $updateResponse['headers']['status-code']); + + // Test arrayInsert operator + $updateResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/test-row", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'transactionId' => $transactionId, + 'data' => [ + 'items' => Operator::arrayInsert(2, 'newItem')->toString() + ] + ]); + + $this->assertEquals(200, $updateResponse['headers']['status-code']); + + // Commit transaction + $commitResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId}", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'commit' => true + ]); + + $this->assertEquals(200, $commitResponse['headers']['status-code']); + + // Verify the operations were applied correctly + $row = $this->client->call(Client::METHOD_GET, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/test-row", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $row['headers']['status-code']); + // After removing item2: ['item1', 'item3', 'item4'] + // After inserting 'newItem' at index 2: ['item1', 'item3', 'newItem', 'item4'] + $this->assertEquals(['item1', 'item3', 'newItem', 'item4'], $row['body']['items']); + } + + /** + * Test array operators in transactions using createOperations + * This tests the fix for operators not being parsed in bulk operation creation + */ + public function testArrayOperatorsWithCreateOperations(): void + { + // Create database + $database = $this->client->call(Client::METHOD_POST, '/tablesdb', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'databaseId' => ID::unique(), + 'name' => 'ArrayOperatorsBulkTestDB' + ]); + + $this->assertEquals(201, $database['headers']['status-code']); + $databaseId = $database['body']['$id']; + + // Create table with array column + $table = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'tableId' => ID::unique(), + 'name' => 'Tags', + 'permissions' => [ + Permission::create(Role::any()), + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + + $this->assertEquals(201, $table['headers']['status-code']); + $tableId = $table['body']['$id']; + + // Create array column + $column = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/columns/string", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'key' => 'tags', + 'size' => 255, + 'required' => false, + 'array' => true, + ]); + + $this->assertEquals(202, $column['headers']['status-code']); + sleep(2); // Wait for column to be created + + // Create initial row + $row = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/rows", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'rowId' => 'doc1', + 'data' => [ + 'tags' => ['php', 'javascript', 'python', 'ruby'] + ] + ]); + + $this->assertEquals(201, $row['headers']['status-code']); + + // Create transaction + $transaction = $this->client->call(Client::METHOD_POST, '/tablesdb/transactions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(201, $transaction['headers']['status-code']); + $transactionId = $transaction['body']['$id']; + + // Create operations using bulk createOperations endpoint with array operators + $operations = $this->client->call(Client::METHOD_POST, "/tablesdb/transactions/{$transactionId}/operations", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'operations' => [ + [ + 'action' => 'update', + 'databaseId' => $databaseId, + 'tableId' => $tableId, + 'rowId' => 'doc1', + 'data' => [ + 'tags' => Operator::arrayRemove('javascript')->toString() + ] + ], + [ + 'action' => 'update', + 'databaseId' => $databaseId, + 'tableId' => $tableId, + 'rowId' => 'doc1', + 'data' => [ + 'tags' => Operator::arrayAppend(['go', 'rust'])->toString() + ] + ] + ] + ]); + + $this->assertEquals(201, $operations['headers']['status-code']); + $this->assertEquals(2, $operations['body']['operations']); + + // Commit transaction + $commitResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId}", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'commit' => true + ]); + + $this->assertEquals(200, $commitResponse['headers']['status-code']); + + // Verify the operations were applied correctly + $row = $this->client->call(Client::METHOD_GET, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/doc1", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $row['headers']['status-code']); + // After removing 'javascript': ['php', 'python', 'ruby'] + // After appending ['go', 'rust']: ['php', 'python', 'ruby', 'go', 'rust'] + $this->assertEquals(['php', 'python', 'ruby', 'go', 'rust'], $row['body']['tags']); + } + + /** + * Test multiple array operators in a single transaction + * This tests all common array operators to ensure comprehensive coverage + */ + public function testMultipleArrayOperators(): void + { + // Create database + $database = $this->client->call(Client::METHOD_POST, '/tablesdb', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'databaseId' => ID::unique(), + 'name' => 'MultipleOperatorsTestDB' + ]); + + $this->assertEquals(201, $database['headers']['status-code']); + $databaseId = $database['body']['$id']; + + // Create table + $table = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'tableId' => ID::unique(), + 'name' => 'Arrays', + 'permissions' => [ + Permission::create(Role::any()), + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + + $this->assertEquals(201, $table['headers']['status-code']); + $tableId = $table['body']['$id']; + + // Create multiple array columns + $columns = [ + ['columnId' => 'list1', 'name' => 'List1'], + ['columnId' => 'list2', 'name' => 'List2'], + ['columnId' => 'list3', 'name' => 'List3'], + ]; + + foreach ($columns as $col) { + $column = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/columns/string", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ]), [ + 'key' => $col['columnId'], + 'size' => 255, + 'required' => false, + 'array' => true, + ]); + $this->assertEquals(202, $column['headers']['status-code']); + } + + sleep(2); // Wait for columns to be created + + // Create initial row + $row = $this->client->call(Client::METHOD_POST, "/tablesdb/{$databaseId}/tables/{$tableId}/rows", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'rowId' => 'multi-ops', + 'data' => [ + 'list1' => ['a', 'b', 'c'], + 'list2' => ['x', 'y', 'z'], + 'list3' => ['1', '2', '3', '4', '5'] + ] + ]); + + $this->assertEquals(201, $row['headers']['status-code']); + + // Create transaction + $transaction = $this->client->call(Client::METHOD_POST, '/tablesdb/transactions', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(201, $transaction['headers']['status-code']); + $transactionId = $transaction['body']['$id']; + + // Test arrayPrepend + $this->client->call(Client::METHOD_PATCH, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/multi-ops", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'transactionId' => $transactionId, + 'data' => [ + 'list1' => Operator::arrayPrepend(['z'])->toString() + ] + ]); + + // Test arrayAppend + $this->client->call(Client::METHOD_PATCH, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/multi-ops", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'transactionId' => $transactionId, + 'data' => [ + 'list2' => Operator::arrayAppend(['w'])->toString() + ] + ]); + + // Test arrayRemove + $this->client->call(Client::METHOD_PATCH, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/multi-ops", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'transactionId' => $transactionId, + 'data' => [ + 'list3' => Operator::arrayRemove('3')->toString() + ] + ]); + + // Commit transaction + $commitResponse = $this->client->call(Client::METHOD_PATCH, "/tablesdb/transactions/{$transactionId}", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'commit' => true + ]); + + $this->assertEquals(200, $commitResponse['headers']['status-code']); + + // Verify all operations were applied correctly + $row = $this->client->call(Client::METHOD_GET, "/tablesdb/{$databaseId}/tables/{$tableId}/rows/multi-ops", array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $row['headers']['status-code']); + $this->assertEquals(['z', 'a', 'b', 'c'], $row['body']['list1'], 'arrayPrepend should add element at the beginning'); + $this->assertEquals(['x', 'y', 'z', 'w'], $row['body']['list2'], 'arrayAppend should add element at the end'); + $this->assertEquals(['1', '2', '4', '5'], $row['body']['list3'], 'arrayRemove should remove the element'); + } } diff --git a/tests/e2e/Services/Functions/FunctionsBase.php b/tests/e2e/Services/Functions/FunctionsBase.php index 27b67d851d..7403b23a73 100644 --- a/tests/e2e/Services/Functions/FunctionsBase.php +++ b/tests/e2e/Services/Functions/FunctionsBase.php @@ -271,6 +271,29 @@ trait FunctionsBase return $template; } + protected function helperGetLatestCommit(string $owner, string $repository): ?string + { + $ch = curl_init("https://api.github.com/repos/{$owner}/{$repository}/commits/main"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'User-Agent: Appwrite', + 'Accept: application/vnd.github.v3+json' + ]); + + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($httpCode === 200) { + $commitData = json_decode($response, true); + if (isset($commitData['sha'])) { + return $commitData['sha']; + } + } + + return null; + } + protected function createExecution(string $functionId, mixed $params = []): mixed { $execution = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/executions', array_merge([ diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index f5846af959..8cc986b072 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -361,7 +361,7 @@ class FunctionsCustomServerTest extends Scope $starterTemplate = $this->getTemplate('starter'); $this->assertEquals(200, $starterTemplate['headers']['status-code']); - $phpRuntime = array_values(array_filter($starterTemplate['body']['runtimes'], function ($runtime) { + $runtime = array_values(array_filter($starterTemplate['body']['runtimes'], function ($runtime) { return $runtime['name'] === 'node-22'; }))[0]; @@ -374,15 +374,15 @@ class FunctionsCustomServerTest extends Scope 'name' => $starterTemplate['body']['name'], 'runtime' => 'node-22', 'execute' => $starterTemplate['body']['permissions'], - 'entrypoint' => $phpRuntime['entrypoint'], + 'entrypoint' => $runtime['entrypoint'], 'events' => $starterTemplate['body']['events'], 'schedule' => $starterTemplate['body']['cron'], 'timeout' => $starterTemplate['body']['timeout'], - 'commands' => $phpRuntime['commands'], + 'commands' => $runtime['commands'], 'scopes' => $starterTemplate['body']['scopes'], 'templateRepository' => $starterTemplate['body']['providerRepositoryId'], 'templateOwner' => $starterTemplate['body']['providerOwner'], - 'templateRootDirectory' => $phpRuntime['providerRootDirectory'], + 'templateRootDirectory' => $runtime['providerRootDirectory'], 'templateVersion' => $starterTemplate['body']['providerVersion'], ] ); @@ -399,19 +399,29 @@ class FunctionsCustomServerTest extends Scope 'activate' => true, 'repository' => $starterTemplate['body']['providerRepositoryId'], 'owner' => $starterTemplate['body']['providerOwner'], - 'rootDirectory' => $phpRuntime['providerRootDirectory'], - 'version' => $starterTemplate['body']['providerVersion'], + 'rootDirectory' => $runtime['providerRootDirectory'], + 'type' => 'tag', + 'reference' => $starterTemplate['body']['providerVersion'], ] ); $this->assertEquals(202, $deployment['headers']['status-code']); $this->assertNotEmpty($deployment['body']['$id']); - $deployment = $this->getDeployment($functionId, $deployment['body']['$id']); + // Wait for deployment to be ready + $deploymentId = $deployment['body']['$id']; + $this->assertEventually(function () use ($functionId, $deploymentId) { + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + // Verify deployment sizes + $deployment = $this->getDeployment($functionId, $deploymentId); $this->assertEquals(200, $deployment['headers']['status-code']); - $this->assertEquals(0, $deployment['body']['sourceSize']); - $this->assertEquals(0, $deployment['body']['buildSize']); - $this->assertEquals(0, $deployment['body']['totalSize']); + $this->assertGreaterThan(0, $deployment['body']['sourceSize']); + $this->assertGreaterThan(0, $deployment['body']['buildSize']); + $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize']; + $this->assertEquals($totalSize, $deployment['body']['totalSize']); $deployments = $this->listDeployments($functionId); @@ -433,16 +443,7 @@ class FunctionsCustomServerTest extends Scope $lastDeployment = $deployments['body']['deployments'][0]; $this->assertNotEmpty($lastDeployment['$id']); - $this->assertEquals(0, $lastDeployment['sourceSize']); - - $deploymentId = $lastDeployment['$id']; - - $this->assertEventually(function () use ($functionId, $deploymentId) { - $deployment = $this->getDeployment($functionId, $deploymentId); - - $this->assertEquals(200, $deployment['headers']['status-code']); - $this->assertEquals('ready', $deployment['body']['status']); - }, 50000, 1000); + $this->assertGreaterThan(0, $lastDeployment['sourceSize']); $function = $this->getFunction($functionId); @@ -511,7 +512,144 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals($deployment['body']['$id'], $function['body']['deploymentId']); $this->assertEquals($deployment['body']['$createdAt'], $function['body']['deploymentCreatedAt']); - $function = $this->cleanupFunction($functionId); + $this->cleanupFunction($functionId); + } + + public function testCreateFunctionAndDeploymentFromTemplateBranch() + { + $starterTemplate = $this->getTemplate('starter'); + $this->assertEquals(200, $starterTemplate['headers']['status-code']); + + $runtime = array_values(array_filter($starterTemplate['body']['runtimes'], function ($runtime) { + return $runtime['name'] === 'node-22'; + }))[0]; + + // If this fails, the template has variables, and this test needs to be updated + $this->assertEmpty($starterTemplate['body']['variables']); + + $function = $this->createFunction( + [ + 'functionId' => ID::unique(), + 'name' => $starterTemplate['body']['name'] . ' - Branch Test', + 'runtime' => 'node-22', + 'execute' => $starterTemplate['body']['permissions'], + 'entrypoint' => $runtime['entrypoint'], + 'events' => $starterTemplate['body']['events'], + 'schedule' => $starterTemplate['body']['cron'], + 'timeout' => $starterTemplate['body']['timeout'], + 'commands' => $runtime['commands'], + 'scopes' => $starterTemplate['body']['scopes'], + ] + ); + + $this->assertEquals(201, $function['headers']['status-code']); + $this->assertNotEmpty($function['body']['$id']); + + $functionId = $function['body']['$id'] ?? ''; + + // Deploy using branch + $deployment = $this->createTemplateDeployment( + $functionId, + [ + 'resourceId' => ID::unique(), + 'activate' => true, + 'repository' => $starterTemplate['body']['providerRepositoryId'], + 'owner' => $starterTemplate['body']['providerOwner'], + 'rootDirectory' => $runtime['providerRootDirectory'], + 'type' => 'branch', + 'reference' => 'main', + ] + ); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deploymentId = $deployment['body']['$id']; + $this->assertEventually(function () use ($functionId, $deploymentId) { + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertGreaterThan(0, $deployment['body']['sourceSize']); + $this->assertGreaterThan(0, $deployment['body']['buildSize']); + $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize']; + $this->assertEquals($totalSize, $deployment['body']['totalSize']); + + $this->cleanupFunction($functionId); + } + + public function testCreateFunctionAndDeploymentFromTemplateCommit() + { + $starterTemplate = $this->getTemplate('starter'); + $this->assertEquals(200, $starterTemplate['headers']['status-code']); + + // Get latest commit using helper function + $latestCommit = $this->helperGetLatestCommit( + $starterTemplate['body']['providerOwner'], + $starterTemplate['body']['providerRepositoryId'] + ); + $this->assertNotNull($latestCommit); + + $runtime = array_values(array_filter($starterTemplate['body']['runtimes'], function ($runtime) { + return $runtime['name'] === 'node-22'; + }))[0]; + + // If this fails, the template has variables, and this test needs to be updated + $this->assertEmpty($starterTemplate['body']['variables']); + + $function = $this->createFunction( + [ + 'functionId' => ID::unique(), + 'name' => $starterTemplate['body']['name'] . ' - Commit Test', + 'runtime' => 'node-22', + 'execute' => $starterTemplate['body']['permissions'], + 'entrypoint' => $runtime['entrypoint'], + 'events' => $starterTemplate['body']['events'], + 'schedule' => $starterTemplate['body']['cron'], + 'timeout' => $starterTemplate['body']['timeout'], + 'commands' => $runtime['commands'], + 'scopes' => $starterTemplate['body']['scopes'], + ] + ); + + $this->assertEquals(201, $function['headers']['status-code']); + $this->assertNotEmpty($function['body']['$id']); + + $functionId = $function['body']['$id'] ?? ''; + + // Deploy using commit + $deployment = $this->createTemplateDeployment( + $functionId, + [ + 'resourceId' => ID::unique(), + 'activate' => true, + 'repository' => $starterTemplate['body']['providerRepositoryId'], + 'owner' => $starterTemplate['body']['providerOwner'], + 'rootDirectory' => $runtime['providerRootDirectory'], + 'type' => 'commit', + 'reference' => $latestCommit, + ] + ); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deploymentId = $deployment['body']['$id']; + $this->assertEventually(function () use ($functionId, $deploymentId) { + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals('ready', $deployment['body']['status']); + }, 50000, 500); + + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertGreaterThan(0, $deployment['body']['sourceSize']); + $this->assertGreaterThan(0, $deployment['body']['buildSize']); + $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize']; + $this->assertEquals($totalSize, $deployment['body']['totalSize']); + + $this->cleanupFunction($functionId); } /** diff --git a/tests/e2e/Services/Health/HealthCustomServerTest.php b/tests/e2e/Services/Health/HealthCustomServerTest.php index 4b7062dc22..63516f624d 100644 --- a/tests/e2e/Services/Health/HealthCustomServerTest.php +++ b/tests/e2e/Services/Health/HealthCustomServerTest.php @@ -40,7 +40,6 @@ class HealthCustomServerTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); - $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals('pass', $response['body']['statuses'][0]['status']); $this->assertIsInt($response['body']['statuses'][0]['ping']); diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 16e58c9c2c..f16864960e 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -1282,39 +1282,11 @@ trait MigrationsBase $this->assertEquals(200, $docs['headers']['status-code']); $this->assertEquals(10, $docs['body']['total'], 'Expected 10 documents but got ' . $docs['body']['total']); - // Create a storage bucket for the export - $bucketIdUnique = ID::unique(); - $bucket = $this->client->call(Client::METHOD_POST, '/storage/buckets', [ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ], [ - 'bucketId' => $bucketIdUnique, - 'name' => 'Test Export Bucket', - 'permissions' => [ - Permission::read(Role::any()), - Permission::create(Role::any()), - Permission::update(Role::any()), - Permission::delete(Role::any()), - ], - 'fileSecurity' => false, - 'enabled' => true, - 'maximumFileSize' => 10485760, // 10MB - 'allowedFileExtensions' => ['csv'], - 'compression' => 'none', - 'encryption' => false, - 'antivirus' => false - ]); - - $this->assertEquals(201, $bucket['headers']['status-code']); - $bucketId = $bucket['body']['$id']; - - // Perform CSV export with notification enabled + // Perform CSV export with notification enabled (uses internal bucket) $migration = $this->client->call(Client::METHOD_POST, '/migrations/csv/exports', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] ], $this->getHeaders()), [ - 'bucketId' => $bucketId, 'resourceId' => $databaseId . ':' . $collectionId, 'filename' => 'test-export', 'columns' => [], @@ -1329,7 +1301,7 @@ trait MigrationsBase $this->assertNotEmpty($migration['body']['$id']); $migrationId = $migration['body']['$id']; - $this->assertEventually(function () use ($bucketId, $migrationId) { + $this->assertEventually(function () use ($migrationId) { $response = $this->client->call(Client::METHOD_GET, '/migrations/' . $migrationId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1341,55 +1313,10 @@ trait MigrationsBase $this->assertEquals('completed', $response['body']['status']); $this->assertEquals('Appwrite', $response['body']['source']); $this->assertEquals('CSV', $response['body']['destination']); - $this->assertEquals($bucketId, $response['body']['options']['bucketId']); return true; }, 30000, 500); - // Check that the file was created in the bucket - // Query files by filename - $files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files', [ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ], [ - 'queries' => [ - Query::equal('name', ['test-export'])->toString() - ] - ]); - - $this->assertEquals(200, $files['headers']['status-code']); - $this->assertEquals(1, $files['body']['total'], 'Expected exactly one file with name "test-export"'); - - // Get the exported file - $file = $files['body']['files'][0]; - $fileId = $file['$id']; - - $this->assertEquals($bucketId, $file['bucketId']); - $this->assertEquals('test-export', $file['name']); - $this->assertEquals('text/csv', $file['mimeType']); - $this->assertGreaterThan(0, $file['sizeOriginal']); - - // Download and verify CSV content - $download = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/download', \array_merge([ - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - $this->assertEquals(200, $download['headers']['status-code']); - - $csvContent = $download['body']; - $lines = explode("\n", trim($csvContent)); - $this->assertCount(11, $lines); - $this->assertStringContainsString('$id', $lines[0]); - $this->assertStringContainsString('$permissions', $lines[0]); - $this->assertStringContainsString('$createdAt', $lines[0]); - $this->assertStringContainsString('$updatedAt', $lines[0]); - $this->assertStringContainsString('name', $lines[0]); - $this->assertStringContainsString('email', $lines[0]); - - $this->assertStringContainsString('Test User 1', $lines[1]); - $this->assertStringContainsString('user1@appwrite.io', $lines[1]); - // Check that email was sent with download link $lastEmail = $this->getLastEmail(); $this->assertNotEmpty($lastEmail); @@ -1407,28 +1334,25 @@ trait MigrationsBase \parse_str($components['query'] ?? '', $queryParams); $this->assertArrayHasKey('jwt', $queryParams, 'JWT not found in download URL'); $this->assertNotEmpty($queryParams['jwt']); + $this->assertArrayHasKey('project', $queryParams, 'Project not found in download URL'); + $this->assertStringContainsString('/storage/buckets/default/files/', $downloadUrl); // Test download with JWT $path = \str_replace('/v1', '', $components['path']); $downloadWithJwt = $this->client->call(Client::METHOD_GET, $path . '?project=' . $queryParams['project'] . '&jwt=' . $queryParams['jwt']); $this->assertEquals(200, $downloadWithJwt['headers']['status-code'], 'Failed to download file with JWT'); - $this->assertEquals($csvContent, $downloadWithJwt['body'], 'Downloaded content differs from original'); - // Test that download without JWT fails - $downloadWithoutJwt = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/download'); - $this->assertEquals(404, $downloadWithoutJwt['headers']['status-code'], 'File should not be downloadable without JWT'); + // Verify the downloaded content is valid CSV + $csvData = $downloadWithJwt['body']; + $this->assertNotEmpty($csvData, 'CSV export should not be empty'); + $this->assertStringContainsString('name', $csvData, 'CSV should contain the name column header'); + $this->assertStringContainsString('email', $csvData, 'CSV should contain the email column header'); + $this->assertStringContainsString('Test User 1', $csvData, 'CSV should contain test data'); - $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]); + // Cleanup $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId, [ 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] ]); - $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId, [ - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ]); } } diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php index 93c55b82b7..7eb5d9699c 100644 --- a/tests/e2e/Services/Sites/SitesBase.php +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -329,9 +329,33 @@ trait SitesBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ]); + return $template; } + protected function helperGetLatestCommit(string $owner, string $repository): ?string + { + $ch = curl_init("https://api.github.com/repos/{$owner}/{$repository}/commits/main"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'User-Agent: Appwrite', + 'Accept: application/vnd.github.v3+json' + ]); + + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($httpCode === 200) { + $commitData = json_decode($response, true); + if (isset($commitData['sha'])) { + return $commitData['sha']; + } + } + + return null; + } + protected function deleteSite(string $siteId): mixed { $site = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId, array_merge([ diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 8591514796..8c03ec7649 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1567,7 +1567,157 @@ class SitesCustomServerTest extends Scope 'repository' => $template['providerRepositoryId'], 'owner' => $template['providerOwner'], 'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'], - 'version' => $template['providerVersion'], + 'type' => 'tag', + 'reference' => $template['providerVersion'], + 'activate' => true + ]); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertEquals(0, $deployment['body']['sourceSize']); + $this->assertEquals(0, $deployment['body']['buildSize']); + $this->assertEquals(0, $deployment['body']['totalSize']); + + $this->assertEventually(function () use ($siteId) { + $site = $this->getSite($siteId); + $this->assertNotEmpty($site['body']['deploymentId']); + }, 50000, 500); + + $domain = $this->setupSiteDomain($siteId); + $proxyClient = new Client(); + $proxyClient->setEndpoint('http://' . $domain); + + $response = $proxyClient->call(Client::METHOD_GET, '/'); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro Blog", $response['body']); + $this->assertStringContainsString("Hello, Astronaut!", $response['body']); + + $response = $proxyClient->call(Client::METHOD_GET, '/about'); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro Blog", $response['body']); + $this->assertStringContainsString("About Me", $response['body']); + + $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertGreaterThan(0, $deployment['body']['sourceSize']); + $this->assertGreaterThan(0, $deployment['body']['buildSize']); + $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize']; + $this->assertEquals($totalSize, $deployment['body']['totalSize']); + + $this->cleanupSite($siteId); + } + + public function testCreateSiteFromTemplateBranch() + { + $template = $this->getTemplate('playground-for-astro'); + $this->assertEquals(200, $template['headers']['status-code']); + + $template = $template['body']; + + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Astro Blog - Branch Test', + 'framework' => $template['frameworks'][0]['key'], + 'adapter' => $template['frameworks'][0]['adapter'], + 'buildRuntime' => $template['frameworks'][0]['buildRuntime'], + 'outputDirectory' => $template['frameworks'][0]['outputDirectory'], + 'buildCommand' => $template['frameworks'][0]['buildCommand'], + 'installCommand' => $template['frameworks'][0]['installCommand'], + 'fallbackFile' => $template['frameworks'][0]['fallbackFile'], + ]); + + $this->assertNotEmpty($siteId); + + // Deploy using branch + $deployment = $this->createTemplateDeployment($siteId, [ + 'repository' => $template['providerRepositoryId'], + 'owner' => $template['providerOwner'], + 'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'], + 'type' => 'branch', + 'reference' => 'main', + 'activate' => true + ]); + + $this->assertEquals(202, $deployment['headers']['status-code']); + $this->assertNotEmpty($deployment['body']['$id']); + + $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertEquals(0, $deployment['body']['sourceSize']); + $this->assertEquals(0, $deployment['body']['buildSize']); + $this->assertEquals(0, $deployment['body']['totalSize']); + + $this->assertEventually(function () use ($siteId) { + $site = $this->getSite($siteId); + $this->assertNotEmpty($site['body']['deploymentId']); + }, 50000, 500); + + $domain = $this->setupSiteDomain($siteId); + $proxyClient = new Client(); + $proxyClient->setEndpoint('http://' . $domain); + + $response = $proxyClient->call(Client::METHOD_GET, '/'); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro Blog", $response['body']); + $this->assertStringContainsString("Hello, Astronaut!", $response['body']); + + $response = $proxyClient->call(Client::METHOD_GET, '/about'); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertStringContainsString("Astro Blog", $response['body']); + $this->assertStringContainsString("About Me", $response['body']); + + $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertGreaterThan(0, $deployment['body']['sourceSize']); + $this->assertGreaterThan(0, $deployment['body']['buildSize']); + $totalSize = $deployment['body']['sourceSize'] + $deployment['body']['buildSize']; + $this->assertEquals($totalSize, $deployment['body']['totalSize']); + + $this->cleanupSite($siteId); + } + + public function testCreateSiteFromTemplateCommit() + { + $template = $this->getTemplate('playground-for-astro'); + $this->assertEquals(200, $template['headers']['status-code']); + + // Get latest commit using helper function + $latestCommit = $this->helperGetLatestCommit( + $template['body']['providerOwner'], + $template['body']['providerRepositoryId'] + ); + $this->assertNotNull($latestCommit); + + $template = $template['body']; + + $siteId = $this->setupSite([ + 'siteId' => ID::unique(), + 'name' => 'Astro Blog - Commit Test', + 'framework' => $template['frameworks'][0]['key'], + 'adapter' => $template['frameworks'][0]['adapter'], + 'buildRuntime' => $template['frameworks'][0]['buildRuntime'], + 'outputDirectory' => $template['frameworks'][0]['outputDirectory'], + 'buildCommand' => $template['frameworks'][0]['buildCommand'], + 'installCommand' => $template['frameworks'][0]['installCommand'], + 'fallbackFile' => $template['frameworks'][0]['fallbackFile'], + ]); + + $this->assertNotEmpty($siteId); + + // Deploy using commit + $deployment = $this->createTemplateDeployment($siteId, [ + 'repository' => $template['providerRepositoryId'], + 'owner' => $template['providerOwner'], + 'rootDirectory' => $template['frameworks'][0]['providerRootDirectory'], + 'type' => 'commit', + 'reference' => $latestCommit, 'activate' => true ]); diff --git a/tests/e2e/Services/Storage/StorageBase.php b/tests/e2e/Services/Storage/StorageBase.php index 6879645a22..c67cfcc99a 100644 --- a/tests/e2e/Services/Storage/StorageBase.php +++ b/tests/e2e/Services/Storage/StorageBase.php @@ -30,7 +30,7 @@ trait StorageBase 'name' => 'Test Bucket', 'fileSecurity' => true, 'maximumFileSize' => 2000000, //2MB - 'allowedFileExtensions' => ['jpg', 'png', 'jfif'], + 'allowedFileExtensions' => ['jpg', 'png', 'jfif', 'webp'], 'permissions' => [ Permission::read(Role::any()), Permission::create(Role::any()), @@ -263,7 +263,39 @@ trait StorageBase $this->assertEquals(400, $res['headers']['status-code']); $this->assertEquals(Exception::STORAGE_INVALID_APPWRITE_ID, $res['body']['type']); - return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id']]; + /** + * Test for SUCCESS - Upload and view webp image + */ + $webpFile = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', array_merge([ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'fileId' => ID::unique(), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/image.webp'), 'image/webp', 'image.webp'), + 'permissions' => [ + Permission::read(Role::any()), + Permission::update(Role::any()), + Permission::delete(Role::any()), + ], + ]); + $this->assertEquals(201, $webpFile['headers']['status-code']); + $this->assertNotEmpty($webpFile['body']['$id']); + $this->assertEquals('image.webp', $webpFile['body']['name']); + $this->assertEquals('image/webp', $webpFile['body']['mimeType']); + + $webpFileId = $webpFile['body']['$id']; + + // View webp file + $webpView = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $webpFileId . '/view', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + $this->assertEquals(200, $webpView['headers']['status-code']); + $this->assertEquals('image/webp', $webpView['headers']['content-type']); + $this->assertNotEmpty($webpView['body']); + + return ['bucketId' => $bucketId, 'fileId' => $file['body']['$id'], 'largeFileId' => $largeFile['body']['$id'], 'largeBucketId' => $bucket2['body']['$id'], 'webpFileId' => $webpFileId]; } public function testCreateBucketFileZstdCompression(): array @@ -416,7 +448,7 @@ trait StorageBase ], ]); $this->assertEquals(200, $files['headers']['status-code']); - $this->assertEquals(0, count($files['body']['files'])); + $this->assertEquals(1, count($files['body']['files'])); $files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([ 'content-type' => 'application/json', @@ -869,6 +901,31 @@ trait StorageBase return $data; } + /** + * @depends testCreateBucketFile + */ + public function testFilePreview(array $data): array + { + $bucketId = $data['bucketId']; + $fileId = $data['fileId']; + + // Preview PNG as webp + $preview = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/preview', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'width' => 300, + 'height' => 300, + 'output' => 'webp', + ]); + + $this->assertEquals(200, $preview['headers']['status-code']); + $this->assertEquals('image/webp', $preview['headers']['content-type']); + $this->assertNotEmpty($preview['body']); + + return $data; + } + /** * @depends testUpdateBucketFile */ diff --git a/tests/e2e/Services/Tokens/TokensBase.php b/tests/e2e/Services/Tokens/TokensBase.php index a4461c06c2..ca6feed5fa 100644 --- a/tests/e2e/Services/Tokens/TokensBase.php +++ b/tests/e2e/Services/Tokens/TokensBase.php @@ -94,7 +94,7 @@ trait TokensBase $this->assertEquals(401, $failedPreview['body']['code']); $this->assertEquals(401, $failedPreview['headers']['status-code']); $this->assertEquals('user_unauthorized', $failedPreview['body']['type']); - $this->assertEquals('The current user is not authorized to perform the requested action.', $failedPreview['body']['message']); + $this->assertEquals('No permissions provided for action \'read\'', $failedPreview['body']['message']); // Extended file preview. Should fail as an anonymous user with no form of any access to the file. $failedCustomPreview = $this->client->call( @@ -113,7 +113,7 @@ trait TokensBase $this->assertEquals(401, $failedCustomPreview['body']['code']); $this->assertEquals(401, $failedCustomPreview['headers']['status-code']); $this->assertEquals('user_unauthorized', $failedCustomPreview['body']['type']); - $this->assertEquals('The current user is not authorized to perform the requested action.', $failedCustomPreview['body']['message']); + $this->assertEquals('No permissions provided for action \'read\'', $failedCustomPreview['body']['message']); // File view. Should fail as an anonymous user with no form of any access to the file. $failedView = $this->client->call( @@ -124,7 +124,7 @@ trait TokensBase $this->assertEquals(401, $failedView['body']['code']); $this->assertEquals(401, $failedView['headers']['status-code']); $this->assertEquals('user_unauthorized', $failedView['body']['type']); - $this->assertEquals('The current user is not authorized to perform the requested action.', $failedView['body']['message']); + $this->assertEquals('No permissions provided for action \'read\'', $failedView['body']['message']); // File download. Should fail as an anonymous user with no form of any access to the file. $failedDownload = $this->client->call( @@ -135,7 +135,7 @@ trait TokensBase $this->assertEquals(401, $failedDownload['body']['code']); $this->assertEquals(401, $failedDownload['headers']['status-code']); $this->assertEquals('user_unauthorized', $failedDownload['body']['type']); - $this->assertEquals('The current user is not authorized to perform the requested action.', $failedDownload['body']['message']); + $this->assertEquals('No permissions provided for action \'read\'', $failedDownload['body']['message']); return $data; } diff --git a/tests/e2e/Services/Tokens/TokensConsoleClientTest.php b/tests/e2e/Services/Tokens/TokensConsoleClientTest.php index c0f94a55bf..f1480faba0 100644 --- a/tests/e2e/Services/Tokens/TokensConsoleClientTest.php +++ b/tests/e2e/Services/Tokens/TokensConsoleClientTest.php @@ -9,7 +9,6 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\DateTime; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -63,10 +62,23 @@ class TokensConsoleClientTest extends Scope $fileId = $file['body']['$id']; + // Failure case: Expire date is in the past $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] - ], $this->getHeaders())); + ], $this->getHeaders()), [ + 'expire' => '2022-11-02', + ]); + $this->assertEquals(400, $token['headers']['status-code']); + $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + + // Success case: No expire date + $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'expire' => null, + ]); $this->assertEquals(201, $token['headers']['status-code']); $this->assertEquals('files', $token['body']['resourceType']); @@ -107,8 +119,19 @@ class TokensConsoleClientTest extends Scope { $tokenId = $data['tokenId']; + // Failure case: Expire date is in the past + $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'expire' => '2022-11-02', + ]); + $this->assertEquals(400, $token['headers']['status-code']); + $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + // Finite expiry - $expiry = DateTime::addSeconds(new \DateTime(), 3600); + $expiry = date('Y-m-d', strtotime("tomorrow")); $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] diff --git a/tests/e2e/Services/Tokens/TokensCustomServerTest.php b/tests/e2e/Services/Tokens/TokensCustomServerTest.php index fe8fa2bad9..779d5449b3 100644 --- a/tests/e2e/Services/Tokens/TokensCustomServerTest.php +++ b/tests/e2e/Services/Tokens/TokensCustomServerTest.php @@ -7,7 +7,6 @@ use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\DateTime; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -61,6 +60,17 @@ class TokensCustomServerTest extends Scope $fileId = $file['body']['$id']; + // Failure case: Expire date is in the past + $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'] + ], $this->getHeaders()), [ + 'expire' => '2022-11-02', + ]); + $this->assertEquals(400, $token['headers']['status-code']); + $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + + // Success case: No expire date $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'] @@ -83,8 +93,19 @@ class TokensCustomServerTest extends Scope { $tokenId = $data['tokenId']; - // Finite expiry - $expiry = DateTime::addSeconds(new \DateTime(), 3600); + // Failure case: Expire date is in the past + $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'expire' => '2022-11-02', + ]); + $this->assertEquals(400, $token['headers']['status-code']); + $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + + // Success case: Finite expiry + $expiry = date('Y-m-d', strtotime("tomorrow")); $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -94,9 +115,10 @@ class TokensCustomServerTest extends Scope ]); $dateValidator = new DatetimeValidator(); + $this->assertEquals(200, $token['headers']['status-code']); $this->assertTrue($dateValidator->isValid($token['body']['expire'])); - // Infinite expiry + // Success case: Infinite expiry $token = $this->client->call(Client::METHOD_PATCH, '/tokens/' . $tokenId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], diff --git a/tests/resources/image.webp b/tests/resources/image.webp new file mode 100644 index 0000000000..4a8791784a Binary files /dev/null and b/tests/resources/image.webp differ diff --git a/tests/unit/Auth/AuthTest.php b/tests/unit/Auth/AuthTest.php index 705da42879..5e883bf924 100644 --- a/tests/unit/Auth/AuthTest.php +++ b/tests/unit/Auth/AuthTest.php @@ -13,13 +13,27 @@ use Utopia\Database\Validator\Roles; class AuthTest extends TestCase { + private $authorization; + + public function getAuthorization(): Authorization + { + if (isset($this->authorization)) { + return $this->authorization; + } + + $this->authorization = new Authorization(); + + return $this->authorization; + } + + /** * Reset Roles */ - public function tearDown(): void + public function setUp(): void { - Authorization::cleanRoles(); - Authorization::setRole(Role::any()->toString()); + $this->getAuthorization()->cleanRoles(); + $this->getAuthorization()->addRole(Role::any()->toString()); } public function testCookieName(): void @@ -347,7 +361,7 @@ class AuthTest extends TestCase '$id' => '' ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, new Authorization()); $this->assertCount(1, $roles); $this->assertContains(Role::guests()->toString(), $roles); } @@ -383,7 +397,7 @@ class AuthTest extends TestCase ] ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $this->assertCount(13, $roles); $this->assertContains(Role::users()->toString(), $roles); @@ -404,21 +418,21 @@ class AuthTest extends TestCase $user['emailVerification'] = false; $user['phoneVerification'] = false; - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $this->assertContains(Role::users(Roles::DIMENSION_UNVERIFIED)->toString(), $roles); $this->assertContains(Role::user(ID::custom('123'), Roles::DIMENSION_UNVERIFIED)->toString(), $roles); // Enable single verification type $user['emailVerification'] = true; - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $this->assertContains(Role::users(Roles::DIMENSION_VERIFIED)->toString(), $roles); $this->assertContains(Role::user(ID::custom('123'), Roles::DIMENSION_VERIFIED)->toString(), $roles); } public function testPrivilegedUserRoles(): void { - Authorization::setRole(Auth::USER_ROLE_OWNER); + $this->getAuthorization()->addRole(Auth::USER_ROLE_OWNER); $user = new Document([ '$id' => ID::custom('123'), 'emailVerification' => true, @@ -444,7 +458,7 @@ class AuthTest extends TestCase ] ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $this->assertCount(7, $roles); $this->assertNotContains(Role::users()->toString(), $roles); @@ -462,7 +476,7 @@ class AuthTest extends TestCase public function testAppUserRoles(): void { - Authorization::setRole(Auth::USER_ROLE_APPS); + $this->getAuthorization()->addRole(Auth::USER_ROLE_APPS); $user = new Document([ '$id' => ID::custom('123'), 'memberships' => [ @@ -486,7 +500,7 @@ class AuthTest extends TestCase ] ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $this->assertCount(7, $roles); $this->assertNotContains(Role::users()->toString(), $roles); diff --git a/tests/unit/Messaging/MessagingChannelsTest.php b/tests/unit/Messaging/MessagingChannelsTest.php index 8ba0374093..8fb7f3f666 100644 --- a/tests/unit/Messaging/MessagingChannelsTest.php +++ b/tests/unit/Messaging/MessagingChannelsTest.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; +use Utopia\Database\Validator\Authorization; class MessagingChannelsTest extends TestCase { @@ -34,6 +35,19 @@ class MessagingChannelsTest extends TestCase 'functions.1', ]; + + private $authorization; + + public function getAuthorization(): Authorization + { + if (isset($this->authorization)) { + return $this->authorization; + } + + $this->authorization = new Authorization(); + return $this->authorization; + } + public function setUp(): void { /** @@ -66,7 +80,7 @@ class MessagingChannelsTest extends TestCase ] ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $parsedChannels = Realtime::convertChannels([0 => $channel], $user->getId()); @@ -90,7 +104,7 @@ class MessagingChannelsTest extends TestCase '$id' => '' ]); - $roles = Auth::getRoles($user); + $roles = Auth::getRoles($user, $this->getAuthorization()); $parsedChannels = Realtime::convertChannels([0 => $channel], $user->getId()); diff --git a/tests/unit/Network/Validators/DNSTest.php b/tests/unit/Network/Validators/DNSTest.php index 9f8928b87f..4611e00f4d 100644 --- a/tests/unit/Network/Validators/DNSTest.php +++ b/tests/unit/Network/Validators/DNSTest.php @@ -51,8 +51,10 @@ class DNSTest extends TestCase #[Retry(count: 5)] public function testCAA(): void { - $certainly = new DNS('certainly.com', Record::TYPE_CAA, 'ns1.digitalocean.com'); - $letsencrypt = new DNS('letsencrypt.org', Record::TYPE_CAA, 'ns1.digitalocean.com'); + $digitalOceanIp = '172.64.52.210'; // ping ns1.digitalocean.com + + $certainly = new DNS('certainly.com', Record::TYPE_CAA, $digitalOceanIp); + $letsencrypt = new DNS('letsencrypt.org', Record::TYPE_CAA, $digitalOceanIp); // No CAA record succeeds on main domain & subdomains for any issuer $this->assertEquals($certainly->isValid('caa.appwrite.org'), true);