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
26 changes: 19 additions & 7 deletions src/lib/stores/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ export type MigrationResource =
| SupabaseMigrationResource
| 'platform'
| 'api-key'
| 'project-variable';
| 'project-variable'
| 'webhook';

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

type ProviderResourceMap = {
Expand Down Expand Up @@ -66,7 +68,8 @@ const initialFormData = {
apiKeys: false
},
settings: {
root: false
root: false,
webhooks: false
}
};

Expand Down Expand Up @@ -108,15 +111,17 @@ export const ResourcesFriendly = {
'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' },
platform: { singular: 'Platform', plural: 'Platforms' },
'api-key': { singular: 'API Key', plural: 'API Keys' },
'project-variable': { singular: 'Project Variable', plural: 'Project Variables' }
'project-variable': { singular: 'Project Variable', plural: 'Project Variables' },
webhook: { singular: 'Webhook', plural: 'Webhooks' }
};

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

return resources as ProviderResourceMap[P];
Expand Down Expand Up @@ -278,6 +286,10 @@ export const resourcesToMigrationForm = (resources: MigrationResource[]): Migrat
if (resources.includes(MigrationResources.ProjectVariable)) {
formData.settings.root = true;
}
if (resources.includes(MigrationResources.Webhook)) {
formData.settings.root = true;
formData.settings.webhooks = true;
}

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

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

const groupToResource: Record<string, MigrationResource> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
apiKeys: 'Include API keys'
},
settings: {
root: 'Project variables'
root: 'Project variables',
webhooks: 'Include webhooks'
}
};

Expand Down Expand Up @@ -75,7 +76,8 @@
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)'
root: 'Import all project-level variables (secret values are not exposed by the SDK and will be migrated empty)',
webhooks: 'Import all webhooks (signing secrets are not exposed by the SDK; the destination regenerates a fresh signature key for each)'
}
};

Expand Down
Loading