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