@esri/hub-common 9.32.0 → 9.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/es2017/content/_internal.js +2 -1
  2. package/dist/es2017/content/_internal.js.map +1 -1
  3. package/dist/es2017/content/compose.js +6 -9
  4. package/dist/es2017/content/compose.js.map +1 -1
  5. package/dist/es2017/content/get-family.js +3 -0
  6. package/dist/es2017/content/get-family.js.map +1 -1
  7. package/dist/es2017/search/filter-utils.js +149 -0
  8. package/dist/es2017/search/filter-utils.js.map +1 -0
  9. package/dist/es2017/search/index.js +1 -0
  10. package/dist/es2017/search/index.js.map +1 -1
  11. package/dist/es2017/search/types/IHubSearchResponse.js +1 -0
  12. package/dist/es2017/search/types/IHubSearchResponse.js.map +1 -0
  13. package/dist/es2017/search/types/index.js +1 -0
  14. package/dist/es2017/search/types/index.js.map +1 -1
  15. package/dist/es2017/search/utils.js +5 -1
  16. package/dist/es2017/search/utils.js.map +1 -1
  17. package/dist/es2017/types.js.map +1 -1
  18. package/dist/esm/content/_internal.js +2 -1
  19. package/dist/esm/content/_internal.js.map +1 -1
  20. package/dist/esm/content/compose.js +6 -9
  21. package/dist/esm/content/compose.js.map +1 -1
  22. package/dist/esm/content/get-family.js +3 -0
  23. package/dist/esm/content/get-family.js.map +1 -1
  24. package/dist/esm/search/filter-utils.js +152 -0
  25. package/dist/esm/search/filter-utils.js.map +1 -0
  26. package/dist/esm/search/index.js +1 -0
  27. package/dist/esm/search/index.js.map +1 -1
  28. package/dist/esm/search/types/IHubSearchResponse.js +1 -0
  29. package/dist/esm/search/types/IHubSearchResponse.js.map +1 -0
  30. package/dist/esm/search/types/index.js +1 -0
  31. package/dist/esm/search/types/index.js.map +1 -1
  32. package/dist/esm/search/utils.js +5 -1
  33. package/dist/esm/search/utils.js.map +1 -1
  34. package/dist/esm/types.js.map +1 -1
  35. package/dist/node/content/_internal.js +2 -1
  36. package/dist/node/content/_internal.js.map +1 -1
  37. package/dist/node/content/compose.js +6 -9
  38. package/dist/node/content/compose.js.map +1 -1
  39. package/dist/node/content/get-family.js +3 -0
  40. package/dist/node/content/get-family.js.map +1 -1
  41. package/dist/node/search/filter-utils.js +154 -0
  42. package/dist/node/search/filter-utils.js.map +1 -0
  43. package/dist/node/search/index.js +1 -0
  44. package/dist/node/search/index.js.map +1 -1
  45. package/dist/node/search/types/IHubSearchResponse.js +3 -0
  46. package/dist/node/search/types/IHubSearchResponse.js.map +1 -0
  47. package/dist/node/search/types/index.js +1 -0
  48. package/dist/node/search/types/index.js.map +1 -1
  49. package/dist/node/search/utils.js +5 -1
  50. package/dist/node/search/utils.js.map +1 -1
  51. package/dist/node/types.js.map +1 -1
  52. package/dist/types/content/compose.d.ts +1 -1
  53. package/dist/types/search/filter-utils.d.ts +18 -0
  54. package/dist/types/search/index.d.ts +1 -0
  55. package/dist/types/search/types/IHubSearchResponse.d.ts +17 -0
  56. package/dist/types/search/types/index.d.ts +1 -0
  57. package/dist/types/search/types/types.d.ts +7 -0
  58. package/dist/types/search/utils.d.ts +1 -0
  59. package/dist/types/types.d.ts +1 -1
  60. package/dist/umd/common.umd.js +183 -28
  61. package/dist/umd/common.umd.js.map +1 -1
  62. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.31.3 - Tue May 17 2022 15:35:53 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.33.0 - Fri May 20 2022 15:01:18 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -6566,6 +6566,9 @@
6566
6566
  case "report template":
6567
6567
  family = "content";
6568
6568
  break;
6569
+ case "hub project":
6570
+ family = "project";
6571
+ break;
6569
6572
  default:
6570
6573
  // by default derive from collection
6571
6574
  family = collectionToFamily(getCollection(type));
@@ -6660,6 +6663,7 @@
6660
6663
  "document",
6661
6664
  "map",
6662
6665
  "template",
6666
+ "project",
6663
6667
  ];
6664
6668
  // default to the catchall content route
6665
6669
  var path = "/content";
@@ -6885,7 +6889,7 @@
6885
6889
  */
6886
6890
  var isDataSourceOfItem = function (resource, item) {
6887
6891
  var serviceUrl = item.url && parseServiceUrl(item.url);
6888
- return serviceUrl && resource.linkage.includes(serviceUrl);
6892
+ return (serviceUrl && resource.linkage && resource.linkage.includes(serviceUrl));
6889
6893
  };
6890
6894
  /**
6891
6895
  * Returns the url for an additional resource.
@@ -7374,7 +7378,7 @@
7374
7378
  };
7375
7379
  // public API
7376
7380
  /**
7377
- * DEPRECATED: Compute the content type icon based on the content type
7381
+ * Compute the content type calcite-icon based on the content type
7378
7382
  * @param content type
7379
7383
  * @returns content type icon
7380
7384
  */
@@ -7418,6 +7422,7 @@
7418
7422
  hubInitiative: "initiative",
7419
7423
  hubInitiativeTemplate: "initiative-template",
7420
7424
  hubPage: "browser",
7425
+ hubProject: "briefcase",
7421
7426
  hubSiteApplication: "web",
7422
7427
  image: "file-image",
7423
7428
  imageService: "data",
@@ -7874,17 +7879,13 @@
7874
7879
  get orgId() {
7875
7880
  // NOTE: it's undocumented, but the portal API will return orgId for items... sometimes
7876
7881
  return org ? org.id : item.orgId || (ownerUser === null || ownerUser === void 0 ? void 0 : ownerUser.orgId);
7877
- },
7882
+ }, get contentTypeIcon() {
7883
+ /* Note: only returns calcite-icons */
7884
+ return getContentTypeIcon(type);
7885
+ },
7878
7886
  // deprecated properties
7879
7887
  // TODO: should we add these in legacy wrappers
7880
7888
  // like itemToContent or datasetToContent instead?
7881
- get contentTypeIcon() {
7882
- /* tslint:disable no-console */
7883
- console.warn(
7884
- /* tslint:enable no-console */
7885
- "DEPRECATED: it is now the responsibility of the consuming package to determine the icon");
7886
- return getContentTypeIcon(type);
7887
- },
7888
7889
  get license() {
7889
7890
  /* tslint:disable no-console */
7890
7891
  console.warn("DEPRECATED: use structuredLicense instead");
@@ -13141,11 +13142,12 @@
13141
13142
  /**
13142
13143
  * @private
13143
13144
  * Serialize a `MatchOptions` into `q` or `filter` on an `ISearchOptions`
13145
+ * DEPRECATED: Serialization should be handled in filter-utils.ts
13144
13146
  * @param key
13145
13147
  * @param opts
13146
13148
  * @returns
13147
13149
  */
13148
- function serializeMatchOptions(key, opts) {
13150
+ function serializeMatchOptions$1(key, opts) {
13149
13151
  var result = {
13150
13152
  q: "",
13151
13153
  filter: "",
@@ -13170,7 +13172,7 @@
13170
13172
  var groupFilterableFields = ["title", "typekeywords", "owner"];
13171
13173
  var filterableFields = __spreadArrays(userFilterableFields, itemFilterableFields, groupFilterableFields);
13172
13174
  if (filterableFields.includes(key)) {
13173
- result.filter = serializeStringOrArray("AND", key, opts.exact);
13175
+ result.filter = serializeStringOrArray$1("AND", key, opts.exact);
13174
13176
  }
13175
13177
  else {
13176
13178
  // Treat it the same as .all
@@ -13196,18 +13198,18 @@
13196
13198
  }
13197
13199
  // Handle the other props
13198
13200
  if (opts.any) {
13199
- result.q = serializeStringOrArray("OR", key, opts.any);
13201
+ result.q = serializeStringOrArray$1("OR", key, opts.any);
13200
13202
  }
13201
13203
  if (opts.all) {
13202
13204
  result.q =
13203
13205
  (result.q ? result.q + " AND " : "") +
13204
- serializeStringOrArray("AND", key, opts.all);
13206
+ serializeStringOrArray$1("AND", key, opts.all);
13205
13207
  }
13206
13208
  if (opts.not) {
13207
13209
  // negate the entries if they are not
13208
13210
  result.q =
13209
13211
  (result.q ? result.q + " AND " : "") +
13210
- serializeStringOrArray("OR", "-" + key, opts.not);
13212
+ serializeStringOrArray$1("OR", "-" + key, opts.not);
13211
13213
  }
13212
13214
  return result;
13213
13215
  }
@@ -13218,7 +13220,7 @@
13218
13220
  * @param range
13219
13221
  * @returns
13220
13222
  */
13221
- function serializeDateRange(key, range) {
13223
+ function serializeDateRange$1(key, range) {
13222
13224
  return {
13223
13225
  q: key + ":[" + range.from + " TO " + range.to + "]",
13224
13226
  filter: "",
@@ -13232,10 +13234,13 @@
13232
13234
  * @param value
13233
13235
  * @returns
13234
13236
  */
13235
- function serializeStringOrArray(join, key, value) {
13237
+ function serializeStringOrArray$1(join, key, value) {
13236
13238
  var q = "";
13237
13239
  if (Array.isArray(value)) {
13238
- q = "(" + key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\")";
13240
+ q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
13241
+ if (value.length > 1) {
13242
+ q = "(" + q + ")";
13243
+ }
13239
13244
  }
13240
13245
  else {
13241
13246
  q = key + ":\"" + value + "\"";
@@ -13716,11 +13721,11 @@
13716
13721
  var key = _a[0], value = _a[1];
13717
13722
  // MatchOptions may go into either q or filter
13718
13723
  if (!specialProps.includes(key)) {
13719
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
13724
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
13720
13725
  }
13721
13726
  // Dates only go into q
13722
13727
  if (dateProps.includes(key)) {
13723
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
13728
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
13724
13729
  }
13725
13730
  });
13726
13731
  return result;
@@ -15966,11 +15971,11 @@
15966
15971
  var key = _a[0], value = _a[1];
15967
15972
  // MatchOptions fields
15968
15973
  if (!specialProps.includes(key)) {
15969
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
15974
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
15970
15975
  }
15971
15976
  // Dates only go into q
15972
15977
  if (dateProps.includes(key)) {
15973
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
15978
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
15974
15979
  }
15975
15980
  });
15976
15981
  // searchUserAccess is also a top-level property
@@ -16099,11 +16104,11 @@
16099
16104
  var key = _a[0], value = _a[1];
16100
16105
  // MatchOptions fields
16101
16106
  if (!specialProps.includes(key)) {
16102
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
16107
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
16103
16108
  }
16104
16109
  // Dates only go into q
16105
16110
  if (dateProps.includes(key)) {
16106
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
16111
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
16107
16112
  }
16108
16113
  });
16109
16114
  // disabled is also a top-level property
@@ -16604,6 +16609,154 @@
16604
16609
  return catalog;
16605
16610
  }
16606
16611
 
16612
+ /**
16613
+ * Expand a Filter into it's more expressive structure so it can be
16614
+ * serialized deterministically.
16615
+ *
16616
+ * Props with type `string | string[] | MatchOptions` expand into `IMatchOptions`
16617
+ * Props relative-dates are expanded into formal date-ranges
16618
+ * @param filter
16619
+ * @returns
16620
+ */
16621
+ function expandFilter(filter) {
16622
+ var result = {};
16623
+ var dateProps = ["created", "modified", "lastlogin"];
16624
+ var copyProps = ["filterType", "term", "searchUserAccess"];
16625
+ var nonMatchOptionsFields = __spreadArrays(dateProps, copyProps);
16626
+ // Do the conversion
16627
+ Object.entries(filter).forEach(function (_a) {
16628
+ var key = _a[0], value = _a[1];
16629
+ // Handle MatchOptions fields
16630
+ if (!nonMatchOptionsFields.includes(key)) {
16631
+ // setProp side-steps typescript complaining
16632
+ setProp(key, valueToMatchOptions(value), result);
16633
+ }
16634
+ // Handle Date fields
16635
+ if (dateProps.includes(key)) {
16636
+ var dateFieldValue = cloneObject$1(getProp(filter, key));
16637
+ if (getProp(filter, key + ".type") === "relative-date") {
16638
+ setProp(key, relativeDateToDateRange(dateFieldValue), result);
16639
+ }
16640
+ else {
16641
+ setProp(key, dateFieldValue, result);
16642
+ }
16643
+ }
16644
+ // Handle fields that are just copied forward
16645
+ if (copyProps.includes(key) && filter.hasOwnProperty(key)) {
16646
+ setProp(key, value, result);
16647
+ }
16648
+ });
16649
+ return result;
16650
+ }
16651
+ /**
16652
+ * Serialize a FilterGroup of any type for Portal
16653
+ * @param filterGroups
16654
+ * @returns
16655
+ */
16656
+ function serializeFilterGroupsForPortal(filterGroups) {
16657
+ var result = {
16658
+ q: "",
16659
+ filter: "",
16660
+ };
16661
+ result.q = filterGroups.map(serializeGroup).join(" AND ");
16662
+ return result;
16663
+ }
16664
+ /**
16665
+ * Serialize the filters in a FitlerGroup into a Portal Query
16666
+ * @param group
16667
+ * @returns
16668
+ */
16669
+ function serializeGroup(group) {
16670
+ var operation = group.operation || "AND";
16671
+ var filters = group.filters.map(expandFilter);
16672
+ return filters.map(serializeFilter).join(" " + operation + " ");
16673
+ }
16674
+ /**
16675
+ * Serialize a Filter into a Portal Query
16676
+ * @param filter
16677
+ * @returns
16678
+ */
16679
+ function serializeFilter(filter) {
16680
+ var dateProps = ["created", "modified"];
16681
+ var specialProps = __spreadArrays(["filterType", "searchUserAccess", "term"], dateProps);
16682
+ // TODO: Look at using reduce vs .map and remove the `.filter`
16683
+ var stringFilters = Object.entries(filter)
16684
+ .map(function (_a) {
16685
+ var key = _a[0], value = _a[1];
16686
+ if (!specialProps.includes(key)) {
16687
+ return serializeMatchOptions(key, value);
16688
+ }
16689
+ if (dateProps.includes(key)) {
16690
+ return serializeDateRange(key, value);
16691
+ }
16692
+ if (key === "term") {
16693
+ return value;
16694
+ }
16695
+ })
16696
+ .filter(function (e) { return e !== undefined; });
16697
+ // eslint-disable-next-line unicorn/prefer-ternary
16698
+ if (stringFilters.length > 1) {
16699
+ return "(" + stringFilters.join(" AND ") + ")";
16700
+ }
16701
+ else {
16702
+ return stringFilters[0];
16703
+ }
16704
+ }
16705
+ /**
16706
+ * Serialize MatchOptions into portal syntax
16707
+ * @param key
16708
+ * @param value
16709
+ * @returns
16710
+ */
16711
+ function serializeMatchOptions(key, value) {
16712
+ var result = "";
16713
+ if (value.any) {
16714
+ result = "" + serializeStringOrArray("OR", key, value.any);
16715
+ }
16716
+ if (value.all) {
16717
+ result =
16718
+ (result ? result + " AND " : "") +
16719
+ ("" + serializeStringOrArray("AND", key, value.all));
16720
+ }
16721
+ if (value.not) {
16722
+ // negate the entries if they are not
16723
+ result =
16724
+ (result ? result + " AND " : "") +
16725
+ ("" + serializeStringOrArray("OR", "-" + key, value.not));
16726
+ }
16727
+ // TODO HANDLE EXACT
16728
+ return result;
16729
+ }
16730
+ /**
16731
+ * Serialize a date-range into Portal syntax
16732
+ * @param key
16733
+ * @param range
16734
+ * @returns
16735
+ */
16736
+ function serializeDateRange(key, range) {
16737
+ return key + ":[" + range.from + " TO " + range.to + "]";
16738
+ }
16739
+ /**
16740
+ * Serialize a `string` or `string[]` into a string
16741
+ * @param join
16742
+ * @param key
16743
+ * @param value
16744
+ * @returns
16745
+ */
16746
+ function serializeStringOrArray(join, key, value) {
16747
+ var q = "";
16748
+ if (Array.isArray(value)) {
16749
+ q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
16750
+ if (value.length > 1) {
16751
+ q = "(" + q + ")";
16752
+ }
16753
+ }
16754
+ else {
16755
+ q = key + ":\"" + value + "\"";
16756
+ }
16757
+ return q;
16758
+ }
16759
+
16607
16760
  /**
16608
16761
  * Add telemetry config object
16609
16762
  * @private
@@ -18487,6 +18640,7 @@
18487
18640
  exports.expandApi = expandApi;
18488
18641
  exports.expandApis = expandApis;
18489
18642
  exports.expandContentFilter = expandContentFilter;
18643
+ exports.expandFilter = expandFilter;
18490
18644
  exports.expandGroupFilter = expandGroupFilter;
18491
18645
  exports.expandTypeField = expandTypeField;
18492
18646
  exports.expandUserFilter = expandUserFilter;
@@ -18629,12 +18783,13 @@
18629
18783
  exports.searchSites = searchSites;
18630
18784
  exports.serializeCollectionState = serializeCollectionState;
18631
18785
  exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
18632
- exports.serializeDateRange = serializeDateRange;
18786
+ exports.serializeDateRange = serializeDateRange$1;
18787
+ exports.serializeFilterGroupsForPortal = serializeFilterGroupsForPortal;
18633
18788
  exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
18634
- exports.serializeMatchOptions = serializeMatchOptions;
18789
+ exports.serializeMatchOptions = serializeMatchOptions$1;
18635
18790
  exports.serializeModel = serializeModel;
18636
18791
  exports.serializeSpatialReference = serializeSpatialReference;
18637
- exports.serializeStringOrArray = serializeStringOrArray;
18792
+ exports.serializeStringOrArray = serializeStringOrArray$1;
18638
18793
  exports.serializeUserFilterForPortal = serializeUserFilterForPortal;
18639
18794
  exports.setContentHubId = setContentHubId;
18640
18795
  exports.setContentSiteUrls = setContentSiteUrls;