From 7aecd3814aede58d88cb0675f3863439feb364e9 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 9 Apr 2025 09:15:36 +0000 Subject: [PATCH] fix: minor mistakes in devkeys naming and initialization --- app/config/collections/platform.php | 2 +- app/init/constants.php | 1 + .../Platform/Modules/Projects/Http/DevKeys/Create.php | 2 +- .../Platform/Modules/Projects/Http/DevKeys/Delete.php | 4 ++-- src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Get.php | 2 +- .../Platform/Modules/Projects/Http/DevKeys/Update.php | 4 ++-- .../Platform/Modules/Projects/Http/DevKeys/XList.php | 6 +++--- src/Appwrite/Utopia/Response.php | 2 +- src/Appwrite/Utopia/Response/Model/DevKey.php | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index 24223acbd3..39a5889b67 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -722,7 +722,7 @@ return [ 'format' => '', 'size' => Database::LENGTH_KEY, 'signed' => true, - 'required' => false, + 'required' => true, 'default' => 0, 'array' => false, 'filters' => [], diff --git a/app/init/constants.php b/app/init/constants.php index 5e4edfd97d..9d3a08ed76 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -26,6 +26,7 @@ const APP_LIMIT_SUBSCRIBERS_SUBQUERY = 1_000_000; const APP_LIMIT_WRITE_RATE_DEFAULT = 60; // Default maximum write rate per rate period const APP_LIMIT_WRITE_RATE_PERIOD_DEFAULT = 60; // Default maximum write rate period in seconds const APP_LIMIT_LIST_DEFAULT = 25; // Default maximum number of items to return in list API calls +const APP_LIMIT_DEV_KEYS = 5000; // Default maximum number of dev keys to return in list API calls const APP_KEY_ACCESS = 24 * 60 * 60; // 24 hours const APP_USER_ACCESS = 24 * 60 * 60; // 24 hours const APP_PROJECT_ACCESS = 24 * 60 * 60; // 24 hours diff --git a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Create.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Create.php index 778f87e417..baf126cf5b 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Create.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Create.php @@ -55,7 +55,7 @@ class Create extends Action ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.', false) ->inject('response') ->inject('dbForPlatform') - ->callback(fn ($projectId, $name, $expire, $response, $dbForPlatform) => $this->action($projectId, $name, $expire, $response, $dbForPlatform)); + ->callback([$this, 'action']); } public function action(string $projectId, string $name, ?string $expire, Response $response, Database $dbForPlatform) diff --git a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Delete.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Delete.php index 635a0e77b9..4fabcc4db1 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Delete.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Delete.php @@ -39,7 +39,7 @@ class Delete extends Action auth: [AuthType::ADMIN], responses: [ new SDKResponse( - code: Response::STATUS_CODE_CREATED, + code: Response::STATUS_CODE_NOCONTENT, model: Response::MODEL_NONE ) ], @@ -49,7 +49,7 @@ class Delete extends Action ->param('keyId', '', new UID(), 'Key unique ID.') ->inject('response') ->inject('dbForPlatform') - ->callback(fn ($projectId, $keyId, $response, $dbForPlatform) => $this->action($projectId, $keyId, $response, $dbForPlatform)); + ->callback([$this, 'action']); } public function action(string $projectId, string $keyId, Response $response, Database $dbForPlatform) diff --git a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Get.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Get.php index eda87238d6..bfbfd6e76c 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Get.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Get.php @@ -49,7 +49,7 @@ class Get extends Action ->param('keyId', '', new UID(), 'Key unique ID.') ->inject('response') ->inject('dbForPlatform') - ->callback(fn ($projectId, $keyId, $response, $dbForPlatform) => $this->action($projectId, $keyId, $response, $dbForPlatform)); + ->callback([$this, 'action']); } public function action(string $projectId, string $keyId, Response $response, Database $dbForPlatform) diff --git a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Update.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Update.php index 7941657a44..7513805913 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Update.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/Update.php @@ -40,7 +40,7 @@ class Update extends Action auth: [AuthType::ADMIN], responses: [ new SDKResponse( - code: Response::STATUS_CODE_CREATED, + code: Response::STATUS_CODE_OK, model: Response::MODEL_DEV_KEY ) ], @@ -52,7 +52,7 @@ class Update extends Action ->param('expire', null, new DatetimeValidator(), 'Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.') ->inject('response') ->inject('dbForPlatform') - ->callback(fn ($projectId, $keyId, $name, $expire, $response, $dbForPlatform) => $this->action($projectId, $keyId, $name, $expire, $response, $dbForPlatform)); + ->callback([$this, 'action']); } public function action(string $projectId, string $keyId, string $name, ?string $expire, Response $response, Database $dbForPlatform) { diff --git a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/XList.php b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/XList.php index 77315a1522..7221d54cda 100644 --- a/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/XList.php +++ b/src/Appwrite/Platform/Modules/Projects/Http/DevKeys/XList.php @@ -40,7 +40,7 @@ class XList extends Action auth: [AuthType::ADMIN], responses: [ new SDKResponse( - code: Response::STATUS_CODE_CREATED, + code: Response::STATUS_CODE_OK, model: Response::MODEL_DEV_KEY_LIST ) ], @@ -49,7 +49,7 @@ class XList extends Action ->param('projectId', '', new UID(), 'Project unique ID.') ->inject('response') ->inject('dbForPlatform') - ->callback(fn ($projectId, $response, $dbForPlatform) => $this->action($projectId, $response, $dbForPlatform)); + ->callback([$this, 'action']); } public function action(string $projectId, Response $response, Database $dbForPlatform) @@ -63,7 +63,7 @@ class XList extends Action $keys = $dbForPlatform->find('devKeys', [ Query::equal('projectInternalId', [$project->getInternalId()]), - Query::limit(5000), + Query::limit(APP_LIMIT_DEV_KEYS), ]); $response->dynamic(new Document([ diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index c196331346..55270f5ff9 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -366,7 +366,7 @@ class Response extends SwooleResponse ->setModel(new BaseList('Projects List', self::MODEL_PROJECT_LIST, 'projects', self::MODEL_PROJECT, true, false)) ->setModel(new BaseList('Webhooks List', self::MODEL_WEBHOOK_LIST, 'webhooks', self::MODEL_WEBHOOK, true, false)) ->setModel(new BaseList('API Keys List', self::MODEL_KEY_LIST, 'keys', self::MODEL_KEY, true, false)) - ->setModel(new BaseList('Dev Keys List', self::MODEL_DEV_KEY_LIST, 'keys', self::MODEL_DEV_KEY, true, false)) + ->setModel(new BaseList('Dev Keys List', self::MODEL_DEV_KEY_LIST, 'devKeys', self::MODEL_DEV_KEY, true, false)) ->setModel(new BaseList('Auth Providers List', self::MODEL_AUTH_PROVIDER_LIST, 'platforms', self::MODEL_AUTH_PROVIDER, true, false)) ->setModel(new BaseList('Platforms List', self::MODEL_PLATFORM_LIST, 'platforms', self::MODEL_PLATFORM, true, false)) ->setModel(new BaseList('Countries List', self::MODEL_COUNTRY_LIST, 'countries', self::MODEL_COUNTRY)) diff --git a/src/Appwrite/Utopia/Response/Model/DevKey.php b/src/Appwrite/Utopia/Response/Model/DevKey.php index 50ce750b6a..d1074bd7d3 100644 --- a/src/Appwrite/Utopia/Response/Model/DevKey.php +++ b/src/Appwrite/Utopia/Response/Model/DevKey.php @@ -37,7 +37,7 @@ class DevKey extends Model 'type' => self::TYPE_STRING, 'description' => 'Key name.', 'default' => '', - 'example' => 'My API Key', + 'example' => 'Dev API Key', ]) ->addRule('expire', [ 'type' => self::TYPE_DATETIME,