@esri/hub-common 9.49.1 → 10.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/es2017/categories.js +4 -2
  2. package/dist/es2017/categories.js.map +1 -1
  3. package/dist/es2017/collections.js +3 -8
  4. package/dist/es2017/collections.js.map +1 -1
  5. package/dist/es2017/content/compose.js +1 -18
  6. package/dist/es2017/content/compose.js.map +1 -1
  7. package/dist/es2017/content/get-family.js +1 -3
  8. package/dist/es2017/content/get-family.js.map +1 -1
  9. package/dist/es2017/content/index.js +8 -71
  10. package/dist/es2017/content/index.js.map +1 -1
  11. package/dist/es2017/extent.js +1 -14
  12. package/dist/es2017/extent.js.map +1 -1
  13. package/dist/es2017/index.js +1 -0
  14. package/dist/es2017/index.js.map +1 -1
  15. package/dist/es2017/projects/HubProjectManager.js +0 -8
  16. package/dist/es2017/projects/HubProjectManager.js.map +1 -1
  17. package/dist/es2017/projects/HubProjects.js.map +1 -1
  18. package/dist/es2017/search/_internal/hubSearchItems.js +3 -137
  19. package/dist/es2017/search/_internal/hubSearchItems.js.map +1 -1
  20. package/dist/es2017/search/_internal/index.js +0 -1
  21. package/dist/es2017/search/_internal/index.js.map +1 -1
  22. package/dist/es2017/search/_internal/portalSearchGroups.js +0 -1
  23. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  24. package/dist/es2017/search/_internal/portalSearchItems.js +4 -29
  25. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  26. package/dist/es2017/search/_internal/portalSearchUsers.js +0 -1
  27. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
  28. package/dist/es2017/search/hubSearch.js +0 -16
  29. package/dist/es2017/search/hubSearch.js.map +1 -1
  30. package/dist/es2017/search/index.js +0 -9
  31. package/dist/es2017/search/index.js.map +1 -1
  32. package/dist/es2017/search/serializeQueryForPortal.js +0 -1
  33. package/dist/es2017/search/serializeQueryForPortal.js.map +1 -1
  34. package/dist/es2017/search/types/index.js +0 -5
  35. package/dist/es2017/search/types/index.js.map +1 -1
  36. package/dist/es2017/search/upgradeCatalogSchema.js +0 -8
  37. package/dist/es2017/search/upgradeCatalogSchema.js.map +1 -1
  38. package/dist/es2017/search/utils.js +1 -207
  39. package/dist/es2017/search/utils.js.map +1 -1
  40. package/dist/es2017/sites/fetchSiteModel.js +0 -9
  41. package/dist/es2017/sites/fetchSiteModel.js.map +1 -1
  42. package/dist/es2017/types.js.map +1 -1
  43. package/dist/esm/categories.js +4 -2
  44. package/dist/esm/categories.js.map +1 -1
  45. package/dist/esm/collections.js +3 -8
  46. package/dist/esm/collections.js.map +1 -1
  47. package/dist/esm/content/compose.js +1 -18
  48. package/dist/esm/content/compose.js.map +1 -1
  49. package/dist/esm/content/get-family.js +1 -3
  50. package/dist/esm/content/get-family.js.map +1 -1
  51. package/dist/esm/content/index.js +8 -71
  52. package/dist/esm/content/index.js.map +1 -1
  53. package/dist/esm/extent.js +1 -14
  54. package/dist/esm/extent.js.map +1 -1
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/projects/HubProjectManager.js +0 -12
  58. package/dist/esm/projects/HubProjectManager.js.map +1 -1
  59. package/dist/esm/projects/HubProjects.js.map +1 -1
  60. package/dist/esm/search/_internal/hubSearchItems.js +4 -146
  61. package/dist/esm/search/_internal/hubSearchItems.js.map +1 -1
  62. package/dist/esm/search/_internal/index.js +0 -1
  63. package/dist/esm/search/_internal/index.js.map +1 -1
  64. package/dist/esm/search/_internal/portalSearchGroups.js +0 -1
  65. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  66. package/dist/esm/search/_internal/portalSearchItems.js +5 -29
  67. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  68. package/dist/esm/search/_internal/portalSearchUsers.js +0 -1
  69. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
  70. package/dist/esm/search/hubSearch.js +0 -20
  71. package/dist/esm/search/hubSearch.js.map +1 -1
  72. package/dist/esm/search/index.js +0 -9
  73. package/dist/esm/search/index.js.map +1 -1
  74. package/dist/esm/search/serializeQueryForPortal.js +0 -1
  75. package/dist/esm/search/serializeQueryForPortal.js.map +1 -1
  76. package/dist/esm/search/types/index.js +0 -5
  77. package/dist/esm/search/types/index.js.map +1 -1
  78. package/dist/esm/search/upgradeCatalogSchema.js +0 -8
  79. package/dist/esm/search/upgradeCatalogSchema.js.map +1 -1
  80. package/dist/esm/search/utils.js +1 -204
  81. package/dist/esm/search/utils.js.map +1 -1
  82. package/dist/esm/sites/fetchSiteModel.js +0 -9
  83. package/dist/esm/sites/fetchSiteModel.js.map +1 -1
  84. package/dist/esm/types.js.map +1 -1
  85. package/dist/node/categories.js +4 -2
  86. package/dist/node/categories.js.map +1 -1
  87. package/dist/node/collections.js +3 -8
  88. package/dist/node/collections.js.map +1 -1
  89. package/dist/node/content/compose.js +1 -18
  90. package/dist/node/content/compose.js.map +1 -1
  91. package/dist/node/content/get-family.js +1 -3
  92. package/dist/node/content/get-family.js.map +1 -1
  93. package/dist/node/content/index.js +9 -73
  94. package/dist/node/content/index.js.map +1 -1
  95. package/dist/node/extent.js +2 -16
  96. package/dist/node/extent.js.map +1 -1
  97. package/dist/node/index.js +1 -0
  98. package/dist/node/index.js.map +1 -1
  99. package/dist/node/projects/HubProjectManager.js +0 -8
  100. package/dist/node/projects/HubProjectManager.js.map +1 -1
  101. package/dist/node/projects/HubProjects.js.map +1 -1
  102. package/dist/node/search/_internal/hubSearchItems.js +4 -139
  103. package/dist/node/search/_internal/hubSearchItems.js.map +1 -1
  104. package/dist/node/search/_internal/index.js +0 -1
  105. package/dist/node/search/_internal/index.js.map +1 -1
  106. package/dist/node/search/_internal/portalSearchGroups.js +0 -1
  107. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  108. package/dist/node/search/_internal/portalSearchItems.js +4 -29
  109. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  110. package/dist/node/search/_internal/portalSearchUsers.js +0 -1
  111. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
  112. package/dist/node/search/hubSearch.js +1 -18
  113. package/dist/node/search/hubSearch.js.map +1 -1
  114. package/dist/node/search/index.js +0 -9
  115. package/dist/node/search/index.js.map +1 -1
  116. package/dist/node/search/serializeQueryForPortal.js +0 -1
  117. package/dist/node/search/serializeQueryForPortal.js.map +1 -1
  118. package/dist/node/search/types/index.js +0 -5
  119. package/dist/node/search/types/index.js.map +1 -1
  120. package/dist/node/search/upgradeCatalogSchema.js +1 -10
  121. package/dist/node/search/upgradeCatalogSchema.js.map +1 -1
  122. package/dist/node/search/utils.js +1 -213
  123. package/dist/node/search/utils.js.map +1 -1
  124. package/dist/node/sites/fetchSiteModel.js +1 -11
  125. package/dist/node/sites/fetchSiteModel.js.map +1 -1
  126. package/dist/node/types.js.map +1 -1
  127. package/dist/types/collections.d.ts +1 -6
  128. package/dist/types/content/_internal.d.ts +0 -3
  129. package/dist/types/content/get-family.d.ts +1 -1
  130. package/dist/types/content/index.d.ts +3 -36
  131. package/dist/types/core/types/IHubContent.d.ts +0 -3
  132. package/dist/types/core/types/IServerEnrichments.d.ts +0 -2
  133. package/dist/types/extent.d.ts +0 -2
  134. package/dist/types/projects/HubProjectManager.d.ts +0 -1
  135. package/dist/types/search/_internal/hubSearchItems.d.ts +3 -4
  136. package/dist/types/search/_internal/index.d.ts +0 -1
  137. package/dist/types/search/_internal/portalSearchItems.d.ts +15 -15
  138. package/dist/types/search/hubSearch.d.ts +0 -13
  139. package/dist/types/search/index.d.ts +0 -9
  140. package/dist/types/search/types/IHubSearchOptions.d.ts +1 -17
  141. package/dist/types/search/types/IHubSearchResponse.d.ts +0 -5
  142. package/dist/types/search/types/IHubSearchResult.d.ts +0 -39
  143. package/dist/types/search/types/index.d.ts +0 -5
  144. package/dist/types/search/types/types.d.ts +0 -206
  145. package/dist/types/search/upgradeCatalogSchema.d.ts +0 -5
  146. package/dist/types/search/utils.d.ts +2 -58
  147. package/dist/types/sites/fetchSiteModel.d.ts +2 -6
  148. package/dist/types/types.d.ts +0 -70
  149. package/dist/umd/common.umd.js +42 -1900
  150. package/dist/umd/common.umd.js.map +1 -1
  151. package/package.json +1 -1
  152. package/dist/es2017/search/_internal/state.js +0 -155
  153. package/dist/es2017/search/_internal/state.js.map +0 -1
  154. package/dist/es2017/search/_searchContent.js +0 -116
  155. package/dist/es2017/search/_searchContent.js.map +0 -1
  156. package/dist/es2017/search/_searchGroups.js +0 -88
  157. package/dist/es2017/search/_searchGroups.js.map +0 -1
  158. package/dist/es2017/search/_searchUsers.js +0 -89
  159. package/dist/es2017/search/_searchUsers.js.map +0 -1
  160. package/dist/es2017/search/collectionState.js +0 -60
  161. package/dist/es2017/search/collectionState.js.map +0 -1
  162. package/dist/es2017/search/content-utils.js +0 -455
  163. package/dist/es2017/search/content-utils.js.map +0 -1
  164. package/dist/es2017/search/filter-utils.js +0 -31
  165. package/dist/es2017/search/filter-utils.js.map +0 -1
  166. package/dist/es2017/search/group-utils.js +0 -142
  167. package/dist/es2017/search/group-utils.js.map +0 -1
  168. package/dist/es2017/search/hub-api-search.js +0 -19
  169. package/dist/es2017/search/hub-api-search.js.map +0 -1
  170. package/dist/es2017/search/types/ICatalog.js +0 -1
  171. package/dist/es2017/search/types/ICatalog.js.map +0 -1
  172. package/dist/es2017/search/types/ICollection.js +0 -1
  173. package/dist/es2017/search/types/ICollection.js.map +0 -1
  174. package/dist/es2017/search/types/IFacet.js +0 -1
  175. package/dist/es2017/search/types/IFacet.js.map +0 -1
  176. package/dist/es2017/search/types/IFacetOption.js +0 -1
  177. package/dist/es2017/search/types/IFacetOption.js.map +0 -1
  178. package/dist/es2017/search/types/IHubApiSearchRequest.js +0 -1
  179. package/dist/es2017/search/types/IHubApiSearchRequest.js.map +0 -1
  180. package/dist/es2017/search/user-utils.js +0 -139
  181. package/dist/es2017/search/user-utils.js.map +0 -1
  182. package/dist/esm/search/_internal/state.js +0 -155
  183. package/dist/esm/search/_internal/state.js.map +0 -1
  184. package/dist/esm/search/_searchContent.js +0 -118
  185. package/dist/esm/search/_searchContent.js.map +0 -1
  186. package/dist/esm/search/_searchGroups.js +0 -91
  187. package/dist/esm/search/_searchGroups.js.map +0 -1
  188. package/dist/esm/search/_searchUsers.js +0 -92
  189. package/dist/esm/search/_searchUsers.js.map +0 -1
  190. package/dist/esm/search/collectionState.js +0 -61
  191. package/dist/esm/search/collectionState.js.map +0 -1
  192. package/dist/esm/search/content-utils.js +0 -462
  193. package/dist/esm/search/content-utils.js.map +0 -1
  194. package/dist/esm/search/filter-utils.js +0 -31
  195. package/dist/esm/search/filter-utils.js.map +0 -1
  196. package/dist/esm/search/group-utils.js +0 -146
  197. package/dist/esm/search/group-utils.js.map +0 -1
  198. package/dist/esm/search/hub-api-search.js +0 -20
  199. package/dist/esm/search/hub-api-search.js.map +0 -1
  200. package/dist/esm/search/types/ICatalog.js +0 -1
  201. package/dist/esm/search/types/ICatalog.js.map +0 -1
  202. package/dist/esm/search/types/ICollection.js +0 -1
  203. package/dist/esm/search/types/ICollection.js.map +0 -1
  204. package/dist/esm/search/types/IFacet.js +0 -1
  205. package/dist/esm/search/types/IFacet.js.map +0 -1
  206. package/dist/esm/search/types/IFacetOption.js +0 -1
  207. package/dist/esm/search/types/IFacetOption.js.map +0 -1
  208. package/dist/esm/search/types/IHubApiSearchRequest.js +0 -1
  209. package/dist/esm/search/types/IHubApiSearchRequest.js.map +0 -1
  210. package/dist/esm/search/user-utils.js +0 -143
  211. package/dist/esm/search/user-utils.js.map +0 -1
  212. package/dist/node/search/_internal/state.js +0 -166
  213. package/dist/node/search/_internal/state.js.map +0 -1
  214. package/dist/node/search/_searchContent.js +0 -120
  215. package/dist/node/search/_searchContent.js.map +0 -1
  216. package/dist/node/search/_searchGroups.js +0 -92
  217. package/dist/node/search/_searchGroups.js.map +0 -1
  218. package/dist/node/search/_searchUsers.js +0 -93
  219. package/dist/node/search/_searchUsers.js.map +0 -1
  220. package/dist/node/search/collectionState.js +0 -65
  221. package/dist/node/search/collectionState.js.map +0 -1
  222. package/dist/node/search/content-utils.js +0 -466
  223. package/dist/node/search/content-utils.js.map +0 -1
  224. package/dist/node/search/filter-utils.js +0 -36
  225. package/dist/node/search/filter-utils.js.map +0 -1
  226. package/dist/node/search/group-utils.js +0 -148
  227. package/dist/node/search/group-utils.js.map +0 -1
  228. package/dist/node/search/hub-api-search.js +0 -23
  229. package/dist/node/search/hub-api-search.js.map +0 -1
  230. package/dist/node/search/types/ICatalog.js +0 -3
  231. package/dist/node/search/types/ICatalog.js.map +0 -1
  232. package/dist/node/search/types/ICollection.js +0 -3
  233. package/dist/node/search/types/ICollection.js.map +0 -1
  234. package/dist/node/search/types/IFacet.js +0 -3
  235. package/dist/node/search/types/IFacet.js.map +0 -1
  236. package/dist/node/search/types/IFacetOption.js +0 -3
  237. package/dist/node/search/types/IFacetOption.js.map +0 -1
  238. package/dist/node/search/types/IHubApiSearchRequest.js +0 -3
  239. package/dist/node/search/types/IHubApiSearchRequest.js.map +0 -1
  240. package/dist/node/search/user-utils.js +0 -145
  241. package/dist/node/search/user-utils.js.map +0 -1
  242. package/dist/types/search/_internal/state.d.ts +0 -70
  243. package/dist/types/search/_searchContent.d.ts +0 -9
  244. package/dist/types/search/_searchGroups.d.ts +0 -17
  245. package/dist/types/search/_searchUsers.d.ts +0 -31
  246. package/dist/types/search/collectionState.d.ts +0 -19
  247. package/dist/types/search/content-utils.d.ts +0 -83
  248. package/dist/types/search/filter-utils.d.ts +0 -13
  249. package/dist/types/search/group-utils.d.ts +0 -36
  250. package/dist/types/search/hub-api-search.d.ts +0 -10
  251. package/dist/types/search/types/ICatalog.d.ts +0 -87
  252. package/dist/types/search/types/ICollection.d.ts +0 -28
  253. package/dist/types/search/types/IFacet.d.ts +0 -62
  254. package/dist/types/search/types/IFacetOption.d.ts +0 -30
  255. package/dist/types/search/types/IHubApiSearchRequest.d.ts +0 -16
  256. package/dist/types/search/user-utils.d.ts +0 -35
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.49.0 - Tue Jul 26 2022 19:34:30 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v10.0.0-next.2 - Thu Jul 28 2022 19:50:35 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -6188,15 +6188,10 @@
6188
6188
  ];
6189
6189
  var site$1 = ["Hub Site Application", "Site Application"];
6190
6190
  /**
6191
- * ```js
6192
- * import { getCollection } from "@esri/hub-common";
6193
- * //
6194
- * getCollection('Feature Layer')
6195
- * > 'dataset'
6196
- * ```
6197
6191
  * Get the Hub collection for a given item type
6198
6192
  * @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
6199
6193
  * @returns the Hub collection of a given item type.
6194
+ * @private
6200
6195
  */
6201
6196
  var getCollection = function (type) {
6202
6197
  if (!type) {
@@ -6208,8 +6203,8 @@
6208
6203
  return collectionTypes.some(function (t) { return t.toLocaleLowerCase() === lowerCaseType; });
6209
6204
  });
6210
6205
  };
6211
- // TODO: remove this at the next breaking change
6212
- // it's only here to support deprecated categories
6206
+ // TODO: remove this when we remove the deprecated categories
6207
+ // and then move the above arrays and getCollection() logic to get-family
6213
6208
  var collections = {
6214
6209
  app: app$1,
6215
6210
  dataset: dataset$1,
@@ -6272,8 +6267,10 @@
6272
6267
  ];
6273
6268
  var downloadableTypeKeywords = ["Data"];
6274
6269
  var apiTypes = ["Feature Service", "Map Service", "Image Service"];
6275
- // TODO: remove this at next breaking version
6276
- // we're just keeping this for backwards compatibility
6270
+ // DEPRECATED: remove this at next breaking version
6271
+ // this is currently used by hub-search and opendata-ui
6272
+ // (in the dataset-display and content-library-engine)
6273
+ // TODO: remove this once it is no longer used in those places
6277
6274
  var categories = {
6278
6275
  app: app.concat(feedback),
6279
6276
  dataset: dataset,
@@ -6567,12 +6564,6 @@
6567
6564
  Array.isArray(extent[0]) &&
6568
6565
  Array.isArray(extent[1]));
6569
6566
  };
6570
- function isExtentCoordinateArray(extent) {
6571
- /* tslint:disable no-console */
6572
- console.warn("DEPRECATED: use isBBox() instead");
6573
- /* tslint:enable no-console */
6574
- return isBBox(extent);
6575
- }
6576
6567
  function isExtentJSON(extent) {
6577
6568
  return ["xmin", "ymin", "xmax", "ymax"].every(function (key) { return typeof extent[key] === "number"; });
6578
6569
  }
@@ -6582,15 +6573,8 @@
6582
6573
  * @return {Boolean} indicator
6583
6574
  */
6584
6575
  function isValidExtent(extent) {
6585
- return (!!extent &&
6586
- [isExtentCoordinateArray, isExtentJSON].some(function (test) { return test(extent); }));
6576
+ return !!extent && [isBBox, isExtentJSON].some(function (test) { return test(extent); });
6587
6577
  }
6588
- /* istanbul ignore next DEPRECATED, remove at next breaking change */
6589
- var bBoxToPolygon = function (bBox) {
6590
- /* tslint:disable no-console */
6591
- console.warn("DEPRECATED: use extentToPolygon(bBoxToExtent(bBox)) instead");
6592
- return extentToPolygon(bBoxToExtent(bBox));
6593
- };
6594
6578
  /**
6595
6579
  * Convert an extent object into a polygon object
6596
6580
  * @param extent
@@ -6641,9 +6625,7 @@
6641
6625
  var family;
6642
6626
  // override default behavior for the rows that are highlighted in yellow here:
6643
6627
  // https://esriis.sharepoint.com/:x:/r/sites/ArcGISHub/_layouts/15/Doc.aspx?sourcedoc=%7BADA1C9DC-4F6C-4DE4-92C6-693EF9571CFA%7D&file=Hub%20Routes.xlsx&nav=MTBfe0VENEREQzI4LUZFMDctNEI0Ri04NjcyLThCQUE2MTA0MEZGRn1fezIwMTIwMEJFLTA4MEQtNEExRC05QzA4LTE5MTAzOUQwMEE1RH0&action=default&mobileredirect=true&cid=df1c874b-c367-4cea-bc13-7bebfad3f2ac
6644
- // DEPRECATED: we should make type a required parameter
6645
- // and just do type.toLowerCase() at the next breaking change
6646
- switch ((type || "").toLowerCase()) {
6628
+ switch (type.toLowerCase()) {
6647
6629
  case "image service":
6648
6630
  family = "dataset";
6649
6631
  break;
@@ -8044,9 +8026,7 @@
8044
8026
  return item.properties && item.properties.metrics;
8045
8027
  }, get spatialReference() {
8046
8028
  var _a;
8047
- // NOTE: I had to add || null just so packages/content/test/portal.test.ts would pass
8048
- // we can remove that when that package is deprecated
8049
- return (((_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference) || getItemSpatialReference(item) || null);
8029
+ return ((_a = layer === null || layer === void 0 ? void 0 : layer.extent) === null || _a === void 0 ? void 0 : _a.spatialReference) || getItemSpatialReference(item);
8050
8030
  },
8051
8031
  get viewDefinition() {
8052
8032
  // if this is a layer view and we have the item data
@@ -8064,21 +8044,6 @@
8064
8044
  /* Note: only returns calcite-icons */
8065
8045
  return getContentTypeIcon(type);
8066
8046
  },
8067
- // deprecated properties
8068
- // TODO: should we add these in legacy wrappers
8069
- // like itemToContent or datasetToContent instead?
8070
- get license() {
8071
- /* tslint:disable no-console */
8072
- console.warn("DEPRECATED: use structuredLicense instead");
8073
- /* tslint:enable no-console */
8074
- return { name: "Custom License", description: item.accessInformation };
8075
- },
8076
- get hubType() {
8077
- /* tslint:disable no-console */
8078
- console.warn("DEPRECATED: use family instead");
8079
- /* tslint:enable no-console */
8080
- return getFamily(type);
8081
- },
8082
8047
  get additionalResources() {
8083
8048
  return getAdditionalResources(item, metadata);
8084
8049
  } });
@@ -12200,15 +12165,16 @@
12200
12165
  * getCategory('Feature Layer')
12201
12166
  * > 'dataset'
12202
12167
  * ```
12203
- * **DEPRECATED: Use getCollection() instead**
12168
+ * **DEPRECATED: Use getFamily() instead**
12204
12169
  * returns the Hub category for a given item type
12205
12170
  * @param itemType The ArcGIS [item type](https://developers.arcgis.com/rest/users-groups-and-items/items-and-item-types.htm).
12206
12171
  * @returns the category of a given item type.
12207
12172
  */
12173
+ /* istanbul ignore next deprecated */
12208
12174
  function getCategory(itemType) {
12209
12175
  if (itemType === void 0) { itemType = ""; }
12210
12176
  /* tslint:disable no-console */
12211
- console.warn("DEPRECATED: Use getCollection() instead. getCategory will be removed at v10.0.0");
12177
+ console.warn("DEPRECATED: Use getFamily() instead. getCategory will be removed at the next breaking version");
12212
12178
  /* tslint:enable no-console */
12213
12179
  var collection = getCollection(itemType);
12214
12180
  // for backwards compatibility
@@ -12237,12 +12203,17 @@
12237
12203
  * getTypeCategories(item)
12238
12204
  * > [ 'Hub Site Application' ]
12239
12205
  * ```
12206
+ * **DEPRECATED: getTypeCategories will be removed at the next breaking version**
12240
12207
  * @param item Item object.
12241
12208
  * @returns typeCategory of the input item.
12242
12209
  *
12243
12210
  */
12211
+ /* istanbul ignore next deprecated */
12244
12212
  function getTypeCategories(item) {
12245
12213
  if (item === void 0) { item = {}; }
12214
+ /* tslint:disable no-console */
12215
+ console.warn("DEPRECATED: getTypeCategories will be removed at the next breaking version");
12216
+ /* tslint:enable no-console */
12246
12217
  var type = normalizeItemType(item);
12247
12218
  var category = getCategory(type);
12248
12219
  if (category) {
@@ -12307,24 +12278,6 @@
12307
12278
  }
12308
12279
  return content.hubId || content.id;
12309
12280
  }
12310
- /**
12311
- * DEPRECATED: Use getFamily() instead.
12312
- *
12313
- * get the HubType for a given item or item type
12314
- *
12315
- * @param itemOrType an item or item.type
12316
- */
12317
- function getItemHubType(itemOrType) {
12318
- /* tslint:disable no-console */
12319
- console.warn("DEPRECATED: Use getFamily() instead. getItemHubType() will be removed at v10.0.0");
12320
- /* tslint:enable no-console */
12321
- if (typeof itemOrType === "string") {
12322
- itemOrType = { type: itemOrType };
12323
- }
12324
- var itemType = normalizeItemType(itemOrType);
12325
- // TODO: not all categories are Hub types, may need to validate
12326
- return getCollection(itemType);
12327
- }
12328
12281
  /**
12329
12282
  * Convert a Portal item to Hub content
12330
12283
  *
@@ -12498,8 +12451,6 @@
12498
12451
  var contentTypeIcon = getContentTypeIcon(normalizedType);
12499
12452
  var contentTypeLabel = getContentTypeLabel(normalizedType, content.isProxied);
12500
12453
  var updated = __assign(__assign({}, content), { type: normalizedType, family: family,
12501
- // TODO: remove this at next breaking change now that it has been deprecated
12502
- normalizedType: normalizedType,
12503
12454
  contentTypeIcon: contentTypeIcon,
12504
12455
  contentTypeLabel: contentTypeLabel });
12505
12456
  // update the relative URL to the content
@@ -12517,55 +12468,6 @@
12517
12468
  var getContentTypeLabel = function (contentType, isProxied) {
12518
12469
  return isProxied ? "CSV" : camelize(contentType || "");
12519
12470
  };
12520
- /**
12521
- * DEPRECATED returns a new content that has the specified hubId and updated identifier
12522
- * @param content orignal content
12523
- * @param hubId new hubId
12524
- * @returns new content
12525
- */
12526
- /* istanbul ignore next DEPRECATED and no longer in use */
12527
- var setContentHubId = function (content, hubId) {
12528
- var id = content.id, slug = content.slug;
12529
- // get the identifier which is based on hubId
12530
- var identifier = slug || hubId || id;
12531
- var updated = __assign(__assign({}, content), { hubId: hubId, identifier: identifier });
12532
- // update the relative URL to the content
12533
- // which is based on identifier
12534
- return appendContentUrls(updated, {
12535
- relative: getContentRelativeUrl(updated),
12536
- });
12537
- };
12538
- /**
12539
- * DEPRECATED: Calculates the relative and absolute urls for a given content on a specific site
12540
- *
12541
- * @param content
12542
- * @param siteModel
12543
- * @returns relative and absolute urls
12544
- */
12545
- var getContentSiteUrls = function (content, siteModel) {
12546
- // compute relative URL using a site specific identifier
12547
- var siteIdentifier = getContentIdentifier(content, siteModel);
12548
- var relative = getContentRelativeUrl(content, siteIdentifier);
12549
- // get the absolute URL to this content on the site
12550
- var siteUrl = getProp(siteModel, "item.url").replace(/\/$/, "");
12551
- var absolute = "" + siteUrl + relative;
12552
- return { relative: relative, absolute: absolute };
12553
- };
12554
- /**
12555
- * append the absolute URL to the content on the site
12556
- * also updates the relative URL in case the
12557
- * @param content
12558
- * @param siteModel
12559
- * @returns
12560
- */
12561
- var setContentSiteUrls = function (content, siteModel) {
12562
- var _a = getContentSiteUrls(content, siteModel), relative = _a.relative, site = _a.absolute;
12563
- // append the updated URLs to a new content
12564
- return appendContentUrls(content, {
12565
- relative: relative,
12566
- site: site,
12567
- });
12568
- };
12569
12471
  // URL helpers
12570
12472
  var appendContentUrls = function (content, newUrls) {
12571
12473
  // merge new urls into existing ones and return a new content
@@ -13350,24 +13252,6 @@
13350
13252
  });
13351
13253
  }
13352
13254
 
13353
- /**
13354
- * Search the Hub API
13355
- *
13356
- * @param requestOptions
13357
- * @returns JSONAPI response
13358
- */
13359
- function hubApiSearch(requestOptions) {
13360
- // derive default headers if authentication
13361
- var authentication = requestOptions.authentication;
13362
- var headers = authentication &&
13363
- authentication.serialize && { authentication: authentication.serialize() };
13364
- var defaults = {
13365
- headers: headers,
13366
- httpMethod: "POST",
13367
- };
13368
- return hubApiRequest("/search", __assign(__assign({}, defaults), requestOptions));
13369
- }
13370
-
13371
13255
  /* Copyright (c) 2018-2021 Environmental Systems Research Institute, Inc.
13372
13256
  * Apache-2.0 */
13373
13257
  /**
@@ -13431,76 +13315,6 @@
13431
13315
  return api;
13432
13316
  }
13433
13317
  }
13434
- /**
13435
- * @private
13436
- * Merge two date ranges by taking the longest span
13437
- * @param dr1
13438
- * @param dr2
13439
- * @returns
13440
- */
13441
- function mergeDateRange(dr1, dr2) {
13442
- // TODO: Remove with _searchContent
13443
- var result = cloneObject$1(dr1);
13444
- // feels like there is a more concise way to do this...
13445
- if (dr2.from < dr1.from) {
13446
- result.from = dr2.from;
13447
- }
13448
- if (dr2.to > dr1.to) {
13449
- result.to = dr2.to;
13450
- }
13451
- return result;
13452
- }
13453
- /**
13454
- * @private
13455
- * Merge two [`MatchOptions`](../MatchOptions)
13456
- *
13457
- * Currently a naieve implementation where the arrays are simply merged
13458
- *
13459
- * @param mo1
13460
- * @param mo2
13461
- * @returns
13462
- */
13463
- function mergeMatchOptions(mo1, mo2) {
13464
- // TODO: Remove with _searchContent
13465
- var result = {};
13466
- // None of these props are required, so we can't just
13467
- // use Object.keys/.entries
13468
- var props = ["any", "all", "not", "exact"];
13469
- props.forEach(function (prop) {
13470
- var key = prop;
13471
- var merged = __spreadArrays(getMatchValue(mo1, key), getMatchValue(mo2, key));
13472
- if (merged.length) {
13473
- // remove any dupes and set on the return
13474
- result[key] = merged.filter(unique);
13475
- }
13476
- });
13477
- return result;
13478
- }
13479
- /**
13480
- * Get the value of a property on an IMatchOptions
13481
- *
13482
- * This is complex b/c all the props are optional, and
13483
- * they could be a simple string, or an array of strings.
13484
- *
13485
- * This function normalizes all that and returns an array,
13486
- * which may or may not be empty
13487
- * @param option
13488
- * @param key
13489
- * @returns
13490
- */
13491
- function getMatchValue(option, key) {
13492
- var matchValue = [];
13493
- if (option[key]) {
13494
- var val = option[key];
13495
- if (Array.isArray(val)) {
13496
- matchValue = val;
13497
- }
13498
- else {
13499
- matchValue = [val];
13500
- }
13501
- }
13502
- return matchValue;
13503
- }
13504
13318
  /**
13505
13319
  * @private
13506
13320
  * Convert a field value into a MatchOptions if it's not already one
@@ -13569,137 +13383,6 @@
13569
13383
  }
13570
13384
  return result;
13571
13385
  }
13572
- /**
13573
- * @private
13574
- * As a final `ISearchOptions` object gets created, many such objects are created, and
13575
- * need to be systematically "merged" so as to return consistently structured `q` and `filter`
13576
- * values.
13577
- * @param so1
13578
- * @param so2
13579
- * @param join
13580
- * @returns
13581
- */
13582
- function mergeSearchOptions$1(so1, so2, join) {
13583
- // TODO: Remove with _searchContent
13584
- Logger.warn("DEPRECATION: mergeSearchOptions will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
13585
- var result = cloneObject$1(so1);
13586
- var q = so2.q, filter = so2.filter;
13587
- if (q) {
13588
- result.q = (result.q ? " (" + result.q + " " + join + " " + q + ")" : q).trim();
13589
- }
13590
- if (filter) {
13591
- result.filter = (result.filter ? "(" + result.filter + " " + join + " " + filter + ")" : filter).trim();
13592
- }
13593
- return result;
13594
- }
13595
- /**
13596
- * @private
13597
- * Serialize a `MatchOptions` into `q` or `filter` on an `ISearchOptions`
13598
- * DEPRECATED: Serialization should be handled in filter-utils.ts
13599
- * @param key
13600
- * @param opts
13601
- * @returns
13602
- */
13603
- function serializeMatchOptions$1(key, opts) {
13604
- var result = {
13605
- q: "",
13606
- filter: "",
13607
- };
13608
- if (opts.exact) {
13609
- // defined separately for refactoring later
13610
- var userFilterableFields = [
13611
- "username",
13612
- "firstname",
13613
- "lastname",
13614
- "fullname",
13615
- "email",
13616
- ];
13617
- var itemFilterableFields = [
13618
- "title",
13619
- "tags",
13620
- "typekeywords",
13621
- "type",
13622
- "name",
13623
- "owner",
13624
- ];
13625
- var groupFilterableFields = ["title", "typekeywords", "owner"];
13626
- var filterableFields = __spreadArrays(userFilterableFields, itemFilterableFields, groupFilterableFields);
13627
- if (filterableFields.includes(key)) {
13628
- result.filter = serializeStringOrArray$1("AND", key, opts.exact);
13629
- }
13630
- else {
13631
- // Treat it the same as .all
13632
- if (typeof opts.exact === "string") {
13633
- if (!opts.all) {
13634
- opts.all = [];
13635
- }
13636
- if (typeof opts.all === "string") {
13637
- opts.all = [opts.all];
13638
- }
13639
- opts.all.push(opts.exact);
13640
- }
13641
- if (Array.isArray(opts.exact)) {
13642
- if (!opts.all) {
13643
- opts.all = [];
13644
- }
13645
- if (typeof opts.all === "string") {
13646
- opts.all = [opts.all];
13647
- }
13648
- opts.all = opts.all.concat(opts.exact);
13649
- }
13650
- }
13651
- }
13652
- // Handle the other props
13653
- if (opts.any) {
13654
- result.q = serializeStringOrArray$1("OR", key, opts.any);
13655
- }
13656
- if (opts.all) {
13657
- result.q =
13658
- (result.q ? result.q + " AND " : "") +
13659
- serializeStringOrArray$1("AND", key, opts.all);
13660
- }
13661
- if (opts.not) {
13662
- // negate the entries if they are not
13663
- result.q =
13664
- (result.q ? result.q + " AND " : "") +
13665
- serializeStringOrArray$1("OR", "-" + key, opts.not);
13666
- }
13667
- return result;
13668
- }
13669
- /**
13670
- * @private
13671
- * Serialize a DateRange<number> into a Portal Query string
13672
- * @param key
13673
- * @param range
13674
- * @returns
13675
- */
13676
- function serializeDateRange$1(key, range) {
13677
- return {
13678
- q: key + ":[" + range.from + " TO " + range.to + "]",
13679
- filter: "",
13680
- };
13681
- }
13682
- /**
13683
- * @private
13684
- * Serialize a `string` or `string[]` into a string
13685
- * @param join
13686
- * @param key
13687
- * @param value
13688
- * @returns
13689
- */
13690
- function serializeStringOrArray$1(join, key, value) {
13691
- var q = "";
13692
- if (Array.isArray(value)) {
13693
- q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
13694
- if (value.length > 1) {
13695
- q = "(" + q + ")";
13696
- }
13697
- }
13698
- else {
13699
- q = key + ":\"" + value + "\"";
13700
- }
13701
- return q;
13702
- }
13703
13386
  /**
13704
13387
  * Create a `.next()` function for a type
13705
13388
  * @param request
@@ -13764,1248 +13447,27 @@
13764
13447
  return thumbnailUrl;
13765
13448
  }
13766
13449
 
13767
- // TODO: Remove with _searchContent
13768
- // TODO: Implement $dataset
13769
- var ContentFilterExpansions = {
13770
- $apps: [
13771
- {
13772
- type: {
13773
- any: [
13774
- "Code Sample",
13775
- "Web Mapping Application",
13776
- "Mobile Application",
13777
- "Application",
13778
- "Desktop Application Template",
13779
- "Desktop Application",
13780
- "Operation View",
13781
- "Dashboard",
13782
- "Operations Dashboard Extension",
13783
- "Workforce Project",
13784
- "Insights Workbook",
13785
- "Insights Page",
13786
- "Insights Model",
13787
- "Hub Page",
13788
- "Hub Initiative",
13789
- "Hub Site Application",
13790
- "StoryMap",
13791
- "Web Experience",
13792
- "Web Experience Template",
13793
- "Form",
13794
- ],
13795
- not: [
13796
- "Code Attachment",
13797
- "Featured Items",
13798
- "Symbol Set",
13799
- "Color Set",
13800
- "Windows Viewer Add In",
13801
- "Windows Viewer Configuration",
13802
- "Map Area",
13803
- "Indoors Map Configuration",
13804
- ],
13805
- },
13806
- typekeywords: {
13807
- not: ["MapAreaPackage", "SMX"],
13808
- },
13809
- },
13810
- ],
13811
- $storymap: [
13812
- {
13813
- type: "StoryMap",
13814
- },
13815
- {
13816
- type: "Web Mapping Application",
13817
- typekeywords: ["Story Map"],
13818
- },
13819
- ],
13820
- $dashboard: [
13821
- {
13822
- type: "Dashboard",
13823
- typekeywords: {
13824
- any: ["Dashboard"],
13825
- not: ["ArcGIS Operation View", "Add In", "Extension"],
13826
- },
13827
- },
13828
- ],
13829
- $dataset: [],
13830
- $experience: [
13831
- {
13832
- type: {
13833
- any: ["Web Experience"],
13834
- not: ["Web Experience Template"],
13835
- },
13836
- },
13837
- ],
13838
- $site: [
13839
- {
13840
- type: ["Hub Site Application", "Site Application"],
13841
- },
13842
- {
13843
- type: ["Web Mapping Application"],
13844
- typekeywords: ["hubSite"],
13845
- },
13846
- ],
13847
- $initiative: [
13848
- {
13849
- type: {
13850
- any: "Hub Initiative",
13851
- not: "Hub Initiative Template",
13852
- },
13853
- },
13854
- ],
13855
- $document: [
13856
- {
13857
- typekeywords: {
13858
- any: "Document",
13859
- not: ["MapAreaPackage", "SMX"],
13860
- },
13861
- type: {
13862
- any: [
13863
- "Image",
13864
- "Layout",
13865
- "Desktop Style",
13866
- "Project Template",
13867
- "Report Template",
13868
- "Pro Report",
13869
- "Statistical Data Collection",
13870
- "360 VR Experience",
13871
- "netCDF",
13872
- "PDF",
13873
- "CSV",
13874
- "Administrative Report",
13875
- "Raster function template",
13876
- ],
13877
- not: [
13878
- "Image Service",
13879
- "Explorer Document",
13880
- "Explorer Map",
13881
- "Globe Document",
13882
- "Scene Document",
13883
- "Code Attachment",
13884
- "Featured Items",
13885
- "Symbol Set",
13886
- "ColorSet",
13887
- "Windows Viewer Add In",
13888
- "Windows Viewer Configuration",
13889
- "Map Area",
13890
- "Indoors Map Configuration",
13891
- ],
13892
- },
13893
- },
13894
- ],
13895
- };
13896
- /**
13897
- * @private
13898
- * Convert portal search response to facets
13899
- * Note: Only applicable to an item search
13900
- * @param response
13901
- * @returns
13902
- */
13903
- // TODO: Remove with _searchContent
13904
- function convertPortalResponseToFacets(response, operation) {
13905
- if (operation === void 0) { operation = "OR"; }
13906
- // delegate to a more future-friendly version
13907
- return convertPortalItemResponseToFacets(response, operation, "filter");
13908
- }
13450
+ var CATALOG_SCHEMA_VERSION = 1.0;
13909
13451
  /**
13910
- * @private
13911
- * Convert portal search response to facets
13912
- * Note: Only applicable to an item search
13913
- * @param response
13452
+ * Apply schema upgrades to Catalog objects
13453
+ * @param catalog
13914
13454
  * @returns
13915
13455
  */
13916
- function convertPortalItemResponseToFacets(response, operation, optionProp // TODO: Remove with _searchContent and use `filters`
13917
- ) {
13918
- var _a;
13919
- if (operation === void 0) { operation = "OR"; }
13920
- if (optionProp === void 0) { optionProp = "filters"; }
13921
- // TODO: move into portalSearchItems
13922
- var result = [];
13923
- if ((_a = response.aggregations) === null || _a === void 0 ? void 0 : _a.counts) {
13924
- response.aggregations.counts.forEach(function (entry) {
13925
- var facet = {
13926
- label: entry.fieldName,
13927
- key: entry.fieldName,
13928
- aggField: entry.fieldName,
13929
- display: "multi-select",
13930
- };
13931
- var options = [];
13932
- entry.fieldValues.forEach(function (fv) {
13933
- var filter = {
13934
- filterType: "item",
13935
- };
13936
- // construct the filter based on the operation
13937
- var matchKey = operation === "OR" ? "any" : "all";
13938
- var filterMatchOption = {};
13939
- filterMatchOption[matchKey] = [fv.value];
13940
- filter[entry.fieldName] = filterMatchOption;
13941
- // construct the FacetOption
13942
- var fo = {
13943
- label: fv.value + " (" + fv.count + ")",
13944
- key: fv.value,
13945
- count: fv.count,
13946
- selected: false,
13947
- };
13948
- // Temporary to ensure the old fn can delegate to this
13949
- // but we can still return the correct structure
13950
- // TODO: Remove with _searchContent
13951
- /* istanbul ignore next */
13952
- if (optionProp === "filter") {
13953
- fo.filter = filter;
13954
- }
13955
- else {
13956
- fo.filters = [filter];
13957
- }
13958
- options.push(fo);
13959
- });
13960
- facet.options = options;
13961
- result.push(facet);
13962
- });
13456
+ function upgradeCatalogSchema(catalog) {
13457
+ var clone = cloneObject$1(catalog);
13458
+ if (getProp(clone, "schemaVersion") === CATALOG_SCHEMA_VERSION) {
13459
+ return clone;
13460
+ }
13461
+ else {
13462
+ // apply migrations in order
13463
+ clone = applyCatalogSchema(clone);
13464
+ return clone;
13963
13465
  }
13964
- return result;
13965
13466
  }
13966
13467
  /**
13967
- * Merge `Filter<"content">` objects
13968
- *
13969
- * Useful in components which may get partial filters from a variety of
13970
- * sub-components, which are then combined into a single filter prior
13971
- * to executing the search.
13972
- * @param filters
13973
- * @returns
13974
- */
13975
- function mergeContentFilter(filters) {
13976
- Logger.warn("DEPRECATION: mergeContentFilter will be removed and filters should not longer be merged. Work with IFilterGroups instead");
13977
- // expand all the filters so all prop types are consistent
13978
- var expanded = filters.map(expandContentFilter);
13979
- // now we can merge based on fields
13980
- var dateFields = ["created", "modified"];
13981
- var specialFields = __spreadArrays(["filterType", "subFilters", "term"], dateFields);
13982
- var result = expanded.reduce(function (acc, entry) {
13983
- // process fields
13984
- Object.entries(entry).forEach(function (_a) {
13985
- var key = _a[0], value = _a[1];
13986
- if (acc.hasOwnProperty(key)) {
13987
- /* istanbul ignore else */
13988
- if (!specialFields.includes(key)) {
13989
- acc[key] = mergeMatchOptions(acc[key], value);
13990
- }
13991
- else if (dateFields.includes(key)) {
13992
- acc[key] = mergeDateRange(acc[key], value);
13993
- }
13994
- else if (key === "term") {
13995
- acc[key] = acc[key] + " " + value;
13996
- }
13997
- else if (key === "subFilters") {
13998
- acc[key] = mergeSubFilters(acc[key], value);
13999
- }
14000
- }
14001
- else {
14002
- acc[key] = cloneObject$1(value);
14003
- }
14004
- });
14005
- return acc;
14006
- }, {});
14007
- result.filterType = "content";
14008
- return result;
14009
- }
14010
- function mergeSubFilters(sf1, sf2) {
14011
- // Simplistic implementation: we just merge the arrays
14012
- // in the future we may try to de-dupe things as a safeguard
14013
- return __spreadArrays(sf1, sf2);
14014
- }
14015
- /**
14016
- * Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
14017
- *
14018
- * Filter's can express their intent in a very terse form, but to ensure consistent structures
14019
- * we expand them into their more verbose form.
14020
- *
14021
- * i.e. `title: "Water"` expands into `title: { any: ["Water"]}`
14022
- *
14023
- * - "well known" type values are expanded
14024
- * - i.e. `type: "$storymap"` expands into two `subFilter` entries
14025
- * - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
14026
- * - RelativeDate fields are converted to DateRange<number>
14027
- *
14028
- * @param filter
14029
- * @returns
14030
- */
14031
- function expandContentFilter(filter) {
14032
- Logger.warn("DEPRECATION: expandContentFilter will be removed. Work with IFilterGroups<\"item\"> instead");
14033
- // Expand filter.type first
14034
- var expandedTypeFilter = expandTypeField(filter);
14035
- // Expand subfilters
14036
- // Guard - JS Clients could send in anything...
14037
- if (Array.isArray(filter.subFilters)) {
14038
- // Convert any strings into the coresponding ContentFilterDefinition
14039
- expandedTypeFilter.subFilters = expandedTypeFilter.subFilters.reduce(function (acc, entry) {
14040
- if (typeof entry === "string") {
14041
- // if the entry is not a key of ContentFilterExpansions
14042
- // we just skip over it
14043
- if (ContentFilterExpansions[entry]) {
14044
- acc = acc.concat(ContentFilterExpansions[entry]);
14045
- }
14046
- }
14047
- else {
14048
- acc.push(entry); // should be a ContentFilterDefinition
14049
- }
14050
- return acc;
14051
- }, []);
14052
- }
14053
- // Convert all props into MatchOptions/DateRanges
14054
- return convertContentDefinitionToFilter(expandedTypeFilter);
14055
- }
14056
- /**
14057
- * @private
14058
- * Expand from a well-known "type" into it's longer form
14059
- *
14060
- * i.e. `type: "$storymap"` expands into two subFilters entries
14061
- *
14062
- * @param filter
14063
- * @returns
14064
- */
14065
- function expandTypeField(filter) {
14066
- var clone = cloneObject$1(filter);
14067
- // ensure subFilters is defined as an array
14068
- clone.subFilters = clone.subFilters || [];
14069
- if (clone.type) {
14070
- // if .type is an Array...
14071
- if (Array.isArray(clone.type)) {
14072
- // remove any well-known-keys and move their expansions into subfilters
14073
- clone.type = clone.type.reduce(function (acc, entry) {
14074
- if (isWellKnownType(entry)) {
14075
- // working with dynamic objects in typescript requires some assertions
14076
- var key = entry;
14077
- clone.subFilters = clone.subFilters.concat(lookupTypeFilters(key));
14078
- }
14079
- else {
14080
- acc.push(entry);
14081
- }
14082
- return acc;
14083
- }, []);
14084
- }
14085
- else if (isWellKnownType(clone.type)) {
14086
- var key = clone.type;
14087
- clone.subFilters = clone.subFilters.concat(lookupTypeFilters(key));
14088
- delete clone.type;
14089
- }
14090
- else ;
14091
- }
14092
- return clone;
14093
- }
14094
- /**
14095
- * Is the argument a well-known type "key"
14096
- *
14097
- * Accepts `string`, `string[]` or `IMatchOptions`
14098
- * but only string values can possibly be properties
14099
- * on `ContentFilterExpansions`
14100
- * @param key
14101
- * @returns
14102
- */
14103
- function isWellKnownType(key) {
14104
- var result = false;
14105
- if (typeof key === "string") {
14106
- result = key in ContentFilterExpansions;
14107
- }
14108
- return result;
14109
- }
14110
- function lookupTypeFilters(key) {
14111
- return ContentFilterExpansions[key];
14112
- }
14113
- /**
14114
- * @private
14115
- * Convert a `ContentFilterDefinition` to a `ContentFilter`
14116
- *
14117
- * ContentFilter is a narrower version of ContentFilterDefinition, without
14118
- * the union types. Using a ContentFilter makes working with the structure
14119
- * in typescript much easier.
14120
- *
14121
- * @param filter
14122
- * @returns
14123
- */
14124
- function convertContentDefinitionToFilter(filter) {
14125
- // TODO: Remove with _searchContent
14126
- Logger.warn("DEPRECATION: convertContentDefinitionToFilter will be removed. Work with IFilterGroups<\"item\"> instead");
14127
- var result = {};
14128
- if (filter.term) {
14129
- result.term = filter.term;
14130
- }
14131
- var dateProps = ["created", "modified"];
14132
- // Some properties should not get converted to MatchOptions
14133
- var specialProps = __spreadArrays(["filterType", "subFilters", "term"], dateProps);
14134
- // Do the conversion
14135
- Object.entries(filter).forEach(function (_a) {
14136
- var key = _a[0], value = _a[1];
14137
- if (!specialProps.includes(key)) {
14138
- result[key] = valueToMatchOptions(value);
14139
- }
14140
- });
14141
- // Special Cases
14142
- // subFilters; Array of ContentFilterDefinitions
14143
- if (filter.subFilters && Array.isArray(filter.subFilters)) {
14144
- // downcast - would be nice to skip this or use some other constuct
14145
- var sf = filter.subFilters;
14146
- result.subFilters = sf.map(convertContentDefinitionToFilter);
14147
- }
14148
- // Dates; Ensure they are all DateRange<number>
14149
- dateProps.forEach(function (fld) {
14150
- if (filter[fld]) {
14151
- if (filter[fld].type === "relative-date") {
14152
- result[fld] = relativeDateToDateRange(filter[fld]);
14153
- }
14154
- else {
14155
- result[fld] = cloneObject$1(filter[fld]);
14156
- }
14157
- }
14158
- });
14159
- return result;
14160
- }
14161
- /**
14162
- * @private
14163
- * Serialize a `ContentFilter` into an `ISearchOptions` for use with `searchItems`
14164
- * @param filter
14165
- * @returns
14166
- */
14167
- function serializeContentFilterForPortal(filter) {
14168
- // TODO: Remove with _searchContent
14169
- Logger.warn("DEPRECATION: serializeContentFilterForPortal will be removed. Work with IFilterGroups<\"item\"> and hubSearch() instead");
14170
- var searchOptions = convertContentFilterToSearchOptions(filter);
14171
- if (filter.subFilters) {
14172
- var subFilterOptions = filter.subFilters.reduce(function (acc, entry) {
14173
- // Next guard is present b/c this can be used from javascript
14174
- // but our tests are written in typescript which prevents us
14175
- // from hitting the else
14176
- /* istanbul ignore else */
14177
- if (typeof entry === "object") {
14178
- acc = mergeSearchOptions$1(acc, convertContentFilterToSearchOptions(entry), "OR");
14179
- }
14180
- return acc;
14181
- }, { q: "", filter: "" });
14182
- // merge with searchOptions using AND
14183
- searchOptions = mergeSearchOptions$1(searchOptions, subFilterOptions, "AND");
14184
- }
14185
- // term is always last, and pre-pended on searchOptions.q
14186
- if (filter.term) {
14187
- searchOptions.q = (filter.term + " " + searchOptions.q).trim();
14188
- }
14189
- return searchOptions;
14190
- }
14191
- /**
14192
- * @private
14193
- * Convert a ContentFilter to a SearchOptions
14194
- *
14195
- * @param filter
14196
- * @returns
14197
- */
14198
- function convertContentFilterToSearchOptions(filter) {
14199
- // TODO: Remove with _searchContent
14200
- Logger.warn("DEPRECATION: convertContentFilterToSearchOptions will be removed. Work with IFilterGroups<\"item\"> and hubSearch() instead");
14201
- var result = {
14202
- q: "",
14203
- filter: "",
14204
- };
14205
- var dateProps = ["created", "modified"];
14206
- var specialProps = __spreadArrays(["filterType", "subFilters", "term"], dateProps);
14207
- Object.entries(filter).forEach(function (_a) {
14208
- var key = _a[0], value = _a[1];
14209
- // MatchOptions may go into either q or filter
14210
- if (!specialProps.includes(key)) {
14211
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14212
- }
14213
- // Dates only go into q
14214
- if (dateProps.includes(key)) {
14215
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14216
- }
14217
- });
14218
- return result;
14219
- }
14220
-
14221
- // TODO: Remove with _searchContent
14222
- /**
14223
- *
14224
- * Merge `Filter<"group">` objects
14225
- *
14226
- * Useful in components which may get partial filters from a variety of
14227
- * sub-components, which are then combined into a single filter prior
14228
- * to executing the search.
14229
- * @param filters
14230
- * @returns
14231
- */
14232
- function mergeGroupFilters(filters) {
14233
- // TODO: Remove with _searchContent
14234
- Logger.warn("DEPRECATION: mergeGroupFilters will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
14235
- // expand all the filters so all prop types are consistent
14236
- var expanded = filters.map(expandGroupFilter);
14237
- // now we can merge based on fields
14238
- var dateFields = ["created", "modified"];
14239
- var specialFields = __spreadArrays(["filterType", "term"], dateFields);
14240
- // acc is initialized as Filter<group> but also needs it
14241
- // in the function signature... for reasons?!
14242
- var result = expanded.reduce(function (acc, entry) {
14243
- // process fields
14244
- Object.entries(entry).forEach(function (_a) {
14245
- // Note: getProp/setProp are used to get around
14246
- // typescript issues with string indexing
14247
- var key = _a[0], value = _a[1];
14248
- if (acc.hasOwnProperty(key)) {
14249
- var existingValue = getProp(acc, key);
14250
- // if the key is not to a special field
14251
- if (!specialFields.includes(key)) {
14252
- // treat as an IMatchOptions
14253
- setProp(key, mergeMatchOptions(existingValue, value), acc);
14254
- }
14255
- else if (dateFields.includes(key)) {
14256
- // treat as IDateRange
14257
- setProp(key, mergeDateRange(existingValue, value), acc);
14258
- }
14259
- else if (key === "term") {
14260
- // append terms
14261
- acc[key] = acc[key] + " " + value;
14262
- }
14263
- }
14264
- else {
14265
- // Acc does not have an entry for this yet
14266
- // so just clone it
14267
- setProp(key, cloneObject$1(value), acc);
14268
- }
14269
- });
14270
- return acc;
14271
- }, {
14272
- filterType: "group",
14273
- });
14274
- return result;
14275
- }
14276
- /**
14277
- * Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
14278
- *
14279
- * Filter's can express their intent in a very terse form, but to ensure consistent structures
14280
- * we expand them into their more verbose form.
14281
- *
14282
- * i.e. `title: "Water"` expands into `title: { any: ["Water"]}`
14283
- *
14284
- * - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
14285
- * - RelativeDate fields are converted to DateRange<number>
14286
- *
14287
- * @param filter
14288
- * @returns
14289
- */
14290
- function expandGroupFilter(filter) {
14291
- // TODO: Remove with _searchContent
14292
- Logger.warn("DEPRECATION: expandGroupFilters will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
14293
- var result = {};
14294
- var dateProps = ["created", "modified"];
14295
- // Some properties should not get converted to MatchOptions
14296
- var specialProps = __spreadArrays(["term", "searchUserAccess"], dateProps);
14297
- // Do the conversion
14298
- Object.entries(filter).forEach(function (_a) {
14299
- var key = _a[0], value = _a[1];
14300
- // handle Matchish fields
14301
- if (!specialProps.includes(key)) {
14302
- // setProp side-steps typescript complaining
14303
- setProp(key, valueToMatchOptions(value), result);
14304
- }
14305
- // Handle date fields
14306
- if (dateProps.includes(key)) {
14307
- var dateFieldValue = cloneObject$1(getProp(filter, key));
14308
- if (getProp(filter, key + ".type") === "relative-date") {
14309
- setProp(key, relativeDateToDateRange(dateFieldValue), result);
14310
- }
14311
- else {
14312
- setProp(key, dateFieldValue, result);
14313
- }
14314
- }
14315
- });
14316
- // searchUserAccess is boolean, so we check if the prop exists
14317
- // vs checking if the value is truthy
14318
- if (filter.hasOwnProperty("searchUserAccess")) {
14319
- result.searchUserAccess = filter.searchUserAccess;
14320
- }
14321
- if (filter.term) {
14322
- result.term = filter.term;
14323
- }
14324
- return result;
14325
- }
14326
- /**
14327
- * @private
14328
- * Serialize an `IGroupFilterDefinition` into an `ISearchOptions` for use
14329
- * with `searchGroups`
14330
- * @param filter
14331
- * @returns
14332
- */
14333
- function serializeGroupFilterForPortal(filter) {
14334
- // TODO: Remove with _searchContent
14335
- Logger.warn("DEPRECATION: serializeGroupFilterForPortal will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
14336
- var result = {
14337
- q: "",
14338
- filter: "",
14339
- };
14340
- var dateProps = ["created", "modified"];
14341
- var specialProps = __spreadArrays(["term", "searchUserAccess", "filterType"], dateProps);
14342
- Object.entries(filter).forEach(function (_a) {
14343
- var key = _a[0], value = _a[1];
14344
- // MatchOptions fields
14345
- if (!specialProps.includes(key)) {
14346
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14347
- }
14348
- // Dates only go into q
14349
- if (dateProps.includes(key)) {
14350
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14351
- }
14352
- });
14353
- // searchUserAccess is also a top-level property
14354
- if (filter.hasOwnProperty("searchUserAccess")) {
14355
- result.searchUserAccess = filter.searchUserAccess;
14356
- }
14357
- // add the term
14358
- if (filter.term) {
14359
- result.q = (filter.term + " " + result.q).trim();
14360
- }
14361
- return result;
14362
- }
14363
-
14364
- // TODO: Remove with _searchContent
14365
- /**
14366
- *
14367
- * Merge `Filter<"user">` objects
14368
- *
14369
- * Useful in components which may get partial filters from a variety of
14370
- * sub-components, which are then combined into a single filter prior
14371
- * to executing the search.
14372
- * @param filters
14373
- * @returns
14374
- */
14375
- function mergeUserFilters(filters) {
14376
- // TODO: Remove with _searchContent
14377
- Logger.warn("DEPRECATION: mergeUserFilters will be removed. Work with IFilterGroups<\"user\"> and hubSearch() instead");
14378
- // expand all the filters so all prop types are consistent
14379
- var expanded = filters.map(expandUserFilter);
14380
- // now we can merge based on fields
14381
- var dateFields = ["created", "modified", "lastlogin"];
14382
- var specialFields = __spreadArrays(["disabled", "term", "filterType"], dateFields);
14383
- // acc is initialized as Filter<group> but also needs it
14384
- // in the function signature... for reasons?!
14385
- var result = expanded.reduce(function (acc, entry) {
14386
- // process fields
14387
- Object.entries(entry).forEach(function (_a) {
14388
- // Note: getProp/setProp are used to get around
14389
- // typescript issues with string indexing
14390
- var key = _a[0], value = _a[1];
14391
- if (acc.hasOwnProperty(key)) {
14392
- var existingValue = getProp(acc, key);
14393
- // if the key is not to a special field
14394
- if (!specialFields.includes(key)) {
14395
- // treat as an IMatchOptions
14396
- setProp(key, mergeMatchOptions(existingValue, value), acc);
14397
- }
14398
- else if (dateFields.includes(key)) {
14399
- // treat as IDateRange
14400
- setProp(key, mergeDateRange(existingValue, value), acc);
14401
- }
14402
- else if (key === "term") {
14403
- // append terms
14404
- acc[key] = acc[key] + " " + value;
14405
- }
14406
- }
14407
- else {
14408
- // Acc does not have an entry for this yet
14409
- // so just clone it
14410
- setProp(key, cloneObject$1(value), acc);
14411
- }
14412
- });
14413
- return acc;
14414
- }, {
14415
- filterType: "user",
14416
- });
14417
- return result;
14418
- }
14419
- /**
14420
- * Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
14421
- *
14422
- * Filter's can express their intent in a very terse form, but to ensure consistent structures
14423
- * we expand them into their more verbose form.
14424
- *
14425
- * i.e. `firstname: "John"` expands into `firstname: { any: ["John"]}`
14426
- *
14427
- * - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
14428
- * - RelativeDate fields are converted to DateRange<number>
14429
- * @param filter
14430
- * @returns
14431
- */
14432
- function expandUserFilter(filter) {
14433
- // TODO: Remove with _searchContent
14434
- Logger.warn("DEPRECATION: expandUserFilter will be removed. Work with IFilterGroups<\"user\"> and hubSearch() instead");
14435
- var result = {};
14436
- var dateProps = ["created", "modified", "lastlogin"];
14437
- var specialProps = __spreadArrays(["disabled", "term"], dateProps);
14438
- Object.entries(filter).forEach(function (_a) {
14439
- var key = _a[0], value = _a[1];
14440
- // handle Matchish fields
14441
- if (!specialProps.includes(key)) {
14442
- // setProp side-steps typescript complaining
14443
- setProp(key, valueToMatchOptions(value), result);
14444
- }
14445
- // Handle date fields
14446
- if (dateProps.includes(key)) {
14447
- var dateFieldValue = cloneObject$1(getProp(filter, key));
14448
- if (getProp(filter, key + ".type") === "relative-date") {
14449
- setProp(key, relativeDateToDateRange(dateFieldValue), result);
14450
- }
14451
- else {
14452
- setProp(key, dateFieldValue, result);
14453
- }
14454
- }
14455
- });
14456
- // disabled is boolean, so we check if the prop exists
14457
- // vs checking if the value is truthy
14458
- if (filter.hasOwnProperty("disabled")) {
14459
- result.disabled = filter.disabled;
14460
- }
14461
- if (filter.term) {
14462
- result.term = filter.term;
14463
- }
14464
- return result;
14465
- }
14466
- /**
14467
- * @private
14468
- * Serialize an `IUserFilterDefinition` into an `ISearchOptions` for use
14469
- * with `searchUsers`
14470
- * @param filter
14471
- * @returns
14472
- */
14473
- function serializeUserFilterForPortal(filter) {
14474
- // TODO: Remove with _searchContent
14475
- Logger.warn("DEPRECATION: serializeUserFilterForPortal will be removed. Work with IFilterGroups<\"user\"> and hubSearch() instead");
14476
- var result = {
14477
- q: "",
14478
- filter: "",
14479
- };
14480
- var dateProps = ["created", "modified", "lastlogin"];
14481
- var specialProps = __spreadArrays(["term", "filterType"], dateProps);
14482
- Object.entries(filter).forEach(function (_a) {
14483
- var key = _a[0], value = _a[1];
14484
- // MatchOptions fields
14485
- if (!specialProps.includes(key)) {
14486
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14487
- }
14488
- // Dates only go into q
14489
- if (dateProps.includes(key)) {
14490
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14491
- }
14492
- });
14493
- // disabled is also a top-level property
14494
- if (filter.hasOwnProperty("disabled")) {
14495
- result.disabled = filter.disabled;
14496
- }
14497
- // add the term
14498
- if (filter.term) {
14499
- // Note: this is slightly different from other types
14500
- result.q = ("(" + filter.term + ") " + result.q).trim();
14501
- }
14502
- return result;
14503
- }
14504
-
14505
- // TODO: Remove with _searchContent
14506
- /**
14507
- * @private
14508
- * Search for content via the Portal or Hub API
14509
- * @param filter
14510
- * @param options
14511
- */
14512
- function _searchContent(filter, options) {
14513
- var _a, _b;
14514
- return __awaiter(this, void 0, void 0, function () {
14515
- var expanded, api, searchPromise, so_1, props;
14516
- return __generator(this, function (_c) {
14517
- Logger.warn("DEPRECATION: _searchContent will be removed; switch to hubSearch(...)");
14518
- expanded = expandContentFilter(filter);
14519
- api = expandApi(options.api || "arcgis");
14520
- // Portal Search
14521
- if (api.type === "arcgis") {
14522
- so_1 = serializeContentFilterForPortal(expanded);
14523
- props = [
14524
- "authentication",
14525
- "num",
14526
- "sortField",
14527
- "sortOrder",
14528
- "site",
14529
- "start",
14530
- ];
14531
- // copy the props over
14532
- props.forEach(function (prop) {
14533
- if (options.hasOwnProperty(prop)) {
14534
- so_1[prop] = options[prop];
14535
- }
14536
- });
14537
- // If we don't have auth, ensure we have .portal
14538
- if (!so_1.authentication) {
14539
- so_1.portal = api.url + "/sharing/rest";
14540
- }
14541
- // DEPRECATION
14542
- if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
14543
- // tslint:disable-next-line:no-console
14544
- console.warn("IHubSearchOptions.aggregations is deprecated. Please use .aggFields instead.");
14545
- so_1.countFields = options.aggregations.join(",");
14546
- so_1.countSize = options.aggLimit || 10;
14547
- }
14548
- // Aggregations
14549
- if ((_b = options.aggFields) === null || _b === void 0 ? void 0 : _b.length) {
14550
- so_1.countFields = options.aggFields.join(",");
14551
- so_1.countSize = options.aggLimit || 10;
14552
- }
14553
- searchPromise = searchPortal$3(so_1);
14554
- }
14555
- else {
14556
- // Hub API Search
14557
- // TODO: Implement hub api content search
14558
- searchPromise = Promise.resolve({
14559
- total: 0,
14560
- results: [],
14561
- facets: [],
14562
- hasNext: false,
14563
- next: function () {
14564
- // tslint:disable-next-line
14565
- Promise.resolve(null);
14566
- },
14567
- });
14568
- }
14569
- return [2 /*return*/, searchPromise];
14570
- });
14571
- });
14572
- }
14573
- /**
14574
- * Internal portal search, which then converts items to Content, and
14575
- * if a Site was passed, also sets urls
14576
- *
14577
- * @param searchOptions
14578
- * @param site
14579
- * @returns
14580
- */
14581
- function searchPortal$3(searchOptions) {
14582
- var _a;
14583
- var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
14584
- var token;
14585
- if (searchOptions.authentication) {
14586
- var us = searchOptions.authentication;
14587
- token = us.token;
14588
- }
14589
- var thumbnailify = function (content) {
14590
- content.thumbnailUrl = getItemThumbnailUrl(content, portalUrl, token);
14591
- return content;
14592
- };
14593
- return searchItems(searchOptions).then(function (resp) {
14594
- var hasNext = resp.nextStart > -1;
14595
- // convert items to IHubContent's
14596
- var content = resp.results.map(itemToContent);
14597
- // if we have a site, add those urls
14598
- if (searchOptions.site) {
14599
- content = content.map(function (entry) {
14600
- return setContentSiteUrls(entry, searchOptions.site);
14601
- });
14602
- }
14603
- // add thumbnailUrl
14604
- content = content.map(thumbnailify);
14605
- // convert aggregations into facets
14606
- var facets = convertPortalResponseToFacets(resp);
14607
- return {
14608
- total: resp.total,
14609
- results: content,
14610
- facets: facets,
14611
- hasNext: hasNext,
14612
- next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$3),
14613
- };
14614
- });
14615
- }
14616
-
14617
- // TODO: Remove with _searchContent
14618
- /**
14619
- * @private
14620
- * Search Groups using Filter<"group">
14621
- *
14622
- * Currently just returns ISearchResult<IGroup>
14623
- * @param filter
14624
- * @param options
14625
- * @returns
14626
- */
14627
- function _searchGroups(filter, options) {
14628
- return __awaiter(this, void 0, void 0, function () {
14629
- var expanded, api, so_1, props;
14630
- return __generator(this, function (_a) {
14631
- Logger.warn("DEPRECATION: _searchGroups will be removed; switch to hubSearch(...)");
14632
- expanded = expandGroupFilter(filter);
14633
- api = expandApi(options.api || "arcgis");
14634
- if (api.type === "arcgis") {
14635
- so_1 = serializeGroupFilterForPortal(expanded);
14636
- props = [
14637
- "authentication",
14638
- "num",
14639
- "sortField",
14640
- "sortOrder",
14641
- "site",
14642
- "start",
14643
- ];
14644
- // copy the props over
14645
- props.forEach(function (prop) {
14646
- if (options.hasOwnProperty(prop)) {
14647
- so_1[prop] = options[prop];
14648
- }
14649
- });
14650
- // If we don't have auth, ensure we have .portal
14651
- if (!so_1.authentication) {
14652
- so_1.portal = api.url + "/sharing/rest";
14653
- }
14654
- return [2 /*return*/, searchPortalGroups(so_1)];
14655
- }
14656
- else {
14657
- throw new Error("_searchGroups is not implemented for non-arcgis apis");
14658
- }
14659
- });
14660
- });
14661
- }
14662
- /**
14663
- * Internal function that searches for groups using the ArcGIS Portal API
14664
- * @param searchOptions
14665
- * @returns
14666
- */
14667
- function searchPortalGroups(searchOptions) {
14668
- var _a;
14669
- var teamLinkify = function (group) {
14670
- group.siteTeamUrl = searchOptions.site.item.url + "/teams/" + group.id + "/about";
14671
- return group;
14672
- };
14673
- var portalUrl = ((_a = searchOptions.authentication) === null || _a === void 0 ? void 0 : _a.portal) || searchOptions.portal;
14674
- var token;
14675
- if (searchOptions.authentication) {
14676
- var us = searchOptions.authentication;
14677
- token = us.token;
14678
- }
14679
- var thumbnailify = function (group) {
14680
- group.thumbnailUrl = getGroupThumbnailUrl(portalUrl, group, token);
14681
- return group;
14682
- };
14683
- // execute the search
14684
- return searchGroups(searchOptions).then(function (response) {
14685
- var _a, _b;
14686
- var hasNext = response.nextStart > -1;
14687
- // upgrade thumbnail url
14688
- var results = response.results.map(thumbnailify);
14689
- // generate the site team url if site url is provided
14690
- if ((_b = (_a = searchOptions.site) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.url) {
14691
- results = response.results.map(teamLinkify);
14692
- }
14693
- return {
14694
- hasNext: hasNext,
14695
- total: response.total,
14696
- results: results,
14697
- next: getNextFunction(searchOptions, response.nextStart, response.total, searchPortalGroups),
14698
- };
14699
- });
14700
- }
14701
-
14702
- // TODO: Remove with _searchContent
14703
- /**
14704
- * @private
14705
- * Search for Users via the Portal API.
14706
- *
14707
- * **Note** Authentication is required
14708
- *
14709
- * Another trivial comment to force a release
14710
- *
14711
- * Note: in the future, there may be options to search via
14712
- * a Hub specific API
14713
- * @param filter
14714
- * @param options
14715
- * @returns
14716
- */
14717
- function _searchUsers(filter, options) {
14718
- return __awaiter(this, void 0, void 0, function () {
14719
- var expanded, api, searchOptions_1, props;
14720
- return __generator(this, function (_a) {
14721
- Logger.warn("DEPRECATION: _searchUsers will be removed; switch to hubSearch(...)");
14722
- // JS Clients may not pass in authentication
14723
- if (!options.authentication) {
14724
- throw new Error("Authentication required to search for users.");
14725
- }
14726
- expanded = expandUserFilter(filter);
14727
- api = expandApi(options.api || "arcgis");
14728
- if (api.type === "arcgis") {
14729
- searchOptions_1 = serializeUserFilterForPortal(expanded);
14730
- props = [
14731
- "authentication",
14732
- "num",
14733
- "sortField",
14734
- "sortOrder",
14735
- "site",
14736
- "start",
14737
- ];
14738
- // copy the props over
14739
- props.forEach(function (prop) {
14740
- if (options.hasOwnProperty(prop)) {
14741
- searchOptions_1[prop] = options[prop];
14742
- }
14743
- });
14744
- return [2 /*return*/, searchPortalUsers(searchOptions_1)];
14745
- }
14746
- else {
14747
- throw new Error("_searchUsers is not implemented for non-arcgis apis");
14748
- }
14749
- });
14750
- });
14751
- }
14752
- /**
14753
- * Internal function that executes the user search along with
14754
- * some simple enrichments
14755
- * @param searchOptions
14756
- * @returns
14757
- */
14758
- function searchPortalUsers(searchOptions) {
14759
- var portalUrl = searchOptions.authentication.portal;
14760
- var token = searchOptions.authentication.token;
14761
- // Partially applied functions for mapping over the results
14762
- var userLinkify = function (user) {
14763
- user.profileUrl = searchOptions.site.item.url + "/people/" + user.username + "/profile";
14764
- return user;
14765
- };
14766
- var thumbnailify = function (user) {
14767
- if (user.thumbnail) {
14768
- user.thumbnailUrl = getUserThumbnailUrl(portalUrl, user, token);
14769
- }
14770
- return user;
14771
- };
14772
- return searchUsers(searchOptions).then(function (response) {
14773
- var _a, _b;
14774
- var hasNext = response.nextStart > -1;
14775
- // upgrade thumbnail url
14776
- var results = response.results.map(thumbnailify);
14777
- // generate the site team url if site url is provided
14778
- if ((_b = (_a = searchOptions.site) === null || _a === void 0 ? void 0 : _a.item) === null || _b === void 0 ? void 0 : _b.url) {
14779
- results = response.results.map(userLinkify);
14780
- }
14781
- return {
14782
- hasNext: hasNext,
14783
- total: response.total,
14784
- results: results,
14785
- next: getNextFunction(searchOptions, response.nextStart, response.total, searchPortalUsers),
14786
- };
14787
- });
14788
- }
14789
-
14790
- /**
14791
- * @private
14792
- * Apply the sortState to SortOptions
14793
- *
14794
- * @param sortOptions
14795
- * @param sortState
14796
- * @returns
14797
- */
14798
- function applySortState(sortOptions, sortState) {
14799
- var updated = cloneObject$1(sortOptions);
14800
- if (sortState) {
14801
- var _a = sortState.split("|"), label = _a[0], attribute = _a[1], order = _a[2];
14802
- updated.label = label;
14803
- updated.attribute = attribute;
14804
- updated.order = order;
14805
- }
14806
- return updated;
14807
- }
14808
- /**
14809
- * @private
14810
- * Apply FacetState to a Facet
14811
- * @param facet
14812
- * @param state
14813
- * @returns
14814
- */
14815
- function applyFacetState(facet, state) {
14816
- var updated = cloneObject$1(facet);
14817
- switch (facet.display) {
14818
- case "single-select":
14819
- updated = applySingleSelectFacetState(facet, state);
14820
- break;
14821
- case "multi-select":
14822
- updated = applyMultiSelectFacetState(facet, state);
14823
- break;
14824
- }
14825
- return updated;
14826
- }
14827
- /**
14828
- * @private
14829
- * Apply the Facet State onto a single-select facet
14830
- *
14831
- * Intentionally mutates the facet.
14832
- * @param facet
14833
- * @param state
14834
- * @returns
14835
- */
14836
- function applySingleSelectFacetState(facet, state) {
14837
- var updated = cloneObject$1(facet);
14838
- updated.options = updated.options.map(function (o) {
14839
- o.selected = o.key === state[facet.key];
14840
- return o;
14841
- });
14842
- return updated;
14843
- }
14844
- /**
14845
- * @private
14846
- * Serialize single-select facet into IFacetState
14847
- * @param facet
14848
- * @returns
14849
- */
14850
- function serializeSingleSelectFacetState(facet) {
14851
- var state = {};
14852
- var selected = facet.options.find(function (o) { return o.selected; });
14853
- if (selected) {
14854
- state[facet.key] = selected.key;
14855
- }
14856
- else {
14857
- state[facet.key] = null;
14858
- }
14859
- return state;
14860
- }
14861
- /**
14862
- * @private
14863
- * Apply the Facet State onto a multi-select Facet
14864
- *
14865
- * Intentionally mutates the facet.
14866
- * @param facet
14867
- * @param state
14868
- * @returns
14869
- */
14870
- function applyMultiSelectFacetState(facet, state) {
14871
- var _a;
14872
- var updated = cloneObject$1(facet);
14873
- var selectedKeys = ((_a = state[facet.key]) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
14874
- updated.options = updated.options.map(function (o) {
14875
- o.selected = selectedKeys.includes(o.key);
14876
- return o;
14877
- });
14878
- return updated;
14879
- }
14880
- /**
14881
- * @private
14882
- * Serialize multi-select facet into IFacetState
14883
- * @param facet
14884
- * @returns
14885
- */
14886
- function serializeMultiSelectFacetState(facet) {
14887
- var state = {};
14888
- var selected = facet.options.filter(function (o) { return o.selected; });
14889
- var value = selected.map(function (o) { return o.key; }).join(",");
14890
- if (value.length) {
14891
- state[facet.key] = value;
14892
- }
14893
- else {
14894
- state[facet.key] = null;
14895
- }
14896
- return state;
14897
- }
14898
- /**
14899
- * @private
14900
- * Serialize the state of the SortOption into a key/value pair
14901
- *
14902
- * Called from the Sort component
14903
- * @param sort
14904
- * @returns
14905
- */
14906
- function serializeSortState(sort) {
14907
- return sort.label + "|" + sort.attribute + "|" + sort.order;
14908
- }
14909
- /**
14910
- * @private
14911
- * Serialize the state of a facet into a key/value pair
14912
- *
14913
- * Called from the various facet components
14914
- * @param facet
14915
- * @returns
14916
- */
14917
- function serializeFacetState(facet) {
14918
- var state = {};
14919
- switch (facet.display) {
14920
- case "single-select":
14921
- state = serializeSingleSelectFacetState(facet);
14922
- break;
14923
- case "multi-select":
14924
- state = serializeMultiSelectFacetState(facet);
14925
- break;
14926
- }
14927
- return state;
14928
- }
14929
-
14930
- /**
14931
- * Apply ICollectionState to an ICollection
14932
- *
14933
- * Typically used in a Gallery or Catalog component to
14934
- * set the inital state, based on values deserialized
14935
- * from a query string
14936
- * @param collection
14937
- * @param state
14938
- * @returns
14939
- */
14940
- function applyCollectionState(collection, state) {
14941
- var updated = cloneObject$1(collection);
14942
- // Apply default query
14943
- if (state.query) {
14944
- updated.defaultQuery = state.query;
14945
- }
14946
- // Apply Sort State
14947
- updated.sortOption = applySortState(updated.sortOption, state.sort);
14948
- // Look for state props for the facets and apply them
14949
- updated.facets = updated.facets.map(function (facet) {
14950
- // see if there is a key for this facet on the state
14951
- if (Object.keys(state).includes(facet.key)) {
14952
- var facetState = {};
14953
- facetState[facet.key] = state[facet.key];
14954
- return applyFacetState(facet, facetState);
14955
- }
14956
- else {
14957
- // Ensure all options are not selected
14958
- // because they were not included in the state
14959
- facet.options.forEach(function (opt) {
14960
- opt.selected = false;
14961
- });
14962
- return facet;
14963
- }
14964
- });
14965
- //
14966
- return updated;
14967
- }
14968
- /**
14969
- * Serialize the current state of a collection into a hash that
14970
- * can be converted into a query string
14971
- * @param collection
14972
- * @returns
14973
- */
14974
- function serializeCollectionState(collection) {
14975
- var state = {};
14976
- if (collection.defaultQuery) {
14977
- state.query = collection.defaultQuery;
14978
- }
14979
- if (collection.sortOption) {
14980
- state.sort = serializeSortState(collection.sortOption);
14981
- }
14982
- var facetState = (collection.facets || []).reduce(function (s, facet) {
14983
- return __assign(__assign({}, s), serializeFacetState(facet));
14984
- }, {});
14985
- return __assign(__assign({}, state), facetState);
14986
- }
14987
-
14988
- var CATALOG_SCHEMA_VERSION = 1.0;
14989
- /**
14990
- * Apply schema upgrades to Catalog objects
14991
- * @param catalog
14992
- * @returns
14993
- */
14994
- function upgradeCatalogSchema(catalog) {
14995
- var clone = cloneObject$1(catalog);
14996
- if (getProp(clone, "schemaVersion") === CATALOG_SCHEMA_VERSION) {
14997
- return clone;
14998
- }
14999
- else {
15000
- // apply migrations in order
15001
- clone = applyCatalogSchema(clone);
15002
- return clone;
15003
- }
15004
- }
15005
- /**
15006
- * Apply the Catalog schema to the original, unversioned
15007
- * site catalog objects
15008
- * @param original
13468
+ * Apply the Catalog schema to the original, unversioned
13469
+ * site catalog objects
13470
+ * @param original
15009
13471
  * @returns
15010
13472
  */
15011
13473
  function applyCatalogSchema(original) {
@@ -15040,45 +13502,6 @@
15040
13502
  return catalog;
15041
13503
  }
15042
13504
  }
15043
- /**
15044
- * DEPRECATED: Use upgradeCatalogSchema(...)
15045
- * @param original
15046
- */
15047
- /* istanbul ignore next */
15048
- function convertCatalog(original) {
15049
- return upgradeCatalogSchema(original);
15050
- }
15051
-
15052
- /**
15053
- * Determine if a Filter is "empty"
15054
- * @param filter
15055
- * @returns
15056
- */
15057
- function isEmptyFilter(filter) {
15058
- // if it has one property, filterType, it's empty
15059
- return (Object.keys(filter).length === 1 && filter.hasOwnProperty("filterType"));
15060
- }
15061
- /**
15062
- * Determine if a filterGroup is "empty"
15063
- * @param filterGroup
15064
- * @returns
15065
- */
15066
- function isEmptyFilterGroup(filterGroup) {
15067
- // if filters array is empty
15068
- if (filterGroup.filters.length === 0) {
15069
- return true;
15070
- }
15071
- else {
15072
- // if all filters are empty
15073
- var result = filterGroup.filters.reduce(function (acc, entry) {
15074
- if (acc) {
15075
- acc = isEmptyFilter(entry);
15076
- }
15077
- return acc;
15078
- }, true);
15079
- return result;
15080
- }
15081
- }
15082
13505
 
15083
13506
  /**
15084
13507
  * @private
@@ -15198,7 +13621,6 @@
15198
13621
  var portalAllowList = [
15199
13622
  "access",
15200
13623
  "categories",
15201
- "capabilities",
15202
13624
  "created",
15203
13625
  "description",
15204
13626
  "disabled",
@@ -16337,18 +14759,6 @@
16337
14759
  });
16338
14760
  });
16339
14761
  };
16340
- // DEPRECATED IN FAVOR OF .fetch()
16341
- // TODO: REMOVE AT NEXT MAJOR
16342
- /* istanbul ignore next */
16343
- HubProjectManager.prototype.get = function (identifier, requestOptions) {
16344
- return __awaiter(this, void 0, void 0, function () {
16345
- return __generator(this, function (_a) {
16346
- // tslint:disable-next-line
16347
- console.warn("HubProjectManager.get is deprecated and will be removed. Use .fetch() instead.");
16348
- return [2 /*return*/, this.fetch(identifier, requestOptions)];
16349
- });
16350
- });
16351
- };
16352
14762
  /**
16353
14763
  * Fetch a Project via id or it's slug
16354
14764
  *
@@ -16961,15 +15371,6 @@
16961
15371
  }
16962
15372
  return prms;
16963
15373
  }
16964
- /**
16965
- * @private // keep out of docs
16966
- */
16967
- /* istanbul ignore next */
16968
- function fetchSite(identifier, hubRequestOptions) {
16969
- // tslint:disable-next-line
16970
- console.warn("@esri/hub-common::fetchSite is deprecated. Please use @esri/hub-common::fetchSiteModel instead");
16971
- return fetchSiteModel(identifier, hubRequestOptions);
16972
- }
16973
15374
 
16974
15375
  /**
16975
15376
  * Get a Site Model by it's Item Id, and apply schema upgrades
@@ -18086,7 +16487,7 @@
18086
16487
  */
18087
16488
  function searchPortal$2(searchOptions) {
18088
16489
  return __awaiter(this, void 0, void 0, function () {
18089
- var resp, fn, results, facets, aggregations;
16490
+ var resp, fn, results, aggregations;
18090
16491
  return __generator(this, function (_a) {
18091
16492
  switch (_a.label) {
18092
16493
  case 0: return [4 /*yield*/, searchItems(searchOptions)];
@@ -18098,13 +16499,11 @@
18098
16499
  return [4 /*yield*/, Promise.all(resp.results.map(fn))];
18099
16500
  case 2:
18100
16501
  results = _a.sent();
18101
- facets = convertPortalItemResponseToFacets(resp);
18102
16502
  aggregations = convertPortalAggregations(resp);
18103
16503
  // Construct the return
18104
16504
  return [2 /*return*/, {
18105
16505
  total: resp.total,
18106
16506
  results: results,
18107
- facets: facets,
18108
16507
  aggregations: aggregations,
18109
16508
  hasNext: resp.nextStart > -1,
18110
16509
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$2),
@@ -18144,10 +16543,9 @@
18144
16543
  });
18145
16544
  });
18146
16545
  }
18147
- var WellKnownItemFilters = {
16546
+ var WellKnownItemPredicates = {
18148
16547
  $application: [
18149
16548
  {
18150
- filterType: "item",
18151
16549
  type: {
18152
16550
  any: [
18153
16551
  "Web Mapping Application",
@@ -18162,14 +16560,12 @@
18162
16560
  },
18163
16561
  },
18164
16562
  {
18165
- filterType: "item",
18166
16563
  type: "Web Mapping Experience",
18167
16564
  typekeywords: "EXB Experience",
18168
16565
  },
18169
16566
  ],
18170
16567
  $dashboard: [
18171
16568
  {
18172
- filterType: "item",
18173
16569
  type: {
18174
16570
  any: ["Dashboard"],
18175
16571
  not: ["Operation View"],
@@ -18181,7 +16577,6 @@
18181
16577
  ],
18182
16578
  $dataset: [
18183
16579
  {
18184
- filterType: "item",
18185
16580
  type: {
18186
16581
  any: [
18187
16582
  "Scene Service",
@@ -18216,13 +16611,11 @@
18216
16611
  },
18217
16612
  },
18218
16613
  {
18219
- filterType: "item",
18220
16614
  typekeywords: ["OGC", "Geodata Service"],
18221
16615
  },
18222
16616
  ],
18223
16617
  $document: [
18224
16618
  {
18225
- filterType: "item",
18226
16619
  type: [
18227
16620
  "PDF",
18228
16621
  "Microsoft Excel",
@@ -18238,48 +16631,40 @@
18238
16631
  ],
18239
16632
  $initiative: [
18240
16633
  {
18241
- filterType: "item",
18242
16634
  type: "Hub Initiative",
18243
16635
  },
18244
16636
  ],
18245
16637
  $experience: [
18246
16638
  {
18247
- filterType: "item",
18248
16639
  type: "Web Experience",
18249
16640
  },
18250
16641
  ],
18251
16642
  $feedback: [
18252
16643
  {
18253
- filterType: "item",
18254
16644
  type: "Form",
18255
16645
  },
18256
16646
  ],
18257
16647
  $page: [
18258
16648
  {
18259
- filterType: "item",
18260
16649
  typekeywords: "hubPage",
18261
16650
  },
18262
16651
  ],
18263
16652
  $site: [
18264
16653
  {
18265
- filterType: "item",
18266
16654
  type: ["Hub Site Application", "Site Application"],
18267
16655
  },
18268
16656
  ],
18269
16657
  $storymap: [
18270
16658
  {
18271
- filterType: "item",
18272
16659
  type: "Storymap",
18273
16660
  },
18274
16661
  {
18275
- filterType: "item",
18276
16662
  type: "Web Mapping Application",
18277
16663
  typekeywords: "Story Map",
18278
16664
  },
18279
16665
  ],
18280
16666
  $template: [
18281
16667
  {
18282
- filterType: "item",
18283
16668
  type: [
18284
16669
  "Web Mapping Application",
18285
16670
  "Hub Initiative",
@@ -18294,7 +16679,6 @@
18294
16679
  ],
18295
16680
  $webmap: [
18296
16681
  {
18297
- filterType: "item",
18298
16682
  type: {
18299
16683
  any: ["Web Map", "Web Scene"],
18300
16684
  not: "Web Mapping Application",
@@ -18363,7 +16747,7 @@
18363
16747
  function isWellKnownTypeFilter(key) {
18364
16748
  var result = false;
18365
16749
  if (typeof key === "string") {
18366
- result = key in WellKnownItemFilters;
16750
+ result = key in WellKnownItemPredicates;
18367
16751
  }
18368
16752
  return result;
18369
16753
  }
@@ -18373,14 +16757,7 @@
18373
16757
  * @returns
18374
16758
  */
18375
16759
  function lookupTypePredicates(key) {
18376
- var rawPredicates = WellKnownItemFilters[key];
18377
- // Remove the filterType property as it's not needed in an IPredicate
18378
- var predicates = rawPredicates.map(function (entry) {
18379
- var c = cloneObject$1(entry);
18380
- delete c.filterType;
18381
- return c;
18382
- });
18383
- return predicates;
16760
+ return WellKnownItemPredicates[key];
18384
16761
  }
18385
16762
 
18386
16763
  // ## ## ####### ######## ########
@@ -18395,194 +16772,18 @@
18395
16772
  /**
18396
16773
  * @private
18397
16774
  * Execute item search against the Hub API
18398
- * @param filter
16775
+ * @param query
18399
16776
  * @param options
18400
16777
  * @returns
18401
16778
  */
18402
16779
  /* istanbul ignore next */
18403
- function hubSearchItems(filters, options) {
18404
- var _a;
16780
+ function hubSearchItems(query, options) {
18405
16781
  return __awaiter(this, void 0, void 0, function () {
18406
- var api, apiUrl, cleanFilters, searchRequest, aggs, session, opts, raw, json, token_1, us, tokenizeThubmnailUrl, conversion, results, facets, response, ex_1;
18407
- return __generator(this, function (_b) {
18408
- switch (_b.label) {
18409
- case 0:
18410
- api = expandApi(options.api || "hub");
18411
- apiUrl = api.url + "/api/items/beta/search";
18412
- cleanFilters = [];
18413
- filters.forEach(function (block) {
18414
- var b = {
18415
- operation: block.operation,
18416
- filters: block.filters.map(function (f) {
18417
- var c = cloneObject$1(f);
18418
- delete c.filterType;
18419
- return c;
18420
- }),
18421
- };
18422
- cleanFilters.push(b);
18423
- });
18424
- searchRequest = {
18425
- q: cleanFilters,
18426
- options: {
18427
- num: options.num || 10,
18428
- start: options.start || 1,
18429
- sortField: options.sortField,
18430
- sortOrder: options.sortOrder,
18431
- },
18432
- };
18433
- // Add optional props via setProp b/c typescript really does not like
18434
- // adding properties after defining an object
18435
- if ((_a = options.aggFields) === null || _a === void 0 ? void 0 : _a.length) {
18436
- aggs = [
18437
- {
18438
- mode: "terms",
18439
- fields: options.aggFields,
18440
- num: options.aggLimit || 10,
18441
- },
18442
- ];
18443
- setProp("aggregations", aggs, searchRequest.options);
18444
- }
18445
- if (options.authentication) {
18446
- session = {
18447
- token: options.authentication.token,
18448
- portal: options.authentication.portal,
18449
- };
18450
- setProp("session", session, searchRequest.options);
18451
- }
18452
- opts = {
18453
- method: "POST",
18454
- mode: "cors",
18455
- cache: "no-cache",
18456
- headers: {
18457
- "Content-Type": "application/json",
18458
- },
18459
- body: JSON.stringify(searchRequest),
18460
- };
18461
- _b.label = 1;
18462
- case 1:
18463
- _b.trys.push([1, 5, , 6]);
18464
- return [4 /*yield*/, fetch(apiUrl, opts)];
18465
- case 2:
18466
- raw = _b.sent();
18467
- return [4 /*yield*/, raw.json()];
18468
- case 3:
18469
- json = _b.sent();
18470
- if (options.authentication) {
18471
- us = options.authentication;
18472
- token_1 = us.token;
18473
- }
18474
- tokenizeThubmnailUrl = function (entry) {
18475
- if (token_1 && entry.attributes.access !== "public") {
18476
- entry.attributes.thumbnailUrl = entry.attributes.thumbnailUrl + "?token=" + token_1;
18477
- }
18478
- return entry;
18479
- };
18480
- json.data = json.data.map(tokenizeThubmnailUrl);
18481
- conversion = function (entry) {
18482
- return hubContentToSearchResult(jsonApiToHubContent(entry));
18483
- };
18484
- return [4 /*yield*/, Promise.all(json.data.map(conversion))];
18485
- case 4:
18486
- results = _b.sent();
18487
- facets = convertHubResponseToFacets(json);
18488
- response = {
18489
- total: json.meta.total,
18490
- results: results,
18491
- facets: facets,
18492
- hasNext: json.meta.hasNext,
18493
- next: function () {
18494
- // tslint:disable-next-line
18495
- Promise.resolve(null);
18496
- },
18497
- };
18498
- return [2 /*return*/, Promise.resolve(response)];
18499
- case 5:
18500
- ex_1 = _b.sent();
18501
- // TODO: Turn into a formal error
18502
- throw ex_1;
18503
- case 6: return [2 /*return*/];
18504
- }
16782
+ return __generator(this, function (_a) {
16783
+ throw new Error("Not implemented");
18505
16784
  });
18506
16785
  });
18507
16786
  }
18508
- /**
18509
- * Re-structure a jsonApi data entry into a flat object cast into
18510
- * IHubContent
18511
- * @param data
18512
- * @returns
18513
- */
18514
- /* istanbul ignore next */
18515
- function jsonApiToHubContent(data) {
18516
- var content = cloneObject$1(data.attributes);
18517
- content.id = data.id;
18518
- return content;
18519
- }
18520
- /* istanbul ignore next */
18521
- function hubContentToSearchResult(content) {
18522
- var result = {
18523
- access: content.access,
18524
- id: content.id,
18525
- type: content.type,
18526
- name: content.name,
18527
- owner: content.owner,
18528
- summary: content.snippet || content.description,
18529
- createdDate: new Date(content.createdDate),
18530
- createdDateSource: content.createdDateSource,
18531
- updatedDate: new Date(content.updatedDate),
18532
- updatedDateSource: content.updatedDateSource,
18533
- thumbnailUrl: content.thumbnailUrl,
18534
- metadata: [],
18535
- family: content.family,
18536
- urls: {
18537
- portalHome: "not-implemented",
18538
- relative: "not-implemented",
18539
- },
18540
- };
18541
- // TODO: Per-type plucking of props into the `meta` hash for use in the card components
18542
- return Promise.resolve(result);
18543
- }
18544
- /* istanbul ignore next */
18545
- function convertHubResponseToFacets(response, operation) {
18546
- var _a;
18547
- if (operation === void 0) { operation = "OR"; }
18548
- var result = [];
18549
- if ((_a = response.meta) === null || _a === void 0 ? void 0 : _a.aggregations) {
18550
- var meta = response.meta;
18551
- meta.aggregations.forEach(function (entry) {
18552
- // Dyanmic facets typically "AND" so we are refining
18553
- var facet = {
18554
- label: entry.field,
18555
- key: entry.field,
18556
- aggField: entry.field,
18557
- display: "multi-select",
18558
- operation: operation,
18559
- };
18560
- var options = [];
18561
- entry.values.forEach(function (fv) {
18562
- var filter = {
18563
- filterType: "item",
18564
- };
18565
- // construct the filter based on the operation
18566
- var matchKey = operation === "OR" ? "any" : "all";
18567
- var filterMatchOption = {};
18568
- filterMatchOption[matchKey] = [fv.value];
18569
- filter[entry.field] = filterMatchOption;
18570
- // construct the FacetOption
18571
- var fo = {
18572
- label: fv.value + " (" + fv.count + ")",
18573
- key: fv.value,
18574
- count: fv.count,
18575
- selected: false,
18576
- filters: [filter],
18577
- };
18578
- options.push(fo);
18579
- });
18580
- facet.options = options;
18581
- result.push(facet);
18582
- });
18583
- }
18584
- return result;
18585
- }
18586
16787
 
18587
16788
  /**
18588
16789
  * @private
@@ -18655,7 +16856,6 @@
18655
16856
  return [2 /*return*/, {
18656
16857
  total: resp.total,
18657
16858
  results: results,
18658
- facets: [],
18659
16859
  hasNext: resp.nextStart > -1,
18660
16860
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$1),
18661
16861
  }];
@@ -18756,7 +16956,6 @@
18756
16956
  return [2 /*return*/, {
18757
16957
  total: resp.total,
18758
16958
  results: results,
18759
- facets: [],
18760
16959
  hasNext: resp.nextStart > -1,
18761
16960
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal),
18762
16961
  }];
@@ -18785,26 +16984,6 @@
18785
16984
  });
18786
16985
  }
18787
16986
 
18788
- /**
18789
- * @private
18790
- * TEMPORARY - this function only exists to allow incremental
18791
- * changes and should be removed as soon as arcgis-hub-gallery
18792
- * is changed to call `hubSearch(...)` directly
18793
- *
18794
- * Default's to search ArcGIS Portal but can delegate
18795
- * to Hub API when it's available.
18796
- * @param filterGroups
18797
- * @param options
18798
- * @returns
18799
- */
18800
- function hubSearchQuery(query, options) {
18801
- return __awaiter(this, void 0, void 0, function () {
18802
- return __generator(this, function (_a) {
18803
- // delegate
18804
- return [2 /*return*/, hubSearch(query, options)];
18805
- });
18806
- });
18807
- }
18808
16987
  /**
18809
16988
  * Main entrypoint for searching via Hub
18810
16989
  *
@@ -21085,9 +19264,6 @@
21085
19264
  exports._processInvite = _processInvite;
21086
19265
  exports._processPrimaryEmail = _processPrimaryEmail;
21087
19266
  exports._processSecondaryEmail = _processSecondaryEmail;
21088
- exports._searchContent = _searchContent;
21089
- exports._searchGroups = _searchGroups;
21090
- exports._searchUsers = _searchUsers;
21091
19267
  exports._unprotectAndRemoveGroup = _unprotectAndRemoveGroup;
21092
19268
  exports._unprotectAndRemoveItem = _unprotectAndRemoveItem;
21093
19269
  exports.addContextToSlug = addContextToSlug;
@@ -21097,13 +19273,11 @@
21097
19273
  exports.addSiteDomains = addSiteDomains;
21098
19274
  exports.addSolutionResourceUrlToAssets = addSolutionResourceUrlToAssets;
21099
19275
  exports.addUsersToGroup = addUsersToGroup;
21100
- exports.applyCollectionState = applyCollectionState;
21101
19276
  exports.applyPropertiesToItems = applyPropertiesToItems;
21102
19277
  exports.arrayToObject = arrayToObject;
21103
19278
  exports.atob = abab.atob;
21104
19279
  exports.autoAddUsers = autoAddUsers;
21105
19280
  exports.bBoxToExtent = bBoxToExtent;
21106
- exports.bBoxToPolygon = bBoxToPolygon;
21107
19281
  exports.batch = batch;
21108
19282
  exports.btoa = abab.btoa;
21109
19283
  exports.buildDraft = buildDraft;
@@ -21123,13 +19297,8 @@
21123
19297
  exports.compose = compose;
21124
19298
  exports.composeContent = composeContent;
21125
19299
  exports.constructSlug = constructSlug;
21126
- exports.convertCatalog = convertCatalog;
21127
- exports.convertContentDefinitionToFilter = convertContentDefinitionToFilter;
21128
- exports.convertContentFilterToSearchOptions = convertContentFilterToSearchOptions;
21129
19300
  exports.convertItemToProject = convertItemToProject;
21130
19301
  exports.convertItemToSite = convertItemToSite;
21131
- exports.convertPortalItemResponseToFacets = convertPortalItemResponseToFacets;
21132
- exports.convertPortalResponseToFacets = convertPortalResponseToFacets;
21133
19302
  exports.convertSolutionTemplateResourcesToAssets = convertSolutionTemplateResourcesToAssets;
21134
19303
  exports.convertToWellKnownLocale = convertToWellKnownLocale;
21135
19304
  exports.convertUrlsToAnchorTags = convertUrlsToAnchorTags;
@@ -21167,10 +19336,6 @@
21167
19336
  exports.ensureUniqueString = ensureUniqueString;
21168
19337
  exports.expandApi = expandApi;
21169
19338
  exports.expandApis = expandApis;
21170
- exports.expandContentFilter = expandContentFilter;
21171
- exports.expandGroupFilter = expandGroupFilter;
21172
- exports.expandTypeField = expandTypeField;
21173
- exports.expandUserFilter = expandUserFilter;
21174
19339
  exports.extend = extend;
21175
19340
  exports.extentToBBox = extentToBBox;
21176
19341
  exports.extentToPolygon = extentToPolygon;
@@ -21187,7 +19352,6 @@
21187
19352
  exports.fetchOrg = fetchOrg;
21188
19353
  exports.fetchOrgLimits = fetchOrgLimits;
21189
19354
  exports.fetchProject = fetchProject;
21190
- exports.fetchSite = fetchSite;
21191
19355
  exports.fetchSiteModel = fetchSiteModel;
21192
19356
  exports.filterBy = filterBy;
21193
19357
  exports.findBy = findBy;
@@ -21196,7 +19360,6 @@
21196
19360
  exports.generateRandomString = generateRandomString;
21197
19361
  exports.getCategory = getCategory;
21198
19362
  exports.getContentIdentifier = getContentIdentifier;
21199
- exports.getContentSiteUrls = getContentSiteUrls;
21200
19363
  exports.getContentTypeIcon = getContentTypeIcon;
21201
19364
  exports.getContentTypeLabel = getContentTypeLabel;
21202
19365
  exports.getCulture = getCulture;
@@ -21221,7 +19384,6 @@
21221
19384
  exports.getItemDataUrl = getItemDataUrl;
21222
19385
  exports.getItemHomeUrl = getItemHomeUrl;
21223
19386
  exports.getItemHubId = getItemHubId;
21224
- exports.getItemHubType = getItemHubType;
21225
19387
  exports.getItemLayer = getItemLayer;
21226
19388
  exports.getItemLayerId = getItemLayerId;
21227
19389
  exports.getItemThumbnailUrl = getItemThumbnailUrl;
@@ -21259,9 +19421,7 @@
21259
19421
  exports.getWithDefault = getWithDefault$1;
21260
19422
  exports.hasBasePriv = hasBasePriv;
21261
19423
  exports.hubApiRequest = hubApiRequest;
21262
- exports.hubApiSearch = hubApiSearch;
21263
19424
  exports.hubSearch = hubSearch;
21264
- exports.hubSearchQuery = hubSearchQuery;
21265
19425
  exports.includes = includes;
21266
19426
  exports.incrementString = incrementString;
21267
19427
  exports.interpolate = interpolate;
@@ -21271,9 +19431,6 @@
21271
19431
  exports.isDomainForLegacySite = isDomainForLegacySite;
21272
19432
  exports.isDomainUsedElsewhere = isDomainUsedElsewhere;
21273
19433
  exports.isDownloadable = isDownloadable;
21274
- exports.isEmptyFilter = isEmptyFilter;
21275
- exports.isEmptyFilterGroup = isEmptyFilterGroup;
21276
- exports.isExtentCoordinateArray = isExtentCoordinateArray;
21277
19434
  exports.isFeatureService = isFeatureService$1;
21278
19435
  exports.isFieldworkerView = isFieldworkerView;
21279
19436
  exports.isGuid = isGuid;
@@ -21291,13 +19448,7 @@
21291
19448
  exports.mapBy = mapBy;
21292
19449
  exports.maybeAdd = maybeAdd;
21293
19450
  exports.maybePush = maybePush;
21294
- exports.mergeContentFilter = mergeContentFilter;
21295
- exports.mergeDateRange = mergeDateRange;
21296
- exports.mergeGroupFilters = mergeGroupFilters;
21297
- exports.mergeMatchOptions = mergeMatchOptions;
21298
19451
  exports.mergeObjects = mergeObjects;
21299
- exports.mergeSearchOptions = mergeSearchOptions$1;
21300
- exports.mergeUserFilters = mergeUserFilters;
21301
19452
  exports.normalizeItemType = normalizeItemType;
21302
19453
  exports.normalizeSolutionTemplateItem = normalizeSolutionTemplateItem;
21303
19454
  exports.objectToArray = objectToArray;
@@ -21319,18 +19470,9 @@
21319
19470
  exports.saveSession = saveSession;
21320
19471
  exports.searchProjects = searchProjects;
21321
19472
  exports.searchSites = searchSites;
21322
- exports.serializeCollectionState = serializeCollectionState;
21323
- exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
21324
- exports.serializeDateRange = serializeDateRange$1;
21325
- exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
21326
- exports.serializeMatchOptions = serializeMatchOptions$1;
21327
19473
  exports.serializeModel = serializeModel;
21328
19474
  exports.serializeQueryForPortal = serializeQueryForPortal;
21329
19475
  exports.serializeSpatialReference = serializeSpatialReference;
21330
- exports.serializeStringOrArray = serializeStringOrArray$1;
21331
- exports.serializeUserFilterForPortal = serializeUserFilterForPortal;
21332
- exports.setContentHubId = setContentHubId;
21333
- exports.setContentSiteUrls = setContentSiteUrls;
21334
19476
  exports.setContentType = setContentType;
21335
19477
  exports.setItemThumbnail = setItemThumbnail;
21336
19478
  exports.setProp = setProp;