mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Introduce GROUP_PROJECTS, rename TYPE_PROTOCOLS/LABELS/SERVICES with TYPE_PROJECT_* prefix
This commit is contained in:
1 parent
2335078191
commit
e1e80b749b
14 files changed
+70
-70
No files matched your search
@@ -293,11 +293,11 @@ class Appwrite extends Destination
|
||||
Resource::TYPE_API_KEY,
|
||||
Resource::TYPE_WEBHOOK,
|
||||
|
||||
// Settings
|
||||
// Project
|
||||
Resource::TYPE_PROJECT_VARIABLE,
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
Resource::TYPE_LABELS,
|
||||
Resource::TYPE_SERVICES,
|
||||
Resource::TYPE_PROJECT_PROTOCOLS,
|
||||
Resource::TYPE_PROJECT_LABELS,
|
||||
Resource::TYPE_PROJECT_SERVICES,
|
||||
|
||||
// Backups
|
||||
Resource::TYPE_BACKUP_POLICY,
|
||||
@@ -459,7 +459,7 @@ class Appwrite extends Destination
|
||||
Transfer::GROUP_SITES => $this->importSiteResource($resource),
|
||||
Transfer::GROUP_INTEGRATIONS => $this->importIntegrationsResource($resource),
|
||||
Transfer::GROUP_BACKUPS => $this->importBackupResource($resource),
|
||||
Transfer::GROUP_SETTINGS => $this->importSettingsResource($resource),
|
||||
Transfer::GROUP_PROJECTS => $this->importProjectsResource($resource),
|
||||
default => throw new \Exception('Invalid resource group', Exception::CODE_VALIDATION),
|
||||
};
|
||||
} catch (\Throwable $e) {
|
||||
@@ -3123,22 +3123,22 @@ class Appwrite extends Destination
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function importSettingsResource(Resource $resource): Resource
|
||||
public function importProjectsResource(Resource $resource): Resource
|
||||
{
|
||||
switch ($resource->getName()) {
|
||||
case Resource::TYPE_PROJECT_VARIABLE:
|
||||
/** @var ProjectVariable $resource */
|
||||
$this->createProjectVariable($resource);
|
||||
break;
|
||||
case Resource::TYPE_PROTOCOLS:
|
||||
case Resource::TYPE_PROJECT_PROTOCOLS:
|
||||
/** @var Protocols $resource */
|
||||
$this->createProtocols($resource);
|
||||
break;
|
||||
case Resource::TYPE_LABELS:
|
||||
case Resource::TYPE_PROJECT_LABELS:
|
||||
/** @var Labels $resource */
|
||||
$this->createLabels($resource);
|
||||
break;
|
||||
case Resource::TYPE_SERVICES:
|
||||
case Resource::TYPE_PROJECT_SERVICES:
|
||||
/** @var ServicesResource $resource */
|
||||
$this->createServices($resource);
|
||||
break;
|
||||
|
||||
+10
-10
@@ -78,13 +78,13 @@ abstract class Resource implements \JsonSerializable
|
||||
// Integrations
|
||||
public const TYPE_PLATFORM = 'platform';
|
||||
public const TYPE_API_KEY = 'api-key';
|
||||
|
||||
// Settings
|
||||
public const TYPE_PROJECT_VARIABLE = 'project-variable';
|
||||
public const TYPE_WEBHOOK = 'webhook';
|
||||
public const TYPE_PROTOCOLS = 'protocols';
|
||||
public const TYPE_LABELS = 'labels';
|
||||
public const TYPE_SERVICES = 'services';
|
||||
|
||||
// Project (per-project singleton/settings resources)
|
||||
public const TYPE_PROJECT_VARIABLE = 'project-variable';
|
||||
public const TYPE_PROJECT_PROTOCOLS = 'project-protocols';
|
||||
public const TYPE_PROJECT_LABELS = 'project-labels';
|
||||
public const TYPE_PROJECT_SERVICES = 'project-services';
|
||||
|
||||
// Messaging
|
||||
public const TYPE_SUBSCRIBER = 'subscriber';
|
||||
@@ -128,11 +128,11 @@ abstract class Resource implements \JsonSerializable
|
||||
self::TYPE_POLICIES,
|
||||
self::TYPE_PLATFORM,
|
||||
self::TYPE_API_KEY,
|
||||
self::TYPE_PROJECT_VARIABLE,
|
||||
self::TYPE_WEBHOOK,
|
||||
self::TYPE_PROTOCOLS,
|
||||
self::TYPE_LABELS,
|
||||
self::TYPE_SERVICES,
|
||||
self::TYPE_PROJECT_VARIABLE,
|
||||
self::TYPE_PROJECT_PROTOCOLS,
|
||||
self::TYPE_PROJECT_LABELS,
|
||||
self::TYPE_PROJECT_SERVICES,
|
||||
self::TYPE_PROVIDER,
|
||||
self::TYPE_TOPIC,
|
||||
self::TYPE_SUBSCRIBER,
|
||||
|
||||
@@ -54,12 +54,12 @@ class Labels extends Resource
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return Resource::TYPE_LABELS;
|
||||
return Resource::TYPE_PROJECT_LABELS;
|
||||
}
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return Transfer::GROUP_SETTINGS;
|
||||
return Transfer::GROUP_PROJECTS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -58,7 +58,7 @@ class ProjectVariable extends Resource
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return Transfer::GROUP_SETTINGS;
|
||||
return Transfer::GROUP_PROJECTS;
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
|
||||
@@ -57,12 +57,12 @@ class Protocols extends Resource
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return Resource::TYPE_PROTOCOLS;
|
||||
return Resource::TYPE_PROJECT_PROTOCOLS;
|
||||
}
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return Transfer::GROUP_SETTINGS;
|
||||
return Transfer::GROUP_PROJECTS;
|
||||
}
|
||||
|
||||
public function getRest(): bool
|
||||
|
||||
@@ -99,12 +99,12 @@ class Services extends Resource
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return Resource::TYPE_SERVICES;
|
||||
return Resource::TYPE_PROJECT_SERVICES;
|
||||
}
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return Transfer::GROUP_SETTINGS;
|
||||
return Transfer::GROUP_PROJECTS;
|
||||
}
|
||||
|
||||
public function getAccount(): bool
|
||||
|
||||
@@ -73,7 +73,7 @@ class Webhook extends Resource
|
||||
|
||||
public function getGroup(): string
|
||||
{
|
||||
return Transfer::GROUP_SETTINGS;
|
||||
return Transfer::GROUP_INTEGRATIONS;
|
||||
}
|
||||
|
||||
public function getWebhookName(): string
|
||||
|
||||
@@ -56,7 +56,7 @@ abstract class Source extends Target
|
||||
return static::$defaultBatchSize;
|
||||
}
|
||||
|
||||
public function getSettingsBatchSize(): int
|
||||
public function getProjectsBatchSize(): int
|
||||
{
|
||||
return static::$defaultBatchSize;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ abstract class Source extends Target
|
||||
Transfer::GROUP_SITES => Transfer::GROUP_SITES_RESOURCES,
|
||||
Transfer::GROUP_INTEGRATIONS => Transfer::GROUP_INTEGRATIONS_RESOURCES,
|
||||
Transfer::GROUP_BACKUPS => Transfer::GROUP_BACKUPS_RESOURCES,
|
||||
Transfer::GROUP_SETTINGS => Transfer::GROUP_SETTINGS_RESOURCES,
|
||||
Transfer::GROUP_PROJECTS => Transfer::GROUP_PROJECTS_RESOURCES,
|
||||
];
|
||||
|
||||
foreach ($mapping as $group => $resources) {
|
||||
@@ -167,8 +167,8 @@ abstract class Source extends Target
|
||||
case Transfer::GROUP_BACKUPS:
|
||||
$this->exportGroupBackups($this->getBackupsBatchSize(), $resources);
|
||||
break;
|
||||
case Transfer::GROUP_SETTINGS:
|
||||
$this->exportGroupSettings($this->getSettingsBatchSize(), $resources);
|
||||
case Transfer::GROUP_PROJECTS:
|
||||
$this->exportGroupProjects($this->getProjectsBatchSize(), $resources);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -239,10 +239,10 @@ abstract class Source extends Target
|
||||
abstract protected function exportGroupBackups(int $batchSize, array $resources): void;
|
||||
|
||||
/**
|
||||
* Export Settings Group
|
||||
* Export Projects Group
|
||||
*
|
||||
* @param int $batchSize
|
||||
* @param array<string> $resources Resources to export
|
||||
*/
|
||||
abstract protected function exportGroupSettings(int $batchSize, array $resources): void;
|
||||
abstract protected function exportGroupProjects(int $batchSize, array $resources): void;
|
||||
}
|
||||
@@ -231,11 +231,11 @@ class Appwrite extends Source
|
||||
// Backups
|
||||
Resource::TYPE_BACKUP_POLICY,
|
||||
|
||||
// Settings
|
||||
// Project
|
||||
Resource::TYPE_PROJECT_VARIABLE,
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
Resource::TYPE_LABELS,
|
||||
Resource::TYPE_SERVICES,
|
||||
Resource::TYPE_PROJECT_PROTOCOLS,
|
||||
Resource::TYPE_PROJECT_LABELS,
|
||||
Resource::TYPE_PROJECT_SERVICES,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ class Appwrite extends Source
|
||||
$this->reportSites($resources, $report, $resourceIds);
|
||||
$this->reportIntegrations($resources, $report, $resourceIds);
|
||||
$this->reportBackups($resources, $report, $resourceIds);
|
||||
$this->reportSettings($resources, $report, $resourceIds);
|
||||
$this->reportProjects($resources, $report, $resourceIds);
|
||||
|
||||
$report['version'] = $this->call(
|
||||
'GET',
|
||||
@@ -1567,7 +1567,7 @@ class Appwrite extends Source
|
||||
}
|
||||
}
|
||||
|
||||
private function reportSettings(array $resources, array &$report, array $resourceIds = []): void
|
||||
private function reportProjects(array $resources, array &$report, array $resourceIds = []): void
|
||||
{
|
||||
if (\in_array(Resource::TYPE_PROJECT_VARIABLE, $resources)) {
|
||||
$variableQueries = $this->buildQueries(
|
||||
@@ -1582,19 +1582,19 @@ class Appwrite extends Source
|
||||
}
|
||||
}
|
||||
|
||||
if (\in_array(Resource::TYPE_PROTOCOLS, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_PROTOCOLS, $resources)) {
|
||||
// Singleton — there is exactly one protocols config per project.
|
||||
$report[Resource::TYPE_PROTOCOLS] = 1;
|
||||
$report[Resource::TYPE_PROJECT_PROTOCOLS] = 1;
|
||||
}
|
||||
|
||||
if (\in_array(Resource::TYPE_LABELS, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_LABELS, $resources)) {
|
||||
// Singleton — one labels array per project.
|
||||
$report[Resource::TYPE_LABELS] = 1;
|
||||
$report[Resource::TYPE_PROJECT_LABELS] = 1;
|
||||
}
|
||||
|
||||
if (\in_array(Resource::TYPE_SERVICES, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_SERVICES, $resources)) {
|
||||
// Singleton — one services config per project.
|
||||
$report[Resource::TYPE_SERVICES] = 1;
|
||||
$report[Resource::TYPE_PROJECT_SERVICES] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1602,7 +1602,7 @@ class Appwrite extends Source
|
||||
* @param int $batchSize
|
||||
* @param array<string> $resources
|
||||
*/
|
||||
protected function exportGroupSettings(int $batchSize, array $resources): void
|
||||
protected function exportGroupProjects(int $batchSize, array $resources): void
|
||||
{
|
||||
if (\in_array(Resource::TYPE_PROJECT_VARIABLE, $resources)) {
|
||||
try {
|
||||
@@ -1610,7 +1610,7 @@ class Appwrite extends Source
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_PROJECT_VARIABLE,
|
||||
Transfer::GROUP_SETTINGS,
|
||||
Transfer::GROUP_PROJECTS,
|
||||
message: $e->getMessage(),
|
||||
code: (int) $e->getCode() ?: Exception::CODE_INTERNAL,
|
||||
previous: $e
|
||||
@@ -1619,13 +1619,13 @@ class Appwrite extends Source
|
||||
}
|
||||
|
||||
try {
|
||||
if (\in_array(Resource::TYPE_PROTOCOLS, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_PROTOCOLS, $resources)) {
|
||||
$this->exportProtocols();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
Transfer::GROUP_SETTINGS,
|
||||
Resource::TYPE_PROJECT_PROTOCOLS,
|
||||
Transfer::GROUP_PROJECTS,
|
||||
message: $e->getMessage(),
|
||||
code: (int) $e->getCode() ?: Exception::CODE_INTERNAL,
|
||||
previous: $e
|
||||
@@ -1633,13 +1633,13 @@ class Appwrite extends Source
|
||||
}
|
||||
|
||||
try {
|
||||
if (\in_array(Resource::TYPE_LABELS, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_LABELS, $resources)) {
|
||||
$this->exportLabels();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_LABELS,
|
||||
Transfer::GROUP_SETTINGS,
|
||||
Resource::TYPE_PROJECT_LABELS,
|
||||
Transfer::GROUP_PROJECTS,
|
||||
message: $e->getMessage(),
|
||||
code: (int) $e->getCode() ?: Exception::CODE_INTERNAL,
|
||||
previous: $e
|
||||
@@ -1647,13 +1647,13 @@ class Appwrite extends Source
|
||||
}
|
||||
|
||||
try {
|
||||
if (\in_array(Resource::TYPE_SERVICES, $resources)) {
|
||||
if (\in_array(Resource::TYPE_PROJECT_SERVICES, $resources)) {
|
||||
$this->exportServices();
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->addError(new Exception(
|
||||
Resource::TYPE_SERVICES,
|
||||
Transfer::GROUP_SETTINGS,
|
||||
Resource::TYPE_PROJECT_SERVICES,
|
||||
Transfer::GROUP_PROJECTS,
|
||||
message: $e->getMessage(),
|
||||
code: (int) $e->getCode() ?: Exception::CODE_INTERNAL,
|
||||
previous: $e
|
||||
|
||||
@@ -440,7 +440,7 @@ class CSV extends Source
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
protected function exportGroupSettings(int $batchSize, array $resources): void
|
||||
protected function exportGroupProjects(int $batchSize, array $resources): void
|
||||
{
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
@@ -828,7 +828,7 @@ class Firebase extends Source
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
|
||||
protected function exportGroupSettings(int $batchSize, array $resources): void
|
||||
protected function exportGroupProjects(int $batchSize, array $resources): void
|
||||
{
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class JSON extends Source
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
protected function exportGroupSettings(int $batchSize, array $resources): void
|
||||
protected function exportGroupProjects(int $batchSize, array $resources): void
|
||||
{
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
@@ -963,7 +963,7 @@ class NHost extends Source
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
protected function exportGroupSettings(int $batchSize, array $resources): void
|
||||
protected function exportGroupProjects(int $batchSize, array $resources): void
|
||||
{
|
||||
throw new \Exception('Not Implemented');
|
||||
}
|
||||
|
||||
+10
-10
@@ -28,7 +28,7 @@ class Transfer
|
||||
|
||||
public const GROUP_BACKUPS = 'backups';
|
||||
|
||||
public const GROUP_SETTINGS = 'settings';
|
||||
public const GROUP_PROJECTS = 'projects';
|
||||
|
||||
public const GROUP_AUTH_RESOURCES = [
|
||||
Resource::TYPE_USER,
|
||||
@@ -97,11 +97,11 @@ class Transfer
|
||||
Resource::TYPE_ATTRIBUTE
|
||||
];
|
||||
|
||||
public const GROUP_SETTINGS_RESOURCES = [
|
||||
public const GROUP_PROJECTS_RESOURCES = [
|
||||
Resource::TYPE_PROJECT_VARIABLE,
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
Resource::TYPE_LABELS,
|
||||
Resource::TYPE_SERVICES,
|
||||
Resource::TYPE_PROJECT_PROTOCOLS,
|
||||
Resource::TYPE_PROJECT_LABELS,
|
||||
Resource::TYPE_PROJECT_SERVICES,
|
||||
];
|
||||
|
||||
public const GROUP_BACKUPS_RESOURCES = [
|
||||
@@ -145,11 +145,11 @@ class Transfer
|
||||
Resource::TYPE_API_KEY,
|
||||
Resource::TYPE_WEBHOOK,
|
||||
|
||||
// Settings
|
||||
// Project
|
||||
Resource::TYPE_PROJECT_VARIABLE,
|
||||
Resource::TYPE_PROTOCOLS,
|
||||
Resource::TYPE_LABELS,
|
||||
Resource::TYPE_SERVICES,
|
||||
Resource::TYPE_PROJECT_PROTOCOLS,
|
||||
Resource::TYPE_PROJECT_LABELS,
|
||||
Resource::TYPE_PROJECT_SERVICES,
|
||||
|
||||
// legacy
|
||||
Resource::TYPE_DOCUMENT,
|
||||
@@ -436,7 +436,7 @@ class Transfer
|
||||
self::GROUP_DATABASES_VECTOR_DB => array_merge($resources, self::GROUP_VECTORSDB_RESOURCES),
|
||||
self::GROUP_MESSAGING => array_merge($resources, self::GROUP_MESSAGING_RESOURCES),
|
||||
self::GROUP_BACKUPS => array_merge($resources, self::GROUP_BACKUPS_RESOURCES),
|
||||
self::GROUP_SETTINGS => array_merge($resources, self::GROUP_SETTINGS_RESOURCES),
|
||||
self::GROUP_PROJECTS => array_merge($resources, self::GROUP_PROJECTS_RESOURCES),
|
||||
default => throw new \Exception('No service group found'),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user