Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/lib/stores/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ export type MigrationResource =
| NHostMigrationResource
| SupabaseMigrationResource
| 'platform'
| 'api-key';
| 'api-key'
| 'project-variable';

// Appwrite enum is the superset of all provider resources — used as a
// provider-agnostic reference. The addResource guard filters by provider.
// Platform and ApiKey are augmented locally until @appwrite.io/console SDK is regenerated against the new spec.
// Platform, ApiKey and ProjectVariable are augmented locally until @appwrite.io/console
// SDK is regenerated against the new spec.
export const MigrationResources = {
...AppwriteMigrationResource,
Platform: 'platform',
ApiKey: 'api-key'
ApiKey: 'api-key',
ProjectVariable: 'project-variable'
} as const;

type ProviderResourceMap = {
Expand Down Expand Up @@ -61,6 +64,9 @@ const initialFormData = {
integrations: {
root: false,
apiKeys: false
},
settings: {
root: false
}
};

Expand Down Expand Up @@ -101,14 +107,16 @@ export const ResourcesFriendly = {
message: { singular: 'Message', plural: 'Messages' },
'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' },
platform: { singular: 'Platform', plural: 'Platforms' },
'api-key': { singular: 'API Key', plural: 'API Keys' }
'api-key': { singular: 'API Key', plural: 'API Keys' },
'project-variable': { singular: 'Project Variable', plural: 'Project Variables' }
};

export const providerResources: ProviderResourceMap = {
appwrite: [
...Object.values(AppwriteMigrationResource),
MigrationResources.Platform as AppwriteMigrationResource,
MigrationResources.ApiKey as AppwriteMigrationResource
MigrationResources.ApiKey as AppwriteMigrationResource,
MigrationResources.ProjectVariable as AppwriteMigrationResource
],
supabase: Object.values(SupabaseMigrationResource),
nhost: Object.values(NHostMigrationResource),
Expand Down Expand Up @@ -178,6 +186,9 @@ export const migrationFormToResources = <P extends Provider>(
addResource(MigrationResources.ApiKey);
}
}
if (formData.settings.root) {
addResource(MigrationResources.ProjectVariable);
}

return resources as ProviderResourceMap[P];
};
Expand Down Expand Up @@ -264,6 +275,9 @@ export const resourcesToMigrationForm = (resources: MigrationResource[]): Migrat
formData.integrations.root = true;
formData.integrations.apiKeys = true;
}
if (resources.includes(MigrationResources.ProjectVariable)) {
formData.settings.root = true;
}

return formData;
};
Expand Down
7 changes: 6 additions & 1 deletion src/routes/(console)/(migration-wizard)/resource-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
);
}

if (groupKey === 'settings') {
return resources.includes(MigrationResources.ProjectVariable);
}

const groupToResource: Record<string, MigrationResource> = {
users: MigrationResources.User,
databases: MigrationResources.Database
Expand All @@ -148,7 +152,8 @@
sites: 'site',
messaging: 'provider',
backups: 'backup-policy',
integrations: 'platform'
integrations: 'platform',
settings: 'project-variable'
};
return map[groupKey] || groupKey;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
integrations: {
root: 'Platforms',
apiKeys: 'Include API keys'
},
settings: {
root: 'Project variables'
}
};

Expand Down Expand Up @@ -70,6 +73,9 @@
integrations: {
root: 'Import all platforms (web, Flutter, iOS, Android, etc.)',
apiKeys: 'Import all API keys with their scopes and expiration'
},
settings: {
root: 'Import all project-level variables (secret values are not exposed by the SDK and will be migrated empty)'
}
};

Expand Down