@esri/solution-velocity 1.3.13 → 1.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-velocity - v1.3.13 - Apache-2.0
2
+ * @esri/solution-velocity - v1.3.16 - Apache-2.0
3
3
  * Copyright (c) 2018-2022 Esri, Inc.
4
- * Tue Apr 26 2022 15:05:07 GMT-0700 (Pacific Daylight Time)
4
+ * Wed Jun 08 2022 11:07:25 GMT-0700 (Pacific Daylight Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1 +1 @@
1
- {"version":3,"file":"velocity.umd.js","sources":["../../src/helpers/velocity-templatize.ts","../../src/helpers/get-velocity-dependencies.ts","../../src/helpers/velocity-helpers.ts","../../src/velocity-processor.ts"],"sourcesContent":["/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { IItemTemplate, getProp, setProp } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Updates the template by adding variables for key properties that will\r\n * need to be swapped when deploying\r\n *\r\n * @param template velocity item info that should be templatized\r\n *\r\n * @returns void\r\n *\r\n */\r\nexport function templatizeVelocity(template: IItemTemplate): void {\r\n _templatize(template, \"data.sources\", _templatizeDatasources);\r\n _templatize(template, \"data.feeds\", _templatizeFeeds);\r\n _templatize(template, \"data.feed\", _templatizeFeed);\r\n}\r\n\r\n/**\r\n * Generic wrapper for the templatize functions that\r\n * will get and set the key properties\r\n *\r\n * @param template velocity item info that should be templatized\r\n * @param prop the prop path to evaluate and set with a templatized variable\r\n * @param fn the templatize function that should be called for this prop\r\n *\r\n * @returns void\r\n *\r\n * @private\r\n */\r\nexport function _templatize(\r\n template: IItemTemplate,\r\n prop: string,\r\n fn: (arg: any) => void\r\n): void {\r\n const obj: any = getProp(template, prop);\r\n /* istanbul ignore else */\r\n if (obj) {\r\n setProp(template, prop, fn(obj));\r\n }\r\n}\r\n\r\n/**\r\n * Updates the template by adding variables for the itemId and the label\r\n * The label controls the name and must be unique for the org.\r\n *\r\n * @param feeds array of velocity feeds that should be templatized\r\n *\r\n * @returns The updated list of feed objects with templatized id and label\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeeds(feeds: any[]): any {\r\n return feeds.map((feed: any) => {\r\n feed.label = feed.label && feed.id ? `{{${feed.id}.label}}` : feed.label;\r\n feed.id = feed.id ? `{{${feed.id}.itemId}}` : feed.id;\r\n return feed;\r\n });\r\n}\r\n\r\n/**\r\n * Updates the portal item id and feature layer id variables for the feed properties.\r\n *\r\n * @param feed the feed object from the item\r\n *\r\n * @returns the updated feed object with templatized portalItemId and layer id\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeed(feed: any): any {\r\n let id = getProp(feed, \"properties.feature-layer.portalItemId\");\r\n /* istanbul ignore else */\r\n if (feed.properties) {\r\n /* istanbul ignore else */\r\n if (feed.properties[\"feature-layer.portalItemId\"]) {\r\n id = feed.properties[\"feature-layer.portalItemId\"];\r\n feed.properties[\"feature-layer.portalItemId\"] = `{{${id}.itemId}}`;\r\n }\r\n /* istanbul ignore else */\r\n if (id && feed.properties.hasOwnProperty(\"feature-layer.layerId\")) {\r\n const flId = feed.properties[\"feature-layer.layerId\"];\r\n feed.properties[\r\n \"feature-layer.layerId\"\r\n ] = `{{${id}.layer${flId}.layerId}}`;\r\n }\r\n }\r\n return feed;\r\n}\r\n\r\n/**\r\n * Velocity datasources share the same props as feeds so they can leverage\r\n * the same templatize function\r\n *\r\n * @param dataSources array of data sources from the item\r\n *\r\n * @returns the updated dataSources object with templatized ids and labels\r\n *\r\n * @private\r\n */\r\nexport function _templatizeDatasources(dataSources: any[]): any {\r\n return dataSources.map((ds: any) => _templatizeFeed(ds));\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n getProp,\r\n getItemBase,\r\n IItemTemplate,\r\n UserSession,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Get the dependencies from the velocity data sources, feeds, and outputs.\r\n * Only dependencies that do NOT have the typeKeyword \"IoTFeatureLayer\" are returned.\r\n *\r\n * @param template The template that for the velocity item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n */\r\nexport function getVelocityDependencies(\r\n template: IItemTemplate,\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const dependencies: string[] = [];\r\n\r\n [\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(f => _getFeedDependencies(f, dependencies));\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(d => _getDependencies(d, dependencies));\r\n\r\n return _validateDependencies(dependencies, authentication);\r\n}\r\n\r\n/**\r\n * Any feature services with the typeKeyword \"IoTFeatureLayer\" should not be templatized or\r\n * listed as a dependency.\r\n * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.\r\n *\r\n * @param dependencies Any dependencies that have been found for this item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n * @private\r\n */\r\nexport function _validateDependencies(\r\n dependencies: string[],\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const defs: Array<Promise<any>> = dependencies.map(d => {\r\n return getItemBase(d, authentication);\r\n });\r\n return Promise.all(defs).then(itemInfos => {\r\n return Promise.resolve(\r\n itemInfos.reduce((prev, cur) => {\r\n if (cur.typeKeywords.indexOf(\"IoTFeatureLayer\") < 0) {\r\n prev.push(cur.id);\r\n }\r\n return prev;\r\n }, [])\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity feeds\r\n * This function will update the input dependencies argument\r\n *\r\n * @param feeds The list of feeds from the velocity template\r\n * @param dependencies The current list of dependencies\r\n * @private\r\n */\r\nexport function _getFeedDependencies(\r\n feeds: any[],\r\n dependencies: string[]\r\n): void {\r\n feeds.reduce((prev: any, cur: any) => {\r\n const id: string = cur.id || undefined;\r\n /* istanbul ignore else */\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n return prev;\r\n }, dependencies);\r\n // run through standard dependency check as well\r\n // in some cases the feed does not have the id property but will have\r\n // a portalItemId value in the properties\r\n _getDependencies(feeds, dependencies);\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity outputs or dataSources.\r\n * This function will update the input dependencies argument\r\n *\r\n * @param outputs The list of outputs from the velocity item\r\n * @param dependencies The current list of dependencies\r\n * @param prop The individual prop to evaluate\r\n * @private\r\n */\r\nexport function _getDependencies(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.reduce((prev: any, cur: any) => {\r\n const names: string[] = getProp(cur, \"name\") ? [cur.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => {\r\n // skip map service and stream service ids\r\n /* istanbul ignore else */\r\n if (p.indexOf(\"mapServicePortalItemID\") < 0 && p.indexOf(\"streamServicePortalItemID\") < 0) {\r\n const id: string = cur.properties ? cur.properties[n + p] : undefined;\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n }\r\n });\r\n });\r\n return prev;\r\n }, dependencies);\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n IVelocityTitle,\r\n getVelocityUrlBase,\r\n replaceInTemplate,\r\n UserSession,\r\n getProp,\r\n fail,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Common function to build urls for reading and interacting with the velocity api\r\n *\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id Optional The id of the velocity item we are constructing a url for\r\n * @param isDeploy Optional Is this being constructed as a part of deployment\r\n * @param urlPrefix Optional prefix args necessary for some url construction\r\n * @param urlSuffix Optional suffix args necessary for some url construction\r\n *\r\n * @returns a promise that will resolve the constructed url\r\n *\r\n */\r\nexport function getVelocityUrl(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id: string = \"\",\r\n isDeploy: boolean = false,\r\n urlPrefix: string = \"\",\r\n urlSuffix: string = \"\"\r\n): Promise<string> {\r\n return getVelocityUrlBase(authentication, templateDictionary).then(url => {\r\n if (url) {\r\n const _type: string =\r\n type === \"Real Time Analytic\"\r\n ? \"analytics/realtime\"\r\n : type === \"Big Data Analytic\"\r\n ? \"analytics/bigdata\"\r\n : type.toLowerCase();\r\n\r\n const suffix: string = urlSuffix ? `/${urlSuffix}` : \"\";\r\n const prefix: string = urlPrefix ? `/${urlPrefix}` : \"\";\r\n\r\n return Promise.resolve(\r\n isDeploy\r\n ? `${url}/iot/${_type}${prefix}${suffix}`\r\n : id\r\n ? `${url}/iot/${_type}${prefix}/${id}${suffix}/?f=json&token=${authentication.token}`\r\n : `${url}/iot/${_type}${prefix}${suffix}/?f=json&token=${authentication.token}`\r\n );\r\n } else {\r\n return Promise.resolve(url);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handles the creation of velocity items.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param template The current itemTemplate that is being used for deployment\r\n * @param data The velocity item data used to create the items.\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param autoStart This can be leveraged to start certain velocity items after they are created.\r\n *\r\n * @returns a promise that will resolve an object containing the item, id, type, and post process flag\r\n *\r\n */\r\nexport function postVelocityData(\r\n authentication: UserSession,\r\n template: IItemTemplate,\r\n data: any,\r\n templateDictionary: any,\r\n autoStart: boolean = false\r\n): Promise<any> {\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n undefined,\r\n true\r\n ).then(url => {\r\n if (url) {\r\n return getTitle(authentication, data.label, url).then((titleInfo: IVelocityTitle) => {\r\n const titles: any[] = titleInfo.titles;\r\n data.label = titleInfo.label;\r\n data.id = \"\";\r\n const body: any = replaceInTemplate(data, templateDictionary);\r\n\r\n const dataOutputs: any[] = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((o: any) => {\r\n return {\r\n id: o.id,\r\n name: o.properties[`${o.name}.name`]\r\n };\r\n });\r\n\r\n const feeds = (body.feeds ? body.feeds : body.feed ? [body.feed] : []).map((o:any) => {\r\n return {\r\n id: o.id ? o.id : o.properties[`${o.name}.portalItemId`] || \"\",\r\n name: o.label ? o.label : data.label\r\n };\r\n });\r\n\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n body,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n ).then(updatedBody => {\r\n return _fetch(authentication, url, \"POST\", updatedBody).then(rr => {\r\n template.item.url = `${url}/${rr.id}`;\r\n template.item.title = data.label;\r\n\r\n // Update the template dictionary\r\n templateDictionary[template.itemId][\"url\"] = template.item.url;\r\n templateDictionary[template.itemId][\"label\"] = data.label;\r\n templateDictionary[template.itemId][\"itemId\"] = rr.id;\r\n\r\n const finalResult = {\r\n item: replaceInTemplate(template.item, templateDictionary),\r\n id: rr.id,\r\n type: template.type,\r\n postProcess: false\r\n };\r\n\r\n if (autoStart) {\r\n return _validateAndStart(\r\n authentication,\r\n templateDictionary,\r\n template,\r\n rr.id\r\n ).then(() => {\r\n return Promise.resolve(finalResult);\r\n });\r\n } else {\r\n return Promise.resolve(finalResult);\r\n }\r\n });\r\n });\r\n });\r\n } else {\r\n return Promise.reject(fail(\"Velocity NOT Supported by Organization\"));\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Velocity item titles must be unique across the organization.\r\n * Check and ensure we set a unique title\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param label The current label of the item from the solution template\r\n * @param url The base velocity url for checking status\r\n *\r\n * @returns a promise that will resolve a unique title\r\n *\r\n */\r\nexport function getTitle(\r\n authentication: UserSession,\r\n label: string,\r\n url: string\r\n): Promise<IVelocityTitle> {\r\n return _fetch(authentication, `${url}StatusList?view=admin`, \"GET\").then(\r\n items => {\r\n const titles: any[] =\r\n items && Array.isArray(items)\r\n ? items.map(item => {\r\n return { title: item.label };\r\n })\r\n : [];\r\n return Promise.resolve({label: getUniqueTitle(label, { titles }, \"titles\"), titles: titles.map(t => t.title)});\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the data that will be used and handle any reported issues with the outputs.\r\n * The output names must be unique across the organization.\r\n *\r\n * This function will update the data arg that is passed in with a unique name.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item\r\n * @param data The data used to construct the velocity item\r\n * @param titles The list of know titles that exist in the org\r\n * @param dataOutputs The velocity items output objects\r\n * @param feeds The velocity items feed objects\r\n *\r\n * @returns a promise that will resolve the data object passed in with any necessary changes.\r\n *\r\n * @private\r\n */\r\nexport function _validateOutputs(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n data: any,\r\n titles: any[],\r\n dataOutputs: any[] = [],\r\n feeds: any[] = []\r\n): Promise<any> {\r\n if (dataOutputs.length > 0 || feeds.length > 0) {\r\n return validate(authentication, templateDictionary, type, \"\", data).then(\r\n (validateResults: any) => {\r\n const names: string[] = _validateMessages(validateResults);\r\n if (names.length > 0) {\r\n /* istanbul ignore else */\r\n if (dataOutputs.length > 0) {\r\n _updateDataOutput(dataOutputs, data, names);\r\n }\r\n /* istanbul ignore else */\r\n if (feeds.length > 0) {\r\n _updateFeed(feeds, data, names.concat(titles));\r\n }\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n data,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n }\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n}\r\n\r\n/**\r\n * Check the validate results for any name conflicts and store the conflicting names.\r\n *\r\n * @param validateResults The results object to check for name conflict errors\r\n *\r\n * @returns a list of names that already exist in the org\r\n *\r\n * @private\r\n */\r\nexport function _validateMessages(\r\n validateResults: any\r\n): string[] {\r\n let messages: any[] = getProp(validateResults, \"validation.messages\");\r\n\r\n const nodes: any[] = getProp(validateResults, \"nodes\");\r\n /* istanbul ignore else */\r\n if (nodes && Array.isArray(nodes)) {\r\n nodes.forEach(node => {\r\n messages = messages.concat(\r\n getProp(node, \"validation.messages\") || []\r\n );\r\n });\r\n }\r\n\r\n let names: string[] = [];\r\n /* istanbul ignore else */\r\n if (messages && Array.isArray(messages)) {\r\n messages.forEach(message => {\r\n // I don't see a way to ask for all output names that exist\r\n // velocityUrl + /outputs/ just gives you generic defaults not what currently exists\r\n const nameErrors = [\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_FEATURE_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_STREAM_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"ITEM_MANAGER__CREATE_ANALYTIC_FAILED_DUPLICATE_OUTPUT_NAMES_IN_ORGANIZATION_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_BIG_DATA_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_REAL_TIME_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_FEED_FAILED_DUPLICATE_NAME\"\r\n ];\r\n // The names returned here seem to replace \" \" with \"_\" so they do not match exactly\r\n /* istanbul ignore else */\r\n if (nameErrors.indexOf(message.key) > -1) {\r\n names = names.concat(message.args);\r\n }\r\n });\r\n }\r\n return names;\r\n}\r\n\r\n/**\r\n * Updates the feed object with a new name when validation fails.\r\n *\r\n * @param feeds The feed objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateFeed(\r\n feeds: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n feeds.forEach(f => {\r\n const update = _getOutputLabel(names, f);\r\n /* istanbul ignore else */\r\n if (update) {\r\n data.label = update.label;\r\n f.name = update.label;\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Updates the data object with a new name when validation fails.\r\n *\r\n * @param dataOutputs The data output objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateDataOutput(\r\n dataOutputs: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n dataOutputs.forEach(dataOutput => {\r\n const update = _getOutputLabel(names, dataOutput);\r\n /* istanbul ignore else */\r\n if (update) {\r\n const _outputs = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((_dataOutput: any) => {\r\n /* istanbul ignore else */\r\n if (_dataOutput.id === update.id) {\r\n /* istanbul ignore else */\r\n if (_dataOutput.properties) {\r\n const nameProp: string = `${_dataOutput.name}.name`;\r\n /* istanbul ignore else */\r\n if (Object.keys(_dataOutput.properties).indexOf(nameProp) > -1) {\r\n _dataOutput.properties[nameProp] = update.label;\r\n }\r\n }\r\n }\r\n return _dataOutput;\r\n });\r\n /* istanbul ignore else */\r\n if (data.outputs) {\r\n data.outputs = _outputs;\r\n }\r\n /* istanbul ignore else */\r\n if (data.output) {\r\n data.output = _outputs[0];\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Get a unique label for the item.\r\n *\r\n * @param names The names that failed due to duplicate error in validation.\r\n * @param dataOutput The current data output that is being evaluated.\r\n *\r\n * @returns an object with a unique label and the outputs id when a name\r\n * conflict is found...otherwise returns undefined\r\n *\r\n * @private\r\n */\r\nexport function _getOutputLabel(names: any[], dataOutput: any): any {\r\n const titles: any[] = names.map((name: any) => {\r\n return { title: name };\r\n });\r\n\r\n const label = getUniqueTitle(dataOutput.name, { titles }, \"titles\");\r\n\r\n return label !== dataOutput.name\r\n ? {\r\n label,\r\n id: dataOutput.id\r\n }\r\n : undefined;\r\n}\r\n\r\n/**\r\n * Will return the provided title if it does not exist as a property\r\n * in one of the objects at the defined path. Otherwise the title will\r\n * have a numerical value attached.\r\n *\r\n * This is based on \"getUniqueTitle\" from common but adds the \"_\" replacement check for velocity names.\r\n * Could switch to using common if Velocity has a way to get a list of all names that are already used.\r\n *\r\n * @param title The root title to test\r\n * @param templateDictionary Hash of the facts\r\n * @param path to the objects to evaluate for potantial name clashes\r\n *\r\n * @returns string The unique title to use\r\n *\r\n */\r\nexport function getUniqueTitle(\r\n title: string,\r\n templateDictionary: any,\r\n path: string\r\n): string {\r\n title = title ? title.trim() : \"_\";\r\n const objs: any[] = getProp(templateDictionary, path) || [];\r\n const titles: string[] = objs.map(obj => {\r\n return obj.title;\r\n });\r\n let newTitle: string = title;\r\n let i: number = 0;\r\n // replace added for velocitcy\r\n // validation seems to add \"_\" to names listed in outputs..so no way to compare without hacking the name\r\n while (\r\n titles.indexOf(newTitle) > -1 ||\r\n titles.indexOf(newTitle.replace(/ /g, \"_\")) > -1\r\n ) {\r\n i++;\r\n newTitle = title + \" \" + i;\r\n }\r\n return newTitle;\r\n}\r\n\r\n/**\r\n * Start the item if validation passes and the item is executable.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param template the item template that has the details for deployment\r\n * @param id the new id for the velocity item that was deployed\r\n *\r\n * @returns a promise that will resolve with the validation results\r\n * or the start results when validation indicates the item is executable\r\n *\r\n * @private\r\n */\r\nexport function _validateAndStart(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n template: IItemTemplate,\r\n id: string\r\n): Promise<any> {\r\n return validate(authentication, templateDictionary, template.type, id).then(\r\n validateResult => {\r\n if (validateResult.executable) {\r\n return start(authentication, templateDictionary, template.type, id);\r\n } else {\r\n return Promise.resolve(validateResult);\r\n }\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the velocity item.\r\n * Used to help find and handle duplicate name errors.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n * @param body? Optional the request body to validate.\r\n *\r\n * @returns a promise that will resolve with an object containing messages\r\n * indicating any issues found when validating such as name conflict errors\r\n *\r\n */\r\nexport function validate(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string,\r\n body?: any\r\n): Promise<any> {\r\n // /iot/feed/validate/{id}/\r\n // /iot/analytics/realtime/validate/{id}/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"validate\",\r\n \"\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"POST\", body).then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Start the given velocity item that has been deployed.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n *\r\n * @returns a promise that will resolve with the result of the start call\r\n *\r\n */\r\nexport function start(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string\r\n): Promise<any> {\r\n // /iot/feed/{id}/start/\r\n // /iot/analytics/realtime/{id}/start/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"\",\r\n \"start\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"GET\").then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Gets the required request options for requests to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param method Indicate if \"GET\" or \"POST\"\r\n *\r\n * @returns generic request options used for various calls to velocity api\r\n *\r\n * @private\r\n */\r\nexport function _getRequestOpts(\r\n authentication: UserSession,\r\n method: string\r\n): RequestInit {\r\n return {\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n Authorization: \"token=\" + authentication.token\r\n },\r\n method\r\n };\r\n}\r\n\r\n/**\r\n * Generic fetch function for making calls to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param url The url from the velocity API to handle reading and writing\r\n * @param method The method for the request \"GET\" or \"POST\"\r\n * @param body The body for POST requests\r\n *\r\n * @returns a promise that will resolve with the result of the fetch call\r\n *\r\n * @private\r\n */\r\nexport function _fetch(\r\n authentication: UserSession,\r\n url: string,\r\n method: string, // GET or POST\r\n body?: any\r\n): Promise<any> {\r\n const requestOpts: any = _getRequestOpts(authentication, method);\r\n /* istanbul ignore else */\r\n if (body) {\r\n requestOpts.body = JSON.stringify(body);\r\n }\r\n return fetch(url, requestOpts).then(r => Promise.resolve(r.json()));\r\n}\r\n\r\n/**\r\n * Remove key properties if the dependency was removed due to having the \"IoTFeatureLayer\" typeKeyword\r\n * This function will update the input template.\r\n *\r\n * @param template The template that for the velocity item\r\n *\r\n */\r\nexport function cleanDataSourcesAndFeeds(\r\n template: IItemTemplate,\r\n velocityUrl: string\r\n): void {\r\n const dependencies: string[] = template.dependencies;\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(d => _removeIdProps(d, dependencies, velocityUrl));\r\n\r\n [\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(outputs => _removeIdPropsAndSetName(outputs, dependencies));\r\n}\r\n\r\n/**\r\n * Remove key properties from the input source or feed\r\n *\r\n * @param sourcesOrFeeds The list of dataSources or feeds\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdProps(\r\n sourcesOrFeeds: any[],\r\n dependencies: string[],\r\n velocityUrl: string\r\n): void {\r\n sourcesOrFeeds.forEach(dataSource => {\r\n const idProp: string = \"feature-layer.portalItemId\";\r\n const layerIdProp: string = \"feature-layer.layerId\"\r\n /* istanbul ignore else */\r\n if (dataSource.properties) {\r\n /* istanbul ignore else */\r\n if (dataSource.properties[idProp]) {\r\n const id: string = dataSource.properties[idProp];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete dataSource.properties[idProp];\r\n delete dataSource.properties[layerIdProp];\r\n }\r\n }\r\n\r\n const urlProp: string = \"simulator.url\";\r\n const url: any = dataSource.properties[urlProp];\r\n // only remove velocity based simulator urls\r\n // otherwise we will leave as is with no templatization\r\n /* istanbul ignore else */\r\n if (url && url.indexOf(velocityUrl) > -1) {\r\n delete dataSource.properties[urlProp]\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Remove key properties from the outputs.\r\n *\r\n * @param outputs The list of outputs\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdPropsAndSetName(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.forEach(output => {\r\n /* istanbul ignore else */\r\n if (output.properties) {\r\n const names: string[] = getProp(output, \"name\") ? [output.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => _removeProp(output.properties, n + p, dependencies));\r\n });\r\n\r\n _updateName(output.properties);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Generic helper function to remove key properties .\r\n *\r\n * @param props the list of props to update\r\n * @param prop the individual prop to remove\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeProp(\r\n props: any,\r\n prop: string,\r\n dependencies: string[]\r\n): void {\r\n const id: string = props[prop];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete props[prop];\r\n }\r\n}\r\n\r\n/**\r\n * Update the feature layer name to include the solution item id.\r\n *\r\n * @param props the list of props to update\r\n *\r\n * @private\r\n */\r\nexport function _updateName(props: any): void {\r\n [\r\n \"feat-lyr-new.name\",\r\n \"stream-lyr-new.name\",\r\n \"feat-lyr-existing.name\"\r\n ].forEach(n => {\r\n const name: string = props[n];\r\n /* istanbul ignore else */\r\n if (name && name.indexOf(\"{{solutionItemId}}\") < 0) {\r\n props[n] = `${name}_{{solutionItemId}}`;\r\n }\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of velocity item types.\r\n *\r\n * @module velocity\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemProgressCallback,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n generateEmptyCreationResponse,\r\n createInitializedItemTemplate,\r\n fail,\r\n removeItem,\r\n updateVelocityReferences,\r\n updateItem\r\n} from \"@esri/solution-common\";\r\nimport { templatizeVelocity } from \"./helpers/velocity-templatize\";\r\nimport { getVelocityDependencies } from \"./helpers/get-velocity-dependencies\";\r\nimport {\r\n cleanDataSourcesAndFeeds,\r\n getVelocityUrl,\r\n postVelocityData\r\n} from \"./helpers/velocity-helpers\";\r\nimport {\r\n moveItem\r\n} from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Convert a Velocity item into a Template\r\n *\r\n * @param solutionItemId The solution to contain the item\r\n * @param itemInfo The basic item info\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n *\r\n * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo\r\n *\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n const template = createInitializedItemTemplate(itemInfo);\r\n return getVelocityUrl(\r\n srcAuthentication,\r\n templateDictionary,\r\n itemInfo.type,\r\n itemInfo.id\r\n ).then(\r\n (url: string) => {\r\n if (url) {\r\n return fetch(url)\r\n .then(data => data.json())\r\n .then(data_json => {\r\n template.item.title = data_json.label;\r\n template.data = data_json;\r\n return getVelocityDependencies(template, srcAuthentication).then(\r\n deps => {\r\n template.dependencies = deps;\r\n cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);\r\n templatizeVelocity(template);\r\n template.item = updateVelocityReferences(template.item, template.type, templateDictionary);\r\n return Promise.resolve(template);\r\n }\r\n );\r\n });\r\n } else {\r\n // In case the org used to have velocity and they still have items\r\n return Promise.reject(\"Velocity NOT Supported by Organization\");\r\n }\r\n },\r\n e => Promise.reject(fail(e))\r\n );\r\n}\r\n\r\n/**\r\n * Create Velocity analytics and feeds from a Template\r\n *\r\n * @param template The template for the volocity items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param destinationAuthentication Credentials for the deployment requests\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n *\r\n * @returns a promise that will resolve with the new item info, id, type, and postProcess flag\r\n *\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // let the progress system know we've started...\r\n const startStatus = itemProgressCallback(\r\n template.itemId,\r\n EItemProgressStatus.Started,\r\n 0\r\n );\r\n\r\n // and if it returned false, just resolve out\r\n /* istanbul ignore else */\r\n if (!startStatus) {\r\n return Promise.resolve(generateEmptyCreationResponse(template.type));\r\n }\r\n\r\n const orgId = template.itemId;\r\n\r\n return postVelocityData(\r\n destinationAuthentication,\r\n template,\r\n template.data,\r\n templateDictionary\r\n ).then(result => {\r\n const finalStatus = itemProgressCallback(\r\n orgId,\r\n EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor || 2,\r\n result.id\r\n );\r\n\r\n if (!finalStatus) {\r\n return removeItem(result.id, destinationAuthentication).then(\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type)),\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n const response: ICreateItemFromTemplateResponse = {\r\n item: {\r\n ...template,\r\n ...result\r\n },\r\n id: result.item.id,\r\n type: template.type,\r\n postProcess: true\r\n };\r\n response.item.itemId = result.item.id;\r\n return response;\r\n }\r\n });\r\n}\r\n\r\n\r\n/**\r\n * Velocity post-processing actions\r\n * \r\n * Move all velocity items to the deployment folder.\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {IItemTemplate} template The item template\r\n * @param {IItemTemplate[]} templates The full collection of item templates\r\n * @param {any} templateDictionary Hash of facts such as the folder id for the deployment\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\n export function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const itemUpdate = itemInfos.filter(ii => ii.id === itemId);\r\n const item: any = itemUpdate[0].item.item;\r\n delete item.url;\r\n delete item.origUrl;\r\n return updateItem(item, authentication).then(() => {\r\n return moveItem({\r\n owner: authentication.username,\r\n itemId,\r\n folderId: templateDictionary.folderId,\r\n authentication\r\n });\r\n });\r\n}\r\n"],"names":["getProp","setProp","getItemBase","BASE_NAMES","PROP_NAMES","getVelocityUrlBase","replaceInTemplate","fail","createInitializedItemTemplate","updateVelocityReferences","EItemProgressStatus","generateEmptyCreationResponse","removeItem","updateItem","moveItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;EAcG;EAIH;;;;;;;;EAQG;EACG,SAAU,kBAAkB,CAAC,QAAuB,EAAA;EACxD,IAAA,WAAW,CAAC,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ACd,KAAK,EAAE,cAAc,CAAC,QAAQ;cAC9B,MAAM;cACN,QAAQ,EAAE,kBAAkB,CAAC,QAAQ;cACrC,cAAc;EACf,SAAA,CAAC,CAAC;EACL,KAAC,CAAC,CAAC;EACN;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"velocity.umd.js","sources":["../../src/helpers/velocity-templatize.ts","../../src/helpers/get-velocity-dependencies.ts","../../src/helpers/velocity-helpers.ts","../../src/velocity-processor.ts"],"sourcesContent":["/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { IItemTemplate, getProp, setProp } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Updates the template by adding variables for key properties that will\r\n * need to be swapped when deploying\r\n *\r\n * @param template velocity item info that should be templatized\r\n *\r\n * @returns void\r\n *\r\n */\r\nexport function templatizeVelocity(template: IItemTemplate): void {\r\n _templatize(template, \"data.sources\", _templatizeDatasources);\r\n _templatize(template, \"data.feeds\", _templatizeFeeds);\r\n _templatize(template, \"data.feed\", _templatizeFeed);\r\n}\r\n\r\n/**\r\n * Generic wrapper for the templatize functions that\r\n * will get and set the key properties\r\n *\r\n * @param template velocity item info that should be templatized\r\n * @param prop the prop path to evaluate and set with a templatized variable\r\n * @param fn the templatize function that should be called for this prop\r\n *\r\n * @returns void\r\n *\r\n * @private\r\n */\r\nexport function _templatize(\r\n template: IItemTemplate,\r\n prop: string,\r\n fn: (arg: any) => void\r\n): void {\r\n const obj: any = getProp(template, prop);\r\n /* istanbul ignore else */\r\n if (obj) {\r\n setProp(template, prop, fn(obj));\r\n }\r\n}\r\n\r\n/**\r\n * Updates the template by adding variables for the itemId and the label\r\n * The label controls the name and must be unique for the org.\r\n *\r\n * @param feeds array of velocity feeds that should be templatized\r\n *\r\n * @returns The updated list of feed objects with templatized id and label\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeeds(feeds: any[]): any {\r\n return feeds.map((feed: any) => {\r\n feed.label = feed.label && feed.id ? `{{${feed.id}.label}}` : feed.label;\r\n feed.id = feed.id ? `{{${feed.id}.itemId}}` : feed.id;\r\n return feed;\r\n });\r\n}\r\n\r\n/**\r\n * Updates the portal item id and feature layer id variables for the feed properties.\r\n *\r\n * @param feed the feed object from the item\r\n *\r\n * @returns the updated feed object with templatized portalItemId and layer id\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeed(feed: any): any {\r\n let id = getProp(feed, \"properties.feature-layer.portalItemId\");\r\n /* istanbul ignore else */\r\n if (feed.properties) {\r\n /* istanbul ignore else */\r\n if (feed.properties[\"feature-layer.portalItemId\"]) {\r\n id = feed.properties[\"feature-layer.portalItemId\"];\r\n feed.properties[\"feature-layer.portalItemId\"] = `{{${id}.itemId}}`;\r\n }\r\n /* istanbul ignore else */\r\n if (id && feed.properties.hasOwnProperty(\"feature-layer.layerId\")) {\r\n const flId = feed.properties[\"feature-layer.layerId\"];\r\n feed.properties[\r\n \"feature-layer.layerId\"\r\n ] = `{{${id}.layer${flId}.layerId}}`;\r\n }\r\n }\r\n return feed;\r\n}\r\n\r\n/**\r\n * Velocity datasources share the same props as feeds so they can leverage\r\n * the same templatize function\r\n *\r\n * @param dataSources array of data sources from the item\r\n *\r\n * @returns the updated dataSources object with templatized ids and labels\r\n *\r\n * @private\r\n */\r\nexport function _templatizeDatasources(dataSources: any[]): any {\r\n return dataSources.map((ds: any) => _templatizeFeed(ds));\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n getProp,\r\n getItemBase,\r\n IItemTemplate,\r\n UserSession,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Get the dependencies from the velocity data sources, feeds, and outputs.\r\n * Only dependencies that do NOT have the typeKeyword \"IoTFeatureLayer\" are returned.\r\n *\r\n * @param template The template that for the velocity item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n */\r\nexport function getVelocityDependencies(\r\n template: IItemTemplate,\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const dependencies: string[] = [];\r\n\r\n [\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(f => _getFeedDependencies(f, dependencies));\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(d => _getDependencies(d, dependencies));\r\n\r\n return _validateDependencies(dependencies, authentication);\r\n}\r\n\r\n/**\r\n * Any feature services with the typeKeyword \"IoTFeatureLayer\" should not be templatized or\r\n * listed as a dependency.\r\n * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.\r\n *\r\n * @param dependencies Any dependencies that have been found for this item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n * @private\r\n */\r\nexport function _validateDependencies(\r\n dependencies: string[],\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const defs: Array<Promise<any>> = dependencies.map(d => {\r\n return getItemBase(d, authentication);\r\n });\r\n return Promise.all(defs).then(itemInfos => {\r\n return Promise.resolve(\r\n itemInfos.reduce((prev, cur) => {\r\n if (cur.typeKeywords.indexOf(\"IoTFeatureLayer\") < 0) {\r\n prev.push(cur.id);\r\n }\r\n return prev;\r\n }, [])\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity feeds\r\n * This function will update the input dependencies argument\r\n *\r\n * @param feeds The list of feeds from the velocity template\r\n * @param dependencies The current list of dependencies\r\n * @private\r\n */\r\nexport function _getFeedDependencies(\r\n feeds: any[],\r\n dependencies: string[]\r\n): void {\r\n feeds.reduce((prev: any, cur: any) => {\r\n const id: string = cur.id || undefined;\r\n /* istanbul ignore else */\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n return prev;\r\n }, dependencies);\r\n // run through standard dependency check as well\r\n // in some cases the feed does not have the id property but will have\r\n // a portalItemId value in the properties\r\n _getDependencies(feeds, dependencies);\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity outputs or dataSources.\r\n * This function will update the input dependencies argument\r\n *\r\n * @param outputs The list of outputs from the velocity item\r\n * @param dependencies The current list of dependencies\r\n * @param prop The individual prop to evaluate\r\n * @private\r\n */\r\nexport function _getDependencies(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.reduce((prev: any, cur: any) => {\r\n const names: string[] = getProp(cur, \"name\") ? [cur.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => {\r\n // skip map service and stream service ids\r\n /* istanbul ignore else */\r\n if (p.indexOf(\"mapServicePortalItemID\") < 0 && p.indexOf(\"streamServicePortalItemID\") < 0) {\r\n const id: string = cur.properties ? cur.properties[n + p] : undefined;\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n }\r\n });\r\n });\r\n return prev;\r\n }, dependencies);\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n IVelocityTitle,\r\n getVelocityUrlBase,\r\n replaceInTemplate,\r\n UserSession,\r\n getProp,\r\n fail,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Common function to build urls for reading and interacting with the velocity api\r\n *\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id Optional The id of the velocity item we are constructing a url for\r\n * @param isDeploy Optional Is this being constructed as a part of deployment\r\n * @param urlPrefix Optional prefix args necessary for some url construction\r\n * @param urlSuffix Optional suffix args necessary for some url construction\r\n *\r\n * @returns a promise that will resolve the constructed url\r\n *\r\n */\r\nexport function getVelocityUrl(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id: string = \"\",\r\n isDeploy: boolean = false,\r\n urlPrefix: string = \"\",\r\n urlSuffix: string = \"\"\r\n): Promise<string> {\r\n return getVelocityUrlBase(authentication, templateDictionary).then(url => {\r\n if (url) {\r\n const _type: string =\r\n type === \"Real Time Analytic\"\r\n ? \"analytics/realtime\"\r\n : type === \"Big Data Analytic\"\r\n ? \"analytics/bigdata\"\r\n : type.toLowerCase();\r\n\r\n const suffix: string = urlSuffix ? `/${urlSuffix}` : \"\";\r\n const prefix: string = urlPrefix ? `/${urlPrefix}` : \"\";\r\n\r\n return Promise.resolve(\r\n isDeploy\r\n ? `${url}/iot/${_type}${prefix}${suffix}`\r\n : id\r\n ? `${url}/iot/${_type}${prefix}/${id}${suffix}/?f=json&token=${authentication.token}`\r\n : `${url}/iot/${_type}${prefix}${suffix}/?f=json&token=${authentication.token}`\r\n );\r\n } else {\r\n return Promise.resolve(url);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handles the creation of velocity items.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param template The current itemTemplate that is being used for deployment\r\n * @param data The velocity item data used to create the items.\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param autoStart This can be leveraged to start certain velocity items after they are created.\r\n *\r\n * @returns a promise that will resolve an object containing the item, id, type, and post process flag\r\n *\r\n */\r\nexport function postVelocityData(\r\n authentication: UserSession,\r\n template: IItemTemplate,\r\n data: any,\r\n templateDictionary: any,\r\n autoStart: boolean = false\r\n): Promise<any> {\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n undefined,\r\n true\r\n ).then(url => {\r\n if (url) {\r\n return getTitle(authentication, data.label, url).then((titleInfo: IVelocityTitle) => {\r\n const titles: any[] = titleInfo.titles;\r\n data.label = titleInfo.label;\r\n data.id = \"\";\r\n const body: any = replaceInTemplate(data, templateDictionary);\r\n\r\n const dataOutputs: any[] = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((o: any) => {\r\n return {\r\n id: o.id,\r\n name: o.properties[`${o.name}.name`]\r\n };\r\n });\r\n\r\n const feeds = (body.feeds ? body.feeds : body.feed ? [body.feed] : []).map((o:any) => {\r\n return {\r\n id: o.id ? o.id : o.properties[`${o.name}.portalItemId`] || \"\",\r\n name: o.label ? o.label : data.label\r\n };\r\n });\r\n\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n body,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n ).then(updatedBody => {\r\n return _fetch(authentication, url, \"POST\", updatedBody).then(rr => {\r\n template.item.url = `${url}/${rr.id}`;\r\n template.item.title = data.label;\r\n\r\n // Update the template dictionary\r\n templateDictionary[template.itemId][\"url\"] = template.item.url;\r\n templateDictionary[template.itemId][\"label\"] = data.label;\r\n templateDictionary[template.itemId][\"itemId\"] = rr.id;\r\n\r\n const finalResult = {\r\n item: replaceInTemplate(template.item, templateDictionary),\r\n id: rr.id,\r\n type: template.type,\r\n postProcess: false\r\n };\r\n\r\n if (autoStart) {\r\n return _validateAndStart(\r\n authentication,\r\n templateDictionary,\r\n template,\r\n rr.id\r\n ).then(() => {\r\n return Promise.resolve(finalResult);\r\n });\r\n } else {\r\n return Promise.resolve(finalResult);\r\n }\r\n });\r\n });\r\n });\r\n } else {\r\n return Promise.reject(fail(\"Velocity NOT Supported by Organization\"));\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Velocity item titles must be unique across the organization.\r\n * Check and ensure we set a unique title\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param label The current label of the item from the solution template\r\n * @param url The base velocity url for checking status\r\n *\r\n * @returns a promise that will resolve a unique title\r\n *\r\n */\r\nexport function getTitle(\r\n authentication: UserSession,\r\n label: string,\r\n url: string\r\n): Promise<IVelocityTitle> {\r\n return _fetch(authentication, `${url}StatusList?view=admin`, \"GET\").then(\r\n items => {\r\n const titles: any[] =\r\n items && Array.isArray(items)\r\n ? items.map(item => {\r\n return { title: item.label };\r\n })\r\n : [];\r\n return Promise.resolve({label: getUniqueTitle(label, { titles }, \"titles\"), titles: titles.map(t => t.title)});\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the data that will be used and handle any reported issues with the outputs.\r\n * The output names must be unique across the organization.\r\n *\r\n * This function will update the data arg that is passed in with a unique name.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item\r\n * @param data The data used to construct the velocity item\r\n * @param titles The list of know titles that exist in the org\r\n * @param dataOutputs The velocity items output objects\r\n * @param feeds The velocity items feed objects\r\n *\r\n * @returns a promise that will resolve the data object passed in with any necessary changes.\r\n *\r\n * @private\r\n */\r\nexport function _validateOutputs(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n data: any,\r\n titles: any[],\r\n dataOutputs: any[] = [],\r\n feeds: any[] = []\r\n): Promise<any> {\r\n if (dataOutputs.length > 0 || feeds.length > 0) {\r\n return validate(authentication, templateDictionary, type, \"\", data).then(\r\n (validateResults: any) => {\r\n const names: string[] = _validateMessages(validateResults);\r\n if (names.length > 0) {\r\n /* istanbul ignore else */\r\n if (dataOutputs.length > 0) {\r\n _updateDataOutput(dataOutputs, data, names);\r\n }\r\n /* istanbul ignore else */\r\n if (feeds.length > 0) {\r\n _updateFeed(feeds, data, names.concat(titles));\r\n }\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n data,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n }\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n}\r\n\r\n/**\r\n * Check the validate results for any name conflicts and store the conflicting names.\r\n *\r\n * @param validateResults The results object to check for name conflict errors\r\n *\r\n * @returns a list of names that already exist in the org\r\n *\r\n * @private\r\n */\r\nexport function _validateMessages(\r\n validateResults: any\r\n): string[] {\r\n let messages: any[] = getProp(validateResults, \"validation.messages\");\r\n\r\n const nodes: any[] = getProp(validateResults, \"nodes\");\r\n /* istanbul ignore else */\r\n if (nodes && Array.isArray(nodes)) {\r\n nodes.forEach(node => {\r\n messages = messages.concat(\r\n getProp(node, \"validation.messages\") || []\r\n );\r\n });\r\n }\r\n\r\n let names: string[] = [];\r\n /* istanbul ignore else */\r\n if (messages && Array.isArray(messages)) {\r\n messages.forEach(message => {\r\n // I don't see a way to ask for all output names that exist\r\n // velocityUrl + /outputs/ just gives you generic defaults not what currently exists\r\n const nameErrors = [\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_FEATURE_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_STREAM_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"ITEM_MANAGER__CREATE_ANALYTIC_FAILED_DUPLICATE_OUTPUT_NAMES_IN_ORGANIZATION_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_BIG_DATA_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_REAL_TIME_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_FEED_FAILED_DUPLICATE_NAME\"\r\n ];\r\n // The names returned here seem to replace \" \" with \"_\" so they do not match exactly\r\n /* istanbul ignore else */\r\n if (nameErrors.indexOf(message.key) > -1) {\r\n names = names.concat(message.args);\r\n }\r\n });\r\n }\r\n return names;\r\n}\r\n\r\n/**\r\n * Updates the feed object with a new name when validation fails.\r\n *\r\n * @param feeds The feed objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateFeed(\r\n feeds: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n feeds.forEach(f => {\r\n const update = _getOutputLabel(names, f);\r\n /* istanbul ignore else */\r\n if (update) {\r\n data.label = update.label;\r\n f.name = update.label;\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Updates the data object with a new name when validation fails.\r\n *\r\n * @param dataOutputs The data output objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateDataOutput(\r\n dataOutputs: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n dataOutputs.forEach(dataOutput => {\r\n const update = _getOutputLabel(names, dataOutput);\r\n /* istanbul ignore else */\r\n if (update) {\r\n const _outputs = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((_dataOutput: any) => {\r\n /* istanbul ignore else */\r\n if (_dataOutput.id === update.id) {\r\n /* istanbul ignore else */\r\n if (_dataOutput.properties) {\r\n const nameProp: string = `${_dataOutput.name}.name`;\r\n /* istanbul ignore else */\r\n if (Object.keys(_dataOutput.properties).indexOf(nameProp) > -1) {\r\n _dataOutput.properties[nameProp] = update.label;\r\n }\r\n }\r\n }\r\n return _dataOutput;\r\n });\r\n /* istanbul ignore else */\r\n if (data.outputs) {\r\n data.outputs = _outputs;\r\n }\r\n /* istanbul ignore else */\r\n if (data.output) {\r\n data.output = _outputs[0];\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Get a unique label for the item.\r\n *\r\n * @param names The names that failed due to duplicate error in validation.\r\n * @param dataOutput The current data output that is being evaluated.\r\n *\r\n * @returns an object with a unique label and the outputs id when a name\r\n * conflict is found...otherwise returns undefined\r\n *\r\n * @private\r\n */\r\nexport function _getOutputLabel(names: any[], dataOutput: any): any {\r\n const titles: any[] = names.map((name: any) => {\r\n return { title: name };\r\n });\r\n\r\n const label = getUniqueTitle(dataOutput.name, { titles }, \"titles\");\r\n\r\n return label !== dataOutput.name\r\n ? {\r\n label,\r\n id: dataOutput.id\r\n }\r\n : undefined;\r\n}\r\n\r\n/**\r\n * Will return the provided title if it does not exist as a property\r\n * in one of the objects at the defined path. Otherwise the title will\r\n * have a numerical value attached.\r\n *\r\n * This is based on \"getUniqueTitle\" from common but adds the \"_\" replacement check for velocity names.\r\n * Could switch to using common if Velocity has a way to get a list of all names that are already used.\r\n *\r\n * @param title The root title to test\r\n * @param templateDictionary Hash of the facts\r\n * @param path to the objects to evaluate for potantial name clashes\r\n *\r\n * @returns string The unique title to use\r\n *\r\n */\r\nexport function getUniqueTitle(\r\n title: string,\r\n templateDictionary: any,\r\n path: string\r\n): string {\r\n title = title ? title.trim() : \"_\";\r\n const objs: any[] = getProp(templateDictionary, path) || [];\r\n const titles: string[] = objs.map(obj => {\r\n return obj.title;\r\n });\r\n let newTitle: string = title;\r\n let i: number = 0;\r\n // replace added for velocitcy\r\n // validation seems to add \"_\" to names listed in outputs..so no way to compare without hacking the name\r\n while (\r\n titles.indexOf(newTitle) > -1 ||\r\n titles.indexOf(newTitle.replace(/ /g, \"_\")) > -1\r\n ) {\r\n i++;\r\n newTitle = title + \" \" + i;\r\n }\r\n return newTitle;\r\n}\r\n\r\n/**\r\n * Start the item if validation passes and the item is executable.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param template the item template that has the details for deployment\r\n * @param id the new id for the velocity item that was deployed\r\n *\r\n * @returns a promise that will resolve with the validation results\r\n * or the start results when validation indicates the item is executable\r\n *\r\n * @private\r\n */\r\nexport function _validateAndStart(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n template: IItemTemplate,\r\n id: string\r\n): Promise<any> {\r\n return validate(authentication, templateDictionary, template.type, id).then(\r\n validateResult => {\r\n if (validateResult.executable) {\r\n return start(authentication, templateDictionary, template.type, id);\r\n } else {\r\n return Promise.resolve(validateResult);\r\n }\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the velocity item.\r\n * Used to help find and handle duplicate name errors.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n * @param body? Optional the request body to validate.\r\n *\r\n * @returns a promise that will resolve with an object containing messages\r\n * indicating any issues found when validating such as name conflict errors\r\n *\r\n */\r\nexport function validate(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string,\r\n body?: any\r\n): Promise<any> {\r\n // /iot/feed/validate/{id}/\r\n // /iot/analytics/realtime/validate/{id}/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"validate\",\r\n \"\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"POST\", body).then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Start the given velocity item that has been deployed.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n *\r\n * @returns a promise that will resolve with the result of the start call\r\n *\r\n */\r\nexport function start(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string\r\n): Promise<any> {\r\n // /iot/feed/{id}/start/\r\n // /iot/analytics/realtime/{id}/start/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"\",\r\n \"start\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"GET\").then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Gets the required request options for requests to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param method Indicate if \"GET\" or \"POST\"\r\n *\r\n * @returns generic request options used for various calls to velocity api\r\n *\r\n * @private\r\n */\r\nexport function _getRequestOpts(\r\n authentication: UserSession,\r\n method: string\r\n): RequestInit {\r\n return {\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n Authorization: \"token=\" + authentication.token\r\n },\r\n method\r\n };\r\n}\r\n\r\n/**\r\n * Generic fetch function for making calls to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param url The url from the velocity API to handle reading and writing\r\n * @param method The method for the request \"GET\" or \"POST\"\r\n * @param body The body for POST requests\r\n *\r\n * @returns a promise that will resolve with the result of the fetch call\r\n *\r\n * @private\r\n */\r\nexport function _fetch(\r\n authentication: UserSession,\r\n url: string,\r\n method: string, // GET or POST\r\n body?: any\r\n): Promise<any> {\r\n const requestOpts: any = _getRequestOpts(authentication, method);\r\n /* istanbul ignore else */\r\n if (body) {\r\n requestOpts.body = JSON.stringify(body);\r\n }\r\n return fetch(url, requestOpts).then(r => Promise.resolve(r.json()));\r\n}\r\n\r\n/**\r\n * Remove key properties if the dependency was removed due to having the \"IoTFeatureLayer\" typeKeyword\r\n * This function will update the input template.\r\n *\r\n * @param template The template that for the velocity item\r\n *\r\n */\r\nexport function cleanDataSourcesAndFeeds(\r\n template: IItemTemplate,\r\n velocityUrl: string\r\n): void {\r\n const dependencies: string[] = template.dependencies;\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(d => _removeIdProps(d, dependencies, velocityUrl));\r\n\r\n [\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(outputs => _removeIdPropsAndSetName(outputs, dependencies));\r\n}\r\n\r\n/**\r\n * Remove key properties from the input source or feed\r\n *\r\n * @param sourcesOrFeeds The list of dataSources or feeds\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdProps(\r\n sourcesOrFeeds: any[],\r\n dependencies: string[],\r\n velocityUrl: string\r\n): void {\r\n sourcesOrFeeds.forEach(dataSource => {\r\n const idProp: string = \"feature-layer.portalItemId\";\r\n const layerIdProp: string = \"feature-layer.layerId\"\r\n /* istanbul ignore else */\r\n if (dataSource.properties) {\r\n /* istanbul ignore else */\r\n if (dataSource.properties[idProp]) {\r\n const id: string = dataSource.properties[idProp];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete dataSource.properties[idProp];\r\n delete dataSource.properties[layerIdProp];\r\n }\r\n }\r\n\r\n const urlProp: string = \"simulator.url\";\r\n const url: any = dataSource.properties[urlProp];\r\n // only remove velocity based simulator urls\r\n // otherwise we will leave as is with no templatization\r\n /* istanbul ignore else */\r\n if (url && url.indexOf(velocityUrl) > -1) {\r\n delete dataSource.properties[urlProp]\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Remove key properties from the outputs.\r\n *\r\n * @param outputs The list of outputs\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdPropsAndSetName(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.forEach(output => {\r\n /* istanbul ignore else */\r\n if (output.properties) {\r\n const names: string[] = getProp(output, \"name\") ? [output.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => _removeProp(output.properties, n + p, dependencies));\r\n });\r\n\r\n _updateName(output.properties);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Generic helper function to remove key properties .\r\n *\r\n * @param props the list of props to update\r\n * @param prop the individual prop to remove\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeProp(\r\n props: any,\r\n prop: string,\r\n dependencies: string[]\r\n): void {\r\n const id: string = props[prop];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete props[prop];\r\n }\r\n}\r\n\r\n/**\r\n * Update the feature layer name to include the solution item id.\r\n *\r\n * @param props the list of props to update\r\n *\r\n * @private\r\n */\r\nexport function _updateName(props: any): void {\r\n [\r\n \"feat-lyr-new.name\",\r\n \"stream-lyr-new.name\",\r\n \"feat-lyr-existing.name\"\r\n ].forEach(n => {\r\n const name: string = props[n];\r\n /* istanbul ignore else */\r\n if (name && name.indexOf(\"{{solutionItemId}}\") < 0) {\r\n props[n] = `${name}_{{solutionItemId}}`;\r\n }\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of velocity item types.\r\n *\r\n * @module velocity\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemProgressCallback,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n generateEmptyCreationResponse,\r\n createInitializedItemTemplate,\r\n fail,\r\n removeItem,\r\n updateVelocityReferences,\r\n updateItem\r\n} from \"@esri/solution-common\";\r\nimport { templatizeVelocity } from \"./helpers/velocity-templatize\";\r\nimport { getVelocityDependencies } from \"./helpers/get-velocity-dependencies\";\r\nimport {\r\n cleanDataSourcesAndFeeds,\r\n getVelocityUrl,\r\n postVelocityData\r\n} from \"./helpers/velocity-helpers\";\r\nimport {\r\n moveItem\r\n} from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Convert a Velocity item into a Template\r\n *\r\n * @param solutionItemId The solution to contain the item\r\n * @param itemInfo The basic item info\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n *\r\n * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo\r\n *\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n const template = createInitializedItemTemplate(itemInfo);\r\n return getVelocityUrl(\r\n srcAuthentication,\r\n templateDictionary,\r\n itemInfo.type,\r\n itemInfo.id\r\n ).then(\r\n (url: string) => {\r\n if (url) {\r\n return fetch(url)\r\n .then(data => data.json())\r\n .then(data_json => {\r\n template.item.title = data_json.label;\r\n template.data = data_json;\r\n return getVelocityDependencies(template, srcAuthentication).then(\r\n deps => {\r\n template.dependencies = deps;\r\n cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);\r\n templatizeVelocity(template);\r\n template.item = updateVelocityReferences(template.item, template.type, templateDictionary);\r\n return Promise.resolve(template);\r\n }\r\n );\r\n });\r\n } else {\r\n // In case the org used to have velocity and they still have items\r\n return Promise.reject(\"Velocity NOT Supported by Organization\");\r\n }\r\n },\r\n e => Promise.reject(fail(e))\r\n );\r\n}\r\n\r\n/**\r\n * Create Velocity analytics and feeds from a Template\r\n *\r\n * @param template The template for the volocity items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param destinationAuthentication Credentials for the deployment requests\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n *\r\n * @returns a promise that will resolve with the new item info, id, type, and postProcess flag\r\n *\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // let the progress system know we've started...\r\n const startStatus = itemProgressCallback(\r\n template.itemId,\r\n EItemProgressStatus.Started,\r\n 0\r\n );\r\n\r\n // and if it returned false, just resolve out\r\n /* istanbul ignore else */\r\n if (!startStatus) {\r\n return Promise.resolve(generateEmptyCreationResponse(template.type));\r\n }\r\n\r\n const orgId = template.itemId;\r\n\r\n return postVelocityData(\r\n destinationAuthentication,\r\n template,\r\n template.data,\r\n templateDictionary\r\n ).then(result => {\r\n const finalStatus = itemProgressCallback(\r\n orgId,\r\n EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor || 2,\r\n result.id\r\n );\r\n\r\n if (!finalStatus) {\r\n return removeItem(result.id, destinationAuthentication).then(\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type)),\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n const response: ICreateItemFromTemplateResponse = {\r\n item: {\r\n ...template,\r\n ...result\r\n },\r\n id: result.item.id,\r\n type: template.type,\r\n postProcess: true\r\n };\r\n response.item.itemId = result.item.id;\r\n return response;\r\n }\r\n });\r\n}\r\n\r\n\r\n/**\r\n * Velocity post-processing actions\r\n * \r\n * Move all velocity items to the deployment folder.\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {IItemTemplate} template The item template\r\n * @param {IItemTemplate[]} templates The full collection of item templates\r\n * @param {any} templateDictionary Hash of facts such as the folder id for the deployment\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\n export function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const itemUpdate = itemInfos.filter(ii => ii.id === itemId);\r\n const item: any = itemUpdate[0].item.item;\r\n delete item.url;\r\n delete item.origUrl;\r\n return updateItem(item, authentication).then(() => {\r\n return moveItem({\r\n owner: authentication.username,\r\n itemId,\r\n folderId: templateDictionary.folderId,\r\n authentication\r\n });\r\n });\r\n}\r\n"],"names":["getProp","setProp","getItemBase","BASE_NAMES","PROP_NAMES","getVelocityUrlBase","replaceInTemplate","fail","createInitializedItemTemplate","updateVelocityReferences","EItemProgressStatus","generateEmptyCreationResponse","removeItem","updateItem","moveItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAkBA;;;;;;;;;WASgB,kBAAkB,CAAC,QAAuB;MACxD,WAAW,CAAC,QAAQ,EAAE,cAAc,EAAE,sBAAsB,CAAC,CAAC;MAC9D,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAC;MACtD,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;EACtD,CAAC;EAED;;;;;;;;;;;;WAYgB,WAAW,CACzB,QAAuB,EACvB,IAAY,EACZ,EAAsB;MAEtB,MAAM,GAAG,GAAQA,sBAAO,CAAC,QA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wed Jun 08 2022 11:07:38 GMT-0700 (Pacific Daylight Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1 +1 @@
1
- {"version":3,"file":"velocity.umd.min.js","sources":["../../src/helpers/velocity-templatize.ts","../../src/helpers/get-velocity-dependencies.ts","../../src/helpers/velocity-helpers.ts","../../src/velocity-processor.ts"],"sourcesContent":["/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { IItemTemplate, getProp, setProp } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Updates the template by adding variables for key properties that will\r\n * need to be swapped when deploying\r\n *\r\n * @param template velocity item info that should be templatized\r\n *\r\n * @returns void\r\n *\r\n */\r\nexport function templatizeVelocity(template: IItemTemplate): void {\r\n _templatize(template, \"data.sources\", _templatizeDatasources);\r\n _templatize(template, \"data.feeds\", _templatizeFeeds);\r\n _templatize(template, \"data.feed\", _templatizeFeed);\r\n}\r\n\r\n/**\r\n * Generic wrapper for the templatize functions that\r\n * will get and set the key properties\r\n *\r\n * @param template velocity item info that should be templatized\r\n * @param prop the prop path to evaluate and set with a templatized variable\r\n * @param fn the templatize function that should be called for this prop\r\n *\r\n * @returns void\r\n *\r\n * @private\r\n */\r\nexport function _templatize(\r\n template: IItemTemplate,\r\n prop: string,\r\n fn: (arg: any) => void\r\n): void {\r\n const obj: any = getProp(template, prop);\r\n /* istanbul ignore else */\r\n if (obj) {\r\n setProp(template, prop, fn(obj));\r\n }\r\n}\r\n\r\n/**\r\n * Updates the template by adding variables for the itemId and the label\r\n * The label controls the name and must be unique for the org.\r\n *\r\n * @param feeds array of velocity feeds that should be templatized\r\n *\r\n * @returns The updated list of feed objects with templatized id and label\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeeds(feeds: any[]): any {\r\n return feeds.map((feed: any) => {\r\n feed.label = feed.label && feed.id ? `{{${feed.id}.label}}` : feed.label;\r\n feed.id = feed.id ? `{{${feed.id}.itemId}}` : feed.id;\r\n return feed;\r\n });\r\n}\r\n\r\n/**\r\n * Updates the portal item id and feature layer id variables for the feed properties.\r\n *\r\n * @param feed the feed object from the item\r\n *\r\n * @returns the updated feed object with templatized portalItemId and layer id\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeed(feed: any): any {\r\n let id = getProp(feed, \"properties.feature-layer.portalItemId\");\r\n /* istanbul ignore else */\r\n if (feed.properties) {\r\n /* istanbul ignore else */\r\n if (feed.properties[\"feature-layer.portalItemId\"]) {\r\n id = feed.properties[\"feature-layer.portalItemId\"];\r\n feed.properties[\"feature-layer.portalItemId\"] = `{{${id}.itemId}}`;\r\n }\r\n /* istanbul ignore else */\r\n if (id && feed.properties.hasOwnProperty(\"feature-layer.layerId\")) {\r\n const flId = feed.properties[\"feature-layer.layerId\"];\r\n feed.properties[\r\n \"feature-layer.layerId\"\r\n ] = `{{${id}.layer${flId}.layerId}}`;\r\n }\r\n }\r\n return feed;\r\n}\r\n\r\n/**\r\n * Velocity datasources share the same props as feeds so they can leverage\r\n * the same templatize function\r\n *\r\n * @param dataSources array of data sources from the item\r\n *\r\n * @returns the updated dataSources object with templatized ids and labels\r\n *\r\n * @private\r\n */\r\nexport function _templatizeDatasources(dataSources: any[]): any {\r\n return dataSources.map((ds: any) => _templatizeFeed(ds));\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n getProp,\r\n getItemBase,\r\n IItemTemplate,\r\n UserSession,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Get the dependencies from the velocity data sources, feeds, and outputs.\r\n * Only dependencies that do NOT have the typeKeyword \"IoTFeatureLayer\" are returned.\r\n *\r\n * @param template The template that for the velocity item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n */\r\nexport function getVelocityDependencies(\r\n template: IItemTemplate,\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const dependencies: string[] = [];\r\n\r\n [\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(f => _getFeedDependencies(f, dependencies));\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(d => _getDependencies(d, dependencies));\r\n\r\n return _validateDependencies(dependencies, authentication);\r\n}\r\n\r\n/**\r\n * Any feature services with the typeKeyword \"IoTFeatureLayer\" should not be templatized or\r\n * listed as a dependency.\r\n * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.\r\n *\r\n * @param dependencies Any dependencies that have been found for this item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n * @private\r\n */\r\nexport function _validateDependencies(\r\n dependencies: string[],\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const defs: Array<Promise<any>> = dependencies.map(d => {\r\n return getItemBase(d, authentication);\r\n });\r\n return Promise.all(defs).then(itemInfos => {\r\n return Promise.resolve(\r\n itemInfos.reduce((prev, cur) => {\r\n if (cur.typeKeywords.indexOf(\"IoTFeatureLayer\") < 0) {\r\n prev.push(cur.id);\r\n }\r\n return prev;\r\n }, [])\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity feeds\r\n * This function will update the input dependencies argument\r\n *\r\n * @param feeds The list of feeds from the velocity template\r\n * @param dependencies The current list of dependencies\r\n * @private\r\n */\r\nexport function _getFeedDependencies(\r\n feeds: any[],\r\n dependencies: string[]\r\n): void {\r\n feeds.reduce((prev: any, cur: any) => {\r\n const id: string = cur.id || undefined;\r\n /* istanbul ignore else */\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n return prev;\r\n }, dependencies);\r\n // run through standard dependency check as well\r\n // in some cases the feed does not have the id property but will have\r\n // a portalItemId value in the properties\r\n _getDependencies(feeds, dependencies);\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity outputs or dataSources.\r\n * This function will update the input dependencies argument\r\n *\r\n * @param outputs The list of outputs from the velocity item\r\n * @param dependencies The current list of dependencies\r\n * @param prop The individual prop to evaluate\r\n * @private\r\n */\r\nexport function _getDependencies(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.reduce((prev: any, cur: any) => {\r\n const names: string[] = getProp(cur, \"name\") ? [cur.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => {\r\n // skip map service and stream service ids\r\n /* istanbul ignore else */\r\n if (p.indexOf(\"mapServicePortalItemID\") < 0 && p.indexOf(\"streamServicePortalItemID\") < 0) {\r\n const id: string = cur.properties ? cur.properties[n + p] : undefined;\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n }\r\n });\r\n });\r\n return prev;\r\n }, dependencies);\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n IVelocityTitle,\r\n getVelocityUrlBase,\r\n replaceInTemplate,\r\n UserSession,\r\n getProp,\r\n fail,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Common function to build urls for reading and interacting with the velocity api\r\n *\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id Optional The id of the velocity item we are constructing a url for\r\n * @param isDeploy Optional Is this being constructed as a part of deployment\r\n * @param urlPrefix Optional prefix args necessary for some url construction\r\n * @param urlSuffix Optional suffix args necessary for some url construction\r\n *\r\n * @returns a promise that will resolve the constructed url\r\n *\r\n */\r\nexport function getVelocityUrl(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id: string = \"\",\r\n isDeploy: boolean = false,\r\n urlPrefix: string = \"\",\r\n urlSuffix: string = \"\"\r\n): Promise<string> {\r\n return getVelocityUrlBase(authentication, templateDictionary).then(url => {\r\n if (url) {\r\n const _type: string =\r\n type === \"Real Time Analytic\"\r\n ? \"analytics/realtime\"\r\n : type === \"Big Data Analytic\"\r\n ? \"analytics/bigdata\"\r\n : type.toLowerCase();\r\n\r\n const suffix: string = urlSuffix ? `/${urlSuffix}` : \"\";\r\n const prefix: string = urlPrefix ? `/${urlPrefix}` : \"\";\r\n\r\n return Promise.resolve(\r\n isDeploy\r\n ? `${url}/iot/${_type}${prefix}${suffix}`\r\n : id\r\n ? `${url}/iot/${_type}${prefix}/${id}${suffix}/?f=json&token=${authentication.token}`\r\n : `${url}/iot/${_type}${prefix}${suffix}/?f=json&token=${authentication.token}`\r\n );\r\n } else {\r\n return Promise.resolve(url);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handles the creation of velocity items.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param template The current itemTemplate that is being used for deployment\r\n * @param data The velocity item data used to create the items.\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param autoStart This can be leveraged to start certain velocity items after they are created.\r\n *\r\n * @returns a promise that will resolve an object containing the item, id, type, and post process flag\r\n *\r\n */\r\nexport function postVelocityData(\r\n authentication: UserSession,\r\n template: IItemTemplate,\r\n data: any,\r\n templateDictionary: any,\r\n autoStart: boolean = false\r\n): Promise<any> {\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n undefined,\r\n true\r\n ).then(url => {\r\n if (url) {\r\n return getTitle(authentication, data.label, url).then((titleInfo: IVelocityTitle) => {\r\n const titles: any[] = titleInfo.titles;\r\n data.label = titleInfo.label;\r\n data.id = \"\";\r\n const body: any = replaceInTemplate(data, templateDictionary);\r\n\r\n const dataOutputs: any[] = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((o: any) => {\r\n return {\r\n id: o.id,\r\n name: o.properties[`${o.name}.name`]\r\n };\r\n });\r\n\r\n const feeds = (body.feeds ? body.feeds : body.feed ? [body.feed] : []).map((o:any) => {\r\n return {\r\n id: o.id ? o.id : o.properties[`${o.name}.portalItemId`] || \"\",\r\n name: o.label ? o.label : data.label\r\n };\r\n });\r\n\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n body,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n ).then(updatedBody => {\r\n return _fetch(authentication, url, \"POST\", updatedBody).then(rr => {\r\n template.item.url = `${url}/${rr.id}`;\r\n template.item.title = data.label;\r\n\r\n // Update the template dictionary\r\n templateDictionary[template.itemId][\"url\"] = template.item.url;\r\n templateDictionary[template.itemId][\"label\"] = data.label;\r\n templateDictionary[template.itemId][\"itemId\"] = rr.id;\r\n\r\n const finalResult = {\r\n item: replaceInTemplate(template.item, templateDictionary),\r\n id: rr.id,\r\n type: template.type,\r\n postProcess: false\r\n };\r\n\r\n if (autoStart) {\r\n return _validateAndStart(\r\n authentication,\r\n templateDictionary,\r\n template,\r\n rr.id\r\n ).then(() => {\r\n return Promise.resolve(finalResult);\r\n });\r\n } else {\r\n return Promise.resolve(finalResult);\r\n }\r\n });\r\n });\r\n });\r\n } else {\r\n return Promise.reject(fail(\"Velocity NOT Supported by Organization\"));\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Velocity item titles must be unique across the organization.\r\n * Check and ensure we set a unique title\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param label The current label of the item from the solution template\r\n * @param url The base velocity url for checking status\r\n *\r\n * @returns a promise that will resolve a unique title\r\n *\r\n */\r\nexport function getTitle(\r\n authentication: UserSession,\r\n label: string,\r\n url: string\r\n): Promise<IVelocityTitle> {\r\n return _fetch(authentication, `${url}StatusList?view=admin`, \"GET\").then(\r\n items => {\r\n const titles: any[] =\r\n items && Array.isArray(items)\r\n ? items.map(item => {\r\n return { title: item.label };\r\n })\r\n : [];\r\n return Promise.resolve({label: getUniqueTitle(label, { titles }, \"titles\"), titles: titles.map(t => t.title)});\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the data that will be used and handle any reported issues with the outputs.\r\n * The output names must be unique across the organization.\r\n *\r\n * This function will update the data arg that is passed in with a unique name.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item\r\n * @param data The data used to construct the velocity item\r\n * @param titles The list of know titles that exist in the org\r\n * @param dataOutputs The velocity items output objects\r\n * @param feeds The velocity items feed objects\r\n *\r\n * @returns a promise that will resolve the data object passed in with any necessary changes.\r\n *\r\n * @private\r\n */\r\nexport function _validateOutputs(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n data: any,\r\n titles: any[],\r\n dataOutputs: any[] = [],\r\n feeds: any[] = []\r\n): Promise<any> {\r\n if (dataOutputs.length > 0 || feeds.length > 0) {\r\n return validate(authentication, templateDictionary, type, \"\", data).then(\r\n (validateResults: any) => {\r\n const names: string[] = _validateMessages(validateResults);\r\n if (names.length > 0) {\r\n /* istanbul ignore else */\r\n if (dataOutputs.length > 0) {\r\n _updateDataOutput(dataOutputs, data, names);\r\n }\r\n /* istanbul ignore else */\r\n if (feeds.length > 0) {\r\n _updateFeed(feeds, data, names.concat(titles));\r\n }\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n data,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n }\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n}\r\n\r\n/**\r\n * Check the validate results for any name conflicts and store the conflicting names.\r\n *\r\n * @param validateResults The results object to check for name conflict errors\r\n *\r\n * @returns a list of names that already exist in the org\r\n *\r\n * @private\r\n */\r\nexport function _validateMessages(\r\n validateResults: any\r\n): string[] {\r\n let messages: any[] = getProp(validateResults, \"validation.messages\");\r\n\r\n const nodes: any[] = getProp(validateResults, \"nodes\");\r\n /* istanbul ignore else */\r\n if (nodes && Array.isArray(nodes)) {\r\n nodes.forEach(node => {\r\n messages = messages.concat(\r\n getProp(node, \"validation.messages\") || []\r\n );\r\n });\r\n }\r\n\r\n let names: string[] = [];\r\n /* istanbul ignore else */\r\n if (messages && Array.isArray(messages)) {\r\n messages.forEach(message => {\r\n // I don't see a way to ask for all output names that exist\r\n // velocityUrl + /outputs/ just gives you generic defaults not what currently exists\r\n const nameErrors = [\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_FEATURE_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_STREAM_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"ITEM_MANAGER__CREATE_ANALYTIC_FAILED_DUPLICATE_OUTPUT_NAMES_IN_ORGANIZATION_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_BIG_DATA_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_REAL_TIME_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_FEED_FAILED_DUPLICATE_NAME\"\r\n ];\r\n // The names returned here seem to replace \" \" with \"_\" so they do not match exactly\r\n /* istanbul ignore else */\r\n if (nameErrors.indexOf(message.key) > -1) {\r\n names = names.concat(message.args);\r\n }\r\n });\r\n }\r\n return names;\r\n}\r\n\r\n/**\r\n * Updates the feed object with a new name when validation fails.\r\n *\r\n * @param feeds The feed objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateFeed(\r\n feeds: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n feeds.forEach(f => {\r\n const update = _getOutputLabel(names, f);\r\n /* istanbul ignore else */\r\n if (update) {\r\n data.label = update.label;\r\n f.name = update.label;\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Updates the data object with a new name when validation fails.\r\n *\r\n * @param dataOutputs The data output objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateDataOutput(\r\n dataOutputs: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n dataOutputs.forEach(dataOutput => {\r\n const update = _getOutputLabel(names, dataOutput);\r\n /* istanbul ignore else */\r\n if (update) {\r\n const _outputs = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((_dataOutput: any) => {\r\n /* istanbul ignore else */\r\n if (_dataOutput.id === update.id) {\r\n /* istanbul ignore else */\r\n if (_dataOutput.properties) {\r\n const nameProp: string = `${_dataOutput.name}.name`;\r\n /* istanbul ignore else */\r\n if (Object.keys(_dataOutput.properties).indexOf(nameProp) > -1) {\r\n _dataOutput.properties[nameProp] = update.label;\r\n }\r\n }\r\n }\r\n return _dataOutput;\r\n });\r\n /* istanbul ignore else */\r\n if (data.outputs) {\r\n data.outputs = _outputs;\r\n }\r\n /* istanbul ignore else */\r\n if (data.output) {\r\n data.output = _outputs[0];\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Get a unique label for the item.\r\n *\r\n * @param names The names that failed due to duplicate error in validation.\r\n * @param dataOutput The current data output that is being evaluated.\r\n *\r\n * @returns an object with a unique label and the outputs id when a name\r\n * conflict is found...otherwise returns undefined\r\n *\r\n * @private\r\n */\r\nexport function _getOutputLabel(names: any[], dataOutput: any): any {\r\n const titles: any[] = names.map((name: any) => {\r\n return { title: name };\r\n });\r\n\r\n const label = getUniqueTitle(dataOutput.name, { titles }, \"titles\");\r\n\r\n return label !== dataOutput.name\r\n ? {\r\n label,\r\n id: dataOutput.id\r\n }\r\n : undefined;\r\n}\r\n\r\n/**\r\n * Will return the provided title if it does not exist as a property\r\n * in one of the objects at the defined path. Otherwise the title will\r\n * have a numerical value attached.\r\n *\r\n * This is based on \"getUniqueTitle\" from common but adds the \"_\" replacement check for velocity names.\r\n * Could switch to using common if Velocity has a way to get a list of all names that are already used.\r\n *\r\n * @param title The root title to test\r\n * @param templateDictionary Hash of the facts\r\n * @param path to the objects to evaluate for potantial name clashes\r\n *\r\n * @returns string The unique title to use\r\n *\r\n */\r\nexport function getUniqueTitle(\r\n title: string,\r\n templateDictionary: any,\r\n path: string\r\n): string {\r\n title = title ? title.trim() : \"_\";\r\n const objs: any[] = getProp(templateDictionary, path) || [];\r\n const titles: string[] = objs.map(obj => {\r\n return obj.title;\r\n });\r\n let newTitle: string = title;\r\n let i: number = 0;\r\n // replace added for velocitcy\r\n // validation seems to add \"_\" to names listed in outputs..so no way to compare without hacking the name\r\n while (\r\n titles.indexOf(newTitle) > -1 ||\r\n titles.indexOf(newTitle.replace(/ /g, \"_\")) > -1\r\n ) {\r\n i++;\r\n newTitle = title + \" \" + i;\r\n }\r\n return newTitle;\r\n}\r\n\r\n/**\r\n * Start the item if validation passes and the item is executable.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param template the item template that has the details for deployment\r\n * @param id the new id for the velocity item that was deployed\r\n *\r\n * @returns a promise that will resolve with the validation results\r\n * or the start results when validation indicates the item is executable\r\n *\r\n * @private\r\n */\r\nexport function _validateAndStart(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n template: IItemTemplate,\r\n id: string\r\n): Promise<any> {\r\n return validate(authentication, templateDictionary, template.type, id).then(\r\n validateResult => {\r\n if (validateResult.executable) {\r\n return start(authentication, templateDictionary, template.type, id);\r\n } else {\r\n return Promise.resolve(validateResult);\r\n }\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the velocity item.\r\n * Used to help find and handle duplicate name errors.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n * @param body? Optional the request body to validate.\r\n *\r\n * @returns a promise that will resolve with an object containing messages\r\n * indicating any issues found when validating such as name conflict errors\r\n *\r\n */\r\nexport function validate(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string,\r\n body?: any\r\n): Promise<any> {\r\n // /iot/feed/validate/{id}/\r\n // /iot/analytics/realtime/validate/{id}/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"validate\",\r\n \"\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"POST\", body).then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Start the given velocity item that has been deployed.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n *\r\n * @returns a promise that will resolve with the result of the start call\r\n *\r\n */\r\nexport function start(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string\r\n): Promise<any> {\r\n // /iot/feed/{id}/start/\r\n // /iot/analytics/realtime/{id}/start/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"\",\r\n \"start\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"GET\").then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Gets the required request options for requests to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param method Indicate if \"GET\" or \"POST\"\r\n *\r\n * @returns generic request options used for various calls to velocity api\r\n *\r\n * @private\r\n */\r\nexport function _getRequestOpts(\r\n authentication: UserSession,\r\n method: string\r\n): RequestInit {\r\n return {\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n Authorization: \"token=\" + authentication.token\r\n },\r\n method\r\n };\r\n}\r\n\r\n/**\r\n * Generic fetch function for making calls to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param url The url from the velocity API to handle reading and writing\r\n * @param method The method for the request \"GET\" or \"POST\"\r\n * @param body The body for POST requests\r\n *\r\n * @returns a promise that will resolve with the result of the fetch call\r\n *\r\n * @private\r\n */\r\nexport function _fetch(\r\n authentication: UserSession,\r\n url: string,\r\n method: string, // GET or POST\r\n body?: any\r\n): Promise<any> {\r\n const requestOpts: any = _getRequestOpts(authentication, method);\r\n /* istanbul ignore else */\r\n if (body) {\r\n requestOpts.body = JSON.stringify(body);\r\n }\r\n return fetch(url, requestOpts).then(r => Promise.resolve(r.json()));\r\n}\r\n\r\n/**\r\n * Remove key properties if the dependency was removed due to having the \"IoTFeatureLayer\" typeKeyword\r\n * This function will update the input template.\r\n *\r\n * @param template The template that for the velocity item\r\n *\r\n */\r\nexport function cleanDataSourcesAndFeeds(\r\n template: IItemTemplate,\r\n velocityUrl: string\r\n): void {\r\n const dependencies: string[] = template.dependencies;\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(d => _removeIdProps(d, dependencies, velocityUrl));\r\n\r\n [\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(outputs => _removeIdPropsAndSetName(outputs, dependencies));\r\n}\r\n\r\n/**\r\n * Remove key properties from the input source or feed\r\n *\r\n * @param sourcesOrFeeds The list of dataSources or feeds\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdProps(\r\n sourcesOrFeeds: any[],\r\n dependencies: string[],\r\n velocityUrl: string\r\n): void {\r\n sourcesOrFeeds.forEach(dataSource => {\r\n const idProp: string = \"feature-layer.portalItemId\";\r\n const layerIdProp: string = \"feature-layer.layerId\"\r\n /* istanbul ignore else */\r\n if (dataSource.properties) {\r\n /* istanbul ignore else */\r\n if (dataSource.properties[idProp]) {\r\n const id: string = dataSource.properties[idProp];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete dataSource.properties[idProp];\r\n delete dataSource.properties[layerIdProp];\r\n }\r\n }\r\n\r\n const urlProp: string = \"simulator.url\";\r\n const url: any = dataSource.properties[urlProp];\r\n // only remove velocity based simulator urls\r\n // otherwise we will leave as is with no templatization\r\n /* istanbul ignore else */\r\n if (url && url.indexOf(velocityUrl) > -1) {\r\n delete dataSource.properties[urlProp]\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Remove key properties from the outputs.\r\n *\r\n * @param outputs The list of outputs\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdPropsAndSetName(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.forEach(output => {\r\n /* istanbul ignore else */\r\n if (output.properties) {\r\n const names: string[] = getProp(output, \"name\") ? [output.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => _removeProp(output.properties, n + p, dependencies));\r\n });\r\n\r\n _updateName(output.properties);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Generic helper function to remove key properties .\r\n *\r\n * @param props the list of props to update\r\n * @param prop the individual prop to remove\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeProp(\r\n props: any,\r\n prop: string,\r\n dependencies: string[]\r\n): void {\r\n const id: string = props[prop];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete props[prop];\r\n }\r\n}\r\n\r\n/**\r\n * Update the feature layer name to include the solution item id.\r\n *\r\n * @param props the list of props to update\r\n *\r\n * @private\r\n */\r\nexport function _updateName(props: any): void {\r\n [\r\n \"feat-lyr-new.name\",\r\n \"stream-lyr-new.name\",\r\n \"feat-lyr-existing.name\"\r\n ].forEach(n => {\r\n const name: string = props[n];\r\n /* istanbul ignore else */\r\n if (name && name.indexOf(\"{{solutionItemId}}\") < 0) {\r\n props[n] = `${name}_{{solutionItemId}}`;\r\n }\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of velocity item types.\r\n *\r\n * @module velocity\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemProgressCallback,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n generateEmptyCreationResponse,\r\n createInitializedItemTemplate,\r\n fail,\r\n removeItem,\r\n updateVelocityReferences,\r\n updateItem\r\n} from \"@esri/solution-common\";\r\nimport { templatizeVelocity } from \"./helpers/velocity-templatize\";\r\nimport { getVelocityDependencies } from \"./helpers/get-velocity-dependencies\";\r\nimport {\r\n cleanDataSourcesAndFeeds,\r\n getVelocityUrl,\r\n postVelocityData\r\n} from \"./helpers/velocity-helpers\";\r\nimport {\r\n moveItem\r\n} from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Convert a Velocity item into a Template\r\n *\r\n * @param solutionItemId The solution to contain the item\r\n * @param itemInfo The basic item info\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n *\r\n * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo\r\n *\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n const template = createInitializedItemTemplate(itemInfo);\r\n return getVelocityUrl(\r\n srcAuthentication,\r\n templateDictionary,\r\n itemInfo.type,\r\n itemInfo.id\r\n ).then(\r\n (url: string) => {\r\n if (url) {\r\n return fetch(url)\r\n .then(data => data.json())\r\n .then(data_json => {\r\n template.item.title = data_json.label;\r\n template.data = data_json;\r\n return getVelocityDependencies(template, srcAuthentication).then(\r\n deps => {\r\n template.dependencies = deps;\r\n cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);\r\n templatizeVelocity(template);\r\n template.item = updateVelocityReferences(template.item, template.type, templateDictionary);\r\n return Promise.resolve(template);\r\n }\r\n );\r\n });\r\n } else {\r\n // In case the org used to have velocity and they still have items\r\n return Promise.reject(\"Velocity NOT Supported by Organization\");\r\n }\r\n },\r\n e => Promise.reject(fail(e))\r\n );\r\n}\r\n\r\n/**\r\n * Create Velocity analytics and feeds from a Template\r\n *\r\n * @param template The template for the volocity items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param destinationAuthentication Credentials for the deployment requests\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n *\r\n * @returns a promise that will resolve with the new item info, id, type, and postProcess flag\r\n *\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // let the progress system know we've started...\r\n const startStatus = itemProgressCallback(\r\n template.itemId,\r\n EItemProgressStatus.Started,\r\n 0\r\n );\r\n\r\n // and if it returned false, just resolve out\r\n /* istanbul ignore else */\r\n if (!startStatus) {\r\n return Promise.resolve(generateEmptyCreationResponse(template.type));\r\n }\r\n\r\n const orgId = template.itemId;\r\n\r\n return postVelocityData(\r\n destinationAuthentication,\r\n template,\r\n template.data,\r\n templateDictionary\r\n ).then(result => {\r\n const finalStatus = itemProgressCallback(\r\n orgId,\r\n EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor || 2,\r\n result.id\r\n );\r\n\r\n if (!finalStatus) {\r\n return removeItem(result.id, destinationAuthentication).then(\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type)),\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n const response: ICreateItemFromTemplateResponse = {\r\n item: {\r\n ...template,\r\n ...result\r\n },\r\n id: result.item.id,\r\n type: template.type,\r\n postProcess: true\r\n };\r\n response.item.itemId = result.item.id;\r\n return response;\r\n }\r\n });\r\n}\r\n\r\n\r\n/**\r\n * Velocity post-processing actions\r\n * \r\n * Move all velocity items to the deployment folder.\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {IItemTemplate} template The item template\r\n * @param {IItemTemplate[]} templates The full collection of item templates\r\n * @param {any} templateDictionary Hash of facts such as the folder id for the deployment\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\n export function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const itemUpdate = itemInfos.filter(ii => ii.id === itemId);\r\n const item: any = itemUpdate[0].item.item;\r\n delete item.url;\r\n delete item.origUrl;\r\n return updateItem(item, authentication).then(() => {\r\n return moveItem({\r\n owner: authentication.username,\r\n itemId,\r\n folderId: templateDictionary.folderId,\r\n authentication\r\n });\r\n });\r\n}\r\n"],"names":["_templatize","template","prop","fn","obj","getProp","setProp","_templatizeFeeds","feeds","map","feed","label","id","_templatizeFeed","properties","hasOwnProperty","flId","_templatizeDatasources","dataSources","ds","getVelocityDependencies","authentication","dependencies","data","forEach","f","reduce","prev","cur","undefined","indexOf","push","_getDependencies","_getFeedDependencies","sources","source","outputs","output","d","defs","getItemBase","Promise","all","then","itemInfos","resolve","typeKeywords","_validateDependencies","name","BASE_NAMES","n","PROP_NAMES","p","getVelocityUrl","templateDictionary","type","isDeploy","urlPrefix","urlSuffix","getVelocityUrlBase","url","_type","toLowerCase","suffix","prefix","token","postVelocityData","autoStart","_fetch","items","titles","Array","isArray","item","title","getUniqueTitle","t","getTitle","titleInfo","body","replaceInTemplate","dataOutputs","o","_validateOutputs","updatedBody","rr","itemId","finalResult","postProcess","validate","validateResult","executable","result","start","_validateAndStart","reject","fail","length","validateResults","names","messages","nodes","node","concat","message","key","args","_validateMessages","dataOutput","update","_getOutputLabel","_outputs","_dataOutput","nameProp","Object","keys","_updateDataOutput","_updateFeed","path","trim","newTitle","i","replace","method","requestOpts","headers","Accept","Authorization","_getRequestOpts","JSON","stringify","fetch","r","json","cleanDataSourcesAndFeeds","velocityUrl","sourcesOrFeeds","dataSource","idProp","layerIdProp","urlProp","_removeIdProps","props","_removeProp","_removeIdPropsAndSetName","solutionItemId","itemInfo","destAuthentication","srcAuthentication","createInitializedItemTemplate","data_json","deps","templatizeVelocity","updateVelocityReferences","e","destinationAuthentication","itemProgressCallback","EItemProgressStatus","Started","generateEmptyCreationResponse","orgId","Finished","estimatedDeploymentCostFactor","response","removeItem","templates","filter","ii","origUrl","updateItem","moveItem","owner","username","folderId"],"mappings":";;;;;;;;;;;;;;;;;2aA6CgBA,EACdC,EACAC,EACAC,GAEA,MAAMC,EAAWC,EAAAA,QAAQJ,EAAUC,GAE/BE,GACFE,EAAAA,QAAQL,EAAUC,EAAMC,EAAGC,IAczB,SAAUG,EAAiBC,GAC/B,OAAOA,EAAMC,KAAKC,IAChBA,EAAKC,MAAQD,EAAKC,OAASD,EAAKE,GAAK,KAAKF,EAAKE,aAAeF,EAAKC,MACnED,EAAKE,GAAKF,EAAKE,GAAK,KAAKF,EAAKE,cAAgBF,EAAKE,GAC5CF,KAaL,SAAUG,EAAgBH,GAC9B,IAAIE,EAAKP,EAAAA,QAAQK,EAAM,yCAEvB,GAAIA,EAAKI,aAEHJ,EAAKI,WAAW,gCAClBF,EAAKF,EAAKI,WAAW,8BACrBJ,EAAKI,WAAW,8BAAgC,KAAKF,cAGnDA,GAAMF,EAAKI,WAAWC,eAAe,0BAA0B,CACjE,MAAMC,EAAON,EAAKI,WAAW,yBAC7BJ,EAAKI,WACH,yBACE,KAAKF,UAAWI,cAGxB,OAAON,EAaH,SAAUO,EAAuBC,GACrC,OAAOA,EAAYT,KAAKU,GAAYN,EAAgBM,KCjFtC,SAAAC,EACdnB,EACAoB,GAEA,MAAMC,EAAyB,GAc/B,MAZA,CACEjB,EAAOA,QAACJ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,GAChEb,QAAQI,QAAQ5C,SAMxBwC,QAAQsD,OAAO,4CAG1B2D,GAAKjH,QAAQsD,OAAOC,EAAAA,KAAK0D,8BAevB,SACJzJ,EACAqD,EACAqG,EACAC,GAWA,IARoBA,EAClB3J,EAASqF,OACTuE,sBAAoBC,QACpB,GAMA,OAAOrH,QAAQI,QAAQkH,EAAAA,8BAA8B9J,EAASsD,OAGhE,MAAMyG,EAAQ/J,EAASqF,OAEvB,OAAOpB,EACLyF,EACA1J,EACAA,EAASsB,KACT+B,GACAX,MAAKiD,IAQL,GAPoBgE,EAClBI,EACAH,sBAAoBI,SACpBhK,EAASiK,+BAAiC,EAC1CtE,EAAOhF,IAQF,CACL,MAAMuJ,EAA4C,CAChD1F,KAAM,IACDxE,KACA2F,GAELhF,GAAIgF,EAAOnB,KAAK7D,GAChB2C,KAAMtD,EAASsD,KACfiC,aAAa,GAGf,OADA2E,EAAS1F,KAAKa,OAASM,EAAOnB,KAAK7D,GAC5BuJ,EAfP,OAAOC,EAAUA,WAACxE,EAAOhF,GAAI+I,GAA2BhH,MACtD,IAAMF,QAAQI,QAAQkH,EAA6BA,8BAAC9J,EAASsD,SAC7D,IAAMd,QAAQI,QAAQkH,EAAAA,8BAA8B9J,EAASsD,yBAiCpD,SACf+B,EACA/B,EACAX,EACA3C,EACAoK,EACA/G,EACAjC,GAEA,MACMoD,EADa7B,EAAU0H,QAAOC,GAAMA,EAAG3J,KAAO0E,IACvB,GAAGb,KAAKA,KAGpC,cAFMA,EAAKb,WACLa,EAAK+F,QACJC,EAAUA,WAAChG,EAAMpD,GAAgBsB,MAAK,IACpC+H,WAAS,CACdC,MAAOtJ,EAAeuJ,SACtBtF,OAAAA,EACAuF,SAAUvH,EAAmBuH,SAC7BxJ,eAAAA"}
1
+ {"version":3,"file":"velocity.umd.min.js","sources":["../../src/helpers/velocity-templatize.ts","../../src/helpers/get-velocity-dependencies.ts","../../src/helpers/velocity-helpers.ts","../../src/velocity-processor.ts"],"sourcesContent":["/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { IItemTemplate, getProp, setProp } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Updates the template by adding variables for key properties that will\r\n * need to be swapped when deploying\r\n *\r\n * @param template velocity item info that should be templatized\r\n *\r\n * @returns void\r\n *\r\n */\r\nexport function templatizeVelocity(template: IItemTemplate): void {\r\n _templatize(template, \"data.sources\", _templatizeDatasources);\r\n _templatize(template, \"data.feeds\", _templatizeFeeds);\r\n _templatize(template, \"data.feed\", _templatizeFeed);\r\n}\r\n\r\n/**\r\n * Generic wrapper for the templatize functions that\r\n * will get and set the key properties\r\n *\r\n * @param template velocity item info that should be templatized\r\n * @param prop the prop path to evaluate and set with a templatized variable\r\n * @param fn the templatize function that should be called for this prop\r\n *\r\n * @returns void\r\n *\r\n * @private\r\n */\r\nexport function _templatize(\r\n template: IItemTemplate,\r\n prop: string,\r\n fn: (arg: any) => void\r\n): void {\r\n const obj: any = getProp(template, prop);\r\n /* istanbul ignore else */\r\n if (obj) {\r\n setProp(template, prop, fn(obj));\r\n }\r\n}\r\n\r\n/**\r\n * Updates the template by adding variables for the itemId and the label\r\n * The label controls the name and must be unique for the org.\r\n *\r\n * @param feeds array of velocity feeds that should be templatized\r\n *\r\n * @returns The updated list of feed objects with templatized id and label\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeeds(feeds: any[]): any {\r\n return feeds.map((feed: any) => {\r\n feed.label = feed.label && feed.id ? `{{${feed.id}.label}}` : feed.label;\r\n feed.id = feed.id ? `{{${feed.id}.itemId}}` : feed.id;\r\n return feed;\r\n });\r\n}\r\n\r\n/**\r\n * Updates the portal item id and feature layer id variables for the feed properties.\r\n *\r\n * @param feed the feed object from the item\r\n *\r\n * @returns the updated feed object with templatized portalItemId and layer id\r\n *\r\n * @private\r\n */\r\nexport function _templatizeFeed(feed: any): any {\r\n let id = getProp(feed, \"properties.feature-layer.portalItemId\");\r\n /* istanbul ignore else */\r\n if (feed.properties) {\r\n /* istanbul ignore else */\r\n if (feed.properties[\"feature-layer.portalItemId\"]) {\r\n id = feed.properties[\"feature-layer.portalItemId\"];\r\n feed.properties[\"feature-layer.portalItemId\"] = `{{${id}.itemId}}`;\r\n }\r\n /* istanbul ignore else */\r\n if (id && feed.properties.hasOwnProperty(\"feature-layer.layerId\")) {\r\n const flId = feed.properties[\"feature-layer.layerId\"];\r\n feed.properties[\r\n \"feature-layer.layerId\"\r\n ] = `{{${id}.layer${flId}.layerId}}`;\r\n }\r\n }\r\n return feed;\r\n}\r\n\r\n/**\r\n * Velocity datasources share the same props as feeds so they can leverage\r\n * the same templatize function\r\n *\r\n * @param dataSources array of data sources from the item\r\n *\r\n * @returns the updated dataSources object with templatized ids and labels\r\n *\r\n * @private\r\n */\r\nexport function _templatizeDatasources(dataSources: any[]): any {\r\n return dataSources.map((ds: any) => _templatizeFeed(ds));\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n getProp,\r\n getItemBase,\r\n IItemTemplate,\r\n UserSession,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Get the dependencies from the velocity data sources, feeds, and outputs.\r\n * Only dependencies that do NOT have the typeKeyword \"IoTFeatureLayer\" are returned.\r\n *\r\n * @param template The template that for the velocity item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n */\r\nexport function getVelocityDependencies(\r\n template: IItemTemplate,\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const dependencies: string[] = [];\r\n\r\n [\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(f => _getFeedDependencies(f, dependencies));\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(d => _getDependencies(d, dependencies));\r\n\r\n return _validateDependencies(dependencies, authentication);\r\n}\r\n\r\n/**\r\n * Any feature services with the typeKeyword \"IoTFeatureLayer\" should not be templatized or\r\n * listed as a dependency.\r\n * We can’t create Velocity feature layers in their spatiotemporal datastore as we have no api.\r\n *\r\n * @param dependencies Any dependencies that have been found for this item\r\n * @param authentication The credentials for any requests\r\n *\r\n * @returns a list of dependency ids\r\n * @private\r\n */\r\nexport function _validateDependencies(\r\n dependencies: string[],\r\n authentication: UserSession\r\n): Promise<string[]> {\r\n const defs: Array<Promise<any>> = dependencies.map(d => {\r\n return getItemBase(d, authentication);\r\n });\r\n return Promise.all(defs).then(itemInfos => {\r\n return Promise.resolve(\r\n itemInfos.reduce((prev, cur) => {\r\n if (cur.typeKeywords.indexOf(\"IoTFeatureLayer\") < 0) {\r\n prev.push(cur.id);\r\n }\r\n return prev;\r\n }, [])\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity feeds\r\n * This function will update the input dependencies argument\r\n *\r\n * @param feeds The list of feeds from the velocity template\r\n * @param dependencies The current list of dependencies\r\n * @private\r\n */\r\nexport function _getFeedDependencies(\r\n feeds: any[],\r\n dependencies: string[]\r\n): void {\r\n feeds.reduce((prev: any, cur: any) => {\r\n const id: string = cur.id || undefined;\r\n /* istanbul ignore else */\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n return prev;\r\n }, dependencies);\r\n // run through standard dependency check as well\r\n // in some cases the feed does not have the id property but will have\r\n // a portalItemId value in the properties\r\n _getDependencies(feeds, dependencies);\r\n}\r\n\r\n/**\r\n * Get the dependencies from the velocity outputs or dataSources.\r\n * This function will update the input dependencies argument\r\n *\r\n * @param outputs The list of outputs from the velocity item\r\n * @param dependencies The current list of dependencies\r\n * @param prop The individual prop to evaluate\r\n * @private\r\n */\r\nexport function _getDependencies(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.reduce((prev: any, cur: any) => {\r\n const names: string[] = getProp(cur, \"name\") ? [cur.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => {\r\n // skip map service and stream service ids\r\n /* istanbul ignore else */\r\n if (p.indexOf(\"mapServicePortalItemID\") < 0 && p.indexOf(\"streamServicePortalItemID\") < 0) {\r\n const id: string = cur.properties ? cur.properties[n + p] : undefined;\r\n if (id && prev.indexOf(id) < 0) {\r\n prev.push(id);\r\n }\r\n }\r\n });\r\n });\r\n return prev;\r\n }, dependencies);\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n IVelocityTitle,\r\n getVelocityUrlBase,\r\n replaceInTemplate,\r\n UserSession,\r\n getProp,\r\n fail,\r\n BASE_NAMES,\r\n PROP_NAMES\r\n} from \"@esri/solution-common\";\r\n\r\n/**\r\n * Common function to build urls for reading and interacting with the velocity api\r\n *\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id Optional The id of the velocity item we are constructing a url for\r\n * @param isDeploy Optional Is this being constructed as a part of deployment\r\n * @param urlPrefix Optional prefix args necessary for some url construction\r\n * @param urlSuffix Optional suffix args necessary for some url construction\r\n *\r\n * @returns a promise that will resolve the constructed url\r\n *\r\n */\r\nexport function getVelocityUrl(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id: string = \"\",\r\n isDeploy: boolean = false,\r\n urlPrefix: string = \"\",\r\n urlSuffix: string = \"\"\r\n): Promise<string> {\r\n return getVelocityUrlBase(authentication, templateDictionary).then(url => {\r\n if (url) {\r\n const _type: string =\r\n type === \"Real Time Analytic\"\r\n ? \"analytics/realtime\"\r\n : type === \"Big Data Analytic\"\r\n ? \"analytics/bigdata\"\r\n : type.toLowerCase();\r\n\r\n const suffix: string = urlSuffix ? `/${urlSuffix}` : \"\";\r\n const prefix: string = urlPrefix ? `/${urlPrefix}` : \"\";\r\n\r\n return Promise.resolve(\r\n isDeploy\r\n ? `${url}/iot/${_type}${prefix}${suffix}`\r\n : id\r\n ? `${url}/iot/${_type}${prefix}/${id}${suffix}/?f=json&token=${authentication.token}`\r\n : `${url}/iot/${_type}${prefix}${suffix}/?f=json&token=${authentication.token}`\r\n );\r\n } else {\r\n return Promise.resolve(url);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handles the creation of velocity items.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param template The current itemTemplate that is being used for deployment\r\n * @param data The velocity item data used to create the items.\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param autoStart This can be leveraged to start certain velocity items after they are created.\r\n *\r\n * @returns a promise that will resolve an object containing the item, id, type, and post process flag\r\n *\r\n */\r\nexport function postVelocityData(\r\n authentication: UserSession,\r\n template: IItemTemplate,\r\n data: any,\r\n templateDictionary: any,\r\n autoStart: boolean = false\r\n): Promise<any> {\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n undefined,\r\n true\r\n ).then(url => {\r\n if (url) {\r\n return getTitle(authentication, data.label, url).then((titleInfo: IVelocityTitle) => {\r\n const titles: any[] = titleInfo.titles;\r\n data.label = titleInfo.label;\r\n data.id = \"\";\r\n const body: any = replaceInTemplate(data, templateDictionary);\r\n\r\n const dataOutputs: any[] = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((o: any) => {\r\n return {\r\n id: o.id,\r\n name: o.properties[`${o.name}.name`]\r\n };\r\n });\r\n\r\n const feeds = (body.feeds ? body.feeds : body.feed ? [body.feed] : []).map((o:any) => {\r\n return {\r\n id: o.id ? o.id : o.properties[`${o.name}.portalItemId`] || \"\",\r\n name: o.label ? o.label : data.label\r\n };\r\n });\r\n\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n template.type,\r\n body,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n ).then(updatedBody => {\r\n return _fetch(authentication, url, \"POST\", updatedBody).then(rr => {\r\n template.item.url = `${url}/${rr.id}`;\r\n template.item.title = data.label;\r\n\r\n // Update the template dictionary\r\n templateDictionary[template.itemId][\"url\"] = template.item.url;\r\n templateDictionary[template.itemId][\"label\"] = data.label;\r\n templateDictionary[template.itemId][\"itemId\"] = rr.id;\r\n\r\n const finalResult = {\r\n item: replaceInTemplate(template.item, templateDictionary),\r\n id: rr.id,\r\n type: template.type,\r\n postProcess: false\r\n };\r\n\r\n if (autoStart) {\r\n return _validateAndStart(\r\n authentication,\r\n templateDictionary,\r\n template,\r\n rr.id\r\n ).then(() => {\r\n return Promise.resolve(finalResult);\r\n });\r\n } else {\r\n return Promise.resolve(finalResult);\r\n }\r\n });\r\n });\r\n });\r\n } else {\r\n return Promise.reject(fail(\"Velocity NOT Supported by Organization\"));\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Velocity item titles must be unique across the organization.\r\n * Check and ensure we set a unique title\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param label The current label of the item from the solution template\r\n * @param url The base velocity url for checking status\r\n *\r\n * @returns a promise that will resolve a unique title\r\n *\r\n */\r\nexport function getTitle(\r\n authentication: UserSession,\r\n label: string,\r\n url: string\r\n): Promise<IVelocityTitle> {\r\n return _fetch(authentication, `${url}StatusList?view=admin`, \"GET\").then(\r\n items => {\r\n const titles: any[] =\r\n items && Array.isArray(items)\r\n ? items.map(item => {\r\n return { title: item.label };\r\n })\r\n : [];\r\n return Promise.resolve({label: getUniqueTitle(label, { titles }, \"titles\"), titles: titles.map(t => t.title)});\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the data that will be used and handle any reported issues with the outputs.\r\n * The output names must be unique across the organization.\r\n *\r\n * This function will update the data arg that is passed in with a unique name.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item\r\n * @param data The data used to construct the velocity item\r\n * @param titles The list of know titles that exist in the org\r\n * @param dataOutputs The velocity items output objects\r\n * @param feeds The velocity items feed objects\r\n *\r\n * @returns a promise that will resolve the data object passed in with any necessary changes.\r\n *\r\n * @private\r\n */\r\nexport function _validateOutputs(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n data: any,\r\n titles: any[],\r\n dataOutputs: any[] = [],\r\n feeds: any[] = []\r\n): Promise<any> {\r\n if (dataOutputs.length > 0 || feeds.length > 0) {\r\n return validate(authentication, templateDictionary, type, \"\", data).then(\r\n (validateResults: any) => {\r\n const names: string[] = _validateMessages(validateResults);\r\n if (names.length > 0) {\r\n /* istanbul ignore else */\r\n if (dataOutputs.length > 0) {\r\n _updateDataOutput(dataOutputs, data, names);\r\n }\r\n /* istanbul ignore else */\r\n if (feeds.length > 0) {\r\n _updateFeed(feeds, data, names.concat(titles));\r\n }\r\n return _validateOutputs(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n data,\r\n titles,\r\n dataOutputs,\r\n feeds\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n }\r\n );\r\n } else {\r\n return Promise.resolve(data);\r\n }\r\n}\r\n\r\n/**\r\n * Check the validate results for any name conflicts and store the conflicting names.\r\n *\r\n * @param validateResults The results object to check for name conflict errors\r\n *\r\n * @returns a list of names that already exist in the org\r\n *\r\n * @private\r\n */\r\nexport function _validateMessages(\r\n validateResults: any\r\n): string[] {\r\n let messages: any[] = getProp(validateResults, \"validation.messages\");\r\n\r\n const nodes: any[] = getProp(validateResults, \"nodes\");\r\n /* istanbul ignore else */\r\n if (nodes && Array.isArray(nodes)) {\r\n nodes.forEach(node => {\r\n messages = messages.concat(\r\n getProp(node, \"validation.messages\") || []\r\n );\r\n });\r\n }\r\n\r\n let names: string[] = [];\r\n /* istanbul ignore else */\r\n if (messages && Array.isArray(messages)) {\r\n messages.forEach(message => {\r\n // I don't see a way to ask for all output names that exist\r\n // velocityUrl + /outputs/ just gives you generic defaults not what currently exists\r\n const nameErrors = [\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_FEATURE_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"VALIDATION_ANALYTICS__MULTIPLE_CREATE_STREAM_LAYER_OUTPUTS_REFERENCE_SAME_LAYER_NAME\",\r\n \"ITEM_MANAGER__CREATE_ANALYTIC_FAILED_DUPLICATE_OUTPUT_NAMES_IN_ORGANIZATION_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_BIG_DATA_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_REAL_TIME_ANALYTIC_FAILED_DUPLICATE_NAMES_NOT_ALLOWED\",\r\n \"ITEM_MANAGER__CREATE_FEED_FAILED_DUPLICATE_NAME\"\r\n ];\r\n // The names returned here seem to replace \" \" with \"_\" so they do not match exactly\r\n /* istanbul ignore else */\r\n if (nameErrors.indexOf(message.key) > -1) {\r\n names = names.concat(message.args);\r\n }\r\n });\r\n }\r\n return names;\r\n}\r\n\r\n/**\r\n * Updates the feed object with a new name when validation fails.\r\n *\r\n * @param feeds The feed objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateFeed(\r\n feeds: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n feeds.forEach(f => {\r\n const update = _getOutputLabel(names, f);\r\n /* istanbul ignore else */\r\n if (update) {\r\n data.label = update.label;\r\n f.name = update.label;\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Updates the data object with a new name when validation fails.\r\n *\r\n * @param dataOutputs The data output objects from the velocity item.\r\n * @param data The full data object used for deploying the velocity item.\r\n * @param names The names that failed due to duplicate error in validation.\r\n *\r\n * @private\r\n */\r\nexport function _updateDataOutput(\r\n dataOutputs: any[],\r\n data: any,\r\n names: string[]\r\n): void {\r\n dataOutputs.forEach(dataOutput => {\r\n const update = _getOutputLabel(names, dataOutput);\r\n /* istanbul ignore else */\r\n if (update) {\r\n const _outputs = (data.outputs ? data.outputs : data.output ? [data.output] : []).map((_dataOutput: any) => {\r\n /* istanbul ignore else */\r\n if (_dataOutput.id === update.id) {\r\n /* istanbul ignore else */\r\n if (_dataOutput.properties) {\r\n const nameProp: string = `${_dataOutput.name}.name`;\r\n /* istanbul ignore else */\r\n if (Object.keys(_dataOutput.properties).indexOf(nameProp) > -1) {\r\n _dataOutput.properties[nameProp] = update.label;\r\n }\r\n }\r\n }\r\n return _dataOutput;\r\n });\r\n /* istanbul ignore else */\r\n if (data.outputs) {\r\n data.outputs = _outputs;\r\n }\r\n /* istanbul ignore else */\r\n if (data.output) {\r\n data.output = _outputs[0];\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Get a unique label for the item.\r\n *\r\n * @param names The names that failed due to duplicate error in validation.\r\n * @param dataOutput The current data output that is being evaluated.\r\n *\r\n * @returns an object with a unique label and the outputs id when a name\r\n * conflict is found...otherwise returns undefined\r\n *\r\n * @private\r\n */\r\nexport function _getOutputLabel(names: any[], dataOutput: any): any {\r\n const titles: any[] = names.map((name: any) => {\r\n return { title: name };\r\n });\r\n\r\n const label = getUniqueTitle(dataOutput.name, { titles }, \"titles\");\r\n\r\n return label !== dataOutput.name\r\n ? {\r\n label,\r\n id: dataOutput.id\r\n }\r\n : undefined;\r\n}\r\n\r\n/**\r\n * Will return the provided title if it does not exist as a property\r\n * in one of the objects at the defined path. Otherwise the title will\r\n * have a numerical value attached.\r\n *\r\n * This is based on \"getUniqueTitle\" from common but adds the \"_\" replacement check for velocity names.\r\n * Could switch to using common if Velocity has a way to get a list of all names that are already used.\r\n *\r\n * @param title The root title to test\r\n * @param templateDictionary Hash of the facts\r\n * @param path to the objects to evaluate for potantial name clashes\r\n *\r\n * @returns string The unique title to use\r\n *\r\n */\r\nexport function getUniqueTitle(\r\n title: string,\r\n templateDictionary: any,\r\n path: string\r\n): string {\r\n title = title ? title.trim() : \"_\";\r\n const objs: any[] = getProp(templateDictionary, path) || [];\r\n const titles: string[] = objs.map(obj => {\r\n return obj.title;\r\n });\r\n let newTitle: string = title;\r\n let i: number = 0;\r\n // replace added for velocitcy\r\n // validation seems to add \"_\" to names listed in outputs..so no way to compare without hacking the name\r\n while (\r\n titles.indexOf(newTitle) > -1 ||\r\n titles.indexOf(newTitle.replace(/ /g, \"_\")) > -1\r\n ) {\r\n i++;\r\n newTitle = title + \" \" + i;\r\n }\r\n return newTitle;\r\n}\r\n\r\n/**\r\n * Start the item if validation passes and the item is executable.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param template the item template that has the details for deployment\r\n * @param id the new id for the velocity item that was deployed\r\n *\r\n * @returns a promise that will resolve with the validation results\r\n * or the start results when validation indicates the item is executable\r\n *\r\n * @private\r\n */\r\nexport function _validateAndStart(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n template: IItemTemplate,\r\n id: string\r\n): Promise<any> {\r\n return validate(authentication, templateDictionary, template.type, id).then(\r\n validateResult => {\r\n if (validateResult.executable) {\r\n return start(authentication, templateDictionary, template.type, id);\r\n } else {\r\n return Promise.resolve(validateResult);\r\n }\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Validate the velocity item.\r\n * Used to help find and handle duplicate name errors.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n * @param body? Optional the request body to validate.\r\n *\r\n * @returns a promise that will resolve with an object containing messages\r\n * indicating any issues found when validating such as name conflict errors\r\n *\r\n */\r\nexport function validate(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string,\r\n body?: any\r\n): Promise<any> {\r\n // /iot/feed/validate/{id}/\r\n // /iot/analytics/realtime/validate/{id}/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"validate\",\r\n \"\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"POST\", body).then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Start the given velocity item that has been deployed.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param type The type of velocity item we are constructing a url for\r\n * @param id? Optional The id of the velocity item we are constructing a url for\r\n *\r\n * @returns a promise that will resolve with the result of the start call\r\n *\r\n */\r\nexport function start(\r\n authentication: UserSession,\r\n templateDictionary: any,\r\n type: string,\r\n id?: string\r\n): Promise<any> {\r\n // /iot/feed/{id}/start/\r\n // /iot/analytics/realtime/{id}/start/\r\n return getVelocityUrl(\r\n authentication,\r\n templateDictionary,\r\n type,\r\n id,\r\n false,\r\n \"\",\r\n \"start\"\r\n ).then(url => {\r\n return _fetch(authentication, url, \"GET\").then(result => {\r\n return Promise.resolve(result);\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Gets the required request options for requests to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param method Indicate if \"GET\" or \"POST\"\r\n *\r\n * @returns generic request options used for various calls to velocity api\r\n *\r\n * @private\r\n */\r\nexport function _getRequestOpts(\r\n authentication: UserSession,\r\n method: string\r\n): RequestInit {\r\n return {\r\n headers: {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n Authorization: \"token=\" + authentication.token\r\n },\r\n method\r\n };\r\n}\r\n\r\n/**\r\n * Generic fetch function for making calls to the velocity API.\r\n *\r\n * @param authentication Credentials for the requests\r\n * @param url The url from the velocity API to handle reading and writing\r\n * @param method The method for the request \"GET\" or \"POST\"\r\n * @param body The body for POST requests\r\n *\r\n * @returns a promise that will resolve with the result of the fetch call\r\n *\r\n * @private\r\n */\r\nexport function _fetch(\r\n authentication: UserSession,\r\n url: string,\r\n method: string, // GET or POST\r\n body?: any\r\n): Promise<any> {\r\n const requestOpts: any = _getRequestOpts(authentication, method);\r\n /* istanbul ignore else */\r\n if (body) {\r\n requestOpts.body = JSON.stringify(body);\r\n }\r\n return fetch(url, requestOpts).then(r => Promise.resolve(r.json()));\r\n}\r\n\r\n/**\r\n * Remove key properties if the dependency was removed due to having the \"IoTFeatureLayer\" typeKeyword\r\n * This function will update the input template.\r\n *\r\n * @param template The template that for the velocity item\r\n *\r\n */\r\nexport function cleanDataSourcesAndFeeds(\r\n template: IItemTemplate,\r\n velocityUrl: string\r\n): void {\r\n const dependencies: string[] = template.dependencies;\r\n\r\n [\r\n getProp(template, \"data.sources\") ? template.data.sources : [],\r\n getProp(template, \"data.source\") ? [template.data.source] : [],\r\n getProp(template, \"data.feeds\") ? template.data.feeds : [],\r\n getProp(template, \"data.feed\") ? [template.data.feed] : []\r\n ].forEach(d => _removeIdProps(d, dependencies, velocityUrl));\r\n\r\n [\r\n getProp(template, \"data.outputs\") ? template.data.outputs : [],\r\n getProp(template, \"data.output\") ? [template.data.output] : []\r\n ].forEach(outputs => _removeIdPropsAndSetName(outputs, dependencies));\r\n}\r\n\r\n/**\r\n * Remove key properties from the input source or feed\r\n *\r\n * @param sourcesOrFeeds The list of dataSources or feeds\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdProps(\r\n sourcesOrFeeds: any[],\r\n dependencies: string[],\r\n velocityUrl: string\r\n): void {\r\n sourcesOrFeeds.forEach(dataSource => {\r\n const idProp: string = \"feature-layer.portalItemId\";\r\n const layerIdProp: string = \"feature-layer.layerId\"\r\n /* istanbul ignore else */\r\n if (dataSource.properties) {\r\n /* istanbul ignore else */\r\n if (dataSource.properties[idProp]) {\r\n const id: string = dataSource.properties[idProp];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete dataSource.properties[idProp];\r\n delete dataSource.properties[layerIdProp];\r\n }\r\n }\r\n\r\n const urlProp: string = \"simulator.url\";\r\n const url: any = dataSource.properties[urlProp];\r\n // only remove velocity based simulator urls\r\n // otherwise we will leave as is with no templatization\r\n /* istanbul ignore else */\r\n if (url && url.indexOf(velocityUrl) > -1) {\r\n delete dataSource.properties[urlProp]\r\n }\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Remove key properties from the outputs.\r\n *\r\n * @param outputs The list of outputs\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeIdPropsAndSetName(\r\n outputs: any[],\r\n dependencies: string[]\r\n): void {\r\n outputs.forEach(output => {\r\n /* istanbul ignore else */\r\n if (output.properties) {\r\n const names: string[] = getProp(output, \"name\") ? [output.name] : BASE_NAMES;\r\n names.forEach(n => {\r\n PROP_NAMES.forEach(p => _removeProp(output.properties, n + p, dependencies));\r\n });\r\n\r\n _updateName(output.properties);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Generic helper function to remove key properties .\r\n *\r\n * @param props the list of props to update\r\n * @param prop the individual prop to remove\r\n * @param dependencies The list of dependencies\r\n *\r\n * @private\r\n */\r\nexport function _removeProp(\r\n props: any,\r\n prop: string,\r\n dependencies: string[]\r\n): void {\r\n const id: string = props[prop];\r\n /* istanbul ignore else */\r\n if (id && dependencies.indexOf(id) < 0) {\r\n delete props[prop];\r\n }\r\n}\r\n\r\n/**\r\n * Update the feature layer name to include the solution item id.\r\n *\r\n * @param props the list of props to update\r\n *\r\n * @private\r\n */\r\nexport function _updateName(props: any): void {\r\n [\r\n \"feat-lyr-new.name\",\r\n \"stream-lyr-new.name\",\r\n \"feat-lyr-existing.name\"\r\n ].forEach(n => {\r\n const name: string = props[n];\r\n /* istanbul ignore else */\r\n if (name && name.indexOf(\"{{solutionItemId}}\") < 0) {\r\n props[n] = `${name}_{{solutionItemId}}`;\r\n }\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2021 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of velocity item types.\r\n *\r\n * @module velocity\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemProgressCallback,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n generateEmptyCreationResponse,\r\n createInitializedItemTemplate,\r\n fail,\r\n removeItem,\r\n updateVelocityReferences,\r\n updateItem\r\n} from \"@esri/solution-common\";\r\nimport { templatizeVelocity } from \"./helpers/velocity-templatize\";\r\nimport { getVelocityDependencies } from \"./helpers/get-velocity-dependencies\";\r\nimport {\r\n cleanDataSourcesAndFeeds,\r\n getVelocityUrl,\r\n postVelocityData\r\n} from \"./helpers/velocity-helpers\";\r\nimport {\r\n moveItem\r\n} from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Convert a Velocity item into a Template\r\n *\r\n * @param solutionItemId The solution to contain the item\r\n * @param itemInfo The basic item info\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n *\r\n * @returns a promise that will resolve the constructed IItemTemplate from the input itemInfo\r\n *\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n const template = createInitializedItemTemplate(itemInfo);\r\n return getVelocityUrl(\r\n srcAuthentication,\r\n templateDictionary,\r\n itemInfo.type,\r\n itemInfo.id\r\n ).then(\r\n (url: string) => {\r\n if (url) {\r\n return fetch(url)\r\n .then(data => data.json())\r\n .then(data_json => {\r\n template.item.title = data_json.label;\r\n template.data = data_json;\r\n return getVelocityDependencies(template, srcAuthentication).then(\r\n deps => {\r\n template.dependencies = deps;\r\n cleanDataSourcesAndFeeds(template, templateDictionary.velocityUrl);\r\n templatizeVelocity(template);\r\n template.item = updateVelocityReferences(template.item, template.type, templateDictionary);\r\n return Promise.resolve(template);\r\n }\r\n );\r\n });\r\n } else {\r\n // In case the org used to have velocity and they still have items\r\n return Promise.reject(\"Velocity NOT Supported by Organization\");\r\n }\r\n },\r\n e => Promise.reject(fail(e))\r\n );\r\n}\r\n\r\n/**\r\n * Create Velocity analytics and feeds from a Template\r\n *\r\n * @param template The template for the volocity items\r\n * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @param destinationAuthentication Credentials for the deployment requests\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n *\r\n * @returns a promise that will resolve with the new item info, id, type, and postProcess flag\r\n *\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // let the progress system know we've started...\r\n const startStatus = itemProgressCallback(\r\n template.itemId,\r\n EItemProgressStatus.Started,\r\n 0\r\n );\r\n\r\n // and if it returned false, just resolve out\r\n /* istanbul ignore else */\r\n if (!startStatus) {\r\n return Promise.resolve(generateEmptyCreationResponse(template.type));\r\n }\r\n\r\n const orgId = template.itemId;\r\n\r\n return postVelocityData(\r\n destinationAuthentication,\r\n template,\r\n template.data,\r\n templateDictionary\r\n ).then(result => {\r\n const finalStatus = itemProgressCallback(\r\n orgId,\r\n EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor || 2,\r\n result.id\r\n );\r\n\r\n if (!finalStatus) {\r\n return removeItem(result.id, destinationAuthentication).then(\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type)),\r\n () => Promise.resolve(generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n const response: ICreateItemFromTemplateResponse = {\r\n item: {\r\n ...template,\r\n ...result\r\n },\r\n id: result.item.id,\r\n type: template.type,\r\n postProcess: true\r\n };\r\n response.item.itemId = result.item.id;\r\n return response;\r\n }\r\n });\r\n}\r\n\r\n\r\n/**\r\n * Velocity post-processing actions\r\n * \r\n * Move all velocity items to the deployment folder.\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {IItemTemplate} template The item template\r\n * @param {IItemTemplate[]} templates The full collection of item templates\r\n * @param {any} templateDictionary Hash of facts such as the folder id for the deployment\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\n export function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const itemUpdate = itemInfos.filter(ii => ii.id === itemId);\r\n const item: any = itemUpdate[0].item.item;\r\n delete item.url;\r\n delete item.origUrl;\r\n return updateItem(item, authentication).then(() => {\r\n return moveItem({\r\n owner: authentication.username,\r\n itemId,\r\n folderId: templateDictionary.folderId,\r\n authentication\r\n });\r\n });\r\n}\r\n"],"names":["_templatize","template","prop","fn","obj","getProp","setProp","_templatizeFeeds","feeds","map","feed","label","id","_templatizeFeed","properties","hasOwnProperty","flId","_templatizeDatasources","dataSources","ds","getVelocityDependencies","authentication","dependencies","data","forEach","f","reduce","prev","cur","undefined","indexOf","push","_getDependencies","_getFeedDependencies","sources","source","outputs","output","d","defs","getItemBase","Promise","all","then","itemInfos","resolve","typeKeywords","_validateDependencies","name","BASE_NAMES","n","PROP_NAMES","p","getVelocityUrl","templateDictionary","type","isDeploy","urlPrefix","urlSuffix","getVelocityUrlBase","url","_type","toLowerCase","suffix","prefix","token","postVelocityData","autoStart","_fetch","items","titles","Array","isArray","item","title","getUniqueTitle","t","getTitle","titleInfo","body","replaceInTemplate","dataOutputs","o","_validateOutputs","updatedBody","rr","itemId","finalResult","postProcess","validate","validateResult","executable","result","start","_validateAndStart","reject","fail","length","validateResults","names","messages","nodes","node","concat","message","key","args","_validateMessages","dataOutput","update","_getOutputLabel","_outputs","_dataOutput","nameProp","Object","keys","_updateDataOutput","_updateFeed","path","trim","newTitle","i","replace","method","requestOpts","headers","Accept","Authorization","_getRequestOpts","JSON","stringify","fetch","r","json","cleanDataSourcesAndFeeds","velocityUrl","sourcesOrFeeds","dataSource","idProp","layerIdProp","urlProp","_removeIdProps","props","_removeProp","_removeIdPropsAndSetName","solutionItemId","itemInfo","destAuthentication","srcAuthentication","createInitializedItemTemplate","data_json","deps","templatizeVelocity","updateVelocityReferences","e","destinationAuthentication","itemProgressCallback","EItemProgressStatus","Started","generateEmptyCreationResponse","orgId","Finished","estimatedDeploymentCostFactor","response","removeItem","templates","filter","ii","origUrl","updateItem","moveItem","owner","username","folderId"],"mappings":";;;;;;;;;;;;;;;;;2aA6CgBA,EACdC,EACAC,EACAC,GAEA,MAAMC,EAAWC,UAAQJ,EAAUC,GAE/BE,GACFE,UAAQL,EAAUC,EAAMC,EAAGC,aAcfG,EAAiBC,GAC/B,OAAOA,EAAMC,KAAKC,IAChBA,EAAKC,MAAQD,EAAKC,OAASD,EAAKE,GAAK,KAAKF,EAAKE,aAAeF,EAAKC,MACnED,EAAKE,GAAKF,EAAKE,GAAK,KAAKF,EAAKE,cAAgBF,EAAKE,GAC5CF,cAaKG,EAAgBH,GAC9B,IAAIE,EAAKP,UAAQK,EAAM,yCAEvB,GAAIA,EAAKI,aAEHJ,EAAKI,WAAW,gCAClBF,EAAKF,EAAKI,WAAW,8BACrBJ,EAAKI,WAAW,8BAAgC,KAAKF,cAGnDA,GAAMF,EAAKI,WAAWC,eAAe,0BAA0B,CACjE,MAAMC,EAAON,EAAKI,WAAW,yBAC7BJ,EAAKI,WACH,yBACE,KAAKF,UAAWI,cAGxB,OAAON,WAaOO,EAAuBC,GACrC,OAAOA,EAAYT,KAAKU,GAAYN,EAAgBM,cCjFtCC,EACdnB,EACAoB,GAEA,MAAMC,EAAyB,GAc/B,MAZA,CACEjB,UAAQJ,EAAU,cAAgBA,EAASsB,KAAKf,MAAQ,GACxDH,UAAQJ,EAAU,aAAe,CAACA,EAASsB,KAAKb,MAAQ,IACxDc,SAAQC,YAmDVjB,EACAc,GAEAd,EAAMkB,QAAO,CAACC,EAAWC,KACvB,MAAMhB,EAAagB,EAAIhB,SAAMiB,EAK7B,OAHIjB,GAAMe,EAAKG,QAAQlB,GAAM,GAC3Be,EAAKI,KAAKnB,GAELe,IACNL,GAIHU,EAAiBxB,EAAOc,GAjETW,CAAqBR,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,GAC5BuJ,EAfP,OAAOC,aAAWxE,EAAOhF,GAAI+I,GAA2BhH,MACtD,IAAMF,QAAQI,QAAQkH,gCAA8B9J,EAASsD,SAC7D,IAAMd,QAAQI,QAAQkH,gCAA8B9J,EAASsD,kCAkCnE+B,EACA/B,EACAX,EACA3C,EACAoK,EACA/G,EACAjC,GAEA,MACMoD,EADa7B,EAAU0H,QAAOC,GAAMA,EAAG3J,KAAO0E,IACvB,GAAGb,KAAKA,KAGpC,cAFMA,EAAKb,WACLa,EAAK+F,QACJC,aAAWhG,EAAMpD,GAAgBsB,MAAK,IACpC+H,WAAS,CACdC,MAAOtJ,EAAeuJ,SACtBtF,SACAuF,SAAUvH,EAAmBuH,SAC7BxJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-velocity",
3
- "version": "1.3.13",
3
+ "version": "1.3.16",
4
4
  "description": "Manages the creation and deployment of Velocity item types for @esri/solution.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "unpkg": "dist/umd/velocity.umd.min.js",
@@ -18,7 +18,7 @@
18
18
  "@esri/arcgis-rest-portal": "3.4.3",
19
19
  "@esri/arcgis-rest-request": "3.4.3",
20
20
  "@esri/arcgis-rest-service-admin": "3.4.3",
21
- "rollup": "2.70.2"
21
+ "rollup": "2.66.1"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@esri/arcgis-rest-auth": "3.4.3",
@@ -28,8 +28,8 @@
28
28
  "@esri/arcgis-rest-service-admin": "3.4.3"
29
29
  },
30
30
  "dependencies": {
31
- "@esri/solution-common": "^1.3.13",
32
- "@esri/solution-simple-types": "^1.3.13",
31
+ "@esri/solution-common": "^1.3.16",
32
+ "@esri/solution-simple-types": "^1.3.16",
33
33
  "tslib": "1.14.1"
34
34
  },
35
35
  "scripts": {
@@ -76,5 +76,5 @@
76
76
  "esri",
77
77
  "ES6"
78
78
  ],
79
- "gitHead": "ee404319048f8e0323933d69c4eb5bbf33c438ec"
79
+ "gitHead": "c87f04e58c80558f19a6d79086b69a965b17db93"
80
80
  }