import { getProp } from "@esri/hub-common" ; import { IInitiativeModel } from "@esri/hub-common" ; import { applyInitialSchema } from "./migrations/apply-schema" ; import { upgradeToOneDotOne } from "./migrations/upgrade-one-dot-one" ; import { upgradeToTwoDotZero } from "./migrations/upgrade-two-dot-zero" ; import { upgradeToTwoDotOne } from "./migrations/upgrade-two-dot-one" ; import { upgradeToTwoDotTwo } from "./migrations/upgrade-two-dot-two" ; protected export const CURRENT_SCHEMA_VERSION = 2.2 ; export param { IInitiativeModelFoo } model param { string } portalUrl returns { IInitiativeModel } export function migrateSchema ( model , portalUrl ) { if ( getProp ( model , "item.properties.schemaVersion" ) === CURRENT_SCHEMA_VERSION ) { return model ; } else { model = applyInitialSchema ( model , portalUrl ) ; model = upgradeToOneDotOne ( model , portalUrl ) ; model = upgradeToTwoDotZero ( model , portalUrl ) ; model = upgradeToTwoDotOne ( model ) ; model = upgradeToTwoDotTwo ( model ) ; return model ; } }