// SPDX-FileCopyrightText: 2021 Johannes Loher // // SPDX-License-Identifier: MIT import { getActorUpdateDataGetter, getCompendiumMigrator, getSceneUpdateDataGetter, migrateActors, migrateCompendiums, migrateItems, migrateScenes, } from "./migrationHelpers"; async function migrate(): Promise { await migrateItems(getItemUpdateData); await migrateActors(getActorUpdateData); await migrateScenes(getSceneUpdateData); await migrateCompendiums(migrateCompendium); } function getItemUpdateData(itemData: Partial) { if (itemData.type !== "spell") return; // @ts-expect-error the type of cooldownDuration was UnitData at the point for this migration, but it changed later on const cooldownDurationUnit: string | undefined = itemData.data?.cooldownDuration.unit; const updateData: Record = { data: { "-=scrollPrice": null, minimumLevels: { healer: null, wizard: null, sorcerer: null }, cooldownDuration: { unit: cooldownDurationUnit === "custom" ? "rounds" : cooldownDurationUnit, }, }, }; return updateData; } const getActorUpdateData = getActorUpdateDataGetter(getItemUpdateData); const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData); const migrateCompendium = getCompendiumMigrator({ getItemUpdateData, getActorUpdateData, getSceneUpdateData }); export const migration = { migrate, migrateCompendium, };