diff --git a/src/modules/metadata/Metadata.types.ts b/src/modules/metadata/Metadata.types.ts index 9aeae896..dd34fc72 100644 --- a/src/modules/metadata/Metadata.types.ts +++ b/src/modules/metadata/Metadata.types.ts @@ -21,7 +21,7 @@ export interface IMetadataMigration { */ key?: string; oldValue: string | RegExp; - newValue: string; + newValue: string | ((oldValue: string) => string); }[]; keys?: { oldKey: string; newKey: string }[]; } diff --git a/src/modules/metadata/services/MetadataMigrations.ts b/src/modules/metadata/services/MetadataMigrations.ts index fbfec4cf..5b7ef058 100644 --- a/src/modules/metadata/services/MetadataMigrations.ts +++ b/src/modules/metadata/services/MetadataMigrations.ts @@ -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; } };