Support dynamic new value creation for metadata value migration

This commit is contained in:
schroda
2024-12-10 21:14:26 +01:00
parent 45bedfaddb
commit d748f630a9
2 changed files with 2 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ export interface IMetadataMigration {
*/
key?: string;
oldValue: string | RegExp;
newValue: string;
newValue: string | ((oldValue: string) => string);
}[];
keys?: { oldKey: string; newKey: string }[];
}

View File

@@ -60,7 +60,7 @@ const applyMetadataValueMigration = (meta: Metadata, migration: IMetadataMigrati
metadataValueChanges.forEach(({ key, oldValue, newValue }) => {
const migrateValue = (metaKey: string) => {
if (meta[metaKey].match(oldValue)) {
migratedMetadata[metaKey] = newValue;
migratedMetadata[metaKey] = typeof newValue === 'function' ? newValue(meta[metaKey]) : newValue;
}
};