mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
AI code review fixes
This commit is contained in:
@@ -1164,6 +1164,11 @@ return [
|
||||
'description' => 'Platform with the requested ID could not be found.',
|
||||
'code' => 404,
|
||||
],
|
||||
Exception::PLATFORM_METHOD_UNSUPPORTED => [
|
||||
'name' => Exception::PLATFORM_METHOD_UNSUPPORTED,
|
||||
'description' => 'The requested platform has invalid type. Please use coresponding update method for the platform type.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::PLATFORM_ALREADY_EXISTS => [
|
||||
'name' => Exception::PLATFORM_ALREADY_EXISTS,
|
||||
'description' => 'Platform with the same ID already exists in this project. Try again with a different ID.',
|
||||
|
||||
@@ -330,6 +330,7 @@ class Exception extends \Exception
|
||||
|
||||
/** Platform */
|
||||
public const string PLATFORM_NOT_FOUND = 'platform_not_found';
|
||||
public const string PLATFORM_METHOD_UNSUPPORTED = 'platform_method_unsupported';
|
||||
public const string PLATFORM_ALREADY_EXISTS = 'platform_already_exists';
|
||||
|
||||
/** GraphqQL */
|
||||
|
||||
@@ -86,7 +86,7 @@ class Create extends Base
|
||||
new WhiteList($this->getSupportedTypes(), true),
|
||||
'Platform type. Possible values are: ' . implode(', ', $this->getSupportedTypes())
|
||||
)
|
||||
->param('identifier', '', new Text(256), 'Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.', true)
|
||||
->param('identifier', '', new Text(256), 'Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.')
|
||||
->inject('response')
|
||||
->inject('queueForEvents')
|
||||
->inject('project')
|
||||
@@ -109,7 +109,7 @@ class Create extends Base
|
||||
$platformId = ($platformId == 'unique()') ? ID::unique() : $platformId;
|
||||
|
||||
$platform = new Document([
|
||||
'$id' => ID::unique(),
|
||||
'$id' => $platformId,
|
||||
'$permissions' => [],
|
||||
'projectInternalId' => $project->getSequence(),
|
||||
'projectId' => $project->getId(),
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms\App;
|
||||
use Appwrite\Event\Event as QueueEvent;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Compute\Base;
|
||||
use Appwrite\Platform\Modules\Project\Http\Project\Platforms\App\Create as AppPlatformCreate;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
@@ -54,7 +55,7 @@ class Update extends Base
|
||||
))
|
||||
->param('platformId', '', fn (Database $dbForPlatform) => new UID($dbForPlatform->getAdapter()->getMaxUIDLength()), 'Platform ID.', false, ['dbForPlatform'])
|
||||
->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.')
|
||||
->param('identifier', '', new Text(256), 'Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.', true)
|
||||
->param('identifier', '', new Text(256), 'Package name for Android or bundle ID for iOS or macOS. Max length: 256 chars.')
|
||||
->inject('response')
|
||||
->inject('queueForEvents')
|
||||
->inject('dbForPlatform')
|
||||
@@ -79,9 +80,14 @@ class Update extends Base
|
||||
throw new Exception(Exception::PLATFORM_NOT_FOUND);
|
||||
}
|
||||
|
||||
$appPlatforms = AppPlatformCreate::getSupportedTypes();
|
||||
if (!\in_array($platform->getAttribute('type', ''), $appPlatforms)) {
|
||||
throw new Exception(Exception::PLATFORM_METHOD_UNSUPPORTED);
|
||||
}
|
||||
|
||||
$updates = new Document([
|
||||
'name' => $name,
|
||||
'identifier' => $identifier,
|
||||
'key' => $identifier,
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
@@ -77,7 +77,7 @@ class Create extends Base
|
||||
new WhiteList($this->getSupportedTypes(), true),
|
||||
'Platform type. Possible values are: ' . implode(', ', $this->getSupportedTypes())
|
||||
)
|
||||
->param('hostname', '', new Hostname(), 'Platform web hostname. Max length: 256 chars.', true)
|
||||
->param('hostname', '', new Hostname(), 'Platform web hostname. Max length: 256 chars.')
|
||||
->inject('response')
|
||||
->inject('queueForEvents')
|
||||
->inject('project')
|
||||
@@ -100,7 +100,7 @@ class Create extends Base
|
||||
$platformId = ($platformId == 'unique()') ? ID::unique() : $platformId;
|
||||
|
||||
$platform = new Document([
|
||||
'$id' => ID::unique(),
|
||||
'$id' => $platformId,
|
||||
'$permissions' => [],
|
||||
'projectInternalId' => $project->getSequence(),
|
||||
'projectId' => $project->getId(),
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Appwrite\Platform\Modules\Project\Http\Project\Platforms\Web;
|
||||
use Appwrite\Event\Event as QueueEvent;
|
||||
use Appwrite\Extend\Exception;
|
||||
use Appwrite\Platform\Modules\Compute\Base;
|
||||
use Appwrite\Platform\Modules\Project\Http\Project\Platforms\Web\Create as WebPlatformCreate;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
@@ -55,7 +56,7 @@ class Update extends Base
|
||||
))
|
||||
->param('platformId', '', fn (Database $dbForPlatform) => new UID($dbForPlatform->getAdapter()->getMaxUIDLength()), 'Platform ID.', false, ['dbForPlatform'])
|
||||
->param('name', null, new Text(128), 'Platform name. Max length: 128 chars.')
|
||||
->param('hostname', '', new Hostname(), 'Platform client hostname. Max length: 256 chars.', true)
|
||||
->param('hostname', '', new Hostname(), 'Platform client hostname. Max length: 256 chars.')
|
||||
->inject('response')
|
||||
->inject('queueForEvents')
|
||||
->inject('dbForPlatform')
|
||||
@@ -80,6 +81,11 @@ class Update extends Base
|
||||
throw new Exception(Exception::PLATFORM_NOT_FOUND);
|
||||
}
|
||||
|
||||
$webPlatforms = WebPlatformCreate::getSupportedTypes();
|
||||
if (!\in_array($platform->getAttribute('type', ''), $webPlatforms)) {
|
||||
throw new Exception(Exception::PLATFORM_METHOD_UNSUPPORTED);
|
||||
}
|
||||
|
||||
$updates = new Document([
|
||||
'name' => $name,
|
||||
'hostname' => $hostname,
|
||||
|
||||
@@ -40,7 +40,7 @@ class PlatformApp extends PlatformBase
|
||||
'description' => 'Platform type. Possible values are: ' . implode(', ', $this->getSupportedTypes()) . '.',
|
||||
'default' => '',
|
||||
'example' => NetworkPlatform::TYPE_APPLE_IOS,
|
||||
'enum' => [$this->getSupportedTypes()],
|
||||
'enum' => $this->getSupportedTypes(),
|
||||
])
|
||||
->addRule('identifier', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
||||
@@ -12,7 +12,7 @@ class PlatformList extends Model
|
||||
$this
|
||||
->addRule('total', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total number of platforms in the given table.',
|
||||
'description' => 'Total number of platforms in the given project.',
|
||||
'default' => 0,
|
||||
'example' => 5,
|
||||
])
|
||||
|
||||
@@ -29,7 +29,7 @@ class PlatformWeb extends PlatformBase
|
||||
'description' => 'Platform type. Possible values are: ' . implode(', ', $this->getSupportedTypes()) . '.',
|
||||
'default' => '',
|
||||
'example' => NetworkPlatform::TYPE_WEB,
|
||||
'enum' => [$this->getSupportedTypes()],
|
||||
'enum' => $this->getSupportedTypes(),
|
||||
])
|
||||
->addRule('hostname', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
||||
@@ -182,7 +182,10 @@ class Project extends Model
|
||||
'array' => true,
|
||||
])
|
||||
->addRule('platforms', [
|
||||
'type' => Response::MODEL_PLATFORM,
|
||||
'type' => [
|
||||
Response::MODEL_PLATFORM_WEB,
|
||||
Response::MODEL_PLATFORM_APP,
|
||||
],
|
||||
'description' => 'List of Platforms.',
|
||||
'default' => [],
|
||||
'example' => new \stdClass(),
|
||||
|
||||
Reference in New Issue
Block a user