Skip to content

Commit 1116c57

Browse files
committed
Add API key migration wizard support
Adds api-key as a child toggle under the existing integrations group, matching the parent-child pattern used by users/teams, databases/rows, and messaging/messages. The backend uses the kebab-case 'api-key' resource id; the form field stays camelCase as a local property.
1 parent 385512c commit 1116c57

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

src/lib/stores/migration.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ export type MigrationResource =
1212
| FirebaseMigrationResource
1313
| NHostMigrationResource
1414
| SupabaseMigrationResource
15-
| 'platform';
15+
| 'platform'
16+
| 'api-key';
1617

1718
// Appwrite enum is the superset of all provider resources — used as a
1819
// provider-agnostic reference. The addResource guard filters by provider.
19-
// Platform is augmented locally until @appwrite.io/console SDK is regenerated against the new spec.
20+
// Platform and ApiKey are augmented locally until @appwrite.io/console SDK is regenerated against the new spec.
2021
export const MigrationResources = {
2122
...AppwriteMigrationResource,
22-
Platform: 'platform'
23+
Platform: 'platform',
24+
ApiKey: 'api-key'
2325
} as const;
2426

2527
type ProviderResourceMap = {
@@ -57,7 +59,8 @@ const initialFormData = {
5759
root: false
5860
},
5961
integrations: {
60-
root: false
62+
root: false,
63+
apiKeys: false
6164
}
6265
};
6366

@@ -97,13 +100,15 @@ export const ResourcesFriendly = {
97100
subscriber: { singular: 'Subscriber', plural: 'Subscribers' },
98101
message: { singular: 'Message', plural: 'Messages' },
99102
'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' },
100-
platform: { singular: 'Platform', plural: 'Platforms' }
103+
platform: { singular: 'Platform', plural: 'Platforms' },
104+
'api-key': { singular: 'API Key', plural: 'API Keys' }
101105
};
102106

103107
export const providerResources: ProviderResourceMap = {
104108
appwrite: [
105109
...Object.values(AppwriteMigrationResource),
106-
MigrationResources.Platform as AppwriteMigrationResource
110+
MigrationResources.Platform as AppwriteMigrationResource,
111+
MigrationResources.ApiKey as AppwriteMigrationResource
107112
],
108113
supabase: Object.values(SupabaseMigrationResource),
109114
nhost: Object.values(NHostMigrationResource),
@@ -169,6 +174,9 @@ export const migrationFormToResources = <P extends Provider>(
169174
}
170175
if (formData.integrations.root) {
171176
addResource(MigrationResources.Platform);
177+
if (formData.integrations.apiKeys) {
178+
addResource(MigrationResources.ApiKey);
179+
}
172180
}
173181

174182
return resources as ProviderResourceMap[P];
@@ -252,6 +260,10 @@ export const resourcesToMigrationForm = (resources: MigrationResource[]): Migrat
252260
if (resources.includes(MigrationResources.Platform)) {
253261
formData.integrations.root = true;
254262
}
263+
if (resources.includes(MigrationResources.ApiKey)) {
264+
formData.integrations.root = true;
265+
formData.integrations.apiKeys = true;
266+
}
255267

256268
return formData;
257269
};

src/routes/(console)/(migration-wizard)/resource-form.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@
120120
}
121121
122122
if (groupKey === 'integrations') {
123-
return resources.includes(MigrationResources.Platform);
123+
return (
124+
resources.includes(MigrationResources.Platform) ||
125+
resources.includes(MigrationResources.ApiKey)
126+
);
124127
}
125128
126129
const groupToResource: Record<string, MigrationResource> = {

src/routes/(console)/project-[region]-[project]/settings/migrations/(import)/importReport.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
root: 'Backup policies'
3939
},
4040
integrations: {
41-
root: 'Platforms'
41+
root: 'Platforms',
42+
apiKeys: 'Include API keys'
4243
}
4344
};
4445
@@ -67,7 +68,8 @@
6768
root: 'Import all backup policies'
6869
},
6970
integrations: {
70-
root: 'Import all platforms (web, Flutter, iOS, Android, etc.)'
71+
root: 'Import all platforms (web, Flutter, iOS, Android, etc.)',
72+
apiKeys: 'Import all API keys with their scopes and expiration'
7173
}
7274
};
7375

0 commit comments

Comments
 (0)