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: 22 additions & 4 deletions src/lib/stores/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +20 to +23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Type cast widens providerResources.appwrite beyond its declared element type

MigrationResources.Platform as AppwriteMigrationResource silences TypeScript's check, so any callsite that receives providerResources.appwrite and 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 local Platform: 'platform' augmentation so the types are in sync again.


type ProviderResourceMap = {
appwrite: AppwriteMigrationResource[];
Expand Down Expand Up @@ -50,6 +55,9 @@ const initialFormData = {
},
backups: {
root: false
},
integrations: {
root: false
}
};

Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 'platform' unconditionally included in Appwrite report request

providerResources.appwrite is passed verbatim to getAppwriteReport as the resources list. Now that 'platform' is always in that array, any source Appwrite instance that pre-dates the backend change (appwrite/appwrite#11439) will receive an unrecognised resource value. Depending on how the API validates the list, it could reject the entire request and surface "Couldn't load resources" to the user — blocking the whole wizard, not just the Platforms row.

supabase: Object.values(SupabaseMigrationResource),
nhost: Object.values(NHostMigrationResource),
firebase: Object.values(FirebaseMigrationResource)
Expand Down Expand Up @@ -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];
};
Expand Down Expand Up @@ -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;
};
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 @@ -119,6 +119,10 @@
return resources.includes(MigrationResources.Backuppolicy);
}

if (groupKey === 'integrations') {
return resources.includes(MigrationResources.Platform);
}

const groupToResource: Record<string, MigrationResource> = {
users: MigrationResources.User,
databases: MigrationResources.Database
Expand All @@ -140,7 +144,8 @@
storage: 'bucket',
sites: 'site',
messaging: 'provider',
backups: 'backup-policy'
backups: 'backup-policy',
integrations: 'platform'
};
return map[groupKey] || groupKey;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
},
backups: {
root: 'Backup policies'
},
integrations: {
root: 'Platforms'
}
};

Expand All @@ -62,6 +65,9 @@
},
backups: {
root: 'Import all backup policies'
},
integrations: {
root: 'Import all platforms (web, Flutter, iOS, Android, etc.)'
}
};

Expand Down
Loading