@esri/solution-viewer 1.1.2 → 1.2.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[];
@@ -13,7 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { __read } from "tslib";
17
16
  /**
18
17
  * Provides the access to the solution's contents.
19
18
  *
@@ -28,35 +27,34 @@ import * as common from "@esri/solution-common";
28
27
  * @param authentication Credentials for the request to AGO
29
28
  * @return List of results of checks of Solution
30
29
  */
31
- export function checkSolution(itemId, authentication) {
32
- if (authentication === void 0) { authentication = null; }
33
- var resultsHtml = ["Item " + itemId];
34
- var item;
35
- var isTemplate = true;
36
- var templateItems;
37
- var templateItemIds;
38
- var currentAction = " while getting complete item";
30
+ export function checkSolution(itemId, authentication = null) {
31
+ const resultsHtml = [`Item ${itemId}`];
32
+ let item;
33
+ let isTemplate = true;
34
+ let templateItems;
35
+ let templateItemIds;
36
+ let currentAction = " while getting complete item";
39
37
  return (common
40
38
  .getCompleteItem(itemId, authentication)
41
- // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//
42
- .then(function (results) {
39
+ // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
40
+ .then((results) => {
43
41
  currentAction = "";
44
42
  item = results;
45
43
  if (!item) {
46
- throw new Error("item is not found");
44
+ throw new Error(`item is not found`);
47
45
  }
48
46
  else if (item.base.type !== "Solution") {
49
- throw new Error("item is not a Solution");
47
+ throw new Error(`item is not a Solution`);
50
48
  }
51
49
  else if (item.base.typeKeywords.includes("Template")) {
52
- resultsHtml.push("&#x2714; item is a Template Solution");
50
+ resultsHtml.push(`&#x2714; item is a Template Solution`);
53
51
  }
54
52
  else if (item.base.typeKeywords.includes("Deployed")) {
55
53
  isTemplate = false;
56
- resultsHtml.push("&#x2714; item is a Deployed Solution");
54
+ resultsHtml.push(`&#x2714; item is a Deployed Solution`);
57
55
  }
58
56
  else {
59
- throw new Error("item is neither a Template Solution nor a Deployed Solution");
57
+ throw new Error(`item is neither a Template Solution nor a Deployed Solution`);
60
58
  }
61
59
  // base: IItem; text/plain JSON
62
60
  // data: File; */*
@@ -67,25 +65,21 @@ export function checkSolution(itemId, authentication) {
67
65
  // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs
68
66
  return common.blobToJson(item.data);
69
67
  })
70
- // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//
71
- .then(function (itemDataJson) {
72
- templateItems = itemDataJson === null || itemDataJson === void 0 ? void 0 : itemDataJson.templates;
68
+ // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
69
+ .then(itemDataJson => {
70
+ templateItems = itemDataJson?.templates;
73
71
  /* istanbul ignore else */
74
72
  if (!templateItems || templateItems.length === 0) {
75
- throw new Error("Solution's data are not valid JSON or the Solution contains no items");
73
+ throw new Error(`Solution's data are not valid JSON or the Solution contains no items`);
76
74
  }
77
75
  templateItemIds = templateItems
78
- .map(function (template) { return template.itemId; })
76
+ .map((template) => template.itemId)
79
77
  .sort();
80
78
  if (!isTemplate) {
81
79
  // Make sure that there's a Solution2Item relationship to each deployed item
82
- var fwdRelatedItemIds = item.fwdRelatedItems
83
- .filter(function (relationshipSet) {
84
- return relationshipSet.relationshipType === "Solution2Item";
85
- })
86
- .reduce(function (flatSet, relationshipSet) {
87
- return flatSet.concat(relationshipSet.relatedItemIds);
88
- }, [])
80
+ const fwdRelatedItemIds = item.fwdRelatedItems
81
+ .filter(relationshipSet => relationshipSet.relationshipType === "Solution2Item")
82
+ .reduce((flatSet, relationshipSet) => flatSet.concat(relationshipSet.relatedItemIds), [])
89
83
  .sort();
90
84
  if (templateItemIds.length < fwdRelatedItemIds.length) {
91
85
  resultsHtml.push("&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)");
@@ -103,18 +97,18 @@ export function checkSolution(itemId, authentication) {
103
97
  }
104
98
  return resultsHtml;
105
99
  })
106
- // ---------- Check that all dependency references are items in Solution -------------------------------------------//
107
- .then(function () {
108
- var dependencyIds = templateItems
109
- .reduce(function (flatSet, template) { return flatSet.concat(template.dependencies); }, [])
110
- .reduce(function (noDupSet, dependency) {
100
+ // ---------- Check that all dependency references are items in Solution ---------------------------------------//
101
+ .then(() => {
102
+ const dependencyIds = templateItems
103
+ .reduce((flatSet, template) => flatSet.concat(template.dependencies), [])
104
+ .reduce((noDupSet, dependency) => {
111
105
  /* istanbul ignore else */
112
106
  if (!noDupSet.includes(dependency))
113
107
  noDupSet.push(dependency);
114
108
  return noDupSet;
115
109
  }, [])
116
110
  .sort();
117
- var missingItems = dependencyIds.filter(function (dependencyId) { return !templateItemIds.includes(dependencyId); });
111
+ const missingItems = dependencyIds.filter((dependencyId) => !templateItemIds.includes(dependencyId));
118
112
  if (missingItems.length === 0) {
119
113
  resultsHtml.push("&#x2714; all dependencies are in Solution");
120
114
  }
@@ -124,13 +118,13 @@ export function checkSolution(itemId, authentication) {
124
118
  }
125
119
  return resultsHtml;
126
120
  })
127
- // ---------- Done -------------------------------------------------------------------------------------------------//
128
- .then(function () {
121
+ // ---------- Done ---------------------------------------------------------------------------------------------//
122
+ .then(() => {
129
123
  return resultsHtml;
130
124
  })
131
- // ---------- Fatal error ------------------------------------------------------------------------------------------//
132
- .catch(function (error) {
133
- resultsHtml.push("&#x2716; error" + currentAction + ": " + error.message);
125
+ // ---------- Fatal error --------------------------------------------------------------------------------------//
126
+ .catch(error => {
127
+ resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);
134
128
  return resultsHtml;
135
129
  }));
136
130
  }
@@ -143,27 +137,26 @@ export function checkSolution(itemId, authentication) {
143
137
  * @return True if objects are the same
144
138
  * @see Only comparable properties are compared; see deleteItemProps() in the `common` package
145
139
  */
146
- export function compareItems(item1, item2, authentication) {
147
- if (authentication === void 0) { authentication = null; }
148
- return new Promise(function (resolve, reject) {
140
+ export function compareItems(item1, item2, authentication = null) {
141
+ return new Promise((resolve, reject) => {
149
142
  // If an input is a string, fetch the item; otherwise, clone the input because we will modify the
150
143
  // item base to remove incomparable properties
151
- var itemBaseDef1;
144
+ let itemBaseDef1;
152
145
  if (typeof item1 === "string") {
153
146
  itemBaseDef1 = common.getItemBase(item1, authentication);
154
147
  }
155
148
  else {
156
149
  itemBaseDef1 = Promise.resolve(common.cloneObject(item1));
157
150
  }
158
- var itemBaseDef2;
151
+ let itemBaseDef2;
159
152
  if (typeof item2 === "string") {
160
153
  itemBaseDef2 = common.getItemBase(item2, authentication);
161
154
  }
162
155
  else {
163
156
  itemBaseDef2 = Promise.resolve(common.cloneObject(item2));
164
157
  }
165
- Promise.all([itemBaseDef1, itemBaseDef2]).then(function (responses) {
166
- var _a = __read(responses, 2), itemBase1 = _a[0], itemBase2 = _a[1];
158
+ Promise.all([itemBaseDef1, itemBaseDef2]).then(responses => {
159
+ const [itemBase1, itemBase2] = responses;
167
160
  common.deleteItemProps(itemBase1);
168
161
  common.deleteItemProps(itemBase2);
169
162
  if (itemBase1.type === "Solution") {
@@ -177,7 +170,84 @@ export function compareItems(item1, item2, authentication) {
177
170
  console.log("item 2 " + item2 + ": ", JSON.stringify(itemBase2, null, 2));
178
171
  console.log("----------------------------------------------------------------");*/
179
172
  resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));
180
- }, function (e) { return reject(e); });
173
+ }, e => reject(e));
181
174
  });
182
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
+ ;
183
253
  //# sourceMappingURL=viewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAc,EACd,cAAyC;IAAzC,+BAAA,EAAA,qBAAyC;IAEzC,IAAM,WAAW,GAAa,CAAC,UAAQ,MAAQ,CAAC,CAAC;IACjD,IAAI,IAA0B,CAAC;IAC/B,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,IAAI,aAAqC,CAAC;IAC1C,IAAI,eAAyB,CAAC;IAE9B,I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CAAC,CAAC;aAC3C;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAAA,CAAC"}
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var tslib_1 = require("tslib");
18
+ const tslib_1 = require("tslib");
19
19
  /**
20
20
  * Provides the access to the solution's contents.
21
21
  *
@@ -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,14 +15,13 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.compareItems = exports.checkSolution = void 0;
19
- var tslib_1 = require("tslib");
18
+ exports._getTopLevelItemIds = exports.getItemHierarchy = exports.compareItems = exports.checkSolution = void 0;
20
19
  /**
21
20
  * Provides the access to the solution's contents.
22
21
  *
23
22
  * @module viewer
24
23
  */
25
- var common = require("@esri/solution-common");
24
+ const common = require("@esri/solution-common");
26
25
  // ------------------------------------------------------------------------------------------------------------------ //
27
26
  /**
28
27
  * Checks a Solution.
@@ -31,35 +30,34 @@ var common = require("@esri/solution-common");
31
30
  * @param authentication Credentials for the request to AGO
32
31
  * @return List of results of checks of Solution
33
32
  */
34
- function checkSolution(itemId, authentication) {
35
- if (authentication === void 0) { authentication = null; }
36
- var resultsHtml = ["Item " + itemId];
37
- var item;
38
- var isTemplate = true;
39
- var templateItems;
40
- var templateItemIds;
41
- var currentAction = " while getting complete item";
33
+ function checkSolution(itemId, authentication = null) {
34
+ const resultsHtml = [`Item ${itemId}`];
35
+ let item;
36
+ let isTemplate = true;
37
+ let templateItems;
38
+ let templateItemIds;
39
+ let currentAction = " while getting complete item";
42
40
  return (common
43
41
  .getCompleteItem(itemId, authentication)
44
- // ---------- Is it a Template or Deployed Solution? ---------------------------------------------------------------//
45
- .then(function (results) {
42
+ // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
43
+ .then((results) => {
46
44
  currentAction = "";
47
45
  item = results;
48
46
  if (!item) {
49
- throw new Error("item is not found");
47
+ throw new Error(`item is not found`);
50
48
  }
51
49
  else if (item.base.type !== "Solution") {
52
- throw new Error("item is not a Solution");
50
+ throw new Error(`item is not a Solution`);
53
51
  }
54
52
  else if (item.base.typeKeywords.includes("Template")) {
55
- resultsHtml.push("&#x2714; item is a Template Solution");
53
+ resultsHtml.push(`&#x2714; item is a Template Solution`);
56
54
  }
57
55
  else if (item.base.typeKeywords.includes("Deployed")) {
58
56
  isTemplate = false;
59
- resultsHtml.push("&#x2714; item is a Deployed Solution");
57
+ resultsHtml.push(`&#x2714; item is a Deployed Solution`);
60
58
  }
61
59
  else {
62
- throw new Error("item is neither a Template Solution nor a Deployed Solution");
60
+ throw new Error(`item is neither a Template Solution nor a Deployed Solution`);
63
61
  }
64
62
  // base: IItem; text/plain JSON
65
63
  // data: File; */*
@@ -70,25 +68,21 @@ function checkSolution(itemId, authentication) {
70
68
  // revRelatedItems: IRelatedItems[]; list of reverse relationshipType/relatedItems[] pairs
71
69
  return common.blobToJson(item.data);
72
70
  })
73
- // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item ------------------//
74
- .then(function (itemDataJson) {
75
- templateItems = itemDataJson === null || itemDataJson === void 0 ? void 0 : itemDataJson.templates;
71
+ // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
72
+ .then(itemDataJson => {
73
+ templateItems = itemDataJson?.templates;
76
74
  /* istanbul ignore else */
77
75
  if (!templateItems || templateItems.length === 0) {
78
- throw new Error("Solution's data are not valid JSON or the Solution contains no items");
76
+ throw new Error(`Solution's data are not valid JSON or the Solution contains no items`);
79
77
  }
80
78
  templateItemIds = templateItems
81
- .map(function (template) { return template.itemId; })
79
+ .map((template) => template.itemId)
82
80
  .sort();
83
81
  if (!isTemplate) {
84
82
  // Make sure that there's a Solution2Item relationship to each deployed item
85
- var fwdRelatedItemIds = item.fwdRelatedItems
86
- .filter(function (relationshipSet) {
87
- return relationshipSet.relationshipType === "Solution2Item";
88
- })
89
- .reduce(function (flatSet, relationshipSet) {
90
- return flatSet.concat(relationshipSet.relatedItemIds);
91
- }, [])
83
+ const fwdRelatedItemIds = item.fwdRelatedItems
84
+ .filter(relationshipSet => relationshipSet.relationshipType === "Solution2Item")
85
+ .reduce((flatSet, relationshipSet) => flatSet.concat(relationshipSet.relatedItemIds), [])
92
86
  .sort();
93
87
  if (templateItemIds.length < fwdRelatedItemIds.length) {
94
88
  resultsHtml.push("&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)");
@@ -106,18 +100,18 @@ function checkSolution(itemId, authentication) {
106
100
  }
107
101
  return resultsHtml;
108
102
  })
109
- // ---------- Check that all dependency references are items in Solution -------------------------------------------//
110
- .then(function () {
111
- var dependencyIds = templateItems
112
- .reduce(function (flatSet, template) { return flatSet.concat(template.dependencies); }, [])
113
- .reduce(function (noDupSet, dependency) {
103
+ // ---------- Check that all dependency references are items in Solution ---------------------------------------//
104
+ .then(() => {
105
+ const dependencyIds = templateItems
106
+ .reduce((flatSet, template) => flatSet.concat(template.dependencies), [])
107
+ .reduce((noDupSet, dependency) => {
114
108
  /* istanbul ignore else */
115
109
  if (!noDupSet.includes(dependency))
116
110
  noDupSet.push(dependency);
117
111
  return noDupSet;
118
112
  }, [])
119
113
  .sort();
120
- var missingItems = dependencyIds.filter(function (dependencyId) { return !templateItemIds.includes(dependencyId); });
114
+ const missingItems = dependencyIds.filter((dependencyId) => !templateItemIds.includes(dependencyId));
121
115
  if (missingItems.length === 0) {
122
116
  resultsHtml.push("&#x2714; all dependencies are in Solution");
123
117
  }
@@ -127,13 +121,13 @@ function checkSolution(itemId, authentication) {
127
121
  }
128
122
  return resultsHtml;
129
123
  })
130
- // ---------- Done -------------------------------------------------------------------------------------------------//
131
- .then(function () {
124
+ // ---------- Done ---------------------------------------------------------------------------------------------//
125
+ .then(() => {
132
126
  return resultsHtml;
133
127
  })
134
- // ---------- Fatal error ------------------------------------------------------------------------------------------//
135
- .catch(function (error) {
136
- resultsHtml.push("&#x2716; error" + currentAction + ": " + error.message);
128
+ // ---------- Fatal error --------------------------------------------------------------------------------------//
129
+ .catch(error => {
130
+ resultsHtml.push(`&#x2716; error${currentAction}: ${error.message}`);
137
131
  return resultsHtml;
138
132
  }));
139
133
  }
@@ -147,27 +141,26 @@ exports.checkSolution = checkSolution;
147
141
  * @return True if objects are the same
148
142
  * @see Only comparable properties are compared; see deleteItemProps() in the `common` package
149
143
  */
150
- function compareItems(item1, item2, authentication) {
151
- if (authentication === void 0) { authentication = null; }
152
- return new Promise(function (resolve, reject) {
144
+ function compareItems(item1, item2, authentication = null) {
145
+ return new Promise((resolve, reject) => {
153
146
  // If an input is a string, fetch the item; otherwise, clone the input because we will modify the
154
147
  // item base to remove incomparable properties
155
- var itemBaseDef1;
148
+ let itemBaseDef1;
156
149
  if (typeof item1 === "string") {
157
150
  itemBaseDef1 = common.getItemBase(item1, authentication);
158
151
  }
159
152
  else {
160
153
  itemBaseDef1 = Promise.resolve(common.cloneObject(item1));
161
154
  }
162
- var itemBaseDef2;
155
+ let itemBaseDef2;
163
156
  if (typeof item2 === "string") {
164
157
  itemBaseDef2 = common.getItemBase(item2, authentication);
165
158
  }
166
159
  else {
167
160
  itemBaseDef2 = Promise.resolve(common.cloneObject(item2));
168
161
  }
169
- Promise.all([itemBaseDef1, itemBaseDef2]).then(function (responses) {
170
- var _a = (0, tslib_1.__read)(responses, 2), itemBase1 = _a[0], itemBase2 = _a[1];
162
+ Promise.all([itemBaseDef1, itemBaseDef2]).then(responses => {
163
+ const [itemBase1, itemBase2] = responses;
171
164
  common.deleteItemProps(itemBase1);
172
165
  common.deleteItemProps(itemBase2);
173
166
  if (itemBase1.type === "Solution") {
@@ -181,8 +174,87 @@ function compareItems(item1, item2, authentication) {
181
174
  console.log("item 2 " + item2 + ": ", JSON.stringify(itemBase2, null, 2));
182
175
  console.log("----------------------------------------------------------------");*/
183
176
  resolve(common.compareJSONNoEmptyStrings(itemBase1, itemBase2));
184
- }, function (e) { return reject(e); });
177
+ }, e => reject(e));
185
178
  });
186
179
  }
187
180
  exports.compareItems = compareItems;
181
+ /**
182
+ * Creates a hierarchy of the items in a Solution template.
183
+ *
184
+ * @param templates Array of templates from a Solution
185
+ * @return List of top-level items, each containing a recursive list of its dependencies
186
+ */
187
+ function getItemHierarchy(templates) {
188
+ const hierarchy = [];
189
+ // Get the template specified by id out of a list of templates
190
+ function getTemplateInSolution(templates, id) {
191
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
192
+ return iTemplate >= 0 ? templates[iTemplate] : null;
193
+ }
194
+ // Hierarchically list the dependencies of specified node
195
+ function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
196
+ // Get the dependencies of the node
197
+ const template = getTemplateInSolution(templates, id);
198
+ /* istanbul ignore else */
199
+ if (template) {
200
+ const templateEntry = {
201
+ id,
202
+ dependencies: []
203
+ };
204
+ // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
205
+ if (alreadyVisitedIds.indexOf(id) < 0) {
206
+ // Add dependency to alreadyVisitedIds list
207
+ alreadyVisitedIds.push(id);
208
+ template.dependencies.forEach(dependencyId => {
209
+ // Remove dependency from list of templates to visit in the top-level loop
210
+ const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
211
+ if (iDependencyTemplate >= 0) {
212
+ templateItemIds.splice(iDependencyTemplate, 1);
213
+ }
214
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
215
+ });
216
+ }
217
+ accumulatedHierarchy.push(templateEntry);
218
+ }
219
+ }
220
+ // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
221
+ let templateItemIds = _getTopLevelItemIds(templates);
222
+ const otherItems = templates
223
+ .filter(template => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
224
+ .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
225
+ templateItemIds = templateItemIds.concat(otherItems.map(template => template.itemId));
226
+ // Step through the list of nodes; we'll also remove nodes as we visit them
227
+ let itemId = templateItemIds.shift();
228
+ while (typeof itemId !== "undefined") {
229
+ traceItemId(itemId, hierarchy);
230
+ itemId = templateItemIds.shift();
231
+ }
232
+ return hierarchy;
233
+ }
234
+ exports.getItemHierarchy = getItemHierarchy;
235
+ // ------------------------------------------------------------------------------------------------------------------ //
236
+ /**
237
+ * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
238
+ *
239
+ * @param templates Array of templates from a Solution
240
+ * @return List of top-level item ids
241
+ */
242
+ function _getTopLevelItemIds(templates) {
243
+ // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
244
+ const topLevelItemCandidateIds = templates.map(function (template) { return template.itemId; });
245
+ templates.forEach(function (template) {
246
+ (template.dependencies || []).forEach(function (dependencyId) {
247
+ const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
248
+ /* istanbul ignore else */
249
+ if (iNode >= 0) {
250
+ // Node is somebody's dependency, so remove the node from the list of top-level nodes
251
+ // If iNode == -1, then it's a shared dependency and it has already been removed
252
+ topLevelItemCandidateIds.splice(iNode, 1);
253
+ }
254
+ });
255
+ });
256
+ return topLevelItemCandidateIds;
257
+ }
258
+ exports._getTopLevelItemIds = _getTopLevelItemIds;
259
+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