From ac51fcbf4ed66eca3eef1582d0d8fc4b634f1aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Thu, 27 Feb 2025 10:04:11 +0100 Subject: [PATCH] Preps for Console SDK --- .../specs/open-api3-latest-console.json | 44 ++++++++++++------ app/config/specs/open-api3-latest-server.json | 26 +++++++---- app/config/specs/swagger2-latest-console.json | 46 +++++++++++++------ app/config/specs/swagger2-latest-server.json | 26 +++++++---- .../Modules/Console/Http/Resources/Get.php | 2 +- .../Proxy/Http/Rules/Function/Create.php | 7 ++- .../Modules/Proxy/Http/Rules/Site/Create.php | 2 +- src/Appwrite/Specification/Format.php | 12 +++++ 8 files changed, 113 insertions(+), 52 deletions(-) diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 1558f3a0c4..6be9d6e5e0 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -4398,7 +4398,7 @@ "enum": [ "rules" ], - "x-enum-name": null, + "x-enum-name": "ConsoleResourceType", "x-enum-keys": [] }, "in": "query" @@ -23834,6 +23834,11 @@ "type": "string", "description": "ID of function to be executed.", "x-example": "" + }, + "branch": { + "type": "string", + "description": "Name of VCS branch to deploy changes automatically", + "x-example": "" } }, "required": [ @@ -23904,8 +23909,8 @@ }, "target": { "type": "string", - "description": "Target URL of redirection", - "x-example": "https:\/\/example.com" + "description": "Target domain (hostname) of redirection", + "x-example": null } }, "required": [ @@ -23978,6 +23983,11 @@ "type": "string", "description": "ID of site to be executed.", "x-example": "" + }, + "branch": { + "type": "string", + "description": "Name of VCS branch to deploy changes automatically", + "x-example": "" } }, "required": [ @@ -24405,8 +24415,14 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Allows: static, ssr", - "x-example": "" + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "installationId": { "type": "string", @@ -24972,8 +24988,14 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Usuallly allows: static, ssr", - "x-example": "" + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "fallbackFile": { "type": "string", @@ -37367,11 +37389,6 @@ "x-example": 128, "format": "int32" }, - "domain": { - "type": "string", - "description": "Preview domain.", - "x-example": "deploy1-project1.appwrite.site" - }, "providerRepositoryName": { "type": "string", "description": "The name of the vcs provider repository", @@ -37440,7 +37457,6 @@ "status", "buildLogs", "buildTime", - "domain", "providerRepositoryName", "providerRepositoryOwner", "providerRepositoryUrl", @@ -39992,7 +40008,7 @@ }, "automation": { "type": "string", - "description": "Action that result in update of rule. If VCS branch, value can be of syntax \"branch=[name]\"", + "description": "Action that results in a rule update. If VCS branch, value can be of syntax \"branch=[name]\"", "x-example": "branch=dev" }, "status": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index 2c0375e357..9bc803d777 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -16526,8 +16526,14 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Allows: static, ssr", - "x-example": "" + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "installationId": { "type": "string", @@ -16871,8 +16877,14 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Usuallly allows: static, ssr", - "x-example": "" + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "fallbackFile": { "type": "string", @@ -27488,11 +27500,6 @@ "x-example": 128, "format": "int32" }, - "domain": { - "type": "string", - "description": "Preview domain.", - "x-example": "deploy1-project1.appwrite.site" - }, "providerRepositoryName": { "type": "string", "description": "The name of the vcs provider repository", @@ -27561,7 +27568,6 @@ "status", "buildLogs", "buildTime", - "domain", "providerRepositoryName", "providerRepositoryOwner", "providerRepositoryUrl", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 5322f41ed7..8b6dfb954d 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -4604,7 +4604,7 @@ "enum": [ "rules" ], - "x-enum-name": null, + "x-enum-name": "ConsoleResourceType", "x-enum-keys": [], "in": "query" } @@ -24324,6 +24324,12 @@ "description": "ID of function to be executed.", "default": null, "x-example": "" + }, + "branch": { + "type": "string", + "description": "Name of VCS branch to deploy changes automatically", + "default": "", + "x-example": "" } }, "required": [ @@ -24397,9 +24403,9 @@ }, "target": { "type": "string", - "description": "Target URL of redirection", + "description": "Target domain (hostname) of redirection", "default": null, - "x-example": "https:\/\/example.com" + "x-example": null } }, "required": [ @@ -24476,6 +24482,12 @@ "description": "ID of site to be executed.", "default": null, "x-example": "" + }, + "branch": { + "type": "string", + "description": "Name of VCS branch to deploy changes automatically", + "default": "", + "x-example": "" } }, "required": [ @@ -24918,9 +24930,15 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Allows: static, ssr", + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", "default": "", - "x-example": "" + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "installationId": { "type": "string", @@ -25497,9 +25515,15 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Usuallly allows: static, ssr", + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", "default": "", - "x-example": "" + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "fallbackFile": { "type": "string", @@ -37960,11 +37984,6 @@ "x-example": 128, "format": "int32" }, - "domain": { - "type": "string", - "description": "Preview domain.", - "x-example": "deploy1-project1.appwrite.site" - }, "providerRepositoryName": { "type": "string", "description": "The name of the vcs provider repository", @@ -38033,7 +38052,6 @@ "status", "buildLogs", "buildTime", - "domain", "providerRepositoryName", "providerRepositoryOwner", "providerRepositoryUrl", @@ -40656,7 +40674,7 @@ }, "automation": { "type": "string", - "description": "Action that result in update of rule. If VCS branch, value can be of syntax \"branch=[name]\"", + "description": "Action that results in a rule update. If VCS branch, value can be of syntax \"branch=[name]\"", "x-example": "branch=dev" }, "status": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index d0dace624e..8d7586da05 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -17008,9 +17008,15 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Allows: static, ssr", + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", "default": "", - "x-example": "" + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "installationId": { "type": "string", @@ -17369,9 +17375,15 @@ }, "adapter": { "type": "string", - "description": "Framework adapter. Usuallly allows: static, ssr", + "description": "Framework adapter defining rendering strategy. Allowed values are: static, ssr", "default": "", - "x-example": "" + "x-example": "static", + "enum": [ + "static", + "ssr" + ], + "x-enum-name": null, + "x-enum-keys": [] }, "fallbackFile": { "type": "string", @@ -28054,11 +28066,6 @@ "x-example": 128, "format": "int32" }, - "domain": { - "type": "string", - "description": "Preview domain.", - "x-example": "deploy1-project1.appwrite.site" - }, "providerRepositoryName": { "type": "string", "description": "The name of the vcs provider repository", @@ -28127,7 +28134,6 @@ "status", "buildLogs", "buildTime", - "domain", "providerRepositoryName", "providerRepositoryOwner", "providerRepositoryUrl", diff --git a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php index dc13e717f0..28e7194b2c 100644 --- a/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php +++ b/src/Appwrite/Platform/Modules/Console/Http/Resources/Get.php @@ -23,7 +23,7 @@ class Get extends Action public static function getName() { - return 'getResources'; + return 'getResource'; } public function __construct() diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php index f09957aa04..bcc3b91e8f 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php @@ -21,6 +21,7 @@ use Utopia\Platform\Action; use Utopia\Platform\Scope\HTTP; use Utopia\System\System; use Utopia\Validator\Domain as ValidatorDomain; +use Utopia\Validator\Text; class Create extends Action { @@ -61,6 +62,7 @@ class Create extends Action ->label('abuse-time', 60) ->param('domain', null, new ValidatorDomain(), 'Domain name.') ->param('functionId', '', new UID(), 'ID of function to be executed.') + ->param('branch', '', new Text(255, 0), 'Name of VCS branch to deploy changes automatically', true) ->inject('response') ->inject('project') ->inject('queueForCertificates') @@ -70,7 +72,7 @@ class Create extends Action ->callback([$this, 'action']); } - public function action(string $domain, string $functionId, Response $response, Document $project, Certificate $queueForCertificates, Event $queueForEvents, Database $dbForPlatform, Database $dbForProject) + public function action(string $domain, string $functionId, string $branch, Response $response, Document $project, Certificate $queueForCertificates, Event $queueForEvents, Database $dbForPlatform, Database $dbForProject) { $mainDomain = System::getEnv('_APP_DOMAIN', ''); $sitesDomain = System::getEnv('_APP_DOMAIN_SITES', ''); @@ -131,7 +133,8 @@ class Create extends Action 'value' => $function->getAttribute('deployment', ''), 'certificateId' => '', 'automation' => 'function=' . $function->getId(), - 'search' => implode(' ', [$ruleId, $domain->get()]), + 'automation' => !empty($branch) ? ('branch=' . $branch) : ('function=' . $function->getId()), + 'search' => implode(' ', [$ruleId, $domain->get(), $branch]), ]); try { diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php index 0a3a528f30..b6e88be00c 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php @@ -133,7 +133,7 @@ class Create extends Action 'value' => $site->getAttribute('deploymentId', ''), 'certificateId' => '', 'automation' => !empty($branch) ? ('branch=' . $branch) : ('site=' . $site->getId()), - 'search' => implode(' ', [$ruleId, $domain->get()]), + 'search' => implode(' ', [$ruleId, $domain->get(), $branch]), ]); try { diff --git a/src/Appwrite/Specification/Format.php b/src/Appwrite/Specification/Format.php index 038f5369f5..f4bec326e7 100644 --- a/src/Appwrite/Specification/Format.php +++ b/src/Appwrite/Specification/Format.php @@ -113,6 +113,18 @@ abstract class Format protected function getEnumName(string $service, string $method, string $param): ?string { switch ($service) { + case 'console': + switch ($method) { + case 'getResource': + switch ($param) { + case 'type': + return 'ConsoleResourceType'; + case 'value': + return 'ConsoleResourceValue'; + } + break; + } + break; case 'account': switch ($method) { case 'createOAuth2Session':