@esri/solution-creator 5.2.3 → 5.2.5

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.
@@ -0,0 +1,108 @@
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 creation of the template of a Solution item via the REST API.
18
+ *
19
+ * @module createItemTemplate
20
+ */
21
+ import { IDatasourceInfo, IItemProgressCallback, IItemTemplate, ISourceFile, UserSession } from "@esri/solution-common";
22
+ /**
23
+ * Creates template for an AGO item and its dependencies
24
+ *
25
+ * @param solutionItemId The solution to contain the item
26
+ * @param itemId AGO id string
27
+ * @param templateDictionary Hash of facts
28
+ * @param srcAuthentication Credentials for requests to source items
29
+ * @param destAuthentication Authentication for requesting information from AGO about items to be included in solution item
30
+ * @param existingTemplates A collection of AGO item templates that can be referenced by newly-created templates
31
+ * @returns A promise which resolves with an array of resources for the item and its dependencies
32
+ * @private
33
+ */
34
+ export declare function createItemTemplate(solutionItemId: string, itemId: string, templateDictionary: any, srcAuthentication: UserSession, destAuthentication: UserSession, existingTemplates: IItemTemplate[], itemProgressCallback: IItemProgressCallback): Promise<ISourceFile[]>;
35
+ /**
36
+ * Templatizes field references within specific template types.
37
+ * Currently only handles web applications
38
+ *
39
+ * @param templates List of solution templates
40
+ * @returns A list of templates that have templatized field references
41
+ */
42
+ export declare function postProcessFieldReferences(templates: IItemTemplate[]): IItemTemplate[];
43
+ /**
44
+ * Get common properties that will support the templatization of field references
45
+ *
46
+ * @param templates List of solution templates
47
+ * @returns A list of IDataSourceInfo objects with key properties
48
+ * @private
49
+ */
50
+ export declare function _getDatasourceInfos(templates: IItemTemplate[]): IDatasourceInfo[];
51
+ /**
52
+ * Creates a simple lookup object to quickly understand an items type and dependencies
53
+ * and associated web map layer ids based on itemId
54
+ *
55
+ * @param templates List of solution templates
56
+ * @returns The lookup object with type, dependencies, and webmap layer info
57
+ * @private
58
+ */
59
+ export declare function _getTemplateTypeHash(templates: IItemTemplate[]): any;
60
+ /**
61
+ * Updates the lookup object with webmap layer info
62
+ * so we can know the id used within a map for a given feature service
63
+ *
64
+ * @param template A webmap solution template
65
+ * @returns The lookup object with webmap layer info added
66
+ * @private
67
+ */
68
+ export declare function _updateWebMapHashInfo(template: IItemTemplate, hashItem: any): void;
69
+ /**
70
+ * Updates a templatized datasource URL with a layer id.
71
+ *
72
+ * @param dataSourceUrl Templatized datasource URL
73
+ * @param layerId Layer id
74
+ * @returns string Amended datasource URL
75
+ * @private
76
+ */
77
+ export declare function _addLayerIdToDatasourceUrl(datasourceUrl?: string, layerId?: any): string;
78
+ /**
79
+ * Updates the datasource info objects by passing the webmap layer IDs from the lookup hash
80
+ * to the underlying feature service datasource infos
81
+ *
82
+ * @param datasourceInfos A webmap solution template
83
+ * @param templateTypeHash A simple lookup object populated with key item info
84
+ * @returns The updated datasource infos
85
+ * @private
86
+ */
87
+ export declare function _addMapLayerIds(datasourceInfos: IDatasourceInfo[], templateTypeHash: any): IDatasourceInfo[];
88
+ /**
89
+ * Get feature service item IDs from applications webmaps
90
+ * As they are not explict dependencies of the application but are needed for field references
91
+ *
92
+ * @param template A webmap solution template
93
+ * @param templateTypeHash A simple lookup object populated with key item info
94
+ * @returns A list of feature service item IDs
95
+ * @private
96
+ */
97
+ export declare function _getWebMapFSDependencies(template: IItemTemplate, templateTypeHash: any): string[];
98
+ /**
99
+ * Perform templatizations needed in an item's resources
100
+ *
101
+ * @param itemTemplate Item being templatized
102
+ * @param resourceItemFiles Resources for the item; these resources are modified as needed
103
+ * by the templatization
104
+ * @param srcAuthentication Credentials for requests to source items
105
+ *
106
+ * @returns A promise that resolves when all templatization has completed
107
+ */
108
+ export declare function _templatizeResources(itemTemplate: IItemTemplate, resourceItemFiles: ISourceFile[], srcAuthentication: UserSession): Promise<void[]>;
@@ -0,0 +1,442 @@
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._templatizeResources = exports._getWebMapFSDependencies = exports._addMapLayerIds = exports._addLayerIdToDatasourceUrl = exports._updateWebMapHashInfo = exports._getTemplateTypeHash = exports._getDatasourceInfos = exports.postProcessFieldReferences = exports.createItemTemplate = void 0;
19
+ /**
20
+ * Manages creation of the template of a Solution item via the REST API.
21
+ *
22
+ * @module createItemTemplate
23
+ */
24
+ const solution_common_1 = require("@esri/solution-common");
25
+ const hub_common_1 = require("@esri/hub-common");
26
+ const module_map_1 = require("./module-map");
27
+ // ------------------------------------------------------------------------------------------------------------------ //
28
+ /**
29
+ * Creates template for an AGO item and its dependencies
30
+ *
31
+ * @param solutionItemId The solution to contain the item
32
+ * @param itemId AGO id string
33
+ * @param templateDictionary Hash of facts
34
+ * @param srcAuthentication Credentials for requests to source items
35
+ * @param destAuthentication Authentication for requesting information from AGO about items to be included in solution item
36
+ * @param existingTemplates A collection of AGO item templates that can be referenced by newly-created templates
37
+ * @returns A promise which resolves with an array of resources for the item and its dependencies
38
+ * @private
39
+ */
40
+ function createItemTemplate(solutionItemId, itemId, templateDictionary, srcAuthentication, destAuthentication, existingTemplates, itemProgressCallback) {
41
+ return new Promise(resolve => {
42
+ // Check if item and its dependents are already in list or are queued
43
+ if ((0, solution_common_1.findTemplateInList)(existingTemplates, itemId)) {
44
+ resolve([]);
45
+ }
46
+ else {
47
+ // Add the id as a placeholder to show that it is being fetched
48
+ existingTemplates.push((0, solution_common_1.createPlaceholderTemplate)(itemId));
49
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Started, 0);
50
+ // Fetch the item
51
+ (0, solution_common_1.getItemBase)(itemId, srcAuthentication)
52
+ .catch(() => {
53
+ // If item query fails, try fetching item as a group
54
+ // Change its placeholder from an empty type to the Group type so that we can later distinguish
55
+ // between items and groups (the base info for a group doesn't include a type property)
56
+ (0, solution_common_1.replaceTemplate)(existingTemplates, itemId, (0, solution_common_1.createPlaceholderTemplate)(itemId, "Group"));
57
+ return (0, solution_common_1.getGroupBase)(itemId, srcAuthentication);
58
+ })
59
+ .then(itemInfo => {
60
+ itemInfo = (0, solution_common_1.sanitizeJSON)(itemInfo);
61
+ // Save the URL as a symbol
62
+ if (itemInfo.url) {
63
+ templateDictionary[itemInfo.url] = "{{" + itemInfo.id + ".url}}";
64
+ itemInfo.origUrl = itemInfo.url;
65
+ }
66
+ const idTest = /^source-[0-9A-F]{32}/i;
67
+ // Remove any source-itemId type keywords
68
+ /* istanbul ignore else */
69
+ if (Array.isArray(itemInfo.typeKeywords)) {
70
+ itemInfo.typeKeywords = itemInfo.typeKeywords.filter(v => idTest.test(v) ? false : true);
71
+ }
72
+ // Remove any source-itemId tags
73
+ /* istanbul ignore else */
74
+ if (Array.isArray(itemInfo.tags)) {
75
+ itemInfo.tags = itemInfo.tags.filter(v => idTest.test(v) ? false : true);
76
+ }
77
+ const placeholder = (0, solution_common_1.findTemplateInList)(existingTemplates, itemId);
78
+ let itemType = placeholder.type;
79
+ if (!itemType) {
80
+ // Groups have this defined when their placeholder is created
81
+ itemType = itemInfo.type;
82
+ placeholder.type = itemType;
83
+ }
84
+ if (!itemInfo.type) {
85
+ itemInfo.type = itemType; // Groups don't have this property, so we'll patch it in
86
+ }
87
+ placeholder.item = {
88
+ ...itemInfo
89
+ };
90
+ // Interrupt process if progress callback returns `false`
91
+ if (!itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Created, 1)) {
92
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Cancelled, 1);
93
+ resolve((0, solution_common_1.fail)("Cancelled"));
94
+ return;
95
+ }
96
+ const itemHandler = module_map_1.moduleMap[itemType];
97
+ if (!itemHandler || itemHandler === module_map_1.UNSUPPORTED) {
98
+ if (itemHandler === module_map_1.UNSUPPORTED) {
99
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Ignored, 1);
100
+ resolve([]);
101
+ }
102
+ else {
103
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Failed, 1);
104
+ placeholder.properties["failed"] = true;
105
+ (0, solution_common_1.replaceTemplate)(existingTemplates, itemId, placeholder);
106
+ resolve((0, solution_common_1.fail)("The type of AGO item " +
107
+ itemId +
108
+ " ('" +
109
+ itemType +
110
+ "') is not supported at this time"));
111
+ }
112
+ }
113
+ else {
114
+ // Handle original Story Maps with next-gen Story Maps
115
+ /* istanbul ignore else */
116
+ /* Not yet supported
117
+ if (storyMap.isAStoryMap(itemType, itemInfo.url)) {
118
+ itemHandler = storyMap;
119
+ } */
120
+ // Delegate the creation of the item to the handler
121
+ itemHandler
122
+ .convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary)
123
+ .then(itemTemplate => {
124
+ let resourcePrepPromise = Promise.resolve([]);
125
+ // If the item type is Quick Capture, then we already have the resource files (except for the
126
+ // thumbnail) and just need to convert them into ISourceFile objects
127
+ if (itemTemplate.type === "QuickCapture Project") {
128
+ // Fetch thumbnail
129
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
130
+ resourcePrepPromise = (0, solution_common_1.getItemResourcesFilesFromPaths)([(0, solution_common_1.generateSourceThumbnailPath)(srcAuthentication.portal, itemTemplate.itemId, itemTemplate.item.thumbnail)], srcAuthentication).then((thumbnailFile) => {
131
+ itemTemplate.item.thumbnail = null; // not needed in this property; handled as a resource
132
+ const resourceSourceFiles = itemTemplate.resources.map((file) => {
133
+ return {
134
+ itemId: itemTemplate.itemId,
135
+ file,
136
+ folder: itemTemplate.itemId,
137
+ filename: file.name
138
+ };
139
+ }).concat(thumbnailFile);
140
+ // Clear out the files from the itemTemplate.resources
141
+ itemTemplate.resources = [];
142
+ return resourceSourceFiles;
143
+ });
144
+ }
145
+ else {
146
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
147
+ resourcePrepPromise = (0, solution_common_1.getItemResourcesPaths)(itemTemplate, solutionItemId, srcAuthentication, solution_common_1.SolutionTemplateFormatVersion).then((resourceItemFilePaths) => {
148
+ itemTemplate.item.thumbnail = null; // not needed in this property; handled as a resource
149
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
150
+ return (0, solution_common_1.getItemResourcesFilesFromPaths)(resourceItemFilePaths, srcAuthentication);
151
+ });
152
+ }
153
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
154
+ resourcePrepPromise.then(async (resourceItemFiles) => {
155
+ // Perform any custom processing needed on resource files
156
+ await _templatizeResources(itemTemplate, resourceItemFiles, srcAuthentication);
157
+ // update the template's resources
158
+ itemTemplate.resources = itemTemplate.resources.concat(resourceItemFiles.map((file) => file.folder + "/" + file.filename));
159
+ // Set the value keyed by the id to the created template, replacing the placeholder template
160
+ (0, solution_common_1.replaceTemplate)(existingTemplates, itemTemplate.itemId, itemTemplate);
161
+ // Trace item dependencies
162
+ if (itemTemplate.dependencies.length === 0) {
163
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Finished, 1);
164
+ resolve(resourceItemFiles);
165
+ }
166
+ else {
167
+ // Get its dependencies, asking each to get its dependents via
168
+ // recursive calls to this function
169
+ const dependentDfds = [];
170
+ itemTemplate.dependencies.forEach(dependentId => {
171
+ if (!(0, solution_common_1.findTemplateInList)(existingTemplates, dependentId)) {
172
+ dependentDfds.push(createItemTemplate(solutionItemId, dependentId, templateDictionary, srcAuthentication, destAuthentication, existingTemplates, itemProgressCallback));
173
+ }
174
+ });
175
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
176
+ Promise.all(dependentDfds).then((dependentResourceItemFiles) => {
177
+ // Templatization of item and its dependencies done
178
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Finished, 1);
179
+ resourceItemFiles = dependentResourceItemFiles.reduce((accumulator, currentValue) => accumulator.concat(currentValue), resourceItemFiles);
180
+ resolve(resourceItemFiles);
181
+ });
182
+ }
183
+ ;
184
+ });
185
+ }, error => {
186
+ placeholder.properties["error"] = JSON.stringify(error);
187
+ (0, solution_common_1.replaceTemplate)(existingTemplates, itemId, placeholder);
188
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Failed, 1);
189
+ resolve([]);
190
+ });
191
+ }
192
+ },
193
+ // Id not found or item is not accessible
194
+ () => {
195
+ // mock hasInvalidDesignations so this will be processed at the end
196
+ // as we do with living atlas layers
197
+ const t = (0, solution_common_1.findTemplateInList)(existingTemplates, itemId);
198
+ t.properties.hasInvalidDesignations = true;
199
+ // Skip items that we cannot fetch per issue #859
200
+ // Use finished rather than ignored
201
+ // ignored will cause the template to be removed before we can check for hasInvalidDesignations
202
+ itemProgressCallback(itemId, solution_common_1.EItemProgressStatus.Finished, 0);
203
+ resolve([]);
204
+ });
205
+ }
206
+ });
207
+ }
208
+ exports.createItemTemplate = createItemTemplate;
209
+ /**
210
+ * Templatizes field references within specific template types.
211
+ * Currently only handles web applications
212
+ *
213
+ * @param templates List of solution templates
214
+ * @returns A list of templates that have templatized field references
215
+ */
216
+ function postProcessFieldReferences(templates) {
217
+ const datasourceInfos = _getDatasourceInfos(templates);
218
+ const templateTypeHash = _getTemplateTypeHash(templates);
219
+ return templates.map(template => {
220
+ /* istanbul ignore else */
221
+ if (template.type === "Web Mapping Application" ||
222
+ template.type === "Dashboard" ||
223
+ template.type === "Web Map") {
224
+ const webMapFSDependencies = _getWebMapFSDependencies(template, templateTypeHash);
225
+ const itemHandler = module_map_1.moduleMap[template.item.type];
226
+ /* istanbul ignore else */
227
+ if (itemHandler) {
228
+ const dependencies = webMapFSDependencies.concat(template.dependencies);
229
+ let dependentDatasources = datasourceInfos.filter(ds => {
230
+ if (dependencies.indexOf(ds.itemId) > -1) {
231
+ return ds;
232
+ }
233
+ });
234
+ dependentDatasources = _addMapLayerIds(dependentDatasources, templateTypeHash);
235
+ if (dependentDatasources.length > 0) {
236
+ template = itemHandler.postProcessFieldReferences(template, dependentDatasources, template.item.type);
237
+ }
238
+ }
239
+ }
240
+ return template;
241
+ });
242
+ }
243
+ exports.postProcessFieldReferences = postProcessFieldReferences;
244
+ // ------------------------------------------------------------------------------------------------------------------ //
245
+ /**
246
+ * Get common properties that will support the templatization of field references
247
+ *
248
+ * @param templates List of solution templates
249
+ * @returns A list of IDataSourceInfo objects with key properties
250
+ * @private
251
+ */
252
+ function _getDatasourceInfos(templates) {
253
+ const datasourceInfos = [];
254
+ templates.forEach(t => {
255
+ if (t.type === "Feature Service") {
256
+ const layers = (0, hub_common_1.getProp)(t, "properties.layers") || [];
257
+ const tables = (0, hub_common_1.getProp)(t, "properties.tables") || [];
258
+ const layersAndTables = layers.concat(tables);
259
+ layersAndTables.forEach(obj => {
260
+ /* istanbul ignore else */
261
+ if (!(0, solution_common_1.hasDatasource)(datasourceInfos, t.itemId, obj.id)) {
262
+ datasourceInfos.push({
263
+ itemId: t.itemId,
264
+ layerId: obj.id,
265
+ fields: obj.fields,
266
+ basePath: t.itemId + ".layer" + obj.id + ".fields",
267
+ url: (0, hub_common_1.getProp)(t, "item.url"),
268
+ ids: [],
269
+ relationships: obj.relationships || [],
270
+ adminLayerInfo: obj.adminLayerInfo || {}
271
+ });
272
+ }
273
+ });
274
+ }
275
+ });
276
+ return datasourceInfos;
277
+ }
278
+ exports._getDatasourceInfos = _getDatasourceInfos;
279
+ /**
280
+ * Creates a simple lookup object to quickly understand an items type and dependencies
281
+ * and associated web map layer ids based on itemId
282
+ *
283
+ * @param templates List of solution templates
284
+ * @returns The lookup object with type, dependencies, and webmap layer info
285
+ * @private
286
+ */
287
+ function _getTemplateTypeHash(templates) {
288
+ const templateTypeHash = {};
289
+ templates.forEach(template => {
290
+ templateTypeHash[template.itemId] = {
291
+ type: template.type,
292
+ dependencies: template.dependencies
293
+ };
294
+ if (template.type === "Web Map") {
295
+ _updateWebMapHashInfo(template, templateTypeHash[template.itemId]);
296
+ }
297
+ });
298
+ return templateTypeHash;
299
+ }
300
+ exports._getTemplateTypeHash = _getTemplateTypeHash;
301
+ /**
302
+ * Updates the lookup object with webmap layer info
303
+ * so we can know the id used within a map for a given feature service
304
+ *
305
+ * @param template A webmap solution template
306
+ * @returns The lookup object with webmap layer info added
307
+ * @private
308
+ */
309
+ function _updateWebMapHashInfo(template, hashItem) {
310
+ const operationalLayers = (0, hub_common_1.getProp)(template, "data.operationalLayers") || [];
311
+ const tables = (0, hub_common_1.getProp)(template, "data.tables") || [];
312
+ const layersAndTables = operationalLayers.concat(tables);
313
+ if (layersAndTables && layersAndTables.length > 0) {
314
+ hashItem.layersAndTables = [];
315
+ layersAndTables.forEach(layer => {
316
+ const obj = {};
317
+ let itemId;
318
+ /* istanbul ignore else */
319
+ if (layer.itemId) {
320
+ itemId = layer.itemId;
321
+ }
322
+ /* istanbul ignore else */
323
+ if (itemId) {
324
+ obj[(0, solution_common_1.cleanLayerBasedItemId)(itemId)] = {
325
+ id: layer.id,
326
+ url: layer.url
327
+ };
328
+ hashItem.layersAndTables.push(obj);
329
+ }
330
+ });
331
+ }
332
+ }
333
+ exports._updateWebMapHashInfo = _updateWebMapHashInfo;
334
+ /**
335
+ * Updates a templatized datasource URL with a layer id.
336
+ *
337
+ * @param dataSourceUrl Templatized datasource URL
338
+ * @param layerId Layer id
339
+ * @returns string Amended datasource URL
340
+ * @private
341
+ */
342
+ function _addLayerIdToDatasourceUrl(datasourceUrl, layerId) {
343
+ return datasourceUrl && !isNaN(layerId)
344
+ ? datasourceUrl.replace(/[.]/, ".layer" + layerId + ".")
345
+ : "";
346
+ }
347
+ exports._addLayerIdToDatasourceUrl = _addLayerIdToDatasourceUrl;
348
+ /**
349
+ * Updates the datasource info objects by passing the webmap layer IDs from the lookup hash
350
+ * to the underlying feature service datasource infos
351
+ *
352
+ * @param datasourceInfos A webmap solution template
353
+ * @param templateTypeHash A simple lookup object populated with key item info
354
+ * @returns The updated datasource infos
355
+ * @private
356
+ */
357
+ function _addMapLayerIds(datasourceInfos, templateTypeHash) {
358
+ const webMapIds = Object.keys(templateTypeHash).filter(k => {
359
+ if (templateTypeHash[k].type === "Web Map") {
360
+ return templateTypeHash[k];
361
+ }
362
+ });
363
+ return datasourceInfos.map(ds => {
364
+ webMapIds.forEach(webMapId => {
365
+ templateTypeHash[webMapId].layersAndTables.forEach((opLayer) => {
366
+ const opLayerInfo = opLayer[ds.itemId];
367
+ const url = _addLayerIdToDatasourceUrl(ds.url, ds.layerId);
368
+ if (opLayerInfo &&
369
+ url === opLayerInfo.url &&
370
+ ds.ids.indexOf(opLayerInfo.id) < 0) {
371
+ ds.ids.push(opLayerInfo.id);
372
+ }
373
+ });
374
+ });
375
+ return ds;
376
+ });
377
+ }
378
+ exports._addMapLayerIds = _addMapLayerIds;
379
+ /**
380
+ * Get feature service item IDs from applications webmaps
381
+ * As they are not explict dependencies of the application but are needed for field references
382
+ *
383
+ * @param template A webmap solution template
384
+ * @param templateTypeHash A simple lookup object populated with key item info
385
+ * @returns A list of feature service item IDs
386
+ * @private
387
+ */
388
+ function _getWebMapFSDependencies(template, templateTypeHash) {
389
+ const webMapFSDependencies = [];
390
+ template.dependencies.forEach(dep => {
391
+ const depObj = templateTypeHash[dep];
392
+ if (depObj.type === "Web Map") {
393
+ depObj.dependencies.forEach((depObjDependency) => {
394
+ /* istanbul ignore else */
395
+ if (templateTypeHash[depObjDependency].type === "Feature Service") {
396
+ webMapFSDependencies.push(depObjDependency);
397
+ }
398
+ });
399
+ }
400
+ });
401
+ return webMapFSDependencies;
402
+ }
403
+ exports._getWebMapFSDependencies = _getWebMapFSDependencies;
404
+ /**
405
+ * Perform templatizations needed in an item's resources
406
+ *
407
+ * @param itemTemplate Item being templatized
408
+ * @param resourceItemFiles Resources for the item; these resources are modified as needed
409
+ * by the templatization
410
+ * @param srcAuthentication Credentials for requests to source items
411
+ *
412
+ * @returns A promise that resolves when all templatization has completed
413
+ */
414
+ function _templatizeResources(itemTemplate, resourceItemFiles, srcAuthentication) {
415
+ const synchronizePromises = [];
416
+ if (itemTemplate.type === "Vector Tile Service") {
417
+ // Get the root.json files
418
+ const rootJsonResources = resourceItemFiles.filter(file => file.filename === "root.json");
419
+ const resourcePath = srcAuthentication.portal + "/content/items/" + itemTemplate.itemId;
420
+ const templatizedResourcePath = "{{" + itemTemplate.itemId + ".url}}";
421
+ const replacer = new RegExp(resourcePath, "g");
422
+ // Templatize the paths in the files that reference the source item id
423
+ rootJsonResources.forEach(rootFileResource => {
424
+ synchronizePromises.push(new Promise(resolve => {
425
+ // Read the file
426
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
427
+ (0, solution_common_1.blobToJson)(rootFileResource.file)
428
+ .then(fileJson => {
429
+ // Templatize by turning JSON into string, replacing paths with template, and re-JSONing
430
+ const updatedFileJson = JSON.parse(JSON.stringify(fileJson)
431
+ .replace(replacer, templatizedResourcePath));
432
+ // Write the changes back into the file
433
+ rootFileResource.file = (0, solution_common_1.jsonToFile)(updatedFileJson, rootFileResource.filename);
434
+ resolve(null);
435
+ });
436
+ }));
437
+ });
438
+ }
439
+ return Promise.all(synchronizePromises);
440
+ }
441
+ exports._templatizeResources = _templatizeResources;
442
+ //# sourceMappingURL=createItemTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createItemTemplate.js","sourceRoot":"","sources":["../../src/createItemTemplate.ts"],"names":[],"mappings":";AAAA;;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CAAC;yBACrB,OAAO,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAC9C,CAAC;oBAEJ,uCAAuC;oBACvC,gBAAgB,CAAC,IAAI,GAAG,IAAA,4BAAU,EAAC,eAAe,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;oBAE/E,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,CAAC;QACN,CAAC,CACF,CAAC;KACH;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAC1C,CAAC;AA1CD,oDA0CC"}
@@ -0,0 +1,97 @@
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 the creation of a Solution item.
18
+ *
19
+ * @module creator
20
+ */
21
+ import { ICreateSolutionOptions, IGroup, IItem, UserSession } from "@esri/solution-common";
22
+ import { IModel } from "@esri/hub-common";
23
+ /**
24
+ * Creates a solution item.
25
+ *
26
+ * @param sourceId AGO id of group whose contents are to be added to solution or of an item to convert into a solution
27
+ * @param srcAuthentication Credentials for requests to source items
28
+ * @param destAuthentication Credentials for the requests to destination solution
29
+ * @param options Customizations for creating the solution
30
+ * @returns A promise that resolves with the AGO id of the new solution
31
+ */
32
+ export declare function createSolution(sourceId: string, srcAuthentication: UserSession, destAuthentication: UserSession, options?: ICreateSolutionOptions): Promise<string>;
33
+ /**
34
+ * Update the createOptions with the group properties
35
+ *
36
+ * @param createOptions
37
+ * @param sourceInfo
38
+ * @param authentication
39
+ * @param isGroup Boolean to indicate if the files are associated with a group or item
40
+ * @private
41
+ */
42
+ export declare function _applySourceToCreateOptions(createOptions: ICreateSolutionOptions, sourceInfo: IGroup | IItem, srcAuthentication: UserSession, isGroup?: boolean): ICreateSolutionOptions;
43
+ /**
44
+ * Update the createOptions with the thumbnail file
45
+ *
46
+ * @param createOptions
47
+ * @param srcAuthentication
48
+ * @private
49
+ */
50
+ export declare function _addThumbnailFileToCreateOptions(createOptions: ICreateSolutionOptions, srcAuthentication: UserSession): Promise<ICreateSolutionOptions>;
51
+ /**
52
+ * Creates a solution item using a list of AGO item ids.
53
+ *
54
+ * @param options Customizations for creating the solution
55
+ * @param srcAuthentication Credentials for requests to source items
56
+ * @param destAuthentication Credentials for the requests to destination solution
57
+ * @returns A promise that resolves with the AGO id of the new solution; solution item is deleted if its
58
+ * there is a problem updating it
59
+ * @private
60
+ */
61
+ export declare function _createSolutionFromItemIds(options: ICreateSolutionOptions, srcAuthentication: UserSession, destAuthentication: UserSession): Promise<string>;
62
+ /**
63
+ * Creates an empty solution item.
64
+ *
65
+ * @param authentication Credentials for the request
66
+ * @param options Customizations for creating the solution
67
+ * @returns A promise that resolves with the AGO id of the new solution; solution item is deleted if its
68
+ * there is a problem updating its thumbnail
69
+ * @private
70
+ */
71
+ export declare function _createSolutionItem(authentication: UserSession, options?: ICreateSolutionOptions): Promise<string>;
72
+ /**
73
+ * Create the Solution Item model to be used to create
74
+ * the Solution Item itself
75
+ *
76
+ * @param options
77
+ * @private
78
+ */
79
+ export declare function _createSolutionItemModel(options: any): IModel;
80
+ /**
81
+ * Gets the deploy.id and deploy.version tag values.
82
+ *
83
+ * @param tags A list of item tags
84
+ * @returns A list containing the two values found in the tags, or defaulting to a new GUID and "1.0", respectively,
85
+ * as needed
86
+ * @private
87
+ */
88
+ export declare function _getDeploymentProperties(tags: string[]): string[];
89
+ /**
90
+ * Searches for a tag that has the specified prefix and returns the rest of the tag following that prefix.
91
+ *
92
+ * @param desiredTagPrefix Tag prefix to look for
93
+ * @param tags A list of item tags
94
+ * @returns The extracted value of the first matching tag or null if a tag with the specified prefix is not found
95
+ * @private
96
+ */
97
+ export declare function _getDeploymentProperty(desiredTagPrefix: string, tags: string[]): string | null;