@esri/solution-simple-types 4.1.2 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/cjs/dashboard.d.ts +93 -93
  2. package/dist/cjs/dashboard.js +352 -352
  3. package/dist/cjs/helpers/convert-item-to-template.d.ts +46 -46
  4. package/dist/cjs/helpers/convert-item-to-template.js +235 -209
  5. package/dist/cjs/helpers/convert-item-to-template.js.map +1 -1
  6. package/dist/cjs/helpers/create-item-from-template.d.ts +17 -17
  7. package/dist/cjs/helpers/create-item-from-template.js +153 -138
  8. package/dist/cjs/helpers/create-item-from-template.js.map +1 -1
  9. package/dist/cjs/helpers/notebook-helpers.d.ts +19 -19
  10. package/dist/cjs/helpers/notebook-helpers.js +24 -24
  11. package/dist/cjs/helpers/quickcapture-helpers.d.ts +18 -18
  12. package/dist/cjs/helpers/quickcapture-helpers.js +22 -22
  13. package/dist/cjs/helpers/simple-type-helpers.d.ts +18 -18
  14. package/dist/cjs/helpers/simple-type-helpers.js +22 -22
  15. package/dist/cjs/helpers/update-notebook-data.d.ts +17 -17
  16. package/dist/cjs/helpers/update-notebook-data.js +27 -27
  17. package/dist/cjs/index.d.ts +27 -27
  18. package/dist/cjs/index.js +36 -36
  19. package/dist/cjs/notebook.d.ts +66 -66
  20. package/dist/cjs/notebook.js +133 -133
  21. package/dist/cjs/oic.d.ts +53 -53
  22. package/dist/cjs/oic.js +170 -170
  23. package/dist/cjs/quickcapture.d.ts +76 -87
  24. package/dist/cjs/quickcapture.js +143 -192
  25. package/dist/cjs/quickcapture.js.map +1 -1
  26. package/dist/cjs/simple-types.d.ts +57 -57
  27. package/dist/cjs/simple-types.js +94 -94
  28. package/dist/cjs/webmap.d.ts +102 -102
  29. package/dist/cjs/webmap.js +325 -325
  30. package/dist/cjs/webmappingapplication.d.ts +176 -176
  31. package/dist/cjs/webmappingapplication.js +674 -674
  32. package/dist/cjs/webmappingapplication.js.map +1 -1
  33. package/dist/cjs/workforce.d.ts +34 -34
  34. package/dist/cjs/workforce.js +44 -44
  35. package/dist/esm/dashboard.d.ts +93 -93
  36. package/dist/esm/dashboard.js +339 -339
  37. package/dist/esm/helpers/convert-item-to-template.d.ts +46 -46
  38. package/dist/esm/helpers/convert-item-to-template.js +228 -202
  39. package/dist/esm/helpers/convert-item-to-template.js.map +1 -1
  40. package/dist/esm/helpers/create-item-from-template.d.ts +17 -17
  41. package/dist/esm/helpers/create-item-from-template.js +148 -133
  42. package/dist/esm/helpers/create-item-from-template.js.map +1 -1
  43. package/dist/esm/helpers/notebook-helpers.d.ts +19 -19
  44. package/dist/esm/helpers/notebook-helpers.js +20 -20
  45. package/dist/esm/helpers/quickcapture-helpers.d.ts +18 -18
  46. package/dist/esm/helpers/quickcapture-helpers.js +19 -19
  47. package/dist/esm/helpers/simple-type-helpers.d.ts +18 -18
  48. package/dist/esm/helpers/simple-type-helpers.js +19 -19
  49. package/dist/esm/helpers/update-notebook-data.d.ts +17 -17
  50. package/dist/esm/helpers/update-notebook-data.js +23 -23
  51. package/dist/esm/index.d.ts +27 -27
  52. package/dist/esm/index.js +27 -27
  53. package/dist/esm/notebook.d.ts +66 -66
  54. package/dist/esm/notebook.js +123 -123
  55. package/dist/esm/oic.d.ts +53 -53
  56. package/dist/esm/oic.js +162 -162
  57. package/dist/esm/quickcapture.d.ts +76 -87
  58. package/dist/esm/quickcapture.js +131 -179
  59. package/dist/esm/quickcapture.js.map +1 -1
  60. package/dist/esm/simple-types.d.ts +57 -57
  61. package/dist/esm/simple-types.js +86 -86
  62. package/dist/esm/webmap.d.ts +102 -102
  63. package/dist/esm/webmap.js +312 -312
  64. package/dist/esm/webmappingapplication.d.ts +176 -176
  65. package/dist/esm/webmappingapplication.js +648 -648
  66. package/dist/esm/webmappingapplication.js.map +1 -1
  67. package/dist/esm/workforce.d.ts +34 -34
  68. package/dist/esm/workforce.js +38 -38
  69. package/package.json +7 -7
@@ -1,326 +1,326 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports._getDatasourceInfo = exports._templatize = exports._templatizeProperty = exports.postProcessFieldReferences = exports._templatizeWebmapLayerIdsAndUrls = exports._getLayerIds = exports._excludeInitialState = exports._extractDependencies = exports.convertItemToTemplate = void 0;
19
- const tslib_1 = require("tslib");
20
- const common = tslib_1.__importStar(require("@esri/solution-common"));
21
- /**
22
- * The portion of a Webmap URL between the server and the map id.
23
- *
24
- * @private
25
- */
26
- const WEBMAP_APP_URL_PART = "home/webmap/viewer.html?webmap=";
27
- /**
28
- * A flag inserted used as a vector tile layer's styleUrl to indicate that the layer is unsupported and should
29
- * be removed.
30
- */
31
- const unsupportedTileLayerUrl = "unsupported";
32
- // ------------------------------------------------------------------------------------------------------------------ //
33
- /**
34
- * Converts an AGOL webmap item to a template.
35
- *
36
- * @param itemTemplate Template for the webmap item
37
- * @param destAuthentication Credentials for requests to the destination organization
38
- * @param srcAuthentication Credentials for requests to source items
39
- * @param templateDictionary Hash of key details used for variable replacement
40
- * @returns Template for the solution item that contains key details for item reconstruction
41
- */
42
- function convertItemToTemplate(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
43
- return new Promise((resolve, reject) => {
44
- // Templatize the app URL if it's not a vector tile service
45
- if (itemTemplate.type !== "Vector Tile Service") {
46
- itemTemplate.item.url = itemTemplate.item.url
47
- ? common.checkUrlPathTermination(common.placeholder(common.SERVER_NAME)) + WEBMAP_APP_URL_PART + itemTemplate.item.id
48
- : itemTemplate.item.url; // templatized id
49
- }
50
- // Extract dependencies
51
- _extractDependencies(itemTemplate, srcAuthentication).then((results) => {
52
- itemTemplate.dependencies = results.dependencies;
53
- // Templatize the map layer ids after we've extracted them as dependencies
54
- if (itemTemplate.data) {
55
- const baseMapLayers = itemTemplate.data.baseMap?.baseMapLayers;
56
- if (baseMapLayers) {
57
- itemTemplate.data.baseMap.baseMapLayers =
58
- baseMapLayers.filter(layer => layer.styleUrl !== unsupportedTileLayerUrl);
59
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.baseMap.baseMapLayers, results.urlHash, templateDictionary);
60
- }
61
- const operationalLayers = itemTemplate.data.operationalLayers;
62
- if (operationalLayers) {
63
- itemTemplate.data.operationalLayers =
64
- operationalLayers.filter(layer => layer.styleUrl !== unsupportedTileLayerUrl);
65
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.operationalLayers, results.urlHash, templateDictionary);
66
- }
67
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.tables, results.urlHash, templateDictionary);
68
- // Exclude intialState
69
- _excludeInitialState(itemTemplate.data);
70
- }
71
- resolve(itemTemplate);
72
- }, e => reject(common.fail(e)));
73
- });
74
- }
75
- exports.convertItemToTemplate = convertItemToTemplate;
76
- /**
77
- * Gets the ids of the dependencies of an AGOL webmap item.
78
- *
79
- * @param itemTemplate A webmap item whose dependencies are sought
80
- * @param authentication Credentials for any requests
81
- * @returns List of dependencies ids and url/itemId hash
82
- * @private
83
- */
84
- function _extractDependencies(itemTemplate, authentication) {
85
- return new Promise((resolve, reject) => {
86
- const dependencies = [];
87
- if (itemTemplate.data) {
88
- const basemapLayers = itemTemplate.data.baseMap?.baseMapLayers || [];
89
- const opLayers = itemTemplate.data.operationalLayers || [];
90
- const tables = itemTemplate.data.tables || [];
91
- const layersAndTables = basemapLayers.concat(opLayers).concat(tables);
92
- _getLayerIds(layersAndTables, dependencies, authentication).then(results => {
93
- resolve(results);
94
- }, e => reject(common.fail(e)));
95
- }
96
- else {
97
- resolve({
98
- dependencies: dependencies,
99
- urlHash: {}
100
- });
101
- }
102
- });
103
- }
104
- exports._extractDependencies = _extractDependencies;
105
- /**
106
- * Remove the initialState prop from webmaps saved from the new map viewer.
107
- * This allows the map to use the item extent property that we templatize.
108
- *
109
- * Added for issue #662
110
- *
111
- * @param data the data for the web maps item template
112
- * @returns void
113
- * @private
114
- */
115
- function _excludeInitialState(data) {
116
- common.deleteProp(data, "initialState");
117
- }
118
- exports._excludeInitialState = _excludeInitialState;
119
- /**
120
- * Extracts the AGOL itemId for each layer or table object in a list using the url.
121
- *
122
- * @param layerList List of map layers or tables; supported vector tile layers have their styleUrls templatized
123
- * @param dependencies Current list of dependencies
124
- * @param authentication Credentials for any requests
125
- * @returns Updated list of dependencies ids, url/itemId hash (for feature layers),
126
- * and id/styleUrl hash (for vector tile layers)
127
- * @private
128
- */
129
- function _getLayerIds(layerList, dependencies, authentication) {
130
- return new Promise((resolve, reject) => {
131
- const urlHash = {};
132
- const options = {
133
- f: "json",
134
- authentication: authentication
135
- };
136
- const layerPromises = [];
137
- const layerChecks = {};
138
- const layers = layerList.filter(layer => {
139
- // Test for Vector Tile Layers
140
- if (layer.itemId && layer.layerType === "VectorTileLayer") {
141
- // Fetch the item so that we can check if it has the typeKeyword "Vector Tile Style Editor", which ensures
142
- // that the user has edited the style and it is something that could be reasonably be packaged with the
143
- // solution
144
- layerPromises.push(common.getItemBase(layer.itemId, authentication));
145
- return true;
146
- // Handle a feature server layer
147
- }
148
- else if (layer.url && layer.url.indexOf("{{velocityUrl}}") < 0) {
149
- const results = /.+FeatureServer/g.exec(layer.url);
150
- const baseUrl = Array.isArray(results) && results.length > 0 ? results[0] : undefined;
151
- if (baseUrl) {
152
- // avoid redundant checks when we have a layer with subLayers
153
- if (Object.keys(layerChecks).indexOf(baseUrl) < 0) {
154
- layerChecks[baseUrl] = common.rest_request(layer.url, options);
155
- }
156
- layerPromises.push(layerChecks[baseUrl]);
157
- return true;
158
- }
159
- else {
160
- return false;
161
- }
162
- // This layer is not a dependency
163
- }
164
- else {
165
- return false;
166
- }
167
- });
168
- // We have a mix of Vector Tile Layer item base requests and Feature Server info requests
169
- if (layerPromises.length > 0) {
170
- Promise.all(layerPromises).then((responses) => {
171
- responses.forEach((response, i) => {
172
- if (layers[i].layerType === "VectorTileLayer") {
173
- const typeKeywords = common.getProp(response, "typeKeywords");
174
- if (typeKeywords && typeKeywords.includes("Vector Tile Style Editor")) {
175
- // Vector tiles edited by the style editor
176
- if (dependencies.indexOf(response.id) < 0) {
177
- dependencies.push(response.id);
178
- }
179
- // Templatize the URL to the style resource
180
- const iSuffix = layers[i].styleUrl.indexOf(response.id) + response.id.length;
181
- layers[i].styleUrl = common.templatizeTerm(layers[i].styleUrl.replace(layers[i].styleUrl.substring(0, iSuffix), response.id), response.id, ".itemUrl");
182
- }
183
- else {
184
- // Unsupported vector tiles
185
- layers[i].styleUrl = unsupportedTileLayerUrl;
186
- }
187
- }
188
- else if (common.getProp(response, "serviceItemId")) {
189
- // Feature Service
190
- const id = response.serviceItemId;
191
- if (dependencies.indexOf(id) < 0) {
192
- dependencies.push(id);
193
- }
194
- urlHash[layers[i].url] = id;
195
- }
196
- });
197
- resolve({
198
- dependencies,
199
- urlHash
200
- });
201
- }, e => reject(common.fail(e)));
202
- }
203
- else {
204
- resolve({
205
- dependencies,
206
- urlHash
207
- });
208
- }
209
- });
210
- }
211
- exports._getLayerIds = _getLayerIds;
212
- /**
213
- * Templatizes the url and item id for layers or tables within the webmap.
214
- *
215
- * @param layerList List of map layers or tables
216
- * @param urlHash Lookup object for analysis layers; hash from URL to AGO item id
217
- * @param templateDictionary Hash of key details used for variable replacement
218
- * @returns void
219
- * @private
220
- */
221
- function _templatizeWebmapLayerIdsAndUrls(layerList = [], urlHash, templateDictionary) {
222
- layerList.forEach((layer) => {
223
- // Test for Vector Tile Layers
224
- if (layer.itemId && layer.layerType === "VectorTileLayer") {
225
- // No further test needed: we've already pruned out unsupported vector tile layers
226
- layer.itemId = common.templatizeTerm(layer.itemId, layer.itemId, ".itemId");
227
- // Handle a feature server layer
228
- }
229
- else if (layer.url) {
230
- const layerId = layer.url.substr(layer.url.lastIndexOf("/") + 1);
231
- const id = Object.keys(urlHash).indexOf(layer.url) > -1
232
- ? urlHash[layer.url]
233
- : undefined;
234
- if (id) {
235
- common.cacheLayerInfo(layerId, id, layer.url, templateDictionary);
236
- layer.url = common.templatizeTerm(id, id, ".layer" + layerId + ".url");
237
- layer.itemId = common.templatizeTerm(id, id, ".layer" + layerId + ".itemId");
238
- }
239
- }
240
- });
241
- }
242
- exports._templatizeWebmapLayerIdsAndUrls = _templatizeWebmapLayerIdsAndUrls;
243
- /**
244
- * Templatize field references.
245
- *
246
- * @param solutionTemplate The solution item template
247
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
248
- * @returns The solutionTemplate with templatized field references
249
- */
250
- function postProcessFieldReferences(solutionTemplate, datasourceInfos) {
251
- const paths = [
252
- "data.operationalLayers",
253
- "data.tables",
254
- "data.applicationProperties.viewing.search.layers"
255
- ];
256
- paths.forEach(p => _templatizeProperty(solutionTemplate, datasourceInfos, p));
257
- return solutionTemplate;
258
- }
259
- exports.postProcessFieldReferences = postProcessFieldReferences;
260
- /**
261
- * Templatize field references.
262
- *
263
- * @param solutionTemplate The solution item template
264
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
265
- * @param path A string path to the object property to templatize
266
- * @private
267
- */
268
- function _templatizeProperty(solutionTemplate, datasourceInfos, path) {
269
- const objs = common.getProp(solutionTemplate, path);
270
- if (objs) {
271
- common.setProp(solutionTemplate, path, _templatize(objs, datasourceInfos));
272
- }
273
- }
274
- exports._templatizeProperty = _templatizeProperty;
275
- /**
276
- * Templatize field references.
277
- *
278
- * @param objs Can be operationalLayers or tables or appProperties search layers
279
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
280
- * @returns updated instances of the objects
281
- * @private
282
- */
283
- function _templatize(objs, datasourceInfos) {
284
- objs.forEach(obj => {
285
- const ds = _getDatasourceInfo(obj, datasourceInfos);
286
- if (ds) {
287
- const fieldNames = ds.fields.map(f => f.name);
288
- common._templatizePopupInfo(obj, ds, ds.basePath, ds.itemId, fieldNames);
289
- common._templatizeDefinitionEditor(obj, ds.basePath, fieldNames);
290
- if (obj.layerDefinition) {
291
- common._templatizeDrawingInfo(obj.layerDefinition, ds.basePath, fieldNames);
292
- common._templatizeDefinitionExpression(obj.layerDefinition, ds.basePath, fieldNames);
293
- }
294
- // used for applicationProperties search layers
295
- const fieldName = common.getProp(obj, "field.name");
296
- if (fieldName) {
297
- common.setProp(obj, "field.name", common._templatizeFieldName(fieldName, obj, ds.itemId, ds.basePath));
298
- }
299
- }
300
- });
301
- return objs;
302
- }
303
- exports._templatize = _templatize;
304
- /**
305
- * Get datasourceInfo by map layer id
306
- *
307
- * @param obj Can be operationalLayer or table or appProperties search layer
308
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
309
- * @returns datasourceInfo for the given object id
310
- * @private
311
- */
312
- function _getDatasourceInfo(obj, datasourceInfos) {
313
- let datasourceInfo;
314
- datasourceInfos.some(ds => {
315
- if (ds.ids.indexOf(obj.id) > -1) {
316
- datasourceInfo = ds;
317
- return true;
318
- }
319
- else {
320
- return false;
321
- }
322
- });
323
- return datasourceInfo;
324
- }
325
- exports._getDatasourceInfo = _getDatasourceInfo;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports._getDatasourceInfo = exports._templatize = exports._templatizeProperty = exports.postProcessFieldReferences = exports._templatizeWebmapLayerIdsAndUrls = exports._getLayerIds = exports._excludeInitialState = exports._extractDependencies = exports.convertItemToTemplate = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
+ /**
22
+ * The portion of a Webmap URL between the server and the map id.
23
+ *
24
+ * @private
25
+ */
26
+ const WEBMAP_APP_URL_PART = "home/webmap/viewer.html?webmap=";
27
+ /**
28
+ * A flag inserted used as a vector tile layer's styleUrl to indicate that the layer is unsupported and should
29
+ * be removed.
30
+ */
31
+ const unsupportedTileLayerUrl = "unsupported";
32
+ // ------------------------------------------------------------------------------------------------------------------ //
33
+ /**
34
+ * Converts an AGOL webmap item to a template.
35
+ *
36
+ * @param itemTemplate Template for the webmap item
37
+ * @param destAuthentication Credentials for requests to the destination organization
38
+ * @param srcAuthentication Credentials for requests to source items
39
+ * @param templateDictionary Hash of key details used for variable replacement
40
+ * @returns Template for the solution item that contains key details for item reconstruction
41
+ */
42
+ function convertItemToTemplate(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
43
+ return new Promise((resolve, reject) => {
44
+ // Templatize the app URL if it's not a vector tile service
45
+ if (itemTemplate.type !== "Vector Tile Service") {
46
+ itemTemplate.item.url = itemTemplate.item.url
47
+ ? common.checkUrlPathTermination(common.placeholder(common.SERVER_NAME)) + WEBMAP_APP_URL_PART + itemTemplate.item.id
48
+ : itemTemplate.item.url; // templatized id
49
+ }
50
+ // Extract dependencies
51
+ _extractDependencies(itemTemplate, srcAuthentication).then((results) => {
52
+ itemTemplate.dependencies = results.dependencies;
53
+ // Templatize the map layer ids after we've extracted them as dependencies
54
+ if (itemTemplate.data) {
55
+ const baseMapLayers = itemTemplate.data.baseMap?.baseMapLayers;
56
+ if (baseMapLayers) {
57
+ itemTemplate.data.baseMap.baseMapLayers =
58
+ baseMapLayers.filter(layer => layer.styleUrl !== unsupportedTileLayerUrl);
59
+ _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.baseMap.baseMapLayers, results.urlHash, templateDictionary);
60
+ }
61
+ const operationalLayers = itemTemplate.data.operationalLayers;
62
+ if (operationalLayers) {
63
+ itemTemplate.data.operationalLayers =
64
+ operationalLayers.filter(layer => layer.styleUrl !== unsupportedTileLayerUrl);
65
+ _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.operationalLayers, results.urlHash, templateDictionary);
66
+ }
67
+ _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.tables, results.urlHash, templateDictionary);
68
+ // Exclude intialState
69
+ _excludeInitialState(itemTemplate.data);
70
+ }
71
+ resolve(itemTemplate);
72
+ }, e => reject(common.fail(e)));
73
+ });
74
+ }
75
+ exports.convertItemToTemplate = convertItemToTemplate;
76
+ /**
77
+ * Gets the ids of the dependencies of an AGOL webmap item.
78
+ *
79
+ * @param itemTemplate A webmap item whose dependencies are sought
80
+ * @param authentication Credentials for any requests
81
+ * @returns List of dependencies ids and url/itemId hash
82
+ * @private
83
+ */
84
+ function _extractDependencies(itemTemplate, authentication) {
85
+ return new Promise((resolve, reject) => {
86
+ const dependencies = [];
87
+ if (itemTemplate.data) {
88
+ const basemapLayers = itemTemplate.data.baseMap?.baseMapLayers || [];
89
+ const opLayers = itemTemplate.data.operationalLayers || [];
90
+ const tables = itemTemplate.data.tables || [];
91
+ const layersAndTables = basemapLayers.concat(opLayers).concat(tables);
92
+ _getLayerIds(layersAndTables, dependencies, authentication).then(results => {
93
+ resolve(results);
94
+ }, e => reject(common.fail(e)));
95
+ }
96
+ else {
97
+ resolve({
98
+ dependencies: dependencies,
99
+ urlHash: {}
100
+ });
101
+ }
102
+ });
103
+ }
104
+ exports._extractDependencies = _extractDependencies;
105
+ /**
106
+ * Remove the initialState prop from webmaps saved from the new map viewer.
107
+ * This allows the map to use the item extent property that we templatize.
108
+ *
109
+ * Added for issue #662
110
+ *
111
+ * @param data the data for the web maps item template
112
+ * @returns void
113
+ * @private
114
+ */
115
+ function _excludeInitialState(data) {
116
+ common.deleteProp(data, "initialState");
117
+ }
118
+ exports._excludeInitialState = _excludeInitialState;
119
+ /**
120
+ * Extracts the AGOL itemId for each layer or table object in a list using the url.
121
+ *
122
+ * @param layerList List of map layers or tables; supported vector tile layers have their styleUrls templatized
123
+ * @param dependencies Current list of dependencies
124
+ * @param authentication Credentials for any requests
125
+ * @returns Updated list of dependencies ids, url/itemId hash (for feature layers),
126
+ * and id/styleUrl hash (for vector tile layers)
127
+ * @private
128
+ */
129
+ function _getLayerIds(layerList, dependencies, authentication) {
130
+ return new Promise((resolve, reject) => {
131
+ const urlHash = {};
132
+ const options = {
133
+ f: "json",
134
+ authentication: authentication
135
+ };
136
+ const layerPromises = [];
137
+ const layerChecks = {};
138
+ const layers = layerList.filter(layer => {
139
+ // Test for Vector Tile Layers
140
+ if (layer.itemId && layer.layerType === "VectorTileLayer") {
141
+ // Fetch the item so that we can check if it has the typeKeyword "Vector Tile Style Editor", which ensures
142
+ // that the user has edited the style and it is something that could be reasonably be packaged with the
143
+ // solution
144
+ layerPromises.push(common.getItemBase(layer.itemId, authentication));
145
+ return true;
146
+ // Handle a feature server layer
147
+ }
148
+ else if (layer.url && layer.url.indexOf("{{velocityUrl}}") < 0) {
149
+ const results = /.+FeatureServer/g.exec(layer.url);
150
+ const baseUrl = Array.isArray(results) && results.length > 0 ? results[0] : undefined;
151
+ if (baseUrl) {
152
+ // avoid redundant checks when we have a layer with subLayers
153
+ if (Object.keys(layerChecks).indexOf(baseUrl) < 0) {
154
+ layerChecks[baseUrl] = common.rest_request(layer.url, options);
155
+ }
156
+ layerPromises.push(layerChecks[baseUrl]);
157
+ return true;
158
+ }
159
+ else {
160
+ return false;
161
+ }
162
+ // This layer is not a dependency
163
+ }
164
+ else {
165
+ return false;
166
+ }
167
+ });
168
+ // We have a mix of Vector Tile Layer item base requests and Feature Server info requests
169
+ if (layerPromises.length > 0) {
170
+ Promise.all(layerPromises).then((responses) => {
171
+ responses.forEach((response, i) => {
172
+ if (layers[i].layerType === "VectorTileLayer") {
173
+ const typeKeywords = common.getProp(response, "typeKeywords");
174
+ if (typeKeywords && typeKeywords.includes("Vector Tile Style Editor")) {
175
+ // Vector tiles edited by the style editor
176
+ if (dependencies.indexOf(response.id) < 0) {
177
+ dependencies.push(response.id);
178
+ }
179
+ // Templatize the URL to the style resource
180
+ const iSuffix = layers[i].styleUrl.indexOf(response.id) + response.id.length;
181
+ layers[i].styleUrl = common.templatizeTerm(layers[i].styleUrl.replace(layers[i].styleUrl.substring(0, iSuffix), response.id), response.id, ".itemUrl");
182
+ }
183
+ else {
184
+ // Unsupported vector tiles
185
+ layers[i].styleUrl = unsupportedTileLayerUrl;
186
+ }
187
+ }
188
+ else if (common.getProp(response, "serviceItemId")) {
189
+ // Feature Service
190
+ const id = response.serviceItemId;
191
+ if (dependencies.indexOf(id) < 0) {
192
+ dependencies.push(id);
193
+ }
194
+ urlHash[layers[i].url] = id;
195
+ }
196
+ });
197
+ resolve({
198
+ dependencies,
199
+ urlHash
200
+ });
201
+ }, e => reject(common.fail(e)));
202
+ }
203
+ else {
204
+ resolve({
205
+ dependencies,
206
+ urlHash
207
+ });
208
+ }
209
+ });
210
+ }
211
+ exports._getLayerIds = _getLayerIds;
212
+ /**
213
+ * Templatizes the url and item id for layers or tables within the webmap.
214
+ *
215
+ * @param layerList List of map layers or tables
216
+ * @param urlHash Lookup object for analysis layers; hash from URL to AGO item id
217
+ * @param templateDictionary Hash of key details used for variable replacement
218
+ * @returns void
219
+ * @private
220
+ */
221
+ function _templatizeWebmapLayerIdsAndUrls(layerList = [], urlHash, templateDictionary) {
222
+ layerList.forEach((layer) => {
223
+ // Test for Vector Tile Layers
224
+ if (layer.itemId && layer.layerType === "VectorTileLayer") {
225
+ // No further test needed: we've already pruned out unsupported vector tile layers
226
+ layer.itemId = common.templatizeTerm(layer.itemId, layer.itemId, ".itemId");
227
+ // Handle a feature server layer
228
+ }
229
+ else if (layer.url) {
230
+ const layerId = layer.url.substr(layer.url.lastIndexOf("/") + 1);
231
+ const id = Object.keys(urlHash).indexOf(layer.url) > -1
232
+ ? urlHash[layer.url]
233
+ : undefined;
234
+ if (id) {
235
+ common.cacheLayerInfo(layerId, id, layer.url, templateDictionary);
236
+ layer.url = common.templatizeTerm(id, id, ".layer" + layerId + ".url");
237
+ layer.itemId = common.templatizeTerm(id, id, ".layer" + layerId + ".itemId");
238
+ }
239
+ }
240
+ });
241
+ }
242
+ exports._templatizeWebmapLayerIdsAndUrls = _templatizeWebmapLayerIdsAndUrls;
243
+ /**
244
+ * Templatize field references.
245
+ *
246
+ * @param solutionTemplate The solution item template
247
+ * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
248
+ * @returns The solutionTemplate with templatized field references
249
+ */
250
+ function postProcessFieldReferences(solutionTemplate, datasourceInfos) {
251
+ const paths = [
252
+ "data.operationalLayers",
253
+ "data.tables",
254
+ "data.applicationProperties.viewing.search.layers"
255
+ ];
256
+ paths.forEach(p => _templatizeProperty(solutionTemplate, datasourceInfos, p));
257
+ return solutionTemplate;
258
+ }
259
+ exports.postProcessFieldReferences = postProcessFieldReferences;
260
+ /**
261
+ * Templatize field references.
262
+ *
263
+ * @param solutionTemplate The solution item template
264
+ * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
265
+ * @param path A string path to the object property to templatize
266
+ * @private
267
+ */
268
+ function _templatizeProperty(solutionTemplate, datasourceInfos, path) {
269
+ const objs = common.getProp(solutionTemplate, path);
270
+ if (objs) {
271
+ common.setProp(solutionTemplate, path, _templatize(objs, datasourceInfos));
272
+ }
273
+ }
274
+ exports._templatizeProperty = _templatizeProperty;
275
+ /**
276
+ * Templatize field references.
277
+ *
278
+ * @param objs Can be operationalLayers or tables or appProperties search layers
279
+ * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
280
+ * @returns updated instances of the objects
281
+ * @private
282
+ */
283
+ function _templatize(objs, datasourceInfos) {
284
+ objs.forEach(obj => {
285
+ const ds = _getDatasourceInfo(obj, datasourceInfos);
286
+ if (ds) {
287
+ const fieldNames = ds.fields.map(f => f.name);
288
+ common._templatizePopupInfo(obj, ds, ds.basePath, ds.itemId, fieldNames);
289
+ common._templatizeDefinitionEditor(obj, ds.basePath, fieldNames);
290
+ if (obj.layerDefinition) {
291
+ common._templatizeDrawingInfo(obj.layerDefinition, ds.basePath, fieldNames);
292
+ common._templatizeDefinitionExpression(obj.layerDefinition, ds.basePath, fieldNames);
293
+ }
294
+ // used for applicationProperties search layers
295
+ const fieldName = common.getProp(obj, "field.name");
296
+ if (fieldName) {
297
+ common.setProp(obj, "field.name", common._templatizeFieldName(fieldName, obj, ds.itemId, ds.basePath));
298
+ }
299
+ }
300
+ });
301
+ return objs;
302
+ }
303
+ exports._templatize = _templatize;
304
+ /**
305
+ * Get datasourceInfo by map layer id
306
+ *
307
+ * @param obj Can be operationalLayer or table or appProperties search layer
308
+ * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
309
+ * @returns datasourceInfo for the given object id
310
+ * @private
311
+ */
312
+ function _getDatasourceInfo(obj, datasourceInfos) {
313
+ let datasourceInfo;
314
+ datasourceInfos.some(ds => {
315
+ if (ds.ids.indexOf(obj.id) > -1) {
316
+ datasourceInfo = ds;
317
+ return true;
318
+ }
319
+ else {
320
+ return false;
321
+ }
322
+ });
323
+ return datasourceInfo;
324
+ }
325
+ exports._getDatasourceInfo = _getDatasourceInfo;
326
326
  //# sourceMappingURL=webmap.js.map