@esri/hub-common 9.12.0 → 9.14.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.
Files changed (78) hide show
  1. package/dist/es2017/ArcGISContext.js +205 -0
  2. package/dist/es2017/ArcGISContext.js.map +1 -0
  3. package/dist/es2017/ArcGISContextManager.js +160 -0
  4. package/dist/es2017/ArcGISContextManager.js.map +1 -0
  5. package/dist/es2017/index.js +2 -0
  6. package/dist/es2017/index.js.map +1 -1
  7. package/dist/es2017/search/_searchContent.js +18 -7
  8. package/dist/es2017/search/_searchContent.js.map +1 -1
  9. package/dist/es2017/search/_searchGroups.js +1 -11
  10. package/dist/es2017/search/_searchGroups.js.map +1 -1
  11. package/dist/es2017/search/utils.js +1 -1
  12. package/dist/es2017/urls/getHubApiFromPortalUrl.js +21 -0
  13. package/dist/es2017/urls/getHubApiFromPortalUrl.js.map +1 -0
  14. package/dist/es2017/urls/getPortalBaseFromOrgUrl.js +25 -0
  15. package/dist/es2017/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  16. package/dist/es2017/urls/index.js +2 -0
  17. package/dist/es2017/urls/index.js.map +1 -1
  18. package/dist/es2017/utils/index.js +1 -0
  19. package/dist/es2017/utils/index.js.map +1 -1
  20. package/dist/es2017/utils/sessionLocalStorage.js +47 -0
  21. package/dist/es2017/utils/sessionLocalStorage.js.map +1 -0
  22. package/dist/esm/ArcGISContext.js +287 -0
  23. package/dist/esm/ArcGISContext.js.map +1 -0
  24. package/dist/esm/ArcGISContextManager.js +204 -0
  25. package/dist/esm/ArcGISContextManager.js.map +1 -0
  26. package/dist/esm/index.js +2 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/search/_searchContent.js +18 -7
  29. package/dist/esm/search/_searchContent.js.map +1 -1
  30. package/dist/esm/search/_searchGroups.js +3 -13
  31. package/dist/esm/search/_searchGroups.js.map +1 -1
  32. package/dist/esm/search/utils.js +1 -1
  33. package/dist/esm/urls/getHubApiFromPortalUrl.js +21 -0
  34. package/dist/esm/urls/getHubApiFromPortalUrl.js.map +1 -0
  35. package/dist/esm/urls/getPortalBaseFromOrgUrl.js +25 -0
  36. package/dist/esm/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  37. package/dist/esm/urls/index.js +2 -0
  38. package/dist/esm/urls/index.js.map +1 -1
  39. package/dist/esm/utils/index.js +1 -0
  40. package/dist/esm/utils/index.js.map +1 -1
  41. package/dist/esm/utils/sessionLocalStorage.js +50 -0
  42. package/dist/esm/utils/sessionLocalStorage.js.map +1 -0
  43. package/dist/node/ArcGISContext.js +209 -0
  44. package/dist/node/ArcGISContext.js.map +1 -0
  45. package/dist/node/ArcGISContextManager.js +164 -0
  46. package/dist/node/ArcGISContextManager.js.map +1 -0
  47. package/dist/node/index.js +2 -0
  48. package/dist/node/index.js.map +1 -1
  49. package/dist/node/search/_searchContent.js +17 -6
  50. package/dist/node/search/_searchContent.js.map +1 -1
  51. package/dist/node/search/_searchGroups.js +1 -11
  52. package/dist/node/search/_searchGroups.js.map +1 -1
  53. package/dist/node/search/utils.js +1 -1
  54. package/dist/node/urls/getHubApiFromPortalUrl.js +25 -0
  55. package/dist/node/urls/getHubApiFromPortalUrl.js.map +1 -0
  56. package/dist/node/urls/getPortalBaseFromOrgUrl.js +29 -0
  57. package/dist/node/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  58. package/dist/node/urls/index.js +2 -0
  59. package/dist/node/urls/index.js.map +1 -1
  60. package/dist/node/utils/index.js +1 -0
  61. package/dist/node/utils/index.js.map +1 -1
  62. package/dist/node/utils/sessionLocalStorage.js +53 -0
  63. package/dist/node/utils/sessionLocalStorage.js.map +1 -0
  64. package/dist/types/ArcGISContext.d.ts +136 -0
  65. package/dist/types/ArcGISContextManager.d.ts +113 -0
  66. package/dist/types/index.d.ts +2 -0
  67. package/dist/types/search/utils.d.ts +1 -1
  68. package/dist/types/types.d.ts +5 -2
  69. package/dist/types/urls/getHubApiFromPortalUrl.d.ts +8 -0
  70. package/dist/types/urls/getPortalBaseFromOrgUrl.d.ts +9 -0
  71. package/dist/types/urls/index.d.ts +2 -0
  72. package/dist/types/utils/index.d.ts +1 -0
  73. package/dist/types/utils/sessionLocalStorage.d.ts +23 -0
  74. package/dist/umd/common.umd.js +3330 -2709
  75. package/dist/umd/common.umd.js.map +1 -1
  76. package/dist/umd/common.umd.min.js +1 -1
  77. package/dist/umd/common.umd.min.js.map +1 -1
  78. package/package.json +1 -1
@@ -17,13 +17,12 @@ async function _searchContent(filter, options) {
17
17
  // API
18
18
  const api = _1.expandApi(options.api || "arcgis");
19
19
  let searchPromise;
20
- // map over the apis, depending on the type we issue the queries
21
- // const searchPromises = apis.map((api) => {
22
20
  // Portal Search
23
21
  if (api.type === "arcgis") {
24
22
  // serialize for portal
25
23
  const so = content_utils_1.serializeContentFilterForPortal(expanded);
26
- // pass auth forward
24
+ // if we have auth, pass it forward
25
+ // otherwise set the portal property
27
26
  if (options.authentication) {
28
27
  so.authentication = options.authentication;
29
28
  }
@@ -36,7 +35,6 @@ async function _searchContent(filter, options) {
36
35
  so.countSize = 200;
37
36
  }
38
37
  // copy over various options
39
- // TODO: Dry this up - typscript makes this... inconvenient
40
38
  if (options.num) {
41
39
  so.num = options.num;
42
40
  }
@@ -64,8 +62,6 @@ async function _searchContent(filter, options) {
64
62
  },
65
63
  });
66
64
  }
67
- // });
68
- // return for results
69
65
  return searchPromise;
70
66
  }
71
67
  exports._searchContent = _searchContent;
@@ -78,12 +74,27 @@ exports._searchContent = _searchContent;
78
74
  * @returns
79
75
  */
80
76
  function searchPortal(searchOptions) {
77
+ var _a;
78
+ const portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
79
+ let token;
80
+ if (searchOptions.authentication) {
81
+ const us = searchOptions.authentication;
82
+ token = us.token;
83
+ }
84
+ const thumbnailify = (content) => {
85
+ content.thumbnailUrl = __1.getItemThumbnailUrl(content, portalUrl, token);
86
+ return content;
87
+ };
81
88
  return arcgis_rest_portal_1.searchItems(searchOptions).then((resp) => {
82
89
  const hasNext = resp.nextStart > -1;
90
+ // convert items to IHubContent's
83
91
  let content = resp.results.map(__1.itemToContent);
92
+ // if we have a site, add those urls
84
93
  if (searchOptions.site) {
85
94
  content = content.map((entry) => __1.setContentSiteUrls(entry, searchOptions.site));
86
95
  }
96
+ // add thumbnailUrl
97
+ content = content.map(thumbnailify);
87
98
  // convert aggregations into facets
88
99
  const facets = content_utils_1.convertPortalResponseToFacets(resp);
89
100
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"_searchContent.js","sourceRoot":"","sources":["../../../src/search/_searchContent.ts"],"names":[],"mappings":";;;AAAA,mDAIyB;AAOzB,iEAAuE;AACvE,wBAA+C;AAC/C,0BAMY;AAEZ;;;;GAIG;AACI,KAAK,UAAU,cAAc,CAClC,MAAyB,EACzB,OAA0B;;IAE1B,kDAAkD;IAClD,MAAM,QAAQ,GAAG,mCAAmB,CAAC,MAAM,CAAC,CAAC;IAE7C,MAAM;IACN,MAAM,GAAG,GAAG,YAAS,CAAC,OAAO,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC;IAE/C,IAAI,aAAa,CAAC;IAClB,gEAAgE;IAChE,6CAA6C;IAC7C,gBAAgB;IAChB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;QACzB,uBAAuB;QACvB,MAAM,EAAE,GAAG,+CAA+B,CAAC,QAAQ,CAAC,CAAC;QACrD,oBAAoB;QACpB,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,EAAE,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;SAC5C;aAAM;YACL,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,eAAe,CAAC;SACvC;QACD,eAAe;QACf,UAAI,OAAO,CAAC,YAAY,0CAAE,MAAM,EAAE;YAChC,EAAE,CAAC,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,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;IAED,MAAM,YAAY,GAAG,CAAC,OAAoB,EAAE,EAAE;QAC5C,OAAO,CAAC,YAAY,GAAG,uBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACtE,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,gCAAW,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAY,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QAC7C,iCAAiC;QACjC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAa,CAAC,CAAC;QAC9C,oCAAoC;QACpC,IAAI,aAAa,CAAC,IAAI,EAAE;YACtB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9B,sBAAkB,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAC9C,CAAC;SACH;QACD,mBAAmB;QACnB,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACpC,mCAAmC;QACnC,MAAM,MAAM,GAAG,6CAA6B,CAAC,IAAI,CAAC,CAAC;QACnD,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,OAAO;YAChB,MAAM;YACN,OAAO;YACP,IAAI,EAAE,kBAAe,CACnB,aAAa,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAK,EACV,YAAY,CACb;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -14,25 +14,20 @@ const __1 = require("..");
14
14
  * @returns
15
15
  */
16
16
  async function _searchGroups(filter, options) {
17
- var _a;
18
17
  // expand filter so we can serialize to either api
19
18
  const expanded = group_utils_1.expandGroupFilter(filter);
20
19
  // API
21
20
  const api = _1.expandApi(options.api || "arcgis");
22
21
  if (api.type === "arcgis") {
23
22
  const so = group_utils_1.serializeGroupFilterForPortal(expanded);
24
- let token = "";
25
23
  // if we have auth, pass it forward
26
24
  // otherwise set the portal property
27
25
  if (options.authentication) {
28
26
  so.authentication = options.authentication;
29
- const us = options.authentication;
30
- token = us.token;
31
27
  }
32
28
  else {
33
29
  so.portal = `${api.url}/sharing/rest`;
34
30
  }
35
- // TODO: Dry this up - typscript makes this... inconvenient
36
31
  if (options.num) {
37
32
  so.num = options.num;
38
33
  }
@@ -42,10 +37,6 @@ async function _searchGroups(filter, options) {
42
37
  if (options.sortOrder) {
43
38
  so.sortOrder = options.sortOrder;
44
39
  }
45
- let portalUrl = `${api.url}/sharing/rest`;
46
- if ((_a = so.authentication) === null || _a === void 0 ? void 0 : _a.portal) {
47
- portalUrl = so.authentication.portal;
48
- }
49
40
  if (options.site) {
50
41
  so.site = __1.cloneObject(options.site);
51
42
  }
@@ -67,8 +58,7 @@ function searchPortalGroups(searchOptions) {
67
58
  group.siteTeamUrl = `${searchOptions.site.item.url}/teams/${group.id}/about`;
68
59
  return group;
69
60
  };
70
- const portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) ||
71
- "https://www.arcgis.com/sharing/rest";
61
+ const portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
72
62
  let token;
73
63
  if (searchOptions.authentication) {
74
64
  const us = searchOptions.authentication;
@@ -1 +1 @@
1
- {"version":3,"file":"_searchGroups.js","sourceRoot":"","sources":["../../../src/search/_searchGroups.ts"],"names":[],"mappings":";;;AAEA,iEAA6E;AAC7E,wBAA+C;AAC/C,+CAGuB;AAEvB,0BAAwE;AAMxE;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CACjC,MAAuB,EACvB,OAA0B;;IAE1B,kDAAkD;IAClD,MAAM,QAAQ,GAAG,+BAAiB,CAAC,MAAM,CAAC,CAAC;IAE3C,MAAM;IACN,MAAM,GAAG,GAAG,YAAS,CAAC,OAAO,CAAC,GAAG,IAAI,QAAQ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,CAAC,SAAS,EAClB,QAAQ,CAAC,KAAK,EACd,kBAAkB,CACnB;SACyB,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -366,7 +366,7 @@ exports.getNextFunction = getNextFunction;
366
366
  * Construct a the full url to a group thumbnail
367
367
  *
368
368
  * - If the group has a thumbnail, construct the full url
369
- * - If the group is not public, append on the token
369
+ * - If the group is not public, append on the token (if passed in)
370
370
  * @param portalUrl
371
371
  * @param group
372
372
  * @param token
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Cross-walk from a portalUrl to the corresponding Hub API Url
4
+ *
5
+ * If the passed url is not recognized, then this will return `undefined`
6
+ * @param portalUrl
7
+ * @returns
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getHubApiFromPortalUrl = void 0;
11
+ function getHubApiFromPortalUrl(portalUrl) {
12
+ let result;
13
+ if (portalUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
14
+ result = "https://hubqa.arcgis.com";
15
+ }
16
+ else if (portalUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
17
+ result = "https://hubdev.arcgis.com";
18
+ }
19
+ else if (portalUrl.match(/(www|\.maps)\.arcgis.com/)) {
20
+ result = "https://hub.arcgis.com";
21
+ }
22
+ return result;
23
+ }
24
+ exports.getHubApiFromPortalUrl = getHubApiFromPortalUrl;
25
+ //# sourceMappingURL=getHubApiFromPortalUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getHubApiFromPortalUrl.js","sourceRoot":"","sources":["../../../src/urls/getHubApiFromPortalUrl.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,SAAgB,sBAAsB,CAAC,SAAiB;IACtD,IAAI,MAAM,CAAC;IAEX,IAAI,SAAS,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QACnD,MAAM,GAAG,0BAA0B,CAAC;KACrC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC/D,MAAM,GAAG,2BAA2B,CAAC;KACtC;SAAM,IAAI,SAAS,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACtD,MAAM,GAAG,wBAAwB,CAAC;KACnC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAZD,wDAYC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPortalBaseFromOrgUrl = void 0;
4
+ /**
5
+ * Given an org url, get the portal base url
6
+ *
7
+ * i.e. https://myorg.maps.arcgis.com will return https://www.arcgis.com
8
+ *
9
+ * @param orgUrl
10
+ * @returns
11
+ */
12
+ function getPortalBaseFromOrgUrl(orgUrl) {
13
+ let result = orgUrl;
14
+ if (orgUrl.match(/(qaext|\.mapsqa)\.arcgis.com/)) {
15
+ result = "https://qaext.arcgis.com";
16
+ }
17
+ else if (orgUrl.match(/(devext|\.mapsdevext)\.arcgis.com/)) {
18
+ result = "https://devext.arcgis.com";
19
+ }
20
+ else {
21
+ /* istanbul ignore else */
22
+ if (orgUrl.match(/(www|\.maps)\.arcgis.com/)) {
23
+ result = "https://www.arcgis.com";
24
+ }
25
+ }
26
+ return result;
27
+ }
28
+ exports.getPortalBaseFromOrgUrl = getPortalBaseFromOrgUrl;
29
+ //# sourceMappingURL=getPortalBaseFromOrgUrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPortalBaseFromOrgUrl.js","sourceRoot":"","sources":["../../../src/urls/getPortalBaseFromOrgUrl.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,SAAgB,uBAAuB,CAAC,MAAc;IACpD,IAAI,MAAM,GAAG,MAAM,CAAC;IAEpB,IAAI,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,EAAE;QAChD,MAAM,GAAG,0BAA0B,CAAC;KACrC;SAAM,IAAI,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,EAAE;QAC5D,MAAM,GAAG,2BAA2B,CAAC;KACtC;SAAM;QACL,0BAA0B;QAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;YAC5C,MAAM,GAAG,wBAAwB,CAAC;SACnC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,0DAeC"}
@@ -18,6 +18,8 @@ tslib_1.__exportStar(require("./get-item-home-url"), exports);
18
18
  tslib_1.__exportStar(require("./get-item-api-url"), exports);
19
19
  tslib_1.__exportStar(require("./get-item-data-url"), exports);
20
20
  tslib_1.__exportStar(require("./convert-urls-to-anchor-tags"), exports);
21
+ tslib_1.__exportStar(require("./getHubApiFromPortalUrl"), exports);
22
+ tslib_1.__exportStar(require("./getPortalBaseFromOrgUrl"), exports);
21
23
  const MAP_OR_FEATURE_SERVER_URL_REGEX = /\/(map|feature)server/i;
22
24
  /**
23
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/urls/index.ts"],"names":[],"mappings":";;;;AAAA,kCAAqC;AACrC,sDAA4B;AAC5B,qEAA2C;AAC3C,+DAAqC;AACrC,2DAAiC;AACjC,2DAAiC;AACjC,6DAAmC;AACnC,2DAAiC;AACjC,qEAA2C;AAC3C,0DAAgC;AAChC,wEAA8C;AAC9C,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAE9C,MAAM,+BAA+B,GAAG,wBAAwB,CAAC;AAEjE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,CAAC,GAAW,EAAE,EAAE;IACrD,OAAO,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,YAAY,IAAI,GAAG,iBAAU,CAAC,YAAY,CAAC,UAAU,CAAC;AAC/D,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/urls/index.ts"],"names":[],"mappings":";;;;AAAA,kCAAqC;AACrC,sDAA4B;AAC5B,qEAA2C;AAC3C,+DAAqC;AACrC,2DAAiC;AACjC,2DAAiC;AACjC,6DAAmC;AACnC,2DAAiC;AACjC,qEAA2C;AAC3C,0DAAgC;AAChC,wEAA8C;AAC9C,oEAA0C;AAC1C,8DAAoC;AACpC,6DAAmC;AACnC,8DAAoC;AACpC,wEAA8C;AAC9C,mEAAyC;AACzC,oEAA0C;AAE1C,MAAM,+BAA+B,GAAG,wBAAwB,CAAC;AAEjE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,CAAC,GAAW,EAAE,EAAE;IACrD,OAAO,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,YAAY,IAAI,GAAG,iBAAU,CAAC,YAAY,CAAC,UAAU,CAAC;AAC/D,CAAC,CAAC"}
@@ -18,4 +18,5 @@ tslib_1.__exportStar(require("./increment-string"), exports);
18
18
  tslib_1.__exportStar(require("./logger"), exports);
19
19
  tslib_1.__exportStar(require("./is-update-group"), exports);
20
20
  tslib_1.__exportStar(require("./revertable-tasks"), exports);
21
+ tslib_1.__exportStar(require("./sessionLocalStorage"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,iEAAuC;AACvC,sEAA4C;AAC5C,sDAA4B;AAC5B,mEAAyC;AACzC,4DAAkC;AAClC,kEAAwC;AACxC,qDAA2B;AAC3B,oDAA0B;AAC1B,mDAAyB;AACzB,oDAA0B;AAC1B,4DAAkC;AAClC,2DAAiC;AACjC,6DAAmC;AACnC,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,iEAAuC;AACvC,sEAA4C;AAC5C,sDAA4B;AAC5B,mEAAyC;AACzC,4DAAkC;AAClC,kEAAwC;AACxC,qDAA2B;AAC3B,oDAA0B;AAC1B,mDAAyB;AACzB,oDAA0B;AAC1B,4DAAkC;AAClC,2DAAiC;AACjC,6DAAmC;AACnC,mDAAyB;AACzB,4DAAkC;AAClC,6DAAmC;AACnC,gEAAsC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveSession = exports.getSession = exports.clearSession = void 0;
4
+ const arcgis_rest_auth_1 = require("@esri/arcgis-rest-auth");
5
+ /**
6
+ * Remove any serialized sessions associated with the passed clientId
7
+ * from a browser's local storage
8
+ * @param clientId oAuth Client Id
9
+ * @param win optional window (used for testing)
10
+ */
11
+ function clearSession(clientId,
12
+ /* istanbul ignore next */
13
+ win = window) {
14
+ if (win.localStorage) {
15
+ win.localStorage.removeItem(`__CONTEXT_${clientId}`);
16
+ }
17
+ }
18
+ exports.clearSession = clearSession;
19
+ /**
20
+ * Re-hydrate a UserSession from a browser's local storage.
21
+ * If not found,
22
+ * @param clientId oAuth Client Id
23
+ * @param win optional window (used for testing)
24
+ * @returns
25
+ */
26
+ function getSession(clientId,
27
+ /* istanbul ignore next */
28
+ win = window) {
29
+ let result = null;
30
+ if (win.localStorage) {
31
+ const serializedSession = win.localStorage.getItem(`__CONTEXT_${clientId}`);
32
+ if (serializedSession) {
33
+ result = arcgis_rest_auth_1.UserSession.deserialize(serializedSession);
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ exports.getSession = getSession;
39
+ /**
40
+ * Serialize a UserSession into a browser's local storage
41
+ * @param clientId oAuth Client Id
42
+ * @param session UserSession
43
+ * @param win optional window (used for testing)
44
+ */
45
+ function saveSession(clientId, session,
46
+ /* istanbul ignore next */
47
+ win = window) {
48
+ if (win.localStorage) {
49
+ win.localStorage.setItem(`__CONTEXT_${clientId}`, session.serialize());
50
+ }
51
+ }
52
+ exports.saveSession = saveSession;
53
+ //# sourceMappingURL=sessionLocalStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionLocalStorage.js","sourceRoot":"","sources":["../../../src/utils/sessionLocalStorage.ts"],"names":[],"mappings":";;;AAAA,6DAAqD;AAErD;;;;;GAKG;AACH,SAAgB,YAAY,CAC1B,QAAgB;AAChB,0BAA0B;AAC1B,MAAW,MAAM;IAEjB,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;KACtD;AACH,CAAC;AARD,oCAQC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,QAAgB;AAChB,0BAA0B;AAC1B,MAAW,MAAM;IAEjB,IAAI,MAAM,GAAuB,IAAI,CAAC;IACtC,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,MAAM,iBAAiB,GAAG,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;QAC5E,IAAI,iBAAiB,EAAE;YACrB,MAAM,GAAG,8BAAW,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;SACrD;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAbD,gCAaC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,QAAgB,EAChB,OAAoB;AACpB,0BAA0B;AAC1B,MAAW,MAAM;IAEjB,IAAI,GAAG,CAAC,YAAY,EAAE;QACpB,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,QAAQ,EAAE,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;KACxE;AACH,CAAC;AATD,kCASC"}
@@ -0,0 +1,136 @@
1
+ import { IUser, IUserRequestOptions, UserSession } from "@esri/arcgis-rest-auth";
2
+ import { IPortal } from "@esri/arcgis-rest-portal";
3
+ import { IRequestOptions } from "@esri/arcgis-rest-request";
4
+ import { IHubRequestOptions } from ".";
5
+ /**
6
+ * Defines the properties of the ArcGISContext.
7
+ * Typically components or functions will get an instance
8
+ * of `ArcGISContext` from `ArcGISContetManager`.
9
+ *
10
+ * `ArcGISContext` implements this interface, and uses
11
+ * getters to simplify the derivation of various complex properties.
12
+ *
13
+ */
14
+ export interface IArcGISContext {
15
+ id: number;
16
+ session: UserSession;
17
+ isAuthenticated: boolean;
18
+ userRequestOptions: IUserRequestOptions;
19
+ requestOptions: IRequestOptions;
20
+ hubRequestOptions: IHubRequestOptions;
21
+ portalUrl: string;
22
+ sharingApiUrl: string;
23
+ hubUrl: string;
24
+ isPortal: boolean;
25
+ discussionsServiceUrl: string;
26
+ hubSearchServiceUrl: string;
27
+ domainServiceUrl: string;
28
+ eventsConfig: any;
29
+ hubEnabled: boolean;
30
+ communityOrgId: string;
31
+ communityOrgHostname: string;
32
+ communityOrgUrl: string;
33
+ helperServices: any;
34
+ currentUser: IUser;
35
+ portal: IPortal;
36
+ }
37
+ /**
38
+ * @internal
39
+ */
40
+ export interface IArcGISContextOptions {
41
+ id: number;
42
+ portalUrl: string;
43
+ hubUrl: string;
44
+ authentication?: UserSession;
45
+ portalSelf?: IPortal;
46
+ currentUser?: IUser;
47
+ }
48
+ /**
49
+ * ArcGISContext
50
+ *
51
+ * Abstraction that holds a UserSession, along with
52
+ * getters to streamline access to various platform
53
+ * urls, and common constructs like IRequestOptions
54
+ *
55
+ * Thin class just used to enable getters
56
+ *
57
+ * This class should not be used by anything other than
58
+ * the ArcGISContextManager class
59
+ */
60
+ export declare class ArcGISContext implements IArcGISContext {
61
+ id: number;
62
+ private _authentication;
63
+ private _portalUrl;
64
+ private _hubUrl;
65
+ private _portalSelf;
66
+ private _currentUser;
67
+ constructor(opts: IArcGISContextOptions);
68
+ /**
69
+ * Return the UserSession if authenticated
70
+ */
71
+ get session(): UserSession;
72
+ /**
73
+ * Return boolean indicating if authenticatio is present
74
+ */
75
+ get isAuthenticated(): boolean;
76
+ /**
77
+ * Return `IUserRequestOptions`, which is used for REST-JS
78
+ * functions which require authentication information.
79
+ *
80
+ * If context is not authenticated, this function will throw
81
+ */
82
+ get userRequestOptions(): IUserRequestOptions;
83
+ /**
84
+ * Return `IRequestOptions`, which is used by REST-JS functions
85
+ * which *may* use authentication information if provided.
86
+ *
87
+ * If context is not authenticated, this function just returns
88
+ * the `portal` property, which informs REST-JS what Sharing API
89
+ * instance to use (i.e. AGO, Enterprise etc)
90
+ */
91
+ get requestOptions(): IRequestOptions;
92
+ /**
93
+ * Return a `IHubRequestOptions` object
94
+ */
95
+ get hubRequestOptions(): IHubRequestOptions;
96
+ /**
97
+ * Return the portal url.
98
+ *
99
+ * If authenticated @ ArcGIS Online, it will return
100
+ * the https://org.env.arcgis.com
101
+ *
102
+ * If authenticated @ ArcGIS Enterprise, it will return
103
+ * https://portalHostname, which includes the web adaptor
104
+ */
105
+ get portalUrl(): string;
106
+ /**
107
+ * Returns the url to the sharing api
108
+ * i.e. https://myorg.maps.arcgis.com/sharing/rest
109
+ */
110
+ get sharingApiUrl(): string;
111
+ get hubUrl(): string;
112
+ /**
113
+ * Returns boolean indicating if the backing system
114
+ * is ArcGIS Enterprise (formerly ArcGIS Portal) or not
115
+ */
116
+ get isPortal(): boolean;
117
+ get discussionsServiceUrl(): string;
118
+ get hubSearchServiceUrl(): string;
119
+ get domainServiceUrl(): string;
120
+ get eventsConfig(): any;
121
+ /**
122
+ * Returns boolean indicating if the current user
123
+ * belongs to an organization that has licensed
124
+ * ArcGIS Hub
125
+ */
126
+ get hubEnabled(): boolean;
127
+ /**
128
+ * Return Hub Community Org Id, if defined
129
+ */
130
+ get communityOrgId(): string;
131
+ get communityOrgHostname(): string;
132
+ get communityOrgUrl(): string;
133
+ get helperServices(): any;
134
+ get currentUser(): IUser;
135
+ get portal(): IPortal;
136
+ }
@@ -0,0 +1,113 @@
1
+ import { IPortal } from "@esri/arcgis-rest-portal";
2
+ import { IUser, UserSession } from "@esri/arcgis-rest-auth";
3
+ import { IArcGISContext } from "./ArcGISContext";
4
+ import { Level } from ".";
5
+ /**
6
+ * Options that can be passed into `ArcGISContextManager.create`
7
+ */
8
+ export interface IArcGISContextManagerOptions {
9
+ /**
10
+ * Existing user session, which may be created from Identity Manager
11
+ * `const session = UserSession.fromCredential(idMgr.getCredential());`
12
+ */
13
+ authentication?: UserSession;
14
+ /**
15
+ * ArcGIS Online or ArcGIS Enterprise portal url.
16
+ * Do not include `/sharing/rest`
17
+ * Defaults to `https://www.arcgis.com`
18
+ * For ArcGIS Enterprise, you must include the webadaptor name.
19
+ * i.e. https://gis.mytown.gov/portal
20
+ *
21
+ * When Authentication is present, the UserSession.portal value is
22
+ * used instead of this property.
23
+ */
24
+ portalUrl?: string;
25
+ /**
26
+ * Portal self for the authenticated user. If not passed into `.create`
27
+ * with the UserSession, it will be fetched
28
+ */
29
+ portal?: IPortal;
30
+ /**
31
+ * Current user as `IUser`. If not passed into `.create` with the UserSession
32
+ * it will be fetched.
33
+ */
34
+ currentUser?: IUser;
35
+ /**
36
+ * Logging level
37
+ * off > error > warn > info > debug > all
38
+ * defaults to 'error'
39
+ */
40
+ logLevel?: Level;
41
+ }
42
+ /**
43
+ * ArcGIS Context Manager
44
+ *
45
+ * The manager exposes context (`IArcGISContext`), which combines a `UserSession` with
46
+ * the `portal/self` and `user/self` responses to provide a central lookup for platform
47
+ * information, api urls, and other useful properties for developers such as IRequestOptions
48
+ * IUserRequestOptions, IHubRequestOptions etc.
49
+ *
50
+ * The context is exposed on gthe `.context` property, and as the authentication changes
51
+ * the `.context` is re-created. This is done to allow web frameworks to watch for
52
+ * changes on that single property, instead of having to leverage observers or events
53
+ * for change detection.
54
+ *
55
+ * This is a work-in-progress, and will likely expand over time.
56
+ *
57
+ */
58
+ export declare class ArcGISContextManager {
59
+ /**
60
+ * Random identifier useful for debugging issues
61
+ * where race-conditions can result in multiple
62
+ * contexts getting created
63
+ */
64
+ id: number;
65
+ private _context;
66
+ private _authentication;
67
+ private _portalUrl;
68
+ private _hubUrl;
69
+ private _portalSelf;
70
+ private _currentUser;
71
+ private _logLevel;
72
+ /**
73
+ * Private constructor. Use `ArcGISContextManager.create(...)` to
74
+ * instantiate an instance
75
+ * @param opts
76
+ */
77
+ private constructor();
78
+ /**
79
+ * Static async Factory
80
+ * @param opts
81
+ * @returns
82
+ */
83
+ static create(opts?: IArcGISContextManagerOptions): Promise<ArcGISContextManager>;
84
+ /**
85
+ * Set the Authentication (UserSession) for the context.
86
+ * This should be called when a user signs into a running
87
+ * application.
88
+ * @param auth
89
+ */
90
+ setAuthentication(auth: UserSession): Promise<void>;
91
+ /**
92
+ * Clear the Authentication (UserSession). This should be
93
+ * called when a user signs out of an application, but
94
+ * the application continues running
95
+ */
96
+ clearAuthentication(): void;
97
+ /**
98
+ * Return a reference to the current state.
99
+ * When `.setAuthentication()` or `.clearAuthenentication()` are
100
+ * called, the state will be re-created. This is done so frameworks
101
+ * like React or Ember can detect changes.
102
+ */
103
+ get context(): IArcGISContext;
104
+ /**
105
+ * If we have a UserSession, fetch portal/self and
106
+ * store that along with current user
107
+ */
108
+ private initialize;
109
+ /**
110
+ * Getter to streamline the creation of updated Context instances
111
+ */
112
+ private get contextOpts();
113
+ }
@@ -18,6 +18,8 @@ export * from "./utils";
18
18
  export * from "./i18n";
19
19
  export * from "./request";
20
20
  export * from "./surveys";
21
+ export * from "./ArcGISContextManager";
22
+ export * from "./ArcGISContext";
21
23
  import OperationStack from "./OperationStack";
22
24
  import OperationError from "./OperationError";
23
25
  export { OperationStack, OperationError };
@@ -104,7 +104,7 @@ export declare function getNextFunction<T>(request: ISearchOptions, nextStart: n
104
104
  * Construct a the full url to a group thumbnail
105
105
  *
106
106
  * - If the group has a thumbnail, construct the full url
107
- * - If the group is not public, append on the token
107
+ * - If the group is not public, append on the token (if passed in)
108
108
  * @param portalUrl
109
109
  * @param group
110
110
  * @param token
@@ -82,7 +82,11 @@ export interface ISolutionTemplate extends IModel {
82
82
  };
83
83
  }
84
84
  export declare type GenericAsyncFunc = (...args: any) => Promise<any>;
85
- interface IHubRequestOptionsPortalSelf extends IPortal {
85
+ /**
86
+ * @internal
87
+ * This just adds user to the IPortal interface
88
+ */
89
+ export interface IHubRequestOptionsPortalSelf extends IPortal {
86
90
  user?: IUser;
87
91
  }
88
92
  export interface IHubRequestOptions extends IRequestOptions {
@@ -415,4 +419,3 @@ export interface ISearchResponse<T> {
415
419
  next: (params?: any) => Promise<ISearchResponse<T>>;
416
420
  facets?: IFacet[];
417
421
  }
418
- export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cross-walk from a portalUrl to the corresponding Hub API Url
3
+ *
4
+ * If the passed url is not recognized, then this will return `undefined`
5
+ * @param portalUrl
6
+ * @returns
7
+ */
8
+ export declare function getHubApiFromPortalUrl(portalUrl: string): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Given an org url, get the portal base url
3
+ *
4
+ * i.e. https://myorg.maps.arcgis.com will return https://www.arcgis.com
5
+ *
6
+ * @param orgUrl
7
+ * @returns
8
+ */
9
+ export declare function getPortalBaseFromOrgUrl(orgUrl: string): string;
@@ -13,6 +13,8 @@ export * from "./get-item-home-url";
13
13
  export * from "./get-item-api-url";
14
14
  export * from "./get-item-data-url";
15
15
  export * from "./convert-urls-to-anchor-tags";
16
+ export * from "./getHubApiFromPortalUrl";
17
+ export * from "./getPortalBaseFromOrgUrl";
16
18
  /**
17
19
  *
18
20
  * @param url
@@ -15,3 +15,4 @@ export * from "./increment-string";
15
15
  export * from "./logger";
16
16
  export * from "./is-update-group";
17
17
  export * from "./revertable-tasks";
18
+ export * from "./sessionLocalStorage";
@@ -0,0 +1,23 @@
1
+ import { UserSession } from "@esri/arcgis-rest-auth";
2
+ /**
3
+ * Remove any serialized sessions associated with the passed clientId
4
+ * from a browser's local storage
5
+ * @param clientId oAuth Client Id
6
+ * @param win optional window (used for testing)
7
+ */
8
+ export declare function clearSession(clientId: string, win?: any): void;
9
+ /**
10
+ * Re-hydrate a UserSession from a browser's local storage.
11
+ * If not found,
12
+ * @param clientId oAuth Client Id
13
+ * @param win optional window (used for testing)
14
+ * @returns
15
+ */
16
+ export declare function getSession(clientId: string, win?: any): UserSession | null;
17
+ /**
18
+ * Serialize a UserSession into a browser's local storage
19
+ * @param clientId oAuth Client Id
20
+ * @param session UserSession
21
+ * @param win optional window (used for testing)
22
+ */
23
+ export declare function saveSession(clientId: string, session: UserSession, win?: any): void;