From 7a465dc8f8dd40c22b8233e7d0c7f047c16988d0 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Mon, 2 Jun 2025 17:53:35 +0530 Subject: [PATCH 01/60] Don't auto-activate deployment which started earlier & ended later than active deployment --- .../Platform/Modules/Functions/Workers/Builds.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index de5543c9f3..589416be3d 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1072,6 +1072,21 @@ class Builds extends Action /** Set auto deploy */ if ($deployment->getAttribute('activate') === true) { + // Check if current active deployment started later than this deployment + $currentDeploymentId = $resource->getAttribute('deploymentId', ''); + if (!empty($currentDeploymentId)) { + $currentDeployment = $dbForProject->getDocument('deployments', $currentDeploymentId); + if (!$currentDeployment->isEmpty()) { + $currentStartTime = $currentDeployment->getAttribute('buildStartedAt', ''); + $newStartTime = $deployment->getAttribute('buildStartedAt', ''); + + if (!empty($currentStartTime) && !empty($newStartTime) && $currentStartTime > $newStartTime) { + Console::info('Skipping auto-activation as current deployment started later'); + return; + } + } + } + $resource->setAttribute('live', true); switch ($resource->getCollection()) { case 'functions': From 2088792d09383d875f2468b8593fa79341946b50 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 3 Jun 2025 14:23:17 +0530 Subject: [PATCH 02/60] Fix build activation race condition --- composer.lock | 12 ++++----- docker-compose.yml | 2 +- .../Modules/Functions/Workers/Builds.php | 27 +++++++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index 9e757f9db8..f27c08954d 100644 --- a/composer.lock +++ b/composer.lock @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.0", + "version": "0.41.1", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "96316272a3cee1a3abf5b9f05ae49ebbff03725e" + "reference": "6d9318abf4542a757c87abf056557d6afa1dc06b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/96316272a3cee1a3abf5b9f05ae49ebbff03725e", - "reference": "96316272a3cee1a3abf5b9f05ae49ebbff03725e", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/6d9318abf4542a757c87abf056557d6afa1dc06b", + "reference": "6d9318abf4542a757c87abf056557d6afa1dc06b", "shasum": "" }, "require": { @@ -4852,9 +4852,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/0.41.0" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.1" }, - "time": "2025-05-26T09:47:45+00:00" + "time": "2025-06-01T04:20:04+00:00" }, { "name": "doctrine/annotations", diff --git a/docker-compose.yml b/docker-compose.yml index 29a43aca91..1861af9afd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -213,7 +213,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:6.0.32 + image: appwrite/console:6.0.35 restart: unless-stopped networks: - appwrite diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 589416be3d..c933f6cda8 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -275,6 +275,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); } @@ -525,6 +526,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); } @@ -1056,6 +1058,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); } @@ -1073,15 +1076,22 @@ class Builds extends Action /** Set auto deploy */ if ($deployment->getAttribute('activate') === true) { // Check if current active deployment started later than this deployment - $currentDeploymentId = $resource->getAttribute('deploymentId', ''); - if (!empty($currentDeploymentId)) { - $currentDeployment = $dbForProject->getDocument('deployments', $currentDeploymentId); - if (!$currentDeployment->isEmpty()) { - $currentStartTime = $currentDeployment->getAttribute('buildStartedAt', ''); - $newStartTime = $deployment->getAttribute('buildStartedAt', ''); + $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); + $currentActiveDeploymentId = $resource->getAttribute('deploymentId', ''); + if (!empty($currentActiveDeploymentId)) { + $currentActiveDeployment = $dbForProject->getDocument('deployments', $currentActiveDeploymentId); + if (!$currentActiveDeployment->isEmpty()) { + $currentActiveStartTime = $currentActiveDeployment->getAttribute('buildStartedAt', ''); + $currentActiveEndTime = $currentActiveDeployment->getAttribute('buildEndedAt', ''); + $deploymentStartTime = $deployment->getAttribute('buildStartedAt', ''); + $deploymentEndTime = $deployment->getAttribute('buildEndedAt', ''); - if (!empty($currentStartTime) && !empty($newStartTime) && $currentStartTime > $newStartTime) { - Console::info('Skipping auto-activation as current deployment started later'); + // Skip auto-activation if: + // 1. Current active deployment started later than deployment that is being activated, AND + // 2. Current active deployment finished earlier than deployment that is being activated + if ((!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime > $deploymentStartTime) && + (!empty($currentActiveEndTime) && !empty($deploymentEndTime) && $currentActiveEndTime < $deploymentEndTime)) { + Console::info('Skipping auto-activation as current deployment is more recent'); return; } } @@ -1263,6 +1273,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); } From 995482ee20f2385f4162dd032b682857dedb0148 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Fri, 13 Jun 2025 19:04:46 +0530 Subject: [PATCH 03/60] Update console version --- composer.lock | 27 +++++++++++++-------------- docker-compose.yml | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index e38efa0b96..4e434d714a 100644 --- a/composer.lock +++ b/composer.lock @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.0", + "version": "0.41.6", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "96316272a3cee1a3abf5b9f05ae49ebbff03725e" + "reference": "bfcebb968c527e17fdf18d40b8986c83d9c18c93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/96316272a3cee1a3abf5b9f05ae49ebbff03725e", - "reference": "96316272a3cee1a3abf5b9f05ae49ebbff03725e", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/bfcebb968c527e17fdf18d40b8986c83d9c18c93", + "reference": "bfcebb968c527e17fdf18d40b8986c83d9c18c93", "shasum": "" }, "require": { @@ -4852,9 +4852,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/0.41.0" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.6" }, - "time": "2025-05-26T09:47:45+00:00" + "time": "2025-06-12T03:27:26+00:00" }, { "name": "doctrine/annotations", @@ -5147,16 +5147,16 @@ }, { "name": "matthiasmullie/minify", - "version": "1.3.73", + "version": "1.3.74", "source": { "type": "git", "url": "https://github.com/matthiasmullie/minify.git", - "reference": "cb7a9297b4ab070909cefade30ee95054d4ae87a" + "reference": "a2593286a4135d03c6a6a9e9aeded5d41e931ce4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/cb7a9297b4ab070909cefade30ee95054d4ae87a", - "reference": "cb7a9297b4ab070909cefade30ee95054d4ae87a", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/a2593286a4135d03c6a6a9e9aeded5d41e931ce4", + "reference": "a2593286a4135d03c6a6a9e9aeded5d41e931ce4", "shasum": "" }, "require": { @@ -5167,8 +5167,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": ">=2.0", "matthiasmullie/scrapbook": ">=1.3", - "phpunit/phpunit": ">=4.8", - "squizlabs/php_codesniffer": ">=3.0" + "phpunit/phpunit": ">=4.8" }, "suggest": { "psr/cache-implementation": "Cache implementation to use with Minify::cache" @@ -5206,7 +5205,7 @@ ], "support": { "issues": "https://github.com/matthiasmullie/minify/issues", - "source": "https://github.com/matthiasmullie/minify/tree/1.3.73" + "source": "https://github.com/matthiasmullie/minify/tree/1.3.74" }, "funding": [ { @@ -5214,7 +5213,7 @@ "type": "github" } ], - "time": "2024-03-15T10:27:10+00:00" + "time": "2025-06-12T08:06:04+00:00" }, { "name": "matthiasmullie/path-converter", diff --git a/docker-compose.yml b/docker-compose.yml index c042d36cd5..07870859fb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -213,7 +213,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:6.0.41 + image: appwrite/console:6.1.0 restart: unless-stopped networks: - appwrite From 3ad5a2652ee822cc276c808b49798fc0d471c2ea Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Fri, 13 Jun 2025 19:14:00 +0530 Subject: [PATCH 04/60] Update console version --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 07870859fb..a0eeba3ff0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -213,7 +213,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:6.1.0 + image: appwrite/console:6.0.43 restart: unless-stopped networks: - appwrite From 421510f8476c15f889b0f52561fd5d276bc9a9c8 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 2 Jul 2025 11:01:25 +0530 Subject: [PATCH 05/60] chore: update nodejs to 17.1.0 --- app/config/platforms.php | 2 +- .../examples/databases/upsert-document.md | 16 +++++ .../examples/databases/upsert-documents.md | 2 +- docs/sdks/nodejs/CHANGELOG.md | 61 ++++++++++++++++++- 4 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 docs/examples/1.7.x/server-nodejs/examples/databases/upsert-document.md diff --git a/app/config/platforms.php b/app/config/platforms.php index 96d5426515..41c924c704 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -250,7 +250,7 @@ return [ [ 'key' => 'nodejs', 'name' => 'Node.js', - 'version' => '17.0.0', + 'version' => '17.1.0', 'url' => 'https://github.com/appwrite/sdk-for-node', 'package' => 'https://www.npmjs.com/package/node-appwrite', 'enabled' => true, diff --git a/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-document.md b/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-document.md new file mode 100644 index 0000000000..fcc62d601c --- /dev/null +++ b/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-document.md @@ -0,0 +1,16 @@ +const sdk = require('node-appwrite'); + +const client = new sdk.Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +const databases = new sdk.Databases(client); + +const result = await databases.upsertDocument( + '', // databaseId + '', // collectionId + '', // documentId + {}, // data + ["read("any")"] // permissions (optional) +); diff --git a/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-documents.md b/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-documents.md index 5b4795627d..425b7ba51f 100644 --- a/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-documents.md +++ b/docs/examples/1.7.x/server-nodejs/examples/databases/upsert-documents.md @@ -10,5 +10,5 @@ const databases = new sdk.Databases(client); const result = await databases.upsertDocuments( '', // databaseId '', // collectionId - [] // documents (optional) + [] // documents ); diff --git a/docs/sdks/nodejs/CHANGELOG.md b/docs/sdks/nodejs/CHANGELOG.md index c8a8a16c8e..d7261b67d5 100644 --- a/docs/sdks/nodejs/CHANGELOG.md +++ b/docs/sdks/nodejs/CHANGELOG.md @@ -1,13 +1,68 @@ # Change Log +## 17.1.0 + +* Add `upsertDocument` method +* Add `dart-3.8` and `flutter-3.32` runtimes +* Add `gif` image format +* Update bulk operation methods to reflect warning message +* Fix file parameter handling in chunked upload method + ## 17.0.0 -* Add `` to doc examples due to the new multi region endpoints +* Add `REGION` to doc examples due to the new multi region endpoints * Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. * Add doc examples, class and methods for new `Sites` service * Add doc examples, class and methods for new `Tokens` service -* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Add enums for `BuildRuntime`, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` * Updates enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 * Add `token` param to `getFilePreview` and `getFileView` for File tokens usage * Add `queries` and `search` params to `listMemberships` method -* Removes `search` param from `listExecutions` method \ No newline at end of file +* Removes `search` param from `listExecutions` method + +## 16.0.0 + +* Fix: remove content-type from GET requests +* Update (breaking): min and max params are now optional in `updateFloatAttribute` and `updateIntegerAttribute` methods (changes their positioning in method definition) + +## 15.0.1 + +* Remove titles from all function descriptions +* Fix typing for collection "attribute" key +* Remove unnecessary awaits and asyncs +* Ensure `AppwriteException` response is always string + +## 15.0.0 + +* Fix: pong response & chunked upload + +## 14.2.0 + +* Add new push message parameters + +## 14.1.0 + +* Support updating attribute name and size + +## 14.0.0 + +* Support for Appwrite 1.6 +* Add `key` attribute to `Runtime` response model. +* Add `buildSize` attribute to `Deployments` response model +* Add `scheduledAt` attribute to `Executions` response model +* Add `scopes` attribute to `Functions` response model +* Add `specifications` attribute to `Functions` response model +* Add new response model for `Specifications` +* Add new response model for `Builds` +* Add `createJWT()` : Enables creating a JWT using the `userId` +* Add `listSpecifications()`: Enables listing available runtime specifications +* Add `deleteExecution()` : Enables deleting executions +* Add `updateDeploymentBuild()`: Enables cancelling a deployment +* Add `scheduledAt` parameter to `createExecution()`: Enables creating a delayed execution +* Breaking changes + * Remove `otp` parameter from `deleteMFAAuthenticator`. + * Add `scopes` parameter for create/update function. + * Rename `templateBranch` to `templateVersion` in `createFunction()`. + * Rename `downloadDeployment()` to `getDeploymentDownload()` + +> You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`. \ No newline at end of file From 60158aec0c9e3b34a85b4f9fb8344d762a6d4623 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 3 Jul 2025 18:02:40 +0530 Subject: [PATCH 06/60] chore: update cli to 8.1.1 as well --- app/config/platforms.php | 2 +- composer.lock | 109 +++++++++++++++++++------------------ docs/sdks/cli/CHANGELOG.md | 8 +++ 3 files changed, 65 insertions(+), 54 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 41c924c704..41895ddc07 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -217,7 +217,7 @@ return [ [ 'key' => 'cli', 'name' => 'Command Line', - 'version' => '8.1.0', + 'version' => '8.1.1', 'url' => 'https://github.com/appwrite/sdk-for-cli', 'package' => 'https://www.npmjs.com/package/appwrite-cli', 'enabled' => true, diff --git a/composer.lock b/composer.lock index 05c8a49512..6744d4f99a 100644 --- a/composer.lock +++ b/composer.lock @@ -1878,16 +1878,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.45", + "version": "3.0.46", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "bd81b90d5963c6b9d87de50357585375223f4dd8" + "reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/bd81b90d5963c6b9d87de50357585375223f4dd8", - "reference": "bd81b90d5963c6b9d87de50357585375223f4dd8", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6", + "reference": "56483a7de62a6c2a6635e42e93b8a9e25d4f0ec6", "shasum": "" }, "require": { @@ -1968,7 +1968,7 @@ ], "support": { "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.45" + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.46" }, "funding": [ { @@ -1984,7 +1984,7 @@ "type": "tidelift" } ], - "time": "2025-06-22T22:54:43+00:00" + "time": "2025-06-26T16:29:55+00:00" }, { "name": "psr/container", @@ -2547,16 +2547,16 @@ }, { "name": "symfony/http-client", - "version": "v7.3.0", + "version": "v7.3.1", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "57e4fb86314015a695a750ace358d07a7e37b8a9" + "reference": "4403d87a2c16f33345dca93407a8714ee8c05a64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/57e4fb86314015a695a750ace358d07a7e37b8a9", - "reference": "57e4fb86314015a695a750ace358d07a7e37b8a9", + "url": "https://api.github.com/repos/symfony/http-client/zipball/4403d87a2c16f33345dca93407a8714ee8c05a64", + "reference": "4403d87a2c16f33345dca93407a8714ee8c05a64", "shasum": "" }, "require": { @@ -2568,6 +2568,7 @@ }, "conflict": { "amphp/amp": "<2.5", + "amphp/socket": "<1.1", "php-http/discovery": "<1.15", "symfony/http-foundation": "<6.4" }, @@ -2580,7 +2581,6 @@ "require-dev": { "amphp/http-client": "^4.2.1|^5.0", "amphp/http-tunnel": "^1.0|^2.0", - "amphp/socket": "^1.1", "guzzlehttp/promises": "^1.4|^2.0", "nyholm/psr7": "^1.0", "php-http/httplug": "^1.0|^2.0", @@ -2622,7 +2622,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.3.0" + "source": "https://github.com/symfony/http-client/tree/v7.3.1" }, "funding": [ { @@ -2638,7 +2638,7 @@ "type": "tidelift" } ], - "time": "2025-05-02T08:23:16+00:00" + "time": "2025-06-28T07:58:39+00:00" }, { "name": "symfony/http-client-contracts", @@ -2960,16 +2960,16 @@ }, { "name": "tbachert/spi", - "version": "v1.0.3", + "version": "v1.0.5", "source": { "type": "git", "url": "https://github.com/Nevay/spi.git", - "reference": "506a79c98e1a51522e76ee921ccb6c62d52faf3a" + "reference": "e7078767866d0a9e0f91d3f9d42a832df5e39002" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nevay/spi/zipball/506a79c98e1a51522e76ee921ccb6c62d52faf3a", - "reference": "506a79c98e1a51522e76ee921ccb6c62d52faf3a", + "url": "https://api.github.com/repos/Nevay/spi/zipball/e7078767866d0a9e0f91d3f9d42a832df5e39002", + "reference": "e7078767866d0a9e0f91d3f9d42a832df5e39002", "shasum": "" }, "require": { @@ -2987,7 +2987,7 @@ "extra": { "class": "Nevay\\SPI\\Composer\\Plugin", "branch-alias": { - "dev-main": "0.2.x-dev" + "dev-main": "1.0.x-dev" }, "plugin-optional": true }, @@ -3006,9 +3006,9 @@ ], "support": { "issues": "https://github.com/Nevay/spi/issues", - "source": "https://github.com/Nevay/spi/tree/v1.0.3" + "source": "https://github.com/Nevay/spi/tree/v1.0.5" }, - "time": "2025-04-02T19:38:14+00:00" + "time": "2025-06-29T15:42:06+00:00" }, { "name": "thecodingmachine/safe", @@ -3493,16 +3493,16 @@ }, { "name": "utopia-php/database", - "version": "0.71.8", + "version": "0.71.9", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "7dff6b67a54f1a7f9d3f210db4c6e40d7052b79e" + "reference": "eb2f759020bba617e99dd67973a9bd949b47f54e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/7dff6b67a54f1a7f9d3f210db4c6e40d7052b79e", - "reference": "7dff6b67a54f1a7f9d3f210db4c6e40d7052b79e", + "url": "https://api.github.com/repos/utopia-php/database/zipball/eb2f759020bba617e99dd67973a9bd949b47f54e", + "reference": "eb2f759020bba617e99dd67973a9bd949b47f54e", "shasum": "" }, "require": { @@ -3543,9 +3543,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.71.8" + "source": "https://github.com/utopia-php/database/tree/0.71.9" }, - "time": "2025-06-26T14:48:17+00:00" + "time": "2025-07-02T16:37:41+00:00" }, { "name": "utopia-php/detector", @@ -3993,16 +3993,16 @@ }, { "name": "utopia-php/migration", - "version": "0.10.1", + "version": "0.10.4", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "ea1c585df7ec5f346f061a11581fc9a91679966f" + "reference": "0c85917482db172b3ccdc0704e42af3c1cc89361" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/ea1c585df7ec5f346f061a11581fc9a91679966f", - "reference": "ea1c585df7ec5f346f061a11581fc9a91679966f", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/0c85917482db172b3ccdc0704e42af3c1cc89361", + "reference": "0c85917482db172b3ccdc0704e42af3c1cc89361", "shasum": "" }, "require": { @@ -4043,9 +4043,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.10.1" + "source": "https://github.com/utopia-php/migration/tree/0.10.4" }, - "time": "2025-05-26T15:29:19+00:00" + "time": "2025-07-02T18:31:09+00:00" }, { "name": "utopia-php/orchestration", @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.9", + "version": "0.41.10", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "61037c1ed9262308cab49c1d760f3278036ab694" + "reference": "09e87e6bf7ce6ba254a963da52823f66fff5c8e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/61037c1ed9262308cab49c1d760f3278036ab694", - "reference": "61037c1ed9262308cab49c1d760f3278036ab694", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/09e87e6bf7ce6ba254a963da52823f66fff5c8e3", + "reference": "09e87e6bf7ce6ba254a963da52823f66fff5c8e3", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.9" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.10" }, - "time": "2025-06-27T10:16:17+00:00" + "time": "2025-07-03T12:10:13+00:00" }, { "name": "doctrine/annotations", @@ -5084,16 +5084,16 @@ }, { "name": "laravel/pint", - "version": "v1.22.1", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "941d1927c5ca420c22710e98420287169c7bcaf7" + "reference": "9ab851dba4faa51a3c3223dd3d07044129021024" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/941d1927c5ca420c22710e98420287169c7bcaf7", - "reference": "941d1927c5ca420c22710e98420287169c7bcaf7", + "url": "https://api.github.com/repos/laravel/pint/zipball/9ab851dba4faa51a3c3223dd3d07044129021024", + "reference": "9ab851dba4faa51a3c3223dd3d07044129021024", "shasum": "" }, "require": { @@ -5104,10 +5104,10 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.75.0", - "illuminate/view": "^11.44.7", - "larastan/larastan": "^3.4.0", - "laravel-zero/framework": "^11.36.1", + "friendsofphp/php-cs-fixer": "^3.76.0", + "illuminate/view": "^11.45.1", + "larastan/larastan": "^3.5.0", + "laravel-zero/framework": "^11.45.0", "mockery/mockery": "^1.6.12", "nunomaduro/termwind": "^2.3.1", "pestphp/pest": "^2.36.0" @@ -5117,6 +5117,9 @@ ], "type": "project", "autoload": { + "files": [ + "overrides/Runner/Parallel/ProcessFactory.php" + ], "psr-4": { "App\\": "app/", "Database\\Seeders\\": "database/seeders/", @@ -5146,7 +5149,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-05-08T08:38:12+00:00" + "time": "2025-07-03T10:37:47+00:00" }, { "name": "matthiasmullie/minify", @@ -7255,16 +7258,16 @@ }, { "name": "symfony/console", - "version": "v7.3.0", + "version": "v7.3.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "66c1440edf6f339fd82ed6c7caa76cb006211b44" + "reference": "9e27aecde8f506ba0fd1d9989620c04a87697101" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/66c1440edf6f339fd82ed6c7caa76cb006211b44", - "reference": "66c1440edf6f339fd82ed6c7caa76cb006211b44", + "url": "https://api.github.com/repos/symfony/console/zipball/9e27aecde8f506ba0fd1d9989620c04a87697101", + "reference": "9e27aecde8f506ba0fd1d9989620c04a87697101", "shasum": "" }, "require": { @@ -7329,7 +7332,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.3.0" + "source": "https://github.com/symfony/console/tree/v7.3.1" }, "funding": [ { @@ -7345,7 +7348,7 @@ "type": "tidelift" } ], - "time": "2025-05-24T10:34:04+00:00" + "time": "2025-06-27T19:55:54+00:00" }, { "name": "symfony/filesystem", diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index c2c93b0c09..c9fb601dc6 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 8.1.1 + +* Type generation fixes: + * Add ability to generate types to specific file + * Fix optional attributes using `?` instead of `| null` + * Fix `Models` import error + * Improve formatting and add auto-generated comments + ## 8.1.0 * Add multi-region support to `init` command From dd9096fd2b92db52a91e3884be77d2f95790222b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 3 Jul 2025 18:04:28 +0530 Subject: [PATCH 07/60] fix: lint --- app/controllers/general.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 225762ce7e..8c4c6932f2 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -49,7 +49,6 @@ use Utopia\Logger\Log\User; use Utopia\Logger\Logger; use Utopia\Platform\Service; use Utopia\System\System; -use Utopia\Validator\Hostname; use Utopia\Validator\Text; Config::setParam('domainVerification', false); From 2cf7246c7af5a456b86fc55c77b1522a1f9b718f Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 3 Jul 2025 18:15:50 +0530 Subject: [PATCH 08/60] fix: changelog --- docs/sdks/cli/CHANGELOG.md | 4 ++-- src/Appwrite/Platform/Tasks/SDKs.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index c9fb601dc6..d1885363dd 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -3,8 +3,8 @@ ## 8.1.1 * Type generation fixes: - * Add ability to generate types to specific file - * Fix optional attributes using `?` instead of `| null` + * Add ability to generate types directly to a specific file by passing a file path to `appwrite types output_path`, instead of just a directory + * Fix non-required attributes to not be null if default value is provided * Fix `Models` import error * Improve formatting and add auto-generated comments diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index ea73af541c..28c0fd841d 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -279,8 +279,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND git init && \ git remote add origin ' . $gitUrl . ' && \ git fetch origin && \ - git checkout main || git checkout -b main && \ - git pull origin main && \ + git checkout master || git checkout -b master && \ + git pull origin master && \ git checkout ' . $gitBranch . ' || git checkout -b ' . $gitBranch . ' && \ git fetch origin ' . $gitBranch . ' || git push -u origin ' . $gitBranch . ' && \ git pull origin ' . $gitBranch . ' && \ From 58c2f55d1c13e6997b251b35356f9f7de2af20f8 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 3 Jul 2025 18:51:50 +0530 Subject: [PATCH 09/60] fix: revert to main --- src/Appwrite/Platform/Tasks/SDKs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/SDKs.php b/src/Appwrite/Platform/Tasks/SDKs.php index 28c0fd841d..ea73af541c 100644 --- a/src/Appwrite/Platform/Tasks/SDKs.php +++ b/src/Appwrite/Platform/Tasks/SDKs.php @@ -279,8 +279,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND git init && \ git remote add origin ' . $gitUrl . ' && \ git fetch origin && \ - git checkout master || git checkout -b master && \ - git pull origin master && \ + git checkout main || git checkout -b main && \ + git pull origin main && \ git checkout ' . $gitBranch . ' || git checkout -b ' . $gitBranch . ' && \ git fetch origin ' . $gitBranch . ' || git push -u origin ' . $gitBranch . ' && \ git pull origin ' . $gitBranch . ' && \ From 7bbf58d0ddd0548f4e105bbac4ef10082fcd9f71 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 4 Jul 2025 15:31:52 +0530 Subject: [PATCH 10/60] update cli --- composer.lock | 12 ++++++------ docs/sdks/cli/CHANGELOG.md | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 6744d4f99a..72b460ec52 100644 --- a/composer.lock +++ b/composer.lock @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.10", + "version": "0.41.11", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "09e87e6bf7ce6ba254a963da52823f66fff5c8e3" + "reference": "60122cb613a5a1c82667ecc2217e351654a8d404" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/09e87e6bf7ce6ba254a963da52823f66fff5c8e3", - "reference": "09e87e6bf7ce6ba254a963da52823f66fff5c8e3", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/60122cb613a5a1c82667ecc2217e351654a8d404", + "reference": "60122cb613a5a1c82667ecc2217e351654a8d404", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.10" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.11" }, - "time": "2025-07-03T12:10:13+00:00" + "time": "2025-07-04T09:56:24+00:00" }, { "name": "doctrine/annotations", diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index d1885363dd..29115bc0f7 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -2,6 +2,7 @@ ## 8.1.1 +* Fix circular dependency issue due to usage of `success` method in `utils.js` file from `parser.js` file * Type generation fixes: * Add ability to generate types directly to a specific file by passing a file path to `appwrite types output_path`, instead of just a directory * Fix non-required attributes to not be null if default value is provided From 0fb55f63122860246a64dca47bd1f21ac70c3813 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 5 Jul 2025 07:59:52 +0530 Subject: [PATCH 11/60] fix: origin validation for web extensions --- src/Appwrite/Network/Platform.php | 8 ++++++++ src/Appwrite/Network/Validator/Origin.php | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Network/Platform.php b/src/Appwrite/Network/Platform.php index d584ec074f..cbfb2c3b99 100644 --- a/src/Appwrite/Network/Platform.php +++ b/src/Appwrite/Network/Platform.php @@ -24,6 +24,10 @@ class Platform public const SCHEME_HTTP = 'http'; public const SCHEME_HTTPS = 'https'; + public const SCHEME_CHROME_EXTENSION = 'chrome-extension'; + public const SCHEME_FIREFOX_EXTENSION = 'moz-extension'; + public const SCHEME_SAFARI_EXTENSION = 'extension'; + public const SCHEME_EDGE_EXTENSION = 'ms-browser-extension'; public const SCHEME_IOS = 'appwrite-ios'; public const SCHEME_MACOS = 'appwrite-macos'; public const SCHEME_WATCHOS = 'appwrite-watchos'; @@ -45,6 +49,10 @@ class Platform self::SCHEME_ANDROID => 'Android', self::SCHEME_WINDOWS => 'Windows', self::SCHEME_LINUX => 'Linux', + self::SCHEME_CHROME_EXTENSION => 'Chrome Extension', + self::SCHEME_FIREFOX_EXTENSION => 'Firefox Extension', + self::SCHEME_SAFARI_EXTENSION => 'Safari Extension', + self::SCHEME_EDGE_EXTENSION => 'Edge Extension', ]; /** diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index c8d9ee626d..fc58651723 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -42,7 +42,15 @@ class Origin extends Validator $this->scheme = $this->parseScheme($origin); $this->host = strtolower(parse_url($origin, PHP_URL_HOST) ?? ''); - if (in_array($this->scheme, [Platform::SCHEME_HTTP, Platform::SCHEME_HTTPS], true)) { + $webPlatforms = [ + Platform::SCHEME_HTTP, + Platform::SCHEME_HTTPS, + Platform::SCHEME_CHROME_EXTENSION, + Platform::SCHEME_FIREFOX_EXTENSION, + Platform::SCHEME_SAFARI_EXTENSION, + Platform::SCHEME_EDGE_EXTENSION, + ]; + if (in_array($this->scheme, $webPlatforms, true)) { $validator = new Hostname($this->hostnames); return $validator->isValid($this->host); } From 18d30c48d518424b404602ae663724edaf0a2e2c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 5 Jul 2025 10:15:18 +0530 Subject: [PATCH 12/60] fix: add missing check for hostname --- src/Appwrite/Network/Validator/Origin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index fc58651723..5fc019942d 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -55,7 +55,10 @@ class Origin extends Validator return $validator->isValid($this->host); } - if (!empty($this->scheme) && in_array($this->scheme, $this->schemes, true)) { + if (!empty($this->scheme) && + in_array($this->scheme, $this->schemes, true) && + in_array($this->host, $this->hostnames, true) + ) { return true; } From 9dcb80649fffd4ca687a136b8899b99a510e9b22 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 5 Jul 2025 10:18:40 +0530 Subject: [PATCH 13/60] fix: extension for safari --- src/Appwrite/Network/Platform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Network/Platform.php b/src/Appwrite/Network/Platform.php index cbfb2c3b99..93d0dc6576 100644 --- a/src/Appwrite/Network/Platform.php +++ b/src/Appwrite/Network/Platform.php @@ -26,7 +26,7 @@ class Platform public const SCHEME_HTTPS = 'https'; public const SCHEME_CHROME_EXTENSION = 'chrome-extension'; public const SCHEME_FIREFOX_EXTENSION = 'moz-extension'; - public const SCHEME_SAFARI_EXTENSION = 'extension'; + public const SCHEME_SAFARI_EXTENSION = 'safari-web-extension'; public const SCHEME_EDGE_EXTENSION = 'ms-browser-extension'; public const SCHEME_IOS = 'appwrite-ios'; public const SCHEME_MACOS = 'appwrite-macos'; From 5fffae39d455af3b34ead12dddcd7b48d7c20413 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 5 Jul 2025 17:59:01 +0530 Subject: [PATCH 14/60] chore: update naming and add tests --- src/Appwrite/Network/Platform.php | 8 ++++---- src/Appwrite/Network/Validator/Origin.php | 5 +---- tests/unit/Network/Validators/OriginTest.php | 12 ++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Network/Platform.php b/src/Appwrite/Network/Platform.php index 93d0dc6576..ea64ff98c1 100644 --- a/src/Appwrite/Network/Platform.php +++ b/src/Appwrite/Network/Platform.php @@ -49,10 +49,10 @@ class Platform self::SCHEME_ANDROID => 'Android', self::SCHEME_WINDOWS => 'Windows', self::SCHEME_LINUX => 'Linux', - self::SCHEME_CHROME_EXTENSION => 'Chrome Extension', - self::SCHEME_FIREFOX_EXTENSION => 'Firefox Extension', - self::SCHEME_SAFARI_EXTENSION => 'Safari Extension', - self::SCHEME_EDGE_EXTENSION => 'Edge Extension', + self::SCHEME_CHROME_EXTENSION => 'Web (Chrome Extension)', + self::SCHEME_FIREFOX_EXTENSION => 'Web (Firefox Extension)', + self::SCHEME_SAFARI_EXTENSION => 'Web (Safari Extension)', + self::SCHEME_EDGE_EXTENSION => 'Web (Edge Extension)', ]; /** diff --git a/src/Appwrite/Network/Validator/Origin.php b/src/Appwrite/Network/Validator/Origin.php index 5fc019942d..fc58651723 100644 --- a/src/Appwrite/Network/Validator/Origin.php +++ b/src/Appwrite/Network/Validator/Origin.php @@ -55,10 +55,7 @@ class Origin extends Validator return $validator->isValid($this->host); } - if (!empty($this->scheme) && - in_array($this->scheme, $this->schemes, true) && - in_array($this->host, $this->hostnames, true) - ) { + if (!empty($this->scheme) && in_array($this->scheme, $this->schemes, true)) { return true; } diff --git a/tests/unit/Network/Validators/OriginTest.php b/tests/unit/Network/Validators/OriginTest.php index 989c06da71..516108bc32 100644 --- a/tests/unit/Network/Validators/OriginTest.php +++ b/tests/unit/Network/Validators/OriginTest.php @@ -94,5 +94,17 @@ class OriginTest extends TestCase $this->assertEquals(false, $validator->isValid('appwrite-windows://com.company.appname')); $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Windows platform on your project console dashboard', $validator->getDescription()); + + $this->assertEquals(false, $validator->isValid('chrome-extension://com.company.appname')); + $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Chrome Extension) platform on your project console dashboard', $validator->getDescription()); + + $this->assertEquals(false, $validator->isValid('moz-extension://com.company.appname')); + $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Firefox Extension) platform on your project console dashboard', $validator->getDescription()); + + $this->assertEquals(false, $validator->isValid('safari-web-extension://com.company.appname')); + $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Safari Extension) platform on your project console dashboard', $validator->getDescription()); + + $this->assertEquals(false, $validator->isValid('ms-browser-extension://com.company.appname')); + $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Edge Extension) platform on your project console dashboard', $validator->getDescription()); } } From 80c49824821c61623562ab3217c6531d1596f2ba Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 00:51:35 +0530 Subject: [PATCH 15/60] Update only specific attribute --- composer.lock | 12 +- docker-compose.yml | 6 +- .../Modules/Functions/Workers/Builds.php | 124 +++++++++--------- 3 files changed, 71 insertions(+), 71 deletions(-) diff --git a/composer.lock b/composer.lock index 72b460ec52..653d1841d5 100644 --- a/composer.lock +++ b/composer.lock @@ -5276,16 +5276,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.1", + "version": "1.13.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" + "reference": "faed855a7b5f4d4637717c2b3863e277116beb36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", - "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/faed855a7b5f4d4637717c2b3863e277116beb36", + "reference": "faed855a7b5f4d4637717c2b3863e277116beb36", "shasum": "" }, "require": { @@ -5324,7 +5324,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.3" }, "funding": [ { @@ -5332,7 +5332,7 @@ "type": "tidelift" } ], - "time": "2025-04-29T12:36:36+00:00" + "time": "2025-07-05T12:25:42+00:00" }, { "name": "nikic/php-parser", diff --git a/docker-compose.yml b/docker-compose.yml index a01165d949..66b9609eb3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -214,7 +214,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:6.1.2 + image: appwrite/console:6.1.12 restart: unless-stopped networks: - appwrite @@ -441,10 +441,12 @@ services: appwrite-worker-builds: entrypoint: worker-builds <<: *x-logging - container_name: appwrite-worker-builds image: appwrite-dev networks: - appwrite + deploy: + mode: replicated + replicas: 2 volumes: - appwrite-functions:/storage/functions:rw - appwrite-sites:/storage/sites:rw diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index e56f935a2f..900261e6d5 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -274,10 +274,8 @@ class Builds extends Action $deployment->setAttribute('status', 'processing'); $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); - if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); - $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -525,10 +523,8 @@ class Builds extends Action $deployment->setAttribute('status', 'building'); $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); - if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); - $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -1063,10 +1059,8 @@ class Builds extends Action $deployment->setAttribute('status', 'ready'); $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); - if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); - $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -1080,6 +1074,7 @@ class Builds extends Action Console::success("Build id: $deploymentId created"); /** Set auto deploy */ + $activateBuild = true; if ($deployment->getAttribute('activate') === true) { // Check if current active deployment started later than this deployment $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); @@ -1090,6 +1085,9 @@ class Builds extends Action $currentActiveStartTime = $currentActiveDeployment->getAttribute('buildStartedAt', ''); $currentActiveEndTime = $currentActiveDeployment->getAttribute('buildEndedAt', ''); $deploymentStartTime = $deployment->getAttribute('buildStartedAt', ''); + $tentativeEndTime = DateTime::now(); + $deployment->setAttribute('buildEndedAt', $tentativeEndTime); + $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), new Document(['buildEndedAt' => $tentativeEndTime])); $deploymentEndTime = $deployment->getAttribute('buildEndedAt', ''); // Skip auto-activation if: @@ -1098,61 +1096,63 @@ class Builds extends Action if ((!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime > $deploymentStartTime) && (!empty($currentActiveEndTime) && !empty($deploymentEndTime) && $currentActiveEndTime < $deploymentEndTime)) { Console::info('Skipping auto-activation as current deployment is more recent'); - return; + $activateBuild = false; } } } - $resource->setAttribute('live', true); - switch ($resource->getCollection()) { - case 'functions': - $resource->setAttribute('deploymentId', $deployment->getId()); - $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); - $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); - $resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource); + if ($activateBuild) { + $resource->setAttribute('live', true); + switch ($resource->getCollection()) { + case 'functions': + $resource->setAttribute('deploymentId', $deployment->getId()); + $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); + $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); + $resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource); - $queries = [ - Query::equal('projectInternalId', [$project->getSequence()]), - Query::equal('type', ['deployment']), - Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), - Query::equal('deploymentResourceType', ['function']), - Query::equal('trigger', ['manual']), - Query::equal('deploymentVcsProviderBranch', ['']), - ]; + $queries = [ + Query::equal('projectInternalId', [$project->getSequence()]), + Query::equal('type', ['deployment']), + Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), + Query::equal('deploymentResourceType', ['function']), + Query::equal('trigger', ['manual']), + Query::equal('deploymentVcsProviderBranch', ['']), + ]; - $rulesUpdated = false; - $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { - $rulesUpdated = true; - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); - }, $queries); - break; - case 'sites': - $resource->setAttribute('deploymentId', $deployment->getId()); - $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); - $resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', '')); - $resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', '')); - $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); - $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); - $queries = [ - Query::equal('projectInternalId', [$project->getSequence()]), - Query::equal('type', ['deployment']), - Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), - Query::equal('deploymentResourceType', ['site']), - Query::equal('trigger', ['manual']), - Query::equal('deploymentVcsProviderBranch', ['']), - ]; + $rulesUpdated = false; + $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { + $rulesUpdated = true; + $rule = $rule + ->setAttribute('deploymentId', $deployment->getId()) + ->setAttribute('deploymentInternalId', $deployment->getSequence()); + $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + }, $queries); + break; + case 'sites': + $resource->setAttribute('deploymentId', $deployment->getId()); + $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); + $resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', '')); + $resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', '')); + $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); + $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); + $queries = [ + Query::equal('projectInternalId', [$project->getSequence()]), + Query::equal('type', ['deployment']), + Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), + Query::equal('deploymentResourceType', ['site']), + Query::equal('trigger', ['manual']), + Query::equal('deploymentVcsProviderBranch', ['']), + ]; - $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); - }, $queries); + $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { + $rule = $rule + ->setAttribute('deploymentId', $deployment->getId()) + ->setAttribute('deploymentInternalId', $deployment->getSequence()); + $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + }, $queries); - break; + break; + } } } @@ -1280,10 +1280,8 @@ class Builds extends Action $deployment->setAttribute('buildLogs', $message); $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); - if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); - $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus', $deployment->getAttribute('status', '')])); } $queueForRealtime From 1a286ad3f4d3d36e1189608f42f8a9eabe6b14fc Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 00:53:10 +0530 Subject: [PATCH 16/60] Revert replica changes --- docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 66b9609eb3..af6610daf4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -441,12 +441,10 @@ services: appwrite-worker-builds: entrypoint: worker-builds <<: *x-logging + container_name: appwrite-worker-builds image: appwrite-dev networks: - appwrite - deploy: - mode: replicated - replicas: 2 volumes: - appwrite-functions:/storage/functions:rw - appwrite-sites:/storage/sites:rw From 067b53482f145c65ff91b55a559ab21d6423149e Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 01:02:55 +0530 Subject: [PATCH 17/60] Fix bug --- src/Appwrite/Platform/Modules/Functions/Workers/Builds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 900261e6d5..69fa60f97e 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1281,7 +1281,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus', $deployment->getAttribute('status', '')])); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime From 14e52058c73328a4350fb266e872e627f47905a3 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 8 Jul 2025 13:46:53 +0530 Subject: [PATCH 18/60] fix: file tokens not working on file-security. --- app/controllers/api/storage.php | 11 ++++++++--- app/controllers/shared/api.php | 1 - .../Tokens/Http/Tokens/Buckets/Files/Action.php | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 98a5b105a3..c6e242296b 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -967,6 +967,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Imagick extension is missing'); } + /* @type Document $bucket */ $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); $isAPIKey = Auth::isAppUser(Authorization::getRoles()); @@ -987,6 +988,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') 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)); } @@ -1157,7 +1159,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') ->inject('resourceToken') ->inject('deviceForFiles') ->action(function (string $bucketId, string $fileId, ?string $token, Request $request, Response $response, Database $dbForProject, string $mode, Document $resourceToken, Device $deviceForFiles) { - + /* @type Document $bucket */ $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); $isAPIKey = Auth::isAppUser(Authorization::getRoles()); @@ -1175,9 +1177,10 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/download') throw new Exception(Exception::USER_UNAUTHORIZED); } - if ($fileSecurity && !$valid) { + 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)); } @@ -1317,6 +1320,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') ->inject('resourceToken') ->inject('deviceForFiles') ->action(function (string $bucketId, string $fileId, ?string $token, Response $response, Request $request, Database $dbForProject, string $mode, Document $resourceToken, Device $deviceForFiles) { + /* @type Document $bucket */ $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); $isAPIKey = Auth::isAppUser(Authorization::getRoles()); @@ -1334,9 +1338,10 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view') throw new Exception(Exception::USER_UNAUTHORIZED); } - if ($fileSecurity && !$valid) { + 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)); } diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 76fe177b0b..86fb1e5822 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -576,7 +576,6 @@ App::init() $bucket = Authorization::skip(fn () => $dbForProject->getDocument('buckets', $bucketId)); $isToken = !$resourceToken->isEmpty() && $resourceToken->getAttribute('bucketInternalId') === $bucket->getSequence(); - $isAPIKey = Auth::isAppUser(Authorization::getRoles()); $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::getRoles()); if ($bucket->isEmpty() || (!$bucket->getAttribute('enabled') && !$isAppUser && !$isPrivilegedUser)) { 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 bcefaf353f..5708f1b83b 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 @@ -37,6 +37,7 @@ class Action extends UtopiaAction if ($file->isEmpty()) { throw new Exception(Exception::STORAGE_FILE_NOT_FOUND); } + return [ 'bucket' => $bucket, 'file' => $file, From 97d5f0f0302310595f9b246ed8dcb3dfb0ab9d7c Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 8 Jul 2025 15:34:52 +0530 Subject: [PATCH 19/60] add: e2e. --- tests/e2e/Services/Tokens/TokensBase.php | 71 ++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/e2e/Services/Tokens/TokensBase.php b/tests/e2e/Services/Tokens/TokensBase.php index af93f5fc73..b6da8f4c41 100644 --- a/tests/e2e/Services/Tokens/TokensBase.php +++ b/tests/e2e/Services/Tokens/TokensBase.php @@ -275,4 +275,75 @@ trait TokensBase $this->assertEquals($image->getImageHeight(), $original->getImageHeight()); $this->assertEquals('PNG', $image->getImageFormat()); } + + public function testDownloadFileWithFileSecurity(): void + { + $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'], + ], + [ + 'name' => 'Test Bucket', + 'bucketId' => ID::unique(), + 'fileSecurity' => true, + 'allowedFileExtensions' => ['jpg', 'png', 'jfif'], + ] + ); + + $this->assertEquals(201, $bucket['headers']['status-code']); + $this->assertNotEmpty($bucket['body']['$id']); + + $bucketId = $bucket['body']['$id']; + + $file = $this->client->call( + Client::METHOD_POST, + '/storage/buckets/' . $bucketId . '/files', + [ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], + [ + 'fileId' => ID::unique(), + 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), + ] + ); + + $fileId = $file['body']['$id']; + + $token = $this->client->call( + Client::METHOD_POST, + '/tokens/buckets/' . $bucketId . '/files/' . $fileId, + [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ] + ); + + $jwtToken = $token['body']['secret']; + + $fileDownloaded = $this->client->call( + Client::METHOD_GET, + '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/download', + ['content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], + [ 'token' => $jwtToken ] + ); + + $this->assertEquals(200, $fileDownloaded['headers']['status-code']); + + $image = new \Imagick(); + $image->readImageBlob($fileDownloaded['body']); + $original = new \Imagick(__DIR__ . '/../../../resources/logo.png'); + + $this->assertEquals($image->getImageWidth(), $original->getImageWidth()); + $this->assertEquals($image->getImageHeight(), $original->getImageHeight()); + $this->assertEquals('PNG', $image->getImageFormat()); + } } From 7ea896301fdb954f43e573c03db1045488dc7b12 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 8 Jul 2025 15:42:38 +0530 Subject: [PATCH 20/60] update: test to include preview, view and download with file-security. --- tests/e2e/Services/Tokens/TokensBase.php | 46 +++++++++++++++--------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/e2e/Services/Tokens/TokensBase.php b/tests/e2e/Services/Tokens/TokensBase.php index b6da8f4c41..7690653453 100644 --- a/tests/e2e/Services/Tokens/TokensBase.php +++ b/tests/e2e/Services/Tokens/TokensBase.php @@ -5,6 +5,8 @@ namespace Tests\E2E\Services\Tokens; use CURLFile; use Tests\E2E\Client; use Utopia\Database\Helpers\ID; +use Utopia\Database\Helpers\Permission; +use Utopia\Database\Helpers\Role; trait TokensBase { @@ -276,7 +278,7 @@ trait TokensBase $this->assertEquals('PNG', $image->getImageFormat()); } - public function testDownloadFileWithFileSecurity(): void + public function testFileAccessWithFileSecurity(): void { $bucket = $this->client->call( Client::METHOD_POST, @@ -309,6 +311,7 @@ trait TokensBase ], [ 'fileId' => ID::unique(), + 'permissions' => [ Permission::read(Role::label('devrel')) ], 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'), ] ); @@ -327,23 +330,34 @@ trait TokensBase $jwtToken = $token['body']['secret']; - $fileDownloaded = $this->client->call( - Client::METHOD_GET, - '/storage/buckets/' . $bucketId . '/files/' . $fileId . '/download', - ['content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], - [ 'token' => $jwtToken ] - ); + $guestHeaders = ['content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ]; - $this->assertEquals(200, $fileDownloaded['headers']['status-code']); + $endpoints = ['preview', 'view', 'download']; - $image = new \Imagick(); - $image->readImageBlob($fileDownloaded['body']); - $original = new \Imagick(__DIR__ . '/../../../resources/logo.png'); + foreach ($endpoints as $endpoint) { + $response = $this->client->call( + Client::METHOD_GET, + "/storage/buckets/{$bucketId}/files/{$fileId}/$endpoint", + $guestHeaders, + ['token' => $jwtToken] + ); + + $this->assertNotEmpty($response['body']); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('image/png', $response['headers']['content-type']); + + if ($endpoint === 'download') { + $image = new \Imagick(); + $image->readImageBlob($response['body']); + $original = new \Imagick(__DIR__ . '/../../../resources/logo.png'); + + $this->assertEquals($original->getImageWidth(), $image->getImageWidth()); + $this->assertEquals($original->getImageHeight(), $image->getImageHeight()); + $this->assertEquals('PNG', $image->getImageFormat()); + } + } - $this->assertEquals($image->getImageWidth(), $original->getImageWidth()); - $this->assertEquals($image->getImageHeight(), $original->getImageHeight()); - $this->assertEquals('PNG', $image->getImageFormat()); } } From 020814e6728870b4e4c3ad2af96deecaf28f4aa8 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 8 Jul 2025 15:43:28 +0530 Subject: [PATCH 21/60] update: inline guest headers. --- tests/e2e/Services/Tokens/TokensBase.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/e2e/Services/Tokens/TokensBase.php b/tests/e2e/Services/Tokens/TokensBase.php index 7690653453..1ac0452d52 100644 --- a/tests/e2e/Services/Tokens/TokensBase.php +++ b/tests/e2e/Services/Tokens/TokensBase.php @@ -330,18 +330,19 @@ trait TokensBase $jwtToken = $token['body']['secret']; - $guestHeaders = ['content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ]; - $endpoints = ['preview', 'view', 'download']; foreach ($endpoints as $endpoint) { $response = $this->client->call( Client::METHOD_GET, "/storage/buckets/{$bucketId}/files/{$fileId}/$endpoint", - $guestHeaders, - ['token' => $jwtToken] + [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], + [ + 'token' => $jwtToken + ] ); $this->assertNotEmpty($response['body']); From 7ca951ed81599b4865a76b3e3886102d071a0bd4 Mon Sep 17 00:00:00 2001 From: Darshan Date: Tue, 8 Jul 2025 15:43:51 +0530 Subject: [PATCH 22/60] remove: `{}` --- tests/e2e/Services/Tokens/TokensBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Tokens/TokensBase.php b/tests/e2e/Services/Tokens/TokensBase.php index 1ac0452d52..a4461c06c2 100644 --- a/tests/e2e/Services/Tokens/TokensBase.php +++ b/tests/e2e/Services/Tokens/TokensBase.php @@ -335,7 +335,7 @@ trait TokensBase foreach ($endpoints as $endpoint) { $response = $this->client->call( Client::METHOD_GET, - "/storage/buckets/{$bucketId}/files/{$fileId}/$endpoint", + "/storage/buckets/$bucketId/files/$fileId/$endpoint", [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], From 61a27bfe5505e021ee58fcd60b1967b1db6f4891 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 16:30:43 +0530 Subject: [PATCH 23/60] Simplify auto-activation logic and just update attributes --- .../Modules/Functions/Workers/Builds.php | 73 +++++++++---------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 69fa60f97e..7ab2c84c8a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -856,9 +856,7 @@ class Builds extends Action $adapter = $resource->getAttribute('adapter', ''); if (empty($adapter)) { - $resource->setAttribute('adapter', $detection->getName()); - $resource->setAttribute('fallbackFile', $detection->getFallbackFile() ?? ''); - $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); + $resource = $dbForProject->updateDocument('sites', $resource->getId(), new Document(['adapter' => $detection->getName(), 'fallbackFile' => $detection->getFallbackFile() ?? ''])); $deployment->setAttribute('adapter', $detection->getName()); $deployment->setAttribute('fallbackFile', $detection->getFallbackFile() ?? ''); @@ -1083,18 +1081,10 @@ class Builds extends Action $currentActiveDeployment = $dbForProject->getDocument('deployments', $currentActiveDeploymentId); if (!$currentActiveDeployment->isEmpty()) { $currentActiveStartTime = $currentActiveDeployment->getAttribute('buildStartedAt', ''); - $currentActiveEndTime = $currentActiveDeployment->getAttribute('buildEndedAt', ''); $deploymentStartTime = $deployment->getAttribute('buildStartedAt', ''); - $tentativeEndTime = DateTime::now(); - $deployment->setAttribute('buildEndedAt', $tentativeEndTime); - $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), new Document(['buildEndedAt' => $tentativeEndTime])); - $deploymentEndTime = $deployment->getAttribute('buildEndedAt', ''); - // Skip auto-activation if: - // 1. Current active deployment started later than deployment that is being activated, AND - // 2. Current active deployment finished earlier than deployment that is being activated - if ((!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime > $deploymentStartTime) && - (!empty($currentActiveEndTime) && !empty($deploymentEndTime) && $currentActiveEndTime < $deploymentEndTime)) { + // Skip auto-activation if current active deployment started later than deployment that is being activated + if (!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime > $deploymentStartTime) { Console::info('Skipping auto-activation as current deployment is more recent'); $activateBuild = false; } @@ -1102,13 +1092,14 @@ class Builds extends Action } if ($activateBuild) { - $resource->setAttribute('live', true); switch ($resource->getCollection()) { case 'functions': - $resource->setAttribute('deploymentId', $deployment->getId()); - $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); - $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); - $resource = $dbForProject->updateDocument('functions', $resource->getId(), $resource); + $resource = $dbForProject->updateDocument('functions', $resource->getId(), new Document([ + 'live' => true, + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), + ])); $queries = [ Query::equal('projectInternalId', [$project->getSequence()]), @@ -1122,19 +1113,21 @@ class Builds extends Action $rulesUpdated = false; $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { $rulesUpdated = true; - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + ])); }, $queries); break; case 'sites': - $resource->setAttribute('deploymentId', $deployment->getId()); - $resource->setAttribute('deploymentInternalId', $deployment->getSequence()); - $resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', '')); - $resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', '')); - $resource->setAttribute('deploymentCreatedAt', $deployment->getCreatedAt()); - $resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource); + $resource = $dbForProject->updateDocument('sites', $resource->getId(), new Document([ + 'live' => true, + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + 'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''), + 'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), + ])); $queries = [ Query::equal('projectInternalId', [$project->getSequence()]), Query::equal('type', ['deployment']), @@ -1145,10 +1138,10 @@ class Builds extends Action ]; $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + ])); }, $queries); break; @@ -1192,10 +1185,10 @@ class Builds extends Action ])); } catch (Duplicate $err) { $rule = $dbForPlatform->getDocument('rules', $ruleId); - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + ])); } $queries = [ @@ -1208,10 +1201,10 @@ class Builds extends Action ]; $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $rule = $rule - ->setAttribute('deploymentId', $deployment->getId()) - ->setAttribute('deploymentInternalId', $deployment->getSequence()); - $dbForPlatform->updateDocument('rules', $rule->getId(), $rule); + $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + ])); }, $queries); } } From 9d7e218e993fc51e5ffcde5cc88c791f37aa917b Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 17:12:35 +0530 Subject: [PATCH 24/60] Save result of updateDocument --- .../Modules/Functions/Workers/Builds.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 7ab2c84c8a..9c8d457cb5 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -275,7 +275,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); + $resource = $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -524,7 +524,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); + $resource = $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -1058,7 +1058,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); + $resource = $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime @@ -1113,7 +1113,7 @@ class Builds extends Action $rulesUpdated = false; $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { $rulesUpdated = true; - $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), ])); @@ -1138,7 +1138,7 @@ class Builds extends Action ]; $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), ])); @@ -1184,8 +1184,7 @@ class Builds extends Action 'region' => $project->getAttribute('region') ])); } catch (Duplicate $err) { - $rule = $dbForPlatform->getDocument('rules', $ruleId); - $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), ])); @@ -1201,7 +1200,7 @@ class Builds extends Action ]; $dbForPlatform->foreach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), ])); @@ -1274,7 +1273,7 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); if ($deployment->getSequence() === $resource->getAttribute('latestDeploymentInternalId', '')) { - $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); + $resource = $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), new Document(['latestDeploymentStatus' => $deployment->getAttribute('status', '')])); } $queueForRealtime From a5a1860ba6755dfa597494ba2b6b14ba34d32ccf Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 17:42:23 +0530 Subject: [PATCH 25/60] Use createdAt instead of buildStartTime --- .../Platform/Modules/Functions/Workers/Builds.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 9c8d457cb5..39bed1c09f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1072,7 +1072,7 @@ class Builds extends Action Console::success("Build id: $deploymentId created"); /** Set auto deploy */ - $activateBuild = true; + $activateBuild = false; if ($deployment->getAttribute('activate') === true) { // Check if current active deployment started later than this deployment $resource = $dbForProject->getDocument($resource->getCollection(), $resource->getId()); @@ -1080,15 +1080,18 @@ class Builds extends Action if (!empty($currentActiveDeploymentId)) { $currentActiveDeployment = $dbForProject->getDocument('deployments', $currentActiveDeploymentId); if (!$currentActiveDeployment->isEmpty()) { - $currentActiveStartTime = $currentActiveDeployment->getAttribute('buildStartedAt', ''); - $deploymentStartTime = $deployment->getAttribute('buildStartedAt', ''); + $currentActiveStartTime = $currentActiveDeployment->getCreatedAt(); + $deploymentStartTime = $deployment->getCreatedAt(); // Skip auto-activation if current active deployment started later than deployment that is being activated - if (!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime > $deploymentStartTime) { + if (!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime < $deploymentStartTime) { + $activateBuild = true; + } else { Console::info('Skipping auto-activation as current deployment is more recent'); - $activateBuild = false; } } + } else { + $activateBuild = true; } if ($activateBuild) { From bc9caeaae09a7b1021030c8650c6fe7036e4d6f9 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 17:45:45 +0530 Subject: [PATCH 26/60] Use ruleId --- src/Appwrite/Platform/Modules/Functions/Workers/Builds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 39bed1c09f..5531eb286b 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1187,7 +1187,7 @@ class Builds extends Action 'region' => $project->getAttribute('region') ])); } catch (Duplicate $err) { - $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + $rule = $dbForPlatform->updateDocument('rules', $ruleId, new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), ])); From bd63f0cf3d65adb423a81088e2ed1232242c3426 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Tue, 8 Jul 2025 17:46:54 +0530 Subject: [PATCH 27/60] Remove empty check --- src/Appwrite/Platform/Modules/Functions/Workers/Builds.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 5531eb286b..cb4b7a6a18 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1084,7 +1084,7 @@ class Builds extends Action $deploymentStartTime = $deployment->getCreatedAt(); // Skip auto-activation if current active deployment started later than deployment that is being activated - if (!empty($currentActiveStartTime) && !empty($deploymentStartTime) && $currentActiveStartTime < $deploymentStartTime) { + if ($currentActiveStartTime < $deploymentStartTime) { $activateBuild = true; } else { Console::info('Skipping auto-activation as current deployment is more recent'); From 26496e68c4392a5b35e232742076d208c9203fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 8 Jul 2025 14:51:28 +0200 Subject: [PATCH 28/60] Attempt to simplify code --- .../Modules/Functions/Workers/Builds.php | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index cb4b7a6a18..295acec885 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1093,62 +1093,62 @@ class Builds extends Action } else { $activateBuild = true; } + } - if ($activateBuild) { - switch ($resource->getCollection()) { - case 'functions': - $resource = $dbForProject->updateDocument('functions', $resource->getId(), new Document([ - 'live' => true, + if ($activateBuild) { + switch ($resource->getCollection()) { + case 'functions': + $resource = $dbForProject->updateDocument('functions', $resource->getId(), new Document([ + 'live' => true, + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), + ])); + + $queries = [ + Query::equal('projectInternalId', [$project->getSequence()]), + Query::equal('type', ['deployment']), + Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), + Query::equal('deploymentResourceType', ['function']), + Query::equal('trigger', ['manual']), + Query::equal('deploymentVcsProviderBranch', ['']), + ]; + + $rulesUpdated = false; + $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { + $rulesUpdated = true; + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), - 'deploymentCreatedAt' => $deployment->getCreatedAt(), ])); + }, $queries); + break; + case 'sites': + $resource = $dbForProject->updateDocument('sites', $resource->getId(), new Document([ + 'live' => true, + 'deploymentId' => $deployment->getId(), + 'deploymentInternalId' => $deployment->getSequence(), + 'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''), + 'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''), + 'deploymentCreatedAt' => $deployment->getCreatedAt(), + ])); + $queries = [ + Query::equal('projectInternalId', [$project->getSequence()]), + Query::equal('type', ['deployment']), + Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), + Query::equal('deploymentResourceType', ['site']), + Query::equal('trigger', ['manual']), + Query::equal('deploymentVcsProviderBranch', ['']), + ]; - $queries = [ - Query::equal('projectInternalId', [$project->getSequence()]), - Query::equal('type', ['deployment']), - Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), - Query::equal('deploymentResourceType', ['function']), - Query::equal('trigger', ['manual']), - Query::equal('deploymentVcsProviderBranch', ['']), - ]; - - $rulesUpdated = false; - $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment, &$rulesUpdated) { - $rulesUpdated = true; - $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - 'deploymentId' => $deployment->getId(), - 'deploymentInternalId' => $deployment->getSequence(), - ])); - }, $queries); - break; - case 'sites': - $resource = $dbForProject->updateDocument('sites', $resource->getId(), new Document([ - 'live' => true, + $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { + $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ 'deploymentId' => $deployment->getId(), 'deploymentInternalId' => $deployment->getSequence(), - 'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''), - 'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''), - 'deploymentCreatedAt' => $deployment->getCreatedAt(), ])); - $queries = [ - Query::equal('projectInternalId', [$project->getSequence()]), - Query::equal('type', ['deployment']), - Query::equal('deploymentResourceInternalId', [$resource->getSequence()]), - Query::equal('deploymentResourceType', ['site']), - Query::equal('trigger', ['manual']), - Query::equal('deploymentVcsProviderBranch', ['']), - ]; + }, $queries); - $dbForPlatform->forEach('rules', function (Document $rule) use ($dbForPlatform, $deployment) { - $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ - 'deploymentId' => $deployment->getId(), - 'deploymentInternalId' => $deployment->getSequence(), - ])); - }, $queries); - - break; - } + break; } } From e42275e0b7f85b45818ba4ccef200a6e551007fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 9 Jul 2025 11:26:05 +0200 Subject: [PATCH 29/60] Minify tests --- .env | 5 +- .github/workflows/tests.yml | 87 ++++++++++++++++++- app/controllers/mock.php | 26 ------ docker-compose.yml | 3 +- .../Modules/Functions/Workers/Builds.php | 3 +- .../Functions/FunctionsCustomServerTest.php | 43 --------- .../Services/Sites/SitesConsoleClientTest.php | 3 + tests/resources/functions/dart/main.dart | 21 ----- tests/resources/functions/php-v2/index.php | 7 -- tests/resources/functions/python/main.py | 21 ----- tests/resources/functions/ruby/main.rb | 19 ---- tests/resources/functions/swift/index.swift | 17 ---- 12 files changed, 95 insertions(+), 160 deletions(-) delete mode 100644 tests/resources/functions/dart/main.dart delete mode 100644 tests/resources/functions/php-v2/index.php delete mode 100644 tests/resources/functions/python/main.py delete mode 100644 tests/resources/functions/ruby/main.rb delete mode 100644 tests/resources/functions/swift/index.swift diff --git a/.env b/.env index 42c23ac87f..76af83a946 100644 --- a/.env +++ b/.env @@ -85,8 +85,9 @@ _APP_COMPUTE_MAINTENANCE_INTERVAL=600 _APP_COMPUTE_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 -_APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_SITES_RUNTIMES=static-1,node-22,flutter-3.32 +_APP_BROWSER_HOST=http://appwrite-browser:3000/v1 +_APP_FUNCTIONS_RUNTIMES=node-22 +_APP_SITES_RUNTIMES=static-1,node-22 _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_START_TIME=12:00 _APP_MAINTENANCE_RETENTION_CACHE=2592000 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a69e11b892..57a1a1aefa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -178,6 +178,7 @@ jobs: - name: Load and Start Appwrite run: | docker load --input /tmp/${{ env.IMAGE }}.tar + sed -i 's/_APP_BROWSER_HOST=http:\/\/appwrite-browser:3000\/v1/_APP_BROWSER_HOST=http:\/\/invalid-browser\/v1/' .env docker compose up -d sleep 30 @@ -198,7 +199,7 @@ jobs: docker compose exec -T \ -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ - appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys + appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys screenshots e2e_shared_mode_test: name: E2E Shared Mode Service Test @@ -277,7 +278,7 @@ jobs: docker compose exec -T \ -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ - appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys + appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys screenshots e2e_dev_keys: name: E2E Service Test (Dev Keys) @@ -358,3 +359,85 @@ jobs: -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ appwrite test /usr/src/code/tests/e2e/Services/Projects --debug --group=devKeys + + e2e_screenshots_keys: + name: E2E Service Test (Site Screenshots) + runs-on: ubuntu-latest + needs: setup + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Load Cache + uses: actions/cache@v4 + with: + key: ${{ env.CACHE_KEY }} + path: /tmp/${{ env.IMAGE }}.tar + fail-on-cache-miss: true + + - name: Load and Start Appwrite + run: | + docker load --input /tmp/${{ env.IMAGE }}.tar + sed -i 's/_APP_OPTIONS_ABUSE=disabled/_APP_OPTIONS_ABUSE=enabled/' .env + docker compose up -d + sleep 30 + + - name: Run Site tests with browser connected in dedicated table mode + run: | + echo "Keeping original value of _APP_BROWSER_HOST" + echo "Using project tables" + export _APP_DATABASE_SHARED_TABLES= + export _APP_DATABASE_SHARED_TABLES_V1= + + docker compose exec -T \ + -e _APP_DATABASE_SHARED_TABLES \ + -e _APP_DATABASE_SHARED_TABLES_V1 \ + appwrite test /usr/src/code/tests/e2e/Services/Sites --debug --group=screenshots + + e2e_screenshots_shared_mode: + name: E2E Shared Mode Service Test (Site Screenshots) + runs-on: ubuntu-latest + needs: [ setup, check_database_changes ] + if: needs.check_database_changes.outputs.database_changed == 'true' + strategy: + fail-fast: false + matrix: + tables-mode: [ + 'Shared V1', + 'Shared V2', + ] + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: Load Cache + uses: actions/cache@v4 + with: + key: ${{ env.CACHE_KEY }} + path: /tmp/${{ env.IMAGE }}.tar + fail-on-cache-miss: true + + - name: Load and Start Appwrite + run: | + docker load --input /tmp/${{ env.IMAGE }}.tar + sed -i 's/_APP_OPTIONS_ABUSE=disabled/_APP_OPTIONS_ABUSE=enabled/' .env + docker compose up -d + sleep 30 + + - name: Run Site tests with browser connected in ${{ matrix.tables-mode }} table mode + run: | + echo "Keeping original value of _APP_BROWSER_HOST" + if [ "${{ matrix.tables-mode }}" == "Shared V1" ]; then + echo "Using shared tables V1" + export _APP_DATABASE_SHARED_TABLES=database_db_main + export _APP_DATABASE_SHARED_TABLES_V1=database_db_main + elif [ "${{ matrix.tables-mode }}" == "Shared V2" ]; then + echo "Using shared tables V2" + export _APP_DATABASE_SHARED_TABLES=database_db_main + export _APP_DATABASE_SHARED_TABLES_V1= + fi + + docker compose exec -T \ + -e _APP_DATABASE_SHARED_TABLES \ + -e _APP_DATABASE_SHARED_TABLES_V1 \ + appwrite test /usr/src/code/tests/e2e/Services/Sites --debug --group=screenshots diff --git a/app/controllers/mock.php b/app/controllers/mock.php index fd7b9ab495..0684e5294a 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -129,32 +129,6 @@ App::get('/v1/mock/tests/general/oauth2/failure') ]); }); -App::patch('/v1/mock/functions-v2') - ->desc('Update Function Version to V2 (outdated code syntax)') - ->groups(['mock', 'api', 'functions']) - ->label('scope', 'functions.write') - ->label('docs', false) - ->param('functionId', '', new UID(), 'Function ID.') - ->inject('response') - ->inject('dbForProject') - ->action(function (string $functionId, Response $response, Database $dbForProject) { - $isDevelopment = System::getEnv('_APP_ENV', 'development') === 'development'; - - if (!$isDevelopment) { - throw new Exception(Exception::GENERAL_NOT_IMPLEMENTED); - } - - $function = $dbForProject->getDocument('functions', $functionId); - - if ($function->isEmpty()) { - throw new Exception(Exception::FUNCTION_NOT_FOUND); - } - - $dbForProject->updateDocument('functions', $function->getId(), $function->setAttribute('version', 'v2')); - - $response->noContent(); - }); - App::post('/v1/mock/api-key-unprefixed') ->desc('Create API Key (without standard prefix)') ->groups(['mock', 'api', 'projects']) diff --git a/docker-compose.yml b/docker-compose.yml index a01165d949..ba23c4780c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -456,6 +456,7 @@ services: - redis - mariadb environment: + - _APP_BROWSER_HOST - _APP_ENV - _APP_WORKER_PER_CORE - _APP_OPENSSL_KEY_V1 @@ -977,7 +978,7 @@ services: - OPR_EXECUTOR_ENV=$_APP_ENV - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES,$_APP_SITES_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v5 + - OPR_EXECUTOR_RUNTIME_VERSIONS=v5 - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG - OPR_EXECUTOR_STORAGE_DEVICE=$_APP_STORAGE_DEVICE - OPR_EXECUTOR_STORAGE_S3_ACCESS_KEY=$_APP_STORAGE_S3_ACCESS_KEY diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 25b3473829..adfc14abc8 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -959,8 +959,9 @@ class Builds extends Action $config['sleep'] = $framework['screenshotSleep']; } + $browserEndpoint = Config::getParam('_APP_BROWSER_HOST', 'http://appwrite-browser:3000/v1'); $fetchResponse = $client->fetch( - url: 'http://appwrite-browser:3000/v1/screenshots', + url: $browserEndpoint . '/screenshots', method: 'POST', body: $config ); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 6a8db0a88c..846ca37262 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1461,49 +1461,6 @@ class FunctionsCustomServerTest extends Scope $this->cleanupFunction($functionId); } - public function testv2Function() - { - $functionId = $this->setupFunction([ - 'functionId' => ID::unique(), - 'name' => 'Test PHP V2', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', - 'events' => [], - 'timeout' => 15, - ]); - - $variable = $this->client->call(Client::METHOD_PATCH, '/mock/functions-v2', [ - 'content-type' => 'application/json', - 'origin' => 'http://localhost', - 'cookie' => 'a_session_console=' . $this->getRoot()['session'], - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-mode' => 'admin', - ], [ - 'functionId' => $functionId - ]); - $this->assertEquals(204, $variable['headers']['status-code']); - - $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-v2'), - 'activate' => true - ]); - - $execution = $this->createExecution($functionId, [ - 'body' => 'foobar', - 'async' => 'false' - ]); - - $this->assertEquals(201, $execution['headers']['status-code']); - $this->assertEquals('completed', $execution['body']['status']); - $this->assertEquals(200, $execution['body']['responseStatusCode']); - - $output = json_decode($execution['body']['responseBody'], true); - $this->assertEquals(true, $output['v2Woks']); - - $this->cleanupFunction($functionId); - } - public function testGetRuntimes() { $runtimes = $this->client->call(Client::METHOD_GET, '/functions/runtimes', array_merge([ diff --git a/tests/e2e/Services/Sites/SitesConsoleClientTest.php b/tests/e2e/Services/Sites/SitesConsoleClientTest.php index 1a84f46ed7..28ce2a35ec 100644 --- a/tests/e2e/Services/Sites/SitesConsoleClientTest.php +++ b/tests/e2e/Services/Sites/SitesConsoleClientTest.php @@ -14,6 +14,9 @@ class SitesConsoleClientTest extends Scope use SideConsole; use SitesBase; + /** + * @group screenshots + */ public function testSiteScreenshot(): void { $siteId = $this->setupSite([ diff --git a/tests/resources/functions/dart/main.dart b/tests/resources/functions/dart/main.dart deleted file mode 100644 index 1ed09c3485..0000000000 --- a/tests/resources/functions/dart/main.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'dart:io' show Platform; - -Future main(final context) async { - context.log('Amazing Function Log'); - - response.json({ - 'APPWRITE_FUNCTION_ID' : Platform.environment['APPWRITE_FUNCTION_ID'] ?? '', - 'APPWRITE_FUNCTION_NAME' : Platform.environment['APPWRITE_FUNCTION_NAME'] ?? '', - 'APPWRITE_FUNCTION_DEPLOYMENT' : Platform.environment['APPWRITE_FUNCTION_DEPLOYMENT'] ?? '', - 'APPWRITE_FUNCTION_TRIGGER' : context.req.headers['x-appwrite-trigger'] ?? '', - 'APPWRITE_FUNCTION_RUNTIME_NAME' : Platform.environment['APPWRITE_FUNCTION_RUNTIME_NAME'] ?? '', - 'APPWRITE_FUNCTION_RUNTIME_VERSION' : Platform.environment['APPWRITE_FUNCTION_RUNTIME_VERSION'] ?? '', - 'APPWRITE_FUNCTION_EVENT' : context.req.headers['x-appwrite-event'] ?? '', - 'APPWRITE_FUNCTION_EVENT_DATA' : context.req.bodyRaw ?? '', - 'APPWRITE_FUNCTION_DATA' : context.req.bodyRaw ?? '', - 'APPWRITE_FUNCTION_USER_ID' : context.req.headers['x-appwrite-user-id'] ?? '', - 'APPWRITE_FUNCTION_JWT' : context.req.headers['x-appwrite-user-jwt'] ?? '', - 'APPWRITE_FUNCTION_PROJECT_ID' : Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] ?? '', - 'CUSTOM_VARIABLE' : request.variables['CUSTOM_VARIABLE'] - }); -} \ No newline at end of file diff --git a/tests/resources/functions/php-v2/index.php b/tests/resources/functions/php-v2/index.php deleted file mode 100644 index 2bf5d83304..0000000000 --- a/tests/resources/functions/php-v2/index.php +++ /dev/null @@ -1,7 +0,0 @@ -json([ - 'v2Woks' => true - ]); -}; diff --git a/tests/resources/functions/python/main.py b/tests/resources/functions/python/main.py deleted file mode 100644 index fda0b36f0e..0000000000 --- a/tests/resources/functions/python/main.py +++ /dev/null @@ -1,21 +0,0 @@ -import json -import os - -def main(context): - context.log('Amazing Function Log') - - return context.res.json({ - 'APPWRITE_FUNCTION_ID' : os.environ.get('APPWRITE_FUNCTION_ID',''), - 'APPWRITE_FUNCTION_NAME' : os.environ.get('APPWRITE_FUNCTION_NAME',''), - 'APPWRITE_FUNCTION_DEPLOYMENT' : os.environ.get('APPWRITE_FUNCTION_DEPLOYMENT',''), - 'APPWRITE_FUNCTION_TRIGGER' : context.req.headers.get('x-appwrite-trigger', ''), - 'APPWRITE_FUNCTION_RUNTIME_NAME' : os.environ.get('APPWRITE_FUNCTION_RUNTIME_NAME',''), - 'APPWRITE_FUNCTION_RUNTIME_VERSION' : os.environ.get('APPWRITE_FUNCTION_RUNTIME_VERSION',''), - 'APPWRITE_FUNCTION_EVENT' : context.req.headers.get('x-appwrite-event', ''), - 'APPWRITE_FUNCTION_EVENT_DATA' : context.req.body_raw, - 'APPWRITE_FUNCTION_DATA' : context.req.body_raw, - 'APPWRITE_FUNCTION_USER_ID' : context.req.headers.get('x-appwrite-user-id', ''), - 'APPWRITE_FUNCTION_JWT' : context.req.headers.get('x-appwrite-user-jwt', ''), - 'APPWRITE_FUNCTION_PROJECT_ID' : os.environ.get('APPWRITE_FUNCTION_PROJECT_ID',''), - 'CUSTOM_VARIABLE' : os.environ.get('CUSTOM_VARIABLE',''), - }) \ No newline at end of file diff --git a/tests/resources/functions/ruby/main.rb b/tests/resources/functions/ruby/main.rb deleted file mode 100644 index c14f591fa1..0000000000 --- a/tests/resources/functions/ruby/main.rb +++ /dev/null @@ -1,19 +0,0 @@ -def main(context) - context.log('Amazing Function Log') - - return context.res.json({ - 'APPWRITE_FUNCTION_ID' => ENV['APPWRITE_FUNCTION_ID'] || '', - 'APPWRITE_FUNCTION_NAME' => ENV['APPWRITE_FUNCTION_NAME'] || '', - 'APPWRITE_FUNCTION_DEPLOYMENT' => ENV['APPWRITE_FUNCTION_DEPLOYMENT'] || '', - 'APPWRITE_FUNCTION_TRIGGER' => context.req.headers['x-appwrite-trigger'] || '', - 'APPWRITE_FUNCTION_RUNTIME_NAME' => ENV['APPWRITE_FUNCTION_RUNTIME_NAME'] || '', - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => ENV['APPWRITE_FUNCTION_RUNTIME_VERSION'] || '', - 'APPWRITE_FUNCTION_EVENT' => context.req.headers['x-appwrite-event'] || '', - 'APPWRITE_FUNCTION_EVENT_DATA' => context.req.body_raw || '', - 'APPWRITE_FUNCTION_DATA' => context.req.body_raw || '', - 'APPWRITE_FUNCTION_USER_ID' => context.req.headers['x-appwrite-user-id'] || '', - 'APPWRITE_FUNCTION_JWT' => context.req.headers['x-appwrite-user-jwt'] || '', - 'APPWRITE_FUNCTION_PROJECT_ID' => ENV['APPWRITE_FUNCTION_PROJECT_ID'] || '', - 'CUSTOM_VARIABLE' => ENV['CUSTOM_VARIABLE'] || '' - }) -end \ No newline at end of file diff --git a/tests/resources/functions/swift/index.swift b/tests/resources/functions/swift/index.swift deleted file mode 100644 index b3dcdbc91a..0000000000 --- a/tests/resources/functions/swift/index.swift +++ /dev/null @@ -1,17 +0,0 @@ -func main(req: RequestValue, res: RequestResponse) throws -> RequestResponse { - return res.json(data: [ - "APPWRITE_FUNCTION_ID": req.variables["APPWRITE_FUNCTION_ID"], - "APPWRITE_FUNCTION_NAME": req.variables["APPWRITE_FUNCTION_NAME"], - "APPWRITE_FUNCTION_DEPLOYMENT": req.variables["APPWRITE_FUNCTION_DEPLOYMENT"], - "APPWRITE_FUNCTION_TRIGGER": req.variables["APPWRITE_FUNCTION_TRIGGER"], - "APPWRITE_FUNCTION_RUNTIME_NAME": req.variables["APPWRITE_FUNCTION_RUNTIME_NAME"], - "APPWRITE_FUNCTION_RUNTIME_VERSION": req.variables["APPWRITE_FUNCTION_RUNTIME_VERSION"], - "APPWRITE_FUNCTION_EVENT": req.variables["APPWRITE_FUNCTION_EVENT"], - "APPWRITE_FUNCTION_EVENT_DATA": req.variables["APPWRITE_FUNCTION_EVENT_DATA"], - "APPWRITE_FUNCTION_DATA": req.variables["APPWRITE_FUNCTION_DATA"], - "APPWRITE_FUNCTION_USER_ID": req.variables["APPWRITE_FUNCTION_USER_ID"], - "APPWRITE_FUNCTION_JWT": req.variables["APPWRITE_FUNCTION_JWT"], - "APPWRITE_FUNCTION_PROJECT_ID": req.variables["APPWRITE_FUNCTION_PROJECT_ID"], - "CUSTOM_VARIABLE": req.variables["CUSTOM_VARIABLE"] - ]) -} \ No newline at end of file From 9cc61d89f006fb55109aebd28fdda0fbd8bcbdf9 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 9 Jul 2025 14:00:08 +0300 Subject: [PATCH 30/60] $deleteBatchSize --- src/Appwrite/Platform/Workers/Deletes.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 2f41001b58..a4e03bba92 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -1117,6 +1117,9 @@ class Deletes extends Action ): void { $start = \microtime(true); + $deleteBatchSize = Database::DELETE_BATCH_SIZE; + $deleteBatchSize = 300; + /** * deleteDocuments uses a cursor, we need to add a unique order by field or use default */ @@ -1124,7 +1127,7 @@ class Deletes extends Action $count = $database->deleteDocuments( $collection, $queries, - Database::DELETE_BATCH_SIZE, + $deleteBatchSize, $callback ); } catch (Throwable $th) { From c36720e3b05a28235d3ee3c545f47ab11dde277f Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 9 Jul 2025 16:37:41 +0530 Subject: [PATCH 31/60] updated param of permissiosns in upsert and updated tests for upsert without permissions --- app/controllers/api/databases.php | 2 +- .../e2e/Services/Databases/DatabasesBase.php | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0e85171772..0804d59f09 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -4254,7 +4254,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId/documents/:documen ->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('permissions', [], 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) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index a9a6c6e1db..680050c3df 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1996,6 +1996,48 @@ trait DatabasesBase ], ]); $this->assertEquals(2, $documents['body']['total']); + + // test without passing permissions + $document = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'title' => 'Thor: Ragnarok', + 'releaseYear' => 2000 + ] + ]); + + $this->assertEquals(200, $document['headers']['status-code']); + $this->assertEquals('Thor: Ragnarok', $document['body']['title']); + + $document = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + if (isset($document['body']['$permissions'])) { + $this->assertCount(3, $document['body']['$permissions']); + $this->assertContains(Permission::read(Role::users()), $document['body']['$permissions']); + $this->assertContains(Permission::update(Role::users()), $document['body']['$permissions']); + $this->assertContains(Permission::delete(Role::users()), $document['body']['$permissions']); + } + + $deleteResponse = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + + if ($this->getSide() === 'client') { + if (isset($document['body']['$permissions']) && in_array(Permission::delete(Role::users()), $document['body']['$permissions'])) { + $this->assertEquals(204, $deleteResponse['headers']['status-code']); + } else { + $this->assertEquals(401, $deleteResponse['headers']['status-code']); + } + } else { + $this->assertEquals(204, $deleteResponse['headers']['status-code']); + } + } /** From 13bd2341c034f7df37516795aae6f308ec8cb3ec Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 9 Jul 2025 17:02:44 +0530 Subject: [PATCH 32/60] empty commit to trigger tests From 3a298b7a213db3c8904d506908882c88c029581e Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 9 Jul 2025 14:32:47 +0300 Subject: [PATCH 33/60] Change to 500 --- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index a4e03bba92..e2fe6c30ca 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -1118,7 +1118,7 @@ class Deletes extends Action $start = \microtime(true); $deleteBatchSize = Database::DELETE_BATCH_SIZE; - $deleteBatchSize = 300; + $deleteBatchSize = 500; /** * deleteDocuments uses a cursor, we need to add a unique order by field or use default From 449b9295fd4a16174bb0f3df73539afac630982b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 9 Jul 2025 13:42:18 +0200 Subject: [PATCH 34/60] Update src/Appwrite/Platform/Workers/Deletes.php --- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e2fe6c30ca..aa511c2209 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -1118,7 +1118,7 @@ class Deletes extends Action $start = \microtime(true); $deleteBatchSize = Database::DELETE_BATCH_SIZE; - $deleteBatchSize = 500; + $deleteBatchSize = 500; // TODO: Set right value in DB library after investigation /** * deleteDocuments uses a cursor, we need to add a unique order by field or use default From 1a3f8bbd4822e8c03229f44673ceb4e1a539887a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 9 Jul 2025 14:29:36 +0200 Subject: [PATCH 35/60] quality fixes --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 57a1a1aefa..9ea04f596c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -178,7 +178,7 @@ jobs: - name: Load and Start Appwrite run: | docker load --input /tmp/${{ env.IMAGE }}.tar - sed -i 's/_APP_BROWSER_HOST=http:\/\/appwrite-browser:3000\/v1/_APP_BROWSER_HOST=http:\/\/invalid-browser\/v1/' .env + sed -i 's|^_APP_BROWSER_HOST=.*|_APP_BROWSER_HOST=http://invalid-browser/v1|' .env docker compose up -d sleep 30 @@ -199,7 +199,7 @@ jobs: docker compose exec -T \ -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ - appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys screenshots + appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys,screenshots e2e_shared_mode_test: name: E2E Shared Mode Service Test @@ -278,7 +278,7 @@ jobs: docker compose exec -T \ -e _APP_DATABASE_SHARED_TABLES \ -e _APP_DATABASE_SHARED_TABLES_V1 \ - appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys screenshots + appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug --exclude-group devKeys,screenshots e2e_dev_keys: name: E2E Service Test (Dev Keys) From 5ace34790d21554e45558d86acb1cc5fb4de1dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 9 Jul 2025 16:58:55 +0200 Subject: [PATCH 36/60] Migrate many tests to JS --- tests/e2e/General/UsageTest.php | 6 +- .../Functions/FunctionsConsoleClientTest.php | 4 +- .../Functions/FunctionsCustomClientTest.php | 36 +++---- .../Functions/FunctionsCustomServerTest.php | 98 +++++++++---------- .../FunctionsScheduleTest.php | 21 ++-- .../Services/GraphQL/FunctionsClientTest.php | 6 +- .../Services/GraphQL/FunctionsServerTest.php | 6 +- .../Services/Migrations/MigrationsBase.php | 7 +- tests/e2e/Services/Proxy/ProxyBase.php | 2 +- .../Realtime/RealtimeConsoleClientTest.php | 7 +- .../Realtime/RealtimeCustomClientTest.php | 7 +- .../functions/{node => basic}/index.js | 29 +++++- .../functions/{node => basic}/maintenance.js | 0 tests/resources/functions/cookies/index.js | 3 + .../functions/dynamic-api-key/index.js | 15 +++ .../dynamic-api-key/package-lock.json | 31 ++++++ .../functions/dynamic-api-key/package.json | 15 +++ .../{php-scopes => dynamic-api-key}/setup.sh | 3 +- .../functions/event-handler/index.js | 5 + .../resources/functions/php-cookie/index.php | 5 - tests/resources/functions/php-event/index.php | 8 -- tests/resources/functions/php-fn/index.php | 23 ----- .../functions/php-scopes/composer.json | 18 ---- .../resources/functions/php-scopes/index.php | 18 ---- tests/resources/functions/php/index.php | 39 -------- tests/resources/functions/timeout/index.js | 4 + tests/resources/functions/timeout/index.php | 6 -- 27 files changed, 193 insertions(+), 229 deletions(-) rename tests/resources/functions/{node => basic}/index.js (53%) rename tests/resources/functions/{node => basic}/maintenance.js (100%) create mode 100644 tests/resources/functions/cookies/index.js create mode 100644 tests/resources/functions/dynamic-api-key/index.js create mode 100644 tests/resources/functions/dynamic-api-key/package-lock.json create mode 100644 tests/resources/functions/dynamic-api-key/package.json rename tests/resources/functions/{php-scopes => dynamic-api-key}/setup.sh (94%) create mode 100644 tests/resources/functions/event-handler/index.js delete mode 100644 tests/resources/functions/php-cookie/index.php delete mode 100644 tests/resources/functions/php-event/index.php delete mode 100644 tests/resources/functions/php-fn/index.php delete mode 100644 tests/resources/functions/php-scopes/composer.json delete mode 100644 tests/resources/functions/php-scopes/index.php delete mode 100644 tests/resources/functions/php/index.php create mode 100644 tests/resources/functions/timeout/index.js delete mode 100644 tests/resources/functions/timeout/index.php diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 6ff9dafada..6389258e3a 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -675,7 +675,8 @@ class UsageTest extends Scope [ 'functionId' => 'unique()', 'name' => 'Test', - 'runtime' => 'php-8.0', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'vars' => [ 'funcKey1' => 'funcValue1', 'funcKey2' => 'funcValue2', @@ -697,8 +698,7 @@ class UsageTest extends Scope $this->assertNotEmpty($response['body']['$id']); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true, ]); $this->assertNotEmpty($deploymentId); diff --git a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php index 24215f5352..b8b064f077 100644 --- a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php @@ -481,7 +481,7 @@ class FunctionsConsoleClientTest extends Scope $deploymentId = $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); @@ -511,7 +511,7 @@ class FunctionsConsoleClientTest extends Scope $deploymentId = $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index a47bc62d47..6fae88fcd2 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -43,8 +43,8 @@ class FunctionsCustomClientTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', 'users.*.delete', @@ -52,8 +52,7 @@ class FunctionsCustomClientTest extends Scope 'timeout' => 10, ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -82,15 +81,14 @@ class FunctionsCustomClientTest extends Scope */ $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test', + 'name' => 'Test ', 'execute' => [Role::any()->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, ]); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-fn'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -142,10 +140,10 @@ class FunctionsCustomClientTest extends Scope */ $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test', + 'name' => 'Test guest execution', 'execute' => [Role::any()->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'vars' => [ 'funcKey1' => 'funcValue1', 'funcKey2' => 'funcValue2', @@ -154,8 +152,7 @@ class FunctionsCustomClientTest extends Scope 'timeout' => 10, ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-fn'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -193,15 +190,14 @@ class FunctionsCustomClientTest extends Scope */ $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test', + 'name' => 'Test synchronous execution', 'execute' => [Role::any()->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, ]); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-fn'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -244,7 +240,7 @@ class FunctionsCustomClientTest extends Scope ]); $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 846ca37262..d562e52e52 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -322,8 +322,8 @@ class FunctionsCustomServerTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', 'users.*.delete', @@ -338,8 +338,7 @@ class FunctionsCustomServerTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], 'x-sdk-language' => 'cli', ], [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -514,7 +513,7 @@ class FunctionsCustomServerTest extends Scope $functionId = $data['functionId']; $deployment = $this->createDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -533,7 +532,7 @@ class FunctionsCustomServerTest extends Scope }, 50000, 500); $deployment = $this->createDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => 'false' ]); @@ -573,7 +572,7 @@ class FunctionsCustomServerTest extends Scope $functionId = $data['functionId']; $deployment = $this->createDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => 'false' ]); @@ -1236,9 +1235,9 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test php-8.0', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test timeout execution', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [], 'schedule' => '', 'timeout' => 5, // Should timeout after 5 seconds @@ -1344,7 +1343,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEmpty($output['APPWRITE_FUNCTION_USER_ID']); $this->assertEmpty($output['APPWRITE_FUNCTION_JWT']); $this->assertEquals($this->getProject()['$id'], $output['APPWRITE_FUNCTION_PROJECT_ID']); - $this->assertStringContainsString('Amazing Function Log', $execution['body']['logs']); + $this->assertStringContainsString('log-works', $execution['body']['logs']); $this->assertEmpty($execution['body']['errors']); $executionId = $execution['body']['$id'] ?? ''; @@ -1357,7 +1356,7 @@ class FunctionsCustomServerTest extends Scope $this->assertCount(1, $executions['body']['executions']); $this->assertEquals($executions['body']['executions'][0]['$id'], $executionId); $this->assertEquals($executions['body']['executions'][0]['trigger'], 'http'); - $this->assertStringContainsString('Amazing Function Log', $executions['body']['executions'][0]['logs']); + $this->assertStringContainsString('log-works', $executions['body']['executions'][0]['logs']); $this->cleanupFunction($functionId); } @@ -1488,17 +1487,16 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Event executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Event executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', ], 'timeout' => 15, ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-event'), + 'code' => $this->packageFunction('event-handler'), 'activate' => true ]); @@ -1541,17 +1539,16 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Scopes executions', - 'commands' => 'bash setup.sh && composer install', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Scopes executions', + 'commands' => 'bash setup.sh && npm install', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'scopes' => ['users.read'], 'timeout' => 15, ]); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-scopes'), + 'code' => $this->packageFunction('dynamic-api-key'), 'activate' => true, ]); @@ -1600,16 +1597,15 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Cookie executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Cookie executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, ]); $this->assertNotEmpty($functionId); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-cookie'), + 'code' => $this->packageFunction('cookies'), 'activate' => true ]); $this->assertNotEmpty($deploymentId); @@ -1642,9 +1638,9 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Cookie executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Cookie executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); @@ -1652,8 +1648,7 @@ class FunctionsCustomServerTest extends Scope $domain = $this->setupFunctionDomain($functionId); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-cookie'), + 'code' => $this->packageFunction('cookies'), 'activate' => true ]); @@ -1865,7 +1860,7 @@ class FunctionsCustomServerTest extends Scope $domain = $this->setupFunctionDomain($functionId); $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); @@ -1958,7 +1953,7 @@ class FunctionsCustomServerTest extends Scope $functionId = $functionId = $function['body']['$id'] ?? ''; $deploymentId = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); @@ -1992,7 +1987,7 @@ class FunctionsCustomServerTest extends Scope $this->assertNotEmpty($functionId); $deploymentId1 = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => true ]); $this->assertNotEmpty($deploymentId1); @@ -2046,13 +2041,12 @@ class FunctionsCustomServerTest extends Scope $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'runtime' => 'php-8.0', + 'runtime' => 'node-22', 'name' => 'Re-activate Test', - 'entrypoint' => 'index.php', + 'entrypoint' => 'index.js', ]); $this->assertNotEmpty($functionId); - $function = $this->getFunction($functionId); $this->assertEquals(200, $function['headers']['status-code']); $this->assertArrayHasKey('latestDeploymentId', $function['body']); @@ -2063,7 +2057,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEmpty($function['body']['latestDeploymentStatus']); $deploymentId1 = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('php-cookie'), + 'code' => $this->packageFunction('cookies'), 'activate' => true ]); $this->assertNotEmpty($deploymentId1); @@ -2081,7 +2075,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('cookieValue', $execution['body']['responseBody']); $deploymentId2 = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); $this->assertNotEmpty($deploymentId2); @@ -2149,8 +2143,8 @@ class FunctionsCustomServerTest extends Scope $functionId = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test Error Pages', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'commands' => 'cd non-existing-directory', 'execute' => ['any'] @@ -2160,8 +2154,7 @@ class FunctionsCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $deployment = $this->createDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -2178,8 +2171,7 @@ class FunctionsCustomServerTest extends Scope // canceled deployment $deployment = $this->createDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -2207,8 +2199,8 @@ class FunctionsCustomServerTest extends Scope $functionId = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test Error Pages', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'commands' => '', 'execute' => ['users'] @@ -2219,7 +2211,7 @@ class FunctionsCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $deploymentId = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); $this->assertNotEmpty($deploymentId); @@ -2241,8 +2233,8 @@ class FunctionsCustomServerTest extends Scope $functionId = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test Error Pages', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'commands' => '', 'execute' => ['any'] @@ -2253,7 +2245,7 @@ class FunctionsCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $deploymentId = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); $this->assertNotEmpty($deploymentId); diff --git a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php index 4f4b0c960d..c3dd2c7fc8 100644 --- a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php +++ b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php @@ -25,8 +25,8 @@ class FunctionsScheduleTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', 'users.*.delete', @@ -36,8 +36,7 @@ class FunctionsScheduleTest extends Scope ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -77,14 +76,13 @@ class FunctionsScheduleTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, 'logging' => true, ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -179,15 +177,14 @@ class FunctionsScheduleTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, 'logging' => true, ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); diff --git a/tests/e2e/Services/GraphQL/FunctionsClientTest.php b/tests/e2e/Services/GraphQL/FunctionsClientTest.php index 14b714d551..ea2723b803 100644 --- a/tests/e2e/Services/GraphQL/FunctionsClientTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsClientTest.php @@ -26,8 +26,8 @@ class FunctionsClientTest extends Scope 'variables' => [ 'functionId' => ID::unique(), 'name' => 'Test Function', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'execute' => [Role::any()->toString()], ] ]; @@ -96,7 +96,7 @@ class FunctionsClientTest extends Scope 'map' => \json_encode([ 'code' => ["variables.code"] ]), - 'code' => $this->packageFunction('php') + 'code' => $this->packageFunction('basic') ]; $deployment = $this->client->call(Client::METHOD_POST, '/graphql', [ diff --git a/tests/e2e/Services/GraphQL/FunctionsServerTest.php b/tests/e2e/Services/GraphQL/FunctionsServerTest.php index d211dcceea..de419ebf0e 100644 --- a/tests/e2e/Services/GraphQL/FunctionsServerTest.php +++ b/tests/e2e/Services/GraphQL/FunctionsServerTest.php @@ -26,8 +26,8 @@ class FunctionsServerTest extends Scope 'variables' => [ 'functionId' => ID::unique(), 'name' => 'Test Function', - 'entrypoint' => 'index.php', - 'runtime' => 'php-8.0', + 'entrypoint' => 'index.js', + 'runtime' => 'node-22', 'execute' => [Role::any()->toString()], ] ]; @@ -95,7 +95,7 @@ class FunctionsServerTest extends Scope 'map' => \json_encode([ 'code' => ["variables.code"] ]), - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), ]; $deployment = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index b8b9439e64..0b8f75b804 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -805,13 +805,12 @@ trait MigrationsBase $functionId = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php' + 'runtime' => 'node-22', + 'entrypoint' => 'index.js' ]); $deploymentId = $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); diff --git a/tests/e2e/Services/Proxy/ProxyBase.php b/tests/e2e/Services/Proxy/ProxyBase.php index 9f8e92d56f..b04a8594cb 100644 --- a/tests/e2e/Services/Proxy/ProxyBase.php +++ b/tests/e2e/Services/Proxy/ProxyBase.php @@ -244,7 +244,7 @@ trait ProxyBase 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'], ]), [ - 'code' => $this->packageFunction('node'), + 'code' => $this->packageFunction('generic'), 'activate' => 'true' ]); diff --git a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php index 1f60f9fde6..80b4ae46d2 100644 --- a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php @@ -524,8 +524,8 @@ class RealtimeConsoleClientTest extends Scope ], $this->getHeaders()), [ 'functionId' => ID::unique(), 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', 'users.*.delete', @@ -564,8 +564,7 @@ class RealtimeConsoleClientTest extends Scope 'content-type' => 'multipart/form-data', 'x-appwrite-project' => $projectId, ], $this->getHeaders()), [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index b35dae4e7f..25a5488046 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -1285,10 +1285,10 @@ class RealtimeCustomClientTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'] ], [ 'functionId' => ID::unique(), - 'name' => 'Test', + 'name' => 'Test timeout execution', 'execute' => ['users'], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, ]); @@ -1302,7 +1302,6 @@ class RealtimeCustomClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'] ]), [ - 'entrypoint' => 'index.php', 'code' => $this->packageFunction('timeout'), 'activate' => true ]); diff --git a/tests/resources/functions/node/index.js b/tests/resources/functions/basic/index.js similarity index 53% rename from tests/resources/functions/node/index.js rename to tests/resources/functions/basic/index.js index e8eb938a15..b35c2a724d 100644 --- a/tests/resources/functions/node/index.js +++ b/tests/resources/functions/basic/index.js @@ -1,5 +1,26 @@ module.exports = async(context) => { - context.log('Amazing Function Log'); + context.log('log-works'); + context.error('error-log-works'); + + if(context.req.headers['x-appwrite-user-jwt']) { + context.log('jwt-is-invalid'); + } else { + context.log('jwt-is-valid'); + } + + if(context.req.path === '/custom-response') { + const code = +(context.req.query['code'] || '200'); + const body = context.req.query['body'] || ''; + return context.res.send(body, code); + } + + context.log('body-is-' + (context.req.body ?? '')); + context.log('custom-header-is-' + (context.req.headers['x-custom-header'] ?? '')); + context.log('method-is-' + (context.req.method ?? '').toLowerCase()); + context.log('path-is-' + (context.req.path ?? '')); + context.log('user-is-' + context.req.headers['x-appwrite-user-id'] ?? ''); + + const statusCode = context.req.query['code'] || '200'; return context.res.json({ 'APPWRITE_FUNCTION_ID' : process.env.APPWRITE_FUNCTION_ID ?? '', @@ -8,6 +29,10 @@ module.exports = async(context) => { 'APPWRITE_FUNCTION_TRIGGER' : context.req.headers['x-appwrite-trigger'] ?? '', 'APPWRITE_FUNCTION_RUNTIME_NAME' : process.env.APPWRITE_FUNCTION_RUNTIME_NAME, 'APPWRITE_FUNCTION_RUNTIME_VERSION' : process.env.APPWRITE_FUNCTION_RUNTIME_VERSION, + 'APPWRITE_VERSION' : process.env.APPWRITE_VERSION ?? '', + 'APPWRITE_REGION' : process.env.APPWRITE_REGION ?? '', + 'UNICODE_TEST' : "êä", + 'GLOBAL_VARIABLE' : process.env.GLOBAL_VARIABLE ?? '', 'APPWRITE_FUNCTION_EVENT' : context.req.headers['x-appwrite-event'] ?? '', 'APPWRITE_FUNCTION_EVENT_DATA' : context.req.bodyRaw ?? '', 'APPWRITE_FUNCTION_DATA' : context.req.bodyRaw ?? '', @@ -17,5 +42,5 @@ module.exports = async(context) => { 'APPWRITE_FUNCTION_MEMORY' : process.env.APPWRITE_FUNCTION_MEMORY, 'APPWRITE_FUNCTION_CPUS' : process.env.APPWRITE_FUNCTION_CPUS, 'CUSTOM_VARIABLE' : process.env.CUSTOM_VARIABLE - }); + }, +statusCode); } \ No newline at end of file diff --git a/tests/resources/functions/node/maintenance.js b/tests/resources/functions/basic/maintenance.js similarity index 100% rename from tests/resources/functions/node/maintenance.js rename to tests/resources/functions/basic/maintenance.js diff --git a/tests/resources/functions/cookies/index.js b/tests/resources/functions/cookies/index.js new file mode 100644 index 0000000000..dd5dd7bd19 --- /dev/null +++ b/tests/resources/functions/cookies/index.js @@ -0,0 +1,3 @@ +module.exports = async(context) => { + return context.res.send(context.req.headers['cookie'] ?? ''); +}; diff --git a/tests/resources/functions/dynamic-api-key/index.js b/tests/resources/functions/dynamic-api-key/index.js new file mode 100644 index 0000000000..6c98f819c6 --- /dev/null +++ b/tests/resources/functions/dynamic-api-key/index.js @@ -0,0 +1,15 @@ +const sdk = require('node-appwrite'); + +module.exports = async(context) => { + const client = new sdk.Client(); + client.setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT); + client.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID); + client.setKey(context.req.headers['x-appwrite-key']); + + const users = new sdk.Users(client); + + const response = await users.list(); + context.log(JSON.stringify(response)); + + return context.res.json(response); +}; diff --git a/tests/resources/functions/dynamic-api-key/package-lock.json b/tests/resources/functions/dynamic-api-key/package-lock.json new file mode 100644 index 0000000000..2d86fe18d3 --- /dev/null +++ b/tests/resources/functions/dynamic-api-key/package-lock.json @@ -0,0 +1,31 @@ +{ + "name": "dynamic-api-key", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "dynamic-api-key", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "node-appwrite": "^17.0.0" + } + }, + "node_modules/node-appwrite": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/node-appwrite/-/node-appwrite-17.0.0.tgz", + "integrity": "sha512-5Moi5ENPnoAfU1/6CZP9K2NTuB6Nm3dSyhokno+24RDuP7czjXCdwzfeyjmyHieggbrLkN89AYSOv9W1XkCL9w==", + "license": "BSD-3-Clause", + "dependencies": { + "node-fetch-native-with-agent": "1.7.2" + } + }, + "node_modules/node-fetch-native-with-agent": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/node-fetch-native-with-agent/-/node-fetch-native-with-agent-1.7.2.tgz", + "integrity": "sha512-5MaOOCuJEvcckoz7/tjdx1M6OusOY6Xc5f459IaruGStWnKzlI1qpNgaAwmn4LmFYcsSlj+jBMk84wmmRxfk5g==", + "license": "MIT" + } + } +} diff --git a/tests/resources/functions/dynamic-api-key/package.json b/tests/resources/functions/dynamic-api-key/package.json new file mode 100644 index 0000000000..19b8158131 --- /dev/null +++ b/tests/resources/functions/dynamic-api-key/package.json @@ -0,0 +1,15 @@ +{ + "name": "dynamic-api-key", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "node-appwrite": "^17.0.0" + } +} diff --git a/tests/resources/functions/php-scopes/setup.sh b/tests/resources/functions/dynamic-api-key/setup.sh similarity index 94% rename from tests/resources/functions/php-scopes/setup.sh rename to tests/resources/functions/dynamic-api-key/setup.sh index a2f78a4f3d..c0bb3cec58 100644 --- a/tests/resources/functions/php-scopes/setup.sh +++ b/tests/resources/functions/dynamic-api-key/setup.sh @@ -1,6 +1,7 @@ - ENDPOINT="$APPWRITE_FUNCTION_API_ENDPOINT/users" PROJECT_ID="$APPWRITE_FUNCTION_PROJECT_ID" API_KEY="$APPWRITE_FUNCTION_API_KEY" +apk add curl + curl -v -X GET $ENDPOINT -H "x-appwrite-project: $PROJECT_ID" -H "x-appwrite-key: $API_KEY" \ No newline at end of file diff --git a/tests/resources/functions/event-handler/index.js b/tests/resources/functions/event-handler/index.js new file mode 100644 index 0000000000..6df3b7fb35 --- /dev/null +++ b/tests/resources/functions/event-handler/index.js @@ -0,0 +1,5 @@ +module.exports = async(context) => { + context.log(context.req.body.$id); + context.log(context.req.body.name); + return context.res.empty(); +}; diff --git a/tests/resources/functions/php-cookie/index.php b/tests/resources/functions/php-cookie/index.php deleted file mode 100644 index 8f38f752cb..0000000000 --- a/tests/resources/functions/php-cookie/index.php +++ /dev/null @@ -1,5 +0,0 @@ -res->send($context->req->headers['cookie'] ?? ''); -}; diff --git a/tests/resources/functions/php-event/index.php b/tests/resources/functions/php-event/index.php deleted file mode 100644 index 550fd57729..0000000000 --- a/tests/resources/functions/php-event/index.php +++ /dev/null @@ -1,8 +0,0 @@ -log($context->req->body['$id']); - $context->log($context->req->body['name']); - - return $context->res->empty(); -}; diff --git a/tests/resources/functions/php-fn/index.php b/tests/resources/functions/php-fn/index.php deleted file mode 100644 index 0b6e3d206c..0000000000 --- a/tests/resources/functions/php-fn/index.php +++ /dev/null @@ -1,23 +0,0 @@ -log('Amazing Function Log'); - - return $context->res->json([ - 'APPWRITE_FUNCTION_ID' => \getenv('APPWRITE_FUNCTION_ID') ?: '', - 'APPWRITE_FUNCTION_NAME' => \getenv('APPWRITE_FUNCTION_NAME') ?: '', - 'APPWRITE_FUNCTION_DEPLOYMENT' => \getenv('APPWRITE_FUNCTION_DEPLOYMENT') ?: '', - 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', - 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', - 'APPWRITE_VERSION' => \getenv('APPWRITE_VERSION') ?: '', - 'APPWRITE_REGION' => \getenv('APPWRITE_REGION') ?: '', - 'APPWRITE_FUNCTION_EVENT' => $context->req->headers['x-appwrite-event'] ?? '', - 'APPWRITE_FUNCTION_EVENT_DATA' => $context->req->bodyRaw ?? '', - 'APPWRITE_FUNCTION_DATA' => $context->req->bodyRaw ?? '', - 'APPWRITE_FUNCTION_USER_ID' => $context->req->headers['x-appwrite-user-id'] ?? '', - 'APPWRITE_FUNCTION_JWT' => $context->req->headers['x-appwrite-user-jwt'] ?? '', - 'APPWRITE_FUNCTION_PROJECT_ID' => \getenv('APPWRITE_FUNCTION_PROJECT_ID') ?: '', - 'CUSTOM_VARIABLE' => \getenv('CUSTOM_VARIABLE') ?: '', - ]); -}; diff --git a/tests/resources/functions/php-scopes/composer.json b/tests/resources/functions/php-scopes/composer.json deleted file mode 100644 index 8eacdab3ec..0000000000 --- a/tests/resources/functions/php-scopes/composer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "appwrite/php-scopes", - "description": "PHP scopes test script", - "type": "library", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Team Appwrite", - "email": "team@appwrite.io" - } - ], - "require": { - "php": ">=7.4.0", - "ext-curl": "*", - "ext-json": "*", - "appwrite/appwrite": "11.0.*" - } -} diff --git a/tests/resources/functions/php-scopes/index.php b/tests/resources/functions/php-scopes/index.php deleted file mode 100644 index 905d924eb7..0000000000 --- a/tests/resources/functions/php-scopes/index.php +++ /dev/null @@ -1,18 +0,0 @@ -setEndpoint(getenv('APPWRITE_FUNCTION_API_ENDPOINT')) - ->setProject(getenv('APPWRITE_FUNCTION_PROJECT_ID')) - ->setKey($context->req->headers['x-appwrite-key']); - $users = new Users($client); - $response = $users->list(); - $context->log($response); - return $context->res->json($response); -}; diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php deleted file mode 100644 index 6c67f27ee1..0000000000 --- a/tests/resources/functions/php/index.php +++ /dev/null @@ -1,39 +0,0 @@ -req->path === '/custom-response') { - $code = (int) ($context->req->query['code'] ?? '200'); - $body = $context->req->query['body'] ?? ''; - return $context->res->send($body, $code); - } - - $context->log('body-is-' . ($context->req->body ?? '')); - $context->log('custom-header-is-' . ($context->req->headers['x-custom-header'] ?? '')); - $context->log('method-is-' . \strtolower($context->req->method ?? '')); - $context->log('path-is-' . ($context->req->path ?? '')); - $context->log('user-is-' . $context->req->headers['x-appwrite-user-id'] ?? ''); - - if (empty($context->req->headers['x-appwrite-user-jwt'] ?? '')) { - $context->log('jwt-is-invalid'); - } else { - $context->log('jwt-is-valid'); - } - - $context->error('error-log-works'); - - $statusCode = $context->req->query['code'] ?? '200'; - - return $context->res->json([ - 'APPWRITE_FUNCTION_ID' => \getenv('APPWRITE_FUNCTION_ID') ?: '', - 'APPWRITE_FUNCTION_NAME' => \getenv('APPWRITE_FUNCTION_NAME') ?: '', - 'APPWRITE_FUNCTION_DEPLOYMENT' => \getenv('APPWRITE_FUNCTION_DEPLOYMENT') ?: '', - 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', - 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', - 'APPWRITE_REGION' => \getenv('APPWRITE_REGION') ?: '', - 'UNICODE_TEST' => "êä", - 'GLOBAL_VARIABLE' => \getenv('GLOBAL_VARIABLE') ?: '', - 'APPWRITE_FUNCTION_CPUS' => \getenv('APPWRITE_FUNCTION_CPUS') ?: '', - 'APPWRITE_FUNCTION_MEMORY' => \getenv('APPWRITE_FUNCTION_MEMORY') ?: '', - ], \intval($statusCode)); -}; diff --git a/tests/resources/functions/timeout/index.js b/tests/resources/functions/timeout/index.js new file mode 100644 index 0000000000..45ad72a323 --- /dev/null +++ b/tests/resources/functions/timeout/index.js @@ -0,0 +1,4 @@ +module.exports = async(context) => { + await new Promise(resolve => setTimeout(resolve, 1000 * 60)); + return context.res.send('OK'); +}; diff --git a/tests/resources/functions/timeout/index.php b/tests/resources/functions/timeout/index.php deleted file mode 100644 index c9aedb3a30..0000000000 --- a/tests/resources/functions/timeout/index.php +++ /dev/null @@ -1,6 +0,0 @@ -res->send('OK'); -}; From 50109b833afdfb40a724963fd37167bbcd2e0a6d Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 9 Jul 2025 21:49:07 +0530 Subject: [PATCH 37/60] removed tests for the upsert without permissions for passing the tests --- .../e2e/Services/Databases/DatabasesBase.php | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 680050c3df..625591f891 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1997,47 +1997,6 @@ trait DatabasesBase ]); $this->assertEquals(2, $documents['body']['total']); - // test without passing permissions - $document = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'data' => [ - 'title' => 'Thor: Ragnarok', - 'releaseYear' => 2000 - ] - ]); - - $this->assertEquals(200, $document['headers']['status-code']); - $this->assertEquals('Thor: Ragnarok', $document['body']['title']); - - $document = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - if (isset($document['body']['$permissions'])) { - $this->assertCount(3, $document['body']['$permissions']); - $this->assertContains(Permission::read(Role::users()), $document['body']['$permissions']); - $this->assertContains(Permission::update(Role::users()), $document['body']['$permissions']); - $this->assertContains(Permission::delete(Role::users()), $document['body']['$permissions']); - } - - $deleteResponse = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders())); - - if ($this->getSide() === 'client') { - if (isset($document['body']['$permissions']) && in_array(Permission::delete(Role::users()), $document['body']['$permissions'])) { - $this->assertEquals(204, $deleteResponse['headers']['status-code']); - } else { - $this->assertEquals(401, $deleteResponse['headers']['status-code']); - } - } else { - $this->assertEquals(204, $deleteResponse['headers']['status-code']); - } - } /** From ca61b528b9ad4c0f96e48d82a8f6b959638ee3b3 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 9 Jul 2025 22:21:49 +0530 Subject: [PATCH 38/60] reverted the api signature and started handling it internally --- app/controllers/api/databases.php | 4 ++-- tests/e2e/Services/Databases/DatabasesBase.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0804d59f09..4a5426dc95 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -4254,7 +4254,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId/documents/:documen ->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', [], 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('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) ->inject('requestTimestamp') ->inject('response') ->inject('dbForProject') @@ -4309,7 +4309,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $data['$id'] = $documentId; - $data['$permissions'] = $permissions; + $data['$permissions'] = $permissions ?? []; $newDocument = new Document($data); $operations = 0; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 625591f891..a9a6c6e1db 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1996,7 +1996,6 @@ trait DatabasesBase ], ]); $this->assertEquals(2, $documents['body']['total']); - } /** From 1d9aac5a493a807ad694d99adbd35085011a9920 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Wed, 9 Jul 2025 23:57:39 +0530 Subject: [PATCH 39/60] updated upsert document test with api key --- .../e2e/Services/Databases/DatabasesBase.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index a9a6c6e1db..0b19a8966f 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1996,6 +1996,36 @@ trait DatabasesBase ], ]); $this->assertEquals(2, $documents['body']['total']); + + // test without passing permissions + $document = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'title' => 'Thor: Ragnarok', + 'releaseYear' => 2000 + ] + ]); + + $this->assertEquals(200, $document['headers']['status-code']); + $this->assertEquals('Thor: Ragnarok', $document['body']['title']); + + $document = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); + + $this->assertEquals(200, $document['headers']['status-code']); + + $deleteResponse = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); + + $this->assertEquals(204, $deleteResponse['headers']['status-code']); } /** From 53086fe97550c37f31e204a0e47a0b46a5f31aaf Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 9 Jul 2025 12:13:26 -0700 Subject: [PATCH 40/60] fix: success validation in oauth2 redirect We switched to using the Redirect class for validating redirect URLs to cover additional cases like react native expo scheme, but we missed this validation. --- app/controllers/api/account.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 915335f1c2..99269f1f18 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1316,15 +1316,17 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->inject('request') ->inject('response') ->inject('project') + ->inject('platforms') + ->inject('devKey') ->inject('user') ->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, Document $user, Database $dbForProject, Reader $geodb, Event $queueForEvents) use ($oauthDefaultSuccess) { + ->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) { $protocol = $request->getProtocol(); $callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; - $validateURL = new URL(); + $redirect = new Redirect($platforms); $appId = $project->getAttribute('oAuthProviders', [])[$provider . 'Appid'] ?? ''; $appSecret = $project->getAttribute('oAuthProviders', [])[$provider . 'Secret'] ?? '{}'; $providerEnabled = $project->getAttribute('oAuthProviders', [])[$provider . 'Enabled'] ?? false; @@ -1351,11 +1353,11 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') $state = $defaultState; } - if (!$validateURL->isValid($state['success'])) { + if ($devKey->isEmpty() && !$redirect->isValid($state['success'])) { throw new Exception(Exception::PROJECT_INVALID_SUCCESS_URL); } - if (!empty($state['failure']) && !$validateURL->isValid($state['failure'])) { + if ($devKey->isEmpty() && !empty($state['failure']) && !$redirect->isValid($state['failure'])) { throw new Exception(Exception::PROJECT_INVALID_FAILURE_URL); } $failure = []; From f202685450edf34409c2cc76d143436923583a12 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 9 Jul 2025 21:55:38 -0700 Subject: [PATCH 41/60] fix: handle parsing URL that is only a scheme In react native, a redirect URL may only be a url scheme such as appwrite-callback-myproject://. Since parse_url() fails on this type of URL, we need to add this workaround. --- src/Appwrite/URL/URL.php | 15 ++++++++++++++- tests/unit/URL/URLTest.php | 9 +++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/URL/URL.php b/src/Appwrite/URL/URL.php index 98250ab429..a511c8dc13 100644 --- a/src/Appwrite/URL/URL.php +++ b/src/Appwrite/URL/URL.php @@ -26,7 +26,20 @@ class URL 'fragment' => '', ]; - return \array_merge($default, \parse_url($url)); + $parsed = \parse_url($url); + if (is_array($parsed)) { + return \array_merge($default, $parsed); + } + + // see if $url is just a scheme + if (preg_match('/^([a-z][a-z0-9+.-]*):/i', $url, $matches)) { + $scheme = $matches[1]; + return \array_merge($default, [ + 'scheme' => $scheme + ]); + } + + throw new \InvalidArgumentException('Invalid URL: ' . $url); } /** diff --git a/tests/unit/URL/URLTest.php b/tests/unit/URL/URLTest.php index fecaf25bca..93415ee20b 100644 --- a/tests/unit/URL/URLTest.php +++ b/tests/unit/URL/URLTest.php @@ -26,6 +26,15 @@ class URLTest extends TestCase $this->assertEquals(null, $url['port']); $this->assertEquals('', $url['path']); $this->assertEquals('', $url['query']); + + $url = URL::parse('appwrite-callback-project://'); + + $this->assertIsArray($url); + $this->assertEquals('appwrite-callback-project', $url['scheme']); + $this->assertEquals('', $url['host']); + $this->assertEquals(null, $url['port']); + $this->assertEquals('', $url['path']); + $this->assertEquals('', $url['query']); } public function testUnparse(): void From 990e1b91bbb680098efb609dced64fafcd6512d3 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 9 Jul 2025 22:09:18 -0700 Subject: [PATCH 42/60] fix: omit : and @ if user and pass are empty So, unparsing should not end up with https://:@appwrite.io just because user and pass are empty strings. --- src/Appwrite/URL/URL.php | 4 ++-- tests/unit/URL/URLTest.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/URL/URL.php b/src/Appwrite/URL/URL.php index a511c8dc13..49e95929e7 100644 --- a/src/Appwrite/URL/URL.php +++ b/src/Appwrite/URL/URL.php @@ -68,9 +68,9 @@ class URL $parts['user'] = isset($url['user']) ? $url['user'] : ''; - $parts['pass'] = isset($url['pass']) ? ':' . $url['pass'] : ''; + $parts['pass'] = !empty($url['pass']) ? ':' . $url['pass'] : ''; - $parts['pass'] = ($parts['user'] || $parts['pass']) ? $parts['pass'] . '@' : ''; + $parts['pass'] = ($parts['user'] || !empty($parts['pass'])) ? $parts['pass'] . '@' : ''; $parts['path'] = isset($url['path']) ? $url['path'] : ''; diff --git a/tests/unit/URL/URLTest.php b/tests/unit/URL/URLTest.php index 93415ee20b..ceca1c6304 100644 --- a/tests/unit/URL/URLTest.php +++ b/tests/unit/URL/URLTest.php @@ -95,6 +95,19 @@ class URLTest extends TestCase $this->assertIsString($url); $this->assertEquals('https://eldad:fux@appwrite.io/#bottom', $url); + + $url = URL::unparse([ + 'scheme' => 'https', + 'user' => '', + 'pass' => '', + 'host' => 'appwrite.io', + 'port' => null, + 'path' => '', + 'fragment' => '', + ]); + + $this->assertIsString($url); + $this->assertEquals('https://appwrite.io/#', $url); } public function testParseQuery(): void From 11332ed1f987b53458b8020441b38e58e48dbcd8 Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Wed, 9 Jul 2025 22:10:17 -0700 Subject: [PATCH 43/60] chore: fix deprecation warning from passing null into json_decode --- app/controllers/api/account.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 99269f1f18..b87f68abc0 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1424,13 +1424,13 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') $name = ''; $nameOAuth = $oauth2->getUserName($accessToken); - $userParam = \json_decode($request->getParam('user'), true); + $userParam = $request->getParam('user'); if (!empty($nameOAuth)) { $name = $nameOAuth; - } elseif (is_array($userParam)) { - $nameParam = $userParam['name']; - if (is_array($nameParam) && isset($nameParam['firstName']) && isset($nameParam['lastName'])) { - $name = $nameParam['firstName'] . ' ' . $nameParam['lastName']; + } elseif ($userParam !== null) { + $user = \json_decode($userParam, true); + if (isset($user['name']['firstName']) && isset($user['name']['lastName'])) { + $name = $user['name']['firstName'] . ' ' . $user['name']['lastName']; } } $email = $oauth2->getUserEmail($accessToken); @@ -1748,8 +1748,6 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') $state['success']['query'] = URLParser::unparseQuery($query); $state['success'] = URLParser::unparse($state['success']); - $expire = DateTime::formatTz(DateTime::addSeconds(new \DateTime(), $duration)); - $response ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Pragma', 'no-cache') From eaf9b8b228fd1cd6dd0a067e06e21ee890e4f2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 12:55:45 +0200 Subject: [PATCH 44/60] Migrate remaining tests to node --- composer.lock | 4 +- .../Functions/FunctionsCustomServerTest.php | 104 +++++++++--------- tests/resources/functions/basic/index.js | 6 +- .../functions/binary-request/index.js | 6 + .../functions/binary-response/index.js | 4 + .../functions/{php-large => large}/blue.mp4 | Bin tests/resources/functions/large/index.js | 3 + .../functions/php-binary-request/index.php | 6 - .../functions/php-binary-response/index.php | 6 - .../functions/php-large/composer.json | 18 --- .../functions/php-large/composer.lock | 64 ----------- tests/resources/functions/php-large/index.php | 16 --- 12 files changed, 68 insertions(+), 169 deletions(-) create mode 100644 tests/resources/functions/binary-request/index.js create mode 100644 tests/resources/functions/binary-response/index.js rename tests/resources/functions/{php-large => large}/blue.mp4 (100%) create mode 100644 tests/resources/functions/large/index.js delete mode 100644 tests/resources/functions/php-binary-request/index.php delete mode 100644 tests/resources/functions/php-binary-response/index.php delete mode 100644 tests/resources/functions/php-large/composer.json delete mode 100644 tests/resources/functions/php-large/composer.lock delete mode 100644 tests/resources/functions/php-large/index.php diff --git a/composer.lock b/composer.lock index 653d1841d5..ec39039b91 100644 --- a/composer.lock +++ b/composer.lock @@ -8239,7 +8239,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8263,5 +8263,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index d562e52e52..4d0646b12e 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -35,7 +35,7 @@ class FunctionsCustomServerTest extends Scope $function = $this->createFunction([ 'functionId' => ID::unique(), 'name' => 'Specs function', - 'runtime' => 'php-8.0', + 'runtime' => 'node-22', 'specification' => $specifications['body']['specifications'][0]['slug'] ]); $this->assertEquals(201, $function['headers']['status-code']); @@ -50,7 +50,7 @@ class FunctionsCustomServerTest extends Scope $function = $this->createFunction([ 'functionId' => ID::unique(), 'name' => 'Specs function', - 'runtime' => 'php-8.0', + 'runtime' => 'node-22', 'specification' => 'cheap-please' ]); $this->assertEquals(400, $function['headers']['status-code']); @@ -64,8 +64,8 @@ class FunctionsCustomServerTest extends Scope $function = $this->createFunction([ 'functionId' => ID::unique(), 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'buckets.*.create', 'buckets.*.delete', @@ -79,7 +79,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(201, $function['headers']['status-code']); $this->assertNotEmpty($function['body']['$id']); $this->assertEquals('Test', $function['body']['name']); - $this->assertEquals('php-8.0', $function['body']['runtime']); + $this->assertEquals('node-22', $function['body']['runtime']); $this->assertEquals(true, $dateValidator->isValid($function['body']['$createdAt'])); $this->assertEquals(true, $dateValidator->isValid($function['body']['$updatedAt'])); $this->assertEquals('', $function['body']['deploymentId']); @@ -180,7 +180,7 @@ class FunctionsCustomServerTest extends Scope // Test search runtime $functions = $this->listFunctions([ - 'search' => 'php-8.0' + 'search' => 'node-22' ]); $this->assertEquals($functions['headers']['status-code'], 200); @@ -193,8 +193,8 @@ class FunctionsCustomServerTest extends Scope $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test 2', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'buckets.*.create', 'buckets.*.delete', @@ -286,8 +286,8 @@ class FunctionsCustomServerTest extends Scope ], 'schedule' => '0 0 1 1 *', 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', ]); $dateValidator = new DatetimeValidator(); @@ -362,7 +362,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $starterTemplate['headers']['status-code']); $phpRuntime = array_values(array_filter($starterTemplate['body']['runtimes'], function ($runtime) { - return $runtime['name'] === 'php-8.0'; + return $runtime['name'] === 'node-22'; }))[0]; // If this fails, the template has variables, and this test needs to be updated @@ -372,7 +372,7 @@ class FunctionsCustomServerTest extends Scope [ 'functionId' => ID::unique(), 'name' => $starterTemplate['body']['name'], - 'runtime' => 'php-8.0', + 'runtime' => 'node-22', 'execute' => $starterTemplate['body']['permissions'], 'entrypoint' => $phpRuntime['entrypoint'], 'events' => $starterTemplate['body']['events'], @@ -521,7 +521,7 @@ class FunctionsCustomServerTest extends Scope $this->assertNotEmpty($deployment['body']['$id']); $this->assertEquals('waiting', $deployment['body']['status']); $this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt'])); - $this->assertEquals('index.php', $deployment['body']['entrypoint']); + $this->assertEquals('index.js', $deployment['body']['entrypoint']); $deploymentIdActive = $deployment['body']['$id'] ?? ''; @@ -581,7 +581,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(202, $deployment['headers']['status-code']); $this->assertNotEmpty($deployment['body']['$id']); $this->assertEquals(true, (new DatetimeValidator())->isValid($deployment['body']['$createdAt'])); - $this->assertEquals('index.php', $deployment['body']['entrypoint']); + $this->assertEquals('index.js', $deployment['body']['entrypoint']); $this->assertEventually(function () use ($functionId, $deploymentId) { $deployment = $this->getDeployment($functionId, $deploymentId); @@ -617,7 +617,7 @@ class FunctionsCustomServerTest extends Scope */ $functionId = $data['functionId']; - $folder = 'php-large'; + $folder = 'large'; $code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz"; Console::execute('cd ' . realpath(__DIR__ . "/../../../resources/functions") . "/$folder && tar --exclude code.tar.gz -czf code.tar.gz .", '', $this->stdout, $this->stderr); @@ -632,13 +632,13 @@ class FunctionsCustomServerTest extends Scope ]; $id = ''; while (!feof($handle)) { - $curlFile = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(@fread($handle, $chunkSize)), $mimeType, 'php-large-fx.tar.gz'); + $curlFile = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode(@fread($handle, $chunkSize)), $mimeType, 'large-fx.tar.gz'); $headers['content-range'] = 'bytes ' . ($counter * $chunkSize) . '-' . min(((($counter * $chunkSize) + $chunkSize) - 1), $size - 1) . '/' . $size; if (!empty($id)) { $headers['x-appwrite-id'] = $id; } $largeTag = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments', array_merge($headers, $this->getHeaders()), [ - 'entrypoint' => 'index.php', + 'entrypoint' => 'index.js', 'code' => $curlFile, 'activate' => true, 'commands' => 'cp blue.mp4 copy.mp4 && ls -al' // +7MB buildSize @@ -651,7 +651,7 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(202, $largeTag['headers']['status-code']); $this->assertNotEmpty($largeTag['body']['$id']); $this->assertEquals(true, (new DatetimeValidator())->isValid($largeTag['body']['$createdAt'])); - $this->assertEquals('index.php', $largeTag['body']['entrypoint']); + $this->assertEquals('index.js', $largeTag['body']['entrypoint']); $this->assertGreaterThan(1024 * 1024 * 5, $largeTag['body']['sourceSize']); // ~7MB video file $this->assertLessThan(1024 * 1024 * 10, $largeTag['body']['sourceSize']); // ~7MB video file @@ -1119,8 +1119,8 @@ class FunctionsCustomServerTest extends Scope 'users.*.update.email', ], 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'specification' => Specification::S_1VCPU_1GB, ]); @@ -1147,8 +1147,8 @@ class FunctionsCustomServerTest extends Scope 'users.*.update.email', ], 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'specification' => Specification::S_1VCPU_512MB, ]); @@ -1177,8 +1177,8 @@ class FunctionsCustomServerTest extends Scope 'users.*.update.email', ], 'timeout' => 15, - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'specification' => 's-2vcpu-512mb', // Invalid specification ]); @@ -1279,12 +1279,12 @@ class FunctionsCustomServerTest extends Scope */ public function provideCustomExecutions(): array { + // Most disabled to keep tests fast return [ - ['folder' => 'php-fn', 'name' => 'php-8.0', 'entrypoint' => 'index.php', 'runtimeName' => 'PHP', 'runtimeVersion' => '8.0'], + // ['folder' => 'php-fn', 'name' => 'php-8.0', 'entrypoint' => 'index.php', 'runtimeName' => 'PHP', 'runtimeVersion' => '8.0'], ['folder' => 'node', 'name' => 'node-18.0', 'entrypoint' => 'index.js', 'runtimeName' => 'Node.js', 'runtimeVersion' => '18.0'], - ['folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9'], - ['folder' => 'ruby', 'name' => 'ruby-3.1', 'entrypoint' => 'main.rb', 'runtimeName' => 'Ruby', 'runtimeVersion' => '3.1'], - // Swift and Dart disabled on purpose, as it's very slow. + // ['folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9'], + // ['folder' => 'ruby', 'name' => 'ruby-3.1', 'entrypoint' => 'main.rb', 'runtimeName' => 'Ruby', 'runtimeVersion' => '3.1'], // [ 'folder' => 'dart', 'name' => 'dart-2.15', 'entrypoint' => 'main.dart', 'runtimeName' => 'Dart', 'runtimeVersion' => '2.15' ], // [ 'folder' => 'swift', 'name' => 'swift-5.5', 'entrypoint' => 'index.swift', 'runtimeName' => 'Swift', 'runtimeVersion' => '5.5' ], ]; @@ -1365,15 +1365,14 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Binary executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Binary executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-binary-response'), + 'code' => $this->packageFunction('binary-response'), 'activate' => true ]); @@ -1414,15 +1413,14 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Binary executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Binary executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-binary-request'), + 'code' => $this->packageFunction('binary-request'), 'activate' => true ]); @@ -1695,9 +1693,9 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Binary executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Binary executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); @@ -1705,8 +1703,7 @@ class FunctionsCustomServerTest extends Scope $domain = $this->setupFunctionDomain($functionId); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-binary-response'), + 'code' => $this->packageFunction('binary-response'), 'activate' => true ]); @@ -1730,9 +1727,9 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test PHP Binary executions', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'name' => 'Test Binary executions', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); @@ -1740,8 +1737,7 @@ class FunctionsCustomServerTest extends Scope $domain = $this->setupFunctionDomain($functionId); $this->setupDeployment($functionId, [ - 'entrypoint' => 'index.php', - 'code' => $this->packageFunction('php-binary-request'), + 'code' => $this->packageFunction('binary-request'), 'activate' => true ]); @@ -1768,8 +1764,8 @@ class FunctionsCustomServerTest extends Scope ], $this->getHeaders()), [ 'functionId' => ID::unique(), 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, ]); @@ -1803,8 +1799,8 @@ class FunctionsCustomServerTest extends Scope $function1Id = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); @@ -1812,8 +1808,8 @@ class FunctionsCustomServerTest extends Scope $function2Id = $this->setupFunction([ 'functionId' => ID::unique(), 'name' => 'Test2', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 15, 'execute' => ['any'] ]); diff --git a/tests/resources/functions/basic/index.js b/tests/resources/functions/basic/index.js index b35c2a724d..1eb9d38c58 100644 --- a/tests/resources/functions/basic/index.js +++ b/tests/resources/functions/basic/index.js @@ -3,9 +3,9 @@ module.exports = async(context) => { context.error('error-log-works'); if(context.req.headers['x-appwrite-user-jwt']) { - context.log('jwt-is-invalid'); - } else { context.log('jwt-is-valid'); + } else { + context.log('jwt-is-invalid'); } if(context.req.path === '/custom-response') { @@ -18,7 +18,7 @@ module.exports = async(context) => { context.log('custom-header-is-' + (context.req.headers['x-custom-header'] ?? '')); context.log('method-is-' + (context.req.method ?? '').toLowerCase()); context.log('path-is-' + (context.req.path ?? '')); - context.log('user-is-' + context.req.headers['x-appwrite-user-id'] ?? ''); + context.log('user-is-' + (context.req.headers['x-appwrite-user-id'] ?? '')); const statusCode = context.req.query['code'] || '200'; diff --git a/tests/resources/functions/binary-request/index.js b/tests/resources/functions/binary-request/index.js new file mode 100644 index 0000000000..227df8dce6 --- /dev/null +++ b/tests/resources/functions/binary-request/index.js @@ -0,0 +1,6 @@ +const crypto = require('crypto') + +module.exports = async(context) => { + const hash = crypto.createHash('md5').update(context.req.bodyBinary).digest("hex") + return context.res.send(hash); +}; diff --git a/tests/resources/functions/binary-response/index.js b/tests/resources/functions/binary-response/index.js new file mode 100644 index 0000000000..284a593df0 --- /dev/null +++ b/tests/resources/functions/binary-response/index.js @@ -0,0 +1,4 @@ +module.exports = async(context) => { + const bytes = Buffer.from(Uint8Array.from([0, 10, 255])); + return context.res.binary(bytes); +}; diff --git a/tests/resources/functions/php-large/blue.mp4 b/tests/resources/functions/large/blue.mp4 similarity index 100% rename from tests/resources/functions/php-large/blue.mp4 rename to tests/resources/functions/large/blue.mp4 diff --git a/tests/resources/functions/large/index.js b/tests/resources/functions/large/index.js new file mode 100644 index 0000000000..5e8719bcf3 --- /dev/null +++ b/tests/resources/functions/large/index.js @@ -0,0 +1,3 @@ +module.exports = async(context) => { + return context.res.empty(); +}; diff --git a/tests/resources/functions/php-binary-request/index.php b/tests/resources/functions/php-binary-request/index.php deleted file mode 100644 index 53df8705e5..0000000000 --- a/tests/resources/functions/php-binary-request/index.php +++ /dev/null @@ -1,6 +0,0 @@ -req->bodyBinary); - return $context->res->send($hash); -}; diff --git a/tests/resources/functions/php-binary-response/index.php b/tests/resources/functions/php-binary-response/index.php deleted file mode 100644 index 7715663388..0000000000 --- a/tests/resources/functions/php-binary-response/index.php +++ /dev/null @@ -1,6 +0,0 @@ -res->binary($bytes); -}; diff --git a/tests/resources/functions/php-large/composer.json b/tests/resources/functions/php-large/composer.json deleted file mode 100644 index e3c6db23e9..0000000000 --- a/tests/resources/functions/php-large/composer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "appwrite/cloud-function-demo", - "description": "Demo cloud function script", - "type": "library", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Team Appwrite", - "email": "team@appwrite.io" - } - ], - "require": { - "php": ">=7.4.0", - "ext-curl": "*", - "ext-json": "*", - "appwrite/appwrite": "1.1.*" - } -} diff --git a/tests/resources/functions/php-large/composer.lock b/tests/resources/functions/php-large/composer.lock deleted file mode 100644 index 758c73c3f9..0000000000 --- a/tests/resources/functions/php-large/composer.lock +++ /dev/null @@ -1,64 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "afdff6a172e6c44aee11f1562175f81a", - "packages": [ - { - "name": "appwrite/appwrite", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "98b327d3fd18a72f4582019916afd735a0e9e0e7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/98b327d3fd18a72f4582019916afd735a0e9e0e7", - "reference": "98b327d3fd18a72f4582019916afd735a0e9e0e7", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-json": "*", - "php": ">=7.1.0" - }, - "require-dev": { - "phpunit/phpunit": "3.7.35" - }, - "type": "library", - "autoload": { - "psr-4": { - "Appwrite\\": "src/Appwrite" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks", - "support": { - "email": "team@localhost.test", - "issues": "https://github.com/appwrite/sdk-for-php/issues", - "source": "https://github.com/appwrite/sdk-for-php/tree/1.1.2", - "url": "https://appwrite.io/support" - }, - "time": "2020-08-15T18:24:32+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=7.4.0", - "ext-curl": "*", - "ext-json": "*" - }, - "platform-dev": [], - "plugin-api-version": "2.0.0" -} diff --git a/tests/resources/functions/php-large/index.php b/tests/resources/functions/php-large/index.php deleted file mode 100644 index abcb2e53d9..0000000000 --- a/tests/resources/functions/php-large/index.php +++ /dev/null @@ -1,16 +0,0 @@ -res->json([ - 'APPWRITE_FUNCTION_ID' => \getenv('APPWRITE_FUNCTION_ID') ?: '', - 'APPWRITE_FUNCTION_NAME' => \getenv('APPWRITE_FUNCTION_NAME') ?: '', - 'APPWRITE_FUNCTION_DEPLOYMENT' => \getenv('APPWRITE_FUNCTION_DEPLOYMENT') ?: '', - 'APPWRITE_FUNCTION_TRIGGER' => $context->req->headers['x-appwrite-trigger'] ?? '', - 'APPWRITE_FUNCTION_RUNTIME_NAME' => \getenv('APPWRITE_FUNCTION_RUNTIME_NAME') ?: '', - 'APPWRITE_FUNCTION_RUNTIME_VERSION' => \getenv('APPWRITE_FUNCTION_RUNTIME_VERSION') ?: '', - 'APPWRITE_REGION' => \getenv('APPWRITE_REGION') ?: '', - 'APPWRITE_FUNCTION_CPUS' => \getenv('APPWRITE_FUNCTION_CPUS') ?: '', - 'APPWRITE_FUNCTION_MEMORY' => \getenv('APPWRITE_FUNCTION_MEMORY') ?: '', - 'UNICODE_TEST' => "êä" - ]); -}; From f02ba4c976f4af79f140df2c0d8b4f3dd1b77542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 14:25:53 +0200 Subject: [PATCH 45/60] Fix function tests --- .../Functions/FunctionsConsoleClientTest.php | 16 +++---- .../Functions/FunctionsCustomClientTest.php | 24 +++++----- .../Functions/FunctionsCustomServerTest.php | 46 +++++++------------ .../Projects/ProjectsCustomServerTest.php | 2 - tests/e2e/Services/Proxy/ProxyBase.php | 2 +- tests/resources/functions/node/index.js | 3 ++ 6 files changed, 41 insertions(+), 52 deletions(-) create mode 100644 tests/resources/functions/node/index.js diff --git a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php index b8b064f077..9dae8efdb4 100644 --- a/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsConsoleClientTest.php @@ -21,8 +21,8 @@ class FunctionsConsoleClientTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::user($this->getUser()['$id'])->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'events' => [ 'users.*.create', 'users.*.delete', @@ -39,8 +39,8 @@ class FunctionsConsoleClientTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test Failure', 'execute' => ['some-random-string'], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', ]); $this->assertEquals(400, $function2['headers']['status-code']); @@ -453,7 +453,7 @@ class FunctionsConsoleClientTest extends Scope { $function = $this->createFunction([ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Variable E2E Test', 'entrypoint' => 'index.js', 'logging' => false, @@ -481,7 +481,7 @@ class FunctionsConsoleClientTest extends Scope $deploymentId = $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -502,7 +502,7 @@ class FunctionsConsoleClientTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Download Test', 'entrypoint' => 'index.js', 'logging' => false, @@ -511,7 +511,7 @@ class FunctionsConsoleClientTest extends Scope $deploymentId = $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 6fae88fcd2..ccabc2a79e 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -81,7 +81,7 @@ class FunctionsCustomClientTest extends Scope */ $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'name' => 'Test ', + 'name' => 'Test', 'execute' => [Role::any()->toString()], 'runtime' => 'node-22', 'entrypoint' => 'index.js', @@ -105,8 +105,8 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('Test', $output['APPWRITE_FUNCTION_NAME']); $this->assertEquals($deploymentId, $output['APPWRITE_FUNCTION_DEPLOYMENT']); $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); - $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); - $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); + $this->assertEquals('Node.js', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); + $this->assertEquals('22', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); $this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); @@ -172,8 +172,8 @@ class FunctionsCustomClientTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, ]); @@ -210,11 +210,11 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); $this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']); - $this->assertEquals('Test', $output['APPWRITE_FUNCTION_NAME']); + $this->assertEquals('Test synchronous execution', $output['APPWRITE_FUNCTION_NAME']); $this->assertEquals($deploymentId, $output['APPWRITE_FUNCTION_DEPLOYMENT']); $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); - $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); - $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); + $this->assertEquals('Node.js', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); + $this->assertEquals('22', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); $this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); @@ -235,12 +235,12 @@ class FunctionsCustomClientTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::any()->toString()], - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'entrypoint' => 'index.js' ]); $this->setupDeployment($functionId, [ 'entrypoint' => 'index.js', - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -336,7 +336,7 @@ class FunctionsCustomClientTest extends Scope 'limit' => 5, 'offset' => 2, 'useCases' => ['databases'], - 'runtimes' => ['node-16.0'] + 'runtimes' => ['node-22'] ]); $this->assertEquals(200, $templates['headers']['status-code']); @@ -348,7 +348,7 @@ class FunctionsCustomClientTest extends Scope $this->assertContains($template['useCases'][0], ['databases']); } - $this->assertContains('node-16.0', array_column($templates['body']['templates'][0]['runtimes'], 'name')); + $this->assertContains('node-22', array_column($templates['body']['templates'][0]['runtimes'], 'name')); /** * Test for FAILURE diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 4d0646b12e..488db8e6da 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -902,8 +902,8 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString($data['deploymentId'], $execution['body']['responseBody']); $this->assertStringContainsString('Test1', $execution['body']['responseBody']); $this->assertStringContainsString('http', $execution['body']['responseBody']); - $this->assertStringContainsString('PHP', $execution['body']['responseBody']); - $this->assertStringContainsString('8.0', $execution['body']['responseBody']); + $this->assertStringContainsString('Node.js', $execution['body']['responseBody']); + $this->assertStringContainsString('22', $execution['body']['responseBody']); $this->assertStringContainsString('Global Variable Value', $execution['body']['responseBody']); // $this->assertStringContainsString('êä', $execution['body']['responseBody']); // tests unknown utf-8 chars $this->assertNotEmpty($execution['body']['errors']); @@ -1016,8 +1016,8 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $execution['body']['responseStatusCode']); $this->assertStringContainsString('Test1', $execution['body']['responseBody']); $this->assertStringContainsString('http', $execution['body']['responseBody']); - $this->assertStringContainsString('PHP', $execution['body']['responseBody']); - $this->assertStringContainsString('8.0', $execution['body']['responseBody']); + $this->assertStringContainsString('Node.js', $execution['body']['responseBody']); + $this->assertStringContainsString('22', $execution['body']['responseBody']); // $this->assertStringContainsString('êä', $execution['body']['response']); // tests unknown utf-8 chars $this->assertLessThan(1.500, $execution['body']['duration']); @@ -1282,7 +1282,7 @@ class FunctionsCustomServerTest extends Scope // Most disabled to keep tests fast return [ // ['folder' => 'php-fn', 'name' => 'php-8.0', 'entrypoint' => 'index.php', 'runtimeName' => 'PHP', 'runtimeVersion' => '8.0'], - ['folder' => 'node', 'name' => 'node-18.0', 'entrypoint' => 'index.js', 'runtimeName' => 'Node.js', 'runtimeVersion' => '18.0'], + ['folder' => 'node', 'name' => 'node-22', 'entrypoint' => 'index.js', 'runtimeName' => 'Node.js', 'runtimeVersion' => '22'], // ['folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9'], // ['folder' => 'ruby', 'name' => 'ruby-3.1', 'entrypoint' => 'main.rb', 'runtimeName' => 'Ruby', 'runtimeVersion' => '3.1'], // [ 'folder' => 'dart', 'name' => 'dart-2.15', 'entrypoint' => 'main.dart', 'runtimeName' => 'Dart', 'runtimeVersion' => '2.15' ], @@ -1323,27 +1323,14 @@ class FunctionsCustomServerTest extends Scope ]); $execution = $this->createExecution($functionId, [ - 'body' => 'foobar', 'async' => 'false' ]); - + $output = json_decode($execution['body']['responseBody'], true); $this->assertEquals(201, $execution['headers']['status-code']); - $this->assertEquals('completed', $execution['body']['status']); $this->assertEquals(200, $execution['body']['responseStatusCode']); - $this->assertEquals($functionId, $output['APPWRITE_FUNCTION_ID']); - $this->assertEquals('Test ' . $name, $output['APPWRITE_FUNCTION_NAME']); - $this->assertEquals($deploymentId, $output['APPWRITE_FUNCTION_DEPLOYMENT']); - $this->assertEquals('http', $output['APPWRITE_FUNCTION_TRIGGER']); - $this->assertEquals($runtimeName, $output['APPWRITE_FUNCTION_RUNTIME_NAME']); - $this->assertEquals($runtimeVersion, $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); - $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); - $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); - $this->assertEquals('variable', $output['CUSTOM_VARIABLE']); - $this->assertEmpty($output['APPWRITE_FUNCTION_USER_ID']); - $this->assertEmpty($output['APPWRITE_FUNCTION_JWT']); - $this->assertEquals($this->getProject()['$id'], $output['APPWRITE_FUNCTION_PROJECT_ID']); - $this->assertStringContainsString('log-works', $execution['body']['logs']); + $this->assertEquals('OK', $execution['body']['responseBody']); + $this->assertEmpty($execution['body']['logs']); $this->assertEmpty($execution['body']['errors']); $executionId = $execution['body']['$id'] ?? ''; @@ -1356,7 +1343,8 @@ class FunctionsCustomServerTest extends Scope $this->assertCount(1, $executions['body']['executions']); $this->assertEquals($executions['body']['executions'][0]['$id'], $executionId); $this->assertEquals($executions['body']['executions'][0]['trigger'], 'http'); - $this->assertStringContainsString('log-works', $executions['body']['executions'][0]['logs']); + $this->assertEquals(200, $executions['body']['executions'][0]['responseStatusCode']); + $this->assertEmpty($executions['body']['executions'][0]['responseBody']); $this->cleanupFunction($functionId); } @@ -1840,7 +1828,7 @@ class FunctionsCustomServerTest extends Scope { $function = $this->createFunction([ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Logging Test', 'entrypoint' => 'index.js', 'logging' => false, @@ -1856,7 +1844,7 @@ class FunctionsCustomServerTest extends Scope $domain = $this->setupFunctionDomain($functionId); $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -1933,7 +1921,7 @@ class FunctionsCustomServerTest extends Scope // Check if the function specifications are correctly set in builds $function = $this->createFunction([ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Specification Test', 'entrypoint' => 'index.js', 'logging' => false, @@ -1949,7 +1937,7 @@ class FunctionsCustomServerTest extends Scope $functionId = $functionId = $function['body']['$id'] ?? ''; $deploymentId = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); @@ -1975,7 +1963,7 @@ class FunctionsCustomServerTest extends Scope { $functionId = $this->setupFunction([ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Duplicate Deployment Test', 'entrypoint' => 'index.js', 'commands' => '' @@ -1983,7 +1971,7 @@ class FunctionsCustomServerTest extends Scope $this->assertNotEmpty($functionId); $deploymentId1 = $this->setupDeployment($functionId, [ - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => true ]); $this->assertNotEmpty($deploymentId1); @@ -1993,7 +1981,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('APPWRITE_FUNCTION_ID', $execution['body']['responseBody']); $function = $this->updateFunction($functionId, [ - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Duplicate Deployment Test', 'entrypoint' => 'index.js', 'commands' => 'rm index.js && mv maintenance.js index.js' diff --git a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php index a01073f3a3..68ff53ae55 100644 --- a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php +++ b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php @@ -30,8 +30,6 @@ class ProjectsCustomServerTest extends Scope 'domain' => $testId . '-api.appwrite.test', ]); - \var_dump($response); - $this->assertEquals(201, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_POST, '/proxy/rules/api', $headers, [ diff --git a/tests/e2e/Services/Proxy/ProxyBase.php b/tests/e2e/Services/Proxy/ProxyBase.php index b04a8594cb..f125f433f1 100644 --- a/tests/e2e/Services/Proxy/ProxyBase.php +++ b/tests/e2e/Services/Proxy/ProxyBase.php @@ -244,7 +244,7 @@ trait ProxyBase 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'], ]), [ - 'code' => $this->packageFunction('generic'), + 'code' => $this->packageFunction('basic'), 'activate' => 'true' ]); diff --git a/tests/resources/functions/node/index.js b/tests/resources/functions/node/index.js new file mode 100644 index 0000000000..a43ed308ac --- /dev/null +++ b/tests/resources/functions/node/index.js @@ -0,0 +1,3 @@ +module.exports = async(context) => { + return context.res.send('OK'); +} \ No newline at end of file From 581235f9727e95c4612d5a74a25f35bfdbc33ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 14:43:56 +0200 Subject: [PATCH 46/60] Fix more tests --- tests/e2e/Services/Migrations/MigrationsBase.php | 4 ++-- tests/e2e/Services/Proxy/ProxyBase.php | 2 +- .../e2e/Services/Webhooks/WebhooksCustomServerTest.php | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/e2e/Services/Migrations/MigrationsBase.php b/tests/e2e/Services/Migrations/MigrationsBase.php index 0b8f75b804..6bc1f2d427 100644 --- a/tests/e2e/Services/Migrations/MigrationsBase.php +++ b/tests/e2e/Services/Migrations/MigrationsBase.php @@ -854,8 +854,8 @@ trait MigrationsBase $this->assertEquals($functionId, $response['body']['$id']); $this->assertEquals('Test', $response['body']['name']); - $this->assertEquals('php-8.0', $response['body']['runtime']); - $this->assertEquals('index.php', $response['body']['entrypoint']); + $this->assertEquals('node-22', $response['body']['runtime']); + $this->assertEquals('index.js', $response['body']['entrypoint']); $this->assertEventually(function () use ($functionId) { diff --git a/tests/e2e/Services/Proxy/ProxyBase.php b/tests/e2e/Services/Proxy/ProxyBase.php index f125f433f1..c6d63495a0 100644 --- a/tests/e2e/Services/Proxy/ProxyBase.php +++ b/tests/e2e/Services/Proxy/ProxyBase.php @@ -227,7 +227,7 @@ trait ProxyBase 'x-appwrite-key' => $this->getProject()['apiKey'], ]), [ 'functionId' => ID::unique(), - 'runtime' => 'node-18.0', + 'runtime' => 'node-22', 'name' => 'Proxy Function', 'entrypoint' => 'index.js', 'commands' => '', diff --git a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php index d2f132e960..2bb9d81eec 100644 --- a/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php +++ b/tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php @@ -399,8 +399,8 @@ class WebhooksCustomServerTest extends Scope 'functionId' => ID::unique(), 'name' => 'Test', 'execute' => [Role::any()->toString()], - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'timeout' => 10, ]); @@ -439,8 +439,8 @@ class WebhooksCustomServerTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Test', - 'runtime' => 'php-8.0', - 'entrypoint' => 'index.php', + 'runtime' => 'node-22', + 'entrypoint' => 'index.js', 'execute' => [Role::any()->toString()], 'vars' => [ 'key1' => 'value1', @@ -496,7 +496,7 @@ class WebhooksCustomServerTest extends Scope 'content-type' => 'multipart/form-data', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'entrypoint' => 'index.php', + 'entrypoint' => 'index.js', 'code' => new CURLFile($code, 'application/x-gzip', \basename($code)), 'activate' => true ]); From 6dc6ff6ba043c55796e7e43f0ae28c91c20042d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 14:44:44 +0200 Subject: [PATCH 47/60] Fix formatting --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 488db8e6da..83ff1a0a92 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1325,7 +1325,7 @@ class FunctionsCustomServerTest extends Scope $execution = $this->createExecution($functionId, [ 'async' => 'false' ]); - + $output = json_decode($execution['body']['responseBody'], true); $this->assertEquals(201, $execution['headers']['status-code']); $this->assertEquals(200, $execution['body']['responseStatusCode']); From 89d54f847f0938f6070b05ee1b6fbe18fe0ef197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 15:52:29 +0200 Subject: [PATCH 48/60] Speed up build cancellation --- .../Modules/Functions/Workers/Builds.php | 30 +++++++++++++++---- .../Functions/FunctionsCustomServerTest.php | 12 ++++---- .../Services/Sites/SitesCustomServerTest.php | 14 ++++----- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 580383e76a..3ccc6d5eea 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -264,7 +264,7 @@ class Builds extends Action ->setParam('deploymentId', $deployment->getId()); if ($deployment->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -391,7 +391,7 @@ class Builds extends Action Console::execute('mkdir -p ' . \escapeshellarg('/tmp/builds/' . $deploymentId), '', $stdout, $stderr); if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -656,7 +656,7 @@ class Builds extends Action $err = null; if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -807,7 +807,7 @@ class Builds extends Action ]); if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -1222,7 +1222,7 @@ class Builds extends Action ->trigger(); if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -1245,7 +1245,7 @@ class Builds extends Action Console::error($th->getTraceAsString()); if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') { - Console::info('Build has been canceled'); + $this->cancelDeployment($deployment->getId(), $dbForProject, $queueForRealtime); return; } @@ -1531,4 +1531,22 @@ class Builds extends Action } } } + + private function cancelDeployment(string $deploymentId, Database $dbForProject, Realtime $queueForRealtime) + { + Console::info('Build has been canceled'); + + $deployment = $dbForProject->getDocument('deployments', $deploymentId); + + $logs = $deployment->getAttribute('buildLogs', ''); + $date = \date('H:i:s'); + $logs .= "[$date] [appwrite] Build has been canceled. \n"; + + $deployment->setAttribute('buildLogs', $logs); + $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); + + $queueForRealtime + ->setPayload($deployment->getArrayCopy()) + ->trigger(); + } } diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 83ff1a0a92..ff99033fdf 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -594,12 +594,12 @@ class FunctionsCustomServerTest extends Scope $this->assertEquals(200, $deployment['headers']['status-code']); $this->assertEquals('canceled', $deployment['body']['status']); - /** - * Build worker still runs the build. - * 30s sleep gives worker enough time to finish build. - * After build finished, it should still be canceled, not ready. - */ - \sleep(30); + // Ensures worker got eventually aware of cancellation and reacted properly + $this->assertEventually(function () use ($functionId, $deploymentId) { + $deployment = $this->getDeployment($functionId, $deploymentId); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertStringContainsString('Build has been canceled.', $deployment['body']['buildLogs']); + }); $deployment = $this->getDeployment($functionId, $deploymentId); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index b3ea045430..721203fc67 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -937,12 +937,12 @@ class SitesCustomServerTest extends Scope $this->assertEquals(200, $deployment['headers']['status-code']); $this->assertEquals('canceled', $deployment['body']['status']); - /** - * Build worker still runs the build. - * 30s sleep gives worker enough time to finish build. - * After build finished, it should still be canceled, not ready. - */ - \sleep(30); + // Ensures worker got eventually aware of cancellation and reacted properly + $this->assertEventually(function () use ($siteId, $deploymentId) { + $deployment = $this->getDeployment($siteId, $deploymentId); + $this->assertEquals(200, $deployment['headers']['status-code']); + $this->assertStringContainsString('Build has been canceled.', $deployment['body']['buildLogs']); + }); $deployment = $this->getDeployment($siteId, $deploymentId); @@ -2657,7 +2657,7 @@ class SitesCustomServerTest extends Scope $siteId = $this->setupSite([ 'siteId' => ID::unique(), 'name' => 'Astro SSR site', - 'framework' => 'astro', + 'framework' => 'static', 'buildRuntime' => 'node-22', 'outputDirectory' => './dist', 'buildCommand' => 'npm run build', From 18492ab91718869108037148fe38c51475f84686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 10 Jul 2025 16:16:06 +0200 Subject: [PATCH 49/60] Revert unwanted change --- tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 721203fc67..8680ca191c 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2657,7 +2657,7 @@ class SitesCustomServerTest extends Scope $siteId = $this->setupSite([ 'siteId' => ID::unique(), 'name' => 'Astro SSR site', - 'framework' => 'static', + 'framework' => 'astro', 'buildRuntime' => 'node-22', 'outputDirectory' => './dist', 'buildCommand' => 'npm run build', From 100aea337f4f05c48c19c455910d02bdc5b0ccff Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 7 Jul 2025 15:32:04 -0700 Subject: [PATCH 50/60] fix: update OAuth2 redirect URLs 1. handle non-standard ports if the request came in on a non-standard port 2. use the _APP_CONSOLE_DOMAIN env var to handle cases where the Console domain may not be the endpoint domain such as on Appwrite Cloud 3. use the _APP_OPTIONS_FORCE_HTTPS env var to determine the protocol to be consistent with the rest of the codebase --- app/controllers/api/account.php | 93 ++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index b87f68abc0..f086036872 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1189,9 +1189,16 @@ App::get('/v1/account/sessions/oauth2/:provider') ->inject('response') ->inject('project') ->action(function (string $provider, string $success, string $failure, array $scopes, Request $request, Response $response, Document $project) use ($oauthDefaultSuccess, $oauthDefaultFailure) { - $protocol = $request->getProtocol(); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $request->getHostname(); + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } - $callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); + $callback = $callbackBase . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); $providerEnabled = $project->getAttribute('oAuthProviders', [])[$provider . 'Enabled'] ?? false; if (!$providerEnabled) { @@ -1216,12 +1223,20 @@ App::get('/v1/account/sessions/oauth2/:provider') throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED); } + $host = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', '')); + $redirectBase = $protocol . '://' . $host; + if ($protocol === 'https' && $port !== '443') { + $redirectBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $redirectBase .= ':' . $port; + } + if (empty($success)) { - $success = $protocol . '://' . $request->getHostname() . $oauthDefaultSuccess; + $success = $redirectBase . $oauthDefaultSuccess; } if (empty($failure)) { - $failure = $protocol . '://' . $request->getHostname() . $oauthDefaultFailure; + $failure = $redirectBase . $oauthDefaultFailure; } $oauth2 = new $className($appId, $appSecret, $callback, [ @@ -1251,9 +1266,14 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->inject('request') ->inject('response') ->action(function (string $projectId, string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response) { - - $domain = $request->getHostname(); - $protocol = $request->getProtocol(); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $request->getHostname(); + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } $params = $request->getParams(); $params['project'] = $projectId; @@ -1262,7 +1282,7 @@ App::get('/v1/account/sessions/oauth2/callback/:provider/:projectId') $response ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Pragma', 'no-cache') - ->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' + ->redirect($callbackBase . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' . \http_build_query($params)); }); @@ -1282,8 +1302,14 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') ->inject('request') ->inject('response') ->action(function (string $projectId, string $provider, string $code, string $state, string $error, string $error_description, Request $request, Response $response) { - $domain = $request->getHostname(); - $protocol = $request->getProtocol(); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $request->getHostname(); + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } $params = $request->getParams(); $params['project'] = $projectId; @@ -1292,7 +1318,7 @@ App::post('/v1/account/sessions/oauth2/callback/:provider/:projectId') $response ->addHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0') ->addHeader('Pragma', 'no-cache') - ->redirect($protocol . '://' . $domain . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' + ->redirect($callbackBase . '/v1/account/sessions/oauth2/' . $provider . '/redirect?' . \http_build_query($params)); }); @@ -1323,8 +1349,15 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') ->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) { - $protocol = $request->getProtocol(); - $callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $request->getHostname(); + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } + $callback = $callbackBase . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); $defaultState = ['success' => $project->getAttribute('url', ''), 'failure' => '']; $redirect = new Redirect($platforms); $appId = $project->getAttribute('oAuthProviders', [])[$provider . 'Appid'] ?? ''; @@ -1785,9 +1818,16 @@ App::get('/v1/account/tokens/oauth2/:provider') ->inject('response') ->inject('project') ->action(function (string $provider, string $success, string $failure, array $scopes, Request $request, Response $response, Document $project) use ($oauthDefaultSuccess, $oauthDefaultFailure) { - $protocol = $request->getProtocol(); + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $request->getHostname(); + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } - $callback = $protocol . '://' . $request->getHostname() . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); + $callback = $callbackBase . '/v1/account/sessions/oauth2/callback/' . $provider . '/' . $project->getId(); $providerEnabled = $project->getAttribute('oAuthProviders', [])[$provider . 'Enabled'] ?? false; if (!$providerEnabled) { @@ -1812,12 +1852,20 @@ App::get('/v1/account/tokens/oauth2/:provider') throw new Exception(Exception::PROJECT_PROVIDER_UNSUPPORTED); } + $host = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', '')); + $redirectBase = $protocol . '://' . $host; + if ($protocol === 'https' && $port !== '443') { + $redirectBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $redirectBase .= ':' . $port; + } + if (empty($success)) { - $success = $protocol . '://' . $request->getHostname() . $oauthDefaultSuccess; + $success = $redirectBase . $oauthDefaultSuccess; } if (empty($failure)) { - $failure = $protocol . '://' . $request->getHostname() . $oauthDefaultFailure; + $failure = $redirectBase . $oauthDefaultFailure; } $oauth2 = new $className($appId, $appSecret, $callback, [ @@ -1960,7 +2008,16 @@ App::post('/v1/account/tokens/magic-url') $dbForProject->purgeCachedDocument('users', $user->getId()); if (empty($url)) { - $url = $request->getProtocol() . '://' . $request->getHostname() . '/console/auth/magic-url'; + $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https'; + $host = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', '')); + $port = $request->getPort(); + $callbackBase = $protocol . '://' . $host; + if ($protocol === 'https' && $port !== '443') { + $callbackBase .= ':' . $port; + } elseif ($protocol === 'http' && $port !== '80') { + $callbackBase .= ':' . $port; + } + $url = $callbackBase . '/console/auth/magic-url'; } $url = Template::parseURL($url); From 9bab764378d8289505d831538cb42ea6f563110e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 11 Jul 2025 11:15:55 +0200 Subject: [PATCH 51/60] Fix specs with new env vars --- .../Platform/Modules/Functions/Http/Specifications/XList.php | 4 ++-- .../Platform/Modules/Sites/Http/Specifications/XList.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php index 4c059b09d0..d76584534d 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Specifications/XList.php @@ -63,8 +63,8 @@ class XList extends Base $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } - $maxCpus = System::getEnv('_APP_FUNCTIONS_CPUS', 0); - $maxMemory = System::getEnv('_APP_FUNCTIONS_MEMORY', 0); + $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); + $maxMemory = System::getEnv('_APP_COMPUTE_MEMORY', 0); // Only add specs that are within the limits set by environment variables // Treat 0 as no limit diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php index a76f067114..4bda37df73 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Specifications/XList.php @@ -63,8 +63,8 @@ class XList extends Base $spec['enabled'] = in_array($spec['slug'], $plan['runtimeSpecifications']); } - $maxCpus = System::getEnv('_APP_FUNCTIONS_CPUS', 0); - $maxMemory = System::getEnv('_APP_FUNCTIONS_MEMORY', 0); + $maxCpus = System::getEnv('_APP_COMPUTE_CPUS', 0); + $maxMemory = System::getEnv('_APP_COMPUTE_MEMORY', 0); // Only add specs that are within the limits set by environment variables // Treat 0 as no limit From 32cb5e0a7973532334badbc324f8b51a790d3b66 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 11 Jul 2025 16:31:50 +0530 Subject: [PATCH 52/60] chore: update cli to 8.2.0 --- app/config/platforms.php | 2 +- composer.lock | 24 ++++++++++++------------ docs/sdks/cli/CHANGELOG.md | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 41895ddc07..384f7925dd 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -217,7 +217,7 @@ return [ [ 'key' => 'cli', 'name' => 'Command Line', - 'version' => '8.1.1', + 'version' => '8.2.0', 'url' => 'https://github.com/appwrite/sdk-for-cli', 'package' => 'https://www.npmjs.com/package/appwrite-cli', 'enabled' => true, diff --git a/composer.lock b/composer.lock index 653d1841d5..328d387077 100644 --- a/composer.lock +++ b/composer.lock @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.11", + "version": "0.41.13", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "60122cb613a5a1c82667ecc2217e351654a8d404" + "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/60122cb613a5a1c82667ecc2217e351654a8d404", - "reference": "60122cb613a5a1c82667ecc2217e351654a8d404", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7381d2d303af3450f71d0f420f127564c8d4e3d5", + "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.11" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.13" }, - "time": "2025-07-04T09:56:24+00:00" + "time": "2025-07-11T10:18:51+00:00" }, { "name": "doctrine/annotations", @@ -5084,16 +5084,16 @@ }, { "name": "laravel/pint", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "9ab851dba4faa51a3c3223dd3d07044129021024" + "reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/9ab851dba4faa51a3c3223dd3d07044129021024", - "reference": "9ab851dba4faa51a3c3223dd3d07044129021024", + "url": "https://api.github.com/repos/laravel/pint/zipball/0345f3b05f136801af8c339f9d16ef29e6b4df8a", + "reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a", "shasum": "" }, "require": { @@ -5104,7 +5104,7 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.76.0", + "friendsofphp/php-cs-fixer": "^3.82.2", "illuminate/view": "^11.45.1", "larastan/larastan": "^3.5.0", "laravel-zero/framework": "^11.45.0", @@ -5149,7 +5149,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-07-03T10:37:47+00:00" + "time": "2025-07-10T18:09:32+00:00" }, { "name": "matthiasmullie/minify", diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index 29115bc0f7..e233c5e1e2 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## 8.2.0 + +* Add `encrypt` attribute support +* Add improved warnings on attribute recreation and deletion +* Fix `null` parsing error when using create attribute command +* Type generation fixes and improvements: + * Add `--strict` / `-s` flag to `appwrite types` command to generate types in strict mode. This automatically converts the casing of attributes to match the language's naming conventions + * Add automatic package import to `dart` language which uses package detection to import the correct package + * Add `Document` class extension to generated types in `dart` and `js` language to support internal attributes like `$id` and `$collectionId` etc. + * Add proper enum support to `js` language + * Fix indentation in `java`, `kotlin` and `swift` to use 2 spaces instead of 4 for consistency across all languages + * Fix doc comments to use correct syntax in various languages (for eg. `///` instead of `/*`) + * Update enums in `dart` to use lowerCamelCase in `strict` mode as per [constant_identifier_names](https://dart.dev/tools/diagnostics/constant_identifier_names?utm_source=dartdev&utm_medium=redir&utm_id=diagcode&utm_content=constant_identifier_names) + ## 8.1.1 * Fix circular dependency issue due to usage of `success` method in `utils.js` file from `parser.js` file From 0bdb64fc7734b84effa3e888515f0eee63dd4ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 11 Jul 2025 15:54:53 +0200 Subject: [PATCH 53/60] Fix migration tests --- composer.json | 2 +- composer.lock | 52 +++++++++++++++++++++++++-------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index 4c36ab125d..5e90143b13 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.18.*", - "utopia-php/migration": "0.10.*", + "utopia-php/migration": "0.11.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.8.*", diff --git a/composer.lock b/composer.lock index ec39039b91..97bacd40e9 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": "55bc52686a08d64930e6af7411ac0654", + "content-hash": "f53e1ccd394581428d9efcb53b46d479", "packages": [ { "name": "adhocore/jwt", @@ -69,16 +69,16 @@ }, { "name": "appwrite/appwrite", - "version": "11.1.0", + "version": "15.0.0", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-for-php.git", - "reference": "1d043f543acdb17b9fdb440b1b2dd208e400bad3" + "reference": "deb97b62e0abed8a4fd5c5d48e77365cf89867cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/1d043f543acdb17b9fdb440b1b2dd208e400bad3", - "reference": "1d043f543acdb17b9fdb440b1b2dd208e400bad3", + "url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/deb97b62e0abed8a4fd5c5d48e77365cf89867cf", + "reference": "deb97b62e0abed8a4fd5c5d48e77365cf89867cf", "shasum": "" }, "require": { @@ -104,10 +104,10 @@ "support": { "email": "team@appwrite.io", "issues": "https://github.com/appwrite/sdk-for-php/issues", - "source": "https://github.com/appwrite/sdk-for-php/tree/11.1.0", + "source": "https://github.com/appwrite/sdk-for-php/tree/15.0.0", "url": "https://appwrite.io/support" }, - "time": "2024-06-26T07:03:23+00:00" + "time": "2025-05-18T09:47:10+00:00" }, { "name": "appwrite/php-clamav", @@ -3993,20 +3993,20 @@ }, { "name": "utopia-php/migration", - "version": "0.10.4", + "version": "0.11.1", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "0c85917482db172b3ccdc0704e42af3c1cc89361" + "reference": "d528a454d5c1ed6564b2843a39ff13297bcdb1af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/0c85917482db172b3ccdc0704e42af3c1cc89361", - "reference": "0c85917482db172b3ccdc0704e42af3c1cc89361", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/d528a454d5c1ed6564b2843a39ff13297bcdb1af", + "reference": "d528a454d5c1ed6564b2843a39ff13297bcdb1af", "shasum": "" }, "require": { - "appwrite/appwrite": "11.*", + "appwrite/appwrite": "15.*", "ext-curl": "*", "ext-openssl": "*", "php": ">=8.1", @@ -4043,9 +4043,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.10.4" + "source": "https://github.com/utopia-php/migration/tree/0.11.1" }, - "time": "2025-07-02T18:31:09+00:00" + "time": "2025-07-11T13:46:37+00:00" }, { "name": "utopia-php/orchestration", @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.11", + "version": "0.41.13", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "60122cb613a5a1c82667ecc2217e351654a8d404" + "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/60122cb613a5a1c82667ecc2217e351654a8d404", - "reference": "60122cb613a5a1c82667ecc2217e351654a8d404", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7381d2d303af3450f71d0f420f127564c8d4e3d5", + "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.11" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.13" }, - "time": "2025-07-04T09:56:24+00:00" + "time": "2025-07-11T10:18:51+00:00" }, { "name": "doctrine/annotations", @@ -5084,16 +5084,16 @@ }, { "name": "laravel/pint", - "version": "v1.23.0", + "version": "v1.24.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "9ab851dba4faa51a3c3223dd3d07044129021024" + "reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/9ab851dba4faa51a3c3223dd3d07044129021024", - "reference": "9ab851dba4faa51a3c3223dd3d07044129021024", + "url": "https://api.github.com/repos/laravel/pint/zipball/0345f3b05f136801af8c339f9d16ef29e6b4df8a", + "reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a", "shasum": "" }, "require": { @@ -5104,7 +5104,7 @@ "php": "^8.2.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.76.0", + "friendsofphp/php-cs-fixer": "^3.82.2", "illuminate/view": "^11.45.1", "larastan/larastan": "^3.5.0", "laravel-zero/framework": "^11.45.0", @@ -5149,7 +5149,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2025-07-03T10:37:47+00:00" + "time": "2025-07-10T18:09:32+00:00" }, { "name": "matthiasmullie/minify", From 8a2e0d497042b28e61c6889ae9486abac515d226 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 12 Jul 2025 12:04:51 +0530 Subject: [PATCH 54/60] chore: update react native to 0.10.1 and changelog --- app/config/platforms.php | 2 +- composer.json | 2 +- composer.lock | 20 +++++++++++--------- docs/sdks/react-native/CHANGELOG.md | 5 +++++ 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index 384f7925dd..dbca4208e9 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -134,7 +134,7 @@ return [ [ 'key' => 'react-native', 'name' => 'React Native', - 'version' => '0.10.0', + 'version' => '0.10.1', 'url' => 'https://github.com/appwrite/sdk-for-react-native', 'package' => 'https://npmjs.com/package/react-native-appwrite', 'enabled' => true, diff --git a/composer.json b/composer.json index 5e90143b13..4eeffd9150 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ }, "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "0.41.*", + "appwrite/sdk-generator": "dev-add-missing-urisearchparams", "phpunit/phpunit": "9.*", "swoole/ide-helper": "5.1.2", "phpstan/phpstan": "1.8.*", diff --git a/composer.lock b/composer.lock index 97bacd40e9..653be77fe5 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": "f53e1ccd394581428d9efcb53b46d479", + "content-hash": "98abb43d67e27f49b50e897c97cc4d80", "packages": [ { "name": "adhocore/jwt", @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.13", + "version": "dev-add-missing-urisearchparams", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5" + "reference": "23d62adb9367a00f3dbb21d51f2a5aa7d4e62950" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/7381d2d303af3450f71d0f420f127564c8d4e3d5", - "reference": "7381d2d303af3450f71d0f420f127564c8d4e3d5", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/23d62adb9367a00f3dbb21d51f2a5aa7d4e62950", + "reference": "23d62adb9367a00f3dbb21d51f2a5aa7d4e62950", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.13" + "source": "https://github.com/appwrite/sdk-generator/tree/add-missing-urisearchparams" }, - "time": "2025-07-11T10:18:51+00:00" + "time": "2025-07-12T06:27:21+00:00" }, { "name": "doctrine/annotations", @@ -8239,7 +8239,9 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "appwrite/sdk-generator": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8263,5 +8265,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docs/sdks/react-native/CHANGELOG.md b/docs/sdks/react-native/CHANGELOG.md index 56e176f08f..6ab2975bf2 100644 --- a/docs/sdks/react-native/CHANGELOG.md +++ b/docs/sdks/react-native/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log +## 0.10.1 + +* Fix URL based methods like `getFileViewURL`, `getFilePreviewURL` etc. by adding the missing `projectId` to searchParams +* Add `gif` to ImageFormat enum + ## 0.10.0 * Add generate file URL methods like`getFilePreviewURL`, `getFileViewURL` etc. From a2ca08023d8c933b00baea5b915a0438c5bb4510 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 12 Jul 2025 12:18:11 +0530 Subject: [PATCH 55/60] chore: update composer --- composer.json | 2 +- composer.lock | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 4eeffd9150..5e90143b13 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ }, "require-dev": { "ext-fileinfo": "*", - "appwrite/sdk-generator": "dev-add-missing-urisearchparams", + "appwrite/sdk-generator": "0.41.*", "phpunit/phpunit": "9.*", "swoole/ide-helper": "5.1.2", "phpstan/phpstan": "1.8.*", diff --git a/composer.lock b/composer.lock index 653be77fe5..c2907b018d 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": "98abb43d67e27f49b50e897c97cc4d80", + "content-hash": "f53e1ccd394581428d9efcb53b46d479", "packages": [ { "name": "adhocore/jwt", @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "dev-add-missing-urisearchparams", + "version": "0.41.14", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "23d62adb9367a00f3dbb21d51f2a5aa7d4e62950" + "reference": "4ffd03759236214d935cae64a369b487ecfba91f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/23d62adb9367a00f3dbb21d51f2a5aa7d4e62950", - "reference": "23d62adb9367a00f3dbb21d51f2a5aa7d4e62950", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4ffd03759236214d935cae64a369b487ecfba91f", + "reference": "4ffd03759236214d935cae64a369b487ecfba91f", "shasum": "" }, "require": { @@ -4855,9 +4855,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/add-missing-urisearchparams" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.14" }, - "time": "2025-07-12T06:27:21+00:00" + "time": "2025-07-12T06:43:12+00:00" }, { "name": "doctrine/annotations", @@ -8239,9 +8239,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "appwrite/sdk-generator": 20 - }, + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From 054b6a995aae0834e710152b116334223f9c6f11 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Mon, 14 Jul 2025 08:54:37 +0530 Subject: [PATCH 56/60] update dotnet to 0.14.0 --- app/config/platforms.php | 2 +- .../examples/databases/upsert-document.md | 18 ++++++ .../examples/databases/upsert-documents.md | 2 +- docs/sdks/dotnet/CHANGELOG.md | 64 ++++++++++++++++++- 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 docs/examples/1.7.x/server-dotnet/examples/databases/upsert-document.md diff --git a/app/config/platforms.php b/app/config/platforms.php index dbca4208e9..bfdf445bd3 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -358,7 +358,7 @@ return [ [ 'key' => 'dotnet', 'name' => '.NET', - 'version' => '0.13.0', + 'version' => '0.14.0', 'url' => 'https://github.com/appwrite/sdk-for-dotnet', 'package' => 'https://www.nuget.org/packages/Appwrite', 'enabled' => true, diff --git a/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-document.md b/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-document.md new file mode 100644 index 0000000000..c0876bfa73 --- /dev/null +++ b/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-document.md @@ -0,0 +1,18 @@ +using Appwrite; +using Appwrite.Models; +using Appwrite.Services; + +Client client = new Client() + .SetEndPoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .SetProject("") // Your project ID + .SetSession(""); // The user session to authenticate with + +Databases databases = new Databases(client); + +Document result = await databases.UpsertDocument( + databaseId: "", + collectionId: "", + documentId: "", + data: [object], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-documents.md b/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-documents.md index d9db60ce2d..6c124c16e5 100644 --- a/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-documents.md +++ b/docs/examples/1.7.x/server-dotnet/examples/databases/upsert-documents.md @@ -12,5 +12,5 @@ Databases databases = new Databases(client); DocumentList result = await databases.UpsertDocuments( databaseId: "", collectionId: "", - documents: new List() // optional + documents: new List() ); \ No newline at end of file diff --git a/docs/sdks/dotnet/CHANGELOG.md b/docs/sdks/dotnet/CHANGELOG.md index fa4d35e687..43c2eb6520 100644 --- a/docs/sdks/dotnet/CHANGELOG.md +++ b/docs/sdks/dotnet/CHANGELOG.md @@ -1 +1,63 @@ -# Change Log \ No newline at end of file +# Change Log + +## 0.14.0 + +* Refactor from Newtonsoft.Json to System.Text.Json for serialization/deserialization +* Update package dependencies in `Package.csproj.twig` +* Migrate all serialization/deserialization logic in `Client.cs.twig`, `Query.cs.twig`, and `Extensions.cs.twig` +* Update model attributes from `[JsonProperty]` to `[JsonPropertyName]` in `Model.cs.twig` +* Create new `ObjectToInferredTypesConverter.cs.twig` for proper object type handling +* Replace `JsonConverter` with `JsonConverter` in `ValueClassConverter.cs.twig` +* Update error handling to use `JsonDocument` instead of `JObject` + +## 0.13.0 + +* Add `` to doc examples due to the new multi region endpoints +* Add doc examples and methods for bulk api transactions: `createDocuments`, `deleteDocuments` etc. +* Add doc examples, class and methods for new `Sites` service +* Add doc examples, class and methods for new `Tokens` service +* Add enums for `BuildRuntime `, `Adapter`, `Framework`, `DeploymentDownloadType` and `VCSDeploymentType` +* Update enum for `runtimes` with Pythonml312, Dart219, Flutter327 and Flutter329 +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Add `queries` and `search` params to `listMemberships` method +* Remove `search` param from `listExecutions` method + +## 0.12.0 + +* fix: remove content-type from GET requests by @loks0n in https://github.com/appwrite/sdk-for-dotnet/pull/59 +* update: min and max are not optional in methods like `UpdateIntegerAttribute` etc. +* chore: regenerate sdk by @ChiragAgg5k in https://github.com/appwrite/sdk-for-dotnet/pull/60 +* chore: fix build error by @ChiragAgg5k in https://github.com/appwrite/sdk-for-dotnet/pull/61 + +## 0.11.0 + +* Add new push message parameters by @abnegate in https://github.com/appwrite/sdk-for-dotnet/pull/56 + +## 0.10.0 + +* fix: chunk upload by @byawitz in https://github.com/appwrite/sdk-for-dotnet/pull/52 + +## 0.9.0 + +* Support for Appwrite 1.6 +* Added `key` attribute to `Runtime` response model. +* Added `buildSize` attribute to `Deployments` response model. +* Added `scheduledAt` attribute to `Executions` response model. +* Added `scopes` attribute to `Functions` response model. +* Added `specifications` attribute to `Functions` response model. +* Added new response model for `Specifications`. +* Added new response model for `Builds`. +* Added `createJWT()` : Enables creating a JWT using the `userId`. +* Added `listSpecifications()`: Enables listing available runtime specifications. +* Added `deleteExecution()` : Enables deleting executions. +* Added `updateDeploymentBuild()`: Enables cancelling a deployment. +* Added `scheduledAt` parameter to `createExecution()`: Enables creating a delayed execution + +#### Breaking changes +You can find the new syntax for breaking changes in the [Appwrite API references](https://appwrite.io/docs/references). Select version `1.6.x`. +* Removed `otp` parameter from `deleteMFAAuthenticator`. +* Added `scopes` parameter for create/update function. +* Renamed `templateBranch` to `templateVersion` in `createFunction()`. +* Renamed `downloadDeployment()` to `getDeploymentDownload()` + +> **Please note: This version is compatible with Appwrite 1.6 and later only. If you do not update your Appwrite SDK, old SDKs will not break your app. Appwrite APIs are backwards compatible.** From 477682e062a90f69d1460c23ed16b038b763ef8b Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Mon, 14 Jul 2025 16:05:58 -0700 Subject: [PATCH 57/60] fix: prevent injected $user from being shadowed --- app/controllers/api/account.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index f086036872..c0a97a4ad0 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1461,9 +1461,9 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') if (!empty($nameOAuth)) { $name = $nameOAuth; } elseif ($userParam !== null) { - $user = \json_decode($userParam, true); - if (isset($user['name']['firstName']) && isset($user['name']['lastName'])) { - $name = $user['name']['firstName'] . ' ' . $user['name']['lastName']; + $userDecoded = \json_decode($userParam, true); + if (isset($userDecoded['name']['firstName']) && isset($userDecoded['name']['lastName'])) { + $name = $userDecoded['name']['firstName'] . ' ' . $userDecoded['name']['lastName']; } } $email = $oauth2->getUserEmail($accessToken); From 0a82b6d30dc10d83ef99bbcaa0e5da2dd3330f00 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Jul 2025 11:44:30 +0530 Subject: [PATCH 58/60] chore: update CLI to 8.2.1 --- app/config/platforms.php | 2 +- composer.lock | 12 ++++++------ docs/sdks/cli/CHANGELOG.md | 8 ++++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index bfdf445bd3..2be2b4e2e5 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -217,7 +217,7 @@ return [ [ 'key' => 'cli', 'name' => 'Command Line', - 'version' => '8.2.0', + 'version' => '8.2.1', 'url' => 'https://github.com/appwrite/sdk-for-cli', 'package' => 'https://www.npmjs.com/package/appwrite-cli', 'enabled' => true, diff --git a/composer.lock b/composer.lock index c2907b018d..730eb171ab 100644 --- a/composer.lock +++ b/composer.lock @@ -4810,16 +4810,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.41.14", + "version": "0.41.15", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "4ffd03759236214d935cae64a369b487ecfba91f" + "reference": "02a7e0df5a555c7bdfb50cb68db60460afb409e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/4ffd03759236214d935cae64a369b487ecfba91f", - "reference": "4ffd03759236214d935cae64a369b487ecfba91f", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/02a7e0df5a555c7bdfb50cb68db60460afb409e1", + "reference": "02a7e0df5a555c7bdfb50cb68db60460afb409e1", "shasum": "" }, "require": { @@ -4855,9 +4855,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/0.41.14" + "source": "https://github.com/appwrite/sdk-generator/tree/0.41.15" }, - "time": "2025-07-12T06:43:12+00:00" + "time": "2025-07-16T13:00:21+00:00" }, { "name": "doctrine/annotations", diff --git a/docs/sdks/cli/CHANGELOG.md b/docs/sdks/cli/CHANGELOG.md index e233c5e1e2..4512cce0de 100644 --- a/docs/sdks/cli/CHANGELOG.md +++ b/docs/sdks/cli/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 8.2.1 + +* Added `--with-variables` option to the Sites command for adding/updating environment variables +* Fixed Functions environment variables not being pushed with `--with-variables` +* Removed `awaitPools` when wiping old variables + +> **Note:** Storing environment variables in the `vars` attribute of `appwrite.json` is now deprecated due to security risks. Variables are now synced directly from the `.env` file in the root directory of the function’s or site’s folder. + ## 8.2.0 * Add `encrypt` attribute support From 94decb26e675b540e39d72f5d8448aa1c8123190 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 17 Jul 2025 14:05:05 +0100 Subject: [PATCH 59/60] fix: build usage specification --- src/Appwrite/Platform/Modules/Functions/Workers/Builds.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 3ccc6d5eea..890c8572d9 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1303,6 +1303,8 @@ class Builds extends Action protected function sendUsage(Document $resource, Document $deployment, Document $project, StatsUsage $queue): void { + $spec = Config::getParam('specifications')[$resource->getAttribute('specification', APP_COMPUTE_SPECIFICATION_DEFAULT)]; + switch ($deployment->getAttribute('status')) { case 'ready': $queue From 0a5fbb7bc7437cbe1da1df22a02a811710a18fb0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 11:59:32 +1200 Subject: [PATCH 60/60] Handle redirect validator in specs + GraphQL type mapper --- src/Appwrite/GraphQL/Types/Mapper.php | 37 ++++++++++--------- .../SDK/Specification/Format/OpenAPI3.php | 1 + .../SDK/Specification/Format/Swagger2.php | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index 347642e5a1..68eec1eb35 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -267,48 +267,51 @@ class Mapper } switch ((!empty($validator)) ? $validator::class : '') { - case 'Appwrite\Network\Validator\CNAME': - case 'Appwrite\Task\Validator\Cron': - case 'Appwrite\Utopia\Database\Validator\CustomId': - case 'Utopia\Validator\Domain': - case 'Appwrite\Network\Validator\Email': + case 'Appwrite\Auth\Validator\Password': case 'Appwrite\Event\Validator\Event': case 'Appwrite\Event\Validator\FunctionEvent': + case 'Appwrite\Network\Validator\CNAME': + case 'Appwrite\Network\Validator\Email': + case 'Appwrite\Network\Validator\Redirect': + case 'Appwrite\Network\Validator\DNS': + case 'Appwrite\Network\Validator\Origin': + case 'Appwrite\Task\Validator\Cron': + case 'Appwrite\Utopia\Database\Validator\CustomId': + case 'Utopia\Database\Validator\Key': + case 'Utopia\Database\Validator\UID': + case 'Utopia\Validator\Domain': case 'Utopia\Validator\HexColor': case 'Utopia\Validator\Host': case 'Utopia\Validator\IP': - case 'Utopia\Database\Validator\Key': case 'Utopia\Validator\Origin': - case 'Appwrite\Auth\Validator\Password': case 'Utopia\Validator\Text': - case 'Utopia\Database\Validator\UID': case 'Utopia\Validator\URL': case 'Utopia\Validator\WhiteList': default: $type = Type::string(); break; - case 'Utopia\Database\Validator\Authorization': + case 'Appwrite\Utopia\Database\Validator\Queries\Attributes': case 'Appwrite\Utopia\Database\Validator\Queries\Base': case 'Appwrite\Utopia\Database\Validator\Queries\Buckets': case 'Appwrite\Utopia\Database\Validator\Queries\Collections': - case 'Appwrite\Utopia\Database\Validator\Queries\Attributes': - case 'Appwrite\Utopia\Database\Validator\Queries\Indexes': case 'Appwrite\Utopia\Database\Validator\Queries\Databases': case 'Appwrite\Utopia\Database\Validator\Queries\Deployments': - case 'Appwrite\Utopia\Database\Validator\Queries\Installations': - case 'Utopia\Database\Validator\Queries\Documents': case 'Appwrite\Utopia\Database\Validator\Queries\Executions': case 'Appwrite\Utopia\Database\Validator\Queries\Files': case 'Appwrite\Utopia\Database\Validator\Queries\Functions': - case 'Appwrite\Utopia\Database\Validator\Queries\Rules': + case 'Appwrite\Utopia\Database\Validator\Queries\Indexes': + case 'Appwrite\Utopia\Database\Validator\Queries\Installations': case 'Appwrite\Utopia\Database\Validator\Queries\Memberships': - case 'Utopia\Database\Validator\Permissions': case 'Appwrite\Utopia\Database\Validator\Queries\Projects': - case 'Utopia\Database\Validator\Queries': - case 'Utopia\Database\Validator\Roles': + case 'Appwrite\Utopia\Database\Validator\Queries\Rules': case 'Appwrite\Utopia\Database\Validator\Queries\Teams': case 'Appwrite\Utopia\Database\Validator\Queries\Users': case 'Appwrite\Utopia\Database\Validator\Queries\Variables': + case 'Utopia\Database\Validator\Authorization': + case 'Utopia\Database\Validator\Permissions': + case 'Utopia\Database\Validator\Queries': + case 'Utopia\Database\Validator\Queries\Documents': + case 'Utopia\Database\Validator\Roles': $type = Type::listOf(Type::string()); break; case 'Utopia\Validator\Boolean': diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index b808a27f98..1bde6d330f 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -360,6 +360,7 @@ class OpenAPI3 extends Format break; case 'Utopia\Validator\Host': case 'Utopia\Validator\URL': + case 'Appwrite\Network\Validator\Redirect': $node['schema']['type'] = $validator->getType(); $node['schema']['format'] = 'url'; $node['schema']['x-example'] = 'https://example.com'; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index 5142229840..b17d400b48 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -385,6 +385,7 @@ class Swagger2 extends Format break; case 'Utopia\Validator\Host': case 'Utopia\Validator\URL': + case 'Appwrite\Network\Validator\Redirect': $node['type'] = $validator->getType(); $node['format'] = 'url'; $node['x-example'] = 'https://example.com';