2021-06-26 22:02:00 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-07-08 02:32:25 +02:00
|
|
|
import {
|
|
|
|
getActorUpdateDataGetter,
|
|
|
|
getCompendiumMigrator,
|
|
|
|
getSceneUpdateDataGetter,
|
|
|
|
migrateActors,
|
|
|
|
migrateCompendiums,
|
|
|
|
migrateItems,
|
|
|
|
migrateScenes,
|
|
|
|
} from "./migrationHelpers";
|
|
|
|
|
2022-02-14 00:58:23 +01:00
|
|
|
async function migrate(): Promise<void> {
|
2021-07-08 02:32:25 +02:00
|
|
|
await migrateItems(getItemUpdateData);
|
|
|
|
await migrateActors(getActorUpdateData);
|
|
|
|
await migrateScenes(getSceneUpdateData);
|
|
|
|
await migrateCompendiums(migrateCompendium);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getItemUpdateData(
|
|
|
|
itemData: Partial<foundry.data.ItemData["_source"]>,
|
|
|
|
): DeepPartial<foundry.data.ItemData["_source"]> | undefined {
|
|
|
|
if (!["equipment", "trinket"].includes(itemData.type ?? "")) return undefined;
|
|
|
|
return { type: itemData.type === "equipment" ? ("loot" as const) : ("equipment" as const) };
|
|
|
|
}
|
|
|
|
|
|
|
|
const getActorUpdateData = getActorUpdateDataGetter(getItemUpdateData);
|
|
|
|
const getSceneUpdateData = getSceneUpdateDataGetter(getActorUpdateData);
|
|
|
|
const migrateCompendium = getCompendiumMigrator(
|
|
|
|
{ getItemUpdateData, getActorUpdateData, getSceneUpdateData },
|
|
|
|
{ migrateToTemplateEarly: false },
|
|
|
|
);
|
2022-02-14 00:58:23 +01:00
|
|
|
|
|
|
|
export const migration = {
|
|
|
|
migrate,
|
|
|
|
migrateCompendium,
|
|
|
|
};
|