From 19ad2088a094b60e6aee4e5eb622b11316afbc89 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 4 Mar 2025 10:08:07 +0200 Subject: [PATCH 01/35] update region --- app/controllers/api/functions.php | 2 +- app/controllers/api/projects.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 4 ++-- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 583468f6c1..0e2d8a0103 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -295,7 +295,7 @@ App::post('/v1/functions') $schedule = Authorization::skip( fn () => $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => $project->getAttribute('region'), 'resourceType' => 'function', 'resourceId' => $function->getId(), 'resourceInternalId' => $function->getInternalId(), diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 48d20cd17f..5099393e68 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -81,7 +81,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', System::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index dad2db0d9a..b62b95b066 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -104,7 +104,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -154,7 +154,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e11181d199..9cb8f21a49 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -183,7 +183,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], From 2a5b3317bf05bed6d57e2278d6dd2904ede59feb Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 4 Mar 2025 11:36:45 +0200 Subject: [PATCH 02/35] update region --- .env | 1 + app/config/variables.php | 9 +++++++++ app/views/install/compose.phtml | 22 +++++++++++++++++++++- docker-compose.yml | 21 +++++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 1893e023ba..9b4aef4ddd 100644 --- a/.env +++ b/.env @@ -1,6 +1,7 @@ _APP_ENV=development _APP_EDITION=self-hosted _APP_LOCALE=en +_APP_REGION=fra _APP_WORKER_PER_CORE=6 _APP_COMPRESSION_MIN_SIZE_BYTES=1024 _APP_CONSOLE_WHITELIST_ROOT=disabled diff --git a/app/config/variables.php b/app/config/variables.php index 98dd9ffec1..2f7a10221d 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -7,6 +7,15 @@ return [ 'category' => 'General', 'description' => '', 'variables' => [ + [ + 'name' => '_APP_REGION', + 'description' => 'Set your server running geo region. By default, the var is set to \'fra\'.', + 'introduction' => '', + 'default' => 'fra', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_ENV', 'description' => 'Set your server running environment. By default, the var is set to \'development\'. When deploying to production, change it to: \'production\'.', diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 62fcd03624..c85fbcafcf 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -164,7 +164,7 @@ $image = $this->getParam('image', ''); - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - _APP_ASSISTANT_OPENAI_API_KEY - + - _APP_REGION appwrite-console: <<: *x-logging container_name: appwrite-console @@ -229,6 +229,7 @@ $image = $this->getParam('image', ''); - _APP_DB_PASS - _APP_USAGE_STATS - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-audits: image: /: @@ -255,6 +256,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-webhooks: image: /: @@ -283,6 +285,7 @@ $image = $this->getParam('image', ''); - _APP_REDIS_USER - _APP_REDIS_PASS - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-deletes: image: /: @@ -342,6 +345,7 @@ $image = $this->getParam('image', ''); - _APP_MAINTENANCE_RETENTION_ABUSE - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_EXECUTION + - _APP_REGION appwrite-worker-databases: image: /: @@ -368,6 +372,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-builds: image: /: @@ -432,6 +437,7 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_SECRET - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET + - _APP_REGION appwrite-worker-certificates: image: /: @@ -465,6 +471,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-functions: image: /: @@ -503,6 +510,7 @@ $image = $this->getParam('image', ''); - _APP_DOCKER_HUB_USERNAME - _APP_DOCKER_HUB_PASSWORD - _APP_LOGGING_CONFIG + - _APP_REGION appwrite-worker-mails: image: /: @@ -537,6 +545,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_DOMAIN - _APP_OPTIONS_FORCE_HTTPS + - _APP_REGION appwrite-worker-messaging: image: /: @@ -588,6 +597,7 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_SECRET - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET + - _APP_REGION appwrite-worker-migrations: image: /: @@ -618,6 +628,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET + - _APP_REGION appwrite-task-maintenance: image: /: @@ -652,6 +663,7 @@ $image = $this->getParam('image', ''); - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES + - _APP_REGION appwrite-task-stats-resources: image: /: @@ -683,6 +695,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL + - _APP_REGION appwrite-worker-stats-resources: image: /: @@ -711,6 +724,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_STATS_RESOURCES_INTERVAL + - _APP_REGION appwrite-worker-stats-usage: image: /: @@ -739,6 +753,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL + - _APP_REGION appwrite-worker-stats-usage-dump: image: /: @@ -767,6 +782,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL + - _APP_REGION appwrite-task-scheduler-functions: image: /: @@ -792,6 +808,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_REGION appwrite-task-scheduler-executions: image: /: @@ -817,6 +834,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_REGION appwrite-task-scheduler-messages: image: /: @@ -842,6 +860,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_REGION appwrite-assistant: image: appwrite/assistant:0.4.0 @@ -877,6 +896,7 @@ $image = $this->getParam('image', ''); - OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV + - OPR_EXECUTOR_REGION=$_APP_REGION - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG diff --git a/docker-compose.yml b/docker-compose.yml index facf0e6db9..51689fd872 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -268,6 +268,7 @@ services: - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-audits: entrypoint: worker-audits @@ -297,6 +298,7 @@ services: - _APP_DB_PASS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-webhooks: entrypoint: worker-webhooks @@ -329,6 +331,7 @@ services: - _APP_LOGGING_CONFIG - _APP_WEBHOOK_MAX_FAILED_ATTEMPTS - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-deletes: entrypoint: worker-deletes @@ -389,6 +392,7 @@ services: - _APP_DATABASE_SHARED_TABLES - _APP_DATABASE_SHARED_TABLES_V1 - _APP_EMAIL_CERTIFICATES + - _APP_REGION appwrite-worker-databases: entrypoint: worker-databases @@ -420,6 +424,7 @@ services: - _APP_WORKERS_NUM - _APP_QUEUE_NAME - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-builds: entrypoint: worker-builds @@ -486,6 +491,7 @@ services: - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-certificates: entrypoint: worker-certificates @@ -521,6 +527,7 @@ services: - _APP_DB_PASS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-functions: entrypoint: worker-functions @@ -563,6 +570,7 @@ services: - _APP_LOGGING_CONFIG - _APP_LOGGING_PROVIDER - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-mails: entrypoint: worker-mails @@ -597,6 +605,7 @@ services: - _APP_DOMAIN - _APP_OPTIONS_FORCE_HTTPS - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-messaging: entrypoint: worker-messaging @@ -652,6 +661,7 @@ services: - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-migrations: entrypoint: worker-migrations @@ -687,6 +697,7 @@ services: - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-task-maintenance: entrypoint: maintenance @@ -725,6 +736,7 @@ services: - _APP_MAINTENANCE_RETENTION_SCHEDULES - _APP_MAINTENANCE_DELAY - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-task-stats-resources: container_name: appwrite-task-stats-resources @@ -756,6 +768,7 @@ services: - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL + - _APP_REGION appwrite-worker-stats-resources: entrypoint: worker-stats-resources @@ -787,6 +800,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-stats-usage: entrypoint: worker-stats-usage @@ -818,6 +832,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-worker-stats-usage-dump: entrypoint: worker-stats-usage-dump @@ -850,6 +865,7 @@ services: - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - _APP_STATS_USAGE_DUAL_WRITING_DBS + - _APP_REGION appwrite-task-scheduler-functions: entrypoint: schedule-functions @@ -878,6 +894,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-task-scheduler-executions: entrypoint: schedule-executions @@ -905,6 +922,7 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS + - _APP_REGION appwrite-task-scheduler-messages: entrypoint: schedule-messages @@ -933,6 +951,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES + - _APP_REGION appwrite-assistant: container_name: appwrite-assistant @@ -966,6 +985,7 @@ services: - OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV + - OPR_EXECUTOR_REGION=$_APP_REGION - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4 @@ -1005,6 +1025,7 @@ services: environment: - OPR_PROXY_WORKER_PER_CORE=$_APP_WORKER_PER_CORE - OPR_PROXY_ENV=$_APP_ENV + - OPR_PROXY_REGION=$_APP_REGION - OPR_PROXY_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG From 4eece99768a78ea1f8c64cd76711aae6cab63397 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 16 Mar 2025 02:35:10 +0000 Subject: [PATCH 03/35] Feat: domains count --- app/init/constants.php | 1 + src/Appwrite/Platform/Workers/StatsResources.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/app/init/constants.php b/app/init/constants.php index 3383b28f57..5e4edfd97d 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -221,6 +221,7 @@ const METRIC_TOPICS = 'topics'; const METRIC_TARGETS = 'targets'; const METRIC_PROVIDER_TYPE_TARGETS = '{providerType}.targets'; const METRIC_KEYS = 'keys'; +const METRIC_DOMAINS = 'domains'; const METRIC_RESOURCE_TYPE_ID_BUILDS = '{resourceType}.{resourceInternalId}.builds'; const METRIC_RESOURCE_TYPE_ID_BUILDS_STORAGE = '{resourceType}.{resourceInternalId}.builds.storage'; const METRIC_RESOURCE_TYPE_ID_DEPLOYMENTS = '{resourceType}.{resourceInternalId}.deployments'; diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 1140698342..3c0e772bd4 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -114,6 +114,13 @@ class StatsResources extends Action $keys = $dbForPlatform->count('keys', [ Query::equal('projectInternalId', [$project->getInternalId()]) ]); + + $domains = $dbForPlatform->count('rules', [ + Query::equal('projectInternalId', [$project->getInternalId()]), + Query::equal('owner', ['']), + ]); + + $databases = $dbForProject->count('databases'); $buckets = $dbForProject->count('buckets'); $users = $dbForProject->count('users'); @@ -162,6 +169,7 @@ class StatsResources extends Action METRIC_PROVIDERS => $providers, METRIC_TOPICS => $topics, METRIC_KEYS => $keys, + METRIC_DOMAINS => $domains, METRIC_TARGETS => $targets, str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets, str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets, From 04711d8c02a341ca9e18e3b820f31a27a19f6c61 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 17 Mar 2025 19:21:31 +1300 Subject: [PATCH 04/35] Add doc --- src/Appwrite/Platform/Workers/Migrations.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index f21a846a0d..4939dc8143 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -34,6 +34,9 @@ class Migrations extends Action protected Document $project; + /** + * @var callable + */ protected $logError; public static function getName(): string From 9cb860d4467f8e087bc1e16e1f6f515c10ad7cee Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 13:52:17 +0200 Subject: [PATCH 05/35] _app_region --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1cd9df243d..ea796682ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,6 +93,7 @@ services: - app/http.php environment: - _APP_ENV + - _APP_REGION - _APP_EDITION - _APP_WORKER_PER_CORE - _APP_LOCALE From 8184bc8c78df84dc04a8c0514edda828a26f061d Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 17:31:24 +0200 Subject: [PATCH 06/35] _app_region --- .env | 2 +- app/config/variables.php | 4 ++-- app/controllers/api/projects.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 4 ++-- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 9b4aef4ddd..ae4522c898 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ _APP_ENV=development _APP_EDITION=self-hosted _APP_LOCALE=en -_APP_REGION=fra +_APP_REGION=default _APP_WORKER_PER_CORE=6 _APP_COMPRESSION_MIN_SIZE_BYTES=1024 _APP_CONSOLE_WHITELIST_ROOT=disabled diff --git a/app/config/variables.php b/app/config/variables.php index 2f7a10221d..592d398062 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -9,9 +9,9 @@ return [ 'variables' => [ [ 'name' => '_APP_REGION', - 'description' => 'Set your server running geo region. By default, the var is set to \'fra\'.', + 'description' => 'Set your server running geo region. By default, the var is set to \'default\'.', 'introduction' => '', - 'default' => 'fra', + 'default' => 'default', 'required' => false, 'question' => '', 'filter' => '' diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 5099393e68..2f46c3c338 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -81,7 +81,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', System::getEnv('_APP_REGION'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION','default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index b62b95b066..b96fd5622f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -104,7 +104,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION','default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -154,7 +154,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION','default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e8195d175d..624948e2f5 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -183,7 +183,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION','default')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], From 59f613f9bbda26a3019feb283b6de0f27b88af93 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 17:33:48 +0200 Subject: [PATCH 07/35] _app_region --- app/controllers/api/projects.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 4 ++-- src/Appwrite/Platform/Workers/Deletes.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 2f46c3c338..48d20cd17f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -81,7 +81,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', System::getEnv('_APP_REGION','default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index b96fd5622f..dad2db0d9a 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -104,7 +104,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION','default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -154,7 +154,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION','default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 624948e2f5..9b0590181a 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -183,7 +183,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [System::getEnv('_APP_REGION','default')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], From 7149deeacb498429a756987d1a5990ca82a164d6 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 18:11:49 +0200 Subject: [PATCH 08/35] _app_region --- .env | 2 +- app/config/regions.php | 7 ------ app/config/variables.php | 2 +- app/controllers/api/functions.php | 2 +- app/controllers/api/messaging.php | 12 +++++----- app/controllers/api/projects.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 4 ++-- src/Appwrite/Platform/Workers/Deletes.php | 2 +- .../Platform/Workers/StatsUsageDump.php | 4 ++-- tests/e2e/Scopes/ProjectCustom.php | 2 +- .../Projects/ProjectsConsoleClientTest.php | 22 +++++++++---------- 11 files changed, 27 insertions(+), 34 deletions(-) diff --git a/.env b/.env index ae4522c898..9b4aef4ddd 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ _APP_ENV=development _APP_EDITION=self-hosted _APP_LOCALE=en -_APP_REGION=default +_APP_REGION=fra _APP_WORKER_PER_CORE=6 _APP_COMPRESSION_MIN_SIZE_BYTES=1024 _APP_CONSOLE_WHITELIST_ROOT=disabled diff --git a/app/config/regions.php b/app/config/regions.php index 61029a9996..0b32d2ba4b 100644 --- a/app/config/regions.php +++ b/app/config/regions.php @@ -1,13 +1,6 @@ [ - '$id' => 'default', - 'name' => 'Frankfurt', - 'disabled' => false, - 'flag' => 'de', - 'default' => true, - ], 'fra' => [ '$id' => 'fra', 'name' => 'Frankfurt', diff --git a/app/config/variables.php b/app/config/variables.php index 592d398062..7c774e8d6a 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -9,7 +9,7 @@ return [ 'variables' => [ [ 'name' => '_APP_REGION', - 'description' => 'Set your server running geo region. By default, the var is set to \'default\'.', + 'description' => 'Set your server running geo region. By default, the var is set to \'fra\'.', 'introduction' => '', 'default' => 'default', 'required' => false, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 1483c3bf03..37932e4165 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -2079,7 +2079,7 @@ App::post('/v1/functions/:functionId/executions') ]; $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => ScheduleExecutions::getSupportedResource(), 'resourceId' => $execution->getId(), 'resourceInternalId' => $execution->getInternalId(), diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 9393f1fbfe..4812fab0f3 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -2936,7 +2936,7 @@ App::post('/v1/messaging/messages/email') break; case MessageStatus::SCHEDULED: $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3058,7 +3058,7 @@ App::post('/v1/messaging/messages/sms') break; case MessageStatus::SCHEDULED: $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3275,7 +3275,7 @@ App::post('/v1/messaging/messages/push') break; case MessageStatus::SCHEDULED: $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3661,7 +3661,7 @@ App::patch('/v1/messaging/messages/email/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -3862,7 +3862,7 @@ App::patch('/v1/messaging/messages/sms/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), @@ -4035,7 +4035,7 @@ App::patch('/v1/messaging/messages/push/:messageId') if (\is_null($currentScheduledAt) && !\is_null($scheduledAt)) { $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 48d20cd17f..5099393e68 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -81,7 +81,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', System::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index dad2db0d9a..b62b95b066 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -104,7 +104,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -154,7 +154,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 9b0590181a..e8195d175d 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -183,7 +183,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), + Query::equal('region', [System::getEnv('_APP_REGION')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], diff --git a/src/Appwrite/Platform/Workers/StatsUsageDump.php b/src/Appwrite/Platform/Workers/StatsUsageDump.php index 119a9e7288..3100a39dea 100644 --- a/src/Appwrite/Platform/Workers/StatsUsageDump.php +++ b/src/Appwrite/Platform/Workers/StatsUsageDump.php @@ -157,7 +157,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION'), ]); $documentClone = new Document($document->getArrayCopy()); @@ -191,7 +191,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION'), ]); $documentClone = new Document($document->getArrayCopy()); $dbForProject->createOrUpdateDocumentsWithIncrease( diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 7f84ace6f2..2799e29772 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -42,7 +42,7 @@ trait ProjectCustom 'x-appwrite-project' => 'console', ], [ 'projectId' => ID::unique(), - 'region' => 'default', + 'region' => 'fra', 'name' => 'Demo Project', 'teamId' => $team['body']['$id'], 'description' => 'Demo Project Description', diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index a6498b8a4e..16a18d27c1 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -49,7 +49,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default', + 'region' => 'fra', ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -89,7 +89,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => '', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -100,7 +100,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'projectId' => ID::unique(), 'name' => 'Project Test', - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -129,7 +129,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => $projectId, 'name' => 'Project Duplicate', 'teamId' => $teamId, - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(409, $response['headers']['status-code']); @@ -178,7 +178,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Team 1 Project', 'teamId' => $team1, - 'region' => 'default', + 'region' => 'fra', ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -277,7 +277,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test 2', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -2042,7 +2042,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -2135,7 +2135,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3749,7 +3749,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project', 'teamId' => $teamId, - 'region' => 'default' + 'region' => 'fra' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3820,7 +3820,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 1', 'teamId' => $teamId, - 'region' => 'default' + 'region' => 'fra' ]); $project2 = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ @@ -3830,7 +3830,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 2', 'teamId' => $teamId, - 'region' => 'default' + 'region' => 'fra' ]); $project1Id = $project1['body']['$id']; From 60912cb0845bb5787126171608a54bcb11619049 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 18:14:58 +0200 Subject: [PATCH 09/35] _app_region --- app/controllers/api/messaging.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 4812fab0f3..178266db60 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -3058,7 +3058,7 @@ App::post('/v1/messaging/messages/sms') break; case MessageStatus::SCHEDULED: $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION'), + 'region' => $project->getAttribute('region'), 'resourceType' => 'message', 'resourceId' => $message->getId(), 'resourceInternalId' => $message->getInternalId(), From e5261e7d70d62ff0ef398facb58f65f1a64247d1 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 17 Mar 2025 18:31:14 +0200 Subject: [PATCH 10/35] _app_region --- src/Appwrite/Migration/Version/V20.php | 2 +- tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index 5a0807cedf..cca0d9244b 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -426,7 +426,7 @@ class V20 extends Migration 'period' => 'inf', 'value' => $value, 'time' => null, - 'region' => 'default', + 'region' => 'fra', ])); } catch (Duplicate $th) { Console::warning("Error while creating inf metric: duplicate id {$metric} {$id}"); diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 914a255663..5e24dc4d89 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -111,7 +111,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('default', $output['APPWRITE_REGION']); + $this->assertEquals('fra', $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); @@ -221,7 +221,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('default', $output['APPWRITE_REGION']); + $this->assertEquals('fra', $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); From a7165e6a32a0c731e0a10939935b863fcb824573 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Mar 2025 16:51:00 +1300 Subject: [PATCH 11/35] Disable PDO persistence since we manage our own pool --- app/init/registers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init/registers.php b/app/init/registers.php index 9c90eb54d2..1ebcbc1691 100644 --- a/app/init/registers.php +++ b/app/init/registers.php @@ -217,7 +217,7 @@ $register->set('pools', function () { return new PDOProxy(function () use ($dsnHost, $dsnPort, $dsnUser, $dsnPass, $dsnDatabase) { return new PDO("mysql:host={$dsnHost};port={$dsnPort};dbname={$dsnDatabase};charset=utf8mb4", $dsnUser, $dsnPass, array( PDO::ATTR_TIMEOUT => 3, // Seconds - PDO::ATTR_PERSISTENT => true, + PDO::ATTR_PERSISTENT => false, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_STRINGIFY_FETCHES => true From e43a3109eb98b46400c19f119d81220f6ea8b81e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Mar 2025 20:05:12 +1300 Subject: [PATCH 12/35] Update migration lib --- composer.json | 2 +- composer.lock | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 53c2a6d482..b604d6d1b8 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,7 @@ "utopia-php/locale": "0.4.*", "utopia-php/logger": "0.6.*", "utopia-php/messaging": "0.16.*", - "utopia-php/migration": "0.6.*", + "utopia-php/migration": "0.8.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", "utopia-php/pools": "0.5.*", diff --git a/composer.lock b/composer.lock index ed19d10202..2e5e6738e6 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": "44c6436ced36b0b026139edba252052e", + "content-hash": "ef36941f461409608974a804999f6787", "packages": [ { "name": "adhocore/jwt", @@ -4159,16 +4159,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.22", + "version": "0.8.0", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "a0269746bd318ff0993f5aa008675b971689d5b5" + "reference": "d8245090a7c55ea3c1fc411815b06bad0d5bcdd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/a0269746bd318ff0993f5aa008675b971689d5b5", - "reference": "a0269746bd318ff0993f5aa008675b971689d5b5", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/d8245090a7c55ea3c1fc411815b06bad0d5bcdd8", + "reference": "d8245090a7c55ea3c1fc411815b06bad0d5bcdd8", "shasum": "" }, "require": { @@ -4209,9 +4209,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.22" + "source": "https://github.com/utopia-php/migration/tree/0.8.0" }, - "time": "2025-03-13T07:35:55+00:00" + "time": "2025-03-18T06:52:33+00:00" }, { "name": "utopia-php/mongo", @@ -4760,16 +4760,16 @@ }, { "name": "utopia-php/telemetry", - "version": "0.1.0", + "version": "0.1.1", "source": { "type": "git", "url": "https://github.com/utopia-php/telemetry.git", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80" + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", - "reference": "d35f2f0632f4ee0be63fb7ace6a94a6adda71a80", + "url": "https://api.github.com/repos/utopia-php/telemetry/zipball/437f0021777f0e575dfb9e8a1a081b3aed75e33f", + "reference": "437f0021777f0e575dfb9e8a1a081b3aed75e33f", "shasum": "" }, "require": { @@ -4790,7 +4790,7 @@ "type": "library", "autoload": { "psr-4": { - "Utopia\\": "src/" + "Utopia\\Telemetry\\": "src/Telemetry" } }, "notification-url": "https://packagist.org/downloads/", @@ -4804,9 +4804,9 @@ ], "support": { "issues": "https://github.com/utopia-php/telemetry/issues", - "source": "https://github.com/utopia-php/telemetry/tree/0.1.0" + "source": "https://github.com/utopia-php/telemetry/tree/0.1.1" }, - "time": "2024-11-13T10:29:53+00:00" + "time": "2025-03-17T11:57:52+00:00" }, { "name": "utopia-php/vcs", @@ -5043,16 +5043,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.40.7", + "version": "0.40.9", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873" + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/9e89b0bc4d8e6c81817d27096629f34a149fa873", - "reference": "9e89b0bc4d8e6c81817d27096629f34a149fa873", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/dbb45a5db22cdc3368fe2573c07ba6088f188fa4", + "reference": "dbb45a5db22cdc3368fe2573c07ba6088f188fa4", "shasum": "" }, "require": { @@ -5088,9 +5088,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.40.7" + "source": "https://github.com/appwrite/sdk-generator/tree/0.40.9" }, - "time": "2025-03-12T08:43:55+00:00" + "time": "2025-03-17T18:39:14+00:00" }, { "name": "doctrine/annotations", From fe308b4f1f86ad97bdb6ef0e3f46becb6b4c5bf2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Mar 2025 20:49:19 +1300 Subject: [PATCH 13/35] Update lib --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 2e5e6738e6..07e77a9037 100644 --- a/composer.lock +++ b/composer.lock @@ -4159,16 +4159,16 @@ }, { "name": "utopia-php/migration", - "version": "0.8.0", + "version": "0.8.1", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "d8245090a7c55ea3c1fc411815b06bad0d5bcdd8" + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/d8245090a7c55ea3c1fc411815b06bad0d5bcdd8", - "reference": "d8245090a7c55ea3c1fc411815b06bad0d5bcdd8", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", "shasum": "" }, "require": { @@ -4209,9 +4209,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.8.0" + "source": "https://github.com/utopia-php/migration/tree/0.8.1" }, - "time": "2025-03-18T06:52:33+00:00" + "time": "2025-03-18T07:48:08+00:00" }, { "name": "utopia-php/mongo", From aa5ea7f3a10f632d87c1dbbf334104c2c38d4135 Mon Sep 17 00:00:00 2001 From: Fabian Gruber Date: Tue, 18 Mar 2025 10:01:06 +0100 Subject: [PATCH 14/35] feat: add pool telemetry --- composer.json | 2 +- composer.lock | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index b604d6d1b8..d7b8505b5c 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,7 @@ "utopia-php/migration": "0.8.*", "utopia-php/orchestration": "0.9.*", "utopia-php/platform": "0.7.*", - "utopia-php/pools": "0.5.*", + "utopia-php/pools": "0.7.*", "utopia-php/preloader": "0.2.*", "utopia-php/queue": "0.9.*", "utopia-php/registry": "0.5.*", diff --git a/composer.lock b/composer.lock index 07e77a9037..cdba756c72 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": "ef36941f461409608974a804999f6787", + "content-hash": "e0d7f21b681e4591144fec16c4f0d6aa", "packages": [ { "name": "adhocore/jwt", @@ -4375,25 +4375,26 @@ }, { "name": "utopia-php/pools", - "version": "0.5.0", + "version": "0.7.0", "source": { "type": "git", "url": "https://github.com/utopia-php/pools.git", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817" + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/pools/zipball/6f716a213a08db95eda1b5dddfa90983c1834817", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817", + "url": "https://api.github.com/repos/utopia-php/pools/zipball/ad64d45afda08ec8b29e2642a8d18075964d40bf", + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf", "shasum": "" }, "require": { - "php": ">=8.0" + "php": ">=8.3", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { - "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.8.*", - "phpunit/phpunit": "^9.3" + "laravel/pint": "1.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -4420,9 +4421,9 @@ ], "support": { "issues": "https://github.com/utopia-php/pools/issues", - "source": "https://github.com/utopia-php/pools/tree/0.5.0" + "source": "https://github.com/utopia-php/pools/tree/0.7.0" }, - "time": "2024-04-19T11:11:54+00:00" + "time": "2025-03-18T03:55:33+00:00" }, { "name": "utopia-php/preloader", @@ -8402,7 +8403,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 70e27748be399a05cacf1bc222b49dac1198731e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 18 Mar 2025 12:52:41 +0000 Subject: [PATCH 15/35] chore: set min operations to 1 for reads and writes --- app/controllers/api/databases.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d8d496089c..2a1ec4cba4 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3355,7 +3355,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') $processDocument($collection, $document); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, $operations) + ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, min($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations) ->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection @@ -3520,7 +3520,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') } $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_READS, $operations) + ->addMetric(METRIC_DATABASES_OPERATIONS_READS, min($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations); $response->addHeader('X-Debug-Operations', $operations); @@ -3661,7 +3661,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen $processDocument($collection, $document); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_READS, $operations) + ->addMetric(METRIC_DATABASES_OPERATIONS_READS, min($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations); $response->addHeader('X-Debug-Operations', $operations); @@ -3959,7 +3959,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum $setCollection($collection, $newDocument); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, $operations) + ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, min($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations); $response->addHeader('X-Debug-Operations', $operations); From aab8bca91e98fcdc42fc854853e6d0725fee86ce Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 18 Mar 2025 14:20:25 +0000 Subject: [PATCH 16/35] fix: logic --- app/controllers/api/databases.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 2a1ec4cba4..0c37e1a765 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -3355,7 +3355,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') $processDocument($collection, $document); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, min($operations, 1)) + ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, max($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations) ->addMetric(str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$database->getInternalId(), $collection->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_STORAGE), 1); // per collection @@ -3520,7 +3520,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') } $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_READS, min($operations, 1)) + ->addMetric(METRIC_DATABASES_OPERATIONS_READS, max($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations); $response->addHeader('X-Debug-Operations', $operations); @@ -3661,7 +3661,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen $processDocument($collection, $document); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_READS, min($operations, 1)) + ->addMetric(METRIC_DATABASES_OPERATIONS_READS, max($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_READS), $operations); $response->addHeader('X-Debug-Operations', $operations); @@ -3959,7 +3959,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum $setCollection($collection, $newDocument); $queueForStatsUsage - ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, min($operations, 1)) + ->addMetric(METRIC_DATABASES_OPERATIONS_WRITES, max($operations, 1)) ->addMetric(str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_OPERATIONS_WRITES), $operations); $response->addHeader('X-Debug-Operations', $operations); From ffb86ace3812c94e1be40d7c1b574f891e521a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 15:29:21 +0100 Subject: [PATCH 17/35] Add latest info detail to site & function --- app/config/collections/projects.php | 101 ++++++++++++++++-- app/controllers/api/vcs.php | 7 ++ .../Platform/Modules/Compute/Base.php | 14 +++ .../Functions/Http/Deployments/Create.php | 14 +++ .../Http/Deployments/Duplicate/Create.php | 7 ++ .../Http/Deployments/Status/Update.php | 5 + .../Http/Deployments/Template/Create.php | 7 ++ .../Modules/Functions/Workers/Builds.php | 20 ++++ .../Modules/Sites/Http/Deployments/Create.php | 14 +++ .../Http/Deployments/Duplicate/Create.php | 7 ++ .../Sites/Http/Deployments/Status/Update.php | 5 + .../Http/Deployments/Template/Create.php | 7 ++ 12 files changed, 197 insertions(+), 11 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index f9a44e169c..c9ab10ddcf 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -590,6 +590,51 @@ return [ 'array' => false, 'filters' => ['datetime'], ], + [ + '$id' => ID::custom('latestDeploymentId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('latestDeploymentInternalId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('latestDeploymentCreatedAt'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + + [ + '$id' => ID::custom('latestDeploymentStatus'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => '', + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('vars'), 'type' => Database::VAR_STRING, @@ -1003,17 +1048,6 @@ return [ 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('deploymentId'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => Database::LENGTH_KEY, - 'signed' => true, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => [], - ], [ '$id' => ID::custom('deploymentCreatedAt'), 'type' => Database::VAR_DATETIME, @@ -1047,6 +1081,51 @@ return [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('latestDeploymentId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('latestDeploymentInternalId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('latestDeploymentCreatedAt'), + 'type' => Database::VAR_DATETIME, + 'format' => '', + 'size' => 0, + 'signed' => false, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => ['datetime'], + ], + + [ + '$id' => ID::custom('latestDeploymentStatus'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16, + 'signed' => true, + 'required' => false, + 'default' => '', + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('vars'), 'type' => Database::VAR_STRING, diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 89a0e251d4..107be3d888 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -253,6 +253,13 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'activate' => $activate, ])); + $resource = $resource + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + if ($resource->getCollection() === 'sites') { $projectId = $project->getId(); diff --git a/src/Appwrite/Platform/Modules/Compute/Base.php b/src/Appwrite/Platform/Modules/Compute/Base.php index 1e70c106a7..6d44be239d 100644 --- a/src/Appwrite/Platform/Modules/Compute/Base.php +++ b/src/Appwrite/Platform/Modules/Compute/Base.php @@ -94,6 +94,13 @@ class Base extends Action 'activate' => $activate, ])); + $function = $function + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); + $queueForBuilds ->setType(BUILD_TYPE_DEPLOYMENT) ->setResource($function) @@ -185,6 +192,13 @@ class Base extends Action 'activate' => $activate, ])); + $site = $site + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php index 1f49568249..00c4f402a1 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Create.php @@ -240,6 +240,13 @@ class Create extends Action 'sourceMetadata' => $metadata, 'type' => $type ])); + + $function = $function + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); } else { $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment->setAttribute('sourceSize', $fileSize)->setAttribute('sourceMetadata', $metadata)); } @@ -273,6 +280,13 @@ class Create extends Action 'sourceMetadata' => $metadata, 'type' => $type ])); + + $function = $function + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); } else { $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment->setAttribute('sourceChunksUploaded', $chunksUploaded)->setAttribute('sourceMetadata', $metadata)); } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php index aa1142570b..eb672dacf9 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Duplicate/Create.php @@ -113,6 +113,13 @@ class Create extends Action 'buildLogs' => '', ])); + $function = $function + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); + $queueForBuilds ->setType(BUILD_TYPE_DEPLOYMENT) ->setResource($function) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php index 6d5cc145c9..053a10f982 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Status/Update.php @@ -95,6 +95,11 @@ class Update extends Action 'status' => 'canceled' ])); + if ($deployment->getInternalId() === $function->getAttribute('latestDeploymentInternalId', '')) { + $function = $function->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); + } + try { $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); $executor->deleteRuntime($project->getId(), $deploymentId . "-build"); diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php index 9d48c1c112..98a975545d 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Template/Create.php @@ -150,6 +150,13 @@ class Create extends Base 'activate' => $activate, ])); + $function = $function + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('functions', $function->getId(), $function); + $queueForBuilds ->setType(BUILD_TYPE_DEPLOYMENT) ->setResource($function) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 16b2e08be1..82dbd99292 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -211,6 +211,11 @@ class Builds extends Action $deployment->setAttribute('status', 'processing'); $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); + if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + } + $queueForRealtime ->setPayload($deployment->getArrayCopy()) ->trigger(); @@ -452,6 +457,11 @@ class Builds extends Action $deployment->setAttribute('status', 'building'); $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment); + if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + } + $queueForRealtime ->setPayload($deployment->getArrayCopy()) ->trigger(); @@ -732,6 +742,11 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); + if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + } + $queueForRealtime ->setPayload($deployment->getArrayCopy()) ->trigger(); @@ -1017,6 +1032,11 @@ class Builds extends Action $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment); + if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) { + $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource); + } + $queueForRealtime ->setPayload($deployment->getArrayCopy()) ->trigger(); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index c52f958da5..ab2d9282ac 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -250,6 +250,13 @@ class Create extends Action 'type' => $type ])); + $site = $site + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; @@ -310,6 +317,13 @@ class Create extends Action 'type' => $type ])); + $site = $site + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; $ruleId = md5($domain); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 9982828ec2..9e33a6b839 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -126,6 +126,13 @@ class Create extends Action 'buildLogs' => '', ])); + $site = $site + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + // Preview deployments for sites $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php index 0361c1bc9c..1970fa898e 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Status/Update.php @@ -93,6 +93,11 @@ class Update extends Action 'status' => 'canceled' ])); + if ($deployment->getInternalId() === $site->getAttribute('latestDeploymentInternalId', '')) { + $site = $site->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + } + try { $executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST')); $executor->deleteRuntime($project->getId(), $deploymentId . "-build"); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index 6e077f2713..c3a4b3ca96 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -161,6 +161,13 @@ class Create extends Base 'activate' => $activate, ])); + $site = $site + ->setAttribute('latestDeploymentId', $deployment->getId()) + ->setAttribute('latestDeploymentInternalId', $deployment->getInternalId()) + ->setAttribute('latestDeploymentCreatedAt', $deployment->getCreatedAt()) + ->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', '')); + $dbForProject->updateDocument('sites', $site->getId(), $site); + $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); $domain = ID::unique() . "." . $sitesDomain; From e75441a0973ef66f0ca7b5e4c8abbed79b37423c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 18 Mar 2025 15:46:28 +0100 Subject: [PATCH 18/35] =?UTF-8?q?Didn't=20mean=20to=20remove=20that=20?= =?UTF-8?q?=F0=9F=8E=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/collections/projects.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index c9ab10ddcf..ffae763f6b 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1048,6 +1048,17 @@ return [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('deploymentId'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => Database::LENGTH_KEY, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('deploymentCreatedAt'), 'type' => Database::VAR_DATETIME, From e9841e53b9995091d64b665addcd1d2389740d25 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 21:40:46 +0200 Subject: [PATCH 19/35] revert --- .env | 1 - app/config/regions.php | 63 +------------------ app/config/variables.php | 9 --- app/controllers/api/projects.php | 2 +- app/views/install/compose.phtml | 37 +++++------ docker-compose.yml | 40 ++++++------ src/Appwrite/Migration/Version/V20.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 4 +- src/Appwrite/Platform/Workers/Deletes.php | 2 +- .../Platform/Workers/StatsUsageDump.php | 4 +- tests/e2e/Scopes/ProjectCustom.php | 2 +- .../Functions/FunctionsCustomClientTest.php | 4 +- .../Projects/ProjectsConsoleClientTest.php | 22 +++---- 13 files changed, 60 insertions(+), 132 deletions(-) diff --git a/.env b/.env index 9b4aef4ddd..1893e023ba 100644 --- a/.env +++ b/.env @@ -1,7 +1,6 @@ _APP_ENV=development _APP_EDITION=self-hosted _APP_LOCALE=en -_APP_REGION=fra _APP_WORKER_PER_CORE=6 _APP_COMPRESSION_MIN_SIZE_BYTES=1024 _APP_CONSOLE_WHITELIST_ROOT=disabled diff --git a/app/config/regions.php b/app/config/regions.php index 0b32d2ba4b..05e04930fe 100644 --- a/app/config/regions.php +++ b/app/config/regions.php @@ -1,67 +1,10 @@ [ - '$id' => 'fra', - 'name' => 'Frankfurt', + 'default' => [ + '$id' => 'default', + 'name' => 'default', 'disabled' => false, - 'flag' => 'de', - 'default' => true, - ], - 'nyc' => [ - '$id' => 'nyc', - 'name' => 'New York', - 'disabled' => true, - 'flag' => 'us', - 'default' => true, - ], - 'sfo' => [ - '$id' => 'sfo', - 'name' => 'San Francisco', - 'disabled' => true, - 'flag' => 'us', - 'default' => true, - ], - 'blr' => [ - '$id' => 'blr', - 'name' => 'Bengaluru', - 'disabled' => true, - 'flag' => 'in', - 'default' => true, - ], - 'lon' => [ - '$id' => 'lon', - 'name' => 'London', - 'disabled' => true, - 'flag' => 'gb', - 'default' => true, - ], - 'ams' => [ - '$id' => 'ams', - 'name' => 'Amsterdam', - 'disabled' => true, - 'flag' => 'nl', - 'default' => true, - ], - 'sgp' => [ - '$id' => 'sgp', - 'name' => 'Singapore', - 'disabled' => true, - 'flag' => 'sg', - 'default' => true, - ], - 'tor' => [ - '$id' => 'tor', - 'name' => 'Toronto', - 'disabled' => true, - 'flag' => 'ca', - 'default' => true, - ], - 'syd' => [ - '$id' => 'syd', - 'name' => 'Sydney', - 'disabled' => true, - 'flag' => 'au', 'default' => true, ], ]; diff --git a/app/config/variables.php b/app/config/variables.php index 7c774e8d6a..98dd9ffec1 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -7,15 +7,6 @@ return [ 'category' => 'General', 'description' => '', 'variables' => [ - [ - 'name' => '_APP_REGION', - 'description' => 'Set your server running geo region. By default, the var is set to \'fra\'.', - 'introduction' => '', - 'default' => 'default', - 'required' => false, - 'question' => '', - 'filter' => '' - ], [ 'name' => '_APP_ENV', 'description' => 'Set your server running environment. By default, the var is set to \'development\'. When deploying to production, change it to: \'production\'.', diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 5099393e68..48d20cd17f 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -81,7 +81,7 @@ App::post('/v1/projects') ->param('projectId', '', new ProjectId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') - ->param('region', System::getEnv('_APP_REGION'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) + ->param('region', System::getEnv('_APP_REGION', 'default'), new Whitelist(array_keys(array_filter(Config::getParam('regions'), fn ($config) => !$config['disabled']))), 'Project Region.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 344a433103..77cf21efd2 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -164,7 +164,6 @@ $image = $this->getParam('image', ''); - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - _APP_ASSISTANT_OPENAI_API_KEY - - _APP_REGION appwrite-console: <<: *x-logging container_name: appwrite-console @@ -229,7 +228,6 @@ $image = $this->getParam('image', ''); - _APP_DB_PASS - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - - _APP_REGION appwrite-worker-audits: image: /: @@ -256,7 +254,6 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG - - _APP_REGION appwrite-worker-webhooks: image: /: @@ -285,7 +282,6 @@ $image = $this->getParam('image', ''); - _APP_REDIS_USER - _APP_REDIS_PASS - _APP_LOGGING_CONFIG - - _APP_REGION appwrite-worker-deletes: image: /: @@ -347,7 +343,7 @@ $image = $this->getParam('image', ''); - _APP_MAINTENANCE_RETENTION_EXECUTION - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS - _APP_EMAIL_CERTIFICATES - - _APP_REGION + appwrite-worker-databases: image: /: @@ -374,7 +370,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG - - _APP_REGION + appwrite-worker-builds: image: /: @@ -439,7 +435,7 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_SECRET - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - - _APP_REGION + appwrite-worker-certificates: image: /: @@ -473,7 +469,7 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - _APP_LOGGING_CONFIG - - _APP_REGION + appwrite-worker-functions: image: /: @@ -512,7 +508,7 @@ $image = $this->getParam('image', ''); - _APP_DOCKER_HUB_USERNAME - _APP_DOCKER_HUB_PASSWORD - _APP_LOGGING_CONFIG - - _APP_REGION + appwrite-worker-mails: image: /: @@ -547,7 +543,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_DOMAIN - _APP_OPTIONS_FORCE_HTTPS - - _APP_REGION + appwrite-worker-messaging: image: /: @@ -599,7 +595,7 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_SECRET - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - - _APP_REGION + appwrite-worker-migrations: image: /: @@ -630,7 +626,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - - _APP_REGION + appwrite-task-maintenance: image: /: @@ -665,7 +661,7 @@ $image = $this->getParam('image', ''); - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES - - _APP_REGION + appwrite-task-stats-resources: image: /: @@ -697,7 +693,7 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL - - _APP_REGION + appwrite-worker-stats-resources: image: /: @@ -726,7 +722,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_STATS_RESOURCES_INTERVAL - - _APP_REGION + appwrite-worker-stats-usage: image: /: @@ -755,7 +751,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - - _APP_REGION + appwrite-worker-stats-usage-dump: image: /: @@ -784,7 +780,7 @@ $image = $this->getParam('image', ''); - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - - _APP_REGION + appwrite-task-scheduler-functions: image: /: @@ -810,7 +806,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REGION + appwrite-task-scheduler-executions: image: /: @@ -836,7 +832,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REGION + appwrite-task-scheduler-messages: image: /: @@ -862,7 +858,7 @@ $image = $this->getParam('image', ''); - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REGION + appwrite-assistant: image: appwrite/assistant:0.4.0 @@ -898,7 +894,6 @@ $image = $this->getParam('image', ''); - OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV - - OPR_EXECUTOR_REGION=$_APP_REGION - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG diff --git a/docker-compose.yml b/docker-compose.yml index ea796682ba..f1451426e8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,7 +93,7 @@ services: - app/http.php environment: - _APP_ENV - - _APP_REGION + - _APP_EDITION - _APP_WORKER_PER_CORE - _APP_LOCALE @@ -269,7 +269,7 @@ services: - _APP_USAGE_STATS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-audits: entrypoint: worker-audits @@ -299,7 +299,7 @@ services: - _APP_DB_PASS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-webhooks: entrypoint: worker-webhooks @@ -332,7 +332,7 @@ services: - _APP_LOGGING_CONFIG - _APP_WEBHOOK_MAX_FAILED_ATTEMPTS - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-deletes: entrypoint: worker-deletes @@ -393,7 +393,7 @@ services: - _APP_DATABASE_SHARED_TABLES - _APP_DATABASE_SHARED_TABLES_V1 - _APP_EMAIL_CERTIFICATES - - _APP_REGION + appwrite-worker-databases: entrypoint: worker-databases @@ -425,7 +425,7 @@ services: - _APP_WORKERS_NUM - _APP_QUEUE_NAME - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-builds: entrypoint: worker-builds @@ -492,7 +492,7 @@ services: - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-certificates: entrypoint: worker-certificates @@ -528,7 +528,7 @@ services: - _APP_DB_PASS - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-functions: entrypoint: worker-functions @@ -571,7 +571,7 @@ services: - _APP_LOGGING_CONFIG - _APP_LOGGING_PROVIDER - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-mails: entrypoint: worker-mails @@ -606,7 +606,7 @@ services: - _APP_DOMAIN - _APP_OPTIONS_FORCE_HTTPS - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-messaging: entrypoint: worker-messaging @@ -662,7 +662,7 @@ services: - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-migrations: entrypoint: worker-migrations @@ -698,7 +698,7 @@ services: - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-task-maintenance: entrypoint: maintenance @@ -737,7 +737,7 @@ services: - _APP_MAINTENANCE_RETENTION_SCHEDULES - _APP_MAINTENANCE_DELAY - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-task-stats-resources: container_name: appwrite-task-stats-resources @@ -769,7 +769,7 @@ services: - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL - - _APP_REGION + appwrite-worker-stats-resources: entrypoint: worker-stats-resources @@ -801,7 +801,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-stats-usage: entrypoint: worker-stats-usage @@ -833,7 +833,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-worker-stats-usage-dump: entrypoint: worker-stats-usage-dump @@ -866,7 +866,7 @@ services: - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - _APP_STATS_USAGE_DUAL_WRITING_DBS - - _APP_REGION + appwrite-task-scheduler-functions: entrypoint: schedule-functions @@ -895,7 +895,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-task-scheduler-executions: entrypoint: schedule-executions @@ -923,7 +923,7 @@ services: - _APP_DB_SCHEMA - _APP_DB_USER - _APP_DB_PASS - - _APP_REGION + appwrite-task-scheduler-messages: entrypoint: schedule-messages @@ -952,7 +952,7 @@ services: - _APP_DB_USER - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES - - _APP_REGION + appwrite-assistant: container_name: appwrite-assistant diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index cca0d9244b..5a0807cedf 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -426,7 +426,7 @@ class V20 extends Migration 'period' => 'inf', 'value' => $value, 'time' => null, - 'region' => 'fra', + 'region' => 'default', ])); } catch (Duplicate $th) { Console::warning("Error while creating inf metric: duplicate id {$metric} {$id}"); diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index b62b95b066..dad2db0d9a 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -104,7 +104,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::equal('active', [true]), ])); @@ -154,7 +154,7 @@ abstract class ScheduleBase extends Action } $results = $dbForPlatform->find('schedules', \array_merge($paginationQueries, [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::equal('resourceType', [static::getSupportedResource()]), Query::greaterThanEqual('resourceUpdatedAt', $lastSyncUpdate), ])); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index e8195d175d..9b0590181a 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -183,7 +183,7 @@ class Deletes extends Action $this->listByGroup( 'schedules', [ - Query::equal('region', [System::getEnv('_APP_REGION')]), + Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), Query::lessThanEqual('resourceUpdatedAt', $datetime), Query::equal('active', [false]), ], diff --git a/src/Appwrite/Platform/Workers/StatsUsageDump.php b/src/Appwrite/Platform/Workers/StatsUsageDump.php index 3100a39dea..c0ff93e9b9 100644 --- a/src/Appwrite/Platform/Workers/StatsUsageDump.php +++ b/src/Appwrite/Platform/Workers/StatsUsageDump.php @@ -157,7 +157,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $documentClone = new Document($document->getArrayCopy()); @@ -191,7 +191,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION'), + 'region' => System::getEnv('_APP_REGION', 'default'), ]); $documentClone = new Document($document->getArrayCopy()); $dbForProject->createOrUpdateDocumentsWithIncrease( diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 2799e29772..7f84ace6f2 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -42,7 +42,7 @@ trait ProjectCustom 'x-appwrite-project' => 'console', ], [ 'projectId' => ID::unique(), - 'region' => 'fra', + 'region' => 'default', 'name' => 'Demo Project', 'teamId' => $team['body']['$id'], 'description' => 'Demo Project Description', diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 5e24dc4d89..914a255663 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -111,7 +111,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('fra', $output['APPWRITE_REGION']); + $this->assertEquals('default', $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); @@ -221,7 +221,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('fra', $output['APPWRITE_REGION']); + $this->assertEquals('default', $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 16a18d27c1..a6498b8a4e 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -49,7 +49,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'fra', + 'region' => 'default', ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -89,7 +89,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => '', 'teamId' => $team['body']['$id'], - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -100,7 +100,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'projectId' => ID::unique(), 'name' => 'Project Test', - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -129,7 +129,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => $projectId, 'name' => 'Project Duplicate', 'teamId' => $teamId, - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(409, $response['headers']['status-code']); @@ -178,7 +178,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Team 1 Project', 'teamId' => $team1, - 'region' => 'fra', + 'region' => 'default', ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -277,7 +277,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test 2', 'teamId' => $team['body']['$id'], - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -2042,7 +2042,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -2135,7 +2135,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3749,7 +3749,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project', 'teamId' => $teamId, - 'region' => 'fra' + 'region' => 'default' ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3820,7 +3820,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 1', 'teamId' => $teamId, - 'region' => 'fra' + 'region' => 'default' ]); $project2 = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ @@ -3830,7 +3830,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 2', 'teamId' => $teamId, - 'region' => 'fra' + 'region' => 'default' ]); $project1Id = $project1['body']['$id']; From e6e7c5c8161ca02f1c9fefb23285c98ad10eb7b9 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 21:44:34 +0200 Subject: [PATCH 20/35] revert --- app/views/install/compose.phtml | 16 ---------------- docker-compose.yml | 19 ------------------- 2 files changed, 35 deletions(-) diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 77cf21efd2..fd05d2a0b6 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -344,7 +344,6 @@ $image = $this->getParam('image', ''); - _APP_SYSTEM_SECURITY_EMAIL_ADDRESS - _APP_EMAIL_CERTIFICATES - appwrite-worker-databases: image: /: entrypoint: worker-databases @@ -371,7 +370,6 @@ $image = $this->getParam('image', ''); - _APP_DB_PASS - _APP_LOGGING_CONFIG - appwrite-worker-builds: image: /: entrypoint: worker-builds @@ -436,7 +434,6 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - appwrite-worker-certificates: image: /: entrypoint: worker-certificates @@ -470,7 +467,6 @@ $image = $this->getParam('image', ''); - _APP_DB_PASS - _APP_LOGGING_CONFIG - appwrite-worker-functions: image: /: entrypoint: worker-functions @@ -509,7 +505,6 @@ $image = $this->getParam('image', ''); - _APP_DOCKER_HUB_PASSWORD - _APP_LOGGING_CONFIG - appwrite-worker-mails: image: /: entrypoint: worker-mails @@ -544,7 +539,6 @@ $image = $this->getParam('image', ''); - _APP_DOMAIN - _APP_OPTIONS_FORCE_HTTPS - appwrite-worker-messaging: image: /: entrypoint: worker-messaging @@ -596,7 +590,6 @@ $image = $this->getParam('image', ''); - _APP_STORAGE_WASABI_REGION - _APP_STORAGE_WASABI_BUCKET - appwrite-worker-migrations: image: /: entrypoint: worker-migrations @@ -627,7 +620,6 @@ $image = $this->getParam('image', ''); - _APP_MIGRATIONS_FIREBASE_CLIENT_ID - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - appwrite-task-maintenance: image: /: entrypoint: maintenance @@ -662,7 +654,6 @@ $image = $this->getParam('image', ''); - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES - appwrite-task-stats-resources: image: /: container_name: appwrite-task-stats-resources @@ -694,7 +685,6 @@ $image = $this->getParam('image', ''); - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL - appwrite-worker-stats-resources: image: /: entrypoint: worker-stats-resources @@ -723,7 +713,6 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_STATS_RESOURCES_INTERVAL - appwrite-worker-stats-usage: image: /: entrypoint: worker-stats-usage @@ -752,7 +741,6 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - appwrite-worker-stats-usage-dump: image: /: entrypoint: worker-stats-usage-dump @@ -781,7 +769,6 @@ $image = $this->getParam('image', ''); - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - appwrite-task-scheduler-functions: image: /: entrypoint: schedule-functions @@ -807,7 +794,6 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - appwrite-task-scheduler-executions: image: /: entrypoint: schedule-executions @@ -833,7 +819,6 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - appwrite-task-scheduler-messages: image: /: entrypoint: schedule-messages @@ -859,7 +844,6 @@ $image = $this->getParam('image', ''); - _APP_DB_USER - _APP_DB_PASS - appwrite-assistant: image: appwrite/assistant:0.4.0 container_name: appwrite-assistant diff --git a/docker-compose.yml b/docker-compose.yml index f1451426e8..5933e37611 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -270,7 +270,6 @@ services: - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - appwrite-worker-audits: entrypoint: worker-audits <<: *x-logging @@ -300,7 +299,6 @@ services: - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - appwrite-worker-webhooks: entrypoint: worker-webhooks <<: *x-logging @@ -333,7 +331,6 @@ services: - _APP_WEBHOOK_MAX_FAILED_ATTEMPTS - _APP_DATABASE_SHARED_TABLES - appwrite-worker-deletes: entrypoint: worker-deletes <<: *x-logging @@ -394,7 +391,6 @@ services: - _APP_DATABASE_SHARED_TABLES_V1 - _APP_EMAIL_CERTIFICATES - appwrite-worker-databases: entrypoint: worker-databases <<: *x-logging @@ -426,7 +422,6 @@ services: - _APP_QUEUE_NAME - _APP_DATABASE_SHARED_TABLES - appwrite-worker-builds: entrypoint: worker-builds <<: *x-logging @@ -493,7 +488,6 @@ services: - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES - appwrite-worker-certificates: entrypoint: worker-certificates <<: *x-logging @@ -529,7 +523,6 @@ services: - _APP_LOGGING_CONFIG - _APP_DATABASE_SHARED_TABLES - appwrite-worker-functions: entrypoint: worker-functions <<: *x-logging @@ -572,7 +565,6 @@ services: - _APP_LOGGING_PROVIDER - _APP_DATABASE_SHARED_TABLES - appwrite-worker-mails: entrypoint: worker-mails <<: *x-logging @@ -607,7 +599,6 @@ services: - _APP_OPTIONS_FORCE_HTTPS - _APP_DATABASE_SHARED_TABLES - appwrite-worker-messaging: entrypoint: worker-messaging <<: *x-logging @@ -663,7 +654,6 @@ services: - _APP_STORAGE_WASABI_BUCKET - _APP_DATABASE_SHARED_TABLES - appwrite-worker-migrations: entrypoint: worker-migrations <<: *x-logging @@ -699,7 +689,6 @@ services: - _APP_MIGRATIONS_FIREBASE_CLIENT_SECRET - _APP_DATABASE_SHARED_TABLES - appwrite-task-maintenance: entrypoint: maintenance <<: *x-logging @@ -738,7 +727,6 @@ services: - _APP_MAINTENANCE_DELAY - _APP_DATABASE_SHARED_TABLES - appwrite-task-stats-resources: container_name: appwrite-task-stats-resources entrypoint: stats-resources @@ -770,7 +758,6 @@ services: - _APP_DATABASE_SHARED_TABLES - _APP_STATS_RESOURCES_INTERVAL - appwrite-worker-stats-resources: entrypoint: worker-stats-resources <<: *x-logging @@ -802,7 +789,6 @@ services: - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - appwrite-worker-stats-usage: entrypoint: worker-stats-usage <<: *x-logging @@ -834,7 +820,6 @@ services: - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - appwrite-worker-stats-usage-dump: entrypoint: worker-stats-usage-dump <<: *x-logging @@ -867,7 +852,6 @@ services: - _APP_DATABASE_SHARED_TABLES - _APP_STATS_USAGE_DUAL_WRITING_DBS - appwrite-task-scheduler-functions: entrypoint: schedule-functions <<: *x-logging @@ -896,7 +880,6 @@ services: - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES - appwrite-task-scheduler-executions: entrypoint: schedule-executions <<: *x-logging @@ -924,7 +907,6 @@ services: - _APP_DB_USER - _APP_DB_PASS - appwrite-task-scheduler-messages: entrypoint: schedule-messages <<: *x-logging @@ -953,7 +935,6 @@ services: - _APP_DB_PASS - _APP_DATABASE_SHARED_TABLES - appwrite-assistant: container_name: appwrite-assistant image: appwrite/assistant:0.7.0 From ee09e2c91b18c280b2ebbf082df06a9e9351fa83 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 21:47:54 +0200 Subject: [PATCH 21/35] revert --- docker-compose.yml | 5 +---- src/Appwrite/Platform/Workers/StatsUsageDump.php | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5933e37611..3f9f54bc1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,7 +93,6 @@ services: - app/http.php environment: - _APP_ENV - - _APP_EDITION - _APP_WORKER_PER_CORE - _APP_LOCALE @@ -788,7 +787,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - + - appwrite-worker-stats-usage: entrypoint: worker-stats-usage <<: *x-logging @@ -967,7 +966,6 @@ services: - OPR_EXECUTOR_DOCKER_HUB_USERNAME=$_APP_DOCKER_HUB_USERNAME - OPR_EXECUTOR_DOCKER_HUB_PASSWORD=$_APP_DOCKER_HUB_PASSWORD - OPR_EXECUTOR_ENV=$_APP_ENV - - OPR_EXECUTOR_REGION=$_APP_REGION - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4 @@ -1007,7 +1005,6 @@ services: environment: - OPR_PROXY_WORKER_PER_CORE=$_APP_WORKER_PER_CORE - OPR_PROXY_ENV=$_APP_ENV - - OPR_PROXY_REGION=$_APP_REGION - OPR_PROXY_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - OPR_PROXY_SECRET=$_APP_EXECUTOR_SECRET - OPR_PROXY_LOGGING_CONFIG=$_APP_LOGGING_CONFIG diff --git a/src/Appwrite/Platform/Workers/StatsUsageDump.php b/src/Appwrite/Platform/Workers/StatsUsageDump.php index c0ff93e9b9..747e6fdbfd 100644 --- a/src/Appwrite/Platform/Workers/StatsUsageDump.php +++ b/src/Appwrite/Platform/Workers/StatsUsageDump.php @@ -191,7 +191,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $documentClone = new Document($document->getArrayCopy()); $dbForProject->createOrUpdateDocumentsWithIncrease( From eb4340cf4c3f3a445ced961f2e75f0957035d11b Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 18 Mar 2025 21:49:28 +0200 Subject: [PATCH 22/35] revert --- docker-compose.yml | 2 +- src/Appwrite/Platform/Workers/StatsUsageDump.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3f9f54bc1e..b6dc80df6a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -787,7 +787,7 @@ services: - _APP_LOGGING_CONFIG - _APP_USAGE_AGGREGATION_INTERVAL - _APP_DATABASE_SHARED_TABLES - - + appwrite-worker-stats-usage: entrypoint: worker-stats-usage <<: *x-logging diff --git a/src/Appwrite/Platform/Workers/StatsUsageDump.php b/src/Appwrite/Platform/Workers/StatsUsageDump.php index 747e6fdbfd..119a9e7288 100644 --- a/src/Appwrite/Platform/Workers/StatsUsageDump.php +++ b/src/Appwrite/Platform/Workers/StatsUsageDump.php @@ -157,7 +157,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION', 'default') + 'region' => System::getEnv('_APP_REGION', 'default'), ]); $documentClone = new Document($document->getArrayCopy()); @@ -191,7 +191,7 @@ class StatsUsageDump extends Action 'time' => $time, 'metric' => $key, 'value' => $value, - 'region' => System::getEnv('_APP_REGION', 'default') + 'region' => System::getEnv('_APP_REGION', 'default'), ]); $documentClone = new Document($document->getArrayCopy()); $dbForProject->createOrUpdateDocumentsWithIncrease( From faed019d921847e05ff9ff5f7d2b42684dc8424e Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Mar 2025 09:32:48 +0200 Subject: [PATCH 23/35] revert --- tests/e2e/Scopes/ProjectCustom.php | 3 ++- .../Projects/ProjectsConsoleClientTest.php | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 7f84ace6f2..533fccd87d 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -4,6 +4,7 @@ namespace Tests\E2E\Scopes; use Tests\E2E\Client; use Utopia\Database\Helpers\ID; +use Utopia\System\System; trait ProjectCustom { @@ -42,7 +43,7 @@ trait ProjectCustom 'x-appwrite-project' => 'console', ], [ 'projectId' => ID::unique(), - 'region' => 'default', + 'region' => System::getEnv('_APP_REGION', 'default'), 'name' => 'Demo Project', 'teamId' => $team['body']['$id'], 'description' => 'Demo Project Description', diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index a6498b8a4e..8e2ab03880 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -14,6 +14,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; +use Utopia\System\System; class ProjectsConsoleClientTest extends Scope { @@ -49,7 +50,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default', + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -89,7 +90,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => '', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -100,7 +101,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'projectId' => ID::unique(), 'name' => 'Project Test', - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -129,7 +130,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => $projectId, 'name' => 'Project Duplicate', 'teamId' => $teamId, - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(409, $response['headers']['status-code']); @@ -178,7 +179,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Team 1 Project', 'teamId' => $team1, - 'region' => 'default', + 'region' => System::getEnv('_APP_REGION', 'default'), ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -277,7 +278,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test 2', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -2042,7 +2043,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -2135,7 +2136,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3749,7 +3750,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project', 'teamId' => $teamId, - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3820,7 +3821,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 1', 'teamId' => $teamId, - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $project2 = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ @@ -3830,7 +3831,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 2', 'teamId' => $teamId, - 'region' => 'default' + 'region' => System::getEnv('_APP_REGION', 'default') ]); $project1Id = $project1['body']['$id']; From 88d6150db2f67ffaf1a4918f0427d444fca770d1 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 19 Mar 2025 10:29:18 +0200 Subject: [PATCH 24/35] revert --- tests/e2e/Services/Functions/FunctionsCustomClientTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 914a255663..55db081720 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -8,6 +8,7 @@ use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Role; +use Utopia\System\System; class FunctionsCustomClientTest extends Scope { @@ -111,7 +112,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('default', $output['APPWRITE_REGION']); + $this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); @@ -221,7 +222,7 @@ class FunctionsCustomClientTest extends Scope $this->assertEquals('PHP', $output['APPWRITE_FUNCTION_RUNTIME_NAME']); $this->assertEquals('8.0', $output['APPWRITE_FUNCTION_RUNTIME_VERSION']); $this->assertEquals(APP_VERSION_STABLE, $output['APPWRITE_VERSION']); - $this->assertEquals('default', $output['APPWRITE_REGION']); + $this->assertEquals(System::getEnv('_APP_REGION', 'default'), $output['APPWRITE_REGION']); $this->assertEquals('', $output['APPWRITE_FUNCTION_EVENT']); $this->assertEquals('foobar', $output['APPWRITE_FUNCTION_DATA']); $this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']); From 31ca35782baa46d73a2ad75cdb209f6c08d7bc97 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 20 Mar 2025 15:21:24 +1300 Subject: [PATCH 25/35] Use cursor pagination with bigger limit for maintenance project loop --- src/Appwrite/Platform/Tasks/Maintenance.php | 33 +++------------------ 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index 98a3f4d295..b9e312a3fb 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -47,13 +47,15 @@ class Maintenance extends Action Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); - $this->foreachProject($dbForPlatform, function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { + $dbForPlatform->foreach('projects', function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { $queueForDeletes ->setType(DELETE_TYPE_MAINTENANCE) ->setProject($project) ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) ->trigger(); - }); + }, [ + Query::limit(100), + ]); $queueForDeletes ->setType(DELETE_TYPE_MAINTENANCE) @@ -68,33 +70,6 @@ class Maintenance extends Action }, $interval, $delay); } - protected function foreachProject(Database $dbForPlatform, callable $callback): void - { - // TODO: @Meldiron name of this method no longer matches. It does not delete, and it gives whole document - $count = 0; - $chunk = 0; - $limit = 50; - $sum = $limit; - $executionStart = \microtime(true); - - while ($sum === $limit) { - $projects = $dbForPlatform->find('projects', [Query::limit($limit), Query::offset($chunk * $limit)]); - - $chunk++; - - /** @var string[] $projectIds */ - $sum = count($projects); - - foreach ($projects as $project) { - $callback($project); - $count++; - } - } - - $executionEnd = \microtime(true); - Console::info("Found {$count} projects " . ($executionEnd - $executionStart) . " seconds"); - } - private function notifyDeleteConnections(Delete $queueForDeletes): void { $queueForDeletes From c2d0aded6debd6e2d4fbbd579e870df88d18272b Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 20 Mar 2025 18:04:36 +0530 Subject: [PATCH 26/35] Fix GitHub check URL --- .../Platform/Modules/Functions/Workers/Builds.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 16b2e08be1..5640ce4371 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1201,7 +1201,13 @@ class Builds extends Action $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; $hostname = System::getEnv('_APP_DOMAIN'); - $providerTargetUrl = "{$protocol}://{$hostname}/console/project-{$project->getId()}/functions/function-{$resource->getId()}"; + + $resourceType = match ($resource->getCollection()) { + 'functions' => 'function', + 'sites' => 'site', + default => throw new \Exception('Invalid resource type') + }; + $providerTargetUrl = "{$protocol}://{$hostname}/console/project-{$project->getId()}/{$resource->getCollection()}/$resourceType-{$resource->getId()}"; $github->updateCommitStatus($repositoryName, $providerCommitHash, $owner, $state, $message, $providerTargetUrl, $name); } From ec6683cfa966595249ed99f96cb40fb3f81e107d Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 20 Mar 2025 18:44:00 +0530 Subject: [PATCH 27/35] Refactor --- .../Platform/Modules/Functions/Workers/Builds.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 5640ce4371..c387d02d2a 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1202,12 +1202,13 @@ class Builds extends Action $protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') == 'disabled' ? 'http' : 'https'; $hostname = System::getEnv('_APP_DOMAIN'); - $resourceType = match ($resource->getCollection()) { - 'functions' => 'function', - 'sites' => 'site', + $projectId = $project->getId(); + $resourceId = $resource->getId(); + $providerTargetUrl = match ($resource->getCollection()) { + 'functions' => "{$protocol}://{$hostname}/console/project-{$projectId}/functions/function-{$resourceId}", + 'sites' => "{$protocol}://{$hostname}/console/project-{$projectId}/sites/site-{$resourceId}", default => throw new \Exception('Invalid resource type') }; - $providerTargetUrl = "{$protocol}://{$hostname}/console/project-{$project->getId()}/{$resource->getCollection()}/$resourceType-{$resource->getId()}"; $github->updateCommitStatus($repositoryName, $providerCommitHash, $owner, $state, $message, $providerTargetUrl, $name); } From bb01c9e9e99e15a78700ffaa4232886ca57acbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 15:22:35 +0100 Subject: [PATCH 28/35] Add latest deployment tests --- .../Functions/Http/Deployments/Delete.php | 16 ++++++ .../Modules/Sites/Http/Deployments/Delete.php | 16 ++++++ .../Utopia/Response/Model/Deployment.php | 2 +- src/Appwrite/Utopia/Response/Model/Func.php | 18 +++++++ src/Appwrite/Utopia/Response/Model/Site.php | 18 +++++++ .../e2e/Services/Functions/FunctionsBase.php | 10 ++++ .../Functions/FunctionsCustomServerTest.php | 32 ++++++++++++ tests/e2e/Services/Sites/SitesBase.php | 10 ++++ .../Services/Sites/SitesCustomServerTest.php | 49 +++++++++++++++---- 9 files changed, 161 insertions(+), 10 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php index 27eded178a..b5a84c9122 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Query; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; @@ -96,6 +97,21 @@ class Delete extends Action } } + if ($function->getAttribute('latestDeploymentId') === $deployment->getId()) { + $latestDeployment = $dbForProject->findOne('deployments', [ + Query::orderDesc('$createdAt'), + ]); + $function = $dbForProject->updateDocument( + 'functions', + $function->getId(), + $function + ->setAttribute('latestDeploymentCreatedAt', $latestDeployment->isEmpty() ? '' : $latestDeployment->getCreatedAt()) + ->setAttribute('latestDeploymentInternalId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getInternalId()) + ->setAttribute('latestDeploymentId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getId()) + ->setAttribute('latestDeploymentStatus', $latestDeployment->isEmpty() ? '' : $latestDeployment->getAttribute('status', '')) + ); + } + if ($function->getAttribute('deploymentId') === $deployment->getId()) { // Reset function deployment $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentId' => '', diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index 00342a7667..b6b347bc04 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -12,6 +12,7 @@ use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\Database\Database; use Utopia\Database\Document; +use Utopia\Database\Query; use Utopia\Database\Validator\UID; use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; @@ -96,6 +97,21 @@ class Delete extends Action } } + if ($site->getAttribute('latestDeploymentId') === $deployment->getId()) { + $latestDeployment = $dbForProject->findOne('deployments', [ + Query::orderDesc('$createdAt'), + ]); + $site = $dbForProject->updateDocument( + 'sites', + $site->getId(), + $site + ->setAttribute('latestDeploymentCreatedAt', $latestDeployment->isEmpty() ? '' : $latestDeployment->getCreatedAt()) + ->setAttribute('latestDeploymentInternalId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getInternalId()) + ->setAttribute('latestDeploymentId', $latestDeployment->isEmpty() ? '' : $latestDeployment->getId()) + ->setAttribute('latestDeploymentStatus', $latestDeployment->isEmpty() ? '' : $latestDeployment->getAttribute('status', '')) + ); + } + if ($site->getAttribute('deploymentId') === $deployment->getId()) { // Reset site deployment $site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [ 'deploymentId' => '', diff --git a/src/Appwrite/Utopia/Response/Model/Deployment.php b/src/Appwrite/Utopia/Response/Model/Deployment.php index 4729e8a122..55c1589af0 100644 --- a/src/Appwrite/Utopia/Response/Model/Deployment.php +++ b/src/Appwrite/Utopia/Response/Model/Deployment.php @@ -96,7 +96,7 @@ class Deployment extends Model ]) ->addRule('status', [ 'type' => self::TYPE_STRING, - 'description' => 'The deployment status. Possible values are "waiting", "processing", "building", "waiting", "ready", and "failed".', + 'description' => 'The deployment status. Possible values are "waiting", "processing", "building", "ready", and "failed".', 'default' => '', 'example' => 'ready', ]) diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index 5d937ab075..d2446585b9 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -77,6 +77,24 @@ class Func extends Model 'default' => '', 'example' => self::TYPE_DATETIME_EXAMPLE, ]) + ->addRule('latestDeploymentId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Site\'s latest deployment ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('latestDeploymentCreatedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Latest deployment creation date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) + ->addRule('latestDeploymentStatus', [ + 'type' => self::TYPE_STRING, + 'description' => 'Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed".', + 'default' => '', + 'example' => 'ready', + ]) ->addRule('scopes', [ 'type' => self::TYPE_STRING, 'description' => 'Allowed permission scopes.', diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index fad4856f3e..478b7881b3 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -76,6 +76,24 @@ class Site extends Model 'default' => '', 'example' => '5e5ea5c16897e', ]) + ->addRule('latestDeploymentId', [ + 'type' => self::TYPE_STRING, + 'description' => 'Site\'s latest deployment ID.', + 'default' => '', + 'example' => '5e5ea5c16897e', + ]) + ->addRule('latestDeploymentCreatedAt', [ + 'type' => self::TYPE_DATETIME, + 'description' => 'Latest deployment creation date in ISO 8601 format.', + 'default' => '', + 'example' => self::TYPE_DATETIME_EXAMPLE, + ]) + ->addRule('latestDeploymentStatus', [ + 'type' => self::TYPE_STRING, + 'description' => 'Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed".', + 'default' => '', + 'example' => 'ready', + ]) ->addRule('vars', [ 'type' => Response::MODEL_VARIABLE, 'description' => 'Site variables.', diff --git a/tests/e2e/Services/Functions/FunctionsBase.php b/tests/e2e/Services/Functions/FunctionsBase.php index 2d82de22f2..475eb9b9b4 100644 --- a/tests/e2e/Services/Functions/FunctionsBase.php +++ b/tests/e2e/Services/Functions/FunctionsBase.php @@ -231,6 +231,16 @@ trait FunctionsBase return $deployment; } + protected function deleteDeployment(string $functionId, string $deploymentId): mixed + { + $deployment = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + return $deployment; + } + protected function createTemplateDeployment(string $functionId, mixed $params = []): mixed { $deployment = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/deployments/template', array_merge([ diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e13e7f9147..933d5d5a12 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -2101,12 +2101,27 @@ class FunctionsCustomServerTest extends Scope ]); $this->assertNotEmpty($functionId); + + $function = $this->getFunction($functionId); + $this->assertEquals(200, $function['headers']['status-code']); + $this->assertArrayHasKey('latestDeploymentId', $function['body']); + $this->assertArrayHasKey('latestDeploymentCreatedAt', $function['body']); + $this->assertArrayHasKey('latestDeploymentStatus', $function['body']); + $this->assertEmpty($function['body']['latestDeploymentId']); + $this->assertEmpty($function['body']['latestDeploymentCreatedAt']); + $this->assertEmpty($function['body']['latestDeploymentStatus']); + $deploymentId1 = $this->setupDeployment($functionId, [ 'code' => $this->packageFunction('php-cookie'), 'activate' => true ]); $this->assertNotEmpty($deploymentId1); + $function = $this->getFunction($functionId); + $this->assertEquals(200, $function['headers']['status-code']); + $this->assertEquals($deploymentId1, $function['body']['latestDeploymentId']); + $this->assertEquals('ready', $function['body']['latestDeploymentStatus']); + $execution = $this->createExecution($functionId, [ 'headers' => [ 'cookie' => 'cookieName=cookieValue' ] ]); @@ -2120,6 +2135,11 @@ class FunctionsCustomServerTest extends Scope ]); $this->assertNotEmpty($deploymentId2); + $function = $this->getFunction($functionId); + $this->assertEquals(200, $function['headers']['status-code']); + $this->assertEquals($deploymentId2, $function['body']['latestDeploymentId']); + $this->assertEquals('ready', $function['body']['latestDeploymentStatus']); + $execution = $this->createExecution($functionId); $this->assertEquals(201, $execution['headers']['status-code']); $this->assertNotEmpty($execution['body']['$id']); @@ -2128,6 +2148,8 @@ class FunctionsCustomServerTest extends Scope $function = $this->getFunction($functionId); $this->assertEquals(200, $function['headers']['status-code']); $this->assertEquals($deploymentId2, $function['body']['deploymentId']); + $this->assertEquals($deploymentId2, $function['body']['latestDeploymentId']); + $this->assertEquals('ready', $function['body']['latestDeploymentStatus']); $function = $this->updateFunctionDeployment($functionId, $deploymentId1); $this->assertEquals(200, $function['headers']['status-code']); @@ -2136,6 +2158,8 @@ class FunctionsCustomServerTest extends Scope $function = $this->getFunction($functionId); $this->assertEquals(200, $function['headers']['status-code']); $this->assertEquals($deploymentId1, $function['body']['deploymentId']); + $this->assertEquals($deploymentId2, $function['body']['latestDeploymentId']); + $this->assertEquals('ready', $function['body']['latestDeploymentStatus']); $execution = $this->createExecution($functionId, [ 'headers' => [ 'cookie' => 'cookieName=cookieValue' ] @@ -2144,6 +2168,14 @@ class FunctionsCustomServerTest extends Scope $this->assertNotEmpty($execution['body']['$id']); $this->assertStringContainsString('cookieValue', $execution['body']['responseBody']); + $deployment = $this->deleteDeployment($functionId, $deploymentId2); + $this->assertEquals(204, $deployment['headers']['status-code']); + + $function = $this->getFunction($functionId); + $this->assertEquals(200, $function['headers']['status-code']); + $this->assertEquals($deploymentId1, $function['body']['latestDeploymentId']); + $this->assertEquals('ready', $function['body']['latestDeploymentStatus']); + $this->cleanupFunction($functionId); } } diff --git a/tests/e2e/Services/Sites/SitesBase.php b/tests/e2e/Services/Sites/SitesBase.php index abfce68d89..ff7e4b283f 100644 --- a/tests/e2e/Services/Sites/SitesBase.php +++ b/tests/e2e/Services/Sites/SitesBase.php @@ -244,6 +244,16 @@ trait SitesBase return $deployment; } + protected function deleteDeployment(string $siteId, string $deploymentId): mixed + { + $deployment = $this->client->call(Client::METHOD_DELETE, '/sites/' . $siteId . '/deployments/' . $deploymentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), []); + + return $deployment; + } + protected function setupDuplicateDeployment(string $siteId, string $deploymentId): string { $deployment = $this->createDuplicateDeployment($siteId, $deploymentId); diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index c1609bfb80..a95568c7ce 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -2057,6 +2057,15 @@ class SitesCustomServerTest extends Scope ]); $this->assertNotEmpty($siteId); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertArrayHasKey('latestDeploymentId', $site['body']); + $this->assertArrayHasKey('latestDeploymentCreatedAt', $site['body']); + $this->assertArrayHasKey('latestDeploymentStatus', $site['body']); + $this->assertEmpty($site['body']['latestDeploymentId']); + $this->assertEmpty($site['body']['latestDeploymentCreatedAt']); + $this->assertEmpty($site['body']['latestDeploymentStatus']); + $domain = $this->setupSiteDomain($siteId); $this->assertNotEmpty($domain); $proxyClient = new Client(); @@ -2068,6 +2077,11 @@ class SitesCustomServerTest extends Scope ]); $this->assertNotEmpty($deploymentId1); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId1, $site['body']['latestDeploymentId']); + $this->assertEquals('ready', $site['body']['latestDeploymentStatus']); + $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString('Hello Appwrite', $response['body']); @@ -2078,26 +2092,43 @@ class SitesCustomServerTest extends Scope ]); $this->assertNotEmpty($deploymentId2); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId2, $site['body']['latestDeploymentId']); + $this->assertEquals('ready', $site['body']['latestDeploymentStatus']); + $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString('Index page', $response['body']); - $function = $this->getSite($siteId); - $this->assertEquals(200, $function['headers']['status-code']); - $this->assertEquals($deploymentId2, $function['body']['deploymentId']); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId2, $site['body']['deploymentId']); + $this->assertEquals($deploymentId2, $site['body']['latestDeploymentId']); + $this->assertEquals('ready', $site['body']['latestDeploymentStatus']); - $function = $this->updateSiteDeployment($siteId, $deploymentId1); - $this->assertEquals(200, $function['headers']['status-code']); - $this->assertEquals($deploymentId1, $function['body']['deploymentId']); + $site = $this->updateSiteDeployment($siteId, $deploymentId1); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId1, $site['body']['deploymentId']); - $function = $this->getSite($siteId); - $this->assertEquals(200, $function['headers']['status-code']); - $this->assertEquals($deploymentId1, $function['body']['deploymentId']); + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId1, $site['body']['deploymentId']); + $this->assertEquals($deploymentId2, $site['body']['latestDeploymentId']); + $this->assertEquals('ready', $site['body']['latestDeploymentStatus']); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); $this->assertStringContainsString('Hello Appwrite', $response['body']); + $deployment = $this->deleteDeployment($siteId, $deploymentId2); + $this->assertEquals(204, $deployment['headers']['status-code']); + + $site = $this->getSite($siteId); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals($deploymentId1, $site['body']['latestDeploymentId']); + $this->assertEquals('ready', $site['body']['latestDeploymentStatus']); + $this->cleanupSite($siteId); } From e34fc92c7c3ef53c1f8e6bbe9bf8d9adb73b82ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 15:44:15 +0100 Subject: [PATCH 29/35] PR review changes --- app/config/collections/projects.php | 2 -- .../Platform/Modules/Functions/Http/Deployments/Delete.php | 2 ++ src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index ffae763f6b..b209a7ec32 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -623,7 +623,6 @@ return [ 'array' => false, 'filters' => ['datetime'], ], - [ '$id' => ID::custom('latestDeploymentStatus'), 'type' => Database::VAR_STRING, @@ -1125,7 +1124,6 @@ return [ 'array' => false, 'filters' => ['datetime'], ], - [ '$id' => ID::custom('latestDeploymentStatus'), 'type' => Database::VAR_STRING, diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php index b5a84c9122..b66ea30bb2 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Deployments/Delete.php @@ -99,6 +99,8 @@ class Delete extends Action if ($function->getAttribute('latestDeploymentId') === $deployment->getId()) { $latestDeployment = $dbForProject->findOne('deployments', [ + Query::equal('resourceType', ['functions']), + Query::equal('resourceInternalId', [$function->getInternalId()]), Query::orderDesc('$createdAt'), ]); $function = $dbForProject->updateDocument( diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php index b6b347bc04..9d30b21a11 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Delete.php @@ -99,6 +99,8 @@ class Delete extends Action if ($site->getAttribute('latestDeploymentId') === $deployment->getId()) { $latestDeployment = $dbForProject->findOne('deployments', [ + Query::equal('resourceType', ['sites']), + Query::equal('resourceInternalId', [$site->getInternalId()]), Query::orderDesc('$createdAt'), ]); $site = $dbForProject->updateDocument( From 0f5480cbc0e8fdf126fc41b55c3e1758a4f1638e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 15:48:18 +0100 Subject: [PATCH 30/35] Fix copy --- src/Appwrite/Utopia/Response/Model/Func.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Response/Model/Func.php b/src/Appwrite/Utopia/Response/Model/Func.php index d2446585b9..e0929684fb 100644 --- a/src/Appwrite/Utopia/Response/Model/Func.php +++ b/src/Appwrite/Utopia/Response/Model/Func.php @@ -79,7 +79,7 @@ class Func extends Model ]) ->addRule('latestDeploymentId', [ 'type' => self::TYPE_STRING, - 'description' => 'Site\'s latest deployment ID.', + 'description' => 'Function\'s latest deployment ID.', 'default' => '', 'example' => '5e5ea5c16897e', ]) From 172ebb5f7f9bae392f82ef65eaf1a6a1bcdf548d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 15:51:15 +0100 Subject: [PATCH 31/35] Update specs --- .../specs/open-api3-latest-console.json | 73 ++++++++++++++++++- app/config/specs/open-api3-latest-server.json | 73 ++++++++++++++++++- app/config/specs/swagger2-latest-console.json | 73 ++++++++++++++++++- app/config/specs/swagger2-latest-server.json | 73 ++++++++++++++++++- 4 files changed, 280 insertions(+), 12 deletions(-) diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 76dd01367e..db615b0411 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -10140,7 +10140,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "schema": { "type": "array", @@ -25699,7 +25699,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "schema": { "type": "array", @@ -36875,6 +36875,36 @@ "description": "Site's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "deploymentScreenshotLight": { + "type": "string", + "description": "Screenshot of active deployment with light theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "deploymentScreenshotDark": { + "type": "string", + "description": "Screenshot of active deployment with dark theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentId": { + "type": "string", + "description": "Site's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "vars": { "type": "array", "description": "Site variables.", @@ -36959,6 +36989,12 @@ "live", "framework", "deploymentId", + "deploymentCreatedAt", + "deploymentScreenshotLight", + "deploymentScreenshotDark", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "vars", "timeout", "installCommand", @@ -37183,6 +37219,26 @@ "description": "Function's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentId": { + "type": "string", + "description": "Function's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "scopes": { "type": "array", "description": "Allowed permission scopes.", @@ -37275,6 +37331,10 @@ "logging", "runtime", "deploymentId", + "deploymentCreatedAt", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "scopes", "vars", "events", @@ -37986,6 +38046,12 @@ "x-example": 128, "format": "int32" }, + "totalSize": { + "type": "integer", + "description": "The total size in bytes (source and build output).", + "x-example": 128, + "format": "int32" + }, "buildId": { "type": "string", "description": "The current build ID.", @@ -38008,7 +38074,7 @@ }, "status": { "type": "string", - "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"waiting\", \"ready\", and \"failed\".", + "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", "x-example": "ready" }, "buildLogs": { @@ -38083,6 +38149,7 @@ "entrypoint", "sourceSize", "buildSize", + "totalSize", "buildId", "activate", "screenshotLight", diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index c7704fd6a8..e819616de5 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -9005,7 +9005,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "schema": { "type": "array", @@ -17574,7 +17574,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "schema": { "type": "array", @@ -27423,6 +27423,36 @@ "description": "Site's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "deploymentScreenshotLight": { + "type": "string", + "description": "Screenshot of active deployment with light theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "deploymentScreenshotDark": { + "type": "string", + "description": "Screenshot of active deployment with dark theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentId": { + "type": "string", + "description": "Site's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "vars": { "type": "array", "description": "Site variables.", @@ -27507,6 +27537,12 @@ "live", "framework", "deploymentId", + "deploymentCreatedAt", + "deploymentScreenshotLight", + "deploymentScreenshotDark", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "vars", "timeout", "installCommand", @@ -27580,6 +27616,26 @@ "description": "Function's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentId": { + "type": "string", + "description": "Function's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "scopes": { "type": "array", "description": "Allowed permission scopes.", @@ -27672,6 +27728,10 @@ "logging", "runtime", "deploymentId", + "deploymentCreatedAt", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "scopes", "vars", "events", @@ -27885,6 +27945,12 @@ "x-example": 128, "format": "int32" }, + "totalSize": { + "type": "integer", + "description": "The total size in bytes (source and build output).", + "x-example": 128, + "format": "int32" + }, "buildId": { "type": "string", "description": "The current build ID.", @@ -27907,7 +27973,7 @@ }, "status": { "type": "string", - "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"waiting\", \"ready\", and \"failed\".", + "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", "x-example": "ready" }, "buildLogs": { @@ -27982,6 +28048,7 @@ "entrypoint", "sourceSize", "buildSize", + "totalSize", "buildId", "activate", "screenshotLight", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 4bfad91074..cd814521be 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -10322,7 +10322,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "type": "array", "collectionFormat": "multi", @@ -26230,7 +26230,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "type": "array", "collectionFormat": "multi", @@ -37455,6 +37455,36 @@ "description": "Site's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "deploymentScreenshotLight": { + "type": "string", + "description": "Screenshot of active deployment with light theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "deploymentScreenshotDark": { + "type": "string", + "description": "Screenshot of active deployment with dark theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentId": { + "type": "string", + "description": "Site's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "vars": { "type": "array", "description": "Site variables.", @@ -37540,6 +37570,12 @@ "live", "framework", "deploymentId", + "deploymentCreatedAt", + "deploymentScreenshotLight", + "deploymentScreenshotDark", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "vars", "timeout", "installCommand", @@ -37766,6 +37802,26 @@ "description": "Function's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentId": { + "type": "string", + "description": "Function's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "scopes": { "type": "array", "description": "Allowed permission scopes.", @@ -37859,6 +37915,10 @@ "logging", "runtime", "deploymentId", + "deploymentCreatedAt", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "scopes", "vars", "events", @@ -38573,6 +38633,12 @@ "x-example": 128, "format": "int32" }, + "totalSize": { + "type": "integer", + "description": "The total size in bytes (source and build output).", + "x-example": 128, + "format": "int32" + }, "buildId": { "type": "string", "description": "The current build ID.", @@ -38595,7 +38661,7 @@ }, "status": { "type": "string", - "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"waiting\", \"ready\", and \"failed\".", + "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", "x-example": "ready" }, "buildLogs": { @@ -38670,6 +38736,7 @@ "entrypoint", "sourceSize", "buildSize", + "totalSize", "buildId", "activate", "screenshotLight", diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index c86f605f23..db2f32abcc 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -9188,7 +9188,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "type": "array", "collectionFormat": "multi", @@ -18075,7 +18075,7 @@ }, { "name": "queries", - "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, buildDuration, status, activate, type", + "description": "Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https:\/\/appwrite.io\/docs\/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type", "required": false, "type": "array", "collectionFormat": "multi", @@ -27974,6 +27974,36 @@ "description": "Site's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "deploymentScreenshotLight": { + "type": "string", + "description": "Screenshot of active deployment with light theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "deploymentScreenshotDark": { + "type": "string", + "description": "Screenshot of active deployment with dark theme preference file ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentId": { + "type": "string", + "description": "Site's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "vars": { "type": "array", "description": "Site variables.", @@ -28059,6 +28089,12 @@ "live", "framework", "deploymentId", + "deploymentCreatedAt", + "deploymentScreenshotLight", + "deploymentScreenshotDark", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "vars", "timeout", "installCommand", @@ -28132,6 +28168,26 @@ "description": "Function's active deployment ID.", "x-example": "5e5ea5c16897e" }, + "deploymentCreatedAt": { + "type": "string", + "description": "Active deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentId": { + "type": "string", + "description": "Function's latest deployment ID.", + "x-example": "5e5ea5c16897e" + }, + "latestDeploymentCreatedAt": { + "type": "string", + "description": "Latest deployment creation date in ISO 8601 format.", + "x-example": "2020-10-15T06:38:00.000+00:00" + }, + "latestDeploymentStatus": { + "type": "string", + "description": "Status of latest deployment. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", + "x-example": "ready" + }, "scopes": { "type": "array", "description": "Allowed permission scopes.", @@ -28225,6 +28281,10 @@ "logging", "runtime", "deploymentId", + "deploymentCreatedAt", + "latestDeploymentId", + "latestDeploymentCreatedAt", + "latestDeploymentStatus", "scopes", "vars", "events", @@ -28439,6 +28499,12 @@ "x-example": 128, "format": "int32" }, + "totalSize": { + "type": "integer", + "description": "The total size in bytes (source and build output).", + "x-example": 128, + "format": "int32" + }, "buildId": { "type": "string", "description": "The current build ID.", @@ -28461,7 +28527,7 @@ }, "status": { "type": "string", - "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"waiting\", \"ready\", and \"failed\".", + "description": "The deployment status. Possible values are \"waiting\", \"processing\", \"building\", \"ready\", and \"failed\".", "x-example": "ready" }, "buildLogs": { @@ -28536,6 +28602,7 @@ "entrypoint", "sourceSize", "buildSize", + "totalSize", "buildId", "activate", "screenshotLight", From e28333ed637d36131d3b3e6f1b330aa434521142 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 20 Mar 2025 20:23:36 +0530 Subject: [PATCH 32/35] Re-enable test --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e13e7f9147..fcc083dae5 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1288,8 +1288,7 @@ class FunctionsCustomServerTest extends Scope 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'], - // TODO: Re-enable; temporarly disabled due to OPR v5 issues - // ['folder' => 'python', 'name' => 'python-3.9', 'entrypoint' => 'main.py', 'runtimeName' => 'Python', 'runtimeVersion' => '3.9'], + ['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' => 'dart', 'name' => 'dart-2.15', 'entrypoint' => 'main.dart', 'runtimeName' => 'Dart', 'runtimeVersion' => '2.15' ], From 813424aa3cba2d62f81d5a771d3c5376a6e55ff8 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Thu, 20 Mar 2025 20:37:32 +0530 Subject: [PATCH 33/35] Split params across multiple lines where overflowing --- .../Modules/Functions/Workers/Builds.php | 76 +++++++++++++++++-- .../Platform/Workers/Certificates.php | 51 +++++++++++-- src/Appwrite/Platform/Workers/Databases.php | 11 ++- src/Appwrite/Platform/Workers/Deletes.php | 18 ++++- src/Appwrite/Platform/Workers/Functions.php | 14 +++- src/Appwrite/Platform/Workers/StatsUsage.php | 6 +- 6 files changed, 153 insertions(+), 23 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 16b2e08be1..1fac6d7f36 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -91,8 +91,23 @@ class Builds extends Action * @return void * @throws \Utopia\Database\Exception */ - public function action(Message $message, Document $project, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, StatsUsage $queueForStatsUsage, Cache $cache, Database $dbForProject, Device $deviceForFunctions, Device $deviceForSites, callable $isResourceBlocked, Device $deviceForFiles, Log $log): void - { + public function action( + Message $message, + Document $project, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + StatsUsage $queueForStatsUsage, + Cache $cache, + Database $dbForProject, + Device $deviceForFunctions, + Device $deviceForSites, + callable $isResourceBlocked, + Device $deviceForFiles, + Log $log + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { @@ -112,7 +127,25 @@ class Builds extends Action case BUILD_TYPE_RETRY: Console::info('Creating build for deployment: ' . $deployment->getId()); $github = new GitHub($cache); - $this->buildDeployment($deviceForFunctions, $deviceForSites, $deviceForFiles, $queueForWebhooks, $queueForFunctions, $queueForRealtime, $queueForEvents, $queueForStatsUsage, $dbForPlatform, $dbForProject, $github, $project, $resource, $deployment, $template, $isResourceBlocked, $log); + $this->buildDeployment( + $deviceForFunctions, + $deviceForSites, + $deviceForFiles, + $queueForWebhooks, + $queueForFunctions, + $queueForRealtime, + $queueForEvents, + $queueForStatsUsage, + $dbForPlatform, + $dbForProject, + $github, + $project, + $resource, + $deployment, + $template, + $isResourceBlocked, + $log + ); break; default: @@ -142,9 +175,26 @@ class Builds extends Action * * @throws Exception */ - protected function buildDeployment(Device $deviceForFunctions, Device $deviceForSites, Device $deviceForFiles, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Event $queueForEvents, StatsUsage $queueForStatsUsage, Database $dbForPlatform, Database $dbForProject, GitHub $github, Document $project, Document $resource, Document $deployment, Document $template, callable $isResourceBlocked, Log $log): void - { - $resourceKey = match($resource->getCollection()) { + protected function buildDeployment( + Device $deviceForFunctions, + Device $deviceForSites, + Device $deviceForFiles, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Event $queueForEvents, + StatsUsage $queueForStatsUsage, + Database $dbForPlatform, + Database $dbForProject, + GitHub $github, + Document $project, + Document $resource, + Document $deployment, + Document $template, + callable $isResourceBlocked, + Log $log + ): void { + $resourceKey = match ($resource->getCollection()) { 'functions' => 'functionId', 'sites' => 'siteId', default => throw new \Exception('Invalid resource type') @@ -1170,8 +1220,18 @@ class Builds extends Action * @throws Conflict * @throws Restricted */ - protected function runGitAction(string $status, GitHub $github, string $providerCommitHash, string $owner, string $repositoryName, Document $project, Document $resource, string $deploymentId, Database $dbForProject, Database $dbForPlatform): void - { + protected function runGitAction( + string $status, + GitHub $github, + string $providerCommitHash, + string $owner, + string $repositoryName, + Document $project, + Document $resource, + string $deploymentId, + Database $dbForProject, + Database $dbForPlatform + ): void { if ($resource->getAttribute('providerSilentMode', false) === true) { return; } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 552f617656..712196fc72 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -69,8 +69,17 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - public function action(Message $message, Database $dbForPlatform, Mail $queueForMails, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Log $log, CertificatesAdapter $certificates): void - { + public function action( + Message $message, + Database $dbForPlatform, + Mail $queueForMails, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Log $log, + CertificatesAdapter $certificates + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { @@ -99,8 +108,18 @@ class Certificates extends Action * @throws Throwable * @throws \Utopia\Database\Exception */ - private function execute(Domain $domain, Database $dbForPlatform, Mail $queueForMails, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Log $log, CertificatesAdapter $certificates, bool $skipRenewCheck = false): void - { + private function execute( + Domain $domain, + Database $dbForPlatform, + Mail $queueForMails, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Log $log, + CertificatesAdapter $certificates, + bool $skipRenewCheck = false + ): void { /** * 1. Read arguments and validate domain * 2. Get main domain @@ -209,8 +228,16 @@ class Certificates extends Action * @throws Conflict * @throws Structure */ - private function saveCertificateDocument(string $domain, Document $certificate, bool $success, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime): void - { + private function saveCertificateDocument( + string $domain, + Document $certificate, + bool $success, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime + ): void { // Check if update or insert required $certificateDocument = $dbForPlatform->findOne('certificates', [Query::equal('domain', [$domain])]); if (!$certificateDocument->isEmpty()) { @@ -342,8 +369,16 @@ class Certificates extends Action * * @return void */ - private function updateDomainDocuments(string $certificateId, string $domain, bool $success, Database $dbForPlatform, Event $queueForEvents, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime): void - { + private function updateDomainDocuments( + string $certificateId, + string $domain, + bool $success, + Database $dbForPlatform, + Event $queueForEvents, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime + ): void { // TODO: @christyjacob remove once we migrate the rules in 1.7.x if (System::getEnv('_APP_RULES_FORMAT') === 'md5') { $rule = $dbForPlatform->getDocument('rules', md5($domain)); diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index e8edb1c0a3..010973519c 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -98,8 +98,15 @@ class Databases extends Action * @throws \Exception * @throws \Throwable */ - private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForPlatform, Database $dbForProject, Realtime $queueForRealtime): void - { + private function createAttribute( + Document $database, + Document $collection, + Document $attribute, + Document $project, + Database $dbForPlatform, + Database $dbForProject, + Realtime $queueForRealtime + ): void { if ($collection->isEmpty()) { throw new Exception('Missing collection'); } diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 7be3cba7ad..4b5b11bce7 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -65,8 +65,22 @@ class Deletes extends Action * @throws Exception * @throws Throwable */ - public function action(Message $message, Document $project, Database $dbForPlatform, callable $getProjectDB, callable $getLogsDB, Device $deviceForFiles, Device $deviceForFunctions, Device $deviceForSites, Device $deviceForBuilds, Device $deviceForCache, CertificatesAdapter $certificates, string $executionRetention, string $auditRetention, Log $log): void - { + public function action( + Message $message, + Document $project, + Database $dbForPlatform, + callable $getProjectDB, + callable $getLogsDB, + Device $deviceForFiles, + Device $deviceForFunctions, + Device $deviceForSites, + Device $deviceForBuilds, + Device $deviceForCache, + CertificatesAdapter $certificates, + string $executionRetention, + string $auditRetention, + Log $log + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index 1bc67f2e0e..99dbea43b2 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -55,8 +55,18 @@ class Functions extends Action ->callback([$this, 'action']); } - public function action(Document $project, Message $message, Database $dbForProject, Webhook $queueForWebhooks, Func $queueForFunctions, Realtime $queueForRealtime, Event $queueForEvents, StatsUsage $queueForStatsUsage, Log $log, callable $isResourceBlocked): void - { + public function action( + Document $project, + Message $message, + Database $dbForProject, + Webhook $queueForWebhooks, + Func $queueForFunctions, + Realtime $queueForRealtime, + Event $queueForEvents, + StatsUsage $queueForStatsUsage, + Log $log, + callable $isResourceBlocked + ): void { $payload = $message->getPayload() ?? []; if (empty($payload)) { diff --git a/src/Appwrite/Platform/Workers/StatsUsage.php b/src/Appwrite/Platform/Workers/StatsUsage.php index a755f723a0..1d270fcd04 100644 --- a/src/Appwrite/Platform/Workers/StatsUsage.php +++ b/src/Appwrite/Platform/Workers/StatsUsage.php @@ -152,7 +152,11 @@ class StatsUsage extends Action case str_starts_with($document->getCollection(), 'database_') && !str_contains($document->getCollection(), 'collection'): //collections $parts = explode('_', $document->getCollection()); $databaseInternalId = $parts[1] ?? 0; - $documents = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace(['{databaseInternalId}', '{collectionInternalId}'], [$databaseInternalId, $document->getInternalId()], METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS))); + $documents = $dbForProject->getDocument('stats', md5(self::INFINITY_PERIOD . str_replace( + ['{databaseInternalId}', '{collectionInternalId}'], + [$databaseInternalId, $document->getInternalId()], + METRIC_DATABASE_ID_COLLECTION_ID_DOCUMENTS + ))); if (!empty($documents['value'])) { $metrics[] = [ From 08b74007f73641ada84c815598b27de902f13605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 16:20:31 +0100 Subject: [PATCH 34/35] Fix specs for console --- app/config/specs/open-api3-latest-console.json | 8 +++++++- app/config/specs/open-api3-latest-server.json | 8 +++++++- app/config/specs/swagger2-latest-console.json | 8 +++++++- app/config/specs/swagger2-latest-server.json | 8 +++++++- src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php | 6 ++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index db615b0411..8cd9ff6aa7 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -37986,13 +37986,19 @@ "type": "string", "description": "Default output directory of build.", "x-example": ".\/dist" + }, + "fallbackFile": { + "type": "string", + "description": "Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed.", + "x-example": "index.html" } }, "required": [ "key", "installCommand", "buildCommand", - "outputDirectory" + "outputDirectory", + "fallbackFile" ] }, "deployment": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index e819616de5..287ce791c3 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -27885,13 +27885,19 @@ "type": "string", "description": "Default output directory of build.", "x-example": ".\/dist" + }, + "fallbackFile": { + "type": "string", + "description": "Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed.", + "x-example": "index.html" } }, "required": [ "key", "installCommand", "buildCommand", - "outputDirectory" + "outputDirectory", + "fallbackFile" ] }, "deployment": { diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index cd814521be..89e23d8117 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -38573,13 +38573,19 @@ "type": "string", "description": "Default output directory of build.", "x-example": ".\/dist" + }, + "fallbackFile": { + "type": "string", + "description": "Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed.", + "x-example": "index.html" } }, "required": [ "key", "installCommand", "buildCommand", - "outputDirectory" + "outputDirectory", + "fallbackFile" ] }, "deployment": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index db2f32abcc..b7371b1bbd 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -28439,13 +28439,19 @@ "type": "string", "description": "Default output directory of build.", "x-example": ".\/dist" + }, + "fallbackFile": { + "type": "string", + "description": "Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed.", + "x-example": "index.html" } }, "required": [ "key", "installCommand", "buildCommand", - "outputDirectory" + "outputDirectory", + "fallbackFile" ] }, "deployment": { diff --git a/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php b/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php index 8348f3a6d5..afbd78eda4 100644 --- a/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php +++ b/src/Appwrite/Utopia/Response/Model/FrameworkAdapter.php @@ -34,6 +34,12 @@ class FrameworkAdapter extends Model 'default' => '', 'example' => './dist', ]) + ->addRule('fallbackFile', [ + 'type' => self::TYPE_STRING, + 'description' => 'Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed.', + 'default' => null, + 'example' => 'index.html', + ]) ; } From 2dcebf30835a2b68b48e294c0a25feeb92edcf32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 20 Mar 2025 16:48:09 +0100 Subject: [PATCH 35/35] Add remaining changes after sync with 1.7.x --- .../specs/open-api3-latest-console.json | 3 +- app/config/specs/swagger2-latest-console.json | 3 +- composer.lock | 54 ++++++++++--------- .../Functions/Http/Executions/Create.php | 2 +- .../Functions/Http/Functions/Create.php | 2 +- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 8cd9ff6aa7..9e9f99db63 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -19353,8 +19353,7 @@ "description": "Project Region.", "x-example": "default", "enum": [ - "default", - "fra" + "default" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 89e23d8117..05acf4a551 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -19823,8 +19823,7 @@ "default": "default", "x-example": "default", "enum": [ - "default", - "fra" + "default" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/composer.lock b/composer.lock index 3ac8abaead..aa9598eb05 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": "eca74b44aa6dc476aa8056344e87f363", + "content-hash": "eeb306ee6d2576e466ceea5e927664d0", "packages": [ { "name": "adhocore/jwt", @@ -753,16 +753,16 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10" + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", - "reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a", + "reference": "4d7aa5dab42e2a76d99559706022885de0e18e1a", "shasum": "" }, "require": { @@ -772,8 +772,9 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^1.4", + "phpstan/phpstan": "^2.0", "phpunit/phpunit": "^7.5|^8.5|^9.6", + "rector/rector": "^2.0", "vimeo/psalm": "^4.3 || ^5.0" }, "type": "library", @@ -806,9 +807,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.1" }, - "time": "2024-11-18T16:19:46+00:00" + "time": "2025-03-19T14:43:43+00:00" }, { "name": "league/csv", @@ -4204,16 +4205,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.22", + "version": "0.8.1", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "a0269746bd318ff0993f5aa008675b971689d5b5" + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/a0269746bd318ff0993f5aa008675b971689d5b5", - "reference": "a0269746bd318ff0993f5aa008675b971689d5b5", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", + "reference": "36ec7af2e6bf78de5d86e1b0a953fd7dcdf69dab", "shasum": "" }, "require": { @@ -4254,9 +4255,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.22" + "source": "https://github.com/utopia-php/migration/tree/0.8.1" }, - "time": "2025-03-13T07:35:55+00:00" + "time": "2025-03-18T07:48:08+00:00" }, { "name": "utopia-php/mongo", @@ -4420,25 +4421,26 @@ }, { "name": "utopia-php/pools", - "version": "0.5.0", + "version": "0.7.0", "source": { "type": "git", "url": "https://github.com/utopia-php/pools.git", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817" + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/pools/zipball/6f716a213a08db95eda1b5dddfa90983c1834817", - "reference": "6f716a213a08db95eda1b5dddfa90983c1834817", + "url": "https://api.github.com/repos/utopia-php/pools/zipball/ad64d45afda08ec8b29e2642a8d18075964d40bf", + "reference": "ad64d45afda08ec8b29e2642a8d18075964d40bf", "shasum": "" }, "require": { - "php": ">=8.0" + "php": ">=8.3", + "utopia-php/telemetry": "0.1.*" }, "require-dev": { - "laravel/pint": "1.2.*", - "phpstan/phpstan": "1.8.*", - "phpunit/phpunit": "^9.3" + "laravel/pint": "1.*", + "phpstan/phpstan": "1.*", + "phpunit/phpunit": "11.*" }, "type": "library", "autoload": { @@ -4465,9 +4467,9 @@ ], "support": { "issues": "https://github.com/utopia-php/pools/issues", - "source": "https://github.com/utopia-php/pools/tree/0.5.0" + "source": "https://github.com/utopia-php/pools/tree/0.7.0" }, - "time": "2024-04-19T11:11:54+00:00" + "time": "2025-03-18T03:55:33+00:00" }, { "name": "utopia-php/preloader", @@ -8505,7 +8507,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -8529,5 +8531,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php index 2e47c04276..7e89196a5b 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Executions/Create.php @@ -300,7 +300,7 @@ class Create extends Base ]; $schedule = $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => $project->getAttribute('region'), 'resourceType' => ScheduleExecutions::getSupportedResource(), 'resourceId' => $execution->getId(), 'resourceInternalId' => $execution->getInternalId(), diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index 552d9655f1..28f2c3cd1f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -207,7 +207,7 @@ class Create extends Base $schedule = Authorization::skip( fn () => $dbForPlatform->createDocument('schedules', new Document([ - 'region' => System::getEnv('_APP_REGION', 'default'), // Todo replace with projects region + 'region' => $project->getAttribute('region'), 'resourceType' => 'function', 'resourceId' => $function->getId(), 'resourceInternalId' => $function->getInternalId(),