@esri/solution-simple-types 1.5.1 → 1.5.2

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 (40) hide show
  1. package/dist/esm/dashboard.d.ts +6 -4
  2. package/dist/esm/dashboard.js +9 -6
  3. package/dist/esm/dashboard.js.map +1 -1
  4. package/dist/esm/helpers/convert-item-to-template.d.ts +11 -0
  5. package/dist/esm/helpers/convert-item-to-template.js +35 -24
  6. package/dist/esm/helpers/convert-item-to-template.js.map +1 -1
  7. package/dist/esm/webmap.d.ts +4 -2
  8. package/dist/esm/webmap.js +7 -4
  9. package/dist/esm/webmap.js.map +1 -1
  10. package/dist/esm/webmappingapplication.d.ts +12 -2
  11. package/dist/esm/webmappingapplication.js +14 -3
  12. package/dist/esm/webmappingapplication.js.map +1 -1
  13. package/dist/esm/workforce.d.ts +2 -1
  14. package/dist/esm/workforce.js +3 -2
  15. package/dist/esm/workforce.js.map +1 -1
  16. package/dist/node/dashboard.d.ts +6 -4
  17. package/dist/node/dashboard.js +9 -6
  18. package/dist/node/dashboard.js.map +1 -1
  19. package/dist/node/helpers/convert-item-to-template.d.ts +11 -0
  20. package/dist/node/helpers/convert-item-to-template.js +37 -25
  21. package/dist/node/helpers/convert-item-to-template.js.map +1 -1
  22. package/dist/node/webmap.d.ts +4 -2
  23. package/dist/node/webmap.js +7 -4
  24. package/dist/node/webmap.js.map +1 -1
  25. package/dist/node/webmappingapplication.d.ts +12 -2
  26. package/dist/node/webmappingapplication.js +14 -3
  27. package/dist/node/webmappingapplication.js.map +1 -1
  28. package/dist/node/workforce.d.ts +2 -1
  29. package/dist/node/workforce.js +3 -2
  30. package/dist/node/workforce.js.map +1 -1
  31. package/dist/umd/simple-types/src/dashboard.d.ts +6 -4
  32. package/dist/umd/simple-types/src/helpers/convert-item-to-template.d.ts +11 -0
  33. package/dist/umd/simple-types/src/webmap.d.ts +4 -2
  34. package/dist/umd/simple-types/src/webmappingapplication.d.ts +12 -2
  35. package/dist/umd/simple-types/src/workforce.d.ts +2 -1
  36. package/dist/umd/simple-types.umd.js +70 -41
  37. package/dist/umd/simple-types.umd.js.map +1 -1
  38. package/dist/umd/simple-types.umd.min.js +3 -3
  39. package/dist/umd/simple-types.umd.min.js.map +1 -1
  40. package/package.json +6 -6
@@ -20,9 +20,10 @@ import * as common from "@esri/solution-common";
20
20
  * @param itemTemplate Template for the webmap item
21
21
  * @param destAuthentication Credentials for requests to the destination organization
22
22
  * @param srcAuthentication Credentials for requests to source items
23
+ * @param templateDictionary Hash of key details used for variable replacement
23
24
  * @returns Template for the solution item that contains key details for item reconstruction
24
25
  */
25
- export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
26
+ export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
26
27
  /**
27
28
  * Gets the ids of the dependencies of an AGOL webmap item.
28
29
  *
@@ -58,10 +59,11 @@ export declare function _getLayerIds(layerList: any[], dependencies: string[], a
58
59
  *
59
60
  * @param layerList List of map layers or tables
60
61
  * @param urlHash Lookup object for analysis layers
62
+ * @param templateDictionary Hash of key details used for variable replacement
61
63
  * @returns void
62
64
  * @private
63
65
  */
64
- export declare function _templatizeWebmapLayerIdsAndUrls(layerList: any[], urlHash: any): void;
66
+ export declare function _templatizeWebmapLayerIdsAndUrls(layerList: any[], urlHash: any, templateDictionary: any): void;
65
67
  /**
66
68
  * Templatize field references.
67
69
  *
@@ -20,10 +20,20 @@ import * as common from "@esri/solution-common";
20
20
  * @param itemInfo Info about the item
21
21
  * @param destAuthentication Credentials for requests to the destination organization
22
22
  * @param srcAuthentication Credentials for requests to source items
23
+ * @param templateDictionary Hash of key details used for variable replacement
23
24
  * @returns A promise that will resolve when the template has been created
24
25
  */
25
- export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
26
- export declare function templatizeDatasources(itemTemplate: common.IItemTemplate, authentication: common.UserSession, portalUrl: string): Promise<common.IItemTemplate>;
26
+ export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
27
+ /**
28
+ * Converts web mapping application datasources to variables for deployment
29
+ *
30
+ * @param itemTemplate The solution item template
31
+ * @param authentication Credentials for requests
32
+ * @param portalUrl Rest Url of the portal to perform the search
33
+ * @param templateDictionary Hash of key details used for variable replacement
34
+ * @returns A promise that will resolve with the created template
35
+ */
36
+ export declare function templatizeDatasources(itemTemplate: common.IItemTemplate, authentication: common.UserSession, portalUrl: string, templateDictionary: any): Promise<common.IItemTemplate>;
27
37
  export declare function templatizeWidgets(itemTemplate: common.IItemTemplate, authentication: common.UserSession, portalUrl: string, widgetPath: string, isOnScreen?: boolean): Promise<common.IItemTemplate>;
28
38
  export declare function templatizeValues(itemTemplate: common.IItemTemplate, authentication: common.UserSession, portalUrl: string, widgetPath: string): Promise<common.IItemTemplate>;
29
39
  export declare function handleServiceRequests(serviceRequests: any[], requestUrls: string[], objString: string): Promise<string>;
@@ -20,9 +20,10 @@ import * as common from "@esri/solution-common";
20
20
  * @param itemTemplate template for the workforce project item
21
21
  * @param destAuthentication Credentials for requests to the destination organization
22
22
  * @param srcAuthentication Credentials for requests to source items
23
+ * @param templateDictionary Hash of key details used for variable replacement
23
24
  * @returns templatized itemTemplate
24
25
  */
25
- export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
26
+ export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
26
27
  /**
27
28
  * Gets the current user and updates the dispatchers service
28
29
  *
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-simple-types - v1.5.1 - Apache-2.0
2
+ * @esri/solution-simple-types - v1.5.2 - Apache-2.0
3
3
  * Copyright (c) 2018-2022 Esri, Inc.
4
- * Fri Sep 30 2022 15:13:54 GMT-0700 (Pacific Daylight Time)
4
+ * Wed Oct 19 2022 09:18:29 GMT-0700 (Pacific Daylight Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -60,20 +60,21 @@
60
60
  * Converts a dashboard item to a template.
61
61
  *
62
62
  * @param itemTemplate Template for the dashboard item
63
+ * @param templateDictionary Hash of key details used for variable replacement
63
64
  * @returns templatized itemTemplate
64
65
  */
65
- function convertItemToTemplate$8(itemTemplate) {
66
- return _extractDependencies$3(itemTemplate);
66
+ function convertItemToTemplate$8(itemTemplate, templateDictionary) {
67
+ return _extractDependencies$3(itemTemplate, templateDictionary);
67
68
  }
68
69
  /**
69
70
  * Templatizes all itemIds and updates the dependency array
70
71
  *
71
72
  * @param itemTemplate Template for the dashboard item
73
+ * @param templateDictionary Hash of key details used for variable replacement
72
74
  * @returns The updated itemTemplate
73
75
  * @private
74
- * @private
75
76
  */
76
- function _extractDependencies$3(itemTemplate) {
77
+ function _extractDependencies$3(itemTemplate, templateDictionary) {
77
78
  // get dependencies from any
78
79
  const updatePaths = [
79
80
  "data.widgets",
@@ -95,7 +96,7 @@
95
96
  }
96
97
  /* istanbul ignore else */
97
98
  if (Array.isArray(obj.datasets)) {
98
- _getDatasourceDependencies(obj, itemTemplate);
99
+ _getDatasourceDependencies(obj, itemTemplate, templateDictionary);
99
100
  }
100
101
  });
101
102
  }
@@ -107,9 +108,10 @@
107
108
  *
108
109
  * @param obj A widget, selector, or urlParameter that contains a datasets collection
109
110
  * @param itemTemplate Template for the dashboard item
111
+ * @param templateDictionary Hash of key details used for variable replacement
110
112
  * @private
111
113
  */
112
- function _getDatasourceDependencies(obj, itemTemplate) {
114
+ function _getDatasourceDependencies(obj, itemTemplate, templateDictionary) {
113
115
  obj.datasets.forEach((dataset) => {
114
116
  // when the datasource has an itemId is an external datasource
115
117
  const itemId = common__namespace.getProp(dataset, "dataSource.itemId");
@@ -118,6 +120,7 @@
118
120
  itemTemplate.dependencies.push(itemId);
119
121
  }
120
122
  const layerId = common__namespace.getProp(dataset, "dataSource.layerId");
123
+ common__namespace.cacheLayerInfo(layerId?.toString(), itemId, "", templateDictionary);
121
124
  dataset.dataSource.itemId = common__namespace.templatizeTerm(itemId, itemId, layerId !== undefined ? ".layer" + layerId + ".itemId" : ".itemId");
122
125
  /* istanbul ignore else */
123
126
  if (layerId !== undefined) {
@@ -372,9 +375,10 @@
372
375
  * @param itemInfo Info about the item
373
376
  * @param destAuthentication Credentials for requests to the destination organization
374
377
  * @param srcAuthentication Credentials for requests to source items
378
+ * @param templateDictionary Hash of key details used for variable replacement
375
379
  * @returns A promise that will resolve when the template has been created
376
380
  */
377
- function convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication) {
381
+ function convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
378
382
  return new Promise((resolve, reject) => {
379
383
  // Remove org base URL and app id, e.g.,
380
384
  // http://anOrg.maps.arcgis.com/apps/CrowdsourcePolling/index.html?appid=6fc5992522d34a6b5ce80d17835eea21
@@ -412,7 +416,7 @@
412
416
  "data.httpProxy.url"
413
417
  ], common__namespace.placeholder(common__namespace.SERVER_NAME));
414
418
  common__namespace.setProp(itemTemplate, "data.geometryService", common__namespace.placeholder(common__namespace.GEOMETRY_SERVER_NAME));
415
- templatizeDatasources(itemTemplate, srcAuthentication, portalUrl).then(() => {
419
+ templatizeDatasources(itemTemplate, srcAuthentication, portalUrl, templateDictionary).then(() => {
416
420
  templatizeWidgets(itemTemplate, srcAuthentication, portalUrl, "data.widgetPool.widgets").then(_itemTemplate => {
417
421
  templatizeWidgets(_itemTemplate, srcAuthentication, portalUrl, "data.widgetOnScreen.widgets", true).then(updatedItemTemplate => {
418
422
  templatizeValues(updatedItemTemplate, srcAuthentication, portalUrl, "data.values").then(_updatedItemTemplate => {
@@ -423,7 +427,16 @@
423
427
  }, e => reject(common__namespace.fail(e)));
424
428
  });
425
429
  }
426
- function templatizeDatasources(itemTemplate, authentication, portalUrl) {
430
+ /**
431
+ * Converts web mapping application datasources to variables for deployment
432
+ *
433
+ * @param itemTemplate The solution item template
434
+ * @param authentication Credentials for requests
435
+ * @param portalUrl Rest Url of the portal to perform the search
436
+ * @param templateDictionary Hash of key details used for variable replacement
437
+ * @returns A promise that will resolve with the created template
438
+ */
439
+ function templatizeDatasources(itemTemplate, authentication, portalUrl, templateDictionary) {
427
440
  return new Promise((resolve, reject) => {
428
441
  const dataSources = common__namespace.getProp(itemTemplate, "data.dataSource.dataSources");
429
442
  if (dataSources && Object.keys(dataSources).length > 0) {
@@ -435,6 +448,7 @@
435
448
  if (common__namespace.getProp(ds, "url")) {
436
449
  if (itemId) {
437
450
  const layerId = ds.url.substr(ds.url.lastIndexOf("/") + 1);
451
+ common__namespace.cacheLayerInfo(layerId.toString(), itemId, ds.url, templateDictionary);
438
452
  ds.itemId = common__namespace.templatizeTerm(itemId, itemId, ".layer" + layerId + ".itemId");
439
453
  }
440
454
  const urlResults = findUrls(ds.url, portalUrl, [], [], authentication);
@@ -1008,10 +1022,11 @@
1008
1022
  * @param itemTemplate template for the workforce project item
1009
1023
  * @param destAuthentication Credentials for requests to the destination organization
1010
1024
  * @param srcAuthentication Credentials for requests to source items
1025
+ * @param templateDictionary Hash of key details used for variable replacement
1011
1026
  * @returns templatized itemTemplate
1012
1027
  */
1013
- function convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication) {
1014
- return common__namespace.convertWorkforceItemToTemplate(itemTemplate, srcAuthentication);
1028
+ function convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
1029
+ return common__namespace.convertWorkforceItemToTemplate(itemTemplate, srcAuthentication, templateDictionary);
1015
1030
  }
1016
1031
  /**
1017
1032
  * Gets the current user and updates the dispatchers service
@@ -1733,9 +1748,10 @@
1733
1748
  * @param itemTemplate Template for the webmap item
1734
1749
  * @param destAuthentication Credentials for requests to the destination organization
1735
1750
  * @param srcAuthentication Credentials for requests to source items
1751
+ * @param templateDictionary Hash of key details used for variable replacement
1736
1752
  * @returns Template for the solution item that contains key details for item reconstruction
1737
1753
  */
1738
- function convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication) {
1754
+ function convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication, templateDictionary) {
1739
1755
  return new Promise((resolve, reject) => {
1740
1756
  // Templatize the app URL
1741
1757
  itemTemplate.item.url = itemTemplate.item.url ?
@@ -1747,8 +1763,8 @@
1747
1763
  itemTemplate.dependencies = results.dependencies;
1748
1764
  // Templatize the map layer ids after we've extracted them as dependencies
1749
1765
  if (itemTemplate.data) {
1750
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.operationalLayers, results.urlHash);
1751
- _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.tables, results.urlHash);
1766
+ _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.operationalLayers, results.urlHash, templateDictionary);
1767
+ _templatizeWebmapLayerIdsAndUrls(itemTemplate.data.tables, results.urlHash, templateDictionary);
1752
1768
  // Exclude intialState
1753
1769
  _excludeInitialState(itemTemplate.data);
1754
1770
  }
@@ -1864,10 +1880,11 @@
1864
1880
  *
1865
1881
  * @param layerList List of map layers or tables
1866
1882
  * @param urlHash Lookup object for analysis layers
1883
+ * @param templateDictionary Hash of key details used for variable replacement
1867
1884
  * @returns void
1868
1885
  * @private
1869
1886
  */
1870
- function _templatizeWebmapLayerIdsAndUrls(layerList = [], urlHash) {
1887
+ function _templatizeWebmapLayerIdsAndUrls(layerList = [], urlHash, templateDictionary) {
1871
1888
  layerList.forEach((layer) => {
1872
1889
  if (layer.url) {
1873
1890
  const layerId = layer.url.substr(layer.url.lastIndexOf("/") + 1);
@@ -1875,6 +1892,7 @@
1875
1892
  ? urlHash[layer.url]
1876
1893
  : undefined;
1877
1894
  if (id) {
1895
+ common__namespace.cacheLayerInfo(layerId, id, layer.url, templateDictionary);
1878
1896
  layer.url = common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".url");
1879
1897
  layer.itemId = common__namespace.templatizeTerm(id, id, ".layer" + layerId + ".itemId");
1880
1898
  }
@@ -2047,32 +2065,28 @@
2047
2065
  });
2048
2066
  }
2049
2067
  });
2050
- let wrapupPromise = Promise.resolve(null);
2051
2068
  let templateModifyingPromise = Promise.resolve(itemTemplate);
2052
2069
  switch (itemInfo.type) {
2053
2070
  case "Dashboard":
2054
- convertItemToTemplate$8(itemTemplate);
2071
+ convertItemToTemplate$8(itemTemplate, templateDictionary);
2055
2072
  break;
2056
2073
  case "Form":
2057
2074
  // Store the form's data in the solution resources, not in template
2058
2075
  itemTemplate.data = null;
2059
- // Store form data
2076
+ // Add the form data to the template for a post-process resource upload
2060
2077
  if (itemDataResponse) {
2061
- const originalFilename = itemTemplate.item.name || itemDataResponse.name;
2062
- const filename = originalFilename && originalFilename !== "undefined"
2063
- ? originalFilename
2064
- : `${itemTemplate.itemId}.zip`;
2065
- itemTemplate.item.name = filename;
2066
- const storageName = common__namespace.convertItemResourceToStorageResource(itemTemplate.itemId, filename, common__namespace.SolutionTemplateFormatVersion, common__namespace.SolutionResourceType.data);
2067
- wrapupPromise = new Promise((resolveDataStorage, rejectDataStorage) => {
2068
- common__namespace
2069
- .addResourceFromBlob(itemDataResponse, solutionItemId, storageName.folder, filename, destAuthentication)
2070
- .then(() => {
2071
- // Update the template's resources
2072
- itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
2073
- resolveDataStorage();
2074
- }, rejectDataStorage);
2075
- });
2078
+ itemTemplate.item.name = _getFormDataFilename(itemTemplate.item.name, itemDataResponse.name, `${itemTemplate.itemId}.zip`);
2079
+ const storageName = common__namespace.convertItemResourceToStorageResource(itemTemplate.itemId, itemTemplate.item.name, common__namespace.SolutionTemplateFormatVersion, common__namespace.SolutionResourceType.data);
2080
+ // Add the data file to the template so that it can be uploaded with the other resources in the solution
2081
+ const dataFile = {
2082
+ itemId: itemTemplate.itemId,
2083
+ file: itemDataResponse,
2084
+ folder: storageName.folder,
2085
+ filename: itemTemplate.item.name
2086
+ };
2087
+ itemTemplate.dataFile = dataFile;
2088
+ // Update the template's resources
2089
+ itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
2076
2090
  }
2077
2091
  break;
2078
2092
  case "Notebook":
@@ -2083,25 +2097,40 @@
2083
2097
  break;
2084
2098
  case "Web Map":
2085
2099
  case "Web Scene":
2086
- templateModifyingPromise = convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication);
2100
+ templateModifyingPromise = convertItemToTemplate$2(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2087
2101
  break;
2088
2102
  case "Web Mapping Application":
2089
2103
  if (itemDataResponse) {
2090
- templateModifyingPromise = convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication);
2104
+ templateModifyingPromise = convertItemToTemplate$7(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2091
2105
  }
2092
2106
  break;
2093
2107
  case "Workforce Project":
2094
- templateModifyingPromise = convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication);
2108
+ templateModifyingPromise = convertItemToTemplate$6(itemTemplate, destAuthentication, srcAuthentication, templateDictionary);
2095
2109
  break;
2096
2110
  case "QuickCapture Project":
2097
2111
  templateModifyingPromise = convertQuickCaptureToTemplate(itemTemplate);
2098
2112
  break;
2099
2113
  }
2100
- wrapupPromise.then(() => {
2101
- templateModifyingPromise.then(resolve, err => reject(common__namespace.fail(err)));
2102
- }, err => reject(common__namespace.fail(err)));
2114
+ templateModifyingPromise.then(resolve, err => reject(common__namespace.fail(err)));
2103
2115
  });
2104
2116
  });
2117
+ }
2118
+ /**
2119
+ * Encapsulates the rules for naming a form's data file.
2120
+ * Chooses the first parameter that's defined and is not the string "undefined".
2121
+ *
2122
+ * @param itemName Template's item name
2123
+ * @param dataFilename The data file name
2124
+ * @param itemIdAsName A name constructed from the template's id suffixed with ".zip"
2125
+ *
2126
+ * @return A name for the data file
2127
+ */
2128
+ function _getFormDataFilename(itemName, dataFilename, itemIdAsName) {
2129
+ const originalFilename = itemName || dataFilename;
2130
+ const filename = originalFilename && originalFilename !== "undefined"
2131
+ ? originalFilename
2132
+ : itemIdAsName;
2133
+ return filename;
2105
2134
  }
2106
2135
 
2107
2136
  /** @license