fix: address PR review findings for widget-only integration refactor
- Fix npm scoped package support (filter time metadata keys, make description optional, exclude falsy releases from version selection) - Fix timetable date formatting (use Intl.DateTimeFormat for stable MM/DD/YYYY output) and named zod import - Guard migration 0000 against unknown provider keys - Fix migration 0003 to delete integration links by integrationId - Reset immich album carousel index when photo list changes - Add bounded limit to timetable router input - Remove stale misspelled noProviderSeleceted translation key - Fix provider name visibility in release widget settings - Update docs: add ArchiveTeam Warrior note, fix typos, correct showPhotoInfo default
This commit is contained in:
44 files changed
+46
-76
No files matched your search
@@ -23,18 +23,19 @@ export async function migrateReleaseWidgetProviderToOptionsAsync(db: Database) {
|
||||
if (options.repositories.length === 0) continue;
|
||||
if (!options.repositories.some((repository) => "providerKey" in repository)) continue;
|
||||
|
||||
const updatedRepositories = options.repositories.map(
|
||||
({ providerKey, ...otherFields }: { providerKey: string; [key: string]: unknown }) => {
|
||||
// Ensure providerKey is camelCase
|
||||
const updatedRepositories = options.repositories
|
||||
.map(({ providerKey, ...otherFields }: { providerKey: string; [key: string]: unknown }) => {
|
||||
const provider = providerKey.charAt(0).toLowerCase() + providerKey.slice(1);
|
||||
const matchedProvider = releaseProviderKinds.find((kind) => kind === provider);
|
||||
if (!matchedProvider) return null;
|
||||
|
||||
return {
|
||||
id: createId(),
|
||||
provider: releaseProviderKinds.find((kind) => kind === provider),
|
||||
provider: matchedProvider,
|
||||
...otherFields,
|
||||
};
|
||||
},
|
||||
);
|
||||
})
|
||||
.filter((repo) => repo !== null);
|
||||
|
||||
updates.push({
|
||||
id: item.id,
|
||||
|
||||
@@ -54,21 +54,11 @@ export async function migrateWidgetOnlyIntegrationsToOptionsAsync(db: Database)
|
||||
.filter((item) => oldIntegrationById.has(item.integrationId))
|
||||
.map((item) => [item.itemId, oldIntegrationById.get(item.integrationId)]),
|
||||
);
|
||||
const oldIntegrationItemIdsByItemId = oldIntegrationItems
|
||||
.filter((item) => oldIntegrationById.has(item.integrationId))
|
||||
.reduce<Map<string, string[]>>((acc, item) => {
|
||||
const itemIds = acc.get(item.itemId) ?? [];
|
||||
itemIds.push(item.integrationId);
|
||||
acc.set(item.itemId, itemIds);
|
||||
return acc;
|
||||
}, new Map());
|
||||
|
||||
const existingItems = await db.query.items.findMany({
|
||||
where: (items, { inArray }) => inArray(items.kind, ["releases", "timetable"]),
|
||||
});
|
||||
|
||||
const updatedItems: { id: string; options: object }[] = [];
|
||||
const unlinkItemIds: string[] = [];
|
||||
|
||||
for (const item of existingItems) {
|
||||
const options = SuperJSON.parse<Record<string, unknown>>(item.options);
|
||||
@@ -89,12 +79,10 @@ export async function migrateWidgetOnlyIntegrationsToOptionsAsync(db: Database)
|
||||
};
|
||||
});
|
||||
updatedItems.push({ id: item.id, options: { ...options, repositories } });
|
||||
if (oldIntegrationItemIdsByItemId.has(item.id)) unlinkItemIds.push(item.id);
|
||||
}
|
||||
|
||||
if (item.kind === "timetable" && linkedIntegration?.kind === "searchCh") {
|
||||
updatedItems.push({ id: item.id, options: { ...options, baseUrl: linkedIntegration.url } });
|
||||
unlinkItemIds.push(item.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,10 +93,7 @@ export async function migrateWidgetOnlyIntegrationsToOptionsAsync(db: Database)
|
||||
.where(eq(items.id, update.id));
|
||||
}
|
||||
|
||||
if (unlinkItemIds.length > 0) {
|
||||
await db.delete(integrationItems).where(inArray(integrationItems.itemId, unlinkItemIds));
|
||||
}
|
||||
|
||||
await db.delete(integrationItems).where(inArray(integrationItems.integrationId, oldIntegrationIds));
|
||||
await db.delete(integrations).where(inArray(integrations.id, oldIntegrationIds));
|
||||
|
||||
console.log(`Migrated widget-only integrations to widget options count="${updatedItems.length}"`);
|
||||
|
||||
Reference in new issue
Block a user