Add src/types/migration.ts
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a13b3acbe5
commit
97f2a5ebb8
22
src/types/migration.ts
Normal file
22
src/types/migration.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
const FMT_VER_0 = 0
|
||||||
|
const FMT_VER_LATEST = FMT_VER_0
|
||||||
|
|
||||||
|
function migrate_A_to_0(e: journey): journey {
|
||||||
|
e.title = e.name;
|
||||||
|
e.main.forEach((v) => {
|
||||||
|
v.date_range = v.date_range || (v as any).dateRange;
|
||||||
|
v.day_title = v.day_title || (v as any).step_title;
|
||||||
|
v.travel;
|
||||||
|
})
|
||||||
|
console.log(e)
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const migrator = (e: journey): journey => {
|
||||||
|
if (e.fmt_ver == FMT_VER_LATEST) return e;
|
||||||
|
switch (e.fmt_ver) {
|
||||||
|
case FMT_VER_0: break; // Update when FMT_VER_1 releases
|
||||||
|
default:
|
||||||
|
return migrate_A_to_0(e)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user