@esri/hub-common 9.49.0 → 10.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/es2017/search/_internal/hubSearchItems.js +0 -43
  2. package/dist/es2017/search/_internal/hubSearchItems.js.map +1 -1
  3. package/dist/es2017/search/_internal/index.js +0 -1
  4. package/dist/es2017/search/_internal/index.js.map +1 -1
  5. package/dist/es2017/search/_internal/portalSearchGroups.js +0 -1
  6. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  7. package/dist/es2017/search/_internal/portalSearchItems.js +1 -4
  8. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  9. package/dist/es2017/search/_internal/portalSearchUsers.js +0 -1
  10. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
  11. package/dist/es2017/search/_searchContent.js +1 -5
  12. package/dist/es2017/search/_searchContent.js.map +1 -1
  13. package/dist/es2017/search/_searchGroups.js.map +1 -1
  14. package/dist/es2017/search/content-utils.js +2 -67
  15. package/dist/es2017/search/content-utils.js.map +1 -1
  16. package/dist/es2017/search/index.js +0 -1
  17. package/dist/es2017/search/index.js.map +1 -1
  18. package/dist/es2017/search/types/index.js +0 -2
  19. package/dist/es2017/search/types/index.js.map +1 -1
  20. package/dist/es2017/types.js.map +1 -1
  21. package/dist/esm/search/_internal/hubSearchItems.js +1 -45
  22. package/dist/esm/search/_internal/hubSearchItems.js.map +1 -1
  23. package/dist/esm/search/_internal/index.js +0 -1
  24. package/dist/esm/search/_internal/index.js.map +1 -1
  25. package/dist/esm/search/_internal/portalSearchGroups.js +0 -1
  26. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  27. package/dist/esm/search/_internal/portalSearchItems.js +2 -4
  28. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  29. package/dist/esm/search/_internal/portalSearchUsers.js +0 -1
  30. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
  31. package/dist/esm/search/_searchContent.js +1 -5
  32. package/dist/esm/search/_searchContent.js.map +1 -1
  33. package/dist/esm/search/_searchGroups.js.map +1 -1
  34. package/dist/esm/search/content-utils.js +2 -70
  35. package/dist/esm/search/content-utils.js.map +1 -1
  36. package/dist/esm/search/index.js +0 -1
  37. package/dist/esm/search/index.js.map +1 -1
  38. package/dist/esm/search/types/index.js +0 -2
  39. package/dist/esm/search/types/index.js.map +1 -1
  40. package/dist/esm/types.js.map +1 -1
  41. package/dist/node/search/_internal/hubSearchItems.js +1 -45
  42. package/dist/node/search/_internal/hubSearchItems.js.map +1 -1
  43. package/dist/node/search/_internal/index.js +0 -1
  44. package/dist/node/search/_internal/index.js.map +1 -1
  45. package/dist/node/search/_internal/portalSearchGroups.js +0 -1
  46. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  47. package/dist/node/search/_internal/portalSearchItems.js +0 -3
  48. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  49. package/dist/node/search/_internal/portalSearchUsers.js +0 -1
  50. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
  51. package/dist/node/search/_searchContent.js +0 -4
  52. package/dist/node/search/_searchContent.js.map +1 -1
  53. package/dist/node/search/_searchGroups.js.map +1 -1
  54. package/dist/node/search/content-utils.js +3 -70
  55. package/dist/node/search/content-utils.js.map +1 -1
  56. package/dist/node/search/index.js +0 -1
  57. package/dist/node/search/index.js.map +1 -1
  58. package/dist/node/search/types/index.js +0 -2
  59. package/dist/node/search/types/index.js.map +1 -1
  60. package/dist/node/types.js.map +1 -1
  61. package/dist/types/search/_internal/hubSearchItems.d.ts +1 -2
  62. package/dist/types/search/_internal/index.d.ts +0 -1
  63. package/dist/types/search/_searchGroups.d.ts +1 -5
  64. package/dist/types/search/content-utils.d.ts +1 -18
  65. package/dist/types/search/index.d.ts +0 -1
  66. package/dist/types/search/types/ICatalog.d.ts +0 -5
  67. package/dist/types/search/types/ICollection.d.ts +0 -2
  68. package/dist/types/search/types/IHubSearchResponse.d.ts +0 -5
  69. package/dist/types/search/types/index.d.ts +0 -2
  70. package/dist/types/search/types/types.d.ts +0 -2
  71. package/dist/types/types.d.ts +0 -2
  72. package/dist/umd/common.umd.js +3 -327
  73. package/dist/umd/common.umd.js.map +1 -1
  74. package/package.json +1 -1
  75. package/dist/es2017/search/_internal/state.js +0 -155
  76. package/dist/es2017/search/_internal/state.js.map +0 -1
  77. package/dist/es2017/search/collectionState.js +0 -60
  78. package/dist/es2017/search/collectionState.js.map +0 -1
  79. package/dist/es2017/search/types/IFacet.js +0 -1
  80. package/dist/es2017/search/types/IFacet.js.map +0 -1
  81. package/dist/es2017/search/types/IFacetOption.js +0 -1
  82. package/dist/es2017/search/types/IFacetOption.js.map +0 -1
  83. package/dist/esm/search/_internal/state.js +0 -155
  84. package/dist/esm/search/_internal/state.js.map +0 -1
  85. package/dist/esm/search/collectionState.js +0 -61
  86. package/dist/esm/search/collectionState.js.map +0 -1
  87. package/dist/esm/search/types/IFacet.js +0 -1
  88. package/dist/esm/search/types/IFacet.js.map +0 -1
  89. package/dist/esm/search/types/IFacetOption.js +0 -1
  90. package/dist/esm/search/types/IFacetOption.js.map +0 -1
  91. package/dist/node/search/_internal/state.js +0 -166
  92. package/dist/node/search/_internal/state.js.map +0 -1
  93. package/dist/node/search/collectionState.js +0 -65
  94. package/dist/node/search/collectionState.js.map +0 -1
  95. package/dist/node/search/types/IFacet.js +0 -3
  96. package/dist/node/search/types/IFacet.js.map +0 -1
  97. package/dist/node/search/types/IFacetOption.js +0 -3
  98. package/dist/node/search/types/IFacetOption.js.map +0 -1
  99. package/dist/types/search/_internal/state.d.ts +0 -70
  100. package/dist/types/search/collectionState.d.ts +0 -19
  101. package/dist/types/search/types/IFacet.d.ts +0 -62
  102. package/dist/types/search/types/IFacetOption.d.ts +0 -30
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.48.0 - Thu Jul 21 2022 15:41:36 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.49.0 - Thu Jul 21 2022 17:19:07 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -13893,76 +13893,6 @@
13893
13893
  },
13894
13894
  ],
13895
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
- }
13909
- /**
13910
- * @private
13911
- * Convert portal search response to facets
13912
- * Note: Only applicable to an item search
13913
- * @param response
13914
- * @returns
13915
- */
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
- });
13963
- }
13964
- return result;
13965
- }
13966
13896
  /**
13967
13897
  * Merge `Filter<"content">` objects
13968
13898
  *
@@ -14558,7 +14488,6 @@
14558
14488
  searchPromise = Promise.resolve({
14559
14489
  total: 0,
14560
14490
  results: [],
14561
- facets: [],
14562
14491
  hasNext: false,
14563
14492
  next: function () {
14564
14493
  // tslint:disable-next-line
@@ -14602,12 +14531,9 @@
14602
14531
  }
14603
14532
  // add thumbnailUrl
14604
14533
  content = content.map(thumbnailify);
14605
- // convert aggregations into facets
14606
- var facets = convertPortalResponseToFacets(resp);
14607
14534
  return {
14608
14535
  total: resp.total,
14609
14536
  results: content,
14610
- facets: facets,
14611
14537
  hasNext: hasNext,
14612
14538
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$3),
14613
14539
  };
@@ -14787,204 +14713,6 @@
14787
14713
  });
14788
14714
  }
14789
14715
 
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
14716
  var CATALOG_SCHEMA_VERSION = 1.0;
14989
14717
  /**
14990
14718
  * Apply schema upgrades to Catalog objects
@@ -18085,7 +17813,7 @@
18085
17813
  */
18086
17814
  function searchPortal$2(searchOptions) {
18087
17815
  return __awaiter(this, void 0, void 0, function () {
18088
- var resp, fn, results, facets, aggregations;
17816
+ var resp, fn, results, aggregations;
18089
17817
  return __generator(this, function (_a) {
18090
17818
  switch (_a.label) {
18091
17819
  case 0: return [4 /*yield*/, searchItems(searchOptions)];
@@ -18097,13 +17825,11 @@
18097
17825
  return [4 /*yield*/, Promise.all(resp.results.map(fn))];
18098
17826
  case 2:
18099
17827
  results = _a.sent();
18100
- facets = convertPortalItemResponseToFacets(resp);
18101
17828
  aggregations = convertPortalAggregations(resp);
18102
17829
  // Construct the return
18103
17830
  return [2 /*return*/, {
18104
17831
  total: resp.total,
18105
17832
  results: results,
18106
- facets: facets,
18107
17833
  aggregations: aggregations,
18108
17834
  hasNext: resp.nextStart > -1,
18109
17835
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$2),
@@ -18402,7 +18128,7 @@
18402
18128
  function hubSearchItems(filters, options) {
18403
18129
  var _a;
18404
18130
  return __awaiter(this, void 0, void 0, function () {
18405
- var api, apiUrl, cleanFilters, searchRequest, aggs, session, opts, raw, json, token_1, us, tokenizeThubmnailUrl, conversion, results, facets, response, ex_1;
18131
+ var api, apiUrl, cleanFilters, searchRequest, aggs, session, opts, raw, json, token_1, us, tokenizeThubmnailUrl, conversion, results, response, ex_1;
18406
18132
  return __generator(this, function (_b) {
18407
18133
  switch (_b.label) {
18408
18134
  case 0:
@@ -18483,11 +18209,9 @@
18483
18209
  return [4 /*yield*/, Promise.all(json.data.map(conversion))];
18484
18210
  case 4:
18485
18211
  results = _b.sent();
18486
- facets = convertHubResponseToFacets(json);
18487
18212
  response = {
18488
18213
  total: json.meta.total,
18489
18214
  results: results,
18490
- facets: facets,
18491
18215
  hasNext: json.meta.hasNext,
18492
18216
  next: function () {
18493
18217
  // tslint:disable-next-line
@@ -18540,48 +18264,6 @@
18540
18264
  // TODO: Per-type plucking of props into the `meta` hash for use in the card components
18541
18265
  return Promise.resolve(result);
18542
18266
  }
18543
- /* istanbul ignore next */
18544
- function convertHubResponseToFacets(response, operation) {
18545
- var _a;
18546
- if (operation === void 0) { operation = "OR"; }
18547
- var result = [];
18548
- if ((_a = response.meta) === null || _a === void 0 ? void 0 : _a.aggregations) {
18549
- var meta = response.meta;
18550
- meta.aggregations.forEach(function (entry) {
18551
- // Dyanmic facets typically "AND" so we are refining
18552
- var facet = {
18553
- label: entry.field,
18554
- key: entry.field,
18555
- aggField: entry.field,
18556
- display: "multi-select",
18557
- operation: operation,
18558
- };
18559
- var options = [];
18560
- entry.values.forEach(function (fv) {
18561
- var filter = {
18562
- filterType: "item",
18563
- };
18564
- // construct the filter based on the operation
18565
- var matchKey = operation === "OR" ? "any" : "all";
18566
- var filterMatchOption = {};
18567
- filterMatchOption[matchKey] = [fv.value];
18568
- filter[entry.field] = filterMatchOption;
18569
- // construct the FacetOption
18570
- var fo = {
18571
- label: fv.value + " (" + fv.count + ")",
18572
- key: fv.value,
18573
- count: fv.count,
18574
- selected: false,
18575
- filters: [filter],
18576
- };
18577
- options.push(fo);
18578
- });
18579
- facet.options = options;
18580
- result.push(facet);
18581
- });
18582
- }
18583
- return result;
18584
- }
18585
18267
 
18586
18268
  /**
18587
18269
  * @private
@@ -18654,7 +18336,6 @@
18654
18336
  return [2 /*return*/, {
18655
18337
  total: resp.total,
18656
18338
  results: results,
18657
- facets: [],
18658
18339
  hasNext: resp.nextStart > -1,
18659
18340
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal$1),
18660
18341
  }];
@@ -18755,7 +18436,6 @@
18755
18436
  return [2 /*return*/, {
18756
18437
  total: resp.total,
18757
18438
  results: results,
18758
- facets: [],
18759
18439
  hasNext: resp.nextStart > -1,
18760
18440
  next: getNextFunction(searchOptions, resp.nextStart, resp.total, searchPortal),
18761
18441
  }];
@@ -21096,7 +20776,6 @@
21096
20776
  exports.addSiteDomains = addSiteDomains;
21097
20777
  exports.addSolutionResourceUrlToAssets = addSolutionResourceUrlToAssets;
21098
20778
  exports.addUsersToGroup = addUsersToGroup;
21099
- exports.applyCollectionState = applyCollectionState;
21100
20779
  exports.applyPropertiesToItems = applyPropertiesToItems;
21101
20780
  exports.arrayToObject = arrayToObject;
21102
20781
  exports.atob = abab.atob;
@@ -21127,8 +20806,6 @@
21127
20806
  exports.convertContentFilterToSearchOptions = convertContentFilterToSearchOptions;
21128
20807
  exports.convertItemToProject = convertItemToProject;
21129
20808
  exports.convertItemToSite = convertItemToSite;
21130
- exports.convertPortalItemResponseToFacets = convertPortalItemResponseToFacets;
21131
- exports.convertPortalResponseToFacets = convertPortalResponseToFacets;
21132
20809
  exports.convertSolutionTemplateResourcesToAssets = convertSolutionTemplateResourcesToAssets;
21133
20810
  exports.convertToWellKnownLocale = convertToWellKnownLocale;
21134
20811
  exports.convertUrlsToAnchorTags = convertUrlsToAnchorTags;
@@ -21318,7 +20995,6 @@
21318
20995
  exports.saveSession = saveSession;
21319
20996
  exports.searchProjects = searchProjects;
21320
20997
  exports.searchSites = searchSites;
21321
- exports.serializeCollectionState = serializeCollectionState;
21322
20998
  exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
21323
20999
  exports.serializeDateRange = serializeDateRange$1;
21324
21000
  exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;