@esri/solution-viewer 1.1.3 → 1.3.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.
@@ -37,3 +37,17 @@ export declare function checkSolution(itemId: string, authentication?: common.Us
37
37
  * @see Only comparable properties are compared; see deleteItemProps() in the `common` package
38
38
  */
39
39
  export declare function compareItems(item1: string | any, item2: string | any, authentication?: common.UserSession): Promise<boolean>;
40
+ /**
41
+ * Creates a hierarchy of the items in a Solution template.
42
+ *
43
+ * @param templates Array of templates from a Solution
44
+ * @return List of top-level items, each containing a recursive list of its dependencies
45
+ */
46
+ export declare function getItemHierarchy(templates: common.IItemTemplate[]): common.IHierarchyElement[];
47
+ /**
48
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
+ *
50
+ * @param templates Array of templates from a Solution
51
+ * @return List of top-level item ids
52
+ */
53
+ export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -36,7 +36,7 @@ export function checkSolution(itemId, authentication = null) {
36
36
  let currentAction = " while getting complete item";
37
37
  return (common
38
38
  .getCompleteItem(itemId, authentication)
39
- // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//
39
+ // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
40
40
  .then((results) => {
41
41
  currentAction = "";
42
42
  item = results;
@@ -65,7 +65,7 @@ export function checkSolution(itemId, authentication = null) {
65
65
  // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs
66
66
  return common.blobToJson(item.data);
67
67
  })
68
- // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//
68
+ // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
69
69
  .then(itemDataJson => {
70
70
  templateItems = itemDataJson?.templates;
71
71
  /* istanbul ignore else */
@@ -97,7 +97,7 @@ export function checkSolution(itemId, authentication = null) {
97
97
  }
98
98
  return resultsHtml;
99
99
  })
100
- // ---------- Check that all dependency references are items in Solution -------------------------------------------//
100
+ // ---------- Check that all dependency references are items in Solution ---------------------------------------//
101
101
  .then(() => {
102
102
  const dependencyIds = templateItems
103
103
  .reduce((flatSet, template) => flatSet.concat(template.dependencies), [])
@@ -118,11 +118,11 @@ export function checkSolution(itemId, authentication = null) {
118
118
  }
119
119
  return resultsHtml;
120
120
  })
121
- // ---------- Done -------------------------------------------------------------------------------------------------//
121
+ // ---------- Done ---------------------------------------------------------------------------------------------//
122
122
  .then(() => {
123
123
  return resultsHtml;
124
124
  })
125
- // ---------- Fatal error ------------------------------------------------------------------------------------------//
125
+ // ---------- Fatal error --------------------------------------------------------------------------------------//
126
126
  .catch(error => {
127
127
  resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);
128
128
  return resultsHtml;
@@ -173,4 +173,81 @@ export function compareItems(item1, item2, authentication = null) {
173
173
  }, e => reject(e));
174
174
  });
175
175
  }
176
+ /**
177
+ * Creates a hierarchy of the items in a Solution template.
178
+ *
179
+ * @param templates Array of templates from a Solution
180
+ * @return List of top-level items, each containing a recursive list of its dependencies
181
+ */
182
+ export function getItemHierarchy(templates) {
183
+ const hierarchy = [];
184
+ // Get the template specified by id out of a list of templates
185
+ function getTemplateInSolution(templates, id) {
186
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
187
+ return iTemplate >= 0 ? templates[iTemplate] : null;
188
+ }
189
+ // Hierarchically list the dependencies of specified node
190
+ function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
191
+ // Get the dependencies of the node
192
+ const template = getTemplateInSolution(templates, id);
193
+ /* istanbul ignore else */
194
+ if (template) {
195
+ const templateEntry = {
196
+ id,
197
+ dependencies: []
198
+ };
199
+ // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
200
+ if (alreadyVisitedIds.indexOf(id) < 0) {
201
+ // Add dependency to alreadyVisitedIds list
202
+ alreadyVisitedIds.push(id);
203
+ template.dependencies.forEach(dependencyId => {
204
+ // Remove dependency from list of templates to visit in the top-level loop
205
+ const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
206
+ if (iDependencyTemplate >= 0) {
207
+ templateItemIds.splice(iDependencyTemplate, 1);
208
+ }
209
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
210
+ });
211
+ }
212
+ accumulatedHierarchy.push(templateEntry);
213
+ }
214
+ }
215
+ // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
216
+ let templateItemIds = _getTopLevelItemIds(templates);
217
+ const otherItems = templates
218
+ .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
219
+ .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
220
+ templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));
221
+ // Step through the list of nodes; we'll also remove nodes as we visit them
222
+ let itemId = templateItemIds.shift();
223
+ while (typeof itemId !== "undefined") {
224
+ traceItemId(itemId, hierarchy);
225
+ itemId = templateItemIds.shift();
226
+ }
227
+ return hierarchy;
228
+ }
229
+ // ------------------------------------------------------------------------------------------------------------------ //
230
+ /**
231
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
232
+ *
233
+ * @param templates Array of templates from a Solution
234
+ * @return List of top-level item ids
235
+ */
236
+ export function _getTopLevelItemIds(templates) {
237
+ // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
238
+ const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });
239
+ templates.forEach(function (template) {
240
+ (template.dependencies || []).forEach(function (dependencyId) {
241
+ const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
242
+ /* istanbul ignore else */
243
+ if (iNode >= 0) {
244
+ // Node is somebody's dependency, so remove the node from the list of top-level nodes
245
+ // If iNode == -1, then it's a shared dependency and it has already been removed
246
+ topLevelItemCandidateIds.splice(iNode, 1);
247
+ }
248
+ });
249
+ });
250
+ return topLevelItemCandidateIds;
251
+ }
252
+ ;
176
253
  //# sourceMappingURL=viewer.js.map
@@ -1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Q,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhG,SAAS,CAAC,OAAO,CAAC,UAAU,QAAQ;QAClC,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,YAAY;YAC1D,MAAM,KAAK,GAAG,wBAAwB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAE7D,0BAA0B;YAC1B,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,qFAAqF;gBACrF,gFAAgF;gBAChF,wBAAwB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAAA,CAAC"}
@@ -37,3 +37,17 @@ export declare function checkSolution(itemId: string, authentication?: common.Us
37
37
  * @see Only comparable properties are compared; see deleteItemProps() in the `common` package
38
38
  */
39
39
  export declare function compareItems(item1: string | any, item2: string | any, authentication?: common.UserSession): Promise<boolean>;
40
+ /**
41
+ * Creates a hierarchy of the items in a Solution template.
42
+ *
43
+ * @param templates Array of templates from a Solution
44
+ * @return List of top-level items, each containing a recursive list of its dependencies
45
+ */
46
+ export declare function getItemHierarchy(templates: common.IItemTemplate[]): common.IHierarchyElement[];
47
+ /**
48
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
+ *
50
+ * @param templates Array of templates from a Solution
51
+ * @return List of top-level item ids
52
+ */
53
+ export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -15,13 +15,14 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.compareItems = exports.checkSolution = void 0;
18
+ exports._getTopLevelItemIds = exports.getItemHierarchy = exports.compareItems = exports.checkSolution = void 0;
19
+ const tslib_1 = require("tslib");
19
20
  /**
20
21
  * Provides the access to the solution's contents.
21
22
  *
22
23
  * @module viewer
23
24
  */
24
- const common = require("@esri/solution-common");
25
+ const common = (0, tslib_1.__importStar)(require("@esri/solution-common"));
25
26
  // ------------------------------------------------------------------------------------------------------------------ //
26
27
  /**
27
28
  * Checks a Solution.
@@ -39,7 +40,7 @@ function checkSolution(itemId, authentication = null) {
39
40
  let currentAction = " while getting complete item";
40
41
  return (common
41
42
  .getCompleteItem(itemId, authentication)
42
- // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//
43
+ // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
43
44
  .then((results) => {
44
45
  currentAction = "";
45
46
  item = results;
@@ -68,7 +69,7 @@ function checkSolution(itemId, authentication = null) {
68
69
  // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs
69
70
  return common.blobToJson(item.data);
70
71
  })
71
- // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//
72
+ // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
72
73
  .then(itemDataJson => {
73
74
  templateItems = itemDataJson?.templates;
74
75
  /* istanbul ignore else */
@@ -100,7 +101,7 @@ function checkSolution(itemId, authentication = null) {
100
101
  }
101
102
  return resultsHtml;
102
103
  })
103
- // ---------- Check that all dependency references are items in Solution -------------------------------------------//
104
+ // ---------- Check that all dependency references are items in Solution ---------------------------------------//
104
105
  .then(() => {
105
106
  const dependencyIds = templateItems
106
107
  .reduce((flatSet, template) => flatSet.concat(template.dependencies), [])
@@ -121,11 +122,11 @@ function checkSolution(itemId, authentication = null) {
121
122
  }
122
123
  return resultsHtml;
123
124
  })
124
- // ---------- Done -------------------------------------------------------------------------------------------------//
125
+ // ---------- Done ---------------------------------------------------------------------------------------------//
125
126
  .then(() => {
126
127
  return resultsHtml;
127
128
  })
128
- // ---------- Fatal error ------------------------------------------------------------------------------------------//
129
+ // ---------- Fatal error --------------------------------------------------------------------------------------//
129
130
  .catch(error => {
130
131
  resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);
131
132
  return resultsHtml;
@@ -178,4 +179,83 @@ function compareItems(item1, item2, authentication = null) {
178
179
  });
179
180
  }
180
181
  exports.compareItems = compareItems;
182
+ /**
183
+ * Creates a hierarchy of the items in a Solution template.
184
+ *
185
+ * @param templates Array of templates from a Solution
186
+ * @return List of top-level items, each containing a recursive list of its dependencies
187
+ */
188
+ function getItemHierarchy(templates) {
189
+ const hierarchy = [];
190
+ // Get the template specified by id out of a list of templates
191
+ function getTemplateInSolution(templates, id) {
192
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
193
+ return iTemplate >= 0 ? templates[iTemplate] : null;
194
+ }
195
+ // Hierarchically list the dependencies of specified node
196
+ function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
197
+ // Get the dependencies of the node
198
+ const template = getTemplateInSolution(templates, id);
199
+ /* istanbul ignore else */
200
+ if (template) {
201
+ const templateEntry = {
202
+ id,
203
+ dependencies: []
204
+ };
205
+ // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
206
+ if (alreadyVisitedIds.indexOf(id) < 0) {
207
+ // Add dependency to alreadyVisitedIds list
208
+ alreadyVisitedIds.push(id);
209
+ template.dependencies.forEach(dependencyId => {
210
+ // Remove dependency from list of templates to visit in the top-level loop
211
+ const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
212
+ if (iDependencyTemplate >= 0) {
213
+ templateItemIds.splice(iDependencyTemplate, 1);
214
+ }
215
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
216
+ });
217
+ }
218
+ accumulatedHierarchy.push(templateEntry);
219
+ }
220
+ }
221
+ // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
222
+ let templateItemIds = _getTopLevelItemIds(templates);
223
+ const otherItems = templates
224
+ .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
225
+ .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
226
+ templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));
227
+ // Step through the list of nodes; we'll also remove nodes as we visit them
228
+ let itemId = templateItemIds.shift();
229
+ while (typeof itemId !== "undefined") {
230
+ traceItemId(itemId, hierarchy);
231
+ itemId = templateItemIds.shift();
232
+ }
233
+ return hierarchy;
234
+ }
235
+ exports.getItemHierarchy = getItemHierarchy;
236
+ // ------------------------------------------------------------------------------------------------------------------ //
237
+ /**
238
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
239
+ *
240
+ * @param templates Array of templates from a Solution
241
+ * @return List of top-level item ids
242
+ */
243
+ function _getTopLevelItemIds(templates) {
244
+ // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
245
+ const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });
246
+ templates.forEach(function (template) {
247
+ (template.dependencies || []).forEach(function (dependencyId) {
248
+ const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
249
+ /* istanbul ignore else */
250
+ if (iNode >= 0) {
251
+ // Node is somebody's dependency, so remove the node from the list of top-level nodes
252
+ // If iNode == -1, then it's a shared dependency and it has already been removed
253
+ topLevelItemCandidateIds.splice(iNode, 1);
254
+ }
255
+ });
256
+ });
257
+ return topLevelItemCandidateIds;
258
+ }
259
+ exports._getTopLevelItemIds = _getTopLevelItemIds;
260
+ ;
181
261
  //# sourceMappingURL=viewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/viewer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,gDAAgD;AAEhD,wHAAwH;AAExH;;;;;;GAMG;AACH,SAAgB,aAAa,CAC3B,MAAc,EACd,iBAAqC,IAAI;IAEzC,MAAM,WAAW,GAAa,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC;IACjD,IAAI,IAA0B,CAAC;IAC/B,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,IAAI,aAAqC,CAAC;IAC1C,IAAI,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AC,CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,wBAAwB,CAAC;AAClC,CAAC;AApBD,kDAoBC;AAAA,CAAC"}
@@ -37,3 +37,17 @@ export declare function checkSolution(itemId: string, authentication?: common.Us
37
37
  * @see Only comparable properties are compared; see deleteItemProps() in the `common` package
38
38
  */
39
39
  export declare function compareItems(item1: string | any, item2: string | any, authentication?: common.UserSession): Promise<boolean>;
40
+ /**
41
+ * Creates a hierarchy of the items in a Solution template.
42
+ *
43
+ * @param templates Array of templates from a Solution
44
+ * @return List of top-level items, each containing a recursive list of its dependencies
45
+ */
46
+ export declare function getItemHierarchy(templates: common.IItemTemplate[]): common.IHierarchyElement[];
47
+ /**
48
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
+ *
50
+ * @param templates Array of templates from a Solution
51
+ * @return List of top-level item ids
52
+ */
53
+ export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-viewer - v1.1.3 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Mon Oct 18 2021 09:02:58 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-viewer - v1.3.0 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 09:44:03 GMT-0800 (Pacific Standard 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.
@@ -18,8 +18,28 @@
18
18
  (function (global, factory) {
19
19
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
20
20
  typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
21
- (global = global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
22
- }(this, (function (exports, common) { 'use strict';
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);
23
43
 
24
44
  /** @license
25
45
  * Copyright 2018 Esri
@@ -51,8 +71,9 @@
51
71
  let templateItems;
52
72
  let templateItemIds;
53
73
  let currentAction = " while getting complete item";
54
- return (common.getCompleteItem(itemId, authentication)
55
- // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//
74
+ return (common__namespace
75
+ .getCompleteItem(itemId, authentication)
76
+ // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
56
77
  .then((results) => {
57
78
  currentAction = "";
58
79
  item = results;
@@ -79,9 +100,9 @@
79
100
  // resources: File[]; list of */*
80
101
  // fwdRelatedItems: IRelatedItems[]; list of forward relationshipType/relatedItems[] pairs
81
102
  // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs
82
- return common.blobToJson(item.data);
103
+ return common__namespace.blobToJson(item.data);
83
104
  })
84
- // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//
105
+ // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
85
106
  .then(itemDataJson => {
86
107
  templateItems = itemDataJson?.templates;
87
108
  /* istanbul ignore else */
@@ -113,7 +134,7 @@
113
134
  }
114
135
  return resultsHtml;
115
136
  })
116
- // ---------- Check that all dependency references are items in Solution -------------------------------------------//
137
+ // ---------- Check that all dependency references are items in Solution ---------------------------------------//
117
138
  .then(() => {
118
139
  const dependencyIds = templateItems
119
140
  .reduce((flatSet, template) => flatSet.concat(template.dependencies), [])
@@ -134,11 +155,11 @@
134
155
  }
135
156
  return resultsHtml;
136
157
  })
137
- // ---------- Done -------------------------------------------------------------------------------------------------//
158
+ // ---------- Done ---------------------------------------------------------------------------------------------//
138
159
  .then(() => {
139
160
  return resultsHtml;
140
161
  })
141
- // ---------- Fatal error ------------------------------------------------------------------------------------------//
162
+ // ---------- Fatal error --------------------------------------------------------------------------------------//
142
163
  .catch(error => {
143
164
  resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);
144
165
  return resultsHtml;
@@ -159,22 +180,22 @@
159
180
  // item base to remove incomparable properties
160
181
  let itemBaseDef1;
161
182
  if (typeof item1 === "string") {
162
- itemBaseDef1 = common.getItemBase(item1, authentication);
183
+ itemBaseDef1 = common__namespace.getItemBase(item1, authentication);
163
184
  }
164
185
  else {
165
- itemBaseDef1 = Promise.resolve(common.cloneObject(item1));
186
+ itemBaseDef1 = Promise.resolve(common__namespace.cloneObject(item1));
166
187
  }
167
188
  let itemBaseDef2;
168
189
  if (typeof item2 === "string") {
169
- itemBaseDef2 = common.getItemBase(item2, authentication);
190
+ itemBaseDef2 = common__namespace.getItemBase(item2, authentication);
170
191
  }
171
192
  else {
172
- itemBaseDef2 = Promise.resolve(common.cloneObject(item2));
193
+ itemBaseDef2 = Promise.resolve(common__namespace.cloneObject(item2));
173
194
  }
174
195
  Promise.all([itemBaseDef1, itemBaseDef2]).then(responses => {
175
196
  const [itemBase1, itemBase2] = responses;
176
- common.deleteItemProps(itemBase1);
177
- common.deleteItemProps(itemBase2);
197
+ common__namespace.deleteItemProps(itemBase1);
198
+ common__namespace.deleteItemProps(itemBase2);
178
199
  if (itemBase1.type === "Solution") {
179
200
  delete itemBase1.typeKeywords;
180
201
  delete itemBase1.size;
@@ -185,15 +206,93 @@
185
206
  console.log("item 1 " + item1 + ": ", JSON.stringify(itemBase1, null, 2));
186
207
  console.log("item 2 " + item2 + ": ", JSON.stringify(itemBase2, null, 2));
187
208
  console.log("----------------------------------------------------------------");*/
188
- resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));
209
+ resolve(common__namespace.compareJSONNoEmptyStrings(itemBase1, itemBase2));
189
210
  }, e => reject(e));
190
211
  });
212
+ }
213
+ /**
214
+ * Creates a hierarchy of the items in a Solution template.
215
+ *
216
+ * @param templates Array of templates from a Solution
217
+ * @return List of top-level items, each containing a recursive list of its dependencies
218
+ */
219
+ function getItemHierarchy(templates) {
220
+ const hierarchy = [];
221
+ // Get the template specified by id out of a list of templates
222
+ function getTemplateInSolution(templates, id) {
223
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
224
+ return iTemplate >= 0 ? templates[iTemplate] : null;
225
+ }
226
+ // Hierarchically list the dependencies of specified node
227
+ function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
228
+ // Get the dependencies of the node
229
+ const template = getTemplateInSolution(templates, id);
230
+ /* istanbul ignore else */
231
+ if (template) {
232
+ const templateEntry = {
233
+ id,
234
+ dependencies: []
235
+ };
236
+ // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
237
+ if (alreadyVisitedIds.indexOf(id) < 0) {
238
+ // Add dependency to alreadyVisitedIds list
239
+ alreadyVisitedIds.push(id);
240
+ template.dependencies.forEach(dependencyId => {
241
+ // Remove dependency from list of templates to visit in the top-level loop
242
+ const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
243
+ if (iDependencyTemplate >= 0) {
244
+ templateItemIds.splice(iDependencyTemplate, 1);
245
+ }
246
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
247
+ });
248
+ }
249
+ accumulatedHierarchy.push(templateEntry);
250
+ }
251
+ }
252
+ // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
253
+ let templateItemIds = _getTopLevelItemIds(templates);
254
+ const otherItems = templates
255
+ .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
256
+ .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
257
+ templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));
258
+ // Step through the list of nodes; we'll also remove nodes as we visit them
259
+ let itemId = templateItemIds.shift();
260
+ while (typeof itemId !== "undefined") {
261
+ traceItemId(itemId, hierarchy);
262
+ itemId = templateItemIds.shift();
263
+ }
264
+ return hierarchy;
265
+ }
266
+ // ------------------------------------------------------------------------------------------------------------------ //
267
+ /**
268
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
269
+ *
270
+ * @param templates Array of templates from a Solution
271
+ * @return List of top-level item ids
272
+ */
273
+ function _getTopLevelItemIds(templates) {
274
+ // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
275
+ const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });
276
+ templates.forEach(function (template) {
277
+ (template.dependencies || []).forEach(function (dependencyId) {
278
+ const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
279
+ /* istanbul ignore else */
280
+ if (iNode >= 0) {
281
+ // Node is somebody's dependency, so remove the node from the list of top-level nodes
282
+ // If iNode == -1, then it's a shared dependency and it has already been removed
283
+ topLevelItemCandidateIds.splice(iNode, 1);
284
+ }
285
+ });
286
+ });
287
+ return topLevelItemCandidateIds;
191
288
  }
192
289
 
290
+ exports._getTopLevelItemIds = _getTopLevelItemIds;
193
291
  exports.checkSolution = checkSolution;
194
292
  exports.compareItems = compareItems;
293
+ exports.getItemHierarchy = getItemHierarchy;
195
294
 
196
295
  Object.defineProperty(exports, '__esModule', { value: true });
197
296
 
198
- })));
297
+ }));
199
298
  //# sourceMappingURL=viewer.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.umd.js","sources":["../../src/viewer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Provides the access to the solution's contents.\r\n *\r\n * @module viewer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Checks a Solution.\r\n *\r\n * @param item Solution id\r\n * @param authentication Credentials for the request to AGO\r\n * @return List of results of checks of Solution\r\n */\r\nexport function checkSolution(\r\n itemId: string,\r\n authentication: common.UserSession = null\r\n): Promise<string[]> {\r\n const resultsHtml: string[] = [`Item ${itemId}`];\r\n let item: common.ICompleteItem;\r\n let isTemplate = true;\r\n let templateItems: common.IItemTemplate[];\r\n let templateItemIds: string[];\r\n\r\n let currentAction: string = \" while getting complete item\";\r\n return (\r\n common\r\n .getCompleteItem(itemId, authentication)\r\n\r\n // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//\r\n .then((results: common.ICompleteItem) => {\r\n currentAction = \"\";\r\n item = results;\r\n\r\n if (!item) {\r\n throw new Error(`item is not found`);\r\n } else if (item.base.type !== \"Solution\") {\r\n throw new Error(`item is not a Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Template\")) {\r\n resultsHtml.push(`&#x2714; item is a Template Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Deployed\")) {\r\n isTemplate = false;\r\n resultsHtml.push(`&#x2714; item is a Deployed Solution`);\r\n } else {\r\n throw new Error(\r\n `item is neither a Template Solution nor a Deployed Solution`\r\n );\r\n }\r\n\r\n // base: IItem; text/plain JSON\r\n // data: File; */*\r\n // thumbnail: File; image/*\r\n // metadata: File; application/xml\r\n // resources: File[]; list of */*\r\n // fwdRelatedItems: IRelatedItems[]; list of forward relationshipType/relatedItems[] pairs\r\n // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs\r\n return common.blobToJson(item.data);\r\n })\r\n\r\n // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//\r\n .then(itemDataJson => {\r\n templateItems = itemDataJson?.templates;\r\n /* istanbul ignore else */\r\n if (!templateItems || templateItems.length === 0) {\r\n throw new Error(\r\n `Solution's data are not valid JSON or the Solution contains no items`\r\n );\r\n }\r\n\r\n templateItemIds = templateItems\r\n .map((template: common.IItemTemplate) => template.itemId)\r\n .sort();\r\n\r\n if (!isTemplate) {\r\n // Make sure that there's a Solution2Item relationship to each deployed item\r\n const fwdRelatedItemIds = item.fwdRelatedItems\r\n .filter(\r\n relationshipSet =>\r\n relationshipSet.relationshipType === \"Solution2Item\"\r\n )\r\n .reduce(\r\n (flatSet, relationshipSet) =>\r\n flatSet.concat(relationshipSet.relatedItemIds),\r\n []\r\n )\r\n .sort();\r\n if (templateItemIds.length < fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)\"\r\n );\r\n } else if (templateItemIds.length > fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; missing forward Solution2Item relationship(s)\"\r\n );\r\n } else if (\r\n JSON.stringify(templateItemIds) !==\r\n JSON.stringify(fwdRelatedItemIds)\r\n ) {\r\n resultsHtml.push(\r\n \"&#x2716; mismatching forward Solution2Item relationship(s)\"\r\n );\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2714; matching forward Solution2Item relationship(s)\"\r\n );\r\n }\r\n }\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Check that all dependency references are items in Solution -------------------------------------------//\r\n .then(() => {\r\n const dependencyIds = templateItems\r\n .reduce(\r\n (flatSet, template) => flatSet.concat(template.dependencies),\r\n []\r\n )\r\n .reduce((noDupSet, dependency) => {\r\n /* istanbul ignore else */\r\n if (!noDupSet.includes(dependency)) noDupSet.push(dependency);\r\n return noDupSet;\r\n }, [])\r\n .sort();\r\n\r\n const missingItems = dependencyIds.filter(\r\n (dependencyId: string) => !templateItemIds.includes(dependencyId)\r\n );\r\n\r\n if (missingItems.length === 0) {\r\n resultsHtml.push(\"&#x2714; all dependencies are in Solution\");\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2716; dependencies that aren't in Solution: \" +\r\n JSON.stringify(missingItems)\r\n );\r\n }\r\n\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Done -------------------------------------------------------------------------------------------------//\r\n .then(() => {\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Fatal error ------------------------------------------------------------------------------------------//\r\n .catch(error => {\r\n resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);\r\n return resultsHtml;\r\n })\r\n );\r\n}\r\n\r\n/**\r\n * Compares two AGO items, fetching them if only their id is supplied.\r\n *\r\n * @param item1 First item or its AGO id\r\n * @param item2 Second item or its AGO id\r\n * @param authentication Credentials for the request to AGO\r\n * @return True if objects are the same\r\n * @see Only comparable properties are compared; see deleteItemProps() in the `common` package\r\n */\r\nexport function compareItems(\r\n item1: string | any,\r\n item2: string | any,\r\n authentication: common.UserSession = null\r\n): Promise<boolean> {\r\n return new Promise<boolean>((resolve, reject) => {\r\n // If an input is a string, fetch the item; otherwise, clone the input because we will modify the\r\n // item base to remove incomparable properties\r\n let itemBaseDef1: Promise<any>;\r\n if (typeof item1 === \"string\") {\r\n itemBaseDef1 = common.getItemBase(item1, authentication);\r\n } else {\r\n itemBaseDef1 = Promise.resolve(common.cloneObject(item1));\r\n }\r\n\r\n let itemBaseDef2: Promise<any>;\r\n if (typeof item2 === \"string\") {\r\n itemBaseDef2 = common.getItemBase(item2, authentication);\r\n } else {\r\n itemBaseDef2 = Promise.resolve(common.cloneObject(item2));\r\n }\r\n\r\n Promise.all([itemBaseDef1, itemBaseDef2]).then(\r\n responses => {\r\n const [itemBase1, itemBase2] = responses;\r\n\r\n common.deleteItemProps(itemBase1);\r\n common.deleteItemProps(itemBase2);\r\n\r\n if (itemBase1.type === \"Solution\") {\r\n delete itemBase1.typeKeywords;\r\n delete itemBase1.size;\r\n delete itemBase2.typeKeywords;\r\n delete itemBase2.size;\r\n }\r\n\r\n /*console.log(\"----------------------------------------------------------------\");\r\n console.log(\"item 1 \" + item1 + \": \", JSON.stringify(itemBase1, null, 2));\r\n console.log(\"item 2 \" + item2 + \": \", JSON.stringify(itemBase2, null, 2));\r\n console.log(\"----------------------------------------------------------------\");*/\r\n\r\n resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));\r\n },\r\n e => reject(e)\r\n );\r\n });\r\n}\r\n"],"names":["common\r\n .getCompleteItem","common.blobToJson","common.getItemBase","common.cloneObject","common.deleteItemProps","common.compareJSONNoEmptyStrings"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAwBA;EAEA;;;;;;;WAOgB,aAAa,CAC3B,MAAc,EACd,iBAAqC,IAAI;MAEzC,MAAM,WAAW,GAAa,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC;MACjD,IAAI,IAA0B,CAAC;MAC/B,IAAI,UAAU,GAAG,IAAI,CAAC;MACtB,IAAI,aAAqC,CAAC;MAC1C,IAAI,eAAyB,CAAC;MAE9B,IAAI,aAAa,GAAW,8BAA8B,CAAC;MAC3D,QACEA,sBACkB,CAAC,MAAM,EAAE,cAAc,CAAC;;WAGvC,IAAI,CAAC,CAAC,OAA6B;UAClC,aAAa,GAAG,EAAE,CAAC;UACnB,IAAI,GAAG,OAAO,CAAC;UAEf,IAAI,CAAC,IAAI,EAAE;cACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;WACtC;eAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;cACxC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;WAC3C;eAAM,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,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ewer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Provides the access to the solution's contents.\r\n *\r\n * @module viewer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Checks a Solution.\r\n *\r\n * @param item Solution id\r\n * @param authentication Credentials for the request to AGO\r\n * @return List of results of checks of Solution\r\n */\r\nexport function checkSolution(\r\n itemId: string,\r\n authentication: common.UserSession = null\r\n): Promise<string[]> {\r\n const resultsHtml: string[] = [`Item ${itemId}`];\r\n let item: common.ICompleteItem;\r\n let isTemplate = true;\r\n let templateItems: common.IItemTemplate[];\r\n let templateItemIds: string[];\r\n\r\n let currentAction: string = \" while getting complete item\";\r\n return (\r\n common\r\n .getCompleteItem(itemId, authentication)\r\n\r\n // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//\r\n .then((results: common.ICompleteItem) => {\r\n currentAction = \"\";\r\n item = results;\r\n\r\n if (!item) {\r\n throw new Error(`item is not found`);\r\n } else if (item.base.type !== \"Solution\") {\r\n throw new Error(`item is not a Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Template\")) {\r\n resultsHtml.push(`&#x2714; item is a Template Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Deployed\")) {\r\n isTemplate = false;\r\n resultsHtml.push(`&#x2714; item is a Deployed Solution`);\r\n } else {\r\n throw new Error(\r\n `item is neither a Template Solution nor a Deployed Solution`\r\n );\r\n }\r\n\r\n // base: IItem; text/plain JSON\r\n // data: File; */*\r\n // thumbnail: File; image/*\r\n // metadata: File; application/xml\r\n // resources: File[]; list of */*\r\n // fwdRelatedItems: IRelatedItems[]; list of forward relationshipType/relatedItems[] pairs\r\n // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs\r\n return common.blobToJson(item.data);\r\n })\r\n\r\n // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//\r\n .then(itemDataJson => {\r\n templateItems = itemDataJson?.templates;\r\n /* istanbul ignore else */\r\n if (!templateItems || templateItems.length === 0) {\r\n throw new Error(\r\n `Solution's data are not valid JSON or the Solution contains no items`\r\n );\r\n }\r\n\r\n templateItemIds = templateItems\r\n .map((template: common.IItemTemplate) => template.itemId)\r\n .sort();\r\n\r\n if (!isTemplate) {\r\n // Make sure that there's a Solution2Item relationship to each deployed item\r\n const fwdRelatedItemIds = item.fwdRelatedItems\r\n .filter(\r\n relationshipSet =>\r\n relationshipSet.relationshipType === \"Solution2Item\"\r\n )\r\n .reduce(\r\n (flatSet, relationshipSet) =>\r\n flatSet.concat(relationshipSet.relatedItemIds),\r\n []\r\n )\r\n .sort();\r\n if (templateItemIds.length < fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)\"\r\n );\r\n } else if (templateItemIds.length > fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; missing forward Solution2Item relationship(s)\"\r\n );\r\n } else if (\r\n JSON.stringify(templateItemIds) !==\r\n JSON.stringify(fwdRelatedItemIds)\r\n ) {\r\n resultsHtml.push(\r\n \"&#x2716; mismatching forward Solution2Item relationship(s)\"\r\n );\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2714; matching forward Solution2Item relationship(s)\"\r\n );\r\n }\r\n }\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Check that all dependency references are items in Solution ---------------------------------------//\r\n .then(() => {\r\n const dependencyIds = templateItems\r\n .reduce(\r\n (flatSet, template) => flatSet.concat(template.dependencies),\r\n []\r\n )\r\n .reduce((noDupSet, dependency) => {\r\n /* istanbul ignore else */\r\n if (!noDupSet.includes(dependency)) noDupSet.push(dependency);\r\n return noDupSet;\r\n }, [])\r\n .sort();\r\n\r\n const missingItems = dependencyIds.filter(\r\n (dependencyId: string) => !templateItemIds.includes(dependencyId)\r\n );\r\n\r\n if (missingItems.length === 0) {\r\n resultsHtml.push(\"&#x2714; all dependencies are in Solution\");\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2716; dependencies that aren't in Solution: \" +\r\n JSON.stringify(missingItems)\r\n );\r\n }\r\n\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Done ---------------------------------------------------------------------------------------------//\r\n .then(() => {\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Fatal error --------------------------------------------------------------------------------------//\r\n .catch(error => {\r\n resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);\r\n return resultsHtml;\r\n })\r\n );\r\n}\r\n\r\n/**\r\n * Compares two AGO items, fetching them if only their id is supplied.\r\n *\r\n * @param item1 First item or its AGO id\r\n * @param item2 Second item or its AGO id\r\n * @param authentication Credentials for the request to AGO\r\n * @return True if objects are the same\r\n * @see Only comparable properties are compared; see deleteItemProps() in the `common` package\r\n */\r\nexport function compareItems(\r\n item1: string | any,\r\n item2: string | any,\r\n authentication: common.UserSession = null\r\n): Promise<boolean> {\r\n return new Promise<boolean>((resolve, reject) => {\r\n // If an input is a string, fetch the item; otherwise, clone the input because we will modify the\r\n // item base to remove incomparable properties\r\n let itemBaseDef1: Promise<any>;\r\n if (typeof item1 === \"string\") {\r\n itemBaseDef1 = common.getItemBase(item1, authentication);\r\n } else {\r\n itemBaseDef1 = Promise.resolve(common.cloneObject(item1));\r\n }\r\n\r\n let itemBaseDef2: Promise<any>;\r\n if (typeof item2 === \"string\") {\r\n itemBaseDef2 = common.getItemBase(item2, authentication);\r\n } else {\r\n itemBaseDef2 = Promise.resolve(common.cloneObject(item2));\r\n }\r\n\r\n Promise.all([itemBaseDef1, itemBaseDef2]).then(\r\n responses => {\r\n const [itemBase1, itemBase2] = responses;\r\n\r\n common.deleteItemProps(itemBase1);\r\n common.deleteItemProps(itemBase2);\r\n\r\n if (itemBase1.type === \"Solution\") {\r\n delete itemBase1.typeKeywords;\r\n delete itemBase1.size;\r\n delete itemBase2.typeKeywords;\r\n delete itemBase2.size;\r\n }\r\n\r\n /*console.log(\"----------------------------------------------------------------\");\r\n console.log(\"item 1 \" + item1 + \": \", JSON.stringify(itemBase1, null, 2));\r\n console.log(\"item 2 \" + item2 + \": \", JSON.stringify(itemBase2, null, 2));\r\n console.log(\"----------------------------------------------------------------\");*/\r\n\r\n resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));\r\n },\r\n e => reject(e)\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Creates a hierarchy of the items in a Solution template.\r\n *\r\n * @param templates Array of templates from a Solution\r\n * @return List of top-level items, each containing a recursive list of its dependencies\r\n */\r\nexport function getItemHierarchy(\r\n templates: common.IItemTemplate[]\r\n): common.IHierarchyElement[] {\r\n const hierarchy = [] as common.IHierarchyElement[];\r\n\r\n // Get the template specified by id out of a list of templates\r\n function getTemplateInSolution(templates: common.IItemTemplate[], id: string): common.IItemTemplate {\r\n const iTemplate = templates.findIndex((template) => id === template.itemId);\r\n return iTemplate >= 0 ? templates[iTemplate] : null;\r\n }\r\n\r\n // Hierarchically list the dependencies of specified node\r\n function traceItemId(id: string, accumulatedHierarchy: common.IHierarchyElement[], alreadyVisitedIds: string[] = []) {\r\n // Get the dependencies of the node\r\n const template = getTemplateInSolution(templates, id);\r\n /* istanbul ignore else */\r\n if (template) {\r\n const templateEntry = {\r\n id,\r\n dependencies: [] as common.IHierarchyElement[]\r\n };\r\n\r\n // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops\r\n if (alreadyVisitedIds.indexOf(id) < 0) {\r\n // Add dependency to alreadyVisitedIds list\r\n alreadyVisitedIds.push(id);\r\n\r\n template.dependencies.forEach(\r\n dependencyId => {\r\n // Remove dependency from list of templates to visit in the top-level loop\r\n const iDependencyTemplate = templateItemIds.indexOf(dependencyId);\r\n if (iDependencyTemplate >= 0) {\r\n templateItemIds.splice(iDependencyTemplate, 1);\r\n }\r\n\r\n traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);\r\n }\r\n );\r\n }\r\n accumulatedHierarchy.push(templateEntry);\r\n }\r\n }\r\n\r\n // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes\r\n let templateItemIds: string[] = _getTopLevelItemIds(templates);\r\n\r\n const otherItems: common.IItemTemplate[] = templates\r\n .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes\r\n .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs\r\n\r\n templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));\r\n\r\n // Step through the list of nodes; we'll also remove nodes as we visit them\r\n let itemId = templateItemIds.shift();\r\n while (typeof itemId !== \"undefined\") {\r\n traceItemId(itemId, hierarchy);\r\n itemId = templateItemIds.shift();\r\n }\r\n\r\n return hierarchy;\r\n}\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.\r\n *\r\n * @param templates Array of templates from a Solution\r\n * @return List of top-level item ids\r\n */\r\nexport function _getTopLevelItemIds(\r\n templates: common.IItemTemplate[]\r\n): string[] {\r\n // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on\r\n const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });\r\n\r\n templates.forEach(function (template) {\r\n (template.dependencies || []).forEach(function (dependencyId) {\r\n const iNode = topLevelItemCandidateIds.indexOf(dependencyId);\r\n\r\n /* istanbul ignore else */\r\n if (iNode >= 0) {\r\n // Node is somebody's dependency, so remove the node from the list of top-level nodes\r\n // If iNode == -1, then it's a shared dependency and it has already been removed\r\n topLevelItemCandidateIds.splice(iNode, 1);\r\n }\r\n });\r\n });\r\n\r\n return topLevelItemCandidateIds;\r\n};\r\n"],"names":["common"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAwBA;EAEA;;;;;;;WAOgB,aAAa,CAC3B,MAAc,EACd,iBAAqC,IAAI;MAEzC,MAAM,WAAW,GAAa,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC;MACjD,IAAI,IAA0B,CAAC;MAC/B,IAAI,UAAU,GAAG,IAAI,CAAC;MACtB,IAAI,aAAqC,CAAC;MAC1C,IAAI,eAAyB,CAAC;MAE9B,IAAI,aAAa,GAAW,8BAA8B,CAAC;MAC3D,QACEA,iBAAM;WACH,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC;;WAGvC,IAAI,CAAC,CAAC,OAA6B;UAClC,aAAa,GAAG,EAAE,CAAC;UACnB,IAAI,GAAG,OAAO,CAAC;UAEf,IAAI,CAAC,IAAI,EAAE;cACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;WACtC;eAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;cACxC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;WAC3C;eAAM,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;cACtD,WAAW,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;WAC1D;eAAM,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;cACtD,UAAU,GAAG,KAAK,CAAC;cACnB,WAAW,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;WAC1D;eAAM;cACL,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;WACH;;;;;;;;UASD,OAAOA,iBAAM,CAAC,UAAU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e,CAAC,KAAK,EAAE,CAAC;MACrC,OAAO,OAAO,MAAM,KAAK,WAAW,EAAE;UACpC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;UAC/B,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC;OAClC;MAED,OAAO,SAAS,CAAC;EACnB,CAAC;EAED;EAEA;;;;;;WAMgB,mBAAmB,CACjC,SAAiC;;MAGjC,MAAM,wBAAwB,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;MAEhG,SAAS,CAAC,OAAO,CAAC,UAAU,QAAQ;UAClC,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,EAAE,OAAO,CAAC,UAAU,YAAY;cAC1D,MAAM,KAAK,GAAG,wBAAwB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;;cAG7D,IAAI,KAAK,IAAI,CAAC,EAAE;;;kBAGd,wBAAwB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;eAC3C;WACF,CAAC,CAAC;OACJ,CAAC,CAAC;MAEH,OAAO,wBAAwB,CAAC;EAClC;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-viewer - v1.1.3 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Mon Oct 18 2021 09:03:03 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-viewer - v1.3.0 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 09:44:10 GMT-0800 (Pacific Standard 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.
@@ -15,5 +15,5 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e=e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";e.checkSolution=function(e,o=null){const n=[`Item ${e}`];let i,s,r,l=!0,u=" while getting complete item";return t.getCompleteItem(e,o).then((e=>{if(u="",i=e,!i)throw new Error("item is not found");if("Solution"!==i.base.type)throw new Error("item is not a Solution");if(i.base.typeKeywords.includes("Template"))n.push("&#x2714; item is a Template Solution");else{if(!i.base.typeKeywords.includes("Deployed"))throw new Error("item is neither a Template Solution nor a Deployed Solution");l=!1,n.push("&#x2714; item is a Deployed Solution")}return t.blobToJson(i.data)})).then((e=>{if(s=e?.templates,!s||0===s.length)throw new Error("Solution's data are not valid JSON or the Solution contains no items");if(r=s.map((e=>e.itemId)).sort(),!l){const e=i.fwdRelatedItems.filter((e=>"Solution2Item"===e.relationshipType)).reduce(((e,t)=>e.concat(t.relatedItemIds)),[]).sort();r.length<e.length?n.push("&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)"):r.length>e.length?n.push("&#x2716; missing forward Solution2Item relationship(s)"):JSON.stringify(r)!==JSON.stringify(e)?n.push("&#x2716; mismatching forward Solution2Item relationship(s)"):n.push("&#x2714; matching forward Solution2Item relationship(s)")}return n})).then((()=>{const e=s.reduce(((e,t)=>e.concat(t.dependencies)),[]).reduce(((e,t)=>(e.includes(t)||e.push(t),e)),[]).sort().filter((e=>!r.includes(e)));return 0===e.length?n.push("&#x2714; all dependencies are in Solution"):n.push("&#x2716; dependencies that aren't in Solution: "+JSON.stringify(e)),n})).then((()=>n)).catch((e=>(n.push(`&#x2716; error${u}: ${e.message}`),n)))},e.compareItems=function(e,o,n=null){return new Promise(((i,s)=>{let r,l;r="string"==typeof e?t.getItemBase(e,n):Promise.resolve(t.cloneObject(e)),l="string"==typeof o?t.getItemBase(o,n):Promise.resolve(t.cloneObject(o)),Promise.all([r,l]).then((e=>{const[o,n]=e;t.deleteItemProps(o),t.deleteItemProps(n),"Solution"===o.type&&(delete o.typeKeywords,delete o.size,delete n.typeKeywords,delete n.size),i(t.compareJSONNoEmptyStrings(o,n))}),(e=>s(e)))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
18
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var o=n(t);function i(e){const t=e.map((function(e){return e.itemId}));return e.forEach((function(e){(e.dependencies||[]).forEach((function(e){const n=t.indexOf(e);n>=0&&t.splice(n,1)}))})),t}e._getTopLevelItemIds=i,e.checkSolution=function(e,t=null){const n=[`Item ${e}`];let i,r,s,l=!0,c=" while getting complete item";return o.getCompleteItem(e,t).then((e=>{if(c="",i=e,!i)throw new Error("item is not found");if("Solution"!==i.base.type)throw new Error("item is not a Solution");if(i.base.typeKeywords.includes("Template"))n.push("&#x2714; item is a Template Solution");else{if(!i.base.typeKeywords.includes("Deployed"))throw new Error("item is neither a Template Solution nor a Deployed Solution");l=!1,n.push("&#x2714; item is a Deployed Solution")}return o.blobToJson(i.data)})).then((e=>{if(r=e?.templates,!r||0===r.length)throw new Error("Solution's data are not valid JSON or the Solution contains no items");if(s=r.map((e=>e.itemId)).sort(),!l){const e=i.fwdRelatedItems.filter((e=>"Solution2Item"===e.relationshipType)).reduce(((e,t)=>e.concat(t.relatedItemIds)),[]).sort();s.length<e.length?n.push("&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)"):s.length>e.length?n.push("&#x2716; missing forward Solution2Item relationship(s)"):JSON.stringify(s)!==JSON.stringify(e)?n.push("&#x2716; mismatching forward Solution2Item relationship(s)"):n.push("&#x2714; matching forward Solution2Item relationship(s)")}return n})).then((()=>{const e=r.reduce(((e,t)=>e.concat(t.dependencies)),[]).reduce(((e,t)=>(e.includes(t)||e.push(t),e)),[]).sort().filter((e=>!s.includes(e)));return 0===e.length?n.push("&#x2714; all dependencies are in Solution"):n.push("&#x2716; dependencies that aren't in Solution: "+JSON.stringify(e)),n})).then((()=>n)).catch((e=>(n.push(`&#x2716; error${c}: ${e.message}`),n)))},e.compareItems=function(e,t,n=null){return new Promise(((i,r)=>{let s,l;s="string"==typeof e?o.getItemBase(e,n):Promise.resolve(o.cloneObject(e)),l="string"==typeof t?o.getItemBase(t,n):Promise.resolve(o.cloneObject(t)),Promise.all([s,l]).then((e=>{const[t,n]=e;o.deleteItemProps(t),o.deleteItemProps(n),"Solution"===t.type&&(delete t.typeKeywords,delete t.size,delete n.typeKeywords,delete n.size),i(o.compareJSONNoEmptyStrings(t,n))}),(e=>r(e)))}))},e.getItemHierarchy=function(e){const t=[];function n(t,i,r=[]){const s=function(e,t){const n=e.findIndex((e=>t===e.itemId));return n>=0?e[n]:null}(e,t);if(s){const e={id:t,dependencies:[]};r.indexOf(t)<0&&(r.push(t),s.dependencies.forEach((t=>{const i=o.indexOf(t);i>=0&&o.splice(i,1),n(t,e.dependencies,r)}))),i.push(e)}}let o=i(e);const r=e.filter((e=>o.indexOf(e.itemId)<0)).sort(((e,t)=>t.dependencies.length-e.dependencies.length));o=o.concat(r.map((e=>e.itemId)));let s=o.shift();for(;void 0!==s;)n(s,t),s=o.shift();return t},Object.defineProperty(e,"__esModule",{value:!0})}));
19
19
  //# sourceMappingURL=viewer.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.umd.min.js","sources":["../../src/viewer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Provides the access to the solution's contents.\r\n *\r\n * @module viewer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Checks a Solution.\r\n *\r\n * @param item Solution id\r\n * @param authentication Credentials for the request to AGO\r\n * @return List of results of checks of Solution\r\n */\r\nexport function checkSolution(\r\n itemId: string,\r\n authentication: common.UserSession = null\r\n): Promise<string[]> {\r\n const resultsHtml: string[] = [`Item ${itemId}`];\r\n let item: common.ICompleteItem;\r\n let isTemplate = true;\r\n let templateItems: common.IItemTemplate[];\r\n let templateItemIds: string[];\r\n\r\n let currentAction: string = \" while getting complete item\";\r\n return (\r\n common\r\n .getCompleteItem(itemId, authentication)\r\n\r\n // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//\r\n .then((results: common.ICompleteItem) => {\r\n currentAction = \"\";\r\n item = results;\r\n\r\n if (!item) {\r\n throw new Error(`item is not found`);\r\n } else if (item.base.type !== \"Solution\") {\r\n throw new Error(`item is not a Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Template\")) {\r\n resultsHtml.push(`&#x2714; item is a Template Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Deployed\")) {\r\n isTemplate = false;\r\n resultsHtml.push(`&#x2714; item is a Deployed Solution`);\r\n } else {\r\n throw new Error(\r\n `item is neither a Template Solution nor a Deployed Solution`\r\n );\r\n }\r\n\r\n // base: IItem; text/plain JSON\r\n // data: File; */*\r\n // thumbnail: File; image/*\r\n // metadata: File; application/xml\r\n // resources: File[]; list of */*\r\n // fwdRelatedItems: IRelatedItems[]; list of forward relationshipType/relatedItems[] pairs\r\n // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs\r\n return common.blobToJson(item.data);\r\n })\r\n\r\n // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//\r\n .then(itemDataJson => {\r\n templateItems = itemDataJson?.templates;\r\n /* istanbul ignore else */\r\n if (!templateItems || templateItems.length === 0) {\r\n throw new Error(\r\n `Solution's data are not valid JSON or the Solution contains no items`\r\n );\r\n }\r\n\r\n templateItemIds = templateItems\r\n .map((template: common.IItemTemplate) => template.itemId)\r\n .sort();\r\n\r\n if (!isTemplate) {\r\n // Make sure that there's a Solution2Item relationship to each deployed item\r\n const fwdRelatedItemIds = item.fwdRelatedItems\r\n .filter(\r\n relationshipSet =>\r\n relationshipSet.relationshipType === \"Solution2Item\"\r\n )\r\n .reduce(\r\n (flatSet, relationshipSet) =>\r\n flatSet.concat(relationshipSet.relatedItemIds),\r\n []\r\n )\r\n .sort();\r\n if (templateItemIds.length < fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)\"\r\n );\r\n } else if (templateItemIds.length > fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; missing forward Solution2Item relationship(s)\"\r\n );\r\n } else if (\r\n JSON.stringify(templateItemIds) !==\r\n JSON.stringify(fwdRelatedItemIds)\r\n ) {\r\n resultsHtml.push(\r\n \"&#x2716; mismatching forward Solution2Item relationship(s)\"\r\n );\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2714; matching forward Solution2Item relationship(s)\"\r\n );\r\n }\r\n }\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Check that all dependency references are items in Solution -------------------------------------------//\r\n .then(() => {\r\n const dependencyIds = templateItems\r\n .reduce(\r\n (flatSet, template) => flatSet.concat(template.dependencies),\r\n []\r\n )\r\n .reduce((noDupSet, dependency) => {\r\n /* istanbul ignore else */\r\n if (!noDupSet.includes(dependency)) noDupSet.push(dependency);\r\n return noDupSet;\r\n }, [])\r\n .sort();\r\n\r\n const missingItems = dependencyIds.filter(\r\n (dependencyId: string) => !templateItemIds.includes(dependencyId)\r\n );\r\n\r\n if (missingItems.length === 0) {\r\n resultsHtml.push(\"&#x2714; all dependencies are in Solution\");\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2716; dependencies that aren't in Solution: \" +\r\n JSON.stringify(missingItems)\r\n );\r\n }\r\n\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Done -------------------------------------------------------------------------------------------------//\r\n .then(() => {\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Fatal error ------------------------------------------------------------------------------------------//\r\n .catch(error => {\r\n resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);\r\n return resultsHtml;\r\n })\r\n );\r\n}\r\n\r\n/**\r\n * Compares two AGO items, fetching them if only their id is supplied.\r\n *\r\n * @param item1 First item or its AGO id\r\n * @param item2 Second item or its AGO id\r\n * @param authentication Credentials for the request to AGO\r\n * @return True if objects are the same\r\n * @see Only comparable properties are compared; see deleteItemProps() in the `common` package\r\n */\r\nexport function compareItems(\r\n item1: string | any,\r\n item2: string | any,\r\n authentication: common.UserSession = null\r\n): Promise<boolean> {\r\n return new Promise<boolean>((resolve, reject) => {\r\n // If an input is a string, fetch the item; otherwise, clone the input because we will modify the\r\n // item base to remove incomparable properties\r\n let itemBaseDef1: Promise<any>;\r\n if (typeof item1 === \"string\") {\r\n itemBaseDef1 = common.getItemBase(item1, authentication);\r\n } else {\r\n itemBaseDef1 = Promise.resolve(common.cloneObject(item1));\r\n }\r\n\r\n let itemBaseDef2: Promise<any>;\r\n if (typeof item2 === \"string\") {\r\n itemBaseDef2 = common.getItemBase(item2, authentication);\r\n } else {\r\n itemBaseDef2 = Promise.resolve(common.cloneObject(item2));\r\n }\r\n\r\n Promise.all([itemBaseDef1, itemBaseDef2]).then(\r\n responses => {\r\n const [itemBase1, itemBase2] = responses;\r\n\r\n common.deleteItemProps(itemBase1);\r\n common.deleteItemProps(itemBase2);\r\n\r\n if (itemBase1.type === \"Solution\") {\r\n delete itemBase1.typeKeywords;\r\n delete itemBase1.size;\r\n delete itemBase2.typeKeywords;\r\n delete itemBase2.size;\r\n }\r\n\r\n /*console.log(\"----------------------------------------------------------------\");\r\n console.log(\"item 1 \" + item1 + \": \", JSON.stringify(itemBase1, null, 2));\r\n console.log(\"item 2 \" + item2 + \": \", JSON.stringify(itemBase2, null, 2));\r\n console.log(\"----------------------------------------------------------------\");*/\r\n\r\n resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));\r\n },\r\n e => reject(e)\r\n );\r\n });\r\n}\r\n"],"names":["itemId","authentication","resultsHtml","item","templateItems","templateItemIds","isTemplate","currentAction","common\r\n .getCompleteItem","then","results","Error","base","type","typeKeywords","includes","push","common.blobToJson","data","itemDataJson","templates","length","map","template","sort","fwdRelatedItemIds","fwdRelatedItems","filter","relationshipSet","relationshipType","reduce","flatSet","concat","relatedItemIds","JSON","stringify","missingItems","dependencies","noDupSet","dependency","dependencyId","catch","error","message","item1","item2","Promise","resolve","reject","itemBaseDef1","itemBaseDef2","common.getItemBase","common.cloneObject","all","responses","itemBase1","itemBase2","common.deleteItemProps","size","common.compareJSONNoEmptyStrings","e"],"mappings":";;;;;;;;;;;;;;;;;mUAkCEA,EACAC,EAAqC,MAErC,MAAMC,EAAwB,CAAC,QAAQF,KACvC,IAAIG,EAEAC,EACAC,EAFAC,GAAa,EAIbC,EAAwB,+BAC5B,OACEC,kBACmBR,EAAQC,GAGxBQ,MAAMC,IAIL,GAHAH,EAAgB,GAChBJ,EAAOO,GAEFP,EACH,MAAM,IAAIQ,MAAM,qBACX,GAAuB,aAAnBR,EAAKS,KAAKC,KACnB,MAAM,IAAIF,MAAM,0BACX,GAAIR,EAAKS,KAAKE,aAAaC,SAAS,YACzCb,EAAYc,KAAK,4CACZ,CAAA,IAAIb,EAAKS,KAAKE,aAAaC,SAAS,YAIzC,MAAM,IAAIJ,MACR,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5C,GAE1B6C,QAAQC,QAAQK,cAAmBP,IAGpDC,QAAQO,IAAI,CAACJ,EAAcC,IAAezC,MACxC6C,IACE,MAAOC,EAAWC,GAAaF,EAE/BG,kBAAuBF,GACvBE,kBAAuBD,GAEA,aAAnBD,EAAU1C,cACL0C,EAAUzC,oBACVyC,EAAUG,YACVF,EAAU1C,oBACV0C,EAAUE,MAQnBX,EAAQY,4BAAiCJ,EAAWC,OAEtDI,GAAKZ,EAAOY"}
1
+ {"version":3,"file":"viewer.umd.min.js","sources":["../../src/viewer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Provides the access to the solution's contents.\r\n *\r\n * @module viewer\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Checks a Solution.\r\n *\r\n * @param item Solution id\r\n * @param authentication Credentials for the request to AGO\r\n * @return List of results of checks of Solution\r\n */\r\nexport function checkSolution(\r\n itemId: string,\r\n authentication: common.UserSession = null\r\n): Promise<string[]> {\r\n const resultsHtml: string[] = [`Item ${itemId}`];\r\n let item: common.ICompleteItem;\r\n let isTemplate = true;\r\n let templateItems: common.IItemTemplate[];\r\n let templateItemIds: string[];\r\n\r\n let currentAction: string = \" while getting complete item\";\r\n return (\r\n common\r\n .getCompleteItem(itemId, authentication)\r\n\r\n // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//\r\n .then((results: common.ICompleteItem) => {\r\n currentAction = \"\";\r\n item = results;\r\n\r\n if (!item) {\r\n throw new Error(`item is not found`);\r\n } else if (item.base.type !== \"Solution\") {\r\n throw new Error(`item is not a Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Template\")) {\r\n resultsHtml.push(`&#x2714; item is a Template Solution`);\r\n } else if (item.base.typeKeywords.includes(\"Deployed\")) {\r\n isTemplate = false;\r\n resultsHtml.push(`&#x2714; item is a Deployed Solution`);\r\n } else {\r\n throw new Error(\r\n `item is neither a Template Solution nor a Deployed Solution`\r\n );\r\n }\r\n\r\n // base: IItem; text/plain JSON\r\n // data: File; */*\r\n // thumbnail: File; image/*\r\n // metadata: File; application/xml\r\n // resources: File[]; list of */*\r\n // fwdRelatedItems: IRelatedItems[]; list of forward relationshipType/relatedItems[] pairs\r\n // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs\r\n return common.blobToJson(item.data);\r\n })\r\n\r\n // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//\r\n .then(itemDataJson => {\r\n templateItems = itemDataJson?.templates;\r\n /* istanbul ignore else */\r\n if (!templateItems || templateItems.length === 0) {\r\n throw new Error(\r\n `Solution's data are not valid JSON or the Solution contains no items`\r\n );\r\n }\r\n\r\n templateItemIds = templateItems\r\n .map((template: common.IItemTemplate) => template.itemId)\r\n .sort();\r\n\r\n if (!isTemplate) {\r\n // Make sure that there's a Solution2Item relationship to each deployed item\r\n const fwdRelatedItemIds = item.fwdRelatedItems\r\n .filter(\r\n relationshipSet =>\r\n relationshipSet.relationshipType === \"Solution2Item\"\r\n )\r\n .reduce(\r\n (flatSet, relationshipSet) =>\r\n flatSet.concat(relationshipSet.relatedItemIds),\r\n []\r\n )\r\n .sort();\r\n if (templateItemIds.length < fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)\"\r\n );\r\n } else if (templateItemIds.length > fwdRelatedItemIds.length) {\r\n resultsHtml.push(\r\n \"&#x2716; missing forward Solution2Item relationship(s)\"\r\n );\r\n } else if (\r\n JSON.stringify(templateItemIds) !==\r\n JSON.stringify(fwdRelatedItemIds)\r\n ) {\r\n resultsHtml.push(\r\n \"&#x2716; mismatching forward Solution2Item relationship(s)\"\r\n );\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2714; matching forward Solution2Item relationship(s)\"\r\n );\r\n }\r\n }\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Check that all dependency references are items in Solution ---------------------------------------//\r\n .then(() => {\r\n const dependencyIds = templateItems\r\n .reduce(\r\n (flatSet, template) => flatSet.concat(template.dependencies),\r\n []\r\n )\r\n .reduce((noDupSet, dependency) => {\r\n /* istanbul ignore else */\r\n if (!noDupSet.includes(dependency)) noDupSet.push(dependency);\r\n return noDupSet;\r\n }, [])\r\n .sort();\r\n\r\n const missingItems = dependencyIds.filter(\r\n (dependencyId: string) => !templateItemIds.includes(dependencyId)\r\n );\r\n\r\n if (missingItems.length === 0) {\r\n resultsHtml.push(\"&#x2714; all dependencies are in Solution\");\r\n } else {\r\n resultsHtml.push(\r\n \"&#x2716; dependencies that aren't in Solution: \" +\r\n JSON.stringify(missingItems)\r\n );\r\n }\r\n\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Done ---------------------------------------------------------------------------------------------//\r\n .then(() => {\r\n return resultsHtml;\r\n })\r\n\r\n // ---------- Fatal error --------------------------------------------------------------------------------------//\r\n .catch(error => {\r\n resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);\r\n return resultsHtml;\r\n })\r\n );\r\n}\r\n\r\n/**\r\n * Compares two AGO items, fetching them if only their id is supplied.\r\n *\r\n * @param item1 First item or its AGO id\r\n * @param item2 Second item or its AGO id\r\n * @param authentication Credentials for the request to AGO\r\n * @return True if objects are the same\r\n * @see Only comparable properties are compared; see deleteItemProps() in the `common` package\r\n */\r\nexport function compareItems(\r\n item1: string | any,\r\n item2: string | any,\r\n authentication: common.UserSession = null\r\n): Promise<boolean> {\r\n return new Promise<boolean>((resolve, reject) => {\r\n // If an input is a string, fetch the item; otherwise, clone the input because we will modify the\r\n // item base to remove incomparable properties\r\n let itemBaseDef1: Promise<any>;\r\n if (typeof item1 === \"string\") {\r\n itemBaseDef1 = common.getItemBase(item1, authentication);\r\n } else {\r\n itemBaseDef1 = Promise.resolve(common.cloneObject(item1));\r\n }\r\n\r\n let itemBaseDef2: Promise<any>;\r\n if (typeof item2 === \"string\") {\r\n itemBaseDef2 = common.getItemBase(item2, authentication);\r\n } else {\r\n itemBaseDef2 = Promise.resolve(common.cloneObject(item2));\r\n }\r\n\r\n Promise.all([itemBaseDef1, itemBaseDef2]).then(\r\n responses => {\r\n const [itemBase1, itemBase2] = responses;\r\n\r\n common.deleteItemProps(itemBase1);\r\n common.deleteItemProps(itemBase2);\r\n\r\n if (itemBase1.type === \"Solution\") {\r\n delete itemBase1.typeKeywords;\r\n delete itemBase1.size;\r\n delete itemBase2.typeKeywords;\r\n delete itemBase2.size;\r\n }\r\n\r\n /*console.log(\"----------------------------------------------------------------\");\r\n console.log(\"item 1 \" + item1 + \": \", JSON.stringify(itemBase1, null, 2));\r\n console.log(\"item 2 \" + item2 + \": \", JSON.stringify(itemBase2, null, 2));\r\n console.log(\"----------------------------------------------------------------\");*/\r\n\r\n resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));\r\n },\r\n e => reject(e)\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Creates a hierarchy of the items in a Solution template.\r\n *\r\n * @param templates Array of templates from a Solution\r\n * @return List of top-level items, each containing a recursive list of its dependencies\r\n */\r\nexport function getItemHierarchy(\r\n templates: common.IItemTemplate[]\r\n): common.IHierarchyElement[] {\r\n const hierarchy = [] as common.IHierarchyElement[];\r\n\r\n // Get the template specified by id out of a list of templates\r\n function getTemplateInSolution(templates: common.IItemTemplate[], id: string): common.IItemTemplate {\r\n const iTemplate = templates.findIndex((template) => id === template.itemId);\r\n return iTemplate >= 0 ? templates[iTemplate] : null;\r\n }\r\n\r\n // Hierarchically list the dependencies of specified node\r\n function traceItemId(id: string, accumulatedHierarchy: common.IHierarchyElement[], alreadyVisitedIds: string[] = []) {\r\n // Get the dependencies of the node\r\n const template = getTemplateInSolution(templates, id);\r\n /* istanbul ignore else */\r\n if (template) {\r\n const templateEntry = {\r\n id,\r\n dependencies: [] as common.IHierarchyElement[]\r\n };\r\n\r\n // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops\r\n if (alreadyVisitedIds.indexOf(id) < 0) {\r\n // Add dependency to alreadyVisitedIds list\r\n alreadyVisitedIds.push(id);\r\n\r\n template.dependencies.forEach(\r\n dependencyId => {\r\n // Remove dependency from list of templates to visit in the top-level loop\r\n const iDependencyTemplate = templateItemIds.indexOf(dependencyId);\r\n if (iDependencyTemplate >= 0) {\r\n templateItemIds.splice(iDependencyTemplate, 1);\r\n }\r\n\r\n traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);\r\n }\r\n );\r\n }\r\n accumulatedHierarchy.push(templateEntry);\r\n }\r\n }\r\n\r\n // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes\r\n let templateItemIds: string[] = _getTopLevelItemIds(templates);\r\n\r\n const otherItems: common.IItemTemplate[] = templates\r\n .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes\r\n .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs\r\n\r\n templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));\r\n\r\n // Step through the list of nodes; we'll also remove nodes as we visit them\r\n let itemId = templateItemIds.shift();\r\n while (typeof itemId !== \"undefined\") {\r\n traceItemId(itemId, hierarchy);\r\n itemId = templateItemIds.shift();\r\n }\r\n\r\n return hierarchy;\r\n}\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.\r\n *\r\n * @param templates Array of templates from a Solution\r\n * @return List of top-level item ids\r\n */\r\nexport function _getTopLevelItemIds(\r\n templates: common.IItemTemplate[]\r\n): string[] {\r\n // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on\r\n const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });\r\n\r\n templates.forEach(function (template) {\r\n (template.dependencies || []).forEach(function (dependencyId) {\r\n const iNode = topLevelItemCandidateIds.indexOf(dependencyId);\r\n\r\n /* istanbul ignore else */\r\n if (iNode >= 0) {\r\n // Node is somebody's dependency, so remove the node from the list of top-level nodes\r\n // If iNode == -1, then it's a shared dependency and it has already been removed\r\n topLevelItemCandidateIds.splice(iNode, 1);\r\n }\r\n });\r\n });\r\n\r\n return topLevelItemCandidateIds;\r\n};\r\n"],"names":["_getTopLevelItemIds","templates","topLevelItemCandidateIds","map","template","itemId","forEach","dependencies","dependencyId","iNode","indexOf","splice","authentication","resultsHtml","item","templateItems","templateItemIds","isTemplate","currentAction","common","getCompleteItem","then","results","Error","base","type","typeKeywords","includes","push","blobToJson","data","itemDataJson","length","sort","fwdRelatedItemIds","fwdRelatedItems","filter","relationshipSet","relationshipType","reduce","flatSet","concat","relatedItemIds","JSON","stringify","missingItems","noDupSet","dependency","catch","error","message","item1","item2","Promise","resolve","reject","itemBaseDef1","itemBaseDef2","getItemBase","cloneObject","all","responses","itemBase1","itemBase2","deleteItemProps","size","compareJSONNoEmptyStrings","e","hierarchy","traceItemId","id","accumulatedHierarchy","alreadyVisitedIds","iTemplate","findIndex","getTemplateInSolution","templateEntry","iDependencyTemplate","otherItems","a","b","shift"],"mappings":";;;;;;;;;;;;;;;;;uoBAiTgBA,EACdC,GAGA,MAAMC,EAA2BD,EAAUE,KAAI,SAAUC,GAAY,OAAOA,EAASC,UAerF,OAbAJ,EAAUK,SAAQ,SAAUF,IACzBA,EAASG,cAAgB,IAAID,SAAQ,SAAUE,GAC9C,MAAMC,EAAQP,EAAyBQ,QAAQF,GAG3CC,GAAS,GAGXP,EAAyBS,OAAOF,EAAO,SAKtCP,mDAlSPG,EACAO,EAA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zB7D,EAAgBL,OAAOkE,EAAqB,GAG9CR,EAAY7D,EAAcoE,EAAcrE,aAAciE,OAI5DD,EAAqB3C,KAAKgD,IAK9B,IAAI5D,EAA4BhB,EAAoBC,GAEpD,MAAM6E,EAAqC7E,EACxCmC,QAAOhC,GAAYY,EAAgBN,QAAQN,EAASC,QAAU,IAC9D4B,MAAK,CAAC8C,EAAGC,IAAMA,EAAEzE,aAAayB,OAAS+C,EAAExE,aAAayB,SAEzDhB,EAAkBA,EAAgByB,OAAOqC,EAAW3E,KAAIC,GAAYA,EAASC,UAG7E,IAAIA,EAASW,EAAgBiE,QAC7B,UAAyB,IAAX5E,GACZgE,EAAYhE,EAAQ+D,GACpB/D,EAASW,EAAgBiE,QAG3B,OAAOb"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-viewer",
3
- "version": "1.1.3",
3
+ "version": "1.3.0",
4
4
  "description": "Simplifies access to @esri/solution.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "unpkg": "dist/umd/viewer.umd.min.js",
@@ -13,32 +13,31 @@
13
13
  "dist/**"
14
14
  ],
15
15
  "devDependencies": {
16
- "@esri/arcgis-rest-auth": "3.4.1",
17
- "@esri/arcgis-rest-feature-layer": "3.4.1",
18
- "@esri/arcgis-rest-portal": "3.4.1",
19
- "@esri/arcgis-rest-request": "3.4.1",
20
- "@esri/arcgis-rest-service-admin": "3.4.1",
21
- "@esri/hub-common": "9.1.4",
22
- "@esri/hub-initiatives": "9.1.4",
23
- "@esri/hub-sites": "9.1.4",
24
- "@esri/hub-teams": "9.1.4",
25
- "rollup": "^1.22.0",
26
- "typescript": "^4.3.4"
16
+ "@esri/arcgis-rest-auth": "3.4.3",
17
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
18
+ "@esri/arcgis-rest-portal": "3.4.3",
19
+ "@esri/arcgis-rest-request": "3.4.3",
20
+ "@esri/arcgis-rest-service-admin": "3.4.3",
21
+ "@esri/hub-common": "9.15.0",
22
+ "@esri/hub-initiatives": "9.15.0",
23
+ "@esri/hub-sites": "9.15.0",
24
+ "@esri/hub-teams": "9.15.0",
25
+ "rollup": "^2.60.0"
27
26
  },
28
27
  "peerDependencies": {
29
- "@esri/arcgis-rest-auth": "3.4.1",
30
- "@esri/arcgis-rest-feature-layer": "3.4.1",
31
- "@esri/arcgis-rest-portal": "3.4.1",
32
- "@esri/arcgis-rest-request": "3.4.1",
33
- "@esri/arcgis-rest-service-admin": "3.4.1",
34
- "@esri/hub-common": "9.1.4",
35
- "@esri/hub-initiatives": "9.1.4",
36
- "@esri/hub-sites": "9.1.4",
37
- "@esri/hub-teams": "9.1.4"
28
+ "@esri/arcgis-rest-auth": "3.4.3",
29
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
30
+ "@esri/arcgis-rest-portal": "3.4.3",
31
+ "@esri/arcgis-rest-request": "3.4.3",
32
+ "@esri/arcgis-rest-service-admin": "3.4.3",
33
+ "@esri/hub-common": "9.15.0",
34
+ "@esri/hub-initiatives": "9.15.0",
35
+ "@esri/hub-sites": "9.15.0",
36
+ "@esri/hub-teams": "9.15.0"
38
37
  },
39
38
  "dependencies": {
40
- "@esri/solution-common": "^1.1.3",
41
- "tslib": "^1.13.0"
39
+ "@esri/solution-common": "^1.3.0",
40
+ "tslib": "1.13.0"
42
41
  },
43
42
  "scripts": {
44
43
  "prepare": "npm run build",
@@ -90,5 +89,5 @@
90
89
  "esri",
91
90
  "ES6"
92
91
  ],
93
- "gitHead": "49a1d019f09a153de90c23d4fff1be1af7d554c0"
92
+ "gitHead": "b8f04e56c71adb7aadaa0293f8708800cdaa9c81"
94
93
  }