@esri/solution-common
Version:
Provides general helper functions for @esri/solution.js.
32 lines • 964 B
JavaScript
import { getProp, cloneObject } from "@esri/hub-common";
/**
* Apply the initial schema for old Hub Solutions
*
* @param model
* @param authentication
* @private
*/
export function _applySchema(model) {
if (getProp(model, "item.properties.schemaVersion") >= 1) {
return model;
}
const clone = cloneObject(model);
if (!clone.item.properties) {
clone.item.properties = {};
}
// upgrade the schema of the Templates
const templates = 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;
}
//# sourceMappingURL=apply-schema.js.map