@esri/solution-deployer 6.1.0-alpha.0 → 6.2.0-alpha.0

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.
Files changed (55) hide show
  1. package/dist/cjs/deploySolutionFromTemplate.d.ts +55 -0
  2. package/dist/cjs/deploySolutionFromTemplate.js +334 -0
  3. package/dist/cjs/deploySolutionFromTemplate.js.map +1 -0
  4. package/dist/cjs/deploySolutionItems.d.ts +224 -0
  5. package/dist/cjs/deploySolutionItems.js +876 -0
  6. package/dist/cjs/deploySolutionItems.js.map +1 -0
  7. package/dist/cjs/deployer.d.ts +34 -0
  8. package/dist/cjs/deployer.js +99 -0
  9. package/dist/cjs/deployer.js.map +1 -0
  10. package/dist/cjs/deployerUtils.d.ts +47 -0
  11. package/dist/cjs/deployerUtils.js +120 -0
  12. package/dist/cjs/deployerUtils.js.map +1 -0
  13. package/dist/cjs/helpers/post-process.d.ts +29 -0
  14. package/dist/cjs/helpers/post-process.js +63 -0
  15. package/dist/cjs/helpers/post-process.js.map +1 -0
  16. package/dist/cjs/helpers/share-templates-to-groups.d.ts +24 -0
  17. package/dist/cjs/helpers/share-templates-to-groups.js +65 -0
  18. package/dist/cjs/helpers/share-templates-to-groups.js.map +1 -0
  19. package/dist/cjs/helpers/sortTemplates.d.ts +23 -0
  20. package/dist/cjs/helpers/sortTemplates.js +14 -0
  21. package/dist/cjs/helpers/sortTemplates.js.map +1 -0
  22. package/dist/cjs/index.d.ts +24 -0
  23. package/dist/cjs/index.js +28 -0
  24. package/dist/cjs/index.js.map +1 -0
  25. package/dist/cjs/module-map.d.ts +23 -0
  26. package/dist/cjs/module-map.js +234 -0
  27. package/dist/cjs/module-map.js.map +1 -0
  28. package/dist/esm/deploySolutionFromTemplate.d.ts +55 -0
  29. package/dist/esm/deploySolutionFromTemplate.js +319 -0
  30. package/dist/esm/deploySolutionFromTemplate.js.map +1 -0
  31. package/dist/esm/deploySolutionItems.d.ts +224 -0
  32. package/dist/esm/deploySolutionItems.js +853 -0
  33. package/dist/esm/deploySolutionItems.js.map +1 -0
  34. package/dist/esm/deployer.d.ts +34 -0
  35. package/dist/esm/deployer.js +94 -0
  36. package/dist/esm/deployer.js.map +1 -0
  37. package/dist/esm/deployerUtils.d.ts +47 -0
  38. package/dist/esm/deployerUtils.js +112 -0
  39. package/dist/esm/deployerUtils.js.map +1 -0
  40. package/dist/esm/helpers/post-process.d.ts +29 -0
  41. package/dist/esm/helpers/post-process.js +59 -0
  42. package/dist/esm/helpers/post-process.js.map +1 -0
  43. package/dist/esm/helpers/share-templates-to-groups.d.ts +24 -0
  44. package/dist/esm/helpers/share-templates-to-groups.js +61 -0
  45. package/dist/esm/helpers/share-templates-to-groups.js.map +1 -0
  46. package/dist/esm/helpers/sortTemplates.d.ts +23 -0
  47. package/dist/esm/helpers/sortTemplates.js +10 -0
  48. package/dist/esm/helpers/sortTemplates.js.map +1 -0
  49. package/dist/esm/index.d.ts +24 -0
  50. package/dist/esm/index.js +25 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/module-map.d.ts +23 -0
  53. package/dist/esm/module-map.js +230 -0
  54. package/dist/esm/module-map.js.map +1 -0
  55. package/package.json +14 -14
@@ -0,0 +1,55 @@
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import * as common from "@esri/solution-common";
17
+ export declare function deploySolutionFromTemplate(templateSolutionId: string, solutionTemplateBase: any, solutionTemplateData: any, authentication: common.UserSession, options: common.IDeploySolutionOptions): Promise<string>;
18
+ /**
19
+ * Add templates for the items that were automatically created by workflow
20
+ *
21
+ * @param preProcessResponse response from pre processing of workflow items
22
+ * @param solutionTemplateData the current solution template data that will be used to show item details
23
+ */
24
+ export declare function _handleWorkflowManagedTemplates(preProcessResponse: common.IPreProcessWorkflowTemplatesResponse, solutionTemplateData: any): void;
25
+ /**
26
+ * Add source-id to items/groups typeKeywords
27
+ *
28
+ * @param template the array of solution data templates
29
+ * @private
30
+ */
31
+ export declare function _addSourceId(templates: common.IItemTemplate[]): common.IItemTemplate[];
32
+ /**
33
+ * Update the deployOptions with the group properties
34
+ *
35
+ * @param deployOptions
36
+ * @param sourceInfo
37
+ * @param authentication
38
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
39
+ * @private
40
+ */
41
+ export declare function _applySourceToDeployOptions(deployOptions: common.IDeploySolutionOptions, solutionTemplateBase: any, templateDictionary: any, authentication: common.UserSession): common.IDeploySolutionOptions;
42
+ export declare function _replaceParamVariables(solutionTemplateData: any, templateDictionary: any): void;
43
+ export declare function _updateProp(template: common.IItemTemplate, path: string, lookup: string, templateDictionary: any): common.IItemTemplate;
44
+ export declare function _checkedReplaceAll(template: string, oldValue: string, newValue: string): string;
45
+ export declare function _getPortalBaseUrl(portalResponse: common.IPortal, authentication: common.UserSession): string;
46
+ export declare function _updateGroupReferences(itemTemplates: any[], templateDictionary: any): any[];
47
+ export declare function _purgeTemplateProperties(itemTemplate: any): any;
48
+ /**
49
+ * Returns a match of a supplied id with the suffix ".itemId" in the template dictionary.
50
+ *
51
+ * @param id Id to look for
52
+ * @param templateDictionary Hash mapping property names to replacement values
53
+ * @returns Match in template dictionary or original id
54
+ */
55
+ export declare function _getNewItemId(id: string, templateDictionary: any): string;
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports._getNewItemId = exports._purgeTemplateProperties = exports._updateGroupReferences = exports._getPortalBaseUrl = exports._checkedReplaceAll = exports._updateProp = exports._replaceParamVariables = exports._applySourceToDeployOptions = exports._addSourceId = exports._handleWorkflowManagedTemplates = exports.deploySolutionFromTemplate = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
+ const deployItems = tslib_1.__importStar(require("./deploySolutionItems"));
22
+ const hub_common_1 = require("@esri/hub-common");
23
+ const post_process_1 = require("./helpers/post-process");
24
+ const sortTemplates_1 = require("./helpers/sortTemplates");
25
+ // NOTE: Moved to separate file to allow stubbing in main deploySolution tests
26
+ async function deploySolutionFromTemplate(templateSolutionId, solutionTemplateBase, solutionTemplateData, authentication, options) {
27
+ options.storageVersion = common.extractSolutionVersion(solutionTemplateData);
28
+ // It is possible to provide a separate authentication for the source
29
+ const storageAuthentication = options.storageAuthentication
30
+ ? options.storageAuthentication
31
+ : authentication;
32
+ // Replacement dictionary and high-level deployment ids for cleanup
33
+ // TODO: Extract all templateDictionary prep into a separate function
34
+ const templateDictionary = options.templateDictionary ?? {};
35
+ const preProcessResponse = common.preprocessWorkflowTemplates(solutionTemplateData.templates, templateDictionary);
36
+ solutionTemplateData.templates = preProcessResponse.deployTemplates;
37
+ _applySourceToDeployOptions(options, solutionTemplateBase, templateDictionary, authentication);
38
+ if (options.additionalTypeKeywords) {
39
+ solutionTemplateBase.typeKeywords = [].concat(solutionTemplateBase.typeKeywords, options.additionalTypeKeywords);
40
+ }
41
+ // Get the thumbnail file
42
+ let thumbFilename = "thumbnail";
43
+ let thumbDef = Promise.resolve(null);
44
+ if (!options.thumbnail && options.thumbnailurl) {
45
+ // Figure out the thumbnail's filename
46
+ thumbFilename = common.getFilenameFromUrl(options.thumbnailurl) || thumbFilename;
47
+ const thumbnailurl = common.appendQueryParam(options.thumbnailurl, "w=400");
48
+ delete options.thumbnailurl;
49
+ // Fetch the thumbnail
50
+ thumbDef = common.getBlobAsFile(thumbnailurl, thumbFilename, storageAuthentication, [400]);
51
+ }
52
+ _replaceParamVariables(solutionTemplateData, templateDictionary);
53
+ // Get information about deployment environment
54
+ const environResponses = await Promise.all([
55
+ common.getPortal("", authentication),
56
+ common.getPortalUrls(authentication),
57
+ common.getUser(authentication),
58
+ common.getFoldersAndGroups(authentication),
59
+ thumbDef,
60
+ ]);
61
+ const [portalResponse, portalUrlsResponse, userResponse, foldersAndGroupsResponse, thumbnailFile] = environResponses;
62
+ if (!options.thumbnail && thumbnailFile) {
63
+ options.thumbnail = thumbnailFile;
64
+ }
65
+ // update template items with source-itemId type keyword
66
+ solutionTemplateData.templates = _addSourceId(solutionTemplateData.templates);
67
+ templateDictionary.isPortal = portalResponse.isPortal;
68
+ templateDictionary.organization = Object.assign(templateDictionary.organization || {}, portalResponse);
69
+ // TODO: Add more computed properties here
70
+ // portal: portalResponse
71
+ // orgextent as bbox for assignment onto items
72
+ // more info in #266 https://github.com/Esri/solution.js/issues/266
73
+ templateDictionary.portalUrls = portalUrlsResponse.urls;
74
+ templateDictionary.portalBaseUrl = _getPortalBaseUrl(portalResponse, authentication);
75
+ templateDictionary.user = userResponse;
76
+ templateDictionary.user.folders = foldersAndGroupsResponse.folders;
77
+ templateDictionary.user.groups = foldersAndGroupsResponse.groups.filter((group) => group.owner === templateDictionary.user.username);
78
+ // Add information needed for workflow manager
79
+ const user = await common.getUser(authentication);
80
+ templateDictionary.workflowBaseUrl = await common.getWorkflowBaseURL(authentication, portalResponse, user.orgId);
81
+ // if we have tracking views and the user is not admin or the org doesn't support tracking an error is thrown
82
+ common.setLocationTrackingEnabled(portalResponse, userResponse, templateDictionary, solutionTemplateData.templates);
83
+ const trackingOwnerPromise = common.getTackingServiceOwner(templateDictionary, authentication);
84
+ // Create a folder to hold the deployed solution. We use the solution name, appending a sequential
85
+ // suffix if the folder exists, e.g.,
86
+ // * Manage Right of Way Activities
87
+ // * Manage Right of Way Activities 1
88
+ // * Manage Right of Way Activities 2
89
+ const folderPromise = common.createUniqueFolder(solutionTemplateBase.title, templateDictionary, authentication);
90
+ // Apply the portal extents to the solution
91
+ const portalExtent = portalResponse.defaultExtent;
92
+ const extentsPromise = common.convertExtentWithFallback(portalExtent, undefined, { wkid: 4326 }, portalResponse.helperServices.geometry.url, authentication);
93
+ // Await completion of async actions: folder creation & extents conversion
94
+ const folderExtentsResponses = await Promise.all([folderPromise, extentsPromise, trackingOwnerPromise]);
95
+ const [folderResponse, wgs84Extent, trackingOwnerResponse] = folderExtentsResponses;
96
+ const deployedFolderId = folderResponse.folder.id;
97
+ templateDictionary.folderId = deployedFolderId;
98
+ templateDictionary.solutionItemExtent =
99
+ wgs84Extent.xmin + "," + wgs84Extent.ymin + "," + wgs84Extent.xmax + "," + wgs84Extent.ymax;
100
+ // Hub Solutions depend on organization defaultExtentBBox as a nested array not a string
101
+ templateDictionary.organization.defaultExtentBBox = [
102
+ [wgs84Extent.xmin, wgs84Extent.ymin],
103
+ [wgs84Extent.xmax, wgs84Extent.ymax],
104
+ ];
105
+ // update templateDictionary to indicate if the user owns the tracking service
106
+ // this will affect how we handle group sharing
107
+ /* istanbul ignore else */
108
+ if (templateDictionary.locationTrackingEnabled) {
109
+ common.setCreateProp(templateDictionary, "locationTracking.userIsOwner", trackingOwnerResponse);
110
+ }
111
+ let deployedSolutionId;
112
+ if (!options.dontCreateSolutionItem) {
113
+ // Create a deployed Solution item
114
+ solutionTemplateBase.categories = []; // we don't want to carry over categories from the template
115
+ const createSolutionItemBase = {
116
+ ...common.sanitizeJSON(solutionTemplateBase),
117
+ type: "Solution",
118
+ typeKeywords: ["Solution"],
119
+ };
120
+ if (options.additionalTypeKeywords) {
121
+ createSolutionItemBase.typeKeywords = ["Solution"].concat(options.additionalTypeKeywords);
122
+ }
123
+ // Create deployed solution item
124
+ createSolutionItemBase.thumbnail = options.thumbnail;
125
+ const createSolutionResponse = await common.createItemWithData(createSolutionItemBase, {}, authentication, deployedFolderId);
126
+ deployedSolutionId = createSolutionResponse.id;
127
+ // Protect the solution item
128
+ const protectOptions = {
129
+ id: deployedSolutionId,
130
+ authentication,
131
+ };
132
+ await common.protectItem(protectOptions);
133
+ // TODO: Attach the whole solution model so we can
134
+ // have stuff like `{{solution.item.title}}
135
+ templateDictionary.solutionItemId = deployedSolutionId;
136
+ solutionTemplateBase.id = deployedSolutionId;
137
+ solutionTemplateBase.tryitUrl = _checkedReplaceAll(solutionTemplateBase.tryitUrl, templateSolutionId, deployedSolutionId);
138
+ solutionTemplateBase.url = _checkedReplaceAll(solutionTemplateBase.url, templateSolutionId, deployedSolutionId);
139
+ }
140
+ // Handle the contained item templates
141
+ const clonedSolutionsResponse = await deployItems.deploySolutionItems(storageAuthentication.portal, templateSolutionId, solutionTemplateData.templates, storageAuthentication, templateDictionary, deployedSolutionId, authentication, options);
142
+ solutionTemplateData.templates = solutionTemplateData.templates.map((itemTemplate) => {
143
+ // Update ids present in template dictionary
144
+ itemTemplate.itemId = common.getProp(templateDictionary, `${itemTemplate.itemId}.itemId`);
145
+ // Update the dependencies hash to point to the new item ids
146
+ itemTemplate.dependencies = itemTemplate.dependencies.map((id) => (0, hub_common_1.getWithDefault)(templateDictionary, `${id}.itemId`, id));
147
+ return itemTemplate;
148
+ });
149
+ // Sort the templates into build order, which is provided by clonedSolutionsResponse
150
+ (0, sortTemplates_1.sortTemplates)(solutionTemplateData.templates, clonedSolutionsResponse.map((response) => response.id));
151
+ // Wrap up with post-processing, in which we deal with groups and cycle remnants
152
+ await (0, post_process_1.postProcess)(deployedSolutionId, solutionTemplateData.templates, clonedSolutionsResponse, authentication, templateDictionary);
153
+ if (!options.dontCreateSolutionItem) {
154
+ // Update solution item using internal representation & and the updated data JSON
155
+ solutionTemplateBase.typeKeywords = [].concat(solutionTemplateBase.typeKeywords, ["Deployed"]);
156
+ const iTemplateKeyword = solutionTemplateBase.typeKeywords.indexOf("Template");
157
+ /* istanbul ignore else */
158
+ if (iTemplateKeyword >= 0) {
159
+ solutionTemplateBase.typeKeywords.splice(iTemplateKeyword, 1);
160
+ }
161
+ solutionTemplateData.templates = solutionTemplateData.templates.map((itemTemplate) => _purgeTemplateProperties(itemTemplate));
162
+ _handleWorkflowManagedTemplates(preProcessResponse, solutionTemplateData);
163
+ solutionTemplateData.templates = _updateGroupReferences(solutionTemplateData.templates, templateDictionary);
164
+ solutionTemplateData.templates = common.updateWorkflowTemplateIds(solutionTemplateData.templates, templateDictionary);
165
+ // Update solution items data using template dictionary, and then update the
166
+ // itemId & dependencies in each item template
167
+ solutionTemplateBase.data = common.replaceInTemplate(solutionTemplateData, templateDictionary);
168
+ // Write any user defined params to the solution
169
+ /* istanbul ignore else */
170
+ if (templateDictionary.params) {
171
+ solutionTemplateBase.data.params = templateDictionary.params;
172
+ }
173
+ await common.updateItem(solutionTemplateBase, authentication, deployedFolderId);
174
+ }
175
+ return solutionTemplateBase.id;
176
+ }
177
+ exports.deploySolutionFromTemplate = deploySolutionFromTemplate;
178
+ /**
179
+ * Add templates for the items that were automatically created by workflow
180
+ *
181
+ * @param preProcessResponse response from pre processing of workflow items
182
+ * @param solutionTemplateData the current solution template data that will be used to show item details
183
+ */
184
+ function _handleWorkflowManagedTemplates(preProcessResponse, solutionTemplateData) {
185
+ preProcessResponse.workflowManagedTemplates.forEach((itemTemplate) => {
186
+ solutionTemplateData.templates.push(_purgeTemplateProperties(itemTemplate));
187
+ });
188
+ }
189
+ exports._handleWorkflowManagedTemplates = _handleWorkflowManagedTemplates;
190
+ /**
191
+ * Add source-id to items/groups typeKeywords
192
+ *
193
+ * @param template the array of solution data templates
194
+ * @private
195
+ */
196
+ function _addSourceId(templates) {
197
+ return templates.map((template) => {
198
+ /* istanbul ignore else */
199
+ if (template.item) {
200
+ const typeKeywords = template.item.typeKeywords || [];
201
+ typeKeywords.push("source-" + template.itemId);
202
+ template.item.typeKeywords = typeKeywords;
203
+ }
204
+ return template;
205
+ });
206
+ }
207
+ exports._addSourceId = _addSourceId;
208
+ /**
209
+ * Update the deployOptions with the group properties
210
+ *
211
+ * @param deployOptions
212
+ * @param sourceInfo
213
+ * @param authentication
214
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
215
+ * @private
216
+ */
217
+ function _applySourceToDeployOptions(deployOptions, solutionTemplateBase, templateDictionary, authentication) {
218
+ // Deploy a solution from the template's contents,
219
+ // using the template's information as defaults for the deployed solution item
220
+ ["title", "snippet", "description", "tags"].forEach((prop) => {
221
+ deployOptions[prop] = deployOptions[prop] ?? solutionTemplateBase[prop];
222
+ if (deployOptions[prop]) {
223
+ solutionTemplateBase[prop] = deployOptions[prop];
224
+ // carry these options forward on the templateDict
225
+ templateDictionary[prop] = deployOptions[prop];
226
+ }
227
+ });
228
+ if (!deployOptions.thumbnailurl && solutionTemplateBase.thumbnail) {
229
+ // Get the full path to the thumbnail
230
+ deployOptions.thumbnailurl = common.generateSourceThumbnailUrl(authentication.portal, solutionTemplateBase.id, solutionTemplateBase.thumbnail);
231
+ delete solutionTemplateBase.thumbnail;
232
+ }
233
+ return deployOptions;
234
+ }
235
+ exports._applySourceToDeployOptions = _applySourceToDeployOptions;
236
+ //TODO: function doc
237
+ function _replaceParamVariables(solutionTemplateData, templateDictionary) {
238
+ // a custom params object can be passed in with the options to deploy a solution
239
+ // in most cases we can defer to the item type handlers to use these values
240
+ // for variable replacement
241
+ // for spatial reference specifically we need to replace up front so the default extent
242
+ // logic can execute as expected
243
+ solutionTemplateData.templates = solutionTemplateData.templates.map((template) => {
244
+ // 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
245
+ // return common.replaceInTemplate(template, templateDictionary);
246
+ /* istanbul ignore else */
247
+ if (template.type === "Feature Service") {
248
+ const paramsLookup = "params.";
249
+ const wkidItemPath = "item.spatialReference.wkid";
250
+ template = _updateProp(template, wkidItemPath, paramsLookup, templateDictionary);
251
+ const wkidServicePath = "properties.service.spatialReference.wkid";
252
+ template = _updateProp(template, wkidServicePath, paramsLookup, templateDictionary);
253
+ }
254
+ return template;
255
+ });
256
+ }
257
+ exports._replaceParamVariables = _replaceParamVariables;
258
+ //TODO: function doc
259
+ function _updateProp(template, path, lookup, templateDictionary) {
260
+ const wkid = common.getProp(template, path);
261
+ /* istanbul ignore else */
262
+ if (wkid && typeof wkid === "string" && wkid.indexOf(lookup) > -1) {
263
+ common.setProp(template, path, common.replaceInTemplate(wkid, templateDictionary));
264
+ }
265
+ return template;
266
+ }
267
+ exports._updateProp = _updateProp;
268
+ //TODO: function doc
269
+ function _checkedReplaceAll(template, oldValue, newValue) {
270
+ let newTemplate;
271
+ if (template && template.indexOf(oldValue) > -1) {
272
+ const re = new RegExp(oldValue, "g");
273
+ newTemplate = template.replace(re, newValue);
274
+ }
275
+ else {
276
+ newTemplate = template;
277
+ }
278
+ return newTemplate;
279
+ }
280
+ exports._checkedReplaceAll = _checkedReplaceAll;
281
+ //TODO: function doc
282
+ function _getPortalBaseUrl(portalResponse, authentication) {
283
+ // As of Spring 2020, only HTTPS (see
284
+ // https://www.esri.com/arcgis-blog/products/product/administration/2019-arcgis-transport-security-improvements/)
285
+ const scheme = "https"; // portalResponse.allSSL ? "https" : "http";
286
+ const urlKey = common.getProp(portalResponse, "urlKey");
287
+ const customBaseUrl = common.getProp(portalResponse, "customBaseUrl");
288
+ const enterpriseBaseUrl = common.getProp(portalResponse, "portalHostname");
289
+ return urlKey && customBaseUrl
290
+ ? `${scheme}://${urlKey}.${customBaseUrl}`
291
+ : enterpriseBaseUrl
292
+ ? `${scheme}://${enterpriseBaseUrl}`
293
+ : authentication.portal.replace("/sharing/rest", "");
294
+ }
295
+ exports._getPortalBaseUrl = _getPortalBaseUrl;
296
+ //TODO: function doc
297
+ function _updateGroupReferences(itemTemplates, templateDictionary) {
298
+ const groupIds = itemTemplates.reduce((result, t) => {
299
+ if (t.type === "Group") {
300
+ result.push(t.itemId);
301
+ }
302
+ return result;
303
+ }, []);
304
+ Object.keys(templateDictionary).forEach((k) => {
305
+ const newId = templateDictionary[k].itemId;
306
+ if (groupIds.indexOf(newId) > -1) {
307
+ itemTemplates.forEach((t) => {
308
+ t.groups = t.groups.map((id) => (id === k ? newId : id));
309
+ });
310
+ }
311
+ });
312
+ return itemTemplates;
313
+ }
314
+ exports._updateGroupReferences = _updateGroupReferences;
315
+ //TODO: function doc
316
+ function _purgeTemplateProperties(itemTemplate) {
317
+ const retainProps = ["itemId", "type", "dependencies", "groups"];
318
+ const deleteProps = Object.keys(itemTemplate).filter((k) => retainProps.indexOf(k) < 0);
319
+ common.deleteProps(itemTemplate, deleteProps);
320
+ return itemTemplate;
321
+ }
322
+ exports._purgeTemplateProperties = _purgeTemplateProperties;
323
+ /**
324
+ * Returns a match of a supplied id with the suffix ".itemId" in the template dictionary.
325
+ *
326
+ * @param id Id to look for
327
+ * @param templateDictionary Hash mapping property names to replacement values
328
+ * @returns Match in template dictionary or original id
329
+ */
330
+ function _getNewItemId(id, templateDictionary) {
331
+ return common.getProp(templateDictionary, id + ".itemId") ?? id;
332
+ }
333
+ exports._getNewItemId = _getNewItemId;
334
+ //# sourceMappingURL=deploySolutionFromTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploySolutionFromTemplate.js","sourceRoot":"","sources":["../../src/deploySolutionFromTemplate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;AAChD,2EAAqD;AACrD,iDAAkD;AAClD,yDAAqD;AACrD,2DAAwD;AAExD,8EAA8E;AAEvE,KAAK,UAAU,0BAA0B,CAC9C,kBAA0B,EAC1B,oBAAyB,EACzB,oBAAyB,EACzB,cAAkC,EAClC,OAAsC;IAEtC,OAAO,CAAC,cAAc,GAAG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AO,aAAa,CAAC;AACvB,CAAC;AAjBD,wDAiBC;AAED,oBAAoB;AACpB,SAAgB,wBAAwB,CAAC,YAAiB;IACxD,MAAM,WAAW,GAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAa,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAClG,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC9C,OAAO,YAAY,CAAC;AACtB,CAAC;AALD,4DAKC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,EAAU,EAAE,kBAAuB;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC;AAFD,sCAEC"}
@@ -0,0 +1,224 @@
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages deployment of items via the REST API.
18
+ *
19
+ * @module deployItems
20
+ */
21
+ import * as common from "@esri/solution-common";
22
+ /**
23
+ * Deploys a set of items defined by templates.
24
+ *
25
+ * @param portalSharingUrl Server/sharing
26
+ * @param storageItemId Id of storage item
27
+ * @param templates A collection of AGO item templates
28
+ * @param storageAuthentication Credentials for the organization with the source items
29
+ * @param templateDictionary Hash of facts: org URL, adlib replacements
30
+ * @param deployedSolutionId Id of deployed Solution item
31
+ * @param destinationAuthentication Credentials for the destination organization
32
+ * @param options Options to tune deployment
33
+ * @returns A promise that will resolve with the list of information about the created items
34
+ */
35
+ export declare function deploySolutionItems(portalSharingUrl: string, storageItemId: string, templates: common.IItemTemplate[], storageAuthentication: common.UserSession, templateDictionary: any, deployedSolutionId: string, destinationAuthentication: common.UserSession, options: common.IDeploySolutionOptions): Promise<common.ICreateItemFromTemplateResponse[]>;
36
+ /**
37
+ * For each item to be patched, convert it to its cloned id and mark the item as needing post processing.
38
+ *
39
+ * @param itemsToBePatched List of items that need to have their dependencies patched
40
+ * @param templateDictionary Hash of facts: org URL, adlib replacements
41
+ * @param templates A collection of AGO item templates
42
+ * @private
43
+ */
44
+ export declare function _flagPatchItemsForPostProcessing(itemsToBePatched: common.IKeyedListsOfStrings, templateDictionary: any, templates: common.ICreateItemFromTemplateResponse[]): void;
45
+ /**
46
+ * Portal does not allow views of a single source to be created at the same time.
47
+ *
48
+ * Update view templates with an array of other view template ids that it should wait on.
49
+ *
50
+ * @param templates a collection of AGO item templates
51
+ *
52
+ * @returns An updated array of item templates
53
+ * @private
54
+ */
55
+ export declare function _evaluateSharedViewSources(templates: common.IItemTemplate[]): common.IItemTemplate[];
56
+ /**
57
+ * Add a syncViews array to each template that will hold all other view ids that
58
+ * have the same FS dependency.
59
+ * These arrays will be processed later to only contain ids that each view will need to wait on.
60
+ *
61
+ * @param templates a collection of AGO item templates
62
+ * @param views an array of view template details
63
+ *
64
+ * @returns An updated array of item templates
65
+ * @private
66
+ */
67
+ export declare function _updateViewTemplates(templates: common.IItemTemplate[], views: any[]): common.IItemTemplate[];
68
+ /**
69
+ * Get all view templates from the source templates collection
70
+ *
71
+ * @param views A collection of view ID and dependencies
72
+ *
73
+ * @returns an array of objects with the source FS id as the key and a list of views that are
74
+ * dependant upon it
75
+ *
76
+ * @private
77
+ */
78
+ export declare function _getViewHash(views: any[]): any;
79
+ /**
80
+ * Get all view templates from the source templates collection
81
+ *
82
+ * @param templates A collection of AGO item templates
83
+ *
84
+ * @returns an array with the view id and its dependencies
85
+ *
86
+ * @private
87
+ */
88
+ export declare function _getViews(templates: common.IItemTemplate[]): any[];
89
+ /**
90
+ * Search for existing items and update the templateDictionary with key details
91
+ *
92
+ * @param templates A collection of AGO item templates
93
+ * @param reuseItems Option to search for existing items
94
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
95
+ * @param authentication Credentials for the requests
96
+ *
97
+ * @returns A Promise that will resolve once existing items have been evaluated
98
+ *
99
+ * @private
100
+ */
101
+ export declare function _reuseDeployedItems(templates: common.IItemTemplate[], reuseItems: boolean, templateDictionary: any, authentication: common.UserSession): Promise<any>;
102
+ /**
103
+ * Search for existing items and update the templateDictionary with key details
104
+ *
105
+ * Subtle difference between _reuseDeployedItems and _useExistingItems
106
+ * _reuseDeployedItems: will search all existing items based on specific type keywords
107
+ * that would have been added by a previous deployment
108
+ * _useExistingItems: will search for an existing item that the user provided
109
+ * the item id for while configuring in the deployment app.
110
+ * This type of item would not necessarily have been laid down by a previous deployment and
111
+ * can thus not expect that it will have the type keywords
112
+ *
113
+ * @param templates A collection of AGO item templates
114
+ * @param useExisting Option to search for existing items
115
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
116
+ * @param authentication Credentials for the requests
117
+ *
118
+ * @returns A Promise that will resolve once existing items have been evaluated
119
+ *
120
+ * @private
121
+ */
122
+ export declare function _useExistingItems(templates: common.IItemTemplate[], useExisting: boolean, templateDictionary: any, authentication: common.UserSession): Promise<any>;
123
+ /**
124
+ * Verify if the existing item has the source-<itemId> typeKeyword and set it if not
125
+ * This allows items that did not come from deployment to be found for reuse after they
126
+ * have been used once via a custom itemId param
127
+ *
128
+ * @param itemDefs
129
+ * @param sourceIdHash key value pairs..actual itemId is the key and the source itemId is the value
130
+ * @param authentication credentials for the requests
131
+ *
132
+ * @returns a promise to indicate when the requests are complete
133
+ * @private
134
+ */
135
+ export declare function _setTypekeywordForExisting(itemDefs: Array<Promise<any>>, sourceIdHash: any, authentication: common.UserSession): Promise<any>;
136
+ /**
137
+ * Update the templateDictionary with key details by item type
138
+ *
139
+ * @param templates A collection of AGO item templates
140
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
141
+ *
142
+ * @private
143
+ */
144
+ export declare function _updateTemplateDictionary(templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
145
+ /**
146
+ * Add the fields from the source layer to the template dictionary for any required replacements
147
+ *
148
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
149
+ * @param itemId the id for the item
150
+ * @param layerId the id for the layer
151
+ * @param fields the fields to transfer
152
+ *
153
+ * @private
154
+ */
155
+ export declare function _setFields(templateDictionary: any, itemId: string, layerId: string, fields: any[]): void;
156
+ /**
157
+ * In some cases an item id search will return a stale item reference
158
+ * it will subsequently fail when we try to fetch the underlying service.
159
+ *
160
+ * We need to remove the item info that has been added to the template dictionary
161
+ * and treat the item as we do other items that don't already exist on deployment.
162
+ *
163
+ * @param result the service request result
164
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
165
+ *
166
+ * @private
167
+ */
168
+ export declare function _updateTemplateDictionaryForError(templateDictionary: any, itemId: string): any;
169
+ /**
170
+ * Optionally search by tags and then update the templateDictionary based on the search results
171
+ *
172
+ * @param existingItemsResponse response object from search by typeKeyword and type
173
+ * @param existingItemIds list of the template ids we have queried
174
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
175
+ * @param authentication Credentials for the request
176
+ * @param addTagQuery Boolean to indicate if a search by tag should happen
177
+ * @returns IFindExistingItemsResponse object with promise that will resolve with an array of results
178
+ * and an array of item ids
179
+ * @private
180
+ */
181
+ export declare function _handleExistingItems(existingItemsResponse: any[], existingItemInfos: common.IFindExistingItemInfos[], templateDictionary: any, authentication: common.UserSession, addTagQuery: boolean): common.IFindExistingItemsResponse;
182
+ export declare function _updateTemplateDictionaryById(templateDictionary: any, sourceId: string, itemId: string, v: any): void;
183
+ /**
184
+ * Search items based on user query
185
+ *
186
+ * @param templates Templates to examine
187
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
188
+ * @param authentication Credentials for the request
189
+ * @returns IFindExistingItemsResponse object with promise that will resolve with an array of results
190
+ * and an array of item ids
191
+ * @private
192
+ */
193
+ export declare function _findExistingItemByKeyword(templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): common.IFindExistingItemsResponse;
194
+ /**
195
+ * Search items based on user query
196
+ *
197
+ * @param query Query string to use
198
+ * @param authentication Credentials for the request
199
+ * @returns A promise that will resolve with an array of results
200
+ * @private
201
+ */
202
+ export declare function _findExistingItem(query: string, authentication: common.UserSession): Promise<any>;
203
+ /**
204
+ * Creates an item from a template once the item's dependencies have been created.
205
+ *
206
+ * @param template Template of item to deploy
207
+ * @param resourceFilePaths URL, folder, and filename for each item resource/metadata/thumbnail
208
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
209
+ * @param userSession Options for the request
210
+ * @param itemProgressCallback Function for reporting progress updates from type-specific template handlers
211
+ * @returns A promise that will resolve with the id of the deployed item (which is simply returned if it's
212
+ * already in the templates list
213
+ * @private
214
+ */
215
+ export declare function _createItemFromTemplateWhenReady(template: common.IItemTemplate, resourceFilePaths: common.IDeployFileCopyPath[], storageAuthentication: common.UserSession, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
216
+ /**
217
+ * Accumulates the estimated deployment cost of a set of templates.
218
+ *
219
+ * @param templates Templates to examine
220
+ * @returns Sum of estimated deployment costs
221
+ * @private
222
+ */
223
+ export declare function _estimateDeploymentCost(templates: common.IItemTemplate[]): number;
224
+ export declare function _getGroupUpdates(template: common.IItemTemplate, authentication: common.UserSession, templateDictionary: any): Array<Promise<any>>;