-
Notifications
You must be signed in to change notification settings - Fork 235
feat: support platform resource in migration wizard #3043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,11 +11,16 @@ export type MigrationResource = | |
| | AppwriteMigrationResource | ||
| | FirebaseMigrationResource | ||
| | NHostMigrationResource | ||
| | SupabaseMigrationResource; | ||
| | SupabaseMigrationResource | ||
| | 'platform'; | ||
|
|
||
| // Appwrite enum is the superset of all provider resources — used as a | ||
| // provider-agnostic reference. The addResource guard filters by provider. | ||
| export const MigrationResources = AppwriteMigrationResource; | ||
| // Platform is augmented locally until @appwrite.io/console SDK is regenerated against the new spec. | ||
| export const MigrationResources = { | ||
| ...AppwriteMigrationResource, | ||
| Platform: 'platform' | ||
| } as const; | ||
|
|
||
| type ProviderResourceMap = { | ||
| appwrite: AppwriteMigrationResource[]; | ||
|
|
@@ -50,6 +55,9 @@ const initialFormData = { | |
| }, | ||
| backups: { | ||
| root: false | ||
| }, | ||
| integrations: { | ||
| root: false | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -88,11 +96,15 @@ export const ResourcesFriendly = { | |
| topic: { singular: 'Topic', plural: 'Topics' }, | ||
| subscriber: { singular: 'Subscriber', plural: 'Subscribers' }, | ||
| message: { singular: 'Message', plural: 'Messages' }, | ||
| 'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' } | ||
| 'backup-policy': { singular: 'Backup Policy', plural: 'Backup Policies' }, | ||
| platform: { singular: 'Platform', plural: 'Platforms' } | ||
| }; | ||
|
|
||
| export const providerResources: ProviderResourceMap = { | ||
| appwrite: Object.values(AppwriteMigrationResource), | ||
| appwrite: [ | ||
| ...Object.values(AppwriteMigrationResource), | ||
| MigrationResources.Platform as AppwriteMigrationResource | ||
| ], | ||
|
Comment on lines
103
to
+107
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| supabase: Object.values(SupabaseMigrationResource), | ||
| nhost: Object.values(NHostMigrationResource), | ||
| firebase: Object.values(FirebaseMigrationResource) | ||
|
|
@@ -155,6 +167,9 @@ export const migrationFormToResources = <P extends Provider>( | |
| if (formData.backups.root) { | ||
| addResource(MigrationResources.Backuppolicy); | ||
| } | ||
| if (formData.integrations.root) { | ||
| addResource(MigrationResources.Platform); | ||
| } | ||
|
|
||
| return resources as ProviderResourceMap[P]; | ||
| }; | ||
|
|
@@ -234,6 +249,9 @@ export const resourcesToMigrationForm = (resources: MigrationResource[]): Migrat | |
| if (resources.includes(MigrationResources.Backuppolicy)) { | ||
| formData.backups.root = true; | ||
| } | ||
| if (resources.includes(MigrationResources.Platform)) { | ||
| formData.integrations.root = true; | ||
| } | ||
|
|
||
| return formData; | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
providerResources.appwritebeyond its declared element typeMigrationResources.Platform as AppwriteMigrationResourcesilences TypeScript's check, so any callsite that receivesproviderResources.appwriteand narrows on the enum values will now silently encounter a value it wasn't compiled to handle. The comment explains this is intentional, but it's worth tracking as a follow-up: once the SDK is regenerated, remove the cast and the localPlatform: 'platform'augmentation so the types are in sync again.