@esri/solution-deployer 1.3.16 → 1.4.1

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-deployer - v1.3.16 - Apache-2.0
2
+ * @esri/solution-deployer - v1.4.1 - Apache-2.0
3
3
  * Copyright (c) 2018-2022 Esri, Inc.
4
- * Wed Jun 08 2022 11:10:55 GMT-0700 (Pacific Daylight Time)
4
+ * Mon Aug 01 2022 14:10: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,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-deployer - v1.3.16 - Apache-2.0
2
+ * @esri/solution-deployer - v1.4.1 - Apache-2.0
3
3
  * Copyright (c) 2018-2022 Esri, Inc.
4
- * Wed Jun 08 2022 11:11:05 GMT-0700 (Pacific Daylight Time)
4
+ * Mon Aug 01 2022 14:10:29 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":"deployer.umd.min.js","sources":["../../src/module-map.ts","../../src/deploySolutionItems.ts","../../src/helpers/post-process.ts","../../src/helpers/share-templates-to-groups.ts","../../src/deploySolutionFromTemplate.ts","../../src/helpers/sortTemplates.ts","../../src/deployerUtils.ts","../../src/deployer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2020 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 { moduleHandler, IItemTypeModuleMap } from \"@esri/solution-common\";\r\nimport * as featureLayer from \"@esri/solution-feature-layer\";\r\nimport * as fileProcessor from \"@esri/solution-file\";\r\nimport * as formProcessor from \"@esri/solution-form\";\r\nimport * as group from \"@esri/solution-group\";\r\nimport {\r\n simpleTypes,\r\n notebookProcessor,\r\n quickcaptureProcessor\r\n} from \"@esri/solution-simple-types\";\r\nimport { StoryMapProcessor } from \"@esri/solution-storymap\";\r\nimport { VelocityProcessor } from \"@esri/solution-velocity\";\r\nimport { WebExperienceProcessor } from \"@esri/solution-web-experience\";\r\nimport { HubPageProcessor, HubSiteProcessor } from \"@esri/solution-hub-types\";\r\n\r\nexport const UNSUPPORTED: moduleHandler = null;\r\n\r\n/**\r\n * Mapping from item type to module with type-specific template-handling code.\r\n * AGO types come from a blend of arcgis-portal-app\\src\\js\\arcgisonline\\pages\\item\\_Info.js and\r\n * arcgis-portal-app\\src\\js\\arcgis-components\\src\\_utils\\metadata\\item\\displayName.ts\r\n */\r\nexport const moduleMap: IItemTypeModuleMap = {\r\n ////////////////////////////////////////////////////////\r\n // Group type\r\n Group: group,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Layer types\r\n \"Big Data Analytic\": VelocityProcessor,\r\n \"Feature Collection\": simpleTypes,\r\n \"Feature Service\": featureLayer,\r\n Feed: VelocityProcessor,\r\n \"Geocoding Service\": undefined,\r\n \"Geodata Service\": undefined,\r\n \"Geometry Service\": undefined,\r\n \"Geoprocessing Service\": undefined,\r\n \"Globe Service\": undefined,\r\n \"Image Service\": undefined,\r\n KML: undefined,\r\n \"Map Service\": featureLayer,\r\n \"Network Analysis Service\": undefined,\r\n \"Real Time Analytic\": VelocityProcessor,\r\n \"Relational Database Connection\": undefined,\r\n \"Scene Service\": undefined,\r\n \"Stream Service\": undefined,\r\n Tool: undefined,\r\n \"Vector Tile Service\": undefined,\r\n WFS: undefined,\r\n WMS: undefined,\r\n WMTS: undefined,\r\n \"Workflow Manager Service\": undefined,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Map types\r\n \"3D Web Scene\": undefined,\r\n \"Web Map\": simpleTypes,\r\n \"Web Scene\": simpleTypes,\r\n\r\n ////////////////////////////////////////////////////////\r\n // App types\r\n Application: undefined,\r\n Dashboard: simpleTypes,\r\n \"Data Store\": undefined,\r\n \"Desktop Application\": undefined,\r\n \"Excalibur Imagery Project\": undefined,\r\n Form: formProcessor,\r\n \"Hub Initiative\": UNSUPPORTED,\r\n \"Hub Page\": HubPageProcessor,\r\n \"Hub Site Application\": HubSiteProcessor,\r\n \"Insights Model\": simpleTypes,\r\n \"Insights Page\": undefined,\r\n \"Insights Theme\": undefined,\r\n \"Insights Workbook\": undefined,\r\n Mission: undefined,\r\n \"Mobile Application\": undefined,\r\n Notebook: notebookProcessor,\r\n \"Oriented Imagery Catalog\": simpleTypes,\r\n \"Ortho Mapping Project\": undefined,\r\n \"QuickCapture Project\": quickcaptureProcessor,\r\n \"Site Application\": HubSiteProcessor,\r\n \"Site Page\": HubPageProcessor,\r\n Solution: UNSUPPORTED,\r\n StoryMap: StoryMapProcessor,\r\n \"Urban Model\": undefined,\r\n \"Web Experience Template\": undefined,\r\n \"Web Experience\": WebExperienceProcessor,\r\n \"Web Mapping Application\": simpleTypes,\r\n \"Workforce Project\": simpleTypes,\r\n\r\n ////////////////////////////////////////////////////////\r\n // File types\r\n \"360 VR Experience\": fileProcessor,\r\n \"AppBuilder Extension\": fileProcessor,\r\n \"AppBuilder Widget Package\": fileProcessor,\r\n \"Application Configuration\": fileProcessor,\r\n \"ArcGIS Pro Add In\": fileProcessor,\r\n \"ArcGIS Pro Configuration\": fileProcessor,\r\n \"ArcPad Package\": fileProcessor,\r\n \"Basemap Package\": fileProcessor,\r\n \"CAD Drawing\": fileProcessor,\r\n \"CityEngine Web Scene\": fileProcessor,\r\n \"Code Attachment\": UNSUPPORTED,\r\n \"Code Sample\": fileProcessor,\r\n \"Color Set\": fileProcessor,\r\n \"Compact Tile Package\": fileProcessor,\r\n \"CSV Collection\": fileProcessor,\r\n CSV: fileProcessor,\r\n \"Deep Learning Package\": fileProcessor,\r\n \"Desktop Add In\": fileProcessor,\r\n \"Desktop Application Template\": fileProcessor,\r\n \"Desktop Style\": fileProcessor,\r\n \"Document Link\": fileProcessor,\r\n \"Explorer Add In\": fileProcessor,\r\n \"Explorer Layer\": fileProcessor,\r\n \"Explorer Map\": fileProcessor,\r\n \"Feature Collection Template\": fileProcessor,\r\n \"File Geodatabase\": fileProcessor,\r\n GeoJson: fileProcessor,\r\n GeoPackage: fileProcessor,\r\n \"Geoprocessing Package\": fileProcessor,\r\n \"Geoprocessing Sample\": fileProcessor,\r\n \"Globe Document\": fileProcessor,\r\n \"Image Collection\": fileProcessor,\r\n Image: fileProcessor,\r\n \"iWork Keynote\": fileProcessor,\r\n \"iWork Numbers\": fileProcessor,\r\n \"iWork Pages\": fileProcessor,\r\n \"KML Collection\": fileProcessor,\r\n \"Layer Package\": fileProcessor,\r\n \"Layer Template\": fileProcessor,\r\n Layer: fileProcessor,\r\n Layout: fileProcessor,\r\n \"Locator Package\": fileProcessor,\r\n \"Map Document\": fileProcessor,\r\n \"Map Package\": fileProcessor,\r\n \"Map Template\": fileProcessor,\r\n \"Microsoft Excel\": fileProcessor,\r\n \"Microsoft Powerpoint\": fileProcessor,\r\n \"Microsoft Word\": fileProcessor,\r\n \"Mobile Basemap Package\": fileProcessor,\r\n \"Mobile Map Package\": fileProcessor,\r\n \"Mobile Scene Package\": fileProcessor,\r\n \"Native Application\": fileProcessor,\r\n \"Native Application Installer\": fileProcessor,\r\n \"Native Application Template\": fileProcessor,\r\n netCDF: fileProcessor,\r\n \"Operation View\": fileProcessor,\r\n \"Operations Dashboard Add In\": fileProcessor,\r\n \"Operations Dashboard Extension\": fileProcessor,\r\n PDF: fileProcessor,\r\n \"Pro Layer Package\": fileProcessor,\r\n \"Pro Layer\": fileProcessor,\r\n \"Pro Map Package\": fileProcessor,\r\n \"Pro Map\": fileProcessor,\r\n \"Pro Report\": fileProcessor,\r\n \"Project Package\": fileProcessor,\r\n \"Project Template\": fileProcessor,\r\n \"Published Map\": fileProcessor,\r\n \"Raster function template\": fileProcessor,\r\n \"Report Template\": fileProcessor,\r\n \"Rule Package\": fileProcessor,\r\n \"Scene Document\": fileProcessor,\r\n \"Scene Package\": fileProcessor,\r\n \"Service Definition\": fileProcessor,\r\n Shapefile: fileProcessor,\r\n \"Statistical Data Collection\": fileProcessor,\r\n Style: fileProcessor,\r\n \"Survey123 Add In\": fileProcessor,\r\n \"Symbol Set\": fileProcessor,\r\n \"Task File\": fileProcessor,\r\n \"Tile Package\": fileProcessor,\r\n \"Toolbox Package\": fileProcessor,\r\n \"Vector Tile Package\": fileProcessor,\r\n \"Viewer Configuration\": fileProcessor,\r\n \"Visio Document\": fileProcessor,\r\n \"Window Mobile Package\": fileProcessor,\r\n \"Windows Mobile Package\": fileProcessor,\r\n \"Windows Viewer Add In\": fileProcessor,\r\n \"Windows Viewer Configuration\": fileProcessor,\r\n \"Workflow Manager Package\": fileProcessor,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Testing \"types\"\r\n Undefined: undefined,\r\n Unsupported: UNSUPPORTED\r\n};\r\n","/** @license\r\n * Copyright 2018 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 deployment of items via the REST API.\r\n *\r\n * @module deployItems\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\nimport { moduleMap } from \"./module-map\";\r\n\r\nconst UNSUPPORTED: common.moduleHandler = null;\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Deploys a set of items defined by templates.\r\n *\r\n * @param portalSharingUrl Server/sharing\r\n * @param storageItemId Id of storage item\r\n * @param templates A collection of AGO item templates\r\n * @param storageAuthentication Credentials for the organization with the source items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements\r\n * @param deployedSolutionId Id of deployed Solution item\r\n * @param destinationAuthentication Credentials for the destination organization\r\n * @param options Options to tune deployment\r\n * @returns A promise that will resolve with the list of information about the created items\r\n */\r\nexport function deploySolutionItems(\r\n portalSharingUrl: string,\r\n storageItemId: string,\r\n templates: common.IItemTemplate[],\r\n storageAuthentication: common.UserSession,\r\n templateDictionary: any,\r\n deployedSolutionId: string,\r\n destinationAuthentication: common.UserSession,\r\n options: common.IDeploySolutionOptions\r\n): Promise<common.ICreateItemFromTemplateResponse[]> {\r\n return new Promise((resolve, reject) => {\r\n // Prepare feedback mechanism\r\n const totalEstimatedCost = _estimateDeploymentCost(templates) + 1; // solution items, plus avoid divide by 0\r\n let percentDone: number = 10; // allow for previous deployment work\r\n const progressPercentStep = (99 - percentDone) / totalEstimatedCost; // leave some % for caller for wrapup\r\n\r\n const failedTemplateItemIds: string[] = [];\r\n const deployedItemIds: string[] = [];\r\n let statusOK = true;\r\n\r\n // TODO: move to separate fn\r\n const itemProgressCallback: common.IItemProgressCallback = (\r\n itemId: string,\r\n status: common.EItemProgressStatus,\r\n costUsed: number,\r\n createdItemId: string // supplied when status is EItemProgressStatus.Created or .Finished\r\n ) => {\r\n percentDone += progressPercentStep * costUsed;\r\n /* istanbul ignore else */\r\n if (options.progressCallback) {\r\n if (status === common.EItemProgressStatus.Finished) {\r\n const event = {\r\n event: common.SItemProgressStatus[status],\r\n data: itemId\r\n } as common.ISolutionProgressEvent;\r\n options.progressCallback(\r\n Math.round(percentDone),\r\n options.jobId,\r\n event\r\n );\r\n } else {\r\n options.progressCallback(Math.round(percentDone), options.jobId);\r\n }\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (options.consoleProgress) {\r\n console.log(\r\n Date.now(),\r\n itemId,\r\n options.jobId ?? \"\",\r\n common.SItemProgressStatus[status],\r\n percentDone.toFixed(0) + \"%\",\r\n costUsed,\r\n createdItemId ? \"==> \" + createdItemId : \"\"\r\n );\r\n }\r\n\r\n if (status === common.EItemProgressStatus.Created) {\r\n deployedItemIds.push(createdItemId);\r\n } else if (status === common.EItemProgressStatus.Failed) {\r\n failedTemplateItemIds.push(itemId);\r\n console.error(\"Item \" + itemId + \" has failed\");\r\n statusOK = false;\r\n }\r\n\r\n return statusOK;\r\n // ---------------------------------------------------------------------------------------------------------------\r\n };\r\n\r\n // portal does not allow views of a single source to be created at the same time\r\n if (common.getProp(templateDictionary, \"organization.isPortal\")) {\r\n templates = _evaluateSharedViewSources(templates);\r\n }\r\n\r\n // Create an ordered graph of the templates so that dependencies are created before the items that need them.\r\n // Because cycles are permitted, we also keep track of items that need to be patched later because their\r\n // dependencies are necessarily created after they are created.\r\n const { buildOrder, itemsToBePatched } = common.topologicallySortItems(\r\n templates\r\n );\r\n\r\n // For each item in order from no dependencies to dependent on other items,\r\n // * replace template symbols using template dictionary\r\n // * create item in destination group\r\n // * add created item's id into the template dictionary\r\n const awaitAllItems = [] as Array<\r\n Promise<common.ICreateItemFromTemplateResponse>\r\n >;\r\n\r\n const reuseItemsDef: Promise<any> = _reuseDeployedItems(\r\n templates,\r\n options.enableItemReuse ?? false,\r\n templateDictionary,\r\n destinationAuthentication\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n reuseItemsDef.then(\r\n () => {\r\n const useExistingItemsDef: Promise<any> = _useExistingItems(\r\n templates,\r\n common.getProp(templateDictionary, \"params.useExisting\"),\r\n templateDictionary,\r\n destinationAuthentication\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n useExistingItemsDef.then(() => {\r\n templates = common.setNamesAndTitles(\r\n templates,\r\n templateDictionary.solutionItemId\r\n );\r\n\r\n buildOrder.forEach((id: string) => {\r\n // Get the item's template out of the list of templates\r\n const template = common.findTemplateInList(templates, id);\r\n awaitAllItems.push(\r\n _createItemFromTemplateWhenReady(\r\n template,\r\n common.generateStorageFilePaths(\r\n portalSharingUrl,\r\n storageItemId,\r\n template.resources,\r\n options.storageVersion\r\n ),\r\n storageAuthentication,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n )\r\n );\r\n });\r\n\r\n // Wait until all items have been created\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(awaitAllItems).then(\r\n (clonedSolutionItems: common.ICreateItemFromTemplateResponse[]) => {\r\n if (failedTemplateItemIds.length === 0) {\r\n // Do we have any items to be patched (i.e., they refer to dependencies using the template id rather\r\n // than the cloned id because the item had to be created before the dependency)? Flag these items\r\n // for post processing in the list of clones.\r\n _flagPatchItemsForPostProcessing(\r\n itemsToBePatched,\r\n templateDictionary,\r\n clonedSolutionItems\r\n );\r\n\r\n resolve(clonedSolutionItems);\r\n } else {\r\n // Delete created items\r\n const progressOptions: common.IDeleteSolutionOptions = {\r\n consoleProgress: true\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .deleteSolutionByComponents(\r\n deployedSolutionId,\r\n deployedItemIds,\r\n templates,\r\n templateDictionary,\r\n destinationAuthentication,\r\n progressOptions\r\n )\r\n .then(() =>\r\n reject(common.failWithIds(failedTemplateItemIds))\r\n );\r\n }\r\n }\r\n );\r\n });\r\n },\r\n e => {\r\n console.error(e);\r\n reject(common.fail(e));\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * For each item to be patched, convert it to its cloned id and mark the item as needing post processing.\r\n *\r\n * @param itemsToBePatched List of items that need to have their dependencies patched\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements\r\n * @param templates A collection of AGO item templates\r\n * @private\r\n */\r\nexport function _flagPatchItemsForPostProcessing(\r\n itemsToBePatched: common.IKeyedListsOfStrings,\r\n templateDictionary: any,\r\n templates: common.ICreateItemFromTemplateResponse[]\r\n): void {\r\n let itemIdsToBePatched = Object.keys(itemsToBePatched);\r\n\r\n /* istanbul ignore else */\r\n if (itemIdsToBePatched.length > 0) {\r\n // Replace the ids of the items to be patched (which are template ids) with their cloned versions\r\n itemIdsToBePatched = itemIdsToBePatched.map(\r\n id => templateDictionary[id].itemId\r\n );\r\n\r\n // Make sure that the items to be patched are flagged for post processing\r\n templates.forEach(item => {\r\n /* istanbul ignore else */\r\n if (itemIdsToBePatched.includes(item.id)) {\r\n item.postProcess = true;\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Portal does not allow views of a single source to be created at the same time.\r\n *\r\n * Update view templates with an array of other view template ids that it should wait on.\r\n *\r\n * @param templates a collection of AGO item templates\r\n *\r\n * @returns An updated array of item templates\r\n * @private\r\n */\r\nexport function _evaluateSharedViewSources(\r\n templates: common.IItemTemplate[]\r\n): common.IItemTemplate[] {\r\n // update the templates so we can defer the deployment when more than one view shares the same source\r\n // these are not classic dependencies but are in some ways similar\r\n const views: any[] = _getViews(templates);\r\n\r\n _updateViewTemplates(templates, views);\r\n\r\n const viewHash: any = _getViewHash(views);\r\n\r\n let processed: string[] = [];\r\n\r\n const visited: string[] = [];\r\n\r\n Object.keys(viewHash).forEach(k => {\r\n const _views: string[] = viewHash[k];\r\n _views.forEach(cv => {\r\n const template = common.findTemplateInList(templates, cv);\r\n const syncViews = common.getProp(template, \"properties.syncViews\");\r\n\r\n /* istanbul ignore else */\r\n if (visited.indexOf(template.itemId) > -1) {\r\n processed = processed.concat(syncViews);\r\n }\r\n /* istanbul ignore else */\r\n if (syncViews && syncViews.length > 0) {\r\n // when a view has multiple dependencies we need to retain the syncViews if they have been set already...\r\n common.setProp(\r\n template,\r\n \"properties.syncViews\",\r\n common.cloneObject(processed)\r\n );\r\n }\r\n /* istanbul ignore else */\r\n if (processed.indexOf(cv) < 0) {\r\n processed.push(cv);\r\n }\r\n /* istanbul ignore else */\r\n if (visited.indexOf(template.itemId) < 0) {\r\n visited.push(template.itemId);\r\n }\r\n });\r\n processed = [];\r\n });\r\n\r\n return templates;\r\n}\r\n\r\n/**\r\n * Add a syncViews array to each template that will hold all other view ids that\r\n * have the same FS dependency.\r\n * These arrays will be processed later to only contain ids that each view will need to wait on.\r\n *\r\n * @param templates a collection of AGO item templates\r\n * @param views an array of view template details\r\n *\r\n * @returns An updated array of item templates\r\n * @private\r\n */\r\nexport function _updateViewTemplates(\r\n templates: common.IItemTemplate[],\r\n views: any[]\r\n): common.IItemTemplate[] {\r\n views.forEach(v => {\r\n v.dependencies.forEach((id: string) => {\r\n templates = templates.map(t => {\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(t, \"properties.service.isView\") &&\r\n t.dependencies.indexOf(id) > -1 &&\r\n t.itemId !== v.id\r\n ) {\r\n /* istanbul ignore else */\r\n if (!Array.isArray(t.properties.syncViews)) {\r\n t.properties.syncViews = [];\r\n }\r\n /* istanbul ignore else */\r\n if (t.properties.syncViews.indexOf(v.id) < 0) {\r\n t.properties.syncViews.push(v.id);\r\n }\r\n }\r\n return t;\r\n });\r\n });\r\n });\r\n return templates;\r\n}\r\n\r\n/**\r\n * Get all view templates from the source templates collection\r\n *\r\n * @param views A collection of view ID and dependencies\r\n *\r\n * @returns an array of objects with the source FS id as the key and a list of views that are\r\n * dependant upon it\r\n *\r\n * @private\r\n */\r\nexport function _getViewHash(views: any[]): any {\r\n const viewHash: any = {};\r\n views.forEach(v => {\r\n v.dependencies.forEach((d: string) => {\r\n /* istanbul ignore else */\r\n if (Object.keys(viewHash).indexOf(d) < 0) {\r\n viewHash[d] = [v.id];\r\n } else if (viewHash[d].indexOf(v.id) < 0) {\r\n viewHash[d].push(v.id);\r\n }\r\n });\r\n });\r\n return viewHash;\r\n}\r\n\r\n/**\r\n * Get all view templates from the source templates collection\r\n *\r\n * @param templates A collection of AGO item templates\r\n *\r\n * @returns an array with the view id and its dependencies\r\n *\r\n * @private\r\n */\r\nexport function _getViews(templates: common.IItemTemplate[]): any[] {\r\n return templates.reduce((acc, v) => {\r\n /* istanbul ignore else */\r\n if (common.getProp(v, \"properties.service.isView\")) {\r\n acc.push({\r\n id: v.itemId,\r\n dependencies: v.dependencies\r\n });\r\n }\r\n return acc;\r\n }, []);\r\n}\r\n\r\n/**\r\n * Search for existing items and update the templateDictionary with key details\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param reuseItems Option to search for existing items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the requests\r\n *\r\n * @returns A Promise that will resolve once existing items have been evaluated\r\n *\r\n * @private\r\n */\r\nexport function _reuseDeployedItems(\r\n templates: common.IItemTemplate[],\r\n reuseItems: boolean,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise((resolve, reject) => {\r\n if (reuseItems) {\r\n const existingItemsByKeyword: Array<Promise<\r\n any\r\n >> = _findExistingItemByKeyword(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n Promise.all(existingItemsByKeyword).then(\r\n (existingItemsByKeywordResponse: any) => {\r\n const existingItemsByTag = _handleExistingItems(\r\n existingItemsByKeywordResponse,\r\n templateDictionary,\r\n authentication,\r\n true\r\n );\r\n\r\n Promise.all(existingItemsByTag).then(\r\n existingItemsByTagResponse => {\r\n _handleExistingItems(\r\n existingItemsByTagResponse,\r\n templateDictionary,\r\n authentication,\r\n false\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _updateTemplateDictionary(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n ).then(resolve);\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Search for existing items and update the templateDictionary with key details\r\n *\r\n * Subtle difference between _reuseDeployedItems and _useExistingItems\r\n * _reuseDeployedItems: will search all existing items based on specific type keywords\r\n * that would have been added by a previous deployment\r\n * _useExistingItems: will search for an existing item that the user provided\r\n * the item id for while configuring in the deployment app.\r\n * This type of item would not necessarily have been laid down by a previous deployment and\r\n * can thus not expect that it will have the type keywords\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param useExisting Option to search for existing items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the requests\r\n *\r\n * @returns A Promise that will resolve once existing items have been evaluated\r\n *\r\n * @private\r\n */\r\nexport function _useExistingItems(\r\n templates: common.IItemTemplate[],\r\n useExisting: boolean,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n if (useExisting) {\r\n const itemDefs: Array<Promise<any>> = [];\r\n const sourceIdHash: any = {};\r\n const itemIds: string[] = [];\r\n Object.keys(templateDictionary.params).forEach(k => {\r\n const v: any = templateDictionary.params[k];\r\n /* istanbul ignore else */\r\n if (v.itemId && /[0-9A-F]{32}/i.test(k)) {\r\n _updateTemplateDictionaryById(templateDictionary, k, v.itemId, v);\r\n\r\n // need to check and set the typeKeyword if it doesn't exist on this service yet\r\n // when the user has passed in an itemId that does not come from a previous deployment\r\n itemDefs.push(common.getItemBase(v.itemId, authentication));\r\n sourceIdHash[v.itemId] = k;\r\n\r\n /* istanbul ignore else */\r\n if (itemIds.indexOf(k) < 0) {\r\n itemIds.push(k);\r\n }\r\n }\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _setTypekeywordForExisting(itemDefs, sourceIdHash, authentication).then(\r\n () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _updateTemplateDictionary(\r\n itemIds.map(id => common.getTemplateById(templates, id)),\r\n templateDictionary,\r\n authentication\r\n ).then(resolve);\r\n }\r\n );\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Verify if the existing item has the source-<itemId> typeKeyword and set it if not\r\n * This allows items that did not come from deployment to be found for reuse after they\r\n * have been used once via a custom itemId param\r\n *\r\n * @param itemDefs\r\n * @param sourceIdHash key value pairs..actual itemId is the key and the source itemId is the value\r\n * @param authentication credentials for the requests\r\n *\r\n * @returns a promise to indicate when the requests are complete\r\n * @private\r\n */\r\nexport function _setTypekeywordForExisting(\r\n itemDefs: Array<Promise<any>>,\r\n sourceIdHash: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n if (itemDefs.length > 0) {\r\n Promise.all(itemDefs).then(\r\n results => {\r\n const itemUpdateDefs: Array<Promise<any>> = [];\r\n results.forEach(result => {\r\n const sourceId: string = sourceIdHash[result.id];\r\n /* istanbul ignore else */\r\n if (result && sourceId && result.typeKeywords) {\r\n const sourceKeyword = `source-${sourceId}`;\r\n const typeKeywords: string[] = result.typeKeywords;\r\n /* istanbul ignore else */\r\n if (typeKeywords.indexOf(sourceKeyword) < 0) {\r\n typeKeywords.push(sourceKeyword);\r\n const itemUpdate: any = { id: result.id, typeKeywords };\r\n itemUpdateDefs.push(\r\n common.updateItem(itemUpdate, authentication)\r\n );\r\n }\r\n }\r\n });\r\n\r\n // wait for updates to finish before we resolve\r\n if (itemUpdateDefs.length > 0) {\r\n Promise.all(itemUpdateDefs).then(resolve, () => resolve(undefined));\r\n } else {\r\n resolve(undefined);\r\n }\r\n },\r\n () => resolve(undefined)\r\n );\r\n } else {\r\n resolve(undefined);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Update the templateDictionary with key details by item type\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n *\r\n * @private\r\n */\r\nexport function _updateTemplateDictionary(\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n const defs: Array<Promise<any>> = [];\r\n const urls: string[] = [];\r\n const types: string[] = [];\r\n const ids: string[] = [];\r\n templates.forEach(t => {\r\n const templateInfo: any = templateDictionary[t.itemId];\r\n /* istanbul ignore else */\r\n if (templateInfo && templateInfo.url && templateInfo.itemId) {\r\n /* istanbul ignore else */\r\n if (t.item.type === \"Feature Service\") {\r\n const enterpriseIDMapping: any = common.getProp(\r\n templateDictionary,\r\n `params.${t.itemId}.enterpriseIDMapping`\r\n );\r\n Object.assign(\r\n templateDictionary[t.itemId],\r\n common.getLayerSettings(\r\n common.getLayersAndTables(t),\r\n templateInfo.url,\r\n templateInfo.itemId,\r\n enterpriseIDMapping\r\n )\r\n );\r\n\r\n // if the service has veiws keep track of the fields so we can use them to\r\n // compare with the view fields\r\n /* istanbul ignore else */\r\n if (common.getProp(t, \"properties.service.hasViews\")) {\r\n common._updateTemplateDictionaryFields(\r\n t,\r\n templateDictionary,\r\n false\r\n );\r\n }\r\n }\r\n\r\n // for fs query with its url...for non fs query the item\r\n // this is to verify situations where we have a stale search index that will\r\n // say some items exist when they don't really exist\r\n // searching the services url or with the item id will return an error when this condition occurs\r\n /* istanbul ignore else */\r\n if (urls.indexOf(templateInfo.url) < 0) {\r\n defs.push(\r\n t.item.type === \"Feature Service\"\r\n ? common.rest_request(templateInfo.url, { authentication })\r\n : common.getItemBase(templateInfo.itemId, authentication)\r\n );\r\n urls.push(templateInfo.url);\r\n types.push(t.item.type);\r\n ids.push(templateInfo.itemId);\r\n }\r\n }\r\n });\r\n\r\n if (defs.length > 0) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(defs.map(p => p.catch(e => e))).then(results => {\r\n /* istanbul ignore else */\r\n if (Array.isArray(results) && results.length > 0) {\r\n const fieldDefs: Array<Promise<any>> = [];\r\n results.forEach((r, i) => {\r\n // a feature service result will contain a serviceItemId if it was successfully fetched\r\n if (r.serviceItemId && types[i] === \"Feature Service\") {\r\n Object.keys(templateDictionary).forEach(k => {\r\n const v: any = templateDictionary[k];\r\n /* istanbul ignore else */\r\n if (v.itemId && v.itemId === r.serviceItemId) {\r\n common.setDefaultSpatialReference(\r\n templateDictionary,\r\n k,\r\n r.spatialReference\r\n );\r\n\r\n // keep the extent values from these responses as well\r\n common.setCreateProp(\r\n templateDictionary,\r\n `${k}.defaultExtent`,\r\n r.fullExtent || r.initialExtent\r\n );\r\n\r\n const layerIds: number[] = (r.layers || []).map(\r\n (l: any) => l.id\r\n );\r\n const tablesIds: number[] = (r.tables || []).map(\r\n (t: any) => t.id\r\n );\r\n fieldDefs.push(\r\n common.getExistingLayersAndTables(\r\n urls[i],\r\n layerIds.concat(tablesIds),\r\n authentication\r\n )\r\n );\r\n }\r\n });\r\n } else {\r\n /* istanbul ignore else */\r\n if (\r\n types[i] === \"Feature Service\" ||\r\n common.getProp(r, \"response.error\")\r\n ) {\r\n // if an error is returned we need to clean up the templateDictionary\r\n templateDictionary = _updateTemplateDictionaryForError(\r\n templateDictionary,\r\n ids[i]\r\n );\r\n }\r\n }\r\n });\r\n\r\n if (fieldDefs.length > 0) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(fieldDefs).then(layerTableResult => {\r\n layerTableResult.forEach(l => {\r\n l.forEach((ll: any) => {\r\n Object.keys(templateDictionary).forEach(k => {\r\n /* istanbul ignore else */\r\n if (templateDictionary[k].itemId === ll.serviceItemId) {\r\n let sourceId: string = \"\";\r\n Object.keys(templateDictionary).some(_k => {\r\n /* istanbul ignore else */\r\n if (\r\n templateDictionary[_k].itemId === ll.serviceItemId\r\n ) {\r\n sourceId = _k;\r\n return true;\r\n }\r\n });\r\n const enterpriseIDMapping: any = common.getProp(\r\n templateDictionary,\r\n `params.${sourceId}.enterpriseIDMapping`\r\n );\r\n if (enterpriseIDMapping) {\r\n Object.keys(enterpriseIDMapping).forEach(id => {\r\n if (\r\n enterpriseIDMapping[id].toString() ===\r\n ll.id.toString()\r\n ) {\r\n _setFields(templateDictionary, k, id, ll.fields);\r\n }\r\n });\r\n } else {\r\n _setFields(templateDictionary, k, ll.id, ll.fields);\r\n }\r\n }\r\n });\r\n });\r\n });\r\n resolve(null);\r\n });\r\n } else {\r\n resolve(null);\r\n }\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Add the fields from the source layer to the template dictionary for any required replacements\r\n *\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param itemId the id for the item\r\n * @param layerId the id for the layer\r\n * @param fields the fields to transfer\r\n *\r\n * @private\r\n */\r\nexport function _setFields(\r\n templateDictionary: any,\r\n itemId: string,\r\n layerId: string,\r\n fields: any[]\r\n): void {\r\n const layerInfo: any = common.getProp(\r\n templateDictionary,\r\n `${itemId}.layer${layerId}`\r\n );\r\n /* istanbul ignore else */\r\n if (layerInfo && fields) {\r\n layerInfo.fields = fields;\r\n }\r\n}\r\n\r\n/**\r\n * In some cases an item id search will return a stale item reference\r\n * it will subsequently fail when we try to fetch the underlying service.\r\n *\r\n * We need to remove the item info that has been added to the template dictionary\r\n * and treat the item as we do other items that don't already exist on deployment.\r\n *\r\n * @param result the service request result\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n *\r\n * @private\r\n */\r\nexport function _updateTemplateDictionaryForError(\r\n templateDictionary: any,\r\n itemId: string\r\n): any {\r\n /* istanbul ignore else */\r\n if (itemId) {\r\n let removeKey: string = \"\";\r\n Object.keys(templateDictionary).some(k => {\r\n /* istanbul ignore else */\r\n if (templateDictionary[k].itemId === itemId) {\r\n removeKey = k;\r\n return true;\r\n }\r\n });\r\n /* istanbul ignore else */\r\n if (removeKey !== \"\") {\r\n delete templateDictionary[removeKey];\r\n }\r\n }\r\n return templateDictionary;\r\n}\r\n\r\n/**\r\n * Optionally search by tags and then update the templateDictionary based on the search results\r\n *\r\n * @param existingItemsResponse response object from search by typeKeyword and type\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the request\r\n * @param addTagQuery Boolean to indicate if a search by tag should happen\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _handleExistingItems(\r\n existingItemsResponse: any[],\r\n templateDictionary: any,\r\n authentication: common.UserSession,\r\n addTagQuery: boolean\r\n): Array<Promise<any>> {\r\n // if items are not found by type keyword search by tag\r\n const existingItemsByTag: Array<Promise<any>> = [Promise.resolve(null)];\r\n /* istanbul ignore else */\r\n if (existingItemsResponse && Array.isArray(existingItemsResponse)) {\r\n existingItemsResponse.forEach(existingItem => {\r\n /* istanbul ignore else */\r\n if (Array.isArray(existingItem?.results)) {\r\n let result: any;\r\n const results: any[] = existingItem.results;\r\n if (results.length === 1) {\r\n result = results[0];\r\n } else if (results.length > 1) {\r\n result = results.reduce((a: any, b: any) =>\r\n a.created > b.created ? a : b\r\n );\r\n } else {\r\n if (addTagQuery && existingItem.query) {\r\n const tagQuery: string = existingItem.query.replace(\r\n \"typekeywords\",\r\n \"tags\"\r\n );\r\n existingItemsByTag.push(\r\n _findExistingItem(tagQuery, authentication)\r\n );\r\n }\r\n }\r\n if (result) {\r\n const sourceId: any = existingItem.query\r\n ? existingItem.query.match(/[0-9A-F]{32}/i)[0]\r\n : existingItem.sourceId;\r\n /* istanbul ignore else */\r\n if (sourceId) {\r\n _updateTemplateDictionaryById(\r\n templateDictionary,\r\n sourceId,\r\n result.id,\r\n result\r\n );\r\n }\r\n }\r\n }\r\n });\r\n }\r\n return existingItemsByTag;\r\n}\r\n\r\n//???\r\nexport function _updateTemplateDictionaryById(\r\n templateDictionary: any,\r\n sourceId: string,\r\n itemId: string,\r\n v: any\r\n): void {\r\n templateDictionary[sourceId] = Object.assign(\r\n templateDictionary[sourceId] || {},\r\n {\r\n def: Promise.resolve(\r\n common.generateEmptyCreationResponse(v.type, itemId)\r\n ),\r\n itemId,\r\n name: v.name,\r\n title: v.title,\r\n url: v.url\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Search items based on user query\r\n *\r\n * @param query Query string to use\r\n * @param authentication Credentials for the request\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _findExistingItemByKeyword(\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Array<Promise<any>> {\r\n const existingItemsDefs: Array<Promise<any>> = [];\r\n templates.forEach(template => {\r\n if (template.item.type === \"Group\") {\r\n const userGroups: any = templateDictionary.user?.groups;\r\n /* istanbul ignore else */\r\n if (Array.isArray(userGroups)) {\r\n existingItemsDefs.push(\r\n Promise.resolve({\r\n results: userGroups\r\n .filter(g => g.tags.indexOf(`source-${template.itemId}`) > -1 || g.typeKeywords.indexOf(`source-${template.itemId}`) > -1)\r\n .map(g => {\r\n g.type = \"Group\";\r\n return g;\r\n }),\r\n sourceId: template.itemId\r\n })\r\n );\r\n }\r\n } else {\r\n existingItemsDefs.push(\r\n _findExistingItem(\r\n `typekeywords:source-${template.itemId} type:${template.item.type} owner:${templateDictionary.user.username}`,\r\n authentication\r\n )\r\n );\r\n }\r\n });\r\n return existingItemsDefs;\r\n}\r\n\r\n/**\r\n * Search items based on user query\r\n *\r\n * @param query Query string to use\r\n * @param authentication Credentials for the request\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _findExistingItem(\r\n query: string,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n const searchOptions = {\r\n q: query,\r\n authentication: authentication,\r\n pagingParam: { start: 1, num: 100 }\r\n };\r\n return common.searchItems(searchOptions);\r\n}\r\n\r\n/**\r\n * Creates an item from a template once the item's dependencies have been created.\r\n *\r\n * @param template Template of item to deploy\r\n * @param resourceFilePaths URL, folder, and filename for each item resource/metadata/thumbnail\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param userSession Options for the request\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n * @returns A promise that will resolve with the id of the deployed item (which is simply returned if it's\r\n * already in the templates list\r\n * @private\r\n */\r\nexport function _createItemFromTemplateWhenReady(\r\n template: common.IItemTemplate,\r\n resourceFilePaths: common.IDeployFileCopyPath[],\r\n storageAuthentication: common.UserSession,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n // ensure this is present\r\n template.dependencies = template.dependencies || [];\r\n // if there is no entry in the templateDictionary\r\n // or if we have a basic entry without the deferred request for its creation, add it\r\n if (\r\n !templateDictionary.hasOwnProperty(template.itemId) ||\r\n !common.getProp(templateDictionary[template.itemId], \"def\")\r\n ) {\r\n let createResponse: common.ICreateItemFromTemplateResponse;\r\n let statusCode: common.EItemProgressStatus =\r\n common.EItemProgressStatus.Unknown;\r\n let itemHandler: common.IItemTemplateConversions;\r\n\r\n templateDictionary[template.itemId] =\r\n templateDictionary[template.itemId] || {};\r\n\r\n // Save the deferred for the use of items that depend on this item being created first\r\n templateDictionary[template.itemId].def = new Promise<\r\n common.ICreateItemFromTemplateResponse\r\n >(resolve => {\r\n // Wait until all of the item's dependencies are deployed\r\n const _awaitDependencies = template.dependencies.reduce(\r\n (acc: any[], id: string) => {\r\n const def = common.getProp(templateDictionary, `${id}.def`);\r\n // can't use maybePush as that clones the object, which does not work for Promises\r\n /* istanbul ignore else */\r\n if (def) {\r\n acc.push(def);\r\n }\r\n return acc;\r\n },\r\n []\r\n );\r\n\r\n const syncViews: string[] = common.getProp(\r\n template,\r\n \"properties.syncViews\"\r\n );\r\n\r\n const awaitDependencies =\r\n syncViews && syncViews.length > 0\r\n ? syncViews.reduce((acc: any[], v: any) => {\r\n const def = common.getProp(templateDictionary, `${v}.def`);\r\n /* istanbul ignore else */\r\n if (def) {\r\n acc.push(def);\r\n }\r\n return acc;\r\n }, _awaitDependencies)\r\n : _awaitDependencies;\r\n\r\n Promise.all(awaitDependencies)\r\n .then(() => {\r\n // Find the conversion handler for this item type\r\n const templateType = template.type;\r\n itemHandler = moduleMap[templateType];\r\n if (!itemHandler || itemHandler === UNSUPPORTED) {\r\n if (itemHandler === UNSUPPORTED) {\r\n statusCode = common.EItemProgressStatus.Ignored;\r\n throw new Error();\r\n } else {\r\n statusCode = common.EItemProgressStatus.Failed;\r\n throw new Error();\r\n }\r\n }\r\n\r\n // Get the item's thumbnail\r\n return common.getThumbnailFromStorageItem(\r\n storageAuthentication,\r\n resourceFilePaths\r\n );\r\n })\r\n .then(thumbnail => {\r\n template.item.thumbnail = thumbnail;\r\n\r\n // Delegate the creation of the item to the handler\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n return itemHandler.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n })\r\n .then((response: common.ICreateItemFromTemplateResponse) => {\r\n if (response.id === \"\") {\r\n statusCode = common.EItemProgressStatus.Failed;\r\n throw new Error(\"handled\"); // fails to create item\r\n }\r\n\r\n /* istanbul ignore else */\r\n createResponse = response;\r\n if (createResponse.item.item.url) {\r\n common.setCreateProp(\r\n templateDictionary,\r\n template.itemId + \".url\",\r\n createResponse.item.item.url\r\n );\r\n }\r\n\r\n if (resourceFilePaths.length > 0) {\r\n // Copy resources, metadata, form\r\n return common.copyFilesFromStorageItem(\r\n storageAuthentication,\r\n resourceFilePaths,\r\n templateDictionary.folderId,\r\n createResponse.id,\r\n destinationAuthentication,\r\n createResponse.item\r\n );\r\n } else {\r\n return Promise.resolve(null);\r\n }\r\n })\r\n .then(() => {\r\n resolve(createResponse);\r\n })\r\n .catch(error => {\r\n if (!error || error.message !== \"handled\") {\r\n itemProgressCallback(\r\n template.itemId,\r\n statusCode === common.EItemProgressStatus.Unknown\r\n ? common.EItemProgressStatus.Failed\r\n : statusCode,\r\n 0\r\n );\r\n }\r\n\r\n // Item type not supported or fails to get item dependencies\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n });\r\n });\r\n }\r\n return templateDictionary[template.itemId].def;\r\n}\r\n\r\n/**\r\n * Accumulates the estimated deployment cost of a set of templates.\r\n *\r\n * @param templates Templates to examine\r\n * @returns Sum of estimated deployment costs\r\n * @private\r\n */\r\nexport function _estimateDeploymentCost(\r\n templates: common.IItemTemplate[]\r\n): number {\r\n return templates.reduce(\r\n (accumulatedEstimatedCost: number, template: common.IItemTemplate) => {\r\n return (\r\n accumulatedEstimatedCost + (template.estimatedDeploymentCostFactor || 1)\r\n );\r\n },\r\n 0\r\n );\r\n}\r\n\r\n//???\r\n// TODO: Return a Promise vs array of promises\r\nexport function _getGroupUpdates(\r\n template: common.IItemTemplate,\r\n authentication: common.UserSession,\r\n templateDictionary: any\r\n): Array<Promise<any>> {\r\n const groups = template.groups || [];\r\n return groups.map((sourceGroupId: string) => {\r\n return common.shareItem(\r\n templateDictionary[sourceGroupId].itemId,\r\n template.itemId,\r\n authentication,\r\n common.isTrackingViewTemplate(template) ? templateDictionary.locationTracking.owner : undefined\r\n );\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 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\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n getTemplateById\r\n} from \"@esri/solution-common\";\r\nimport { addItemRelationship } from \"@esri/arcgis-rest-portal\";\r\nimport { moduleMap } from \"../module-map\";\r\nimport { shareTemplatesToGroups } from \"./share-templates-to-groups\";\r\n\r\n/**\r\n * Delegate post-processing to the type specific\r\n * processors. This allows each type to have fine-grained\r\n * control over what they do. Common post-processing is\r\n * exposed as functions that can be imported\r\n *\r\n * @param deployedSolutionId\r\n * @param templates\r\n * @param clonedSolutions\r\n * @param authentication\r\n * @param templateDictionary\r\n */\r\nexport function postProcess(\r\n deployedSolutionId: string,\r\n templates: IItemTemplate[],\r\n clonedSolutions: ICreateItemFromTemplateResponse[],\r\n authentication: UserSession,\r\n templateDictionary: any\r\n): Promise<any> {\r\n // connect the solution with its items; groups cannot be connected\r\n const relationshipPromises = clonedSolutions\r\n .filter(entry => entry.type !== \"Group\")\r\n .map(\r\n entry =>\r\n addItemRelationship({\r\n originItemId: deployedSolutionId,\r\n destinationItemId: entry.id,\r\n relationshipType: \"Solution2Item\",\r\n authentication: authentication\r\n } as any) // TODO: remove `as any`, which is here until arcgis-rest-js' ItemRelationshipType defn catches up\r\n );\r\n\r\n // delegate sharing to groups\r\n const sharePromises = shareTemplatesToGroups(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n // what needs post processing?\r\n const itemsToProcess = clonedSolutions.filter(entry => entry.postProcess);\r\n\r\n // map over these items\r\n const postProcessPromises = itemsToProcess.reduce((acc, entry) => {\r\n const itemHandler: any = moduleMap[entry.type];\r\n // only delegate if the handler has a postProcess method\r\n if (itemHandler && itemHandler.postProcess) {\r\n acc.push(\r\n itemHandler.postProcess(\r\n entry.id,\r\n entry.type,\r\n clonedSolutions,\r\n getTemplateById(templates, entry.id),\r\n templates,\r\n templateDictionary,\r\n authentication\r\n )\r\n );\r\n }\r\n return acc;\r\n }, []);\r\n\r\n return Promise.all(\r\n [sharePromises].concat(postProcessPromises, relationshipPromises)\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 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\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getProp,\r\n shareItemToGroups,\r\n isTrackingViewTemplate,\r\n replaceInTemplate\r\n} from \"@esri/solution-common\";\r\nimport { maybePush } from \"@esri/hub-common\";\r\n\r\n/**\r\n * Given the created templates\r\n *\r\n * @param templates\r\n * @param templateDictionary\r\n * @param authentication\r\n */\r\nexport function shareTemplatesToGroups(\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n // Filter to entries with groups to share to\r\n const templatesWithGroups = templates.filter(e => {\r\n return e.groups && e.groups.length > 0;\r\n });\r\n // fire off all the promises\r\n return Promise.all(\r\n templatesWithGroups.map(tmpl => {\r\n const groupIds = tmpl.groups.reduce((acc, sourceGroupId) => {\r\n return maybePush(\r\n getProp(templateDictionary, `${sourceGroupId}.itemId`),\r\n acc\r\n );\r\n }, []);\r\n // need to pass the tracking owner when sharing to tracking group\r\n if (isTrackingViewTemplate(tmpl) && !getProp(templateDictionary, \"locationTracking.userIsOwner\")) {\r\n const trackingGroupId = getProp(tmpl, \"item.properties.trackViewGroup\");\r\n const owner = getProp(templateDictionary, \"locationTracking.owner\");\r\n /* istanbul ignore else */\r\n if (trackingGroupId && owner) {\r\n const trackerGroupIds = groupIds.filter(id => {\r\n return id === replaceInTemplate(trackingGroupId, templateDictionary);\r\n });\r\n if (trackerGroupIds.length !== groupIds.length) {\r\n const nonTrackerGroupIds = groupIds.filter(id => id !== trackingGroupId)\r\n return Promise.all([\r\n shareItemToGroups(trackerGroupIds, tmpl.itemId, authentication, owner),\r\n shareItemToGroups(nonTrackerGroupIds, tmpl.itemId, authentication)\r\n ])\r\n } else {\r\n return shareItemToGroups(groupIds, tmpl.itemId, authentication, owner);\r\n }\r\n }\r\n } else {\r\n return shareItemToGroups(groupIds, tmpl.itemId, authentication);\r\n }\r\n })\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 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 * as common from \"@esri/solution-common\";\r\nimport * as deployItems from \"./deploySolutionItems\";\r\nimport { getWithDefault } from \"@esri/hub-common\";\r\nimport * as portal from \"@esri/arcgis-rest-portal\";\r\nimport { postProcess } from \"./helpers/post-process\";\r\nimport { sortTemplates } from \"./helpers/sortTemplates\";\r\nimport { setCreateProp } from \"@esri/solution-common\";\r\n\r\n// NOTE: Moved to separate file to allow stubbing in main deploySolution tests\r\n\r\nexport function deploySolutionFromTemplate(\r\n templateSolutionId: string,\r\n solutionTemplateBase: any,\r\n solutionTemplateData: any,\r\n authentication: common.UserSession,\r\n options: common.IDeploySolutionOptions\r\n): Promise<string> {\r\n options.storageVersion = common.extractSolutionVersion(solutionTemplateData);\r\n\r\n return new Promise((resolve, reject) => {\r\n // It is possible to provide a separate authentication for the source\r\n const storageAuthentication: common.UserSession = options.storageAuthentication\r\n ? options.storageAuthentication\r\n : authentication;\r\n\r\n // Replacement dictionary and high-level deployment ids for cleanup\r\n\r\n // TODO: Extract all templateDictionary prep into a separate function\r\n const templateDictionary = options.templateDictionary ?? {};\r\n let deployedFolderId: string;\r\n let deployedSolutionId: string;\r\n\r\n _applySourceToDeployOptions(\r\n options,\r\n solutionTemplateBase,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n if (options.additionalTypeKeywords) {\r\n solutionTemplateBase.typeKeywords = [].concat(\r\n solutionTemplateBase.typeKeywords,\r\n options.additionalTypeKeywords\r\n );\r\n }\r\n\r\n // Get the thumbnail file\r\n let thumbFilename = \"thumbnail\";\r\n let thumbDef = Promise.resolve(null);\r\n if (!options.thumbnail && options.thumbnailurl) {\r\n // Figure out the thumbnail's filename\r\n thumbFilename =\r\n common.getFilenameFromUrl(options.thumbnailurl) || thumbFilename;\r\n const thumbnailurl = common.appendQueryParam(\r\n options.thumbnailurl,\r\n \"w=400\"\r\n );\r\n delete options.thumbnailurl;\r\n\r\n // Fetch the thumbnail\r\n thumbDef = common.getBlobAsFile(\r\n thumbnailurl,\r\n thumbFilename,\r\n storageAuthentication,\r\n [400]\r\n );\r\n }\r\n\r\n _replaceParamVariables(solutionTemplateData, templateDictionary);\r\n\r\n // Get information about deployment environment\r\n Promise.all([\r\n common.getPortal(\"\", authentication), // determine if we are deploying to portal\r\n common.getUser(authentication), // find out about the user\r\n common.getFoldersAndGroups(authentication), // get all folders so that we can create a unique one, and all groups\r\n thumbDef\r\n ])\r\n .then(responses => {\r\n const [\r\n portalResponse,\r\n userResponse,\r\n foldersAndGroupsResponse,\r\n thumbnailFile\r\n ] = responses;\r\n if (!options.thumbnail && thumbnailFile) {\r\n options.thumbnail = thumbnailFile;\r\n }\r\n\r\n // update template items with source-itemId type keyword\r\n solutionTemplateData.templates = _addSourceId(solutionTemplateData.templates);\r\n\r\n templateDictionary.isPortal = portalResponse.isPortal;\r\n templateDictionary.organization = Object.assign(\r\n templateDictionary.organization || {},\r\n portalResponse\r\n );\r\n // TODO: Add more computed properties here\r\n // portal: portalResponse\r\n // orgextent as bbox for assignment onto items\r\n // more info in #266 https://github.com/Esri/solution.js/issues/266\r\n\r\n templateDictionary.portalBaseUrl = _getPortalBaseUrl(\r\n portalResponse,\r\n authentication\r\n );\r\n\r\n templateDictionary.user = userResponse;\r\n templateDictionary.user.folders = foldersAndGroupsResponse.folders;\r\n templateDictionary.user.groups = foldersAndGroupsResponse.groups.filter(\r\n (group: common.IGroup) =>\r\n group.owner === templateDictionary.user.username\r\n );\r\n\r\n // if we have tracking views and the user is not admin or the org doesn't support tracking an error is thrown\r\n common.setLocationTrackingEnabled(\r\n portalResponse,\r\n userResponse,\r\n templateDictionary,\r\n solutionTemplateData.templates\r\n );\r\n const trackingOwnerPromise = common.getTackingServiceOwner(\r\n templateDictionary,\r\n authentication\r\n )\r\n\r\n // Create a folder to hold the deployed solution. We use the solution name, appending a sequential\r\n // suffix if the folder exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n const folderPromise = common.createUniqueFolder(\r\n solutionTemplateBase.title,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n // Apply the portal extents to the solution\r\n const portalExtent: any = portalResponse.defaultExtent;\r\n const extentsPromise = common.convertExtentWithFallback(\r\n portalExtent,\r\n undefined,\r\n { wkid: 4326 },\r\n portalResponse.helperServices.geometry.url,\r\n authentication\r\n );\r\n\r\n // Await completion of async actions: folder creation & extents conversion\r\n return Promise.all([folderPromise, extentsPromise, trackingOwnerPromise]);\r\n })\r\n .then(responses => {\r\n const [folderResponse, wgs84Extent, trackingOwnerResponse] = responses;\r\n deployedFolderId = folderResponse.folder.id;\r\n templateDictionary.folderId = deployedFolderId;\r\n templateDictionary.solutionItemExtent =\r\n wgs84Extent.xmin +\r\n \",\" +\r\n wgs84Extent.ymin +\r\n \",\" +\r\n wgs84Extent.xmax +\r\n \",\" +\r\n wgs84Extent.ymax;\r\n // Hub Solutions depend on organization defaultExtentBBox as a nested array not a string\r\n templateDictionary.organization.defaultExtentBBox = [\r\n [wgs84Extent.xmin, wgs84Extent.ymin],\r\n [wgs84Extent.xmax, wgs84Extent.ymax]\r\n ];\r\n\r\n // update templateDictionary to indicate if the user owns the tracking service\r\n // this will affect how we handle group sharing\r\n /* istanbul ignore else */\r\n if (templateDictionary.locationTrackingEnabled) {\r\n setCreateProp(\r\n templateDictionary,\r\n \"locationTracking.userIsOwner\",\r\n trackingOwnerResponse\r\n );\r\n }\r\n\r\n // Create a deployed Solution item\r\n const createSolutionItemBase = {\r\n ...common.sanitizeJSONAndReportChanges(solutionTemplateBase),\r\n type: \"Solution\",\r\n typeKeywords: [\"Solution\"]\r\n };\r\n\r\n if (options.additionalTypeKeywords) {\r\n createSolutionItemBase.typeKeywords = [\"Solution\"].concat(\r\n options.additionalTypeKeywords\r\n );\r\n }\r\n\r\n // Create deployed solution item\r\n createSolutionItemBase.thumbnail = options.thumbnail;\r\n return common.createItemWithData(\r\n createSolutionItemBase,\r\n {},\r\n authentication,\r\n deployedFolderId\r\n );\r\n })\r\n .then(createSolutionResponse => {\r\n deployedSolutionId = createSolutionResponse.id;\r\n\r\n // Protect the solution item\r\n const protectOptions: portal.IUserItemOptions = {\r\n id: deployedSolutionId,\r\n authentication\r\n };\r\n return portal.protectItem(protectOptions);\r\n })\r\n .then(() => {\r\n // TODO: Attach the whole solution model so we can\r\n // have stuff like `{{solution.item.title}}\r\n templateDictionary.solutionItemId = deployedSolutionId;\r\n solutionTemplateBase.id = deployedSolutionId;\r\n\r\n solutionTemplateBase.tryitUrl = _checkedReplaceAll(\r\n solutionTemplateBase.tryitUrl,\r\n templateSolutionId,\r\n deployedSolutionId\r\n );\r\n solutionTemplateBase.url = _checkedReplaceAll(\r\n solutionTemplateBase.url,\r\n templateSolutionId,\r\n deployedSolutionId\r\n );\r\n\r\n // Handle the contained item templates\r\n return deployItems.deploySolutionItems(\r\n storageAuthentication.portal,\r\n templateSolutionId,\r\n solutionTemplateData.templates,\r\n storageAuthentication,\r\n templateDictionary,\r\n deployedSolutionId,\r\n authentication,\r\n options\r\n );\r\n })\r\n .then(\r\n (clonedSolutionsResponse: common.ICreateItemFromTemplateResponse[]) => {\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (itemTemplate: common.IItemTemplate) => {\r\n // Update ids present in template dictionary\r\n itemTemplate.itemId = common.getProp(\r\n templateDictionary,\r\n `${itemTemplate.itemId}.itemId`\r\n );\r\n\r\n // Update the dependencies hash to point to the new item ids\r\n itemTemplate.dependencies = itemTemplate.dependencies.map(\r\n (id: string) =>\r\n getWithDefault(templateDictionary, `${id}.itemId`, id)\r\n );\r\n return itemTemplate;\r\n }\r\n );\r\n\r\n // Sort the templates into build order, which is provided by clonedSolutionsResponse\r\n sortTemplates(\r\n solutionTemplateData.templates,\r\n clonedSolutionsResponse.map(response => response.id)\r\n );\r\n\r\n // Wrap up with post-processing, in which we deal with groups and cycle remnants\r\n return postProcess(\r\n deployedSolutionId,\r\n solutionTemplateData.templates,\r\n clonedSolutionsResponse,\r\n authentication,\r\n templateDictionary\r\n );\r\n }\r\n )\r\n .then(() => {\r\n // Update solution item using internal representation & and the updated data JSON\r\n solutionTemplateBase.typeKeywords = [].concat(\r\n solutionTemplateBase.typeKeywords,\r\n [\"Deployed\"]\r\n );\r\n const iTemplateKeyword = solutionTemplateBase.typeKeywords.indexOf(\r\n \"Template\"\r\n );\r\n /* istanbul ignore else */\r\n if (iTemplateKeyword >= 0) {\r\n solutionTemplateBase.typeKeywords.splice(iTemplateKeyword, 1);\r\n }\r\n\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (itemTemplate: common.IItemTemplate) =>\r\n _purgeTemplateProperties(itemTemplate)\r\n );\r\n\r\n solutionTemplateData.templates = _updateGroupReferences(\r\n solutionTemplateData.templates,\r\n templateDictionary\r\n );\r\n\r\n // Update solution items data using template dictionary, and then update the\r\n // itemId & dependencies in each item template\r\n solutionTemplateBase.data = common.replaceInTemplate(\r\n solutionTemplateData,\r\n templateDictionary\r\n );\r\n\r\n // Write any user defined params to the solution\r\n /* istanbul ignore else */\r\n if (templateDictionary.params) {\r\n solutionTemplateBase.data.params = templateDictionary.params;\r\n }\r\n\r\n return common.updateItem(\r\n solutionTemplateBase,\r\n authentication,\r\n deployedFolderId\r\n );\r\n })\r\n .then(() => resolve(solutionTemplateBase.id), reject);\r\n });\r\n}\r\n\r\n/**\r\n * Add source-id to items/groups typeKeywords\r\n *\r\n * @param template the array of solution data templates\r\n * @private\r\n */\r\nexport function _addSourceId(\r\n templates: common.IItemTemplate[]\r\n): common.IItemTemplate[] {\r\n return templates.map(\r\n (template: any) => {\r\n /* istanbul ignore else */\r\n if (template.item) {\r\n const typeKeywords = template.item!.typeKeywords || [];\r\n typeKeywords.push(\"source-\" + template.itemId);\r\n template.item.typeKeywords = typeKeywords;\r\n }\r\n return template;\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Update the deployOptions with the group properties\r\n *\r\n * @param deployOptions\r\n * @param sourceInfo\r\n * @param authentication\r\n * @param isGroup Boolean to indicate if the files are associated with a group or item\r\n * @private\r\n */\r\nexport function _applySourceToDeployOptions(\r\n deployOptions: common.IDeploySolutionOptions,\r\n solutionTemplateBase: any,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): common.IDeploySolutionOptions {\r\n // Deploy a solution from the template's contents,\r\n // using the template's information as defaults for the deployed solution item\r\n [\"title\", \"snippet\", \"description\", \"tags\"].forEach(prop => {\r\n deployOptions[prop] = deployOptions[prop] ?? solutionTemplateBase[prop];\r\n if (deployOptions[prop]) {\r\n solutionTemplateBase[prop] = deployOptions[prop];\r\n // carry these options forward on the templateDict\r\n templateDictionary[prop] = deployOptions[prop];\r\n }\r\n });\r\n\r\n if (!deployOptions.thumbnailurl && solutionTemplateBase.thumbnail) {\r\n // Get the full path to the thumbnail\r\n deployOptions.thumbnailurl = common.generateSourceThumbnailUrl(\r\n authentication.portal,\r\n solutionTemplateBase.id,\r\n solutionTemplateBase.thumbnail\r\n );\r\n delete solutionTemplateBase.thumbnail;\r\n }\r\n\r\n return deployOptions;\r\n}\r\n\r\n//???\r\nexport function _replaceParamVariables(\r\n solutionTemplateData: any,\r\n templateDictionary: any\r\n): void {\r\n // a custom params object can be passed in with the options to deploy a solution\r\n // in most cases we can defer to the item type handlers to use these values\r\n // for variable replacement\r\n // for spatial reference specifically we need to replace up front so the default extent\r\n // logic can execute as expected\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (template: common.IItemTemplate) => {\r\n // can't do this as it causes other values that don't exist in the dict yet to revert to defaults they may have defined\r\n // return common.replaceInTemplate(template, templateDictionary);\r\n /* istanbul ignore else */\r\n if (template.type === \"Feature Service\") {\r\n const paramsLookup: string = \"params.\";\r\n\r\n const wkidItemPath: string = \"item.spatialReference.wkid\";\r\n template = _updateProp(\r\n template,\r\n wkidItemPath,\r\n paramsLookup,\r\n templateDictionary\r\n );\r\n\r\n const wkidServicePath: string =\r\n \"properties.service.spatialReference.wkid\";\r\n template = _updateProp(\r\n template,\r\n wkidServicePath,\r\n paramsLookup,\r\n templateDictionary\r\n );\r\n }\r\n return template;\r\n }\r\n );\r\n}\r\n\r\n//???\r\nexport function _updateProp(\r\n template: common.IItemTemplate,\r\n path: string,\r\n lookup: string,\r\n templateDictionary: any\r\n): common.IItemTemplate {\r\n const wkid: any = common.getProp(template, path);\r\n /* istanbul ignore else */\r\n if (wkid && typeof wkid === \"string\" && wkid.indexOf(lookup) > -1) {\r\n common.setProp(\r\n template,\r\n path,\r\n common.replaceInTemplate(wkid, templateDictionary)\r\n );\r\n }\r\n return template;\r\n}\r\n\r\n//???\r\nexport function _checkedReplaceAll(\r\n template: string,\r\n oldValue: string,\r\n newValue: string\r\n): string {\r\n let newTemplate;\r\n if (template && template.indexOf(oldValue) > -1) {\r\n const re = new RegExp(oldValue, \"g\");\r\n newTemplate = template.replace(re, newValue);\r\n } else {\r\n newTemplate = template;\r\n }\r\n return newTemplate;\r\n}\r\n\r\n//???\r\nexport function _getPortalBaseUrl(\r\n portalResponse: common.IPortal,\r\n authentication: common.UserSession\r\n): string {\r\n // As of Spring 2020, only HTTPS (see\r\n // https://www.esri.com/arcgis-blog/products/product/administration/2019-arcgis-transport-security-improvements/)\r\n const scheme: string = \"https\"; // portalResponse.allSSL ? \"https\" : \"http\";\r\n const urlKey: string = common.getProp(portalResponse, \"urlKey\");\r\n const customBaseUrl: string = common.getProp(portalResponse, \"customBaseUrl\");\r\n const enterpriseBaseUrl = common.getProp(portalResponse, \"portalHostname\");\r\n\r\n return urlKey && customBaseUrl\r\n ? `${scheme}://${urlKey}.${customBaseUrl}`\r\n : enterpriseBaseUrl\r\n ? `${scheme}://${enterpriseBaseUrl}`\r\n : authentication.portal.replace(\"/sharing/rest\", \"\");\r\n}\r\n\r\n//???\r\nexport function _updateGroupReferences(\r\n itemTemplates: any[],\r\n templateDictionary: any\r\n): any[] {\r\n const groupIds = itemTemplates.reduce(\r\n (result: string[], t: common.IItemTemplate) => {\r\n if (t.type === \"Group\") {\r\n result.push(t.itemId);\r\n }\r\n return result;\r\n },\r\n []\r\n );\r\n\r\n Object.keys(templateDictionary).forEach(k => {\r\n const newId: string = templateDictionary[k].itemId;\r\n if (groupIds.indexOf(newId) > -1) {\r\n itemTemplates.forEach(t => {\r\n t.groups = t.groups.map((id: string) => (id === k ? newId : id));\r\n });\r\n }\r\n });\r\n return itemTemplates;\r\n}\r\n\r\n//???\r\nexport function _purgeTemplateProperties(itemTemplate: any): any {\r\n const retainProps: string[] = [\"itemId\", \"type\", \"dependencies\", \"groups\"];\r\n const deleteProps: string[] = Object.keys(itemTemplate).filter(\r\n k => retainProps.indexOf(k) < 0\r\n );\r\n common.deleteProps(itemTemplate, deleteProps);\r\n return itemTemplate;\r\n}\r\n\r\n/**\r\n * Returns a match of a supplied id with the suffix \".itemId\" in the template dictionary.\r\n *\r\n * @param id Id to look for\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @returns Match in template dictionary or original id\r\n */\r\nexport function _getNewItemId(id: string, templateDictionary: any): string {\r\n return common.getProp(templateDictionary, id + \".itemId\") ?? id;\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\nimport { IItemTemplate } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Sorts a list of templates in place to match a provided sort-order list.\r\n *\r\n * @param templates List of templates in a Solution\r\n * @param sortOrderIds List of template ids in the desired sort order\r\n */\r\nexport function sortTemplates(\r\n templates: IItemTemplate[],\r\n sortOrderIds: string[]\r\n): void {\r\n templates.sort(\r\n (template1: IItemTemplate, template2: IItemTemplate) =>\r\n sortOrderIds.indexOf(template1.itemId) -\r\n sortOrderIds.indexOf(template2.itemId)\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 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 * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Given an itemId or an object, either fetch the item or\r\n * resolve using the object, if it is structured as expected\r\n *\r\n * @param idOrObject string || object like `{item:{...}, data: {...}}`\r\n * @param authentication UserSession\r\n */\r\nexport function getSolutionTemplateItem(\r\n idOrObject: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n if (typeof idOrObject === \"string\") {\r\n // get the item + data\r\n return Promise.all([\r\n common.getItemBase(idOrObject, authentication),\r\n common.getItemDataAsJson(idOrObject, authentication)\r\n ]).then(([item, data]) => {\r\n // format into a model and migrate the schema\r\n return common.migrateSchema({\r\n item,\r\n data\r\n });\r\n });\r\n } else {\r\n // check if it is a \"Model\"\r\n if (_isModel(idOrObject)) {\r\n // run migrations\r\n return common.migrateSchema(idOrObject);\r\n } else {\r\n return Promise.reject(\r\n common.fail(\r\n `getSolutionTemplateItem must be passed an item id or a model object`\r\n )\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Update the Deploy Options with information from the\r\n * Solution Template item\r\n *\r\n * @param deployOptions\r\n * @param item\r\n * @param authentication\r\n */\r\nexport function updateDeployOptions(\r\n deployOptions: any,\r\n item: common.IItem,\r\n authentication: common.UserSession\r\n): any {\r\n deployOptions.jobId = deployOptions.jobId ?? item.id;\r\n deployOptions.title = deployOptions.title ?? item.title;\r\n deployOptions.snippet = deployOptions.snippet ?? item.snippet;\r\n deployOptions.description = deployOptions.description ?? item.description;\r\n deployOptions.tags = deployOptions.tags ?? item.tags;\r\n // add the thumbnail url\r\n deployOptions.thumbnailurl = item.thumbnail\r\n ? common.getItemThumbnailUrl(item.id, item.thumbnail, false, authentication)\r\n : null;\r\n\r\n return deployOptions;\r\n}\r\n\r\n/**\r\n * Check if an object is an Model\r\n *\r\n * @param obj any object\r\n * @private\r\n */\r\nexport function _isModel(obj: any): boolean {\r\n let result = false as boolean;\r\n // TODO Hoist into common?\r\n const isNotStringOrArray = (v: any): boolean =>\r\n v != null &&\r\n typeof v !== \"string\" &&\r\n !Array.isArray(v) &&\r\n typeof v === \"object\";\r\n\r\n if (isNotStringOrArray(obj)) {\r\n result = [\"item\", \"data\"].reduce((acc, prop) => {\r\n if (acc) {\r\n acc = isNotStringOrArray(obj[prop]);\r\n }\r\n return acc;\r\n }, true as boolean);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Does the item have the correct type and keywords\r\n * to be a Solution Template item?\r\n *\r\n * @param item IItem\r\n */\r\nexport function isSolutionTemplateItem(item: common.IItem): boolean {\r\n const kwds = item.typeKeywords;\r\n // Solution items\r\n let result = false;\r\n if (item.type === \"Solution\") {\r\n if (\r\n kwds.indexOf(\"Solution\") > -1 &&\r\n (kwds.indexOf(\"Template\") > -1 || kwds.indexOf(\"solutionTemplate\") > -1)\r\n ) {\r\n result = true;\r\n }\r\n }\r\n // Older Hub Solutions used Web Mapping Application items\r\n if (item.type === \"Web Mapping Application\") {\r\n if (kwds.indexOf(\"hubSolutionTemplate\") > -1) {\r\n result = true;\r\n }\r\n }\r\n return result;\r\n}\r\n","/** @license\r\n * Copyright 2018 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 deployment of a Solution.\r\n *\r\n * @module deployer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\nimport { deploySolutionFromTemplate } from \"./deploySolutionFromTemplate\";\r\nimport {\r\n getSolutionTemplateItem,\r\n isSolutionTemplateItem,\r\n updateDeployOptions\r\n} from \"./deployerUtils\";\r\nimport { IModel } from \"@esri/hub-common\";\r\n\r\n/**\r\n * Deploy a Solution\r\n *\r\n * Pass in either the item id or an IModel (`{item:{}, model:{}}`)\r\n * of a Solution Template, and this will generate the Solution\r\n *\r\n * @param maybeModel Item Id or IModel\r\n * @param authentication Credentials for the destination organization\r\n * @param options Options to override deployed information and to provide additional credentials\r\n * @returns The id of the created deployed solution item\r\n */\r\nexport function deploySolution(\r\n maybeModel: string | IModel,\r\n authentication: common.UserSession,\r\n options?: common.IDeploySolutionOptions\r\n): Promise<string> {\r\n // if we are not passed the maybeModel, reject\r\n if (!maybeModel) {\r\n return Promise.reject(common.fail(\"The Solution Template id is missing\"));\r\n }\r\n let deployOptions: common.IDeploySolutionOptions = options || {};\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(1, deployOptions.jobId); // let the caller know that we've started\r\n }\r\n\r\n // It is possible to provide a separate authentication for the source\r\n const storageAuthentication: common.UserSession = deployOptions.storageAuthentication\r\n ? deployOptions.storageAuthentication\r\n : authentication;\r\n\r\n // deal with maybe getting an item or an id\r\n return getSolutionTemplateItem(maybeModel, storageAuthentication)\r\n .then(model => {\r\n if (!isSolutionTemplateItem(model.item)) {\r\n return Promise.reject(\r\n common.fail(`${model.item.id} is not a Solution Template`)\r\n );\r\n } else {\r\n // fetch the metadata if the model's id is a GUID and pass the item & data forward\r\n return Promise.all([\r\n Promise.resolve(model.item),\r\n Promise.resolve(model.data)\r\n ]);\r\n }\r\n })\r\n .then(responses => {\r\n // extract responses\r\n const [itemBase, itemData] = responses;\r\n // sanitize all the things\r\n const sanitizer = new common.Sanitizer();\r\n const item = common.sanitizeJSONAndReportChanges(itemBase, sanitizer);\r\n // TODO: we should delegate data sanization to the type-specific modules\r\n const data = itemData;\r\n // get the item id before it is deleted\r\n const itemId = item.id;\r\n // apply item props to deployOptions\r\n deployOptions = updateDeployOptions(\r\n deployOptions,\r\n item,\r\n storageAuthentication\r\n );\r\n // Clone before mutating? This was messing me up in some testing...\r\n common.deleteItemProps(item);\r\n\r\n return deploySolutionFromTemplate(\r\n itemId,\r\n item,\r\n data,\r\n authentication,\r\n deployOptions\r\n );\r\n })\r\n .then(\r\n createdSolutionId => {\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(100, deployOptions.jobId); // we're done\r\n }\r\n return createdSolutionId;\r\n },\r\n error => {\r\n // Error deploying solution\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(1, deployOptions.jobId);\r\n }\r\n return Promise.reject(error);\r\n }\r\n )\r\n .catch(ex => {\r\n throw ex;\r\n });\r\n}\r\n"],"names":["UNSUPPORTED","moduleMap","Group","group","VelocityProcessor","simpleTypes","featureLayer","Feed","undefined","KML","Tool","WFS","WMS","WMTS","Application","Dashboard","Form","formProcessor","HubPageProcessor","HubSiteProcessor","Mission","Notebook","notebookProcessor","quickcaptureProcessor","Solution","StoryMap","StoryMapProcessor","WebExperienceProcessor","fileProcessor","CSV","GeoJson","GeoPackage","Image","Layer","Layout","netCDF","PDF","Shapefile","Style","Undefined","Unsupported","deploySolutionItems","portalSharingUrl","storageItemId","templates","storageAuthentication","templateDictionary","deployedSolutionId","destinationAuthentication","options","Promise","resolve","reject","totalEstimatedCost","_estimateDeploymentCost","percentDone","progressPercentStep","failedTemplateItemIds","deployedItemIds","statusOK","itemProgressCallback","itemId","status","costUsed","createdItemId","progressCallback","common","EItemProgressStatus","Finished","event","SItemProgressStatus","data","Math","round","jobId","consoleProgress","console","log","Date","now","toFixed","Created","push","Failed","error","getProp","_evaluateSharedViewSources","buildOrder","itemsToBePatched","topologicallySortItems","awaitAllItems","_reuseDeployedItems","enableItemReuse","then","_useExistingItems","setNamesAndTitles","solutionItemId","forEach","id","template","findTemplateInList","_createItemFromTemplateWhenReady","generateStorageFilePaths","resources","storageVersion","all","clonedSolutionItems","length","_flagPatchItemsForPostProcessing","progressOptions","deleteSolutionByComponents","failWithIds","e","fail","itemIdsToBePatched","Object","keys","map","item","includes","postProcess","views","_getViews","_updateViewTemplates","viewHash","_getViewHash","processed","visited","k","cv","syncViews","indexOf","concat","setProp","cloneObject","v","dependencies","t","Array","isArray","properties","d","reduce","acc","reuseItems","authentication","existingItemsByKeyword","_findExistingItemByKeyword","existingItemsByKeywordResponse","existingItemsByTag","_handleExistingItems","existingItemsByTagResponse","_updateTemplateDictionary","useExisting","itemDefs","sourceIdHash","itemIds","params","test","_updateTemplateDictionaryById","getItemBase","_setTypekeywordForExisting","getTemplateById","results","itemUpdateDefs","result","sourceId","typeKeywords","sourceKeyword","itemUpdate","updateItem","defs","urls","types","ids","templateInfo","url","type","enterpriseIDMapping","assign","getLayerSettings","getLayersAndTables","_updateTemplateDictionaryFields","rest_request","p","catch","fieldDefs","r","i","serviceItemId","setDefaultSpatialReference","spatialReference","setCreateProp","fullExtent","initialExtent","layerIds","layers","l","tablesIds","tables","getExistingLayersAndTables","_updateTemplateDictionaryForError","layerTableResult","ll","some","_k","toString","_setFields","fields","layerId","layerInfo","removeKey","existingItemsResponse","addTagQuery","existingItem","a","b","created","query","tagQuery","replace","_findExistingItem","match","def","generateEmptyCreationResponse","name","title","existingItemsDefs","userGroups","user","groups","filter","g","tags","username","searchOptions","q","pagingParam","start","num","searchItems","resourceFilePaths","hasOwnProperty","createResponse","itemHandler","statusCode","Unknown","_awaitDependencies","awaitDependencies","templateType","Ignored","Error","getThumbnailFromStorageItem","thumbnail","createItemFromTemplate","response","copyFilesFromStorageItem","folderId","message","accumulatedEstimatedCost","estimatedDeploymentCostFactor","clonedSolutions","relationshipPromises","entry","addItemRelationship","originItemId","destinationItemId","relationshipType","sharePromises","templatesWithGroups","tmpl","groupIds","sourceGroupId","maybePush","isTrackingViewTemplate","shareItemToGroups","trackingGroupId","owner","trackerGroupIds","replaceInTemplate","nonTrackerGroupIds","shareTemplatesToGroups","postProcessPromises","deploySolutionFromTemplate","templateSolutionId","solutionTemplateBase","solutionTemplateData","extractSolutionVersion","deployedFolderId","deployOptions","prop","thumbnailurl","generateSourceThumbnailUrl","portal","_applySourceToDeployOptions","additionalTypeKeywords","thumbFilename","thumbDef","getFilenameFromUrl","appendQueryParam","getBlobAsFile","paramsLookup","_updateProp","_replaceParamVariables","getPortal","getUser","getFoldersAndGroups","responses","portalResponse","userResponse","foldersAndGroupsResponse","thumbnailFile","isPortal","organization","portalBaseUrl","scheme","urlKey","customBaseUrl","enterpriseBaseUrl","_getPortalBaseUrl","folders","setLocationTrackingEnabled","trackingOwnerPromise","getTackingServiceOwner","folderPromise","createUniqueFolder","portalExtent","defaultExtent","extentsPromise","convertExtentWithFallback","wkid","helperServices","geometry","folderResponse","wgs84Extent","trackingOwnerResponse","folder","solutionItemExtent","xmin","ymin","xmax","ymax","defaultExtentBBox","locationTrackingEnabled","createSolutionItemBase","sanitizeJSONAndReportChanges","createItemWithData","createSolutionResponse","protectOptions","protectItem","tryitUrl","_checkedReplaceAll","deployItems.deploySolutionItems","clonedSolutionsResponse","sortOrderIds","itemTemplate","getWithDefault","sort","template1","template2","iTemplateKeyword","splice","retainProps","deleteProps","_purgeTemplateProperties","itemTemplates","newId","_updateGroupReferences","path","lookup","oldValue","newValue","newTemplate","re","RegExp","getSolutionTemplateItem","idOrObject","getItemDataAsJson","migrateSchema","_isModel","updateDeployOptions","snippet","description","getItemThumbnailUrl","obj","isNotStringOrArray","isSolutionTemplateItem","kwds","shareItem","locationTracking","maybeModel","model","itemBase","itemData","sanitizer","Sanitizer","deleteItemProps","createdSolutionId","ex"],"mappings":";;;;;;;;;;;;;;;;;4gDA+BaA,EAA6B,KAO7BC,EAAgC,CAG3CC,MAAOC,EAIP,oBAAqBC,oBACrB,qBAAsBC,cACtB,kBAAmBC,EACnBC,KAAMH,oBACN,yBAAqBI,EACrB,uBAAmBA,EACnB,wBAAoBA,EACpB,6BAAyBA,EACzB,qBAAiBA,EACjB,qBAAiBA,EACjBC,SAAKD,EACL,cAAeF,EACf,gCAA4BE,EAC5B,qBAAsBJ,oBACtB,sCAAkCI,EAClC,qBAAiBA,EACjB,sBAAkBA,EAClBE,UAAMF,EACN,2BAAuBA,EACvBG,SAAKH,EACLI,SAAKJ,EACLK,UAAML,EACN,gCAA4BA,EAI5B,oBAAgBA,EAChB,UAAWH,cACX,YAAaA,cAIbS,iBAAaN,EACbO,UAAWV,cACX,kBAAcG,EACd,2BAAuBA,EACvB,iCAA6BA,EAC7BQ,KAAMC,EACN,iBAAkBjB,EAClB,WAAYkB,mBACZ,uBAAwBC,mBACxB,iBAAkBd,cAClB,qBAAiBG,EACjB,sBAAkBA,EAClB,yBAAqBA,EACrBY,aAASZ,EACT,0BAAsBA,EACtBa,SAAUC,oBACV,2BAA4BjB,cAC5B,6BAAyBG,EACzB,uBAAwBe,wBACxB,mBAAoBJ,mBACpB,YAAaD,mBACbM,SAAUxB,EACVyB,SAAUC,oBACV,mBAAelB,EACf,+BAA2BA,EAC3B,iBAAkBmB,yBAClB,0BAA2BtB,cAC3B,oBAAqBA,cAIrB,oBAAqBuB,EACrB,uBAAwBA,EACxB,4BAA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
1
+ {"version":3,"file":"deployer.umd.min.js","sources":["../../src/module-map.ts","../../src/deploySolutionItems.ts","../../src/helpers/post-process.ts","../../src/helpers/share-templates-to-groups.ts","../../src/deploySolutionFromTemplate.ts","../../src/helpers/sortTemplates.ts","../../src/deployerUtils.ts","../../src/deployer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2020 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 { moduleHandler, IItemTypeModuleMap } from \"@esri/solution-common\";\r\nimport * as featureLayer from \"@esri/solution-feature-layer\";\r\nimport * as fileProcessor from \"@esri/solution-file\";\r\nimport * as formProcessor from \"@esri/solution-form\";\r\nimport * as group from \"@esri/solution-group\";\r\nimport {\r\n simpleTypes,\r\n notebookProcessor,\r\n quickcaptureProcessor\r\n} from \"@esri/solution-simple-types\";\r\nimport { StoryMapProcessor } from \"@esri/solution-storymap\";\r\nimport { VelocityProcessor } from \"@esri/solution-velocity\";\r\nimport { WebExperienceProcessor } from \"@esri/solution-web-experience\";\r\nimport { HubPageProcessor, HubSiteProcessor } from \"@esri/solution-hub-types\";\r\n\r\nexport const UNSUPPORTED: moduleHandler = null;\r\n\r\n/**\r\n * Mapping from item type to module with type-specific template-handling code.\r\n * AGO types come from a blend of arcgis-portal-app\\src\\js\\arcgisonline\\pages\\item\\_Info.js and\r\n * arcgis-portal-app\\src\\js\\arcgis-components\\src\\_utils\\metadata\\item\\displayName.ts\r\n */\r\nexport const moduleMap: IItemTypeModuleMap = {\r\n ////////////////////////////////////////////////////////\r\n // Group type\r\n Group: group,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Layer types\r\n \"Big Data Analytic\": VelocityProcessor,\r\n \"Feature Collection\": simpleTypes,\r\n \"Feature Service\": featureLayer,\r\n Feed: VelocityProcessor,\r\n \"Geocoding Service\": undefined,\r\n \"Geodata Service\": undefined,\r\n \"Geometry Service\": undefined,\r\n \"Geoprocessing Service\": undefined,\r\n \"Globe Service\": undefined,\r\n \"Image Service\": undefined,\r\n KML: undefined,\r\n \"Map Service\": featureLayer,\r\n \"Network Analysis Service\": undefined,\r\n \"Real Time Analytic\": VelocityProcessor,\r\n \"Relational Database Connection\": undefined,\r\n \"Scene Service\": undefined,\r\n \"Stream Service\": undefined,\r\n Tool: undefined,\r\n \"Vector Tile Service\": undefined,\r\n WFS: undefined,\r\n WMS: undefined,\r\n WMTS: undefined,\r\n \"Workflow Manager Service\": undefined,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Map types\r\n \"3D Web Scene\": undefined,\r\n \"Web Map\": simpleTypes,\r\n \"Web Scene\": simpleTypes,\r\n\r\n ////////////////////////////////////////////////////////\r\n // App types\r\n Application: undefined,\r\n Dashboard: simpleTypes,\r\n \"Data Store\": undefined,\r\n \"Desktop Application\": undefined,\r\n \"Excalibur Imagery Project\": undefined,\r\n Form: formProcessor,\r\n \"Hub Initiative\": UNSUPPORTED,\r\n \"Hub Page\": HubPageProcessor,\r\n \"Hub Site Application\": HubSiteProcessor,\r\n \"Insights Model\": simpleTypes,\r\n \"Insights Page\": undefined,\r\n \"Insights Theme\": undefined,\r\n \"Insights Workbook\": undefined,\r\n Mission: undefined,\r\n \"Mobile Application\": undefined,\r\n Notebook: notebookProcessor,\r\n \"Oriented Imagery Catalog\": simpleTypes,\r\n \"Ortho Mapping Project\": undefined,\r\n \"QuickCapture Project\": quickcaptureProcessor,\r\n \"Site Application\": HubSiteProcessor,\r\n \"Site Page\": HubPageProcessor,\r\n Solution: UNSUPPORTED,\r\n StoryMap: StoryMapProcessor,\r\n \"Urban Model\": undefined,\r\n \"Web Experience Template\": undefined,\r\n \"Web Experience\": WebExperienceProcessor,\r\n \"Web Mapping Application\": simpleTypes,\r\n \"Workforce Project\": simpleTypes,\r\n\r\n ////////////////////////////////////////////////////////\r\n // File types\r\n \"360 VR Experience\": fileProcessor,\r\n \"AppBuilder Extension\": fileProcessor,\r\n \"AppBuilder Widget Package\": fileProcessor,\r\n \"Application Configuration\": fileProcessor,\r\n \"ArcGIS Pro Add In\": fileProcessor,\r\n \"ArcGIS Pro Configuration\": fileProcessor,\r\n \"ArcPad Package\": fileProcessor,\r\n \"Basemap Package\": fileProcessor,\r\n \"CAD Drawing\": fileProcessor,\r\n \"CityEngine Web Scene\": fileProcessor,\r\n \"Code Attachment\": UNSUPPORTED,\r\n \"Code Sample\": fileProcessor,\r\n \"Color Set\": fileProcessor,\r\n \"Compact Tile Package\": fileProcessor,\r\n \"CSV Collection\": fileProcessor,\r\n CSV: fileProcessor,\r\n \"Deep Learning Package\": fileProcessor,\r\n \"Desktop Add In\": fileProcessor,\r\n \"Desktop Application Template\": fileProcessor,\r\n \"Desktop Style\": fileProcessor,\r\n \"Document Link\": fileProcessor,\r\n \"Explorer Add In\": fileProcessor,\r\n \"Explorer Layer\": fileProcessor,\r\n \"Explorer Map\": fileProcessor,\r\n \"Feature Collection Template\": fileProcessor,\r\n \"File Geodatabase\": fileProcessor,\r\n GeoJson: fileProcessor,\r\n GeoPackage: fileProcessor,\r\n \"Geoprocessing Package\": fileProcessor,\r\n \"Geoprocessing Sample\": fileProcessor,\r\n \"Globe Document\": fileProcessor,\r\n \"Image Collection\": fileProcessor,\r\n Image: fileProcessor,\r\n \"iWork Keynote\": fileProcessor,\r\n \"iWork Numbers\": fileProcessor,\r\n \"iWork Pages\": fileProcessor,\r\n \"KML Collection\": fileProcessor,\r\n \"Layer Package\": fileProcessor,\r\n \"Layer Template\": fileProcessor,\r\n Layer: fileProcessor,\r\n Layout: fileProcessor,\r\n \"Locator Package\": fileProcessor,\r\n \"Map Document\": fileProcessor,\r\n \"Map Package\": fileProcessor,\r\n \"Map Template\": fileProcessor,\r\n \"Microsoft Excel\": fileProcessor,\r\n \"Microsoft Powerpoint\": fileProcessor,\r\n \"Microsoft Word\": fileProcessor,\r\n \"Mobile Basemap Package\": fileProcessor,\r\n \"Mobile Map Package\": fileProcessor,\r\n \"Mobile Scene Package\": fileProcessor,\r\n \"Native Application\": fileProcessor,\r\n \"Native Application Installer\": fileProcessor,\r\n \"Native Application Template\": fileProcessor,\r\n netCDF: fileProcessor,\r\n \"Operation View\": fileProcessor,\r\n \"Operations Dashboard Add In\": fileProcessor,\r\n \"Operations Dashboard Extension\": fileProcessor,\r\n PDF: fileProcessor,\r\n \"Pro Layer Package\": fileProcessor,\r\n \"Pro Layer\": fileProcessor,\r\n \"Pro Map Package\": fileProcessor,\r\n \"Pro Map\": fileProcessor,\r\n \"Pro Report\": fileProcessor,\r\n \"Project Package\": fileProcessor,\r\n \"Project Template\": fileProcessor,\r\n \"Published Map\": fileProcessor,\r\n \"Raster function template\": fileProcessor,\r\n \"Report Template\": fileProcessor,\r\n \"Rule Package\": fileProcessor,\r\n \"Scene Document\": fileProcessor,\r\n \"Scene Package\": fileProcessor,\r\n \"Service Definition\": fileProcessor,\r\n Shapefile: fileProcessor,\r\n \"Statistical Data Collection\": fileProcessor,\r\n Style: fileProcessor,\r\n \"Survey123 Add In\": fileProcessor,\r\n \"Symbol Set\": fileProcessor,\r\n \"Task File\": fileProcessor,\r\n \"Tile Package\": fileProcessor,\r\n \"Toolbox Package\": fileProcessor,\r\n \"Vector Tile Package\": fileProcessor,\r\n \"Viewer Configuration\": fileProcessor,\r\n \"Visio Document\": fileProcessor,\r\n \"Window Mobile Package\": fileProcessor,\r\n \"Windows Mobile Package\": fileProcessor,\r\n \"Windows Viewer Add In\": fileProcessor,\r\n \"Windows Viewer Configuration\": fileProcessor,\r\n \"Workflow Manager Package\": fileProcessor,\r\n\r\n ////////////////////////////////////////////////////////\r\n // Testing \"types\"\r\n Undefined: undefined,\r\n Unsupported: UNSUPPORTED\r\n};\r\n","/** @license\r\n * Copyright 2018 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 deployment of items via the REST API.\r\n *\r\n * @module deployItems\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\nimport { moduleMap } from \"./module-map\";\r\n\r\nconst UNSUPPORTED: common.moduleHandler = null;\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Deploys a set of items defined by templates.\r\n *\r\n * @param portalSharingUrl Server/sharing\r\n * @param storageItemId Id of storage item\r\n * @param templates A collection of AGO item templates\r\n * @param storageAuthentication Credentials for the organization with the source items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements\r\n * @param deployedSolutionId Id of deployed Solution item\r\n * @param destinationAuthentication Credentials for the destination organization\r\n * @param options Options to tune deployment\r\n * @returns A promise that will resolve with the list of information about the created items\r\n */\r\nexport function deploySolutionItems(\r\n portalSharingUrl: string,\r\n storageItemId: string,\r\n templates: common.IItemTemplate[],\r\n storageAuthentication: common.UserSession,\r\n templateDictionary: any,\r\n deployedSolutionId: string,\r\n destinationAuthentication: common.UserSession,\r\n options: common.IDeploySolutionOptions\r\n): Promise<common.ICreateItemFromTemplateResponse[]> {\r\n return new Promise((resolve, reject) => {\r\n // Prepare feedback mechanism\r\n const totalEstimatedCost = _estimateDeploymentCost(templates) + 1; // solution items, plus avoid divide by 0\r\n let percentDone: number = 10; // allow for previous deployment work\r\n const progressPercentStep = (99 - percentDone) / totalEstimatedCost; // leave some % for caller for wrapup\r\n\r\n const failedTemplateItemIds: string[] = [];\r\n const deployedItemIds: string[] = [];\r\n let statusOK = true;\r\n\r\n // TODO: move to separate fn\r\n const itemProgressCallback: common.IItemProgressCallback = (\r\n itemId: string,\r\n status: common.EItemProgressStatus,\r\n costUsed: number,\r\n createdItemId: string // supplied when status is EItemProgressStatus.Created or .Finished\r\n ) => {\r\n percentDone += progressPercentStep * costUsed;\r\n /* istanbul ignore else */\r\n if (options.progressCallback) {\r\n if (status === common.EItemProgressStatus.Finished) {\r\n const event = {\r\n event: common.SItemProgressStatus[status],\r\n data: itemId\r\n } as common.ISolutionProgressEvent;\r\n options.progressCallback(\r\n Math.round(percentDone),\r\n options.jobId,\r\n event\r\n );\r\n } else {\r\n options.progressCallback(Math.round(percentDone), options.jobId);\r\n }\r\n }\r\n\r\n /* istanbul ignore if */\r\n if (options.consoleProgress) {\r\n console.log(\r\n Date.now(),\r\n itemId,\r\n options.jobId ?? \"\",\r\n common.SItemProgressStatus[status],\r\n percentDone.toFixed(0) + \"%\",\r\n costUsed,\r\n createdItemId ? \"==> \" + createdItemId : \"\"\r\n );\r\n }\r\n\r\n if (status === common.EItemProgressStatus.Created) {\r\n deployedItemIds.push(createdItemId);\r\n } else if (status === common.EItemProgressStatus.Failed) {\r\n failedTemplateItemIds.push(itemId);\r\n console.error(\"Item \" + itemId + \" has failed\");\r\n statusOK = false;\r\n }\r\n\r\n return statusOK;\r\n // ---------------------------------------------------------------------------------------------------------------\r\n };\r\n\r\n // portal does not allow views of a single source to be created at the same time\r\n if (common.getProp(templateDictionary, \"organization.isPortal\")) {\r\n templates = _evaluateSharedViewSources(templates);\r\n }\r\n\r\n // Create an ordered graph of the templates so that dependencies are created before the items that need them.\r\n // Because cycles are permitted, we also keep track of items that need to be patched later because their\r\n // dependencies are necessarily created after they are created.\r\n const { buildOrder, itemsToBePatched } = common.topologicallySortItems(\r\n templates\r\n );\r\n\r\n // For each item in order from no dependencies to dependent on other items,\r\n // * replace template symbols using template dictionary\r\n // * create item in destination group\r\n // * add created item's id into the template dictionary\r\n const awaitAllItems = [] as Array<\r\n Promise<common.ICreateItemFromTemplateResponse>\r\n >;\r\n\r\n const reuseItemsDef: Promise<any> = _reuseDeployedItems(\r\n templates,\r\n options.enableItemReuse ?? false,\r\n templateDictionary,\r\n destinationAuthentication\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n reuseItemsDef.then(\r\n () => {\r\n const useExistingItemsDef: Promise<any> = _useExistingItems(\r\n templates,\r\n common.getProp(templateDictionary, \"params.useExisting\"),\r\n templateDictionary,\r\n destinationAuthentication\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n useExistingItemsDef.then(() => {\r\n templates = common.setNamesAndTitles(\r\n templates,\r\n templateDictionary.solutionItemId\r\n );\r\n\r\n buildOrder.forEach((id: string) => {\r\n // Get the item's template out of the list of templates\r\n const template = common.findTemplateInList(templates, id);\r\n awaitAllItems.push(\r\n _createItemFromTemplateWhenReady(\r\n template,\r\n common.generateStorageFilePaths(\r\n portalSharingUrl,\r\n storageItemId,\r\n template.resources,\r\n options.storageVersion\r\n ),\r\n storageAuthentication,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n )\r\n );\r\n });\r\n\r\n // Wait until all items have been created\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(awaitAllItems).then(\r\n (clonedSolutionItems: common.ICreateItemFromTemplateResponse[]) => {\r\n if (failedTemplateItemIds.length === 0) {\r\n // Do we have any items to be patched (i.e., they refer to dependencies using the template id rather\r\n // than the cloned id because the item had to be created before the dependency)? Flag these items\r\n // for post processing in the list of clones.\r\n _flagPatchItemsForPostProcessing(\r\n itemsToBePatched,\r\n templateDictionary,\r\n clonedSolutionItems\r\n );\r\n\r\n resolve(clonedSolutionItems);\r\n } else {\r\n // Delete created items\r\n const progressOptions: common.IDeleteSolutionOptions = {\r\n consoleProgress: true\r\n };\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .deleteSolutionByComponents(\r\n deployedSolutionId,\r\n deployedItemIds,\r\n templates,\r\n templateDictionary,\r\n destinationAuthentication,\r\n progressOptions\r\n )\r\n .then(() =>\r\n reject(common.failWithIds(failedTemplateItemIds))\r\n );\r\n }\r\n }\r\n );\r\n });\r\n },\r\n e => {\r\n console.error(e);\r\n reject(common.fail(e));\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * For each item to be patched, convert it to its cloned id and mark the item as needing post processing.\r\n *\r\n * @param itemsToBePatched List of items that need to have their dependencies patched\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements\r\n * @param templates A collection of AGO item templates\r\n * @private\r\n */\r\nexport function _flagPatchItemsForPostProcessing(\r\n itemsToBePatched: common.IKeyedListsOfStrings,\r\n templateDictionary: any,\r\n templates: common.ICreateItemFromTemplateResponse[]\r\n): void {\r\n let itemIdsToBePatched = Object.keys(itemsToBePatched);\r\n\r\n /* istanbul ignore else */\r\n if (itemIdsToBePatched.length > 0) {\r\n // Replace the ids of the items to be patched (which are template ids) with their cloned versions\r\n itemIdsToBePatched = itemIdsToBePatched.map(\r\n id => templateDictionary[id].itemId\r\n );\r\n\r\n // Make sure that the items to be patched are flagged for post processing\r\n templates.forEach(item => {\r\n /* istanbul ignore else */\r\n if (itemIdsToBePatched.includes(item.id)) {\r\n item.postProcess = true;\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Portal does not allow views of a single source to be created at the same time.\r\n *\r\n * Update view templates with an array of other view template ids that it should wait on.\r\n *\r\n * @param templates a collection of AGO item templates\r\n *\r\n * @returns An updated array of item templates\r\n * @private\r\n */\r\nexport function _evaluateSharedViewSources(\r\n templates: common.IItemTemplate[]\r\n): common.IItemTemplate[] {\r\n // update the templates so we can defer the deployment when more than one view shares the same source\r\n // these are not classic dependencies but are in some ways similar\r\n const views: any[] = _getViews(templates);\r\n\r\n _updateViewTemplates(templates, views);\r\n\r\n const viewHash: any = _getViewHash(views);\r\n\r\n let processed: string[] = [];\r\n\r\n const visited: string[] = [];\r\n\r\n Object.keys(viewHash).forEach(k => {\r\n const _views: string[] = viewHash[k];\r\n _views.forEach(cv => {\r\n const template = common.findTemplateInList(templates, cv);\r\n const syncViews = common.getProp(template, \"properties.syncViews\");\r\n\r\n /* istanbul ignore else */\r\n if (visited.indexOf(template.itemId) > -1) {\r\n processed = processed.concat(syncViews);\r\n }\r\n /* istanbul ignore else */\r\n if (syncViews && syncViews.length > 0) {\r\n // when a view has multiple dependencies we need to retain the syncViews if they have been set already...\r\n common.setProp(\r\n template,\r\n \"properties.syncViews\",\r\n common.cloneObject(processed)\r\n );\r\n }\r\n /* istanbul ignore else */\r\n if (processed.indexOf(cv) < 0) {\r\n processed.push(cv);\r\n }\r\n /* istanbul ignore else */\r\n if (visited.indexOf(template.itemId) < 0) {\r\n visited.push(template.itemId);\r\n }\r\n });\r\n processed = [];\r\n });\r\n\r\n return templates;\r\n}\r\n\r\n/**\r\n * Add a syncViews array to each template that will hold all other view ids that\r\n * have the same FS dependency.\r\n * These arrays will be processed later to only contain ids that each view will need to wait on.\r\n *\r\n * @param templates a collection of AGO item templates\r\n * @param views an array of view template details\r\n *\r\n * @returns An updated array of item templates\r\n * @private\r\n */\r\nexport function _updateViewTemplates(\r\n templates: common.IItemTemplate[],\r\n views: any[]\r\n): common.IItemTemplate[] {\r\n views.forEach(v => {\r\n v.dependencies.forEach((id: string) => {\r\n templates = templates.map(t => {\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(t, \"properties.service.isView\") &&\r\n t.dependencies.indexOf(id) > -1 &&\r\n t.itemId !== v.id\r\n ) {\r\n /* istanbul ignore else */\r\n if (!Array.isArray(t.properties.syncViews)) {\r\n t.properties.syncViews = [];\r\n }\r\n /* istanbul ignore else */\r\n if (t.properties.syncViews.indexOf(v.id) < 0) {\r\n t.properties.syncViews.push(v.id);\r\n }\r\n }\r\n return t;\r\n });\r\n });\r\n });\r\n return templates;\r\n}\r\n\r\n/**\r\n * Get all view templates from the source templates collection\r\n *\r\n * @param views A collection of view ID and dependencies\r\n *\r\n * @returns an array of objects with the source FS id as the key and a list of views that are\r\n * dependant upon it\r\n *\r\n * @private\r\n */\r\nexport function _getViewHash(views: any[]): any {\r\n const viewHash: any = {};\r\n views.forEach(v => {\r\n v.dependencies.forEach((d: string) => {\r\n /* istanbul ignore else */\r\n if (Object.keys(viewHash).indexOf(d) < 0) {\r\n viewHash[d] = [v.id];\r\n } else if (viewHash[d].indexOf(v.id) < 0) {\r\n viewHash[d].push(v.id);\r\n }\r\n });\r\n });\r\n return viewHash;\r\n}\r\n\r\n/**\r\n * Get all view templates from the source templates collection\r\n *\r\n * @param templates A collection of AGO item templates\r\n *\r\n * @returns an array with the view id and its dependencies\r\n *\r\n * @private\r\n */\r\nexport function _getViews(templates: common.IItemTemplate[]): any[] {\r\n return templates.reduce((acc, v) => {\r\n /* istanbul ignore else */\r\n if (common.getProp(v, \"properties.service.isView\")) {\r\n acc.push({\r\n id: v.itemId,\r\n dependencies: v.dependencies\r\n });\r\n }\r\n return acc;\r\n }, []);\r\n}\r\n\r\n/**\r\n * Search for existing items and update the templateDictionary with key details\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param reuseItems Option to search for existing items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the requests\r\n *\r\n * @returns A Promise that will resolve once existing items have been evaluated\r\n *\r\n * @private\r\n */\r\nexport function _reuseDeployedItems(\r\n templates: common.IItemTemplate[],\r\n reuseItems: boolean,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise((resolve, reject) => {\r\n if (reuseItems) {\r\n const existingItemsByKeyword: Array<Promise<\r\n any\r\n >> = _findExistingItemByKeyword(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n Promise.all(existingItemsByKeyword).then(\r\n (existingItemsByKeywordResponse: any) => {\r\n const existingItemsByTag = _handleExistingItems(\r\n existingItemsByKeywordResponse,\r\n templateDictionary,\r\n authentication,\r\n true\r\n );\r\n\r\n Promise.all(existingItemsByTag).then(\r\n existingItemsByTagResponse => {\r\n _handleExistingItems(\r\n existingItemsByTagResponse,\r\n templateDictionary,\r\n authentication,\r\n false\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _updateTemplateDictionary(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n ).then(resolve);\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Search for existing items and update the templateDictionary with key details\r\n *\r\n * Subtle difference between _reuseDeployedItems and _useExistingItems\r\n * _reuseDeployedItems: will search all existing items based on specific type keywords\r\n * that would have been added by a previous deployment\r\n * _useExistingItems: will search for an existing item that the user provided\r\n * the item id for while configuring in the deployment app.\r\n * This type of item would not necessarily have been laid down by a previous deployment and\r\n * can thus not expect that it will have the type keywords\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param useExisting Option to search for existing items\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the requests\r\n *\r\n * @returns A Promise that will resolve once existing items have been evaluated\r\n *\r\n * @private\r\n */\r\nexport function _useExistingItems(\r\n templates: common.IItemTemplate[],\r\n useExisting: boolean,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n if (useExisting) {\r\n const itemDefs: Array<Promise<any>> = [];\r\n const sourceIdHash: any = {};\r\n const itemIds: string[] = [];\r\n Object.keys(templateDictionary.params).forEach(k => {\r\n const v: any = templateDictionary.params[k];\r\n /* istanbul ignore else */\r\n if (v.itemId && /[0-9A-F]{32}/i.test(k)) {\r\n _updateTemplateDictionaryById(templateDictionary, k, v.itemId, v);\r\n\r\n // need to check and set the typeKeyword if it doesn't exist on this service yet\r\n // when the user has passed in an itemId that does not come from a previous deployment\r\n itemDefs.push(common.getItemBase(v.itemId, authentication));\r\n sourceIdHash[v.itemId] = k;\r\n\r\n /* istanbul ignore else */\r\n if (itemIds.indexOf(k) < 0) {\r\n itemIds.push(k);\r\n }\r\n }\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _setTypekeywordForExisting(itemDefs, sourceIdHash, authentication).then(\r\n () => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n _updateTemplateDictionary(\r\n itemIds.map(id => common.getTemplateById(templates, id)),\r\n templateDictionary,\r\n authentication\r\n ).then(resolve);\r\n }\r\n );\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Verify if the existing item has the source-<itemId> typeKeyword and set it if not\r\n * This allows items that did not come from deployment to be found for reuse after they\r\n * have been used once via a custom itemId param\r\n *\r\n * @param itemDefs\r\n * @param sourceIdHash key value pairs..actual itemId is the key and the source itemId is the value\r\n * @param authentication credentials for the requests\r\n *\r\n * @returns a promise to indicate when the requests are complete\r\n * @private\r\n */\r\nexport function _setTypekeywordForExisting(\r\n itemDefs: Array<Promise<any>>,\r\n sourceIdHash: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n if (itemDefs.length > 0) {\r\n Promise.all(itemDefs).then(\r\n results => {\r\n const itemUpdateDefs: Array<Promise<any>> = [];\r\n results.forEach(result => {\r\n const sourceId: string = sourceIdHash[result.id];\r\n /* istanbul ignore else */\r\n if (result && sourceId && result.typeKeywords) {\r\n const sourceKeyword = `source-${sourceId}`;\r\n const typeKeywords: string[] = result.typeKeywords;\r\n /* istanbul ignore else */\r\n if (typeKeywords.indexOf(sourceKeyword) < 0) {\r\n typeKeywords.push(sourceKeyword);\r\n const itemUpdate: any = { id: result.id, typeKeywords };\r\n itemUpdateDefs.push(\r\n common.updateItem(itemUpdate, authentication)\r\n );\r\n }\r\n }\r\n });\r\n\r\n // wait for updates to finish before we resolve\r\n if (itemUpdateDefs.length > 0) {\r\n Promise.all(itemUpdateDefs).then(resolve, () => resolve(undefined));\r\n } else {\r\n resolve(undefined);\r\n }\r\n },\r\n () => resolve(undefined)\r\n );\r\n } else {\r\n resolve(undefined);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Update the templateDictionary with key details by item type\r\n *\r\n * @param templates A collection of AGO item templates\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n *\r\n * @private\r\n */\r\nexport function _updateTemplateDictionary(\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n return new Promise(resolve => {\r\n const defs: Array<Promise<any>> = [];\r\n const urls: string[] = [];\r\n const types: string[] = [];\r\n const ids: string[] = [];\r\n templates.forEach(t => {\r\n const templateInfo: any = templateDictionary[t.itemId];\r\n /* istanbul ignore else */\r\n if (templateInfo && templateInfo.url && templateInfo.itemId) {\r\n /* istanbul ignore else */\r\n if (t.item.type === \"Feature Service\") {\r\n const enterpriseIDMapping: any = common.getProp(\r\n templateDictionary,\r\n `params.${t.itemId}.enterpriseIDMapping`\r\n );\r\n Object.assign(\r\n templateDictionary[t.itemId],\r\n common.getLayerSettings(\r\n common.getLayersAndTables(t),\r\n templateInfo.url,\r\n templateInfo.itemId,\r\n enterpriseIDMapping\r\n )\r\n );\r\n\r\n // if the service has veiws keep track of the fields so we can use them to\r\n // compare with the view fields\r\n /* istanbul ignore else */\r\n if (common.getProp(t, \"properties.service.hasViews\")) {\r\n common._updateTemplateDictionaryFields(\r\n t,\r\n templateDictionary,\r\n false\r\n );\r\n }\r\n }\r\n\r\n // for fs query with its url...for non fs query the item\r\n // this is to verify situations where we have a stale search index that will\r\n // say some items exist when they don't really exist\r\n // searching the services url or with the item id will return an error when this condition occurs\r\n /* istanbul ignore else */\r\n if (urls.indexOf(templateInfo.url) < 0) {\r\n defs.push(\r\n t.item.type === \"Feature Service\"\r\n ? common.rest_request(templateInfo.url, { authentication })\r\n : common.getItemBase(templateInfo.itemId, authentication)\r\n );\r\n urls.push(templateInfo.url);\r\n types.push(t.item.type);\r\n ids.push(templateInfo.itemId);\r\n }\r\n }\r\n });\r\n\r\n if (defs.length > 0) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(defs.map(p => p.catch(e => e))).then(results => {\r\n /* istanbul ignore else */\r\n if (Array.isArray(results) && results.length > 0) {\r\n const fieldDefs: Array<Promise<any>> = [];\r\n results.forEach((r, i) => {\r\n // a feature service result will contain a serviceItemId if it was successfully fetched\r\n if (r.serviceItemId && types[i] === \"Feature Service\") {\r\n Object.keys(templateDictionary).forEach(k => {\r\n const v: any = templateDictionary[k];\r\n /* istanbul ignore else */\r\n if (v.itemId && v.itemId === r.serviceItemId) {\r\n common.setDefaultSpatialReference(\r\n templateDictionary,\r\n k,\r\n r.spatialReference\r\n );\r\n\r\n // keep the extent values from these responses as well\r\n common.setCreateProp(\r\n templateDictionary,\r\n `${k}.defaultExtent`,\r\n r.fullExtent || r.initialExtent\r\n );\r\n\r\n const layerIds: number[] = (r.layers || []).map(\r\n (l: any) => l.id\r\n );\r\n const tablesIds: number[] = (r.tables || []).map(\r\n (t: any) => t.id\r\n );\r\n fieldDefs.push(\r\n common.getExistingLayersAndTables(\r\n urls[i],\r\n layerIds.concat(tablesIds),\r\n authentication\r\n )\r\n );\r\n }\r\n });\r\n } else {\r\n /* istanbul ignore else */\r\n if (\r\n types[i] === \"Feature Service\" ||\r\n common.getProp(r, \"response.error\")\r\n ) {\r\n // if an error is returned we need to clean up the templateDictionary\r\n templateDictionary = _updateTemplateDictionaryForError(\r\n templateDictionary,\r\n ids[i]\r\n );\r\n }\r\n }\r\n });\r\n\r\n if (fieldDefs.length > 0) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all(fieldDefs).then(layerTableResult => {\r\n layerTableResult.forEach(l => {\r\n l.forEach((ll: any) => {\r\n Object.keys(templateDictionary).forEach(k => {\r\n /* istanbul ignore else */\r\n if (templateDictionary[k].itemId === ll.serviceItemId) {\r\n let sourceId: string = \"\";\r\n Object.keys(templateDictionary).some(_k => {\r\n /* istanbul ignore else */\r\n if (\r\n templateDictionary[_k].itemId === ll.serviceItemId\r\n ) {\r\n sourceId = _k;\r\n return true;\r\n }\r\n });\r\n const enterpriseIDMapping: any = common.getProp(\r\n templateDictionary,\r\n `params.${sourceId}.enterpriseIDMapping`\r\n );\r\n if (enterpriseIDMapping) {\r\n Object.keys(enterpriseIDMapping).forEach(id => {\r\n if (\r\n enterpriseIDMapping[id].toString() ===\r\n ll.id.toString()\r\n ) {\r\n _setFields(templateDictionary, k, id, ll.fields);\r\n }\r\n });\r\n } else {\r\n _setFields(templateDictionary, k, ll.id, ll.fields);\r\n }\r\n }\r\n });\r\n });\r\n });\r\n resolve(null);\r\n });\r\n } else {\r\n resolve(null);\r\n }\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n } else {\r\n resolve(null);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Add the fields from the source layer to the template dictionary for any required replacements\r\n *\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param itemId the id for the item\r\n * @param layerId the id for the layer\r\n * @param fields the fields to transfer\r\n *\r\n * @private\r\n */\r\nexport function _setFields(\r\n templateDictionary: any,\r\n itemId: string,\r\n layerId: string,\r\n fields: any[]\r\n): void {\r\n const layerInfo: any = common.getProp(\r\n templateDictionary,\r\n `${itemId}.layer${layerId}`\r\n );\r\n /* istanbul ignore else */\r\n if (layerInfo && fields) {\r\n layerInfo.fields = fields;\r\n }\r\n}\r\n\r\n/**\r\n * In some cases an item id search will return a stale item reference\r\n * it will subsequently fail when we try to fetch the underlying service.\r\n *\r\n * We need to remove the item info that has been added to the template dictionary\r\n * and treat the item as we do other items that don't already exist on deployment.\r\n *\r\n * @param result the service request result\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n *\r\n * @private\r\n */\r\nexport function _updateTemplateDictionaryForError(\r\n templateDictionary: any,\r\n itemId: string\r\n): any {\r\n /* istanbul ignore else */\r\n if (itemId) {\r\n let removeKey: string = \"\";\r\n Object.keys(templateDictionary).some(k => {\r\n /* istanbul ignore else */\r\n if (templateDictionary[k].itemId === itemId) {\r\n removeKey = k;\r\n return true;\r\n }\r\n });\r\n /* istanbul ignore else */\r\n if (removeKey !== \"\") {\r\n delete templateDictionary[removeKey];\r\n }\r\n }\r\n return templateDictionary;\r\n}\r\n\r\n/**\r\n * Optionally search by tags and then update the templateDictionary based on the search results\r\n *\r\n * @param existingItemsResponse response object from search by typeKeyword and type\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param authentication Credentials for the request\r\n * @param addTagQuery Boolean to indicate if a search by tag should happen\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _handleExistingItems(\r\n existingItemsResponse: any[],\r\n templateDictionary: any,\r\n authentication: common.UserSession,\r\n addTagQuery: boolean\r\n): Array<Promise<any>> {\r\n // if items are not found by type keyword search by tag\r\n const existingItemsByTag: Array<Promise<any>> = [Promise.resolve(null)];\r\n /* istanbul ignore else */\r\n if (existingItemsResponse && Array.isArray(existingItemsResponse)) {\r\n existingItemsResponse.forEach(existingItem => {\r\n /* istanbul ignore else */\r\n if (Array.isArray(existingItem?.results)) {\r\n let result: any;\r\n const results: any[] = existingItem.results;\r\n if (results.length === 1) {\r\n result = results[0];\r\n } else if (results.length > 1) {\r\n result = results.reduce((a: any, b: any) =>\r\n a.created > b.created ? a : b\r\n );\r\n } else {\r\n if (addTagQuery && existingItem.query) {\r\n const tagQuery: string = existingItem.query.replace(\r\n \"typekeywords\",\r\n \"tags\"\r\n );\r\n existingItemsByTag.push(\r\n _findExistingItem(tagQuery, authentication)\r\n );\r\n }\r\n }\r\n if (result) {\r\n const sourceId: any = existingItem.query\r\n ? existingItem.query.match(/[0-9A-F]{32}/i)[0]\r\n : existingItem.sourceId;\r\n /* istanbul ignore else */\r\n if (sourceId) {\r\n _updateTemplateDictionaryById(\r\n templateDictionary,\r\n sourceId,\r\n result.id,\r\n result\r\n );\r\n }\r\n }\r\n }\r\n });\r\n }\r\n return existingItemsByTag;\r\n}\r\n\r\n//???\r\nexport function _updateTemplateDictionaryById(\r\n templateDictionary: any,\r\n sourceId: string,\r\n itemId: string,\r\n v: any\r\n): void {\r\n templateDictionary[sourceId] = Object.assign(\r\n templateDictionary[sourceId] || {},\r\n {\r\n def: Promise.resolve(\r\n common.generateEmptyCreationResponse(v.type, itemId)\r\n ),\r\n itemId,\r\n name: v.name,\r\n title: v.title,\r\n url: v.url\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Search items based on user query\r\n *\r\n * @param query Query string to use\r\n * @param authentication Credentials for the request\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _findExistingItemByKeyword(\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Array<Promise<any>> {\r\n const existingItemsDefs: Array<Promise<any>> = [];\r\n templates.forEach(template => {\r\n if (template.item.type === \"Group\") {\r\n const userGroups: any = templateDictionary.user?.groups;\r\n /* istanbul ignore else */\r\n if (Array.isArray(userGroups)) {\r\n existingItemsDefs.push(\r\n Promise.resolve({\r\n results: userGroups\r\n .filter(g => g.tags.indexOf(`source-${template.itemId}`) > -1 || g.typeKeywords.indexOf(`source-${template.itemId}`) > -1)\r\n .map(g => {\r\n g.type = \"Group\";\r\n return g;\r\n }),\r\n sourceId: template.itemId\r\n })\r\n );\r\n }\r\n } else {\r\n existingItemsDefs.push(\r\n _findExistingItem(\r\n `typekeywords:source-${template.itemId} type:${template.item.type} owner:${templateDictionary.user.username}`,\r\n authentication\r\n )\r\n );\r\n }\r\n });\r\n return existingItemsDefs;\r\n}\r\n\r\n/**\r\n * Search items based on user query\r\n *\r\n * @param query Query string to use\r\n * @param authentication Credentials for the request\r\n * @returns A promise that will resolve with an array of results\r\n * @private\r\n */\r\nexport function _findExistingItem(\r\n query: string,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n const searchOptions = {\r\n q: query,\r\n authentication: authentication,\r\n pagingParam: { start: 1, num: 100 }\r\n };\r\n return common.searchItems(searchOptions);\r\n}\r\n\r\n/**\r\n * Creates an item from a template once the item's dependencies have been created.\r\n *\r\n * @param template Template of item to deploy\r\n * @param resourceFilePaths URL, folder, and filename for each item resource/metadata/thumbnail\r\n * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies\r\n * @param userSession Options for the request\r\n * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers\r\n * @returns A promise that will resolve with the id of the deployed item (which is simply returned if it's\r\n * already in the templates list\r\n * @private\r\n */\r\nexport function _createItemFromTemplateWhenReady(\r\n template: common.IItemTemplate,\r\n resourceFilePaths: common.IDeployFileCopyPath[],\r\n storageAuthentication: common.UserSession,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n // ensure this is present\r\n template.dependencies = template.dependencies || [];\r\n // if there is no entry in the templateDictionary\r\n // or if we have a basic entry without the deferred request for its creation, add it\r\n if (\r\n !templateDictionary.hasOwnProperty(template.itemId) ||\r\n !common.getProp(templateDictionary[template.itemId], \"def\")\r\n ) {\r\n let createResponse: common.ICreateItemFromTemplateResponse;\r\n let statusCode: common.EItemProgressStatus =\r\n common.EItemProgressStatus.Unknown;\r\n let itemHandler: common.IItemTemplateConversions;\r\n\r\n templateDictionary[template.itemId] =\r\n templateDictionary[template.itemId] || {};\r\n\r\n // Save the deferred for the use of items that depend on this item being created first\r\n templateDictionary[template.itemId].def = new Promise<\r\n common.ICreateItemFromTemplateResponse\r\n >(resolve => {\r\n // Wait until all of the item's dependencies are deployed\r\n const _awaitDependencies = template.dependencies.reduce(\r\n (acc: any[], id: string) => {\r\n const def = common.getProp(templateDictionary, `${id}.def`);\r\n // can't use maybePush as that clones the object, which does not work for Promises\r\n /* istanbul ignore else */\r\n if (def) {\r\n acc.push(def);\r\n }\r\n return acc;\r\n },\r\n []\r\n );\r\n\r\n const syncViews: string[] = common.getProp(\r\n template,\r\n \"properties.syncViews\"\r\n );\r\n\r\n const awaitDependencies =\r\n syncViews && syncViews.length > 0\r\n ? syncViews.reduce((acc: any[], v: any) => {\r\n const def = common.getProp(templateDictionary, `${v}.def`);\r\n /* istanbul ignore else */\r\n if (def) {\r\n acc.push(def);\r\n }\r\n return acc;\r\n }, _awaitDependencies)\r\n : _awaitDependencies;\r\n\r\n Promise.all(awaitDependencies)\r\n .then(() => {\r\n // Find the conversion handler for this item type\r\n const templateType = template.type;\r\n itemHandler = moduleMap[templateType];\r\n if (!itemHandler || itemHandler === UNSUPPORTED) {\r\n if (itemHandler === UNSUPPORTED) {\r\n statusCode = common.EItemProgressStatus.Ignored;\r\n throw new Error();\r\n } else {\r\n statusCode = common.EItemProgressStatus.Failed;\r\n throw new Error();\r\n }\r\n }\r\n\r\n // Get the item's thumbnail\r\n return common.getThumbnailFromStorageItem(\r\n storageAuthentication,\r\n resourceFilePaths\r\n );\r\n })\r\n .then(thumbnail => {\r\n template.item.thumbnail = thumbnail;\r\n\r\n // Delegate the creation of the item to the handler\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n return itemHandler.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n })\r\n .then((response: common.ICreateItemFromTemplateResponse) => {\r\n if (response.id === \"\") {\r\n statusCode = common.EItemProgressStatus.Failed;\r\n throw new Error(\"handled\"); // fails to create item\r\n }\r\n\r\n /* istanbul ignore else */\r\n createResponse = response;\r\n if (createResponse.item.item.url) {\r\n common.setCreateProp(\r\n templateDictionary,\r\n template.itemId + \".url\",\r\n createResponse.item.item.url\r\n );\r\n }\r\n\r\n if (resourceFilePaths.length > 0) {\r\n // Copy resources, metadata, form\r\n return common.copyFilesFromStorageItem(\r\n storageAuthentication,\r\n resourceFilePaths,\r\n templateDictionary.folderId,\r\n createResponse.id,\r\n destinationAuthentication,\r\n createResponse.item\r\n );\r\n } else {\r\n return Promise.resolve(null);\r\n }\r\n })\r\n .then(() => {\r\n resolve(createResponse);\r\n })\r\n .catch(error => {\r\n if (!error || error.message !== \"handled\") {\r\n itemProgressCallback(\r\n template.itemId,\r\n statusCode === common.EItemProgressStatus.Unknown\r\n ? common.EItemProgressStatus.Failed\r\n : statusCode,\r\n 0\r\n );\r\n }\r\n\r\n // Item type not supported or fails to get item dependencies\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n });\r\n });\r\n }\r\n return templateDictionary[template.itemId].def;\r\n}\r\n\r\n/**\r\n * Accumulates the estimated deployment cost of a set of templates.\r\n *\r\n * @param templates Templates to examine\r\n * @returns Sum of estimated deployment costs\r\n * @private\r\n */\r\nexport function _estimateDeploymentCost(\r\n templates: common.IItemTemplate[]\r\n): number {\r\n return templates.reduce(\r\n (accumulatedEstimatedCost: number, template: common.IItemTemplate) => {\r\n return (\r\n accumulatedEstimatedCost + (template.estimatedDeploymentCostFactor || 1)\r\n );\r\n },\r\n 0\r\n );\r\n}\r\n\r\n//???\r\n// TODO: Return a Promise vs array of promises\r\nexport function _getGroupUpdates(\r\n template: common.IItemTemplate,\r\n authentication: common.UserSession,\r\n templateDictionary: any\r\n): Array<Promise<any>> {\r\n const groups = template.groups || [];\r\n return groups.map((sourceGroupId: string) => {\r\n return common.shareItem(\r\n templateDictionary[sourceGroupId].itemId,\r\n template.itemId,\r\n authentication,\r\n common.isTrackingViewTemplate(template) ? templateDictionary.locationTracking.owner : undefined\r\n );\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 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\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n ICreateItemFromTemplateResponse,\r\n getTemplateById\r\n} from \"@esri/solution-common\";\r\nimport { addItemRelationship } from \"@esri/arcgis-rest-portal\";\r\nimport { moduleMap } from \"../module-map\";\r\nimport { shareTemplatesToGroups } from \"./share-templates-to-groups\";\r\n\r\n/**\r\n * Delegate post-processing to the type specific\r\n * processors. This allows each type to have fine-grained\r\n * control over what they do. Common post-processing is\r\n * exposed as functions that can be imported\r\n *\r\n * @param deployedSolutionId\r\n * @param templates\r\n * @param clonedSolutions\r\n * @param authentication\r\n * @param templateDictionary\r\n */\r\nexport function postProcess(\r\n deployedSolutionId: string,\r\n templates: IItemTemplate[],\r\n clonedSolutions: ICreateItemFromTemplateResponse[],\r\n authentication: UserSession,\r\n templateDictionary: any\r\n): Promise<any> {\r\n // connect the solution with its items; groups cannot be connected\r\n const relationshipPromises = clonedSolutions\r\n .filter(entry => entry.type !== \"Group\")\r\n .map(\r\n entry =>\r\n addItemRelationship({\r\n originItemId: deployedSolutionId,\r\n destinationItemId: entry.id,\r\n relationshipType: \"Solution2Item\",\r\n authentication: authentication\r\n } as any) // TODO: remove `as any`, which is here until arcgis-rest-js' ItemRelationshipType defn catches up\r\n );\r\n\r\n // delegate sharing to groups\r\n const sharePromises = shareTemplatesToGroups(\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n // what needs post processing?\r\n const itemsToProcess = clonedSolutions.filter(entry => entry.postProcess);\r\n\r\n // map over these items\r\n const postProcessPromises = itemsToProcess.reduce((acc, entry) => {\r\n const itemHandler: any = moduleMap[entry.type];\r\n // only delegate if the handler has a postProcess method\r\n if (itemHandler && itemHandler.postProcess) {\r\n acc.push(\r\n itemHandler.postProcess(\r\n entry.id,\r\n entry.type,\r\n clonedSolutions,\r\n getTemplateById(templates, entry.id),\r\n templates,\r\n templateDictionary,\r\n authentication\r\n )\r\n );\r\n }\r\n return acc;\r\n }, []);\r\n\r\n return Promise.all(\r\n [sharePromises].concat(postProcessPromises, relationshipPromises)\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 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\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getProp,\r\n shareItemToGroups,\r\n isTrackingViewTemplate,\r\n replaceInTemplate\r\n} from \"@esri/solution-common\";\r\nimport { maybePush } from \"@esri/hub-common\";\r\n\r\n/**\r\n * Given the created templates\r\n *\r\n * @param templates\r\n * @param templateDictionary\r\n * @param authentication\r\n */\r\nexport function shareTemplatesToGroups(\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n // Filter to entries with groups to share to\r\n const templatesWithGroups = templates.filter(e => {\r\n return e.groups && e.groups.length > 0;\r\n });\r\n // fire off all the promises\r\n return Promise.all(\r\n templatesWithGroups.map(tmpl => {\r\n const groupIds = tmpl.groups.reduce((acc, sourceGroupId) => {\r\n return maybePush(\r\n getProp(templateDictionary, `${sourceGroupId}.itemId`),\r\n acc\r\n );\r\n }, []);\r\n // need to pass the tracking owner when sharing to tracking group\r\n if (isTrackingViewTemplate(tmpl) && !getProp(templateDictionary, \"locationTracking.userIsOwner\")) {\r\n const trackingGroupId = getProp(tmpl, \"item.properties.trackViewGroup\");\r\n const owner = getProp(templateDictionary, \"locationTracking.owner\");\r\n /* istanbul ignore else */\r\n if (trackingGroupId && owner) {\r\n const trackerGroupIds = groupIds.filter(id => {\r\n return id === replaceInTemplate(trackingGroupId, templateDictionary);\r\n });\r\n if (trackerGroupIds.length !== groupIds.length) {\r\n const nonTrackerGroupIds = groupIds.filter(id => id !== trackingGroupId)\r\n return Promise.all([\r\n shareItemToGroups(trackerGroupIds, tmpl.itemId, authentication, owner),\r\n shareItemToGroups(nonTrackerGroupIds, tmpl.itemId, authentication)\r\n ])\r\n } else {\r\n return shareItemToGroups(groupIds, tmpl.itemId, authentication, owner);\r\n }\r\n }\r\n } else {\r\n return shareItemToGroups(groupIds, tmpl.itemId, authentication);\r\n }\r\n })\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 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 * as common from \"@esri/solution-common\";\r\nimport * as deployItems from \"./deploySolutionItems\";\r\nimport { getWithDefault } from \"@esri/hub-common\";\r\nimport * as portal from \"@esri/arcgis-rest-portal\";\r\nimport { postProcess } from \"./helpers/post-process\";\r\nimport { sortTemplates } from \"./helpers/sortTemplates\";\r\nimport { setCreateProp } from \"@esri/solution-common\";\r\n\r\n// NOTE: Moved to separate file to allow stubbing in main deploySolution tests\r\n\r\nexport function deploySolutionFromTemplate(\r\n templateSolutionId: string,\r\n solutionTemplateBase: any,\r\n solutionTemplateData: any,\r\n authentication: common.UserSession,\r\n options: common.IDeploySolutionOptions\r\n): Promise<string> {\r\n options.storageVersion = common.extractSolutionVersion(solutionTemplateData);\r\n\r\n return new Promise((resolve, reject) => {\r\n // It is possible to provide a separate authentication for the source\r\n const storageAuthentication: common.UserSession = options.storageAuthentication\r\n ? options.storageAuthentication\r\n : authentication;\r\n\r\n // Replacement dictionary and high-level deployment ids for cleanup\r\n\r\n // TODO: Extract all templateDictionary prep into a separate function\r\n const templateDictionary = options.templateDictionary ?? {};\r\n let deployedFolderId: string;\r\n let deployedSolutionId: string;\r\n\r\n _applySourceToDeployOptions(\r\n options,\r\n solutionTemplateBase,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n if (options.additionalTypeKeywords) {\r\n solutionTemplateBase.typeKeywords = [].concat(\r\n solutionTemplateBase.typeKeywords,\r\n options.additionalTypeKeywords\r\n );\r\n }\r\n\r\n // Get the thumbnail file\r\n let thumbFilename = \"thumbnail\";\r\n let thumbDef = Promise.resolve(null);\r\n if (!options.thumbnail && options.thumbnailurl) {\r\n // Figure out the thumbnail's filename\r\n thumbFilename =\r\n common.getFilenameFromUrl(options.thumbnailurl) || thumbFilename;\r\n const thumbnailurl = common.appendQueryParam(\r\n options.thumbnailurl,\r\n \"w=400\"\r\n );\r\n delete options.thumbnailurl;\r\n\r\n // Fetch the thumbnail\r\n thumbDef = common.getBlobAsFile(\r\n thumbnailurl,\r\n thumbFilename,\r\n storageAuthentication,\r\n [400]\r\n );\r\n }\r\n\r\n _replaceParamVariables(solutionTemplateData, templateDictionary);\r\n\r\n // Get information about deployment environment\r\n Promise.all([\r\n common.getPortal(\"\", authentication), // determine if we are deploying to portal\r\n common.getUser(authentication), // find out about the user\r\n common.getFoldersAndGroups(authentication), // get all folders so that we can create a unique one, and all groups\r\n thumbDef\r\n ])\r\n .then(responses => {\r\n const [\r\n portalResponse,\r\n userResponse,\r\n foldersAndGroupsResponse,\r\n thumbnailFile\r\n ] = responses;\r\n if (!options.thumbnail && thumbnailFile) {\r\n options.thumbnail = thumbnailFile;\r\n }\r\n\r\n // update template items with source-itemId type keyword\r\n solutionTemplateData.templates = _addSourceId(solutionTemplateData.templates);\r\n\r\n templateDictionary.isPortal = portalResponse.isPortal;\r\n templateDictionary.organization = Object.assign(\r\n templateDictionary.organization || {},\r\n portalResponse\r\n );\r\n // TODO: Add more computed properties here\r\n // portal: portalResponse\r\n // orgextent as bbox for assignment onto items\r\n // more info in #266 https://github.com/Esri/solution.js/issues/266\r\n\r\n templateDictionary.portalBaseUrl = _getPortalBaseUrl(\r\n portalResponse,\r\n authentication\r\n );\r\n\r\n templateDictionary.user = userResponse;\r\n templateDictionary.user.folders = foldersAndGroupsResponse.folders;\r\n templateDictionary.user.groups = foldersAndGroupsResponse.groups.filter(\r\n (group: common.IGroup) =>\r\n group.owner === templateDictionary.user.username\r\n );\r\n\r\n // if we have tracking views and the user is not admin or the org doesn't support tracking an error is thrown\r\n common.setLocationTrackingEnabled(\r\n portalResponse,\r\n userResponse,\r\n templateDictionary,\r\n solutionTemplateData.templates\r\n );\r\n const trackingOwnerPromise = common.getTackingServiceOwner(\r\n templateDictionary,\r\n authentication\r\n )\r\n\r\n // Create a folder to hold the deployed solution. We use the solution name, appending a sequential\r\n // suffix if the folder exists, e.g.,\r\n // * Manage Right of Way Activities\r\n // * Manage Right of Way Activities 1\r\n // * Manage Right of Way Activities 2\r\n const folderPromise = common.createUniqueFolder(\r\n solutionTemplateBase.title,\r\n templateDictionary,\r\n authentication\r\n );\r\n\r\n // Apply the portal extents to the solution\r\n const portalExtent: any = portalResponse.defaultExtent;\r\n const extentsPromise = common.convertExtentWithFallback(\r\n portalExtent,\r\n undefined,\r\n { wkid: 4326 },\r\n portalResponse.helperServices.geometry.url,\r\n authentication\r\n );\r\n\r\n // Await completion of async actions: folder creation & extents conversion\r\n return Promise.all([folderPromise, extentsPromise, trackingOwnerPromise]);\r\n })\r\n .then(responses => {\r\n const [folderResponse, wgs84Extent, trackingOwnerResponse] = responses;\r\n deployedFolderId = folderResponse.folder.id;\r\n templateDictionary.folderId = deployedFolderId;\r\n templateDictionary.solutionItemExtent =\r\n wgs84Extent.xmin +\r\n \",\" +\r\n wgs84Extent.ymin +\r\n \",\" +\r\n wgs84Extent.xmax +\r\n \",\" +\r\n wgs84Extent.ymax;\r\n // Hub Solutions depend on organization defaultExtentBBox as a nested array not a string\r\n templateDictionary.organization.defaultExtentBBox = [\r\n [wgs84Extent.xmin, wgs84Extent.ymin],\r\n [wgs84Extent.xmax, wgs84Extent.ymax]\r\n ];\r\n\r\n // update templateDictionary to indicate if the user owns the tracking service\r\n // this will affect how we handle group sharing\r\n /* istanbul ignore else */\r\n if (templateDictionary.locationTrackingEnabled) {\r\n setCreateProp(\r\n templateDictionary,\r\n \"locationTracking.userIsOwner\",\r\n trackingOwnerResponse\r\n );\r\n }\r\n\r\n // Create a deployed Solution item\r\n const createSolutionItemBase = {\r\n ...common.sanitizeJSONAndReportChanges(solutionTemplateBase),\r\n type: \"Solution\",\r\n typeKeywords: [\"Solution\"]\r\n };\r\n\r\n if (options.additionalTypeKeywords) {\r\n createSolutionItemBase.typeKeywords = [\"Solution\"].concat(\r\n options.additionalTypeKeywords\r\n );\r\n }\r\n\r\n // Create deployed solution item\r\n createSolutionItemBase.thumbnail = options.thumbnail;\r\n return common.createItemWithData(\r\n createSolutionItemBase,\r\n {},\r\n authentication,\r\n deployedFolderId\r\n );\r\n })\r\n .then(createSolutionResponse => {\r\n deployedSolutionId = createSolutionResponse.id;\r\n\r\n // Protect the solution item\r\n const protectOptions: portal.IUserItemOptions = {\r\n id: deployedSolutionId,\r\n authentication\r\n };\r\n return portal.protectItem(protectOptions);\r\n })\r\n .then(() => {\r\n // TODO: Attach the whole solution model so we can\r\n // have stuff like `{{solution.item.title}}\r\n templateDictionary.solutionItemId = deployedSolutionId;\r\n solutionTemplateBase.id = deployedSolutionId;\r\n\r\n solutionTemplateBase.tryitUrl = _checkedReplaceAll(\r\n solutionTemplateBase.tryitUrl,\r\n templateSolutionId,\r\n deployedSolutionId\r\n );\r\n solutionTemplateBase.url = _checkedReplaceAll(\r\n solutionTemplateBase.url,\r\n templateSolutionId,\r\n deployedSolutionId\r\n );\r\n\r\n // Handle the contained item templates\r\n return deployItems.deploySolutionItems(\r\n storageAuthentication.portal,\r\n templateSolutionId,\r\n solutionTemplateData.templates,\r\n storageAuthentication,\r\n templateDictionary,\r\n deployedSolutionId,\r\n authentication,\r\n options\r\n );\r\n })\r\n .then(\r\n (clonedSolutionsResponse: common.ICreateItemFromTemplateResponse[]) => {\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (itemTemplate: common.IItemTemplate) => {\r\n // Update ids present in template dictionary\r\n itemTemplate.itemId = common.getProp(\r\n templateDictionary,\r\n `${itemTemplate.itemId}.itemId`\r\n );\r\n\r\n // Update the dependencies hash to point to the new item ids\r\n itemTemplate.dependencies = itemTemplate.dependencies.map(\r\n (id: string) =>\r\n getWithDefault(templateDictionary, `${id}.itemId`, id)\r\n );\r\n return itemTemplate;\r\n }\r\n );\r\n\r\n // Sort the templates into build order, which is provided by clonedSolutionsResponse\r\n sortTemplates(\r\n solutionTemplateData.templates,\r\n clonedSolutionsResponse.map(response => response.id)\r\n );\r\n\r\n // Wrap up with post-processing, in which we deal with groups and cycle remnants\r\n return postProcess(\r\n deployedSolutionId,\r\n solutionTemplateData.templates,\r\n clonedSolutionsResponse,\r\n authentication,\r\n templateDictionary\r\n );\r\n }\r\n )\r\n .then(() => {\r\n // Update solution item using internal representation & and the updated data JSON\r\n solutionTemplateBase.typeKeywords = [].concat(\r\n solutionTemplateBase.typeKeywords,\r\n [\"Deployed\"]\r\n );\r\n const iTemplateKeyword = solutionTemplateBase.typeKeywords.indexOf(\r\n \"Template\"\r\n );\r\n /* istanbul ignore else */\r\n if (iTemplateKeyword >= 0) {\r\n solutionTemplateBase.typeKeywords.splice(iTemplateKeyword, 1);\r\n }\r\n\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (itemTemplate: common.IItemTemplate) =>\r\n _purgeTemplateProperties(itemTemplate)\r\n );\r\n\r\n solutionTemplateData.templates = _updateGroupReferences(\r\n solutionTemplateData.templates,\r\n templateDictionary\r\n );\r\n\r\n // Update solution items data using template dictionary, and then update the\r\n // itemId & dependencies in each item template\r\n solutionTemplateBase.data = common.replaceInTemplate(\r\n solutionTemplateData,\r\n templateDictionary\r\n );\r\n\r\n // Write any user defined params to the solution\r\n /* istanbul ignore else */\r\n if (templateDictionary.params) {\r\n solutionTemplateBase.data.params = templateDictionary.params;\r\n }\r\n\r\n return common.updateItem(\r\n solutionTemplateBase,\r\n authentication,\r\n deployedFolderId\r\n );\r\n })\r\n .then(() => resolve(solutionTemplateBase.id), reject);\r\n });\r\n}\r\n\r\n/**\r\n * Add source-id to items/groups typeKeywords\r\n *\r\n * @param template the array of solution data templates\r\n * @private\r\n */\r\nexport function _addSourceId(\r\n templates: common.IItemTemplate[]\r\n): common.IItemTemplate[] {\r\n return templates.map(\r\n (template: any) => {\r\n /* istanbul ignore else */\r\n if (template.item) {\r\n const typeKeywords = template.item!.typeKeywords || [];\r\n typeKeywords.push(\"source-\" + template.itemId);\r\n template.item.typeKeywords = typeKeywords;\r\n }\r\n return template;\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Update the deployOptions with the group properties\r\n *\r\n * @param deployOptions\r\n * @param sourceInfo\r\n * @param authentication\r\n * @param isGroup Boolean to indicate if the files are associated with a group or item\r\n * @private\r\n */\r\nexport function _applySourceToDeployOptions(\r\n deployOptions: common.IDeploySolutionOptions,\r\n solutionTemplateBase: any,\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): common.IDeploySolutionOptions {\r\n // Deploy a solution from the template's contents,\r\n // using the template's information as defaults for the deployed solution item\r\n [\"title\", \"snippet\", \"description\", \"tags\"].forEach(prop => {\r\n deployOptions[prop] = deployOptions[prop] ?? solutionTemplateBase[prop];\r\n if (deployOptions[prop]) {\r\n solutionTemplateBase[prop] = deployOptions[prop];\r\n // carry these options forward on the templateDict\r\n templateDictionary[prop] = deployOptions[prop];\r\n }\r\n });\r\n\r\n if (!deployOptions.thumbnailurl && solutionTemplateBase.thumbnail) {\r\n // Get the full path to the thumbnail\r\n deployOptions.thumbnailurl = common.generateSourceThumbnailUrl(\r\n authentication.portal,\r\n solutionTemplateBase.id,\r\n solutionTemplateBase.thumbnail\r\n );\r\n delete solutionTemplateBase.thumbnail;\r\n }\r\n\r\n return deployOptions;\r\n}\r\n\r\n//???\r\nexport function _replaceParamVariables(\r\n solutionTemplateData: any,\r\n templateDictionary: any\r\n): void {\r\n // a custom params object can be passed in with the options to deploy a solution\r\n // in most cases we can defer to the item type handlers to use these values\r\n // for variable replacement\r\n // for spatial reference specifically we need to replace up front so the default extent\r\n // logic can execute as expected\r\n solutionTemplateData.templates = solutionTemplateData.templates.map(\r\n (template: common.IItemTemplate) => {\r\n // can't do this as it causes other values that don't exist in the dict yet to revert to defaults they may have defined\r\n // return common.replaceInTemplate(template, templateDictionary);\r\n /* istanbul ignore else */\r\n if (template.type === \"Feature Service\") {\r\n const paramsLookup: string = \"params.\";\r\n\r\n const wkidItemPath: string = \"item.spatialReference.wkid\";\r\n template = _updateProp(\r\n template,\r\n wkidItemPath,\r\n paramsLookup,\r\n templateDictionary\r\n );\r\n\r\n const wkidServicePath: string =\r\n \"properties.service.spatialReference.wkid\";\r\n template = _updateProp(\r\n template,\r\n wkidServicePath,\r\n paramsLookup,\r\n templateDictionary\r\n );\r\n }\r\n return template;\r\n }\r\n );\r\n}\r\n\r\n//???\r\nexport function _updateProp(\r\n template: common.IItemTemplate,\r\n path: string,\r\n lookup: string,\r\n templateDictionary: any\r\n): common.IItemTemplate {\r\n const wkid: any = common.getProp(template, path);\r\n /* istanbul ignore else */\r\n if (wkid && typeof wkid === \"string\" && wkid.indexOf(lookup) > -1) {\r\n common.setProp(\r\n template,\r\n path,\r\n common.replaceInTemplate(wkid, templateDictionary)\r\n );\r\n }\r\n return template;\r\n}\r\n\r\n//???\r\nexport function _checkedReplaceAll(\r\n template: string,\r\n oldValue: string,\r\n newValue: string\r\n): string {\r\n let newTemplate;\r\n if (template && template.indexOf(oldValue) > -1) {\r\n const re = new RegExp(oldValue, \"g\");\r\n newTemplate = template.replace(re, newValue);\r\n } else {\r\n newTemplate = template;\r\n }\r\n return newTemplate;\r\n}\r\n\r\n//???\r\nexport function _getPortalBaseUrl(\r\n portalResponse: common.IPortal,\r\n authentication: common.UserSession\r\n): string {\r\n // As of Spring 2020, only HTTPS (see\r\n // https://www.esri.com/arcgis-blog/products/product/administration/2019-arcgis-transport-security-improvements/)\r\n const scheme: string = \"https\"; // portalResponse.allSSL ? \"https\" : \"http\";\r\n const urlKey: string = common.getProp(portalResponse, \"urlKey\");\r\n const customBaseUrl: string = common.getProp(portalResponse, \"customBaseUrl\");\r\n const enterpriseBaseUrl = common.getProp(portalResponse, \"portalHostname\");\r\n\r\n return urlKey && customBaseUrl\r\n ? `${scheme}://${urlKey}.${customBaseUrl}`\r\n : enterpriseBaseUrl\r\n ? `${scheme}://${enterpriseBaseUrl}`\r\n : authentication.portal.replace(\"/sharing/rest\", \"\");\r\n}\r\n\r\n//???\r\nexport function _updateGroupReferences(\r\n itemTemplates: any[],\r\n templateDictionary: any\r\n): any[] {\r\n const groupIds = itemTemplates.reduce(\r\n (result: string[], t: common.IItemTemplate) => {\r\n if (t.type === \"Group\") {\r\n result.push(t.itemId);\r\n }\r\n return result;\r\n },\r\n []\r\n );\r\n\r\n Object.keys(templateDictionary).forEach(k => {\r\n const newId: string = templateDictionary[k].itemId;\r\n if (groupIds.indexOf(newId) > -1) {\r\n itemTemplates.forEach(t => {\r\n t.groups = t.groups.map((id: string) => (id === k ? newId : id));\r\n });\r\n }\r\n });\r\n return itemTemplates;\r\n}\r\n\r\n//???\r\nexport function _purgeTemplateProperties(itemTemplate: any): any {\r\n const retainProps: string[] = [\"itemId\", \"type\", \"dependencies\", \"groups\"];\r\n const deleteProps: string[] = Object.keys(itemTemplate).filter(\r\n k => retainProps.indexOf(k) < 0\r\n );\r\n common.deleteProps(itemTemplate, deleteProps);\r\n return itemTemplate;\r\n}\r\n\r\n/**\r\n * Returns a match of a supplied id with the suffix \".itemId\" in the template dictionary.\r\n *\r\n * @param id Id to look for\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @returns Match in template dictionary or original id\r\n */\r\nexport function _getNewItemId(id: string, templateDictionary: any): string {\r\n return common.getProp(templateDictionary, id + \".itemId\") ?? id;\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\nimport { IItemTemplate } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Sorts a list of templates in place to match a provided sort-order list.\r\n *\r\n * @param templates List of templates in a Solution\r\n * @param sortOrderIds List of template ids in the desired sort order\r\n */\r\nexport function sortTemplates(\r\n templates: IItemTemplate[],\r\n sortOrderIds: string[]\r\n): void {\r\n templates.sort(\r\n (template1: IItemTemplate, template2: IItemTemplate) =>\r\n sortOrderIds.indexOf(template1.itemId) -\r\n sortOrderIds.indexOf(template2.itemId)\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 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 * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Given an itemId or an object, either fetch the item or\r\n * resolve using the object, if it is structured as expected\r\n *\r\n * @param idOrObject string || object like `{item:{...}, data: {...}}`\r\n * @param authentication UserSession\r\n */\r\nexport function getSolutionTemplateItem(\r\n idOrObject: any,\r\n authentication: common.UserSession\r\n): Promise<any> {\r\n if (typeof idOrObject === \"string\") {\r\n // get the item + data\r\n return Promise.all([\r\n common.getItemBase(idOrObject, authentication),\r\n common.getItemDataAsJson(idOrObject, authentication)\r\n ]).then(([item, data]) => {\r\n // format into a model and migrate the schema\r\n return common.migrateSchema({\r\n item,\r\n data\r\n });\r\n });\r\n } else {\r\n // check if it is a \"Model\"\r\n if (_isModel(idOrObject)) {\r\n // run migrations\r\n return common.migrateSchema(idOrObject);\r\n } else {\r\n return Promise.reject(\r\n common.fail(\r\n `getSolutionTemplateItem must be passed an item id or a model object`\r\n )\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Update the Deploy Options with information from the\r\n * Solution Template item\r\n *\r\n * @param deployOptions\r\n * @param item\r\n * @param authentication\r\n */\r\nexport function updateDeployOptions(\r\n deployOptions: any,\r\n item: common.IItem,\r\n authentication: common.UserSession\r\n): any {\r\n deployOptions.jobId = deployOptions.jobId ?? item.id;\r\n deployOptions.title = deployOptions.title ?? item.title;\r\n deployOptions.snippet = deployOptions.snippet ?? item.snippet;\r\n deployOptions.description = deployOptions.description ?? item.description;\r\n deployOptions.tags = deployOptions.tags ?? item.tags;\r\n // add the thumbnail url\r\n deployOptions.thumbnailurl = item.thumbnail\r\n ? common.getItemThumbnailUrl(item.id, item.thumbnail, false, authentication)\r\n : null;\r\n\r\n return deployOptions;\r\n}\r\n\r\n/**\r\n * Check if an object is an Model\r\n *\r\n * @param obj any object\r\n * @private\r\n */\r\nexport function _isModel(obj: any): boolean {\r\n let result = false as boolean;\r\n // TODO Hoist into common?\r\n const isNotStringOrArray = (v: any): boolean =>\r\n v != null &&\r\n typeof v !== \"string\" &&\r\n !Array.isArray(v) &&\r\n typeof v === \"object\";\r\n\r\n if (isNotStringOrArray(obj)) {\r\n result = [\"item\", \"data\"].reduce((acc, prop) => {\r\n if (acc) {\r\n acc = isNotStringOrArray(obj[prop]);\r\n }\r\n return acc;\r\n }, true as boolean);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Does the item have the correct type and keywords\r\n * to be a Solution Template item?\r\n *\r\n * @param item IItem\r\n */\r\nexport function isSolutionTemplateItem(item: common.IItem): boolean {\r\n const kwds = item.typeKeywords;\r\n // Solution items\r\n let result = false;\r\n if (item.type === \"Solution\") {\r\n if (\r\n kwds.indexOf(\"Solution\") > -1 &&\r\n (kwds.indexOf(\"Template\") > -1 || kwds.indexOf(\"solutionTemplate\") > -1)\r\n ) {\r\n result = true;\r\n }\r\n }\r\n // Older Hub Solutions used Web Mapping Application items\r\n if (item.type === \"Web Mapping Application\") {\r\n if (kwds.indexOf(\"hubSolutionTemplate\") > -1) {\r\n result = true;\r\n }\r\n }\r\n return result;\r\n}\r\n","/** @license\r\n * Copyright 2018 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 deployment of a Solution.\r\n *\r\n * @module deployer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\nimport { deploySolutionFromTemplate } from \"./deploySolutionFromTemplate\";\r\nimport {\r\n getSolutionTemplateItem,\r\n isSolutionTemplateItem,\r\n updateDeployOptions\r\n} from \"./deployerUtils\";\r\nimport { IModel } from \"@esri/hub-common\";\r\n\r\n/**\r\n * Deploy a Solution\r\n *\r\n * Pass in either the item id or an IModel (`{item:{}, model:{}}`)\r\n * of a Solution Template, and this will generate the Solution\r\n *\r\n * @param maybeModel Item Id or IModel\r\n * @param authentication Credentials for the destination organization\r\n * @param options Options to override deployed information and to provide additional credentials\r\n * @returns The id of the created deployed solution item\r\n */\r\nexport function deploySolution(\r\n maybeModel: string | IModel,\r\n authentication: common.UserSession,\r\n options?: common.IDeploySolutionOptions\r\n): Promise<string> {\r\n // if we are not passed the maybeModel, reject\r\n if (!maybeModel) {\r\n return Promise.reject(common.fail(\"The Solution Template id is missing\"));\r\n }\r\n let deployOptions: common.IDeploySolutionOptions = options || {};\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(1, deployOptions.jobId); // let the caller know that we've started\r\n }\r\n\r\n // It is possible to provide a separate authentication for the source\r\n const storageAuthentication: common.UserSession = deployOptions.storageAuthentication\r\n ? deployOptions.storageAuthentication\r\n : authentication;\r\n\r\n // deal with maybe getting an item or an id\r\n return getSolutionTemplateItem(maybeModel, storageAuthentication)\r\n .then(model => {\r\n if (!isSolutionTemplateItem(model.item)) {\r\n return Promise.reject(\r\n common.fail(`${model.item.id} is not a Solution Template`)\r\n );\r\n } else {\r\n // fetch the metadata if the model's id is a GUID and pass the item & data forward\r\n return Promise.all([\r\n Promise.resolve(model.item),\r\n Promise.resolve(model.data)\r\n ]);\r\n }\r\n })\r\n .then(responses => {\r\n // extract responses\r\n const [itemBase, itemData] = responses;\r\n // sanitize all the things\r\n const sanitizer = new common.Sanitizer();\r\n const item = common.sanitizeJSONAndReportChanges(itemBase, sanitizer);\r\n // TODO: we should delegate data sanization to the type-specific modules\r\n const data = itemData;\r\n // get the item id before it is deleted\r\n const itemId = item.id;\r\n // apply item props to deployOptions\r\n deployOptions = updateDeployOptions(\r\n deployOptions,\r\n item,\r\n storageAuthentication\r\n );\r\n // Clone before mutating? This was messing me up in some testing...\r\n common.deleteItemProps(item);\r\n\r\n return deploySolutionFromTemplate(\r\n itemId,\r\n item,\r\n data,\r\n authentication,\r\n deployOptions\r\n );\r\n })\r\n .then(\r\n createdSolutionId => {\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(100, deployOptions.jobId); // we're done\r\n }\r\n return createdSolutionId;\r\n },\r\n error => {\r\n // Error deploying solution\r\n /* istanbul ignore else */\r\n if (deployOptions.progressCallback) {\r\n deployOptions.progressCallback(1, deployOptions.jobId);\r\n }\r\n return Promise.reject(error);\r\n }\r\n )\r\n .catch(ex => {\r\n throw ex;\r\n });\r\n}\r\n"],"names":["UNSUPPORTED","moduleMap","Group","group","VelocityProcessor","simpleTypes","featureLayer","Feed","undefined","KML","Tool","WFS","WMS","WMTS","Application","Dashboard","Form","formProcessor","HubPageProcessor","HubSiteProcessor","Mission","Notebook","notebookProcessor","quickcaptureProcessor","Solution","StoryMap","StoryMapProcessor","WebExperienceProcessor","fileProcessor","CSV","GeoJson","GeoPackage","Image","Layer","Layout","netCDF","PDF","Shapefile","Style","Undefined","Unsupported","deploySolutionItems","portalSharingUrl","storageItemId","templates","storageAuthentication","templateDictionary","deployedSolutionId","destinationAuthentication","options","Promise","resolve","reject","totalEstimatedCost","_estimateDeploymentCost","percentDone","progressPercentStep","failedTemplateItemIds","deployedItemIds","statusOK","itemProgressCallback","itemId","status","costUsed","createdItemId","progressCallback","common","EItemProgressStatus","Finished","event","SItemProgressStatus","data","Math","round","jobId","consoleProgress","console","log","Date","now","toFixed","Created","push","Failed","error","getProp","_evaluateSharedViewSources","buildOrder","itemsToBePatched","topologicallySortItems","awaitAllItems","_reuseDeployedItems","enableItemReuse","then","_useExistingItems","setNamesAndTitles","solutionItemId","forEach","id","template","findTemplateInList","_createItemFromTemplateWhenReady","generateStorageFilePaths","resources","storageVersion","all","clonedSolutionItems","length","_flagPatchItemsForPostProcessing","progressOptions","deleteSolutionByComponents","failWithIds","e","fail","itemIdsToBePatched","Object","keys","map","item","includes","postProcess","views","_getViews","_updateViewTemplates","viewHash","_getViewHash","processed","visited","k","cv","syncViews","indexOf","concat","setProp","cloneObject","v","dependencies","t","Array","isArray","properties","d","reduce","acc","reuseItems","authentication","existingItemsByKeyword","_findExistingItemByKeyword","existingItemsByKeywordResponse","existingItemsByTag","_handleExistingItems","existingItemsByTagResponse","_updateTemplateDictionary","useExisting","itemDefs","sourceIdHash","itemIds","params","test","_updateTemplateDictionaryById","getItemBase","_setTypekeywordForExisting","getTemplateById","results","itemUpdateDefs","result","sourceId","typeKeywords","sourceKeyword","itemUpdate","updateItem","defs","urls","types","ids","templateInfo","url","type","enterpriseIDMapping","assign","getLayerSettings","getLayersAndTables","_updateTemplateDictionaryFields","rest_request","p","catch","fieldDefs","r","i","serviceItemId","setDefaultSpatialReference","spatialReference","setCreateProp","fullExtent","initialExtent","layerIds","layers","l","tablesIds","tables","getExistingLayersAndTables","_updateTemplateDictionaryForError","layerTableResult","ll","some","_k","toString","_setFields","fields","layerId","layerInfo","removeKey","existingItemsResponse","addTagQuery","existingItem","a","b","created","query","tagQuery","replace","_findExistingItem","match","def","generateEmptyCreationResponse","name","title","existingItemsDefs","userGroups","user","groups","filter","g","tags","username","searchOptions","q","pagingParam","start","num","searchItems","resourceFilePaths","hasOwnProperty","createResponse","itemHandler","statusCode","Unknown","_awaitDependencies","awaitDependencies","templateType","Ignored","Error","getThumbnailFromStorageItem","thumbnail","createItemFromTemplate","response","copyFilesFromStorageItem","folderId","message","accumulatedEstimatedCost","estimatedDeploymentCostFactor","clonedSolutions","relationshipPromises","entry","addItemRelationship","originItemId","destinationItemId","relationshipType","sharePromises","templatesWithGroups","tmpl","groupIds","sourceGroupId","maybePush","isTrackingViewTemplate","shareItemToGroups","trackingGroupId","owner","trackerGroupIds","replaceInTemplate","nonTrackerGroupIds","shareTemplatesToGroups","postProcessPromises","deploySolutionFromTemplate","templateSolutionId","solutionTemplateBase","solutionTemplateData","extractSolutionVersion","deployedFolderId","deployOptions","prop","thumbnailurl","generateSourceThumbnailUrl","portal","_applySourceToDeployOptions","additionalTypeKeywords","thumbFilename","thumbDef","getFilenameFromUrl","appendQueryParam","getBlobAsFile","paramsLookup","_updateProp","_replaceParamVariables","getPortal","getUser","getFoldersAndGroups","responses","portalResponse","userResponse","foldersAndGroupsResponse","thumbnailFile","isPortal","organization","portalBaseUrl","scheme","urlKey","customBaseUrl","enterpriseBaseUrl","_getPortalBaseUrl","folders","setLocationTrackingEnabled","trackingOwnerPromise","getTackingServiceOwner","folderPromise","createUniqueFolder","portalExtent","defaultExtent","extentsPromise","convertExtentWithFallback","wkid","helperServices","geometry","folderResponse","wgs84Extent","trackingOwnerResponse","folder","solutionItemExtent","xmin","ymin","xmax","ymax","defaultExtentBBox","locationTrackingEnabled","createSolutionItemBase","sanitizeJSONAndReportChanges","createItemWithData","createSolutionResponse","protectOptions","protectItem","tryitUrl","_checkedReplaceAll","deployItems.deploySolutionItems","clonedSolutionsResponse","sortOrderIds","itemTemplate","getWithDefault","sort","template1","template2","iTemplateKeyword","splice","retainProps","deleteProps","_purgeTemplateProperties","itemTemplates","newId","_updateGroupReferences","path","lookup","oldValue","newValue","newTemplate","re","RegExp","getSolutionTemplateItem","idOrObject","getItemDataAsJson","migrateSchema","_isModel","updateDeployOptions","snippet","description","getItemThumbnailUrl","obj","isNotStringOrArray","isSolutionTemplateItem","kwds","shareItem","locationTracking","maybeModel","model","itemBase","itemData","sanitizer","Sanitizer","deleteItemProps","createdSolutionId","ex"],"mappings":";;;;;;;;;;;;;;;;;4gDA+BaA,EAA6B,KAO7BC,EAAgC,CAG3CC,MAAOC,EAIP,oBAAqBC,oBACrB,qBAAsBC,cACtB,kBAAmBC,EACnBC,KAAMH,oBACN,yBAAqBI,EACrB,uBAAmBA,EACnB,wBAAoBA,EACpB,6BAAyBA,EACzB,qBAAiBA,EACjB,qBAAiBA,EACjBC,SAAKD,EACL,cAAeF,EACf,gCAA4BE,EAC5B,qBAAsBJ,oBACtB,sCAAkCI,EAClC,qBAAiBA,EACjB,sBAAkBA,EAClBE,UAAMF,EACN,2BAAuBA,EACvBG,SAAKH,EACLI,SAAKJ,EACLK,UAAML,EACN,gCAA4BA,EAI5B,oBAAgBA,EAChB,UAAWH,cACX,YAAaA,cAIbS,iB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AAO+C,KAAK,wCAEpC,IAAIgL,EAA+ChP,GAAW,GAE1DgP,EAAchO,kBAChBgO,EAAchO,iBAAiB,EAAGgO,EAAcvN,OAIlD,MAAM7B,EAA4CoP,EAAcpP,sBAC5DoP,EAAcpP,sBACdoG,EAGJ,OAAOsO,EAAwBe,EAAYzV,GACxCgD,MAAK0S,GACCL,EAAuBK,EAAMjR,MAMzBpE,QAAQuD,IAAI,CACjBvD,QAAQC,QAAQoV,EAAMjR,MACtBpE,QAAQC,QAAQoV,EAAMhU,QAPjBrB,QAAQE,OACbc,EAAO+C,KAAK,GAAGsR,EAAMjR,KAAKpB,oCAU/BL,MAAKsN,IAEJ,MAAOqF,EAAUC,GAAYtF,EAEvBuF,EAAY,IAAIxU,EAAOyU,UACvBrR,EAAOpD,EAAOuR,6BAA6B+C,EAAUE,GAErDnU,EAAOkU,EAEP5U,EAASyD,EAAKpB,GAUpB,OARA+L,EAAgB2F,EACd3F,EACA3K,EACAzE,GAGFqB,EAAO0U,gBAAgBtR,GAEhBqK,EACL9N,EACAyD,EACA/C,EACA0E,EACAgJ,EACD,IAEFpM,MACCgT,IAEM5G,EAAchO,kBAChBgO,EAAchO,iBAAiB,IAAKgO,EAAcvN,OAE7CmU,KAETzT,IAGM6M,EAAchO,kBAChBgO,EAAchO,iBAAiB,EAAGgO,EAAcvN,OAE3CxB,QAAQE,OAAOgC,MAGzBqG,OAAMqN,IACL,MAAMA,CAAE,GAEd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-deployer",
3
- "version": "1.3.16",
3
+ "version": "1.4.1",
4
4
  "description": "Manages the deployment of a Solution for @esri/solution.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "unpkg": "dist/umd/deployer.umd.min.js",
@@ -18,10 +18,10 @@
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
- "@esri/hub-common": "9.29.0",
22
- "@esri/hub-initiatives": "9.29.0",
23
- "@esri/hub-sites": "9.29.0",
24
- "@esri/hub-teams": "9.29.0",
21
+ "@esri/hub-common": "^10.0.0-next.3",
22
+ "@esri/hub-initiatives": "^10.0.0-next.3",
23
+ "@esri/hub-sites": "^10.0.0-next.3",
24
+ "@esri/hub-teams": "^10.0.0-next.3",
25
25
  "rollup": "2.66.1"
26
26
  },
27
27
  "peerDependencies": {
@@ -30,22 +30,22 @@
30
30
  "@esri/arcgis-rest-portal": "3.4.3",
31
31
  "@esri/arcgis-rest-request": "3.4.3",
32
32
  "@esri/arcgis-rest-service-admin": "3.4.3",
33
- "@esri/hub-common": "9.29.0",
34
- "@esri/hub-initiatives": "9.29.0",
35
- "@esri/hub-sites": "9.29.0",
36
- "@esri/hub-teams": "9.29.0"
33
+ "@esri/hub-common": "^10.0.0-next.3",
34
+ "@esri/hub-initiatives": "^10.0.0-next.3",
35
+ "@esri/hub-sites": "^10.0.0-next.3",
36
+ "@esri/hub-teams": "^10.0.0-next.3"
37
37
  },
38
38
  "dependencies": {
39
- "@esri/solution-common": "^1.3.16",
40
- "@esri/solution-feature-layer": "^1.3.16",
41
- "@esri/solution-file": "^1.3.16",
42
- "@esri/solution-form": "^1.3.16",
43
- "@esri/solution-group": "^1.3.16",
44
- "@esri/solution-hub-types": "^1.3.16",
45
- "@esri/solution-simple-types": "^1.3.16",
46
- "@esri/solution-storymap": "^1.3.16",
47
- "@esri/solution-velocity": "^1.3.16",
48
- "@esri/solution-web-experience": "^1.3.16",
39
+ "@esri/solution-common": "^1.4.1",
40
+ "@esri/solution-feature-layer": "^1.4.1",
41
+ "@esri/solution-file": "^1.4.1",
42
+ "@esri/solution-form": "^1.4.1",
43
+ "@esri/solution-group": "^1.4.1",
44
+ "@esri/solution-hub-types": "^1.4.1",
45
+ "@esri/solution-simple-types": "^1.4.1",
46
+ "@esri/solution-storymap": "^1.4.1",
47
+ "@esri/solution-velocity": "^1.4.1",
48
+ "@esri/solution-web-experience": "^1.4.1",
49
49
  "tslib": "1.14.1"
50
50
  },
51
51
  "scripts": {
@@ -100,5 +100,5 @@
100
100
  "esri",
101
101
  "ES6"
102
102
  ],
103
- "gitHead": "c87f04e58c80558f19a6d79086b69a965b17db93"
103
+ "gitHead": "71006b142f9473cdd1b4a8b9fad0d6bfe50e12bd"
104
104
  }