UNPKG

@esri/solution-common

Version:

Provides general helper functions for @esri/solution.js.

36 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._applySchema = void 0; const hub_common_1 = require("@esri/hub-common"); /** * Apply the initial schema for old Hub Solutions * * @param model * @param authentication * @private */ function _applySchema(model) { if ((0, hub_common_1.getProp)(model, "item.properties.schemaVersion") >= 1) { return model; } const clone = (0, hub_common_1.cloneObject)(model); if (!clone.item.properties) { clone.item.properties = {}; } // upgrade the schema of the Templates const templates = (0, hub_common_1.getProp)(clone, "data.templates") || []; clone.data.templates = templates.map((entry) => { return { key: entry.fieldName || entry.key, type: entry.type, item: entry.item, data: entry.data, itemId: entry.itemId || entry.fieldName || entry.key, resources: entry.resources || [], }; }); clone.item.properties.schemaVersion = 1; return clone; } exports._applySchema = _applySchema; //# sourceMappingURL=apply-schema.js.map