Skip to content

Commit f26ca9f

Browse files
committed
Add API key migration wizard support
Promote api-key to its own top-level resource group in the wizard (parallel to platforms / backup policies) and wire it through the form-to-resources translation. The migration backend uses the kebab-case 'api-key' resource id; the form field name 'apiKeys' stays camelCase as it's a local property.
1 parent 385512c commit f26ca9f

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/lib/stores/migration.ts

Lines changed: 18 additions & 5 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 = {
@@ -58,6 +60,9 @@ const initialFormData = {
5860
},
5961
integrations: {
6062
root: false
63+
},
64+
apiKeys: {
65+
root: false
6166
}
6267
};
6368

@@ -97,13 +102,15 @@ export const ResourcesFriendly = {
97102
subscriber: { singular: 'Subscriber', plural: 'Subscribers' },
98103
message: { singular: 'Message', plural: 'Messages' },
99104
'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' },
100-
platform: { singular: 'Platform', plural: 'Platforms' }
105+
platform: { singular: 'Platform', plural: 'Platforms' },
106+
'api-key': { singular: 'API Key', plural: 'API Keys' }
101107
};
102108

103109
export const providerResources: ProviderResourceMap = {
104110
appwrite: [
105111
...Object.values(AppwriteMigrationResource),
106-
MigrationResources.Platform as AppwriteMigrationResource
112+
MigrationResources.Platform as AppwriteMigrationResource,
113+
MigrationResources.ApiKey as AppwriteMigrationResource
107114
],
108115
supabase: Object.values(SupabaseMigrationResource),
109116
nhost: Object.values(NHostMigrationResource),
@@ -170,6 +177,9 @@ export const migrationFormToResources = <P extends Provider>(
170177
if (formData.integrations.root) {
171178
addResource(MigrationResources.Platform);
172179
}
180+
if (formData.apiKeys.root) {
181+
addResource(MigrationResources.ApiKey);
182+
}
173183

174184
return resources as ProviderResourceMap[P];
175185
};
@@ -252,6 +262,9 @@ export const resourcesToMigrationForm = (resources: MigrationResource[]): Migrat
252262
if (resources.includes(MigrationResources.Platform)) {
253263
formData.integrations.root = true;
254264
}
265+
if (resources.includes(MigrationResources.ApiKey)) {
266+
formData.apiKeys.root = true;
267+
}
255268

256269
return formData;
257270
};

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
return resources.includes(MigrationResources.Platform);
124124
}
125125
126+
if (groupKey === 'apiKeys') {
127+
return resources.includes(MigrationResources.ApiKey);
128+
}
129+
126130
const groupToResource: Record<string, MigrationResource> = {
127131
users: MigrationResources.User,
128132
databases: MigrationResources.Database
@@ -145,7 +149,8 @@
145149
sites: 'site',
146150
messaging: 'provider',
147151
backups: 'backup-policy',
148-
integrations: 'platform'
152+
integrations: 'platform',
153+
apiKeys: 'api-key'
149154
};
150155
return map[groupKey] || groupKey;
151156
};

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
},
4040
integrations: {
4141
root: 'Platforms'
42+
},
43+
apiKeys: {
44+
root: 'API keys'
4245
}
4346
};
4447
@@ -68,6 +71,9 @@
6871
},
6972
integrations: {
7073
root: 'Import all platforms (web, Flutter, iOS, Android, etc.)'
74+
},
75+
apiKeys: {
76+
root: 'Import all API keys with their scopes and expiration'
7177
}
7278
};
7379

0 commit comments

Comments
 (0)