@esri/solution-simple-types 5.2.2 → 5.2.3

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 (50) hide show
  1. package/dist/esm/helpers/convert-item-to-template.js +23 -12
  2. package/dist/esm/helpers/convert-item-to-template.js.map +1 -1
  3. package/dist/{cjs/helpers/create-item-from-template.d.ts → esm/helpers/formHelpers.d.ts} +11 -3
  4. package/dist/esm/helpers/formHelpers.js +53 -0
  5. package/dist/esm/helpers/formHelpers.js.map +1 -0
  6. package/package.json +7 -7
  7. package/dist/cjs/dashboard.d.ts +0 -93
  8. package/dist/cjs/dashboard.js +0 -353
  9. package/dist/cjs/dashboard.js.map +0 -1
  10. package/dist/cjs/helpers/convert-item-to-template.d.ts +0 -45
  11. package/dist/cjs/helpers/convert-item-to-template.js +0 -235
  12. package/dist/cjs/helpers/convert-item-to-template.js.map +0 -1
  13. package/dist/cjs/helpers/create-item-from-template.js +0 -154
  14. package/dist/cjs/helpers/create-item-from-template.js.map +0 -1
  15. package/dist/cjs/helpers/notebook-helpers.d.ts +0 -19
  16. package/dist/cjs/helpers/notebook-helpers.js +0 -25
  17. package/dist/cjs/helpers/notebook-helpers.js.map +0 -1
  18. package/dist/cjs/helpers/quickcapture-helpers.d.ts +0 -18
  19. package/dist/cjs/helpers/quickcapture-helpers.js +0 -23
  20. package/dist/cjs/helpers/quickcapture-helpers.js.map +0 -1
  21. package/dist/cjs/helpers/simple-type-helpers.d.ts +0 -18
  22. package/dist/cjs/helpers/simple-type-helpers.js +0 -23
  23. package/dist/cjs/helpers/simple-type-helpers.js.map +0 -1
  24. package/dist/cjs/helpers/update-notebook-data.d.ts +0 -17
  25. package/dist/cjs/helpers/update-notebook-data.js +0 -28
  26. package/dist/cjs/helpers/update-notebook-data.js.map +0 -1
  27. package/dist/cjs/index.d.ts +0 -27
  28. package/dist/cjs/index.js +0 -37
  29. package/dist/cjs/index.js.map +0 -1
  30. package/dist/cjs/notebook.d.ts +0 -65
  31. package/dist/cjs/notebook.js +0 -133
  32. package/dist/cjs/notebook.js.map +0 -1
  33. package/dist/cjs/oic.d.ts +0 -53
  34. package/dist/cjs/oic.js +0 -171
  35. package/dist/cjs/oic.js.map +0 -1
  36. package/dist/cjs/quickcapture.d.ts +0 -75
  37. package/dist/cjs/quickcapture.js +0 -143
  38. package/dist/cjs/quickcapture.js.map +0 -1
  39. package/dist/cjs/simple-types.d.ts +0 -56
  40. package/dist/cjs/simple-types.js +0 -94
  41. package/dist/cjs/simple-types.js.map +0 -1
  42. package/dist/cjs/webmap.d.ts +0 -102
  43. package/dist/cjs/webmap.js +0 -318
  44. package/dist/cjs/webmap.js.map +0 -1
  45. package/dist/cjs/webmappingapplication.d.ts +0 -176
  46. package/dist/cjs/webmappingapplication.js +0 -675
  47. package/dist/cjs/webmappingapplication.js.map +0 -1
  48. package/dist/cjs/workforce.d.ts +0 -34
  49. package/dist/cjs/workforce.js +0 -45
  50. package/dist/cjs/workforce.js.map +0 -1
@@ -21,6 +21,8 @@ import * as quickcapture from "../quickcapture";
21
21
  import * as webmap from "../webmap";
22
22
  import * as webmappingapplication from "../webmappingapplication";
23
23
  import * as workforce from "../workforce";
24
+ import * as formHelpers from "./formHelpers";
25
+ // ------------------------------------------------------------------------------------------------------------------ //
24
26
  /**
25
27
  * Converts an item into a template.
26
28
  *
@@ -109,18 +111,27 @@ export function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentic
109
111
  itemTemplate.data = null;
110
112
  // Add the form data to the template for a post-process resource upload
111
113
  if (itemDataResponse) {
112
- itemTemplate.item.name = _getFormDataFilename(itemTemplate.item.name, itemDataResponse.name, `${itemTemplate.itemId}.zip`);
113
- const storageName = common.convertItemResourceToStorageResource(itemTemplate.itemId, itemTemplate.item.name, common.SolutionTemplateFormatVersion, common.SolutionResourceType.data);
114
- // Add the data file to the template so that it can be uploaded with the other resources in the solution
115
- const dataFile = {
116
- itemId: itemTemplate.itemId,
117
- file: itemDataResponse,
118
- folder: storageName.folder,
119
- filename: itemTemplate.item.name
120
- };
121
- itemTemplate.dataFile = dataFile;
122
- // Update the template's resources
123
- itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
114
+ templateModifyingPromise = new Promise(
115
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises, no-async-promise-executor
116
+ async (resolve) => {
117
+ let zipObject = await common.blobToZipObject(itemDataResponse);
118
+ // Templatize the form's webhooks,
119
+ zipObject = await formHelpers.templatizeFormWebHooks(zipObject, itemTemplate.item.isOrgItem);
120
+ itemTemplate.item.name = _getFormDataFilename(itemTemplate.item.name, itemDataResponse.name, `${itemTemplate.itemId}.zip`);
121
+ const templatizedFormData = await common.zipObjectToZipFile(zipObject, itemTemplate.item.name);
122
+ // Add the data file to the template so that it can be uploaded with the other resources in the solution
123
+ const storageName = common.convertItemResourceToStorageResource(itemTemplate.itemId, itemTemplate.item.name, common.SolutionTemplateFormatVersion, common.SolutionResourceType.data);
124
+ const dataFile = {
125
+ itemId: itemTemplate.itemId,
126
+ file: templatizedFormData,
127
+ folder: storageName.folder,
128
+ filename: itemTemplate.item.name
129
+ };
130
+ itemTemplate.dataFile = dataFile;
131
+ // Update the template's resources
132
+ itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
133
+ resolve(itemTemplate);
134
+ });
124
135
  }
125
136
  break;
126
137
  case "Notebook":
@@ -1 +1 @@
1
- {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-item-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAC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ACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,QAAa;IAEb,MAAM,YAAY,GAAG,EAAc,CAAC;IACpC,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAEjF,eAAe,CAAC,OAAO,CACrB,YAAY,CAAC,EAAE;QACb,IAAI,YAAY,CAAC,IAAI,KAAK,sBAAsB,IAAI,YAAY,CAAC,IAAI,KAAK,oBAAoB,EAAE;YAC9F,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAA;YACtF,IAAI,gBAAgB,EAAE;gBACpB,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACrC;SACF;IACH,CAAC,CACF,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,YAAoB,EACpB,YAAoB;IAEpB,MAAM,gBAAgB,GAAG,QAAQ,IAAI,YAAY,CAAC;IAClD,MAAM,QAAQ,GACZ,gBAAgB,IAAI,gBAAgB,KAAK,WAAW;QAClD,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,YAAY,CAAC;IACnB,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../../src/helpers/convert-item-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAC;AAC9B,OAAO,KAAK,YAAY,MAAM,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U,oBAAoB,CAClC,QAAgB,EAChB,YAAoB,EACpB,YAAoB;IAEpB,MAAM,gBAAgB,GAAG,QAAQ,IAAI,YAAY,CAAC;IAClD,MAAM,QAAQ,GACZ,gBAAgB,IAAI,gBAAgB,KAAK,WAAW;QAClD,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,YAAY,CAAC;IACnB,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** @license
2
- * Copyright 2020 Esri
2
+ * Copyright 2024 Esri
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -13,5 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import * as common from "@esri/solution-common";
17
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
16
+ import JSZip from "jszip";
17
+ /**
18
+ * Templatizes the URLs in webhooks in a form's zip object.
19
+ *
20
+ * @param zipObject Form zip object to templatize; it is modified in place
21
+ * @param isOrgItem Indicates whether this item and the user whose credential was used to fetch this item belong
22
+ * to the same ArcGIS Enterprise Portal or ArcGIS Online Organization
23
+ * @returns Promise that resolves to the modified zip object
24
+ */
25
+ export declare function templatizeFormWebHooks(zipObject: JSZip, isOrgItem: boolean): Promise<JSZip>;
@@ -0,0 +1,53 @@
1
+ /** @license
2
+ * Copyright 2024 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import * as common from "@esri/solution-common";
17
+ // ------------------------------------------------------------------------------------------------------------------ //
18
+ /**
19
+ * Templatizes the URLs in webhooks in a form's zip object.
20
+ *
21
+ * @param zipObject Form zip object to templatize; it is modified in place
22
+ * @param isOrgItem Indicates whether this item and the user whose credential was used to fetch this item belong
23
+ * to the same ArcGIS Enterprise Portal or ArcGIS Online Organization
24
+ * @returns Promise that resolves to the modified zip object
25
+ */
26
+ export async function templatizeFormWebHooks(zipObject, isOrgItem) {
27
+ const webhooks = await common.getWebHooksFromZipObject(zipObject);
28
+ if (webhooks.length > 0) {
29
+ webhooks.forEach((webhook) => {
30
+ // Templatize the webhook URL
31
+ let url = webhook.url;
32
+ const urlObj = new URL(url);
33
+ const server = `${urlObj.protocol}//${urlObj.host}`;
34
+ const workflowServer = "https://workflow.arcgis.com";
35
+ if (server === workflowServer) {
36
+ // Templatize organization
37
+ const partialPath = url.substring(workflowServer.length);
38
+ const partialPathParts = partialPath.split("/");
39
+ const orgId = partialPathParts[1];
40
+ url = url.replace(orgId, "{{user.orgId}}");
41
+ }
42
+ else if (isOrgItem) {
43
+ // Templatize server
44
+ url = url.replace(server, "{{portalBaseUrl}}");
45
+ }
46
+ webhook.url = url;
47
+ });
48
+ zipObject = await common.setWebHooksInZipObject(zipObject, webhooks);
49
+ }
50
+ // Return the modified zip object
51
+ return Promise.resolve(zipObject);
52
+ }
53
+ //# sourceMappingURL=formHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formHelpers.js","sourceRoot":"","sources":["../../../src/helpers/formHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAGhD,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,SAAgB,EAChB,SAAkB;IAElB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAClE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAY,EAAE,EAAE;YAChC,6BAA6B;YAC7B,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YACtB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;YAE5B,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;YACpD,MAAM,cAAc,GAAG,6BAA6B,CAAC;YAErD,IAAI,MAAM,KAAK,cAAc,EAAE;gBAC7B,0BAA0B;gBAC1B,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;gBACzD,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAChD,MAAM,KAAK,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;gBAClC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;aAE5C;iBAAM,IAAI,SAAS,EAAE;gBACpB,oBAAoB;gBACpB,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;aAChD;YAED,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,SAAS,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;KACtE;IAED,iCAAiC;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-simple-types",
3
- "version": "5.2.2",
3
+ "version": "5.2.3",
4
4
  "description": "Manages the creation and deployment of simple item types for @esri/solution.js.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,13 +23,13 @@
23
23
  "@esri/arcgis-rest-portal": "^3.7.0",
24
24
  "@esri/arcgis-rest-request": "^3.7.0",
25
25
  "@esri/arcgis-rest-service-admin": "^3.7.0",
26
- "@esri/hub-common": "^14.84.0",
26
+ "@esri/hub-common": "^14.97.0",
27
27
  "@esri/hub-sites": "^14.2.2",
28
28
  "@esri/hub-teams": "^14.1.0",
29
- "@esri/solution-common": "^5.2.2",
30
- "@esri/solution-feature-layer": "^5.2.2",
31
- "@esri/solution-file": "^5.2.2",
32
- "@esri/solution-group": "^5.2.2",
29
+ "@esri/solution-common": "^5.2.3",
30
+ "@esri/solution-feature-layer": "^5.2.3",
31
+ "@esri/solution-file": "^5.2.3",
32
+ "@esri/solution-group": "^5.2.3",
33
33
  "@types/jasmine": "^5.1.4",
34
34
  "fetch-mock": "^7.7.3",
35
35
  "jasmine": "^5.1.0",
@@ -90,5 +90,5 @@
90
90
  "esri",
91
91
  "ES6"
92
92
  ],
93
- "gitHead": "d92c1d8e3e6df12fda59df3ecc395d7570fa60dd"
93
+ "gitHead": "bcf0907f47cf8a2970f8da38f8e1e2a4ac7beccb"
94
94
  }
@@ -1,93 +0,0 @@
1
- /** @license
2
- * Copyright 2018 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import * as common from "@esri/solution-common";
17
- /**
18
- * Converts a dashboard item to a template.
19
- *
20
- * @param itemTemplate Template for the dashboard item
21
- * @param templateDictionary Hash of key details used for variable replacement
22
- * @returns templatized itemTemplate
23
- */
24
- export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, templateDictionary: any): common.IItemTemplate;
25
- /**
26
- * Templatizes all itemIds and updates the dependency array
27
- *
28
- * @param itemTemplate Template for the dashboard item
29
- * @param templateDictionary Hash of key details used for variable replacement
30
- * @returns The updated itemTemplate
31
- * @private
32
- */
33
- export declare function _extractDependencies(itemTemplate: common.IItemTemplate, templateDictionary: any): common.IItemTemplate;
34
- /**
35
- * Templatize datasource itemIds and update the dependency array
36
- *
37
- * @param obj A widget, selector, or urlParameter that contains a datasets collection
38
- * @param itemTemplate Template for the dashboard item
39
- * @param templateDictionary Hash of key details used for variable replacement
40
- * @private
41
- */
42
- export declare function _getDatasourceDependencies(obj: any, itemTemplate: common.IItemTemplate, templateDictionary: any): void;
43
- /**
44
- * Templatize field references for datasources and widgets.
45
- *
46
- * @param solutionTemplate The solution item template
47
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
48
- * @returns The solutionTemplate with templatized field references
49
- */
50
- export declare function postProcessFieldReferences(solutionTemplate: common.IItemTemplate, datasourceInfos: common.IDatasourceInfo[]): common.IItemTemplate;
51
- /**
52
- * Add all dataset ids to the appropriate datasource info object so we can navigate any relative references
53
- *
54
- * @param objs Thes can be widgets, selectors, or urlParameters
55
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
56
- * @private
57
- */
58
- export declare function _updateDatasourceReferences(objs: any, datasourceInfos: common.IDatasourceInfo[]): void;
59
- /**
60
- * Templatize all datasets and/or events for the objects at the given path
61
- *
62
- * @param itemTemplate Template for the dashboard item
63
- * @param path A property path to an array of objects that could contain datasets or events
64
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
65
- * @private
66
- */
67
- export declare function _templatize(itemTemplate: common.IItemTemplate, path: string, datasourceInfos: common.IDatasourceInfo[]): void;
68
- /**
69
- * For any service dataset datasource templatize all field references
70
- *
71
- * @param objs A list of objects that can contain field references
72
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
73
- * @returns An updated list of objects with templatized field references
74
- * @private
75
- */
76
- export declare function _templatizeByDatasource(objs: any[], datasourceInfos: common.IDatasourceInfo[]): any;
77
- /**
78
- * Find the appropriate datasource info object from the datasourceInfo collection
79
- *
80
- * @param obj Can be a Dataset or an event
81
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
82
- * @returns The supporting datasource info for the given object
83
- * @private
84
- */
85
- export declare function _getDatasourceInfo(obj: any, datasourceInfos: common.IDatasourceInfo[]): any;
86
- /**
87
- * Verifies if the datasource info contains the given id and adds it if not
88
- *
89
- * @param ds The datasource info to add the reference to
90
- * @param id The id from dashboard object, commonly another widget
91
- * @private
92
- */
93
- export declare function _updateReferences(ds: common.IDatasourceInfo, id: string): void;
@@ -1,353 +0,0 @@
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._updateReferences = exports._getDatasourceInfo = exports._templatizeByDatasource = exports._templatize = exports._updateDatasourceReferences = exports.postProcessFieldReferences = exports._getDatasourceDependencies = exports._extractDependencies = exports.convertItemToTemplate = void 0;
19
- const tslib_1 = require("tslib");
20
- const common = tslib_1.__importStar(require("@esri/solution-common"));
21
- /**
22
- * Converts a dashboard item to a template.
23
- *
24
- * @param itemTemplate Template for the dashboard item
25
- * @param templateDictionary Hash of key details used for variable replacement
26
- * @returns templatized itemTemplate
27
- */
28
- function convertItemToTemplate(itemTemplate, templateDictionary) {
29
- return _extractDependencies(itemTemplate, templateDictionary);
30
- }
31
- exports.convertItemToTemplate = convertItemToTemplate;
32
- /**
33
- * Templatizes all itemIds and updates the dependency array
34
- *
35
- * @param itemTemplate Template for the dashboard item
36
- * @param templateDictionary Hash of key details used for variable replacement
37
- * @returns The updated itemTemplate
38
- * @private
39
- */
40
- function _extractDependencies(itemTemplate, templateDictionary) {
41
- // get dependencies from any
42
- const updatePaths = [
43
- "data.desktopView.header",
44
- "data.desktopView.headerPanel.selectors",
45
- "data.desktopView.leftPanel.selectors",
46
- "data.desktopView.sidebar",
47
- "data.desktopView.urlParameters",
48
- "data.desktopView.widgets",
49
- "data.header",
50
- "data.headerPanel.selectors",
51
- "data.leftPanel.selectors",
52
- "data.mobileView.header",
53
- "data.mobileView.headerPanel.selectors",
54
- "data.mobileView.leftPanel.selectors",
55
- "data.mobileView.sidebar",
56
- "data.mobileView.urlParameters",
57
- "data.mobileView.widgets",
58
- "data.sidebar",
59
- "data.urlParameters",
60
- "data.widgets"
61
- ];
62
- updatePaths.forEach(path => {
63
- const objs = common.getProp(itemTemplate, path);
64
- if (Array.isArray(objs)) {
65
- objs.forEach(obj => {
66
- /* istanbul ignore else */
67
- if (obj.type === "mapWidget") {
68
- /* istanbul ignore else */
69
- if (itemTemplate.dependencies.indexOf(obj.itemId) < 0) {
70
- itemTemplate.dependencies.push(obj.itemId);
71
- }
72
- obj.itemId = common.templatizeTerm(obj.itemId, obj.itemId, ".itemId");
73
- }
74
- /* istanbul ignore else */
75
- if (Array.isArray(obj.datasets)) {
76
- _getDatasourceDependencies(obj, itemTemplate, templateDictionary);
77
- }
78
- });
79
- }
80
- });
81
- return itemTemplate;
82
- }
83
- exports._extractDependencies = _extractDependencies;
84
- /**
85
- * Templatize datasource itemIds and update the dependency array
86
- *
87
- * @param obj A widget, selector, or urlParameter that contains a datasets collection
88
- * @param itemTemplate Template for the dashboard item
89
- * @param templateDictionary Hash of key details used for variable replacement
90
- * @private
91
- */
92
- function _getDatasourceDependencies(obj, itemTemplate, templateDictionary) {
93
- obj.datasets.forEach((dataset) => {
94
- // when the datasource has an itemId it's an external datasource except if the datasource type is "arcadeDataSource"
95
- const dataSourceType = common.getProp(dataset, "dataSource.type");
96
- if (dataSourceType !== "arcadeDataSource") {
97
- const itemId = common.getProp(dataset, "dataSource.itemId");
98
- if (itemId) {
99
- if (itemTemplate.dependencies.indexOf(itemId) < 0) {
100
- itemTemplate.dependencies.push(itemId);
101
- }
102
- const layerId = common.getProp(dataset, "dataSource.layerId");
103
- common.cacheLayerInfo(layerId?.toString(), itemId, "", templateDictionary);
104
- dataset.dataSource.itemId = common.templatizeTerm(itemId, itemId, ".itemId");
105
- }
106
- }
107
- });
108
- }
109
- exports._getDatasourceDependencies = _getDatasourceDependencies;
110
- /**
111
- * Templatize field references for datasources and widgets.
112
- *
113
- * @param solutionTemplate The solution item template
114
- * @param datasourceInfos A list of datasource info objects that contain key values to templatize field references
115
- * @returns The solutionTemplate with templatized field references
116
- */
117
- function postProcessFieldReferences(solutionTemplate, datasourceInfos) {
118
- const updatePaths = [
119
- "data.desktopView.header",
120
- "data.desktopView.headerPanel.selectors",
121
- "data.desktopView.leftPanel.selectors",
122
- "data.desktopView.sidebar",
123
- "data.desktopView.urlParameters",
124
- "data.desktopView.widgets",
125
- "data.header",
126
- "data.headerPanel.selectors",
127
- "data.leftPanel.selectors",
128
- "data.mobileView.header",
129
- "data.mobileView.headerPanel.selectors",
130
- "data.mobileView.leftPanel.selectors",
131
- "data.mobileView.sidebar",
132
- "data.mobileView.urlParameters",
133
- "data.mobileView.widgets",
134
- "data.sidebar",
135
- "data.urlParameters",
136
- "data.widgets"
137
- ];
138
- // dashboards reference datasets from other widgets
139
- // add reference IDs to the appropriate datasourceInfos
140
- updatePaths.forEach(path => {
141
- const objs = common.getProp(solutionTemplate, path);
142
- _updateDatasourceReferences(objs, datasourceInfos);
143
- });
144
- // after we know the potential references go ahead and templatize
145
- updatePaths.forEach(path => {
146
- _templatize(solutionTemplate, path, datasourceInfos);
147
- });
148
- return solutionTemplate;
149
- }
150
- exports.postProcessFieldReferences = postProcessFieldReferences;
151
- /**
152
- * Add all dataset ids to the appropriate datasource info object so we can navigate any relative references
153
- *
154
- * @param objs Thes can be widgets, selectors, or urlParameters
155
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
156
- * @private
157
- */
158
- function _updateDatasourceReferences(objs, datasourceInfos) {
159
- // objects can be events or widgets
160
- /* istanbul ignore else */
161
- if (objs && Array.isArray(objs)) {
162
- objs.forEach(obj => {
163
- if (Array.isArray(obj.datasets)) {
164
- obj.datasets.forEach((dataset) => {
165
- // when the datasource has an itemId it's an external datasource
166
- const itemId = common.cleanItemId(common.getProp(dataset, "dataSource.itemId"));
167
- if (itemId) {
168
- const layerId = common.cleanLayerId(common.getProp(dataset, "dataSource.layerId"));
169
- datasourceInfos.some(ds => {
170
- if (ds.itemId === itemId && ds.layerId === layerId) {
171
- _updateReferences(ds, obj.id);
172
- return true;
173
- }
174
- else {
175
- return false;
176
- }
177
- });
178
- }
179
- else {
180
- // add placeholder for map layer datasource info so we can know the items that reference them
181
- // needed when item field reference are derived from another widgets datasource eg. <dashboardWidgetId>#datasetname
182
- const id = common.getProp(dataset, "dataSource.id");
183
- if (id) {
184
- const dashboardLayerId = id.split("#")[1];
185
- datasourceInfos.some(ds => {
186
- if (ds.ids.indexOf(dashboardLayerId) > -1) {
187
- _updateReferences(ds, obj.id);
188
- return true;
189
- }
190
- else {
191
- return false;
192
- }
193
- });
194
- }
195
- }
196
- });
197
- }
198
- });
199
- }
200
- }
201
- exports._updateDatasourceReferences = _updateDatasourceReferences;
202
- /**
203
- * Templatize all datasets and/or events for the objects at the given path
204
- *
205
- * @param itemTemplate Template for the dashboard item
206
- * @param path A property path to an array of objects that could contain datasets or events
207
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
208
- * @private
209
- */
210
- function _templatize(itemTemplate, path, datasourceInfos) {
211
- const obj = common.getProp(itemTemplate, path);
212
- /* istanbul ignore else */
213
- if (obj) {
214
- common.setProp(itemTemplate, path, _templatizeByDatasource(obj, datasourceInfos));
215
- }
216
- }
217
- exports._templatize = _templatize;
218
- /**
219
- * For any service dataset datasource templatize all field references
220
- *
221
- * @param objs A list of objects that can contain field references
222
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
223
- * @returns An updated list of objects with templatized field references
224
- * @private
225
- */
226
- function _templatizeByDatasource(objs, datasourceInfos) {
227
- if (Array.isArray(objs)) {
228
- return objs.map(obj => {
229
- let _obj = obj;
230
- if (Array.isArray(_obj.events)) {
231
- // Events can be associated with datasets but they can also be associated with a target
232
- // In some cases an event will have a source and a target.
233
- // Handle these specifically first to ensure that it has the correct layer reference
234
- _obj.events = _obj.events.map((event) => {
235
- const _event = event;
236
- /* istanbul ignore else */
237
- if (Array.isArray(_event.actions)) {
238
- _event.actions = _event.actions.map((action) => {
239
- const _action = action;
240
- if (_action.fieldMap &&
241
- _action.targetId &&
242
- _action.targetId.indexOf("#") > -1) {
243
- const datasourceInfo = _getDatasourceInfo(_action, datasourceInfos);
244
- /* istanbul ignore else */
245
- if (datasourceInfo) {
246
- const fields = common.getProp(datasourceInfo, "fields");
247
- const basePath = common.getProp(datasourceInfo, "basePath");
248
- /* istanbul ignore else */
249
- if (Array.isArray(fields) && basePath) {
250
- _action.fieldMap = _action.fieldMap.map((m) => {
251
- const _m = m;
252
- _m.targetName = common.templatizeFieldReferences(_m.targetName, fields, basePath);
253
- return _m;
254
- });
255
- }
256
- }
257
- }
258
- return _action;
259
- });
260
- }
261
- return _event;
262
- });
263
- }
264
- if (Array.isArray(_obj.datasets)) {
265
- _obj.datasets = _obj.datasets.map((dataset) => {
266
- let _dataset = dataset;
267
- if (_dataset.type === "serviceDataset") {
268
- const datasourceInfo = _getDatasourceInfo(dataset, datasourceInfos);
269
- /* istanbul ignore else */
270
- if (datasourceInfo) {
271
- const fields = common.getProp(datasourceInfo, "fields");
272
- const basePath = common.getProp(datasourceInfo, "basePath");
273
- /* istanbul ignore else */
274
- if (Array.isArray(fields) && basePath) {
275
- _obj = common.templatizeFieldReferences(_obj, fields, basePath);
276
- _dataset = common.templatizeFieldReferences(_dataset, fields, basePath);
277
- }
278
- }
279
- }
280
- return _dataset;
281
- });
282
- return _obj;
283
- }
284
- else
285
- return _obj;
286
- });
287
- }
288
- else {
289
- return objs;
290
- }
291
- }
292
- exports._templatizeByDatasource = _templatizeByDatasource;
293
- /**
294
- * Find the appropriate datasource info object from the datasourceInfo collection
295
- *
296
- * @param obj Can be a Dataset or an event
297
- * @param datasourceInfos A list of objects that contain key details about the datasources from the application
298
- * @returns The supporting datasource info for the given object
299
- * @private
300
- */
301
- function _getDatasourceInfo(obj, datasourceInfos) {
302
- let info;
303
- // the datasource will have an id property when it's referencing a map layer
304
- // the fields collection will already be defined
305
- const id = common.getProp(obj, "dataSource.id") || common.getProp(obj, "targetId");
306
- if (id) {
307
- const dashboardLayerId = id.split("#")[1];
308
- if (!datasourceInfos.some(di => {
309
- info = di.ids.indexOf(dashboardLayerId) > -1 ? di : info;
310
- return di.ids.indexOf(dashboardLayerId) > -1;
311
- })) {
312
- // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
313
- // in that case lookup the datasource from referenced widget
314
- const dashboardWidgetId = id.split("#")[0];
315
- datasourceInfos.some(di => {
316
- const references = di.references || [];
317
- const hasRef = references.indexOf(dashboardWidgetId) > -1;
318
- info = hasRef ? di : info;
319
- return hasRef;
320
- });
321
- }
322
- }
323
- else {
324
- // otherwise match the itemId and the layerId to get the correct fields and path
325
- const itemId = common.cleanItemId(common.getProp(obj, "dataSource.itemId"));
326
- const layerId = common.cleanLayerId(common.getProp(obj, "dataSource.layerId"));
327
- /* istanbul ignore else */
328
- if (itemId) {
329
- datasourceInfos.some(di => {
330
- const matches = itemId === di.itemId && layerId === di.layerId;
331
- info = matches ? di : info;
332
- return matches;
333
- });
334
- }
335
- }
336
- return info;
337
- }
338
- exports._getDatasourceInfo = _getDatasourceInfo;
339
- /**
340
- * Verifies if the datasource info contains the given id and adds it if not
341
- *
342
- * @param ds The datasource info to add the reference to
343
- * @param id The id from dashboard object, commonly another widget
344
- * @private
345
- */
346
- function _updateReferences(ds, id) {
347
- ds.references = Array.isArray(ds.references) ? ds.references : [];
348
- if (ds.references.indexOf(id) < 0) {
349
- ds.references.push(id);
350
- }
351
- }
352
- exports._updateReferences = _updateReferences;
353
- //# sourceMappingURL=dashboard.js.map