mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Self review after refactor
This commit is contained in:
@@ -594,7 +594,7 @@ $platformCollections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('key'), // Identifier on API
|
||||
'$id' => ID::custom('key'), // For app platforms
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
@@ -616,7 +616,7 @@ $platformCollections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('hostname'),
|
||||
'$id' => ID::custom('hostname'), // For web platforms
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 256,
|
||||
|
||||
@@ -86,7 +86,7 @@ class Create extends Base
|
||||
'type' => Platform::TYPE_LINUX,
|
||||
'name' => $name,
|
||||
'key' => $packageName,
|
||||
'hostname' => null, // Web platform attribute
|
||||
'hostname' => '', // Web platform attribute
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
@@ -9,7 +9,6 @@ use Appwrite\Platform\Modules\Compute\Base;
|
||||
use Appwrite\SDK\AuthType;
|
||||
use Appwrite\SDK\Method;
|
||||
use Appwrite\SDK\Response as SDKResponse;
|
||||
use Appwrite\Utopia\Request;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
|
||||
@@ -86,7 +86,7 @@ class Create extends Base
|
||||
'projectId' => $project->getId(),
|
||||
'type' => Platform::TYPE_WEB,
|
||||
'name' => $name,
|
||||
'key' => null, // App platform attribute
|
||||
'key' => '', // App platform attribute
|
||||
'hostname' => $hostname
|
||||
]);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class XList extends Base
|
||||
}
|
||||
|
||||
foreach ($queries as $query) {
|
||||
if (\in_array($query->getAttribute(), ['identifier', 'bundleIdentifier', 'applicationId', 'packageIdentifierName', 'packageName'])) {
|
||||
if (\in_array($query->getAttribute(), ['bundleIdentifier', 'applicationId', 'packageIdentifierName', 'packageName'])) {
|
||||
$query->setAttribute('key');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ class Platforms extends Base
|
||||
'type',
|
||||
'name',
|
||||
'hostname',
|
||||
'identifier',
|
||||
'bundleIdentifier',
|
||||
'applicationId',
|
||||
'packageIdentifierName',
|
||||
|
||||
@@ -12,48 +12,57 @@ class V21 extends Filter
|
||||
{
|
||||
switch ($model) {
|
||||
case 'project.createWebPlatform':
|
||||
case 'project.createAppPlatform':
|
||||
$content = $this->fillPlatformId($content);
|
||||
|
||||
// Remove store ID
|
||||
unset($content['store']);
|
||||
|
||||
// key -> identifier
|
||||
$content['identifier'] = $content['identifier'] ?? $content['key'] ?? null;
|
||||
unset($content['key']);
|
||||
|
||||
$content = $this->removePlatformStore($content);
|
||||
unset($content['key']); // Key unsupported
|
||||
break;
|
||||
case 'project.updateWebPlatform':
|
||||
$content = $this->removePlatformStore($content);
|
||||
unset($content['key']); // Key unsupported
|
||||
break;
|
||||
case 'project.createApplePlatform':
|
||||
$content = $this->fillPlatformId($content);
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'bundleIdentifier');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.updateApplePlatform':
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'bundleIdentifier');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.createAndroidPlatform':
|
||||
$content = $this->fillPlatformId($content);
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'applicationId');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.updateAndroidPlatform':
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'applicationId');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.createWindowsPlatform':
|
||||
$content = $this->fillPlatformId($content);
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'packageIdentifierName');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.updateWindowsPlatform':
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'packageIdentifierName');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.createLinuxPlatform':
|
||||
$content = $this->fillPlatformId($content);
|
||||
|
||||
// Remove store ID
|
||||
unset($content['store']);
|
||||
|
||||
// key -> packageName
|
||||
$content['packageName'] = $content['packageName'] ?? $content['identifier'] ?? $content['key'] ?? null;
|
||||
unset($content['key']);
|
||||
unset($content['identifier']);
|
||||
|
||||
break;
|
||||
case 'project.updateWebPlatform':
|
||||
case 'project.updateAppPlatform':
|
||||
// Remove store ID
|
||||
unset($content['store']);
|
||||
|
||||
// key -> identifier
|
||||
$content['identifier'] = $content['identifier'] ?? $content['key'] ?? null;
|
||||
unset($content['key']);
|
||||
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'packageName');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.updateLinuxPlatform':
|
||||
// Remove store ID
|
||||
unset($content['store']);
|
||||
|
||||
// key -> packageName
|
||||
$content['packageName'] = $content['packageName'] ?? $content['identifier'] ?? $content['key'] ?? null;
|
||||
unset($content['key']);
|
||||
unset($content['identifier']);
|
||||
|
||||
$content = $this->removePlatformStore($content);
|
||||
$content = $this->replacePlatformKey($content, 'packageName');
|
||||
unset($content['hostname']); // Hostname unsupported
|
||||
break;
|
||||
case 'project.listPlatforms':
|
||||
$content = $this->preservePlatformsQueries($content);
|
||||
@@ -118,6 +127,20 @@ class V21 extends Filter
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function replacePlatformKey(array $content, string $newKey): array
|
||||
{
|
||||
$content[$newKey] = $content[$newKey] ?? $content['key'] ?? null;
|
||||
unset($content['key']);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function removePlatformStore(array $content): array
|
||||
{
|
||||
unset($content['store']);
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function fillVariableId(array $content): array
|
||||
{
|
||||
$content['variableId'] = $content['variableId'] ?? 'unique()';
|
||||
|
||||
@@ -256,7 +256,6 @@ class Response extends SwooleResponse
|
||||
public const MODEL_MOCK_NUMBER = 'mockNumber';
|
||||
public const MODEL_AUTH_PROVIDER = 'authProvider';
|
||||
public const MODEL_AUTH_PROVIDER_LIST = 'authProviderList';
|
||||
public const MODEL_PLATFORM_APP = 'platformApp'; // Deprecated - kept for backwards compatibility
|
||||
public const MODEL_PLATFORM_APPLE = 'platformApple';
|
||||
public const MODEL_PLATFORM_ANDROID = 'platformAndroid';
|
||||
public const MODEL_PLATFORM_WINDOWS = 'platformWindows';
|
||||
|
||||
@@ -12,7 +12,6 @@ class V21 extends Filter
|
||||
{
|
||||
return match ($model) {
|
||||
Response::MODEL_PLATFORM_WEB => $this->parsePlatform($content),
|
||||
Response::MODEL_PLATFORM_APP => $this->parsePlatform($content),
|
||||
Response::MODEL_PLATFORM_APPLE => $this->parsePlatform($content),
|
||||
Response::MODEL_PLATFORM_ANDROID => $this->parsePlatform($content),
|
||||
Response::MODEL_PLATFORM_WINDOWS => $this->parsePlatform($content),
|
||||
@@ -63,14 +62,12 @@ class V21 extends Filter
|
||||
?? $content['applicationId']
|
||||
?? $content['packageIdentifierName']
|
||||
?? $content['packageName']
|
||||
?? $content['identifier']
|
||||
?? $content['key']
|
||||
?? '';
|
||||
unset($content['bundleIdentifier']);
|
||||
unset($content['applicationId']);
|
||||
unset($content['packageIdentifierName']);
|
||||
unset($content['packageName']);
|
||||
unset($content['identifier']);
|
||||
|
||||
// Restore fields removed in v1.9
|
||||
$content['store'] = $content['store'] ?? '';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user