@esri/solution-viewer 1.1.4 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,6 @@ export declare function getItemHierarchy(templates: common.IItemTemplate[]): com
48
48
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
49
  *
50
50
  * @param templates Array of templates from a Solution
51
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
52
- * where there are no top-level items due to a circular dependency
51
+ * @return List of top-level item ids
53
52
  */
54
53
  export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -183,39 +183,47 @@ export function getItemHierarchy(templates) {
183
183
  const hierarchy = [];
184
184
  // Get the template specified by id out of a list of templates
185
185
  function getTemplateInSolution(templates, id) {
186
- const childId = templates.findIndex(function (template) { return id === template.itemId; });
187
- return childId >= 0 ? templates[childId] : null;
186
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
187
+ return iTemplate >= 0 ? templates[iTemplate] : null;
188
188
  }
189
- // Hierarchically list the children of specified nodes
190
- function itemChildren(children, accumulatedHierarchy, ancestors = []) {
191
- // Visit each child
192
- children.forEach((id) => {
193
- const child = {
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 = {
194
196
  id,
195
197
  dependencies: []
196
198
  };
197
- // Fill in the child's dependencies array with its children
198
- const template = getTemplateInSolution(templates, id);
199
- /* istanbul ignore else */
200
- if (template) {
201
- // Only continue with this child's dependencies if it's not in the ancestors list to avoid infinite loops
202
- /* istanbul ignore else */
203
- if (ancestors.indexOf(id) < 0) {
204
- // Add child to ancestors list
205
- ancestors.push(id);
206
- const dependencyIds = template.dependencies;
207
- if (Array.isArray(dependencyIds) && dependencyIds.length > 0) {
208
- itemChildren(dependencyIds, child.dependencies, ancestors);
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);
209
208
  }
210
- }
209
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
210
+ });
211
211
  }
212
- accumulatedHierarchy.push(child);
213
- });
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();
214
226
  }
215
- // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
216
- const topLevelItemIds = _getTopLevelItemIds(templates);
217
- // Start the recursive search with the top-level items
218
- itemChildren(topLevelItemIds, hierarchy);
219
227
  return hierarchy;
220
228
  }
221
229
  // ------------------------------------------------------------------------------------------------------------------ //
@@ -223,8 +231,7 @@ export function getItemHierarchy(templates) {
223
231
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
224
232
  *
225
233
  * @param templates Array of templates from a Solution
226
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
227
- * where there are no top-level items due to a circular dependency
234
+ * @return List of top-level item ids
228
235
  */
229
236
  export function _getTopLevelItemIds(templates) {
230
237
  // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
@@ -240,10 +247,6 @@ export function _getTopLevelItemIds(templates) {
240
247
  }
241
248
  });
242
249
  });
243
- // If no node is top level because of a circular dependency, choose the first template in the list
244
- if (topLevelItemCandidateIds.length === 0 && templates.length > 0) {
245
- topLevelItemCandidateIds.push(templates[0].itemId);
246
- }
247
250
  return topLevelItemCandidateIds;
248
251
  }
249
252
  ;
@@ -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,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,eAAyB,CAAC;IAE9B,IAAI,aAAa,GAAW,8BAA8B,CAAC;IAC3D,OAAO,CACL,MAAM;SACH,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC;QAExC,kHAAkH;SACjH,IAAI,CAAC,CAAC,OAA6B,EAAE,EAAE;QACtC,aAAa,GAAG,EAAE,CAAC;QACnB,IAAI,GAAG,OAAO,CAAC;QAEf,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;SACtC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC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;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiC;IAEjC,+FAA+F;IAC/F,MAAM,wBAAwB,GAAG,SAAS,CAAC,GAAG,CAAC,UAAU,QAAQ,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"}
@@ -48,7 +48,6 @@ export declare function getItemHierarchy(templates: common.IItemTemplate[]): com
48
48
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
49
  *
50
50
  * @param templates Array of templates from a Solution
51
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
52
- * where there are no top-level items due to a circular dependency
51
+ * @return List of top-level item ids
53
52
  */
54
53
  export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -16,12 +16,13 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
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.
@@ -188,39 +189,47 @@ function getItemHierarchy(templates) {
188
189
  const hierarchy = [];
189
190
  // Get the template specified by id out of a list of templates
190
191
  function getTemplateInSolution(templates, id) {
191
- const childId = templates.findIndex(function (template) { return id === template.itemId; });
192
- return childId >= 0 ? templates[childId] : null;
192
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
193
+ return iTemplate >= 0 ? templates[iTemplate] : null;
193
194
  }
194
- // Hierarchically list the children of specified nodes
195
- function itemChildren(children, accumulatedHierarchy, ancestors = []) {
196
- // Visit each child
197
- children.forEach((id) => {
198
- const child = {
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 = {
199
202
  id,
200
203
  dependencies: []
201
204
  };
202
- // Fill in the child's dependencies array with its children
203
- const template = getTemplateInSolution(templates, id);
204
- /* istanbul ignore else */
205
- if (template) {
206
- // Only continue with this child's dependencies if it's not in the ancestors list to avoid infinite loops
207
- /* istanbul ignore else */
208
- if (ancestors.indexOf(id) < 0) {
209
- // Add child to ancestors list
210
- ancestors.push(id);
211
- const dependencyIds = template.dependencies;
212
- if (Array.isArray(dependencyIds) && dependencyIds.length > 0) {
213
- itemChildren(dependencyIds, child.dependencies, ancestors);
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
214
  }
215
- }
215
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
216
+ });
216
217
  }
217
- accumulatedHierarchy.push(child);
218
- });
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();
219
232
  }
220
- // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
221
- const topLevelItemIds = _getTopLevelItemIds(templates);
222
- // Start the recursive search with the top-level items
223
- itemChildren(topLevelItemIds, hierarchy);
224
233
  return hierarchy;
225
234
  }
226
235
  exports.getItemHierarchy = getItemHierarchy;
@@ -229,8 +238,7 @@ exports.getItemHierarchy = getItemHierarchy;
229
238
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
230
239
  *
231
240
  * @param templates Array of templates from a Solution
232
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
233
- * where there are no top-level items due to a circular dependency
241
+ * @return List of top-level item ids
234
242
  */
235
243
  function _getTopLevelItemIds(templates) {
236
244
  // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
@@ -246,10 +254,6 @@ function _getTopLevelItemIds(templates) {
246
254
  }
247
255
  });
248
256
  });
249
- // If no node is top level because of a circular dependency, choose the first template in the list
250
- if (topLevelItemCandidateIds.length === 0 && templates.length > 0) {
251
- topLevelItemCandidateIds.push(templates[0].itemId);
252
- }
253
257
  return topLevelItemCandidateIds;
254
258
  }
255
259
  exports._getTopLevelItemIds = _getTopLevelItemIds;
@@ -1 +1 @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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;AApBD,kDAoBC;AAAA,CAAC"}
@@ -48,7 +48,6 @@ export declare function getItemHierarchy(templates: common.IItemTemplate[]): com
48
48
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
49
49
  *
50
50
  * @param templates Array of templates from a Solution
51
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
52
- * where there are no top-level items due to a circular dependency
51
+ * @return List of top-level item ids
53
52
  */
54
53
  export declare function _getTopLevelItemIds(templates: common.IItemTemplate[]): string[];
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-viewer - v1.1.4 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Tue Oct 26 2021 15:14:48 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-viewer - v1.3.1 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 10:44:02 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,7 +71,8 @@
51
71
  let templateItems;
52
72
  let templateItemIds;
53
73
  let currentAction = " while getting complete item";
54
- return (common.getCompleteItem(itemId, authentication)
74
+ return (common__namespace
75
+ .getCompleteItem(itemId, authentication)
55
76
  // ---------- Is it a Template or Deployed Solution? -----------------------------------------------------------//
56
77
  .then((results) => {
57
78
  currentAction = "";
@@ -79,7 +100,7 @@
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
105
  // ---------- Check the Solution2Item relationship from a Deployed Solution to each deployed item --------------//
85
106
  .then(itemDataJson => {
@@ -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,7 +206,7 @@
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
  });
191
212
  }
@@ -199,39 +220,47 @@
199
220
  const hierarchy = [];
200
221
  // Get the template specified by id out of a list of templates
201
222
  function getTemplateInSolution(templates, id) {
202
- const childId = templates.findIndex(function (template) { return id === template.itemId; });
203
- return childId >= 0 ? templates[childId] : null;
223
+ const iTemplate = templates.findIndex((template) => id === template.itemId);
224
+ return iTemplate >= 0 ? templates[iTemplate] : null;
204
225
  }
205
- // Hierarchically list the children of specified nodes
206
- function itemChildren(children, accumulatedHierarchy, ancestors = []) {
207
- // Visit each child
208
- children.forEach((id) => {
209
- const child = {
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 = {
210
233
  id,
211
234
  dependencies: []
212
235
  };
213
- // Fill in the child's dependencies array with its children
214
- const template = getTemplateInSolution(templates, id);
215
- /* istanbul ignore else */
216
- if (template) {
217
- // Only continue with this child's dependencies if it's not in the ancestors list to avoid infinite loops
218
- /* istanbul ignore else */
219
- if (ancestors.indexOf(id) < 0) {
220
- // Add child to ancestors list
221
- ancestors.push(id);
222
- const dependencyIds = template.dependencies;
223
- if (Array.isArray(dependencyIds) && dependencyIds.length > 0) {
224
- itemChildren(dependencyIds, child.dependencies, ancestors);
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);
225
245
  }
226
- }
246
+ traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
247
+ });
227
248
  }
228
- accumulatedHierarchy.push(child);
229
- });
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();
230
263
  }
231
- // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
232
- const topLevelItemIds = _getTopLevelItemIds(templates);
233
- // Start the recursive search with the top-level items
234
- itemChildren(topLevelItemIds, hierarchy);
235
264
  return hierarchy;
236
265
  }
237
266
  // ------------------------------------------------------------------------------------------------------------------ //
@@ -239,8 +268,7 @@
239
268
  * Finds the top-level items in a Solution template--the items that are not dependencies of any other item.
240
269
  *
241
270
  * @param templates Array of templates from a Solution
242
- * @return List of top-level item ids; note that the first item in the templates array is returned in the case
243
- * where there are no top-level items due to a circular dependency
271
+ * @return List of top-level item ids
244
272
  */
245
273
  function _getTopLevelItemIds(templates) {
246
274
  // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
@@ -256,10 +284,6 @@
256
284
  }
257
285
  });
258
286
  });
259
- // If no node is top level because of a circular dependency, choose the first template in the list
260
- if (topLevelItemCandidateIds.length === 0 && templates.length > 0) {
261
- topLevelItemCandidateIds.push(templates[0].itemId);
262
- }
263
287
  return topLevelItemCandidateIds;
264
288
  }
265
289
 
@@ -270,5 +294,5 @@
270
294
 
271
295
  Object.defineProperty(exports, '__esModule', { value: true });
272
296
 
273
- })));
297
+ }));
274
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\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 childId = templates.findIndex(function (template) { return id === template.itemId; });\r\n return childId >= 0 ? templates[childId] : null;\r\n }\r\n\r\n // Hierarchically list the children of specified nodes\r\n function itemChildren(children: string[], accumulatedHierarchy: common.IHierarchyElement[], ancestors: string[] = []) {\r\n // Visit each child\r\n children.forEach((id) => {\r\n const child = {\r\n id,\r\n dependencies: [] as common.IHierarchyElement[]\r\n };\r\n\r\n // Fill in the child's dependencies array with its children\r\n const template = getTemplateInSolution(templates, id);\r\n /* istanbul ignore else */\r\n if (template) {\r\n // Only continue with this child's dependencies if it's not in the ancestors list to avoid infinite loops\r\n /* istanbul ignore else */\r\n if (ancestors.indexOf(id) < 0) {\r\n // Add child to ancestors list\r\n ancestors.push(id);\r\n\r\n const dependencyIds: string[] = template.dependencies;\r\n if (Array.isArray(dependencyIds) && dependencyIds.length > 0) {\r\n itemChildren(dependencyIds, child.dependencies, ancestors);\r\n }\r\n }\r\n }\r\n accumulatedHierarchy.push(child);\r\n });\r\n }\r\n\r\n // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on\r\n const topLevelItemIds = _getTopLevelItemIds(templates);\r\n\r\n // Start the recursive search with the top-level items\r\n itemChildren(topLevelItemIds, hierarchy);\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; note that the first item in the templates array is returned in the case\r\n * where there are no top-level items due to a circular dependency\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 // If no node is top level because of a circular dependency, choose the first template in the list\r\n if (topLevelItemCandidateIds.length === 0 && templates.length > 0) {\r\n topLevelItemCandidateIds.push(templates[0].itemId);\r\n }\r\n\r\n return topLevelItemCandidateIds;\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,IA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AC;OACJ;;MAGD,MAAM,eAAe,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;;MAGvD,YAAY,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;MACzC,OAAO,SAAS,CAAC;EACnB,CAAC;EAED;EAEA;;;;;;;WAOgB,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;;MAGH,IAAI,wBAAwB,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;UACjE,wBAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;OACpD;MAED,OAAO,wBAAwB,CAAC;EAClC;;;;;;;;;;;;;;;"}
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\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,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,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.4 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Tue Oct 26 2021 15:14:54 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-viewer - v1.3.1 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 10:44:12 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";function n(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)}))})),0===t.length&&e.length>0&&t.push(e[0].itemId),t}e._getTopLevelItemIds=n,e.checkSolution=function(e,n=null){const o=[`Item ${e}`];let i,r,s,l=!0,u=" while getting complete item";return t.getCompleteItem(e,n).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"))o.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,o.push("&#x2714; item is a Deployed Solution")}return t.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?o.push("&#x2716; there are forward Solution2Item relationship(s) to unknown item(s)"):s.length>e.length?o.push("&#x2716; missing forward Solution2Item relationship(s)"):JSON.stringify(s)!==JSON.stringify(e)?o.push("&#x2716; mismatching forward Solution2Item relationship(s)"):o.push("&#x2714; matching forward Solution2Item relationship(s)")}return o})).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?o.push("&#x2714; all dependencies are in Solution"):o.push("&#x2716; dependencies that aren't in Solution: "+JSON.stringify(e)),o})).then((()=>o)).catch((e=>(o.push(`&#x2716; error${u}: ${e.message}`),o)))},e.compareItems=function(e,n,o=null){return new Promise(((i,r)=>{let s,l;s="string"==typeof e?t.getItemBase(e,o):Promise.resolve(t.cloneObject(e)),l="string"==typeof n?t.getItemBase(n,o):Promise.resolve(t.cloneObject(n)),Promise.all([s,l]).then((e=>{const[n,o]=e;t.deleteItemProps(n),t.deleteItemProps(o),"Solution"===n.type&&(delete n.typeKeywords,delete n.size,delete o.typeKeywords,delete o.size),i(t.compareJSONNoEmptyStrings(n,o))}),(e=>r(e)))}))},e.getItemHierarchy=function(e){const t=[];return function t(n,o,i=[]){n.forEach((n=>{const r={id:n,dependencies:[]},s=function(e,t){const n=e.findIndex((function(e){return t===e.itemId}));return n>=0?e[n]:null}(e,n);if(s&&i.indexOf(n)<0){i.push(n);const e=s.dependencies;Array.isArray(e)&&e.length>0&&t(e,r.dependencies,i)}o.push(r)}))}(n(e),t),t},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\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 childId = templates.findIndex(function (template) { return id === template.itemId; });\r\n return childId >= 0 ? templates[childId] : null;\r\n }\r\n\r\n // Hierarchically list the children of specified nodes\r\n function itemChildren(children: string[], accumulatedHierarchy: common.IHierarchyElement[], ancestors: string[] = []) {\r\n // Visit each child\r\n children.forEach((id) => {\r\n const child = {\r\n id,\r\n dependencies: [] as common.IHierarchyElement[]\r\n };\r\n\r\n // Fill in the child's dependencies array with its children\r\n const template = getTemplateInSolution(templates, id);\r\n /* istanbul ignore else */\r\n if (template) {\r\n // Only continue with this child's dependencies if it's not in the ancestors list to avoid infinite loops\r\n /* istanbul ignore else */\r\n if (ancestors.indexOf(id) < 0) {\r\n // Add child to ancestors list\r\n ancestors.push(id);\r\n\r\n const dependencyIds: string[] = template.dependencies;\r\n if (Array.isArray(dependencyIds) && dependencyIds.length > 0) {\r\n itemChildren(dependencyIds, child.dependencies, ancestors);\r\n }\r\n }\r\n }\r\n accumulatedHierarchy.push(child);\r\n });\r\n }\r\n\r\n // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on\r\n const topLevelItemIds = _getTopLevelItemIds(templates);\r\n\r\n // Start the recursive search with the top-level items\r\n itemChildren(topLevelItemIds, hierarchy);\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; note that the first item in the templates array is returned in the case\r\n * where there are no top-level items due to a circular dependency\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 // If no node is top level because of a circular dependency, choose the first template in the list\r\n if (topLevelItemCandidateIds.length === 0 && templates.length > 0) {\r\n topLevelItemCandidateIds.push(templates[0].itemId);\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","length","push","authentication","resultsHtml","item","templateItems","templateItemIds","isTemplate","currentAction","common\r\n .getCompleteItem","then","results","Error","base","type","typeKeywords","includes","common.blobToJson","data","itemDataJson","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","common.getItemBase","common.cloneObject","all","responses","itemBase1","itemBase2","common.deleteItemProps","size","common.compareJSONNoEmptyStrings","e","hierarchy","itemChildren","children","accumulatedHierarchy","ancestors","id","child","childId","findIndex","getTemplateInSolution","dependencyIds","Array","isArray"],"mappings":";;;;;;;;;;;;;;;;;mTAoSgBA,EACdC,GAGA,MAAMC,EAA2BD,EAAUE,KAAI,SAAUC,GAAY,OAAOA,EAASC,UAoBrF,OAlBAJ,EAAUK,SAAQ,SAAUF,IACzBA,EAASG,cAAgB,IAAID,SAAQ,SAAUE,GAC9C,MAAMC,EAAQP,EAAyBQ,QAAQF,GAG3CC,GAAS,GAGXP,EAAyBS,OAAOF,EAAO,SAML,IAApCP,EAAyBU,QAAgBX,EAAUW,OAAS,GAC9DV,EAAyBW,KAAKZ,EAAU,GAAGI,QAGtCH,mDA1RPG,EACAS,EAAqC,MAErC,MAAMC,EAAwB,CAAC,QAAQV,KACvC,IAAIW,EAEAC,EACAC,EAFAC,GAAa,EAIbC,EAAwB,+BAC5B,OACEC,kBACmBhB,EAAQS,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,EAAYF,KAAK,4CACZ,CAAA,IAAIG,EAAKS,KAAKE,aAAaC,SAAS,YAIzC,MAAM,IAAIJ,MACR,+DAJFL,GAAa,EACbJ,EAAYF,KAAK,wCAcnB,OAAOgB,aAAkBb,EAAKc,SAI/BR,MAAKS,IAGJ,GAFAd,EAAgBc,GAAc9B,WAEzBgB,GAA0C,IAAzBA,EA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A,aAAnBD,EAAUnC,cACLmC,EAAUlC,oBACVkC,EAAUG,YACVF,EAAUnC,oBACVmC,EAAUE,MAQnBX,EAAQY,4BAAiCJ,EAAWC,OAEtDI,GAAKZ,EAAOY,qCAYhBjE,GAEA,MAAMkE,EAAY,GA0ClB,OAjCA,SAASC,EAAaC,EAAoBC,EAAkDC,EAAsB,IAEhHF,EAAS/D,SAASkE,IAChB,MAAMC,EAAQ,CACZD,GAAAA,EACAjE,aAAc,IAIVH,EAfV,SAA+BH,EAAmCuE,GAChE,MAAME,EAAUzE,EAAU0E,WAAU,SAAUvE,GAAY,OAAOoE,IAAOpE,EAASC,UACjF,OAAOqE,GAAW,EAAIzE,EAAUyE,GAAW,KAaxBE,CAAsB3E,EAAWuE,GAElD,GAAIpE,GAGEmE,EAAU7D,QAAQ8D,GAAM,EAAG,CAE7BD,EAAU1D,KAAK2D,GAEf,MAAMK,EAA0BzE,EAASG,aACrCuE,MAAMC,QAAQF,IAAkBA,EAAcjE,OAAS,GACzDwD,EAAaS,EAAeJ,EAAMlE,aAAcgE,GAItDD,EAAqBzD,KAAK4D,MAQ9BL,CAHwBpE,EAAoBC,GAGdkE,GACvBA"}
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,EAAqC,MAErC,MAAMC,EAAwB,CAAC,QAAQR,KACvC,IAAIS,EAEAC,EACAC,EAFAC,GAAa,EAIbC,EAAwB,+BAC5B,OACEC,EACGC,gBAAgBf,EAAQO,GAGxBS,MAAMC,IAIL,GAHAJ,EAAgB,GAChBJ,EAAOQ,GAEFR,EACH,MAAM,IAAIS,MAAM,qBACX,GAAuB,aAAnBT,EAAKU,KAAKC,KACnB,MAAM,IAAIF,MAAM,0BACX,GAAIT,EAAKU,KAAKE,aAAaC,SAAS,YACzCd,EAAYe,KAAK,4CACZ,CAAA,IAAId,EAAKU,KAAKE,aAAaC,SAAS,YAIzC,MAAM,IAAIJ,MACR,+DAJFN,GAAa,EACbJ,EAAYe,KAAK,wCAcnB,OAAOT,EAAOU,WAAWf,EAAKgB,SAI/BT,MAAKU,IAGJ,GAFAhB,EAAgBgB,GAAc9B,WAEzBc,GAA0C,IAAzBA,EAAciB,OAClC,MAAM,IAAIT,MACR,wEAQJ,GAJAP,EAAkBD,EACfZ,KAAKC,GAAmCA,EAASC,SACjD4B,QAEEhB,EAAY,CAEf,MAAMiB,EAAoBpB,EAAKqB,gBAC5BC,QACCC,GACuC,kBAArCA,EAAgBC,mBAEnBC,QACC,CAACC,EAASH,IACRG,EAAQC,OAAOJ,EAAgBK,iB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MmE,EAAY,GASlB,SAASC,EAAYC,EAAYC,EAAkDC,EAA8B,IAE/G,MAAMpE,EARR,SAA+BH,EAAmCqE,GAChE,MAAMG,EAAYxE,EAAUyE,WAAWtE,GAAakE,IAAOlE,EAASC,SACpE,OAAOoE,GAAa,EAAIxE,EAAUwE,GAAa,KAM9BE,CAAsB1E,EAAWqE,GAElD,GAAIlE,EAAU,CACZ,MAAMwE,EAAgB,CACpBN,GAAAA,EACA/D,aAAc,IAIZiE,EAAkB9D,QAAQ4D,GAAM,IAElCE,EAAkB5C,KAAK0C,GAEvBlE,EAASG,aAAaD,SACpBE,IAEE,MAAMqE,EAAsB7D,EAAgBN,QAAQF,GAChDqE,GAAuB,GACzB7D,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.4",
3
+ "version": "1.3.1",
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.2",
17
- "@esri/arcgis-rest-feature-layer": "3.4.2",
18
- "@esri/arcgis-rest-portal": "3.4.2",
19
- "@esri/arcgis-rest-request": "3.4.2",
20
- "@esri/arcgis-rest-service-admin": "3.4.2",
21
- "@esri/hub-common": "9.2.0",
22
- "@esri/hub-initiatives": "9.2.0",
23
- "@esri/hub-sites": "9.2.0",
24
- "@esri/hub-teams": "9.2.0",
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.2",
30
- "@esri/arcgis-rest-feature-layer": "3.4.2",
31
- "@esri/arcgis-rest-portal": "3.4.2",
32
- "@esri/arcgis-rest-request": "3.4.2",
33
- "@esri/arcgis-rest-service-admin": "3.4.2",
34
- "@esri/hub-common": "9.2.0",
35
- "@esri/hub-initiatives": "9.2.0",
36
- "@esri/hub-sites": "9.2.0",
37
- "@esri/hub-teams": "9.2.0"
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.4",
41
- "tslib": "^1.13.0"
39
+ "@esri/solution-common": "^1.3.1",
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": "85775515ebd9e68d836d60ea1aa99ebdcde7771e"
92
+ "gitHead": "70c45e0eb9c745f7dbc0f8b6ce3654921cca11a0"
94
93
  }