@esri/solution-simple-types 3.0.1 → 3.1.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 (69) hide show
  1. package/dist/esm/helpers/convert-item-to-template.js +1 -0
  2. package/dist/esm/helpers/convert-item-to-template.js.map +1 -1
  3. package/dist/esm/webmap.js +6 -5
  4. package/dist/esm/webmap.js.map +1 -1
  5. package/package.json +6 -6
  6. package/dist/node/dashboard.d.ts +0 -93
  7. package/dist/node/dashboard.js +0 -354
  8. package/dist/node/dashboard.js.map +0 -1
  9. package/dist/node/helpers/convert-item-to-template.d.ts +0 -39
  10. package/dist/node/helpers/convert-item-to-template.js +0 -184
  11. package/dist/node/helpers/convert-item-to-template.js.map +0 -1
  12. package/dist/node/helpers/create-item-from-template.d.ts +0 -17
  13. package/dist/node/helpers/create-item-from-template.js +0 -138
  14. package/dist/node/helpers/create-item-from-template.js.map +0 -1
  15. package/dist/node/helpers/notebook-helpers.d.ts +0 -19
  16. package/dist/node/helpers/notebook-helpers.js +0 -25
  17. package/dist/node/helpers/notebook-helpers.js.map +0 -1
  18. package/dist/node/helpers/quickcapture-helpers.d.ts +0 -18
  19. package/dist/node/helpers/quickcapture-helpers.js +0 -23
  20. package/dist/node/helpers/quickcapture-helpers.js.map +0 -1
  21. package/dist/node/helpers/simple-type-helpers.d.ts +0 -18
  22. package/dist/node/helpers/simple-type-helpers.js +0 -23
  23. package/dist/node/helpers/simple-type-helpers.js.map +0 -1
  24. package/dist/node/helpers/update-notebook-data.d.ts +0 -17
  25. package/dist/node/helpers/update-notebook-data.js +0 -28
  26. package/dist/node/helpers/update-notebook-data.js.map +0 -1
  27. package/dist/node/index.d.ts +0 -27
  28. package/dist/node/index.js +0 -37
  29. package/dist/node/index.js.map +0 -1
  30. package/dist/node/notebook.d.ts +0 -66
  31. package/dist/node/notebook.js +0 -134
  32. package/dist/node/notebook.js.map +0 -1
  33. package/dist/node/oic.d.ts +0 -53
  34. package/dist/node/oic.js +0 -171
  35. package/dist/node/oic.js.map +0 -1
  36. package/dist/node/quickcapture.d.ts +0 -87
  37. package/dist/node/quickcapture.js +0 -193
  38. package/dist/node/quickcapture.js.map +0 -1
  39. package/dist/node/simple-types.d.ts +0 -57
  40. package/dist/node/simple-types.js +0 -95
  41. package/dist/node/simple-types.js.map +0 -1
  42. package/dist/node/webmap.d.ts +0 -101
  43. package/dist/node/webmap.js +0 -273
  44. package/dist/node/webmap.js.map +0 -1
  45. package/dist/node/webmappingapplication.d.ts +0 -176
  46. package/dist/node/webmappingapplication.js +0 -675
  47. package/dist/node/webmappingapplication.js.map +0 -1
  48. package/dist/node/workforce.d.ts +0 -34
  49. package/dist/node/workforce.js +0 -45
  50. package/dist/node/workforce.js.map +0 -1
  51. package/dist/umd/simple-types/src/dashboard.d.ts +0 -93
  52. package/dist/umd/simple-types/src/helpers/convert-item-to-template.d.ts +0 -39
  53. package/dist/umd/simple-types/src/helpers/create-item-from-template.d.ts +0 -17
  54. package/dist/umd/simple-types/src/helpers/notebook-helpers.d.ts +0 -19
  55. package/dist/umd/simple-types/src/helpers/quickcapture-helpers.d.ts +0 -18
  56. package/dist/umd/simple-types/src/helpers/simple-type-helpers.d.ts +0 -18
  57. package/dist/umd/simple-types/src/helpers/update-notebook-data.d.ts +0 -17
  58. package/dist/umd/simple-types/src/index.d.ts +0 -27
  59. package/dist/umd/simple-types/src/notebook.d.ts +0 -66
  60. package/dist/umd/simple-types/src/oic.d.ts +0 -53
  61. package/dist/umd/simple-types/src/quickcapture.d.ts +0 -87
  62. package/dist/umd/simple-types/src/simple-types.d.ts +0 -57
  63. package/dist/umd/simple-types/src/webmap.d.ts +0 -101
  64. package/dist/umd/simple-types/src/webmappingapplication.d.ts +0 -176
  65. package/dist/umd/simple-types/src/workforce.d.ts +0 -34
  66. package/dist/umd/simple-types.umd.js +0 -2296
  67. package/dist/umd/simple-types.umd.js.map +0 -1
  68. package/dist/umd/simple-types.umd.min.js +0 -19
  69. package/dist/umd/simple-types.umd.min.js.map +0 -1
@@ -1,2296 +0,0 @@
1
- /* @preserve
2
- * @esri/solution-simple-types - v1.7.0 - Apache-2.0
3
- * Copyright (c) 2018-2023 Esri, Inc.
4
- * Fri Apr 28 2023 11:22:29 GMT-0700 (Pacific Daylight Time)
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- (function (global, factory) {
19
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
20
- typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
21
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
22
- })(this, (function (exports, common) { 'use strict';
23
-
24
- function _interopNamespace(e) {
25
- if (e && e.__esModule) return e;
26
- var n = Object.create(null);
27
- if (e) {
28
- Object.keys(e).forEach(function (k) {
29
- if (k !== 'default') {
30
- var d = Object.getOwnPropertyDescriptor(e, k);
31
- Object.defineProperty(n, k, d.get ? d : {
32
- enumerable: true,
33
- get: function () { return e[k]; }
34
- });
35
- }
36
- });
37
- }
38
- n["default"] = e;
39
- return Object.freeze(n);
40
- }
41
-
42
- var common__namespace = /*#__PURE__*/_interopNamespace(common);
43
-
44
- /** @license
45
- * Copyright 2018 Esri
46
- *
47
- * Licensed under the Apache License, Version 2.0 (the "License");
48
- * you may not use this file except in compliance with the License.
49
- * You may obtain a copy of the License at
50
- *
51
- * http://www.apache.org/licenses/LICENSE-2.0
52
- *
53
- * Unless required by applicable law or agreed to in writing, software
54
- * distributed under the License is distributed on an "AS IS" BASIS,
55
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
- * See the License for the specific language governing permissions and
57
- * limitations under the License.
58
- */
59
- /**
60
- * Converts a dashboard item to a template.
61
- *
62
- * @param itemTemplate Template for the dashboard item
63
- * @param templateDictionary Hash of key details used for variable replacement
64
- * @returns templatized itemTemplate
65
- */
66
- function convertItemToTemplate$8(itemTemplate, templateDictionary) {
67
- return _extractDependencies$3(itemTemplate, templateDictionary);
68
- }
69
- /**
70
- * Templatizes all itemIds and updates the dependency array
71
- *
72
- * @param itemTemplate Template for the dashboard item
73
- * @param templateDictionary Hash of key details used for variable replacement
74
- * @returns The updated itemTemplate
75
- * @private
76
- */
77
- function _extractDependencies$3(itemTemplate, templateDictionary) {
78
- // get dependencies from any
79
- const updatePaths = [
80
- "data.desktopView.header",
81
- "data.desktopView.headerPanel.selectors",
82
- "data.desktopView.leftPanel.selectors",
83
- "data.desktopView.sidebar",
84
- "data.desktopView.urlParameters",
85
- "data.desktopView.widgets",
86
- "data.header",
87
- "data.headerPanel.selectors",
88
- "data.leftPanel.selectors",
89
- "data.mobileView.header",
90
- "data.mobileView.headerPanel.selectors",
91
- "data.mobileView.leftPanel.selectors",
92
- "data.mobileView.sidebar",
93
- "data.mobileView.urlParameters",
94
- "data.mobileView.widgets",
95
- "data.sidebar",
96
- "data.urlParameters",
97
- "data.widgets"
98
- ];
99
- updatePaths.forEach(path => {
100
- const objs = common__namespace.getProp(itemTemplate, path);
101
- if (Array.isArray(objs)) {
102
- objs.forEach(obj => {
103
- /* istanbul ignore else */
104
- if (obj.type === "mapWidget") {
105
- /* istanbul ignore else */
106
- if (itemTemplate.dependencies.indexOf(obj.itemId) < 0) {
107
- itemTemplate.dependencies.push(obj.itemId);
108
- }
109
- obj.itemId = common__namespace.templatizeTerm(obj.itemId, obj.itemId, ".itemId");
110
- }
111
- /* istanbul ignore else */
112
- if (Array.isArray(obj.datasets)) {
113
- _getDatasourceDependencies(obj, itemTemplate, templateDictionary);
114
- }
115
- });
116
- }
117
- });
118
- return itemTemplate;
119
- }
120
- /**
121
- * Templatize datasource itemIds and update the dependency array
122
- *
123
- * @param obj A widget, selector, or urlParameter that contains a datasets collection
124
- * @param itemTemplate Template for the dashboard item
125
- * @param templateDictionary Hash of key details used for variable replacement
126
- * @private
127
- */
128
- function _getDatasourceDependencies(obj, itemTemplate, templateDictionary) {
129
- obj.datasets.forEach((dataset) => {
130
- // when the datasource has an itemId is an external datasource
131
- const itemId = common__namespace.getProp(dataset, "dataSource.itemId");
132
- if (itemId) {
133
- if (itemTemplate.dependencies.indexOf(itemId) < 0) {
134
- itemTemplate.dependencies.push(itemId);
135
- }
136
- const layerId = common__namespace.getProp(dataset, "dataSource.layerId");
137
- common__namespace.cacheLayerInfo(layerId?.toString(), itemId, "", templateDictionary);
138
- dataset.dataSource.itemId = common__namespace.templatizeTerm(itemId, itemId, layerId !== undefined ? ".layer" + layerId + ".itemId" : ".itemId");
139
- /* istanbul ignore else */
140
- if (layerId !== undefined) {
141
- dataset.dataSource.layerId = common__namespace.templatizeTerm(itemId, itemId, ".layer" + layerId + ".layerId");
142
- }
143
- }
144
- });
145
- }
146
- /**
147
- * Templatize field references for datasources and widgets.
148
- *
149
- * @param solutionTemplate The solution item template
150
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
151
- * @returns The solutionTemplate with templatized field references
152
- */
153
- function postProcessFieldReferences$3(solutionTemplate, datasourceInfos) {
154
- const updatePaths = [
155
- "data.desktopView.header",
156
- "data.desktopView.headerPanel.selectors",
157
- "data.desktopView.leftPanel.selectors",
158
- "data.desktopView.sidebar",
159
- "data.desktopView.urlParameters",
160
- "data.desktopView.widgets",
161
- "data.header",
162
- "data.headerPanel.selectors",
163
- "data.leftPanel.selectors",
164
- "data.mobileView.header",
165
- "data.mobileView.headerPanel.selectors",
166
- "data.mobileView.leftPanel.selectors",
167
- "data.mobileView.sidebar",
168
- "data.mobileView.urlParameters",
169
- "data.mobileView.widgets",
170
- "data.sidebar",
171
- "data.urlParameters",
172
- "data.widgets"
173
- ];
174
- // dashboards reference datasets from other widgets
175
- // add reference IDs to the appropriate datasourceInfos
176
- updatePaths.forEach(path => {
177
- const objs = common__namespace.getProp(solutionTemplate, path);
178
- _updateDatasourceReferences(objs, datasourceInfos);
179
- });
180
- // after we know the potential references go ahead and templatize
181
- updatePaths.forEach(path => {
182
- _templatize$1(solutionTemplate, path, datasourceInfos);
183
- });
184
- return solutionTemplate;
185
- }
186
- /**
187
- * Add all dataset ids to the appropriate datasource info object so we can navigate any relative references
188
- *
189
- * @param objs Thes can be widgets, selectors, or urlParameters
190
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
191
- * @private
192
- */
193
- function _updateDatasourceReferences(objs, datasourceInfos) {
194
- // objects can be events or widgets
195
- /* istanbul ignore else */
196
- if (objs && Array.isArray(objs)) {
197
- objs.forEach(obj => {
198
- if (Array.isArray(obj.datasets)) {
199
- obj.datasets.forEach((dataset) => {
200
- // when the datasource has an itemId it's an external datasource
201
- const itemId = common__namespace.cleanLayerBasedItemId(common__namespace.getProp(dataset, "dataSource.itemId"));
202
- if (itemId) {
203
- const layerId = common__namespace.cleanLayerId(common__namespace.getProp(dataset, "dataSource.layerId"));
204
- datasourceInfos.some(ds => {
205
- if (ds.itemId === itemId && ds.layerId === layerId) {
206
- _updateReferences(ds, obj.id);
207
- return true;
208
- }
209
- else {
210
- return false;
211
- }
212
- });
213
- }
214
- else {
215
- // add placeholder for map layer datasource info so we can know the items that reference them
216
- // needed when item field reference are derived from another widgets datasource eg. <dashboardWidgetId>#datasetname
217
- const id = common__namespace.getProp(dataset, "dataSource.id");
218
- if (id) {
219
- const dashboardLayerId = id.split("#")[1];
220
- datasourceInfos.some(ds => {
221
- if (ds.ids.indexOf(dashboardLayerId) > -1) {
222
- _updateReferences(ds, obj.id);
223
- return true;
224
- }
225
- else {
226
- return false;
227
- }
228
- });
229
- }
230
- }
231
- });
232
- }
233
- });
234
- }
235
- }
236
- /**
237
- * Templatize all datasets and/or events for the objects at the given path
238
- *
239
- * @param itemTemplate Template for the dashboard item
240
- * @param path A property path to an array of objects that could contain datasets or events
241
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
242
- * @private
243
- */
244
- function _templatize$1(itemTemplate, path, datasourceInfos) {
245
- const obj = common__namespace.getProp(itemTemplate, path);
246
- /* istanbul ignore else */
247
- if (obj) {
248
- common__namespace.setProp(itemTemplate, path, _templatizeByDatasource(obj, datasourceInfos));
249
- }
250
- }
251
- /**
252
- * For any service dataset datasource templatize all field references
253
- *
254
- * @param objs A list of objects that can contain field references
255
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
256
- * @returns An updated list of objects with templatized field references
257
- * @private
258
- */
259
- function _templatizeByDatasource(objs, datasourceInfos) {
260
- if (Array.isArray(objs)) {
261
- return objs.map(obj => {
262
- let _obj = obj;
263
- if (Array.isArray(_obj.events)) {
264
- // Events can be associated with datasets but they can also be associated with a target
265
- // In some cases an event will have a source and a target.
266
- // Handle these specifically first to ensure that it has the correct layer reference
267
- _obj.events = _obj.events.map((event) => {
268
- const _event = event;
269
- /* istanbul ignore else */
270
- if (Array.isArray(_event.actions)) {
271
- _event.actions = _event.actions.map((action) => {
272
- const _action = action;
273
- if (_action.fieldMap &&
274
- _action.targetId &&
275
- _action.targetId.indexOf("#") > -1) {
276
- const datasourceInfo = _getDatasourceInfo$1(_action, datasourceInfos);
277
- /* istanbul ignore else */
278
- if (datasourceInfo) {
279
- const fields = common__namespace.getProp(datasourceInfo, "fields");
280
- const basePath = common__namespace.getProp(datasourceInfo, "basePath");
281
- /* istanbul ignore else */
282
- if (Array.isArray(fields) && basePath) {
283
- _action.fieldMap = _action.fieldMap.map((m) => {
284
- const _m = m;
285
- _m.targetName = common__namespace.templatizeFieldReferences(_m.targetName, fields, basePath);
286
- return _m;
287
- });
288
- }
289
- }
290
- }
291
- return _action;
292
- });
293
- }
294
- return _event;
295
- });
296
- }
297
- if (Array.isArray(_obj.datasets)) {
298
- _obj.datasets = _obj.datasets.map((dataset) => {
299
- let _dataset = dataset;
300
- if (_dataset.type === "serviceDataset") {
301
- const datasourceInfo = _getDatasourceInfo$1(dataset, datasourceInfos);
302
- /* istanbul ignore else */
303
- if (datasourceInfo) {
304
- const fields = common__namespace.getProp(datasourceInfo, "fields");
305
- const basePath = common__namespace.getProp(datasourceInfo, "basePath");
306
- /* istanbul ignore else */
307
- if (Array.isArray(fields) && basePath) {
308
- _obj = common__namespace.templatizeFieldReferences(_obj, fields, basePath);
309
- _dataset = common__namespace.templatizeFieldReferences(_dataset, fields, basePath);
310
- }
311
- }
312
- }
313
- return _dataset;
314
- });
315
- return _obj;
316
- }
317
- else
318
- return _obj;
319
- });
320
- }
321
- else {
322
- return objs;
323
- }
324
- }
325
- /**
326
- * Find the appropriate datasource info object from the datasourceInfo collection
327
- *
328
- * @param obj Can be a Dataset or an event
329
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
330
- * @returns The supporting datasource info for the given object
331
- * @private
332
- */
333
- function _getDatasourceInfo$1(obj, datasourceInfos) {
334
- let info;
335
- // the datasource will have an id property when it's referencing a map layer
336
- // the fields collection will already be defined
337
- const id = common__namespace.getProp(obj, "dataSource.id") || common__namespace.getProp(obj, "targetId");
338
- if (id) {
339
- const dashboardLayerId = id.split("#")[1];
340
- if (!datasourceInfos.some(di => {
341
- info = di.ids.indexOf(dashboardLayerId) > -1 ? di : info;
342
- return di.ids.indexOf(dashboardLayerId) > -1;
343
- })) {
344
- // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
345
- // in that case lookup the datasource from referenced widget
346
- const dashboardWidgetId = id.split("#")[0];
347
- datasourceInfos.some(di => {
348
- const references = di.references || [];
349
- const hasRef = references.indexOf(dashboardWidgetId) > -1;
350
- info = hasRef ? di : info;
351
- return hasRef;
352
- });
353
- }
354
- }
355
- else {
356
- // otherwise match the itemId and the layerId to get the correct fields and path
357
- const itemId = common__namespace.cleanLayerBasedItemId(common__namespace.getProp(obj, "dataSource.itemId"));
358
- const layerId = common__namespace.cleanLayerId(common__namespace.getProp(obj, "dataSource.layerId"));
359
- /* istanbul ignore else */
360
- if (itemId) {
361
- datasourceInfos.some(di => {
362
- const matches = itemId === di.itemId && layerId === di.layerId;
363
- info = matches ? di : info;
364
- return matches;
365
- });
366
- }
367
- }
368
- return info;
369
- }
370
- /**
371
- * Verifies if the datasource info contains the given id and adds it if not
372
- *
373
- * @param ds The datasource info to add the reference to
374
- * @param id The id from dashboard object, commonly another widget
375
- * @private
376
- */
377
- function _updateReferences(ds, id) {
378
- ds.references = Array.isArray(ds.references) ? ds.references : [];
379
- if (ds.references.indexOf(id) < 0) {
380
- ds.references.push(id);
381
- }
382
- }
383
-
384
- /** @license
385
- * Copyright 2020 Esri
386
- *
387
- * Licensed under the Apache License, Version 2.0 (the "License");
388
- * you may not use this file except in compliance with the License.
389
- * You may obtain a copy of the License at
390
- *
391
- * http://www.apache.org/licenses/LICENSE-2.0
392
- *
393
- * Unless required by applicable law or agreed to in writing, software
394
- * distributed under the License is distributed on an "AS IS" BASIS,
395
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
396
- * See the License for the specific language governing permissions and
397
- * limitations under the License.
398
- */
399
- // ------------------------------------------------------------------------------------------------------------------ //
400
- /**
401
- * Converts a web mapping application item into a template.
402
- *
403
- * @param itemInfo Info about the item
404
- * @param destAuthentication Credentials for requests to the destination organization
405
- * @param srcAuthentication Credentials for requests to source items
406
- * @param templateDictionary Hash of key details used for variable replacement
407
- * @returns A promise that will resolve when the template has been created
408
- */
409
- function convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
410
- return new Promise((resolve, reject) => {
411
- // Remove org base URL and app id, e.g.,
412
- // http://anOrg.maps.arcgis.com/apps/CrowdsourcePolling/index.html?appid=6fc5992522d34a6b5ce80d17835eea21
413
- // to
414
- // <placeholder(SERVER_NAME)>/apps/CrowdsourcePolling/index.html?appid={{<itemId>.id}}
415
- // Need to add placeholder server name because otherwise AGOL makes URL null
416
- let portalUrl = "";
417
- if (itemTemplate.item.url) {
418
- const templatizedUrl = itemTemplate.item.url;
419
- const iSep = templatizedUrl.indexOf("//");
420
- itemTemplate.item.url =
421
- common__namespace.placeholder(common__namespace.SERVER_NAME) + // add placeholder server name
422
- templatizedUrl.substring(templatizedUrl.indexOf("/", iSep + 2), templatizedUrl.lastIndexOf("=") + 1) +
423
- itemTemplate.item.id; // templatized id
424
- portalUrl = templatizedUrl.replace(templatizedUrl.substring(templatizedUrl.indexOf("/", iSep + 2)), "");
425
- }
426
- // Extract dependencies
427
- itemTemplate.dependencies = _extractDependencies$2(itemTemplate);
428
- // Set the folder
429
- common__namespace.setProp(itemTemplate, "data.folderId", "{{folderId}}");
430
- // Set the map or group after we've extracted them as dependencies
431
- _templatizeIdPaths(itemTemplate, [
432
- "data.map.itemId",
433
- "data.map.appProxy.mapItemId",
434
- "data.values.webmap",
435
- "data.values.group"
436
- ]);
437
- // force the appItemId to be pulled directly from the template item
438
- // this is to address solution.js #124
439
- _templatizeIdPath(itemTemplate, "data.appItemId", itemTemplate.itemId);
440
- setValues(itemTemplate, [
441
- "data.logo",
442
- "data.map.portalUrl",
443
- "data.portalUrl",
444
- "data.httpProxy.url"
445
- ], common__namespace.placeholder(common__namespace.SERVER_NAME));
446
- common__namespace.setProp(itemTemplate, "data.geometryService", common__namespace.placeholder(common__namespace.GEOMETRY_SERVER_NAME));
447
- templatizeDatasources(itemTemplate, srcAuthentication, portalUrl, templateDictionary).then(() => {
448
- templatizeWidgets(itemTemplate, srcAuthentication, portalUrl, "data.widgetPool.widgets").then(_itemTemplate => {
449
- templatizeWidgets(_itemTemplate, srcAuthentication, portalUrl, "data.widgetOnScreen.widgets", true).then(updatedItemTemplate => {
450
- templatizeValues(updatedItemTemplate, srcAuthentication, portalUrl, "data.values").then(_updatedItemTemplate => {
451
- resolve(_updatedItemTemplate);
452
- }, e => reject(common__namespace.fail(e)));
453
- }, e => reject(common__namespace.fail(e)));
454
- }, e => reject(common__namespace.fail(e)));
455
- }, e => reject(common__namespace.fail(e)));
456
- });
457
- }
458
- /**
459
- * Converts web mapping application datasources to variables for deployment
460
- *
461
- * @param itemTemplate The solution item template
462
- * @param authentication Credentials for requests
463
- * @param portalUrl Rest Url of the portal to perform the search
464
- * @param templateDictionary Hash of key details used for variable replacement
465
- * @returns A promise that will resolve with the created template
466
- */
467
- function templatizeDatasources(itemTemplate, authentication, portalUrl, templateDictionary) {
468
- return new Promise((resolve, reject) => {
469
- const dataSources = common__namespace.getProp(itemTemplate, "data.dataSource.dataSources");
470
- if (dataSources && Object.keys(dataSources).length > 0) {
471
- const pendingRequests = new Array();
472
- Object.keys(dataSources).forEach(k => {
473
- const ds = dataSources[k];
474
- common__namespace.setProp(ds, "portalUrl", common__namespace.placeholder(common__namespace.SERVER_NAME));
475
- const itemId = common__namespace.getProp(ds, "itemId");
476
- if (common__namespace.getProp(ds, "url")) {
477
- if (itemId) {
478
- const layerId = ds.url.substr(ds.url.lastIndexOf("/") + 1);
479
- common__namespace.cacheLayerInfo(layerId.toString(), itemId, ds.url, templateDictionary);
480
- ds.itemId = common__namespace.templatizeTerm(itemId, itemId, ".layer" + layerId + ".itemId");
481
- }
482
- const urlResults = findUrls(ds.url, portalUrl, [], [], authentication);
483
- pendingRequests.push(new Promise((resolveReq, rejectReq) => {
484
- handleServiceRequests(urlResults.serviceRequests, urlResults.requestUrls, urlResults.testString).then(response => {
485
- ds.url = response;
486
- resolveReq();
487
- }, e => rejectReq(common__namespace.fail(e)));
488
- }));
489
- }
490
- else {
491
- if (itemId) {
492
- ds.itemId = common__namespace.templatizeTerm(itemId, itemId, ".itemId");
493
- }
494
- }
495
- });
496
- Promise.all(pendingRequests).then(() => resolve(itemTemplate), e => reject(common__namespace.fail(e)));
497
- }
498
- else {
499
- resolve(itemTemplate);
500
- }
501
- });
502
- }
503
- function templatizeWidgets(itemTemplate, authentication, portalUrl, widgetPath, isOnScreen = false) {
504
- return new Promise((resolve, reject) => {
505
- // update widgets
506
- const widgets = common__namespace.getProp(itemTemplate, widgetPath) || [];
507
- let serviceRequests = [];
508
- let requestUrls = [];
509
- widgets.forEach(widget => {
510
- /* istanbul ignore else */
511
- if (!isOnScreen && common__namespace.getProp(widget, "icon")) {
512
- setValues(widget, ["icon"], common__namespace.placeholder(common__namespace.SERVER_NAME));
513
- }
514
- const config = widget.config;
515
- if (config) {
516
- const sConfig = JSON.stringify(config);
517
- const urlResults = findUrls(sConfig, portalUrl, requestUrls, serviceRequests, authentication);
518
- widget.config = JSON.parse(urlResults.testString);
519
- serviceRequests = urlResults.serviceRequests;
520
- requestUrls = urlResults.requestUrls;
521
- }
522
- });
523
- if (serviceRequests.length > 0) {
524
- const sWidgets = JSON.stringify(widgets);
525
- handleServiceRequests(serviceRequests, requestUrls, sWidgets).then(response => {
526
- common__namespace.setProp(itemTemplate, widgetPath, JSON.parse(response));
527
- resolve(itemTemplate);
528
- }, e => reject(common__namespace.fail(e)));
529
- }
530
- else {
531
- resolve(itemTemplate);
532
- }
533
- });
534
- }
535
- function templatizeValues(itemTemplate, authentication, portalUrl, widgetPath) {
536
- return new Promise((resolve, reject) => {
537
- // update properties of values collection for web app templates
538
- let values = common__namespace.getProp(itemTemplate, widgetPath);
539
- let serviceRequests = [];
540
- let requestUrls = [];
541
- if (values) {
542
- if (common__namespace.getProp(values, "icon")) {
543
- setValues(values, ["icon"], common__namespace.placeholder(common__namespace.SERVER_NAME));
544
- }
545
- const sConfig = JSON.stringify(values);
546
- const urlResults = findUrls(sConfig, portalUrl, requestUrls, serviceRequests, authentication);
547
- values = JSON.parse(urlResults.testString);
548
- serviceRequests = urlResults.serviceRequests;
549
- requestUrls = urlResults.requestUrls;
550
- }
551
- if (serviceRequests.length > 0) {
552
- const sWidgets = JSON.stringify(values);
553
- handleServiceRequests(serviceRequests, requestUrls, sWidgets).then(response => {
554
- common__namespace.setProp(itemTemplate, widgetPath, JSON.parse(response));
555
- resolve(itemTemplate);
556
- }, e => reject(common__namespace.fail(e)));
557
- }
558
- else {
559
- resolve(itemTemplate);
560
- }
561
- });
562
- }
563
- function handleServiceRequests(serviceRequests, requestUrls, objString) {
564
- return new Promise((resolve, reject) => {
565
- if (serviceRequests && serviceRequests.length > 0) {
566
- let i = 0;
567
- Promise.all(serviceRequests).then(serviceResponses => {
568
- serviceResponses.forEach(serviceResponse => {
569
- if (common__namespace.getProp(serviceResponse, "serviceItemId")) {
570
- const serviceTemplate = "{{" +
571
- serviceResponse.serviceItemId +
572
- (serviceResponse.hasOwnProperty("id")
573
- ? ".layer" + serviceResponse.id
574
- : "") +
575
- ".url}}";
576
- objString = replaceUrl(objString, requestUrls[i], serviceTemplate, true);
577
- }
578
- i++;
579
- });
580
- resolve(objString);
581
- }, e => reject(common__namespace.fail(e)));
582
- }
583
- else {
584
- resolve(objString);
585
- }
586
- });
587
- }
588
- function findUrls(testString, portalUrl, requestUrls, serviceRequests, authentication) {
589
- const options = {
590
- f: "json",
591
- authentication: authentication
592
- };
593
- // test for URLs
594
- const results = testString.match(/(\bhttps?:\/\/[-A-Z0-9/._]*)/gim);
595
- if (results && results.length) {
596
- results.forEach((url) => {
597
- if (url.indexOf("NAServer") > -1) {
598
- testString = replaceUrl(testString, url, common__namespace.placeholder(common__namespace.NA_SERVER_NAME));
599
- }
600
- else if (url.indexOf("GeocodeServer") > -1) {
601
- testString = replaceUrl(testString, url, common__namespace.placeholder(common__namespace.GEOCODE_SERVER_NAME));
602
- }
603
- else if (portalUrl && url.indexOf(portalUrl) > -1) {
604
- testString = replaceUrl(testString, portalUrl, common__namespace.placeholder(common__namespace.SERVER_NAME));
605
- }
606
- else if (url.indexOf("FeatureServer") > -1) {
607
- if (requestUrls.indexOf(url) === -1) {
608
- requestUrls.push(url);
609
- serviceRequests.push(common__namespace.rest_request(url, options));
610
- }
611
- }
612
- });
613
- }
614
- return {
615
- testString,
616
- requestUrls,
617
- serviceRequests
618
- };
619
- }
620
- /**
621
- * Replace url with templatized url value
622
- *
623
- * @param obj can be a single url string or a stringified JSON object
624
- * @param url the current url we are testing for
625
- * @param newUrl the templatized url
626
- * @param validateFullUrl should only replace url when we have a full match.
627
- * This property is only relevant when the obj is a stringified JSON object.
628
- *
629
- * @returns the obj with any instances of the url replaced
630
- */
631
- function replaceUrl(obj, url, newUrl, validateFullUrl = false) {
632
- const enforceFullUrl = validateFullUrl && obj.indexOf('"') > -1;
633
- const re = new RegExp(enforceFullUrl ? '"' + url + '"' : url, "gmi");
634
- return obj.replace(re, enforceFullUrl ? '"' + newUrl + '"' : newUrl);
635
- }
636
- function setValues(itemTemplate, paths, base) {
637
- paths.forEach(path => {
638
- const url = common__namespace.getProp(itemTemplate, path);
639
- if (url) {
640
- const subString = url.substring(url.indexOf("/", url.indexOf("//") + 2));
641
- common__namespace.setProp(itemTemplate, path, subString !== url ? base + subString : base);
642
- }
643
- });
644
- }
645
- function fineTuneCreatedItem$2(originalTemplate, newlyCreatedItem, templateDictionary, destinationAuthentication) {
646
- return new Promise(resolve => {
647
- // If this is a Web AppBuilder application, we will create a Code Attachment for downloading
648
- if (common__namespace.hasAnyKeyword(originalTemplate, [
649
- "WAB2D",
650
- "WAB3D",
651
- "Web AppBuilder"
652
- ])) {
653
- // Update item so properties like appItemId can now be set now that we know the new apps ID
654
- const updateOptions = {
655
- id: newlyCreatedItem.itemId,
656
- url: newlyCreatedItem.item.url,
657
- data: newlyCreatedItem.data
658
- };
659
- const updateDef = common__namespace.updateItem(updateOptions, destinationAuthentication);
660
- const itemInfo = {
661
- tags: originalTemplate.item.tags,
662
- title: originalTemplate.item.title,
663
- type: "Code Attachment",
664
- typeKeywords: ["Code", "Javascript", "Web Mapping Application"],
665
- relationshipType: "WMA2Code",
666
- originItemId: newlyCreatedItem.itemId,
667
- url: common__namespace.checkUrlPathTermination(common__namespace.replaceInTemplate(common__namespace.placeholder(common__namespace.SERVER_NAME), templateDictionary)) +
668
- "sharing/rest/content/items/" +
669
- newlyCreatedItem.itemId +
670
- "/package"
671
- };
672
- const createItemWithDataDef = common__namespace.createItemWithData(itemInfo, {}, destinationAuthentication, templateDictionary.folderId);
673
- Promise.all([updateDef, createItemWithDataDef]).then(() => resolve(null), () => resolve(null));
674
- }
675
- else {
676
- // Otherwise, nothing extra needed
677
- resolve(null);
678
- }
679
- });
680
- }
681
- // ------------------------------------------------------------------------------------------------------------------ //
682
- /**
683
- * Gets the ids of the dependencies of an AGOL webapp item.
684
- *
685
- * @param fullItem A webapp item whose dependencies are sought
686
- * @returns A promise that will resolve with list of dependent ids
687
- * @private
688
- */
689
- function _extractDependencies$2(model) {
690
- let processor = _getGenericWebAppDependencies;
691
- /*
692
- if (common.hasTypeKeyword(model, "Story Map")) {
693
- processor = getStoryMapDependencies;
694
- }
695
- */
696
- if (common__namespace.hasAnyKeyword(model, ["WAB2D", "WAB3D", "Web AppBuilder"])) {
697
- processor = _getWABDependencies;
698
- }
699
- return processor(model);
700
- }
701
- /**
702
- * Generic Web App Dependencies
703
- *
704
- * @private
705
- */
706
- function _getGenericWebAppDependencies(model) {
707
- const props = ["data.values.webmap", "data.values.group"];
708
- return common__namespace.getProps(model, props);
709
- }
710
- //???
711
- function _getWABDependencies(model) {
712
- const deps = [];
713
- const v = common__namespace.getProp(model, "data.map.itemId");
714
- if (v) {
715
- deps.push(v);
716
- }
717
- const dataSources = common__namespace.getProp(model, "data.dataSource.dataSources");
718
- if (dataSources) {
719
- Object.keys(dataSources).forEach(k => {
720
- const ds = dataSources[k];
721
- if (ds.itemId) {
722
- deps.push(ds.itemId);
723
- }
724
- });
725
- }
726
- return deps;
727
- }
728
- /**
729
- * Templatizes id properties for the paths provided
730
- *
731
- * @param itemTemplate The solution item template
732
- * @param paths A list of property paths that contain ids
733
- * @private
734
- */
735
- function _templatizeIdPaths(itemTemplate, paths) {
736
- paths.forEach(path => {
737
- const id = common__namespace.getProp(itemTemplate, path);
738
- _templatizeIdPath(itemTemplate, path, id);
739
- });
740
- }
741
- /**
742
- * Templatizes id property for the path provided
743
- *
744
- * @param itemTemplate The solution item template
745
- * @param path A path to an id property
746
- * @param id The base id to use when templatizing
747
- * @private
748
- */
749
- function _templatizeIdPath(itemTemplate, path, id) {
750
- common__namespace.setProp(itemTemplate, path, common__namespace.templatizeTerm(id, id, ".itemId"));
751
- }
752
- /**
753
- * Templatize field references for datasources and widgets.
754
- *
755
- * @param solutionTemplate The solution item template
756
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
757
- * @returns The solutionTemplate with templatized field references
758
- */
759
- function postProcessFieldReferences$2(solutionTemplate, datasourceInfos) {
760
- // handle datasources common for WAB apps
761
- const dataSources = common__namespace.getProp(solutionTemplate, "data.dataSource.dataSources");
762
- if (dataSources && Object.keys(dataSources).length > 0) {
763
- Object.keys(dataSources).forEach(k => {
764
- const ds = dataSources[k];
765
- dataSources[k] = _templatizeObject(ds, datasourceInfos);
766
- });
767
- common__namespace.setProp(solutionTemplate, "data.dataSource.dataSources", dataSources);
768
- }
769
- // handle widgets common for WAB apps
770
- const paths = [
771
- "data.widgetPool.widgets",
772
- "data.widgetOnScreen.widgets"
773
- ];
774
- paths.forEach(path => {
775
- const widgets = common__namespace.getProp(solutionTemplate, path);
776
- if (widgets) {
777
- common__namespace.setProp(solutionTemplate, path, _templatizeObjectArray(widgets, datasourceInfos));
778
- }
779
- });
780
- // handle values common for web app templates
781
- const values = common__namespace.getProp(solutionTemplate, "data.values");
782
- if (values) {
783
- common__namespace.setProp(solutionTemplate, "data.values", _templatizeObject(values, datasourceInfos));
784
- }
785
- return solutionTemplate;
786
- }
787
- /**
788
- * Templatize field references for given dataSource from the web application.
789
- *
790
- * @param obj The dataSource or widget object from the web application.
791
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
792
- * @returns The dataSource with templatized field references
793
- * @private
794
- */
795
- function _templatizeObject(obj, datasourceInfos, templatizeKeys = false) {
796
- obj = _prioritizedTests(obj, datasourceInfos, templatizeKeys);
797
- const replaceOrder = _getReplaceOrder(obj, datasourceInfos);
798
- replaceOrder.forEach(ds => {
799
- obj = common__namespace.templatizeFieldReferences(obj, ds.fields, ds.basePath, templatizeKeys);
800
- });
801
- return obj;
802
- }
803
- /**
804
- * Templatize field references from an array of various objects from the web application.
805
- *
806
- * @param objects A list of widgets or objects from the web application that may contain field references.
807
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
808
- * @returns The widgets with templatized field references
809
- * @private
810
- */
811
- function _templatizeObjectArray(objects, datasourceInfos) {
812
- const updateKeyObjects = ["SmartEditor", "Screening"];
813
- return objects.map(obj => {
814
- // only templatize the config and lower
815
- if (obj.config) {
816
- const templatizeKeys = updateKeyObjects.indexOf(obj.name) > -1;
817
- obj.config = _templatizeObject(obj.config, datasourceInfos, templatizeKeys);
818
- }
819
- return obj;
820
- });
821
- }
822
- /**
823
- * Gets an order for testing wit the various datasource info objects against the widget or dataSource.
824
- * A widget or dataSource that contain a layers url or webmap layer id are more likely
825
- * to have field references from that layer.
826
- *
827
- * @param obj The dataSource or widget object from the web application.
828
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
829
- * @returns A list of datasourceInfo objects sorted based on the presence of a layers url or id
830
- * @private
831
- */
832
- function _getReplaceOrder(obj, datasourceInfos) {
833
- const objString = JSON.stringify(obj);
834
- // If we don't find any layer url, web map layer id, service url, agol itemId then remove the datasource.
835
- const _datasourceInfos = datasourceInfos.filter(ds => _getSortOrder(ds, objString) < 4);
836
- return _datasourceInfos.sort((a, b) => {
837
- return _getSortOrder(a, objString) - _getSortOrder(b, objString);
838
- });
839
- }
840
- /**
841
- * Determine an order for checking field names against a dataSource or widget.
842
- * Sort order preference is set in this order: layer url, web map layer id, service url, agol itemId
843
- *
844
- * @param datasourceInfo The datasource object with key properties about the service.
845
- * @param testString A stringified version of a widget or dataSource
846
- * @returns The prioritized order for testing
847
- * @private
848
- */
849
- function _getSortOrder(datasourceInfo, testString) {
850
- const url = datasourceInfo.url;
851
- const itemId = datasourceInfo.itemId;
852
- const layerId = datasourceInfo.layerId;
853
- // if we have the url and the layerID and its found prioritize it first
854
- // else if we find the maps layer id prioritze it first
855
- let layerUrlTest;
856
- if (url && !isNaN(layerId)) {
857
- layerUrlTest = new RegExp(url.replace(/[.]/, ".layer" + layerId + "."), "gm");
858
- }
859
- if (layerUrlTest && layerUrlTest.test(testString)) {
860
- return 1;
861
- }
862
- else if (datasourceInfo.ids.length > 0) {
863
- if (datasourceInfo.ids.some(id => {
864
- const layerMapIdTest = new RegExp(id, "gm");
865
- return layerMapIdTest.test(testString);
866
- })) {
867
- return 1;
868
- }
869
- }
870
- // if neither full layer url or map layer id are found...check to see if we can
871
- // find the base service url
872
- if (url) {
873
- const serviceUrlTest = new RegExp(url, "gm");
874
- if (serviceUrlTest.test(testString)) {
875
- return 2;
876
- }
877
- }
878
- // if none of the above see if we can find an AGOL item id reference
879
- if (itemId) {
880
- const itemIdTest = new RegExp(itemId, "gm");
881
- if (itemIdTest.test(testString)) {
882
- return 3;
883
- }
884
- }
885
- return 4;
886
- }
887
- /**
888
- * These tests will run prior to the tests associated with the higher level tests based on sort order.
889
- * The tests work more like cloning an object where we go through and review each individual property.
890
- * If we find a url or webmap layer id we will templatize the parent object that contains this property.
891
- * Many widgets will store one of these two properties in an object that will also contain various field references.
892
- *
893
- * @param obj The dataSource or widget object from the application
894
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
895
- * @returns An updated instance of the dataSource or widget with as many field references templatized as possible.
896
- * @private
897
- */
898
- function _prioritizedTests(obj, datasourceInfos, templatizeKeys) {
899
- const objString = JSON.stringify(obj);
900
- const hasDatasources = datasourceInfos.filter(ds => {
901
- let urlTest;
902
- if (ds.url && !isNaN(ds.layerId)) {
903
- urlTest = new RegExp(ds.url.replace(/[.]/, ".layer" + ds.layerId + "."), "gm");
904
- }
905
- let hasMapLayerId = false;
906
- if (ds.ids.length > 0) {
907
- hasMapLayerId = ds.ids.some(id => {
908
- const idTest = new RegExp(id, "gm");
909
- return idTest.test(objString);
910
- });
911
- }
912
- if (hasMapLayerId || (urlTest && urlTest.test(objString))) {
913
- return ds;
914
- }
915
- });
916
- if (hasDatasources.length > 0) {
917
- hasDatasources.forEach(ds => {
918
- // specific url reference is the most common
919
- obj = _templatizeParentByURL(obj, ds, templatizeKeys);
920
- if (ds.ids.length > 0) {
921
- // the second most common is to use the layerId from the webmap
922
- ds.ids.forEach(id => {
923
- obj = _templatizeParentByWebMapLayerId(obj, ds, id, templatizeKeys);
924
- });
925
- }
926
- });
927
- }
928
- return obj;
929
- }
930
- /**
931
- * This is very close to common.cloneObject but will test if an object
932
- * has one of the datasource urls as a property. If it finds one it will
933
- * templatize it's parent based on the fields from that datasource
934
- *
935
- * @param obj The dataSource or widget object from the application
936
- * @param ds A datasourceInfo object to use for testing against the current dataSource or widget
937
- * @returns The updated instance of the object with as many field references templatized as possible
938
- * @private
939
- */
940
- function _templatizeParentByURL(obj, ds, templatizeKeys) {
941
- let clone = {};
942
- const url = ds.url;
943
- const layerId = ds.layerId;
944
- let urlTest;
945
- if (url && !isNaN(layerId)) {
946
- urlTest = new RegExp(url.replace(/[.]/, ".layer" + layerId + "."), "gm");
947
- }
948
- if (Array.isArray(obj)) {
949
- clone = obj.map(c => {
950
- return _templatizeParentByURL(c, ds, templatizeKeys);
951
- });
952
- }
953
- else if (typeof obj === "object") {
954
- for (const i in obj) {
955
- if (obj[i] != null && typeof obj[i] === "object") {
956
- clone[i] = _templatizeParentByURL(obj[i], ds, templatizeKeys);
957
- }
958
- else {
959
- if (urlTest && urlTest.test(obj[i])) {
960
- obj = common__namespace.templatizeFieldReferences(obj, ds.fields, ds.basePath, templatizeKeys);
961
- }
962
- clone[i] = obj[i];
963
- }
964
- }
965
- }
966
- else {
967
- clone = obj;
968
- }
969
- return clone;
970
- }
971
- /**
972
- * This is very close to common.cloneObject but will test if an object
973
- * has one of the datasource webmap layer ids as a property. If it finds one it will
974
- * templatize it's parent based on the fields from that datasource.
975
- *
976
- * @param obj The dataSource or widget object from the application
977
- * @param ds A datasourceInfo object to use for testing against the current dataSource or widget
978
- * @param id A webmap layer id to test with.
979
- * @returns The updated instance of the object with as many field references templatized as possible
980
- * @private
981
- */
982
- function _templatizeParentByWebMapLayerId(obj, ds, id, templatizeKeys) {
983
- let clone = {};
984
- const idTest = new RegExp(id, "gm");
985
- if (Array.isArray(obj)) {
986
- clone = obj.map(c => {
987
- return _templatizeParentByWebMapLayerId(c, ds, id, templatizeKeys);
988
- });
989
- }
990
- else if (typeof obj === "object") {
991
- for (const i in obj) {
992
- if (obj[i] !== null) {
993
- // In some web application templates they store a stringified version of an object that can
994
- // contain multiple layer references at a very high level on the main values collection.
995
- // This was causing many other more typical layer references to be set incorrectly as the first
996
- // layerId found in this high level string would be used against the main object.
997
- let parsedProp;
998
- try {
999
- parsedProp = JSON.parse(obj[i]);
1000
- }
1001
- catch (error) {
1002
- parsedProp = undefined;
1003
- }
1004
- if (parsedProp && typeof parsedProp === "object") {
1005
- clone[i] = JSON.stringify(_templatizeParentByWebMapLayerId(parsedProp, ds, id, templatizeKeys));
1006
- }
1007
- else if (typeof obj[i] === "object") {
1008
- // some widgets store the layerId as a key to a collection of details that contain field references
1009
- if (idTest.test(i) && templatizeKeys) {
1010
- obj[i] = common__namespace.templatizeFieldReferences(obj[i], ds.fields, ds.basePath, templatizeKeys);
1011
- }
1012
- clone[i] = _templatizeParentByWebMapLayerId(obj[i], ds, id, templatizeKeys);
1013
- }
1014
- else {
1015
- if (idTest.test(obj[i])) {
1016
- obj = common__namespace.templatizeFieldReferences(obj, ds.fields, ds.basePath, templatizeKeys);
1017
- }
1018
- clone[i] = obj[i];
1019
- }
1020
- }
1021
- else {
1022
- clone[i] = obj[i];
1023
- }
1024
- }
1025
- }
1026
- else {
1027
- clone = obj;
1028
- }
1029
- return clone;
1030
- }
1031
-
1032
- /** @license
1033
- * Copyright 2018 Esri
1034
- *
1035
- * Licensed under the Apache License, Version 2.0 (the "License");
1036
- * you may not use this file except in compliance with the License.
1037
- * You may obtain a copy of the License at
1038
- *
1039
- * http://www.apache.org/licenses/LICENSE-2.0
1040
- *
1041
- * Unless required by applicable law or agreed to in writing, software
1042
- * distributed under the License is distributed on an "AS IS" BASIS,
1043
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1044
- * See the License for the specific language governing permissions and
1045
- * limitations under the License.
1046
- */
1047
- /**
1048
- * Converts an workforce item to a template.
1049
- *
1050
- * @param itemTemplate template for the workforce project item
1051
- * @param destAuthentication Credentials for requests to the destination organization
1052
- * @param srcAuthentication Credentials for requests to source items
1053
- * @param templateDictionary Hash of key details used for variable replacement
1054
- * @returns templatized itemTemplate
1055
- */
1056
- function convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
1057
- return common__namespace.convertWorkforceItemToTemplate(itemTemplate, srcAuthentication, templateDictionary);
1058
- }
1059
- /**
1060
- * Gets the current user and updates the dispatchers service
1061
- *
1062
- * @param newlyCreatedItem Item to be created; n.b.: this item is modified
1063
- * @param destinationAuthentication The session used to create the new item(s)
1064
- * @returns A promise that will resolve with { "success" === true || false }
1065
- */
1066
- function fineTuneCreatedItem$1(newlyCreatedItem, destinationAuthentication, templateDictionary) {
1067
- return common__namespace.fineTuneCreatedWorkforceItem(newlyCreatedItem, destinationAuthentication, "", templateDictionary);
1068
- }
1069
-
1070
- /** @license
1071
- * Copyright 2020 Esri
1072
- *
1073
- * Licensed under the Apache License, Version 2.0 (the "License");
1074
- * you may not use this file except in compliance with the License.
1075
- * You may obtain a copy of the License at
1076
- *
1077
- * http://www.apache.org/licenses/LICENSE-2.0
1078
- *
1079
- * Unless required by applicable law or agreed to in writing, software
1080
- * distributed under the License is distributed on an "AS IS" BASIS,
1081
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1082
- * See the License for the specific language governing permissions and
1083
- * limitations under the License.
1084
- */
1085
- function createItemFromTemplate$3(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
1086
- return new Promise(resolve => {
1087
- // Interrupt process if progress callback returns `false`
1088
- if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Started, 0)) {
1089
- itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Ignored, 0);
1090
- resolve(common__namespace.generateEmptyCreationResponse(template.type));
1091
- }
1092
- else {
1093
- // Replace the templatized symbols in a copy of the template
1094
- let newItemTemplate = common__namespace.cloneObject(template);
1095
- newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
1096
- // Create the item, then update its URL with its new id
1097
- // some fieldnames are used as keys for objects
1098
- // when we templatize field references for web applications we first stringify the components of the
1099
- // web application that could contain field references and then serach for them with a regular expression.
1100
- // We also need to stringify the web application when de-templatizing so it will find all of these occurrences as well.
1101
- if (template.type === "Web Mapping Application" && template.data) {
1102
- newItemTemplate = JSON.parse(common__namespace.replaceInTemplate(JSON.stringify(newItemTemplate), templateDictionary));
1103
- }
1104
- if (template.item.thumbnail) {
1105
- newItemTemplate.item.thumbnail = template.item.thumbnail; // make sure that our File is still there
1106
- }
1107
- common__namespace
1108
- .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
1109
- .then(createResponse => {
1110
- // Interrupt process if progress callback returns `false`
1111
- if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
1112
- itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
1113
- common__namespace
1114
- .removeItem(createResponse.id, destinationAuthentication)
1115
- .then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
1116
- }
1117
- else {
1118
- // Add the new item to the settings
1119
- templateDictionary[template.itemId] = {
1120
- itemId: createResponse.id
1121
- };
1122
- newItemTemplate.itemId = createResponse.id;
1123
- // Set the appItemId manually to get around cases where the path was incorrectly set
1124
- // in legacy deployments
1125
- if (newItemTemplate.type === "Web Mapping Application" &&
1126
- template.data) {
1127
- common__namespace.setProp(newItemTemplate, "data.appItemId", createResponse.id);
1128
- }
1129
- const postProcess = common__namespace.hasUnresolvedVariables(newItemTemplate.data);
1130
- // Update the template again now that we have the new item id
1131
- const originalURL = newItemTemplate.item.url;
1132
- newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
1133
- // Update relationships
1134
- let relationshipsDef = Promise.resolve([]);
1135
- if (newItemTemplate.relatedItems) {
1136
- // Templatize references in relationships obj
1137
- const updatedRelatedItems = common__namespace.replaceInTemplate(common__namespace.templatizeIds(newItemTemplate.relatedItems), templateDictionary);
1138
- // Add the relationships
1139
- relationshipsDef = common__namespace.addForwardItemRelationships(newItemTemplate.itemId, updatedRelatedItems, destinationAuthentication);
1140
- }
1141
- // Check for extra processing for web mapping application et al.
1142
- let customProcDef;
1143
- if (template.type === "Web Mapping Application" &&
1144
- template.data &&
1145
- common__namespace.hasAnyKeyword(template, [
1146
- "WAB2D",
1147
- "WAB3D",
1148
- "Web AppBuilder"
1149
- ])) {
1150
- // If this is a Web AppBuilder application, we will create a Code Attachment for downloading
1151
- customProcDef = fineTuneCreatedItem$2(template, newItemTemplate, templateDictionary, destinationAuthentication);
1152
- }
1153
- else if (template.type === "Workforce Project") {
1154
- customProcDef = fineTuneCreatedItem$1(newItemTemplate, destinationAuthentication, templateDictionary);
1155
- }
1156
- else if (template.type === "Notebook") {
1157
- customProcDef = fineTuneCreatedItem(template, newItemTemplate, templateDictionary, destinationAuthentication);
1158
- }
1159
- else if (originalURL !== newItemTemplate.item.url) {
1160
- // For web mapping applications that are not Web AppBuilder apps
1161
- customProcDef = new Promise((resolve2, reject2) => {
1162
- common__namespace
1163
- .updateItemURL(createResponse.id, newItemTemplate.item.url, destinationAuthentication)
1164
- .then(() => resolve2(), reject2);
1165
- });
1166
- }
1167
- else {
1168
- customProcDef = Promise.resolve(null);
1169
- }
1170
- Promise.all([relationshipsDef, customProcDef]).then(() => {
1171
- // Interrupt process if progress callback returns `false`
1172
- if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
1173
- itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
1174
- common__namespace
1175
- .removeItem(createResponse.id, destinationAuthentication)
1176
- .then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
1177
- }
1178
- else {
1179
- resolve({
1180
- item: newItemTemplate,
1181
- id: createResponse.id,
1182
- type: newItemTemplate.type,
1183
- postProcess: postProcess
1184
- });
1185
- }
1186
- }, () => {
1187
- itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
1188
- resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to deploy all resources to the item
1189
- });
1190
- }
1191
- }, () => {
1192
- itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
1193
- resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
1194
- });
1195
- }
1196
- });
1197
- }
1198
-
1199
- /** @license
1200
- * Copyright 2020 Esri
1201
- *
1202
- * Licensed under the Apache License, Version 2.0 (the "License");
1203
- * you may not use this file except in compliance with the License.
1204
- * You may obtain a copy of the License at
1205
- *
1206
- * http://www.apache.org/licenses/LICENSE-2.0
1207
- *
1208
- * Unless required by applicable law or agreed to in writing, software
1209
- * distributed under the License is distributed on an "AS IS" BASIS,
1210
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1211
- * See the License for the specific language governing permissions and
1212
- * limitations under the License.
1213
- */
1214
- function updateNotebookData(itemId, data, authentication) {
1215
- const updateOptions = {
1216
- id: itemId,
1217
- data: common.jsonToBlob(data)
1218
- };
1219
- return common.updateItem(updateOptions, authentication);
1220
- }
1221
-
1222
- /** @license
1223
- * Copyright 2020 Esri
1224
- *
1225
- * Licensed under the Apache License, Version 2.0 (the "License");
1226
- * you may not use this file except in compliance with the License.
1227
- * You may obtain a copy of the License at
1228
- *
1229
- * http://www.apache.org/licenses/LICENSE-2.0
1230
- *
1231
- * Unless required by applicable law or agreed to in writing, software
1232
- * distributed under the License is distributed on an "AS IS" BASIS,
1233
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1234
- * See the License for the specific language governing permissions and
1235
- * limitations under the License.
1236
- */
1237
-
1238
- var notebookHelpers = /*#__PURE__*/Object.freeze({
1239
- __proto__: null,
1240
- createItemFromTemplate: createItemFromTemplate$3,
1241
- convertItemToTemplate: convertItemToTemplate$1,
1242
- updateNotebookData: updateNotebookData
1243
- });
1244
-
1245
- /** @license
1246
- * Copyright 2020 Esri
1247
- *
1248
- * Licensed under the Apache License, Version 2.0 (the "License");
1249
- * you may not use this file except in compliance with the License.
1250
- * You may obtain a copy of the License at
1251
- *
1252
- * http://www.apache.org/licenses/LICENSE-2.0
1253
- *
1254
- * Unless required by applicable law or agreed to in writing, software
1255
- * distributed under the License is distributed on an "AS IS" BASIS,
1256
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1257
- * See the License for the specific language governing permissions and
1258
- * limitations under the License.
1259
- */
1260
- /**
1261
- * Converts a notebook item into a template.
1262
- *
1263
- * @param solutionItemId The solution to contain the template
1264
- * @param itemInfo Info about the item
1265
- * @param destAuthentication Credentials for requests to the destination organization
1266
- * @param srcAuthentication Credentials for requests to source items
1267
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
1268
- * @returns A promise that will resolve when the template has been created
1269
- */
1270
- function convertItemToTemplate$5(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
1271
- // Delegate back to simple-types, which will in-turn delegate
1272
- // to convertNotebookToTemplate at the correct point in the process
1273
- // This is a temporary refactor step
1274
- return convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
1275
- }
1276
- // Delegate back to simple-types
1277
- // This is a temporary refactor step
1278
- function createItemFromTemplate$2(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
1279
- return createItemFromTemplate$3(template, templateDictionary, destinationAuthentication, itemProgressCallback);
1280
- }
1281
- /**
1282
- * Converts a Python Notebook item to a template.
1283
- *
1284
- * @param itemTemplate template for the Python Notebook
1285
- * @returns templatized itemTemplate
1286
- */
1287
- function convertNotebookToTemplate(itemTemplate) {
1288
- // The templates data to process
1289
- const data = itemTemplate.data;
1290
- deleteProps(data);
1291
- let dataString = JSON.stringify(data);
1292
- const idTest = /[0-9A-F]{32}/gim;
1293
- if (data && idTest.test(dataString)) {
1294
- const ids = dataString.match(idTest);
1295
- const verifiedIds = [];
1296
- ids.forEach(id => {
1297
- if (verifiedIds.indexOf(id) === -1) {
1298
- verifiedIds.push(id);
1299
- // templatize the itemId--but only once per unique id
1300
- const regEx = new RegExp(id, "gm");
1301
- dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");
1302
- // update the dependencies
1303
- if (itemTemplate.dependencies.indexOf(id) === -1) {
1304
- itemTemplate.dependencies.push(id);
1305
- }
1306
- }
1307
- });
1308
- itemTemplate.data = JSON.parse(dataString);
1309
- }
1310
- return itemTemplate;
1311
- }
1312
- /**
1313
- * Remove interpreter and papermill props
1314
- *
1315
- * This function will update the data passed in by removing key props
1316
- *
1317
- * @param data The notebooks data object
1318
- *
1319
- */
1320
- function deleteProps(data) {
1321
- /* istanbul ignore else */
1322
- if (data) {
1323
- const props = ["metadata.interpreter", "metadata.papermill"];
1324
- common__namespace.deleteProps(data, props);
1325
- (data.cells || []).forEach((cell) => {
1326
- common__namespace.deleteProps(cell, props);
1327
- });
1328
- }
1329
- }
1330
- /**
1331
- * Update the notebooks data
1332
- *
1333
- * @param originalTemplate The original template item
1334
- * @param newlyCreatedItem The current item that may have unswapped variables
1335
- * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
1336
- * @param authentication Credentials for the requests to the destination
1337
- *
1338
- * @returns A promise that will resolve once any updates have been made
1339
- */
1340
- function fineTuneCreatedItem(originalTemplate, newlyCreatedItem, templateDictionary, authentication) {
1341
- return new Promise((resolve, reject) => {
1342
- const updateOptions = {
1343
- id: newlyCreatedItem.itemId,
1344
- url: newlyCreatedItem.item.url,
1345
- data: common__namespace.jsonToFile(newlyCreatedItem.data, newlyCreatedItem.itemId + ".ipynb")
1346
- };
1347
- common__namespace
1348
- .updateItem(updateOptions, authentication)
1349
- .then(() => resolve(null), reject);
1350
- });
1351
- }
1352
- /**
1353
- * Notebook specific post-processing actions
1354
- *
1355
- * @param {string} itemId The item ID
1356
- * @param {string} type The template type
1357
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
1358
- * @param {any} templateDictionary The template dictionary
1359
- * @param {UserSession} authentication The destination session info
1360
- * @returns {Promise<any>}
1361
- */
1362
- function postProcess$2(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
1363
- return common__namespace.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
1364
- }
1365
-
1366
- var notebook = /*#__PURE__*/Object.freeze({
1367
- __proto__: null,
1368
- convertItemToTemplate: convertItemToTemplate$5,
1369
- createItemFromTemplate: createItemFromTemplate$2,
1370
- convertNotebookToTemplate: convertNotebookToTemplate,
1371
- deleteProps: deleteProps,
1372
- fineTuneCreatedItem: fineTuneCreatedItem,
1373
- postProcess: postProcess$2
1374
- });
1375
-
1376
- /** @license
1377
- * Copyright 2018 Esri
1378
- *
1379
- * Licensed under the Apache License, Version 2.0 (the "License");
1380
- * you may not use this file except in compliance with the License.
1381
- * You may obtain a copy of the License at
1382
- *
1383
- * http://www.apache.org/licenses/LICENSE-2.0
1384
- *
1385
- * Unless required by applicable law or agreed to in writing, software
1386
- * distributed under the License is distributed on an "AS IS" BASIS,
1387
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1388
- * See the License for the specific language governing permissions and
1389
- * limitations under the License.
1390
- */
1391
- // ------------------------------------------------------------------------------------------------------------------ //
1392
- /**
1393
- * Converts an AGOL OIC (Oriented Imagery Catalog) item to a template.
1394
- *
1395
- * @param itemTemplate Template for the OIC (Oriented Imagery Catalog) item
1396
- * @param destAuthentication Credentials for requests to the destination organization
1397
- * @param srcAuthentication Credentials for requests to source items
1398
- * @returns Template for the solution item that contains key details for item reconstruction
1399
- */
1400
- function convertItemToTemplate$4(itemTemplate, destAuthentication, srcAuthentication) {
1401
- return new Promise((resolve, reject) => {
1402
- // Extract dependencies
1403
- _extractDependencies$1(itemTemplate, srcAuthentication).then((results) => {
1404
- itemTemplate.dependencies = results.dependencies;
1405
- // Templatize the map layer ids after we've extracted them as dependencies
1406
- /* istanbul ignore else */
1407
- if (itemTemplate.data?.properties) {
1408
- itemTemplate.data.properties.ServiceURL = _templatizeOicLayerUrl(itemTemplate.data.properties.ServiceURL, results.urlHash);
1409
- itemTemplate.data.properties.OverviewURL = _templatizeOicLayerUrl(itemTemplate.data.properties.OverviewURL, results.urlHash);
1410
- }
1411
- resolve(itemTemplate);
1412
- }, e => reject(common__namespace.fail(e)));
1413
- });
1414
- }
1415
- /**
1416
- * Gets the ids of the dependencies of an AGOL OIC (Oriented Imagery Catalog) item.
1417
- *
1418
- * @param itemTemplate A OIC (Oriented Imagery Catalog) item whose dependencies are sought
1419
- * @param authentication Credentials for any requests
1420
- * @returns List of dependencies ids and url/itemId hash
1421
- * @private
1422
- */
1423
- function _extractDependencies$1(itemTemplate, authentication) {
1424
- return new Promise((resolve, reject) => {
1425
- const dependencies = [];
1426
- if (itemTemplate.data?.properties) {
1427
- const layerURLs = [];
1428
- /* istanbul ignore else */
1429
- if (itemTemplate.data.properties.ServiceURL) {
1430
- layerURLs.push(itemTemplate.data.properties.ServiceURL);
1431
- }
1432
- /* istanbul ignore else */
1433
- if (itemTemplate.data.properties.OverviewURL &&
1434
- itemTemplate.data.properties.OverviewURL !==
1435
- itemTemplate.data.properties.ServiceURL) {
1436
- layerURLs.push(itemTemplate.data.properties.OverviewURL);
1437
- }
1438
- _getLayerIds$1(layerURLs, dependencies, authentication).then(results => {
1439
- resolve(results);
1440
- }, e => reject(common__namespace.fail(e)));
1441
- }
1442
- else {
1443
- resolve({
1444
- dependencies: dependencies,
1445
- urlHash: {}
1446
- });
1447
- }
1448
- });
1449
- }
1450
- /**
1451
- * Extracts the AGOL itemId for each layer in a list using the url.
1452
- *
1453
- * @param layerURLs List of OIC layer URLs
1454
- * @param dependencies Current list of dependencies
1455
- * @param authentication Credentials for any requests
1456
- * @returns List of dependencies ids and url/itemId hash
1457
- * @private
1458
- */
1459
- function _getLayerIds$1(layerURLs, dependencies, authentication) {
1460
- return new Promise((resolve, reject) => {
1461
- const urlHash = {};
1462
- const options = {
1463
- f: "json",
1464
- authentication: authentication
1465
- };
1466
- const layerPromises = [];
1467
- const layerChecks = {};
1468
- const filteredLayerURLs = layerURLs.filter(layerURL => {
1469
- if (layerURL) {
1470
- const results = /.+FeatureServer/g.exec(layerURL);
1471
- const baseUrl = Array.isArray(results) && results.length > 0 ? results[0] : undefined;
1472
- if (baseUrl) {
1473
- // avoid redundant checks when we have a layer with subLayers
1474
- /* istanbul ignore else */
1475
- if (Object.keys(layerChecks).indexOf(baseUrl) < 0) {
1476
- layerChecks[baseUrl] = common__namespace.rest_request(layerURL, options);
1477
- }
1478
- layerPromises.push(layerChecks[baseUrl]);
1479
- return true;
1480
- }
1481
- else {
1482
- return false;
1483
- }
1484
- }
1485
- else {
1486
- return false;
1487
- }
1488
- });
1489
- if (layerPromises.length > 0) {
1490
- Promise.all(layerPromises).then(serviceResponses => {
1491
- serviceResponses.forEach((serviceResponse, i) => {
1492
- /* istanbul ignore else */
1493
- if (common__namespace.getProp(serviceResponse, "serviceItemId")) {
1494
- const id = serviceResponse.serviceItemId;
1495
- /* istanbul ignore else */
1496
- if (dependencies.indexOf(id) < 0) {
1497
- dependencies.push(id);
1498
- }
1499
- urlHash[filteredLayerURLs[i]] = id;
1500
- }
1501
- });
1502
- resolve({
1503
- dependencies: dependencies,
1504
- urlHash: urlHash
1505
- });
1506
- }, e => reject(common__namespace.fail(e)));
1507
- }
1508
- else {
1509
- resolve({
1510
- dependencies: dependencies,
1511
- urlHash: urlHash
1512
- });
1513
- }
1514
- });
1515
- }
1516
- /**
1517
- * Templatizes the url and item id for a layer.
1518
- *
1519
- * @param layerURL OIC layer URL
1520
- * @param urlHash Lookup object for analysis layers
1521
- * @returns Templatized URL if layerURL is in the urlHash
1522
- * @private
1523
- */
1524
- function _templatizeOicLayerUrl(layerURL, urlHash) {
1525
- let templatizedURL = layerURL;
1526
- if (layerURL) {
1527
- const id = urlHash[layerURL];
1528
- if (id) {
1529
- const layerId = layerURL.substr(layerURL.lastIndexOf("/") + 1);
1530
- templatizedURL = common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".url");
1531
- }
1532
- // replace everything up until /home with portalBaseUrl var and templatize the itemId
1533
- templatizedURL = common__namespace.templatizeIds(templatizedURL.replace(/.+?(?=\/home)/, "{{portalBaseUrl}}"));
1534
- }
1535
- return templatizedURL;
1536
- }
1537
-
1538
- /** @license
1539
- * Copyright 2020 Esri
1540
- *
1541
- * Licensed under the Apache License, Version 2.0 (the "License");
1542
- * you may not use this file except in compliance with the License.
1543
- * You may obtain a copy of the License at
1544
- *
1545
- * http://www.apache.org/licenses/LICENSE-2.0
1546
- *
1547
- * Unless required by applicable law or agreed to in writing, software
1548
- * distributed under the License is distributed on an "AS IS" BASIS,
1549
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1550
- * See the License for the specific language governing permissions and
1551
- * limitations under the License.
1552
- */
1553
-
1554
- var quickcaptureHelpers = /*#__PURE__*/Object.freeze({
1555
- __proto__: null,
1556
- createItemFromTemplate: createItemFromTemplate$3,
1557
- convertItemToTemplate: convertItemToTemplate$1
1558
- });
1559
-
1560
- /** @license
1561
- * Copyright 2018 Esri
1562
- *
1563
- * Licensed under the Apache License, Version 2.0 (the "License");
1564
- * you may not use this file except in compliance with the License.
1565
- * You may obtain a copy of the License at
1566
- *
1567
- * http://www.apache.org/licenses/LICENSE-2.0
1568
- *
1569
- * Unless required by applicable law or agreed to in writing, software
1570
- * distributed under the License is distributed on an "AS IS" BASIS,
1571
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1572
- * See the License for the specific language governing permissions and
1573
- * limitations under the License.
1574
- */
1575
- //#region Publish Process ---------------------------------------------------------------------------------------//
1576
- /**
1577
- * Converts a Quick Capture item into a template.
1578
- *
1579
- * @param solutionItemId The solution to contain the template
1580
- * @param itemInfo Info about the item
1581
- * @param destAuthentication Credentials for requests to the destination organization
1582
- * @param srcAuthentication Credentials for requests to source items
1583
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
1584
- * @returns A promise that will resolve when the template has been created
1585
- */
1586
- function convertItemToTemplate$3(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
1587
- // Delegate back to simple-types, which will in-turn delegate
1588
- // to convertNotebookToTemplate at the correct point in the process
1589
- // This is a temporary refactor step
1590
- return convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
1591
- }
1592
- /**
1593
- * Converts an quick capture item to a template.
1594
- *
1595
- * @param itemTemplate template for the quick capture project item
1596
- * @returns templatized itemTemplate
1597
- */
1598
- function convertQuickCaptureToTemplate(itemTemplate) {
1599
- return new Promise((resolve, reject) => {
1600
- // The templates data to process
1601
- const data = itemTemplate.data;
1602
- if (data && Array.isArray(data)) {
1603
- let applicationRequest = Promise.resolve(null);
1604
- let applicationName = "";
1605
- data.some((item) => {
1606
- if (item.type === "application/json") {
1607
- applicationName = item.name;
1608
- applicationRequest = common__namespace.getBlobText(item);
1609
- return true;
1610
- }
1611
- });
1612
- applicationRequest.then(result => {
1613
- // replace the template data array with the templatized application JSON
1614
- itemTemplate.data = result
1615
- ? {
1616
- application: _templatizeApplication(JSON.parse(result), itemTemplate),
1617
- name: applicationName
1618
- }
1619
- : {};
1620
- resolve(itemTemplate);
1621
- }, reject);
1622
- }
1623
- else {
1624
- resolve(itemTemplate);
1625
- }
1626
- });
1627
- }
1628
- /**
1629
- * Templatizes key properties for a quick capture project and gathers item dependencies
1630
- *
1631
- * @param data the projects json
1632
- * @param itemTemplate template for the quick capture project item
1633
- * @returns templatized itemTemplate
1634
- * @private
1635
- */
1636
- function _templatizeApplication(data, itemTemplate) {
1637
- // Quick Project item id
1638
- _templatizeId(data, "itemId");
1639
- // Set the admin email
1640
- _templatizeAdminEmail(data);
1641
- // datasource item id and url
1642
- const dataSources = data.dataSources;
1643
- if (dataSources && Array.isArray(dataSources)) {
1644
- dataSources.forEach(ds => {
1645
- const id = ds.featureServiceItemId;
1646
- if (id) {
1647
- _updateDependencies(id, itemTemplate);
1648
- _templatizeUrl(ds, "featureServiceItemId", "url");
1649
- _templatizeId(ds, "featureServiceItemId");
1650
- }
1651
- });
1652
- }
1653
- return data;
1654
- }
1655
- /**
1656
- * Templatize the email property
1657
- *
1658
- * @param data the quick capture application
1659
- * @private
1660
- */
1661
- function _templatizeAdminEmail(data) {
1662
- if (common__namespace.getProp(data, "preferences.adminEmail")) {
1663
- common__namespace.setProp(data, "preferences.adminEmail", "{{user.email}}");
1664
- }
1665
- }
1666
- /**
1667
- * Updates the templates dependencies list with unique item ids
1668
- *
1669
- * @param id the item id of the dependency
1670
- * @param itemTemplate template for the quick capture project item
1671
- * @returns templatized itemTemplate
1672
- */
1673
- function _updateDependencies(id, itemTemplate) {
1674
- if (itemTemplate.dependencies.indexOf(id) === -1) {
1675
- itemTemplate.dependencies.push(id);
1676
- }
1677
- }
1678
- /**
1679
- * Templatize a url property
1680
- *
1681
- * @param obj the datasource object
1682
- * @param idPath the path to the id property
1683
- * @param urlPath the path to the url property
1684
- * @private
1685
- */
1686
- function _templatizeUrl(obj, idPath, urlPath) {
1687
- const id = common__namespace.getProp(obj, idPath);
1688
- const url = common__namespace.getProp(obj, urlPath);
1689
- if (url) {
1690
- const layerId = url.substr(url.lastIndexOf("/") + 1);
1691
- common__namespace.setProp(obj, urlPath, common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".url"));
1692
- }
1693
- }
1694
- /**
1695
- * Templatize the item id property
1696
- *
1697
- * @param obj the datasource or object that contains the item id property
1698
- * @param path the path to the id property
1699
- * @private
1700
- */
1701
- function _templatizeId(obj, path) {
1702
- const id = common__namespace.getProp(obj, path);
1703
- if (id) {
1704
- common__namespace.setProp(obj, path, common__namespace.templatizeTerm(id, id, ".itemId"));
1705
- }
1706
- }
1707
- //#endregion
1708
- //#region Deploy Process ---------------------------------------------------------------------------------------//
1709
- // Delegate back to simple-types
1710
- // This is a temporary refactor step
1711
- function createItemFromTemplate$1(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
1712
- return createItemFromTemplate$3(template, templateDictionary, destinationAuthentication, itemProgressCallback);
1713
- }
1714
- /**
1715
- * QuickCapture post-processing actions
1716
- *
1717
- * @param {string} itemId The item ID
1718
- * @param {string} type The template type
1719
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
1720
- * @param {any} templateDictionary The template dictionary
1721
- * @param {UserSession} authentication The destination session info
1722
- * @returns Promise resolving to successfulness of update
1723
- */
1724
- function postProcess$1(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
1725
- return new Promise((resolve, reject) => {
1726
- template.data = common__namespace.replaceInTemplate(template.data, templateDictionary);
1727
- common__namespace
1728
- .updateItemTemplateFromDictionary(itemId, templateDictionary, authentication)
1729
- .then(() => {
1730
- common__namespace
1731
- .updateItemResourceText(itemId, template.data.name, JSON.stringify(template.data.application), authentication)
1732
- .then(resolve, reject);
1733
- }, reject);
1734
- });
1735
- }
1736
- //#endregion
1737
-
1738
- var quickcapture = /*#__PURE__*/Object.freeze({
1739
- __proto__: null,
1740
- convertItemToTemplate: convertItemToTemplate$3,
1741
- convertQuickCaptureToTemplate: convertQuickCaptureToTemplate,
1742
- _templatizeApplication: _templatizeApplication,
1743
- _templatizeAdminEmail: _templatizeAdminEmail,
1744
- _updateDependencies: _updateDependencies,
1745
- _templatizeUrl: _templatizeUrl,
1746
- _templatizeId: _templatizeId,
1747
- createItemFromTemplate: createItemFromTemplate$1,
1748
- postProcess: postProcess$1
1749
- });
1750
-
1751
- /** @license
1752
- * Copyright 2018 Esri
1753
- *
1754
- * Licensed under the Apache License, Version 2.0 (the "License");
1755
- * you may not use this file except in compliance with the License.
1756
- * You may obtain a copy of the License at
1757
- *
1758
- * http://www.apache.org/licenses/LICENSE-2.0
1759
- *
1760
- * Unless required by applicable law or agreed to in writing, software
1761
- * distributed under the License is distributed on an "AS IS" BASIS,
1762
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1763
- * See the License for the specific language governing permissions and
1764
- * limitations under the License.
1765
- */
1766
- /**
1767
- * The portion of a Webmap URL between the server and the map id.
1768
- *
1769
- * @private
1770
- */
1771
- const WEBMAP_APP_URL_PART = "home/webmap/viewer.html?webmap=";
1772
- // ------------------------------------------------------------------------------------------------------------------ //
1773
- /**
1774
- * Converts an AGOL webmap item to a template.
1775
- *
1776
- * @param itemTemplate Template for the webmap item
1777
- * @param destAuthentication Credentials for requests to the destination organization
1778
- * @param srcAuthentication Credentials for requests to source items
1779
- * @param templateDictionary Hash of key details used for variable replacement
1780
- * @returns Template for the solution item that contains key details for item reconstruction
1781
- */
1782
- function convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
1783
- return new Promise((resolve, reject) => {
1784
- // Templatize the app URL
1785
- itemTemplate.item.url = itemTemplate.item.url ?
1786
- common__namespace.checkUrlPathTermination(common__namespace.placeholder(common__namespace.SERVER_NAME)) +
1787
- WEBMAP_APP_URL_PART +
1788
- itemTemplate.item.id : itemTemplate.item.url; // templatized id
1789
- // Extract dependencies
1790
- _extractDependencies(itemTemplate, srcAuthentication).then((results) => {
1791
- itemTemplate.dependencies = results.dependencies;
1792
- // Templatize the map layer ids after we've extracted them as dependencies
1793
- if (itemTemplate.data) {
1794
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.operationalLayers, results.urlHash, templateDictionary);
1795
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.tables, results.urlHash, templateDictionary);
1796
- // Exclude intialState
1797
- _excludeInitialState(itemTemplate.data);
1798
- }
1799
- resolve(itemTemplate);
1800
- }, e => reject(common__namespace.fail(e)));
1801
- });
1802
- }
1803
- /**
1804
- * Gets the ids of the dependencies of an AGOL webmap item.
1805
- *
1806
- * @param itemTemplate A webmap item whose dependencies are sought
1807
- * @param authentication Credentials for any requests
1808
- * @returns List of dependencies ids and url/itemId hash
1809
- * @private
1810
- */
1811
- function _extractDependencies(itemTemplate, authentication) {
1812
- return new Promise((resolve, reject) => {
1813
- const dependencies = [];
1814
- if (itemTemplate.data) {
1815
- const layers = itemTemplate.data.operationalLayers || [];
1816
- const tables = itemTemplate.data.tables || [];
1817
- const layersAndTables = layers.concat(tables);
1818
- _getLayerIds(layersAndTables, dependencies, authentication).then(results => {
1819
- resolve(results);
1820
- }, e => reject(common__namespace.fail(e)));
1821
- }
1822
- else {
1823
- resolve({
1824
- dependencies: dependencies,
1825
- urlHash: {}
1826
- });
1827
- }
1828
- });
1829
- }
1830
- /**
1831
- * Remove the initialState prop from webmaps saved from the new map viewer.
1832
- * This allows the map to use the item extent property that we templatize.
1833
- *
1834
- * Added for issue #662
1835
- *
1836
- * @param data the data for the web maps item template
1837
- * @returns void
1838
- * @private
1839
- */
1840
- function _excludeInitialState(data) {
1841
- common__namespace.deleteProp(data, "initialState");
1842
- }
1843
- /**
1844
- * Extracts the AGOL itemId for each layer or table object in a list using the url.
1845
- *
1846
- * @param layerList List of map layers or tables
1847
- * @param dependencies Current list of dependencies
1848
- * @param authentication Credentials for any requests
1849
- * @returns List of dependencies ids and url/itemId hash
1850
- * @private
1851
- */
1852
- function _getLayerIds(layerList, dependencies, authentication) {
1853
- return new Promise((resolve, reject) => {
1854
- const urlHash = {};
1855
- const options = {
1856
- f: "json",
1857
- authentication: authentication
1858
- };
1859
- const layerPromises = [];
1860
- const layerChecks = {};
1861
- const layers = layerList.filter(layer => {
1862
- if (layer.url && layer.url.indexOf("{{velocityUrl}}") < 0) {
1863
- const results = /.+FeatureServer/g.exec(layer.url);
1864
- const baseUrl = Array.isArray(results) && results.length > 0 ? results[0] : undefined;
1865
- if (baseUrl) {
1866
- // avoid redundant checks when we have a layer with subLayers
1867
- if (Object.keys(layerChecks).indexOf(baseUrl) < 0) {
1868
- layerChecks[baseUrl] = common__namespace.rest_request(layer.url, options);
1869
- }
1870
- layerPromises.push(layerChecks[baseUrl]);
1871
- return true;
1872
- }
1873
- else {
1874
- return false;
1875
- }
1876
- }
1877
- else {
1878
- return false;
1879
- }
1880
- });
1881
- if (layerPromises.length > 0) {
1882
- Promise.all(layerPromises).then(serviceResponses => {
1883
- serviceResponses.forEach((serviceResponse, i) => {
1884
- if (common__namespace.getProp(serviceResponse, "serviceItemId")) {
1885
- const id = serviceResponse.serviceItemId;
1886
- if (dependencies.indexOf(id) < 0) {
1887
- dependencies.push(id);
1888
- }
1889
- urlHash[layers[i].url] = id;
1890
- }
1891
- });
1892
- resolve({
1893
- dependencies: dependencies,
1894
- urlHash: urlHash
1895
- });
1896
- }, e => reject(common__namespace.fail(e)));
1897
- }
1898
- else {
1899
- resolve({
1900
- dependencies: dependencies,
1901
- urlHash: urlHash
1902
- });
1903
- }
1904
- });
1905
- }
1906
- /**
1907
- * Templatizes the url and item id for layers or tables within the webmap.
1908
- *
1909
- * @param layerList List of map layers or tables
1910
- * @param urlHash Lookup object for analysis layers
1911
- * @param templateDictionary Hash of key details used for variable replacement
1912
- * @returns void
1913
- * @private
1914
- */
1915
- function _templatizeWebmapLayerIdsAndUrls(layerList = [], urlHash, templateDictionary) {
1916
- layerList.forEach((layer) => {
1917
- if (layer.url) {
1918
- const layerId = layer.url.substr(layer.url.lastIndexOf("/") + 1);
1919
- const id = Object.keys(urlHash).indexOf(layer.url) > -1
1920
- ? urlHash[layer.url]
1921
- : undefined;
1922
- if (id) {
1923
- common__namespace.cacheLayerInfo(layerId, id, layer.url, templateDictionary);
1924
- layer.url = common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".url");
1925
- layer.itemId = common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".itemId");
1926
- }
1927
- }
1928
- });
1929
- }
1930
- /**
1931
- * Templatize field references.
1932
- *
1933
- * @param solutionTemplate The solution item template
1934
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
1935
- * @returns The solutionTemplate with templatized field references
1936
- */
1937
- function postProcessFieldReferences$1(solutionTemplate, datasourceInfos) {
1938
- const paths = [
1939
- "data.operationalLayers",
1940
- "data.tables",
1941
- "data.applicationProperties.viewing.search.layers"
1942
- ];
1943
- paths.forEach(p => _templatizeProperty(solutionTemplate, datasourceInfos, p));
1944
- return solutionTemplate;
1945
- }
1946
- /**
1947
- * Templatize field references.
1948
- *
1949
- * @param solutionTemplate The solution item template
1950
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
1951
- * @param path A string path to the object property to templatize
1952
- * @private
1953
- */
1954
- function _templatizeProperty(solutionTemplate, datasourceInfos, path) {
1955
- const objs = common__namespace.getProp(solutionTemplate, path);
1956
- if (objs) {
1957
- common__namespace.setProp(solutionTemplate, path, _templatize(objs, datasourceInfos));
1958
- }
1959
- }
1960
- /**
1961
- * Templatize field references.
1962
- *
1963
- * @param objs Can be operationalLayers or tables or appProperties search layers
1964
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
1965
- * @returns updated instances of the objects
1966
- * @private
1967
- */
1968
- function _templatize(objs, datasourceInfos) {
1969
- objs.forEach(obj => {
1970
- const ds = _getDatasourceInfo(obj, datasourceInfos);
1971
- if (ds) {
1972
- const fieldNames = ds.fields.map(f => f.name);
1973
- common__namespace._templatizePopupInfo(obj, ds, ds.basePath, ds.itemId, fieldNames);
1974
- common__namespace._templatizeDefinitionEditor(obj, ds.basePath, fieldNames);
1975
- if (obj.layerDefinition) {
1976
- common__namespace._templatizeDrawingInfo(obj.layerDefinition, ds.basePath, fieldNames);
1977
- common__namespace._templatizeDefinitionExpression(obj.layerDefinition, ds.basePath, fieldNames);
1978
- }
1979
- // used for applicationProperties search layers
1980
- const fieldName = common__namespace.getProp(obj, "field.name");
1981
- if (fieldName) {
1982
- common__namespace.setProp(obj, "field.name", common__namespace._templatizeFieldName(fieldName, obj, ds.itemId, ds.basePath));
1983
- }
1984
- }
1985
- });
1986
- return objs;
1987
- }
1988
- /**
1989
- * Get datasourceInfo by map layer id
1990
- *
1991
- * @param obj Can be operationalLayer or table or appProperties search layer
1992
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
1993
- * @returns datasourceInfo for the given object id
1994
- * @private
1995
- */
1996
- function _getDatasourceInfo(obj, datasourceInfos) {
1997
- let datasourceInfo;
1998
- datasourceInfos.some(ds => {
1999
- if (ds.ids.indexOf(obj.id) > -1) {
2000
- datasourceInfo = ds;
2001
- return true;
2002
- }
2003
- else {
2004
- return false;
2005
- }
2006
- });
2007
- return datasourceInfo;
2008
- }
2009
-
2010
- /** @license
2011
- * Copyright 2020 Esri
2012
- *
2013
- * Licensed under the Apache License, Version 2.0 (the "License");
2014
- * you may not use this file except in compliance with the License.
2015
- * You may obtain a copy of the License at
2016
- *
2017
- * http://www.apache.org/licenses/LICENSE-2.0
2018
- *
2019
- * Unless required by applicable law or agreed to in writing, software
2020
- * distributed under the License is distributed on an "AS IS" BASIS,
2021
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2022
- * See the License for the specific language governing permissions and
2023
- * limitations under the License.
2024
- */
2025
- /**
2026
- * Converts an item into a template.
2027
- *
2028
- * @param solutionItemId The solution to contain the template
2029
- * @param itemInfo Info about the item
2030
- * @param destAuthentication Credentials for requests to the destination organization
2031
- * @param srcAuthentication Credentials for requests to source items
2032
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
2033
- *
2034
- * @returns A promise that will resolve when the template has been created
2035
- */
2036
- function convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
2037
- return new Promise((resolve, reject) => {
2038
- // Init template
2039
- const itemTemplate = common__namespace.createInitializedItemTemplate(itemInfo);
2040
- // Templatize item info property values
2041
- itemTemplate.item.id = common__namespace.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
2042
- // Request related items
2043
- const relatedPromise = common__namespace.getItemRelatedItemsInSameDirection(itemTemplate.itemId, "forward", srcAuthentication);
2044
- // Perform type-specific handling
2045
- let dataPromise = Promise.resolve({});
2046
- let resourcesPromise = Promise.resolve([]);
2047
- switch (itemInfo.type) {
2048
- case "Dashboard":
2049
- case "Feature Collection":
2050
- case "Feature Service":
2051
- case "Hub Initiative":
2052
- case "Hub Page":
2053
- case "Hub Site Application":
2054
- case "Insights Model":
2055
- case "Oriented Imagery Catalog":
2056
- case "Project Package":
2057
- case "Workforce Project":
2058
- case "Web Map":
2059
- case "Web Mapping Application":
2060
- case "Web Scene":
2061
- case "Notebook":
2062
- dataPromise = new Promise(resolveJSON => {
2063
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
2064
- common__namespace
2065
- .getItemDataAsJson(itemTemplate.itemId, srcAuthentication)
2066
- .then(json => resolveJSON(json));
2067
- });
2068
- break;
2069
- case "Form":
2070
- dataPromise = common__namespace.getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, srcAuthentication);
2071
- break;
2072
- case "QuickCapture Project":
2073
- dataPromise = new Promise(resolveJSON => {
2074
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
2075
- common__namespace
2076
- .getItemDataAsJson(itemTemplate.itemId, srcAuthentication)
2077
- .then(json => resolveJSON(json));
2078
- });
2079
- resourcesPromise = common__namespace.getItemResourcesFiles(itemTemplate.itemId, srcAuthentication);
2080
- break;
2081
- }
2082
- // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:
2083
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
2084
- Promise.all([dataPromise, relatedPromise, resourcesPromise]).then(responses => {
2085
- const [itemDataResponse, relatedItemsResponse, resourcesResponse] = responses;
2086
- // need to pre-process for velocity urls before they could be templatized by other processors
2087
- itemTemplate.data = common__namespace.updateVelocityReferences(itemDataResponse, itemInfo.type, templateDictionary);
2088
- const relationships = relatedItemsResponse;
2089
- // Save the mappings to related items & add those items to the dependencies, but not WMA Code Attachments
2090
- itemTemplate.dependencies = [];
2091
- itemTemplate.relatedItems = [];
2092
- relationships.forEach(relationship => {
2093
- /* istanbul ignore else */
2094
- if (relationship.relationshipType !== "WMA2Code") {
2095
- itemTemplate.relatedItems.push(relationship);
2096
- relationship.relatedItemIds.forEach(relatedItemId => {
2097
- if (itemTemplate.dependencies.indexOf(relatedItemId) < 0) {
2098
- itemTemplate.dependencies.push(relatedItemId);
2099
- }
2100
- });
2101
- }
2102
- });
2103
- // Add QuickCapture basemap webmap references
2104
- if (itemInfo.type === "QuickCapture Project") {
2105
- const basemap = itemDataResponse?.application?.basemap;
2106
- if (basemap?.type === "WebMap") {
2107
- itemTemplate.dependencies.push(basemap.itemId);
2108
- }
2109
- itemTemplate.resources = resourcesResponse;
2110
- }
2111
- // Create the template
2112
- let templateModifyingPromise = Promise.resolve(itemTemplate);
2113
- switch (itemInfo.type) {
2114
- case "Dashboard":
2115
- convertItemToTemplate$8(itemTemplate, templateDictionary);
2116
- break;
2117
- case "Form":
2118
- // Store the form's data in the solution resources, not in template
2119
- itemTemplate.data = null;
2120
- // Add the form data to the template for a post-process resource upload
2121
- if (itemDataResponse) {
2122
- itemTemplate.item.name = _getFormDataFilename(itemTemplate.item.name, itemDataResponse.name, `${itemTemplate.itemId}.zip`);
2123
- const storageName = common__namespace.convertItemResourceToStorageResource(itemTemplate.itemId, itemTemplate.item.name, common__namespace.SolutionTemplateFormatVersion, common__namespace.SolutionResourceType.data);
2124
- // Add the data file to the template so that it can be uploaded with the other resources in the solution
2125
- const dataFile = {
2126
- itemId: itemTemplate.itemId,
2127
- file: itemDataResponse,
2128
- folder: storageName.folder,
2129
- filename: itemTemplate.item.name
2130
- };
2131
- itemTemplate.dataFile = dataFile;
2132
- // Update the template's resources
2133
- itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
2134
- }
2135
- break;
2136
- case "Notebook":
2137
- convertNotebookToTemplate(itemTemplate);
2138
- break;
2139
- case "Oriented Imagery Catalog":
2140
- templateModifyingPromise = convertItemToTemplate$4(itemTemplate, destAuthentication, srcAuthentication);
2141
- break;
2142
- case "Web Map":
2143
- case "Web Scene":
2144
- templateModifyingPromise = convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2145
- break;
2146
- case "Web Mapping Application":
2147
- if (itemDataResponse) {
2148
- templateModifyingPromise = convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2149
- }
2150
- break;
2151
- case "Workforce Project":
2152
- templateModifyingPromise = convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2153
- break;
2154
- case "QuickCapture Project":
2155
- templateModifyingPromise = convertQuickCaptureToTemplate(itemTemplate);
2156
- break;
2157
- }
2158
- templateModifyingPromise.then(resolve, err => reject(common__namespace.fail(err)));
2159
- });
2160
- });
2161
- }
2162
- /**
2163
- * Encapsulates the rules for naming a form's data file.
2164
- * Chooses the first parameter that's defined and is not the string "undefined".
2165
- *
2166
- * @param itemName Template's item name
2167
- * @param dataFilename The data file name
2168
- * @param itemIdAsName A name constructed from the template's id suffixed with ".zip"
2169
- *
2170
- * @return A name for the data file
2171
- */
2172
- function _getFormDataFilename(itemName, dataFilename, itemIdAsName) {
2173
- const originalFilename = itemName || dataFilename;
2174
- const filename = originalFilename && originalFilename !== "undefined"
2175
- ? originalFilename
2176
- : itemIdAsName;
2177
- return filename;
2178
- }
2179
-
2180
- /** @license
2181
- * Copyright 2020 Esri
2182
- *
2183
- * Licensed under the Apache License, Version 2.0 (the "License");
2184
- * you may not use this file except in compliance with the License.
2185
- * You may obtain a copy of the License at
2186
- *
2187
- * http://www.apache.org/licenses/LICENSE-2.0
2188
- *
2189
- * Unless required by applicable law or agreed to in writing, software
2190
- * distributed under the License is distributed on an "AS IS" BASIS,
2191
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2192
- * See the License for the specific language governing permissions and
2193
- * limitations under the License.
2194
- */
2195
-
2196
- var simpleTypeHelpers = /*#__PURE__*/Object.freeze({
2197
- __proto__: null,
2198
- createItemFromTemplate: createItemFromTemplate$3,
2199
- convertItemToTemplate: convertItemToTemplate$1
2200
- });
2201
-
2202
- /** @license
2203
- * Copyright 2018 Esri
2204
- *
2205
- * Licensed under the Apache License, Version 2.0 (the "License");
2206
- * you may not use this file except in compliance with the License.
2207
- * You may obtain a copy of the License at
2208
- *
2209
- * http://www.apache.org/licenses/LICENSE-2.0
2210
- *
2211
- * Unless required by applicable law or agreed to in writing, software
2212
- * distributed under the License is distributed on an "AS IS" BASIS,
2213
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2214
- * See the License for the specific language governing permissions and
2215
- * limitations under the License.
2216
- */
2217
- /**
2218
- * Converts an item into a template.
2219
- *
2220
- * @param solutionItemId The solution to contain the template
2221
- * @param itemInfo Info about the item
2222
- * @param destAuthentication Credentials for requests to the destination organization
2223
- * @param srcAuthentication Credentials for requests to source items
2224
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
2225
- * @returns A promise that will resolve when the template has been created
2226
- */
2227
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
2228
- return convertItemToTemplate$1(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
2229
- }
2230
- /**
2231
- * Delegate to simpleType creator
2232
- *
2233
- * @param template
2234
- * @param templateDictionary
2235
- * @param destinationAuthentication
2236
- * @param itemProgressCallback
2237
- */
2238
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
2239
- return createItemFromTemplate$3(template, templateDictionary, destinationAuthentication, itemProgressCallback);
2240
- }
2241
- /**
2242
- * Templatizes field references within specific template types.
2243
- * Currently only handles web mapping applications
2244
- *
2245
- * @param template A solution template
2246
- * @param datasourceInfos A list of objects that store key datasource info used to templatizing field references
2247
- * @param type The item type
2248
- * @returns The updated solution template
2249
- */
2250
- function postProcessFieldReferences(solutionTemplate, datasourceInfos, type) {
2251
- switch (type) {
2252
- case "Web Mapping Application":
2253
- postProcessFieldReferences$2(solutionTemplate, datasourceInfos);
2254
- break;
2255
- case "Dashboard":
2256
- postProcessFieldReferences$3(solutionTemplate, datasourceInfos);
2257
- break;
2258
- case "Web Map":
2259
- postProcessFieldReferences$1(solutionTemplate, datasourceInfos);
2260
- break;
2261
- }
2262
- return solutionTemplate;
2263
- }
2264
- /**
2265
- * Simple Type post-processing actions
2266
- *
2267
- * @param {string} itemId The item ID
2268
- * @param {string} type The template type
2269
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
2270
- * @param {any} templateDictionary The template dictionary
2271
- * @param {UserSession} authentication The destination session info
2272
- * @returns Promise resolving to successfulness of update
2273
- */
2274
- function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
2275
- return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
2276
- }
2277
-
2278
- var simpleTypes = /*#__PURE__*/Object.freeze({
2279
- __proto__: null,
2280
- convertItemToTemplate: convertItemToTemplate,
2281
- createItemFromTemplate: createItemFromTemplate,
2282
- postProcessFieldReferences: postProcessFieldReferences,
2283
- postProcess: postProcess
2284
- });
2285
-
2286
- exports.notebookHelpers = notebookHelpers;
2287
- exports.notebookProcessor = notebook;
2288
- exports.quickcaptureHelpers = quickcaptureHelpers;
2289
- exports.quickcaptureProcessor = quickcapture;
2290
- exports.simpleTypeHelpers = simpleTypeHelpers;
2291
- exports.simpleTypes = simpleTypes;
2292
-
2293
- Object.defineProperty(exports, '__esModule', { value: true });
2294
-
2295
- }));
2296
- //# sourceMappingURL=simple-types.umd.js.map