in src/app/stores/migrator.ts [43:192]
public migrate(state: AppStoreState, targetVersion: string): AppStoreState {
// First, fix version if missing
if (!state.version) {
// Initially we didn't have the version field, so fix it.
state.version = "1.0.0";
}
// console.log(`Migrate state from ${state.version} to ${targetVersion}`);
if (
compareVersion(state.version, "1.3.0") < 0 &&
compareVersion(targetVersion, "1.3.0") >= 0
) {
// Major change at version 1.3.0: MainStoreState => AppStoreState
const stateOld = (state as any) as {
version: string;
dataset: { dataset: Dataset.Dataset };
chart: {
chart: Specification.Chart;
chartState: Specification.ChartState;
};
};
state = {
version: stateOld.version, // keep the old version, so the following code can run
dataset: stateOld.dataset.dataset,
chart: stateOld.chart.chart,
chartState: stateOld.chart.chartState,
};
}
if (
compareVersion(state.version, "1.1.0") < 0 &&
compareVersion(targetVersion, "1.1.0") >= 0
) {
// Major change in spec from 1.1.0: the dataRowIndices are changed from number[] to number[][]
state = this.fixDataRowIndices(state);
state = this.fixDataMappingExpressions(state);
}
if (
compareVersion(state.version, "1.4.0") < 0 &&
compareVersion(targetVersion, "1.4.0") >= 0
) {
// Major change at version 1.4.0: Links are not automatically sorted in rendering now
state = this.fixLinkOrder_v130(state);
}
if (
compareVersion(state.version, "1.5.0") < 0 &&
compareVersion(targetVersion, "1.5.0") >= 0
) {
// Minor change at version 1.5.0: Links are not automatically sorted in rendering now
state = this.addScaleMappings(state);
}
if (
compareVersion(state.version, "1.5.1") < 0 &&
compareVersion(targetVersion, "1.5.1") >= 0
) {
// Minor change at version 1.5.1: Links are not automatically sorted in rendering now
state = this.addTableTypes(state);
}
if (
compareVersion(state.version, "1.6.0") < 0 &&
compareVersion(targetVersion, "1.6.0") >= 0
) {
// Minor change at version 1.6.0: Links are not automatically sorted in rendering now
state = this.addOriginDataSet(state);
}
if (
compareVersion(state.version, "1.7.0") < 0 &&
compareVersion(targetVersion, "1.7.0") >= 0
) {
// Minor change at version 1.7.0: Interactivity properties for marks
state = this.addInteractivityProperties(state);
// Minor change at version 1.7.0: Guides now have a baseline prop
state = upgradeGuidesToBaseline(state);
}
if (
compareVersion(state.version, "1.8.0") < 0 &&
compareVersion(targetVersion, "1.8.0") >= 0
) {
// Minor change at version 1.8.0: Add default value for property layout in legend
state = this.setValueToLayoutPropertyOfLegend(state);
}
if (
compareVersion(state.version, "2.0.0") < 0 &&
compareVersion(targetVersion, "2.0.0") >= 0
) {
// Major change at version 2.0.0: Add default value for property layout in legend
state = this.setValueItemShapeOfLegend(state);
}
if (
compareVersion(state.version, "2.0.1") < 0 &&
compareVersion(targetVersion, "2.0.1") >= 0
) {
// Patch change at version 2.0.1: Add polar/angular legend
state = this.setPolarAngularLegend(state);
}
if (
compareVersion(state.version, "2.0.2") < 0 &&
compareVersion(targetVersion, "2.0.2") >= 0
) {
state = this.setAllowFlipToMarks(state);
}
if (
compareVersion(state.version, "2.0.4") < 0 &&
compareVersion(targetVersion, "2.0.4") >= 0
) {
state = this.setMissedProperties(state);
}
if (
compareVersion(state.version, "2.1.0") < 0 &&
compareVersion(targetVersion, "2.1.0") >= 0
) {
state = this.setMissedGlyphRectProperties(state);
}
if (
compareVersion(state.version, "2.1.1") < 0 &&
compareVersion(targetVersion, "2.1.1") >= 0
) {
state = this.setMissedSortProperties(state);
}
if (
compareVersion(state.version, "2.1.2") < 0 &&
compareVersion(targetVersion, "2.1.2") >= 0
) {
state = this.setMissedSortProperties(state);
}
if (
compareVersion(state.version, "2.1.5") < 0 &&
compareVersion(targetVersion, "2.1.5") >= 0
) {
state = this.setMissedLegendProperties(state);
}
// After migration, set version to targetVersion
state.version = targetVersion;
return state;
}