@esri/hub-common 9.43.3 → 9.44.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 (71) hide show
  1. package/dist/es2017/ArcGISContext.js +1 -1
  2. package/dist/es2017/ArcGISContext.js.map +1 -1
  3. package/dist/es2017/search/Collection.js +71 -0
  4. package/dist/es2017/search/Collection.js.map +1 -0
  5. package/dist/es2017/search/_internal/ifilter-utils.js +221 -0
  6. package/dist/es2017/search/_internal/ifilter-utils.js.map +1 -0
  7. package/dist/es2017/search/_internal/portalSearchGroups.js +47 -2
  8. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  9. package/dist/es2017/search/_internal/portalSearchItems.js +95 -6
  10. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  11. package/dist/es2017/search/_internal/portalSearchUsers.js +46 -1
  12. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
  13. package/dist/es2017/search/filter-utils.js +1 -0
  14. package/dist/es2017/search/filter-utils.js.map +1 -1
  15. package/dist/es2017/search/hubSearch.js +38 -3
  16. package/dist/es2017/search/hubSearch.js.map +1 -1
  17. package/dist/es2017/search/types/IHubCatalog.js +1 -0
  18. package/dist/es2017/search/types/IHubCatalog.js.map +1 -0
  19. package/dist/es2017/search/types/index.js +1 -0
  20. package/dist/es2017/search/types/index.js.map +1 -1
  21. package/dist/esm/ArcGISContext.js +1 -1
  22. package/dist/esm/ArcGISContext.js.map +1 -1
  23. package/dist/esm/search/Collection.js +106 -0
  24. package/dist/esm/search/Collection.js.map +1 -0
  25. package/dist/esm/search/_internal/ifilter-utils.js +222 -0
  26. package/dist/esm/search/_internal/ifilter-utils.js.map +1 -0
  27. package/dist/esm/search/_internal/portalSearchGroups.js +50 -2
  28. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  29. package/dist/esm/search/_internal/portalSearchItems.js +97 -6
  30. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  31. package/dist/esm/search/_internal/portalSearchUsers.js +49 -1
  32. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
  33. package/dist/esm/search/filter-utils.js +1 -0
  34. package/dist/esm/search/filter-utils.js.map +1 -1
  35. package/dist/esm/search/hubSearch.js +41 -3
  36. package/dist/esm/search/hubSearch.js.map +1 -1
  37. package/dist/esm/search/types/IHubCatalog.js +1 -0
  38. package/dist/esm/search/types/IHubCatalog.js.map +1 -0
  39. package/dist/esm/search/types/index.js +1 -0
  40. package/dist/esm/search/types/index.js.map +1 -1
  41. package/dist/node/ArcGISContext.js +1 -1
  42. package/dist/node/ArcGISContext.js.map +1 -1
  43. package/dist/node/search/Collection.js +75 -0
  44. package/dist/node/search/Collection.js.map +1 -0
  45. package/dist/node/search/_internal/ifilter-utils.js +226 -0
  46. package/dist/node/search/_internal/ifilter-utils.js.map +1 -0
  47. package/dist/node/search/_internal/portalSearchGroups.js +49 -3
  48. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  49. package/dist/node/search/_internal/portalSearchItems.js +98 -6
  50. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  51. package/dist/node/search/_internal/portalSearchUsers.js +48 -2
  52. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
  53. package/dist/node/search/filter-utils.js +1 -0
  54. package/dist/node/search/filter-utils.js.map +1 -1
  55. package/dist/node/search/hubSearch.js +39 -3
  56. package/dist/node/search/hubSearch.js.map +1 -1
  57. package/dist/node/search/types/IHubCatalog.js +3 -0
  58. package/dist/node/search/types/IHubCatalog.js.map +1 -0
  59. package/dist/node/search/types/index.js +1 -0
  60. package/dist/node/search/types/index.js.map +1 -1
  61. package/dist/types/search/Collection.d.ts +18 -0
  62. package/dist/types/search/_internal/ifilter-utils.d.ts +4 -0
  63. package/dist/types/search/_internal/portalSearchGroups.d.ts +12 -3
  64. package/dist/types/search/_internal/portalSearchItems.d.ts +28 -4
  65. package/dist/types/search/_internal/portalSearchUsers.d.ts +11 -2
  66. package/dist/types/search/hubSearch.d.ts +2 -1
  67. package/dist/types/search/types/IHubCatalog.d.ts +71 -0
  68. package/dist/types/search/types/index.d.ts +1 -0
  69. package/dist/umd/common.umd.js +485 -44
  70. package/dist/umd/common.umd.js.map +1 -1
  71. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.43.2 - Thu Jun 23 2022 17:43:06 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.43.3 - Fri Jun 24 2022 18:21:01 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -5631,7 +5631,7 @@
5631
5631
  */
5632
5632
  get: function () {
5633
5633
  if (this.isAuthenticated) {
5634
- if (this.isPortal) {
5634
+ if (this.isPortal || !this._portalSelf.urlKey) {
5635
5635
  return "https://" + this._portalSelf.portalHostname;
5636
5636
  }
5637
5637
  else {
@@ -13548,7 +13548,7 @@
13548
13548
  * @param join
13549
13549
  * @returns
13550
13550
  */
13551
- function mergeSearchOptions$1(so1, so2, join) {
13551
+ function mergeSearchOptions$2(so1, so2, join) {
13552
13552
  // TODO: Remove with _searchContent
13553
13553
  Logger.warn("DEPRECATION: mergeSearchOptions will be removed. Work with IFilterGroups<\"group\"> and hubSearch() instead");
13554
13554
  var result = cloneObject$1(so1);
@@ -13569,7 +13569,7 @@
13569
13569
  * @param opts
13570
13570
  * @returns
13571
13571
  */
13572
- function serializeMatchOptions$1(key, opts) {
13572
+ function serializeMatchOptions$2(key, opts) {
13573
13573
  var result = {
13574
13574
  q: "",
13575
13575
  filter: "",
@@ -13594,7 +13594,7 @@
13594
13594
  var groupFilterableFields = ["title", "typekeywords", "owner"];
13595
13595
  var filterableFields = __spreadArrays(userFilterableFields, itemFilterableFields, groupFilterableFields);
13596
13596
  if (filterableFields.includes(key)) {
13597
- result.filter = serializeStringOrArray$1("AND", key, opts.exact);
13597
+ result.filter = serializeStringOrArray$2("AND", key, opts.exact);
13598
13598
  }
13599
13599
  else {
13600
13600
  // Treat it the same as .all
@@ -13620,18 +13620,18 @@
13620
13620
  }
13621
13621
  // Handle the other props
13622
13622
  if (opts.any) {
13623
- result.q = serializeStringOrArray$1("OR", key, opts.any);
13623
+ result.q = serializeStringOrArray$2("OR", key, opts.any);
13624
13624
  }
13625
13625
  if (opts.all) {
13626
13626
  result.q =
13627
13627
  (result.q ? result.q + " AND " : "") +
13628
- serializeStringOrArray$1("AND", key, opts.all);
13628
+ serializeStringOrArray$2("AND", key, opts.all);
13629
13629
  }
13630
13630
  if (opts.not) {
13631
13631
  // negate the entries if they are not
13632
13632
  result.q =
13633
13633
  (result.q ? result.q + " AND " : "") +
13634
- serializeStringOrArray$1("OR", "-" + key, opts.not);
13634
+ serializeStringOrArray$2("OR", "-" + key, opts.not);
13635
13635
  }
13636
13636
  return result;
13637
13637
  }
@@ -13642,7 +13642,7 @@
13642
13642
  * @param range
13643
13643
  * @returns
13644
13644
  */
13645
- function serializeDateRange$1(key, range) {
13645
+ function serializeDateRange$2(key, range) {
13646
13646
  return {
13647
13647
  q: key + ":[" + range.from + " TO " + range.to + "]",
13648
13648
  filter: "",
@@ -13656,7 +13656,7 @@
13656
13656
  * @param value
13657
13657
  * @returns
13658
13658
  */
13659
- function serializeStringOrArray$1(join, key, value) {
13659
+ function serializeStringOrArray$2(join, key, value) {
13660
13660
  var q = "";
13661
13661
  if (Array.isArray(value)) {
13662
13662
  q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
@@ -14144,12 +14144,12 @@
14144
14144
  // from hitting the else
14145
14145
  /* istanbul ignore else */
14146
14146
  if (typeof entry === "object") {
14147
- acc = mergeSearchOptions$1(acc, convertContentFilterToSearchOptions(entry), "OR");
14147
+ acc = mergeSearchOptions$2(acc, convertContentFilterToSearchOptions(entry), "OR");
14148
14148
  }
14149
14149
  return acc;
14150
14150
  }, { q: "", filter: "" });
14151
14151
  // merge with searchOptions using AND
14152
- searchOptions = mergeSearchOptions$1(searchOptions, subFilterOptions, "AND");
14152
+ searchOptions = mergeSearchOptions$2(searchOptions, subFilterOptions, "AND");
14153
14153
  }
14154
14154
  // term is always last, and pre-pended on searchOptions.q
14155
14155
  if (filter.term) {
@@ -14177,11 +14177,11 @@
14177
14177
  var key = _a[0], value = _a[1];
14178
14178
  // MatchOptions may go into either q or filter
14179
14179
  if (!specialProps.includes(key)) {
14180
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14180
+ result = mergeSearchOptions$2(result, serializeMatchOptions$2(key, value), "AND");
14181
14181
  }
14182
14182
  // Dates only go into q
14183
14183
  if (dateProps.includes(key)) {
14184
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14184
+ result = mergeSearchOptions$2(result, serializeDateRange$2(key, value), "AND");
14185
14185
  }
14186
14186
  });
14187
14187
  return result;
@@ -14312,11 +14312,11 @@
14312
14312
  var key = _a[0], value = _a[1];
14313
14313
  // MatchOptions fields
14314
14314
  if (!specialProps.includes(key)) {
14315
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14315
+ result = mergeSearchOptions$2(result, serializeMatchOptions$2(key, value), "AND");
14316
14316
  }
14317
14317
  // Dates only go into q
14318
14318
  if (dateProps.includes(key)) {
14319
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14319
+ result = mergeSearchOptions$2(result, serializeDateRange$2(key, value), "AND");
14320
14320
  }
14321
14321
  });
14322
14322
  // searchUserAccess is also a top-level property
@@ -14452,11 +14452,11 @@
14452
14452
  var key = _a[0], value = _a[1];
14453
14453
  // MatchOptions fields
14454
14454
  if (!specialProps.includes(key)) {
14455
- result = mergeSearchOptions$1(result, serializeMatchOptions$1(key, value), "AND");
14455
+ result = mergeSearchOptions$2(result, serializeMatchOptions$2(key, value), "AND");
14456
14456
  }
14457
14457
  // Dates only go into q
14458
14458
  if (dateProps.includes(key)) {
14459
- result = mergeSearchOptions$1(result, serializeDateRange$1(key, value), "AND");
14459
+ result = mergeSearchOptions$2(result, serializeDateRange$2(key, value), "AND");
14460
14460
  }
14461
14461
  });
14462
14462
  // disabled is also a top-level property
@@ -14974,6 +14974,7 @@
14974
14974
  return catalog;
14975
14975
  }
14976
14976
 
14977
+ // DEPRECATED - REMOVE THIS FILE
14977
14978
  /**
14978
14979
  * Expand a Filter into it's more expressive structure so it can be
14979
14980
  * serialized deterministically.
@@ -15026,7 +15027,7 @@
15026
15027
  */
15027
15028
  function serializeFilterGroupsForPortal(filterGroups) {
15028
15029
  var groupSearchOptions = filterGroups.map(serializeGroup);
15029
- var result = mergeSearchOptions(groupSearchOptions, "AND");
15030
+ var result = mergeSearchOptions$1(groupSearchOptions, "AND");
15030
15031
  return result;
15031
15032
  }
15032
15033
  /**
@@ -15037,9 +15038,9 @@
15037
15038
  function serializeGroup(filterGroup) {
15038
15039
  var operation = filterGroup.operation || "AND";
15039
15040
  var filters = filterGroup.filters.map(expandFilter);
15040
- var filterSearchOptions = filters.map(serializeFilter);
15041
+ var filterSearchOptions = filters.map(serializeFilter$1);
15041
15042
  // combine these searchOptions
15042
- var groupSearchOptions = mergeSearchOptions(filterSearchOptions, operation);
15043
+ var groupSearchOptions = mergeSearchOptions$1(filterSearchOptions, operation);
15043
15044
  //
15044
15045
  if (filters.length > 1) {
15045
15046
  groupSearchOptions.q = "(" + groupSearchOptions.q + ")";
@@ -15051,7 +15052,7 @@
15051
15052
  * @param filter
15052
15053
  * @returns
15053
15054
  */
15054
- function serializeFilter(filter) {
15055
+ function serializeFilter$1(filter) {
15055
15056
  var dateProps = ["created", "modified"];
15056
15057
  var boolProps = ["isopendata"];
15057
15058
  var passThroughProps = ["searchUserAccess", "searchUserName"];
@@ -15067,11 +15068,11 @@
15067
15068
  var so = { q: "" };
15068
15069
  if (!specialProps.includes(key)) {
15069
15070
  qCount++;
15070
- so.q = serializeMatchOptions(key, value);
15071
+ so.q = serializeMatchOptions$1(key, value);
15071
15072
  }
15072
15073
  if (dateProps.includes(key)) {
15073
15074
  qCount++;
15074
- so.q = serializeDateRange(key, value);
15075
+ so.q = serializeDateRange$1(key, value);
15075
15076
  }
15076
15077
  if (boolProps.includes(key)) {
15077
15078
  qCount++;
@@ -15088,13 +15089,13 @@
15088
15089
  })
15089
15090
  .filter(function (e) { return e !== undefined; });
15090
15091
  // merge up all the searchOptions
15091
- var searchOptions = mergeSearchOptions(opts, "AND");
15092
+ var searchOptions = mergeSearchOptions$1(opts, "AND");
15092
15093
  if (qCount > 1) {
15093
15094
  searchOptions.q = "(" + searchOptions.q + ")";
15094
15095
  }
15095
15096
  return searchOptions;
15096
15097
  }
15097
- function mergeSearchOptions(options, operation) {
15098
+ function mergeSearchOptions$1(options, operation) {
15098
15099
  var result = options.reduce(function (acc, entry) {
15099
15100
  // walk the props
15100
15101
  Object.entries(entry).forEach(function (_a) {
@@ -15119,21 +15120,21 @@
15119
15120
  * @param value
15120
15121
  * @returns
15121
15122
  */
15122
- function serializeMatchOptions(key, value) {
15123
+ function serializeMatchOptions$1(key, value) {
15123
15124
  var result = "";
15124
15125
  if (value.any) {
15125
- result = "" + serializeStringOrArray("OR", key, value.any);
15126
+ result = "" + serializeStringOrArray$1("OR", key, value.any);
15126
15127
  }
15127
15128
  if (value.all) {
15128
15129
  result =
15129
15130
  (result ? result + " AND " : "") +
15130
- ("" + serializeStringOrArray("AND", key, value.all));
15131
+ ("" + serializeStringOrArray$1("AND", key, value.all));
15131
15132
  }
15132
15133
  if (value.not) {
15133
15134
  // negate the entries if they are not
15134
15135
  result =
15135
15136
  (result ? result + " AND " : "") +
15136
- ("" + serializeStringOrArray("OR", "-" + key, value.not));
15137
+ ("" + serializeStringOrArray$1("OR", "-" + key, value.not));
15137
15138
  }
15138
15139
  // TODO HANDLE EXACT
15139
15140
  return result;
@@ -15144,7 +15145,7 @@
15144
15145
  * @param range
15145
15146
  * @returns
15146
15147
  */
15147
- function serializeDateRange(key, range) {
15148
+ function serializeDateRange$1(key, range) {
15148
15149
  return key + ":[" + range.from + " TO " + range.to + "]";
15149
15150
  }
15150
15151
  /**
@@ -15154,7 +15155,7 @@
15154
15155
  * @param value
15155
15156
  * @returns
15156
15157
  */
15157
- function serializeStringOrArray(join, key, value) {
15158
+ function serializeStringOrArray$1(join, key, value) {
15158
15159
  var q = "";
15159
15160
  if (Array.isArray(value)) {
15160
15161
  q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
@@ -15332,6 +15333,224 @@
15332
15333
  };
15333
15334
  }
15334
15335
 
15336
+ function expandPredicate(predicate) {
15337
+ var result = {};
15338
+ var dateProps = ["created", "modified", "lastlogin"];
15339
+ var copyProps = [
15340
+ "filterType",
15341
+ "term",
15342
+ "searchUserAccess",
15343
+ "isopendata",
15344
+ "searchUserName",
15345
+ ];
15346
+ var nonMatchOptionsFields = __spreadArrays(dateProps, copyProps);
15347
+ // Do the conversion
15348
+ Object.entries(predicate).forEach(function (_a) {
15349
+ var key = _a[0], value = _a[1];
15350
+ // Handle MatchOptions fields
15351
+ if (!nonMatchOptionsFields.includes(key)) {
15352
+ setProp(key, valueToMatchOptions(value), result);
15353
+ }
15354
+ // Handle Date fields
15355
+ if (dateProps.includes(key)) {
15356
+ var dateFieldValue = cloneObject$1(getProp(predicate, key));
15357
+ if (getProp(predicate, key + ".type") === "relative-date") {
15358
+ setProp(key, relativeDateToDateRange(dateFieldValue), result);
15359
+ }
15360
+ else {
15361
+ setProp(key, dateFieldValue, result);
15362
+ }
15363
+ }
15364
+ // Handle fields that are just copied forward
15365
+ if (copyProps.includes(key) && predicate.hasOwnProperty(key)) {
15366
+ setProp(key, value, result);
15367
+ }
15368
+ });
15369
+ return result;
15370
+ }
15371
+ function serializeQueryForPortal(query) {
15372
+ var filterSearchOptions = query.filters.map(serializeFilter);
15373
+ var result = mergeSearchOptions(filterSearchOptions, "AND");
15374
+ return result;
15375
+ }
15376
+ function mergeSearchOptions(options, operation) {
15377
+ var result = options.reduce(function (acc, entry) {
15378
+ // walk the props
15379
+ Object.entries(entry).forEach(function (_a) {
15380
+ var key = _a[0], value = _a[1];
15381
+ // if prop exists
15382
+ if (acc[key]) {
15383
+ // combine via operation
15384
+ acc[key] = acc[key] + " " + operation + " " + value;
15385
+ }
15386
+ else {
15387
+ // just copy the value
15388
+ acc[key] = value;
15389
+ }
15390
+ });
15391
+ return acc;
15392
+ }, { q: "" });
15393
+ return result;
15394
+ }
15395
+ /**
15396
+ * Serialize the filters in a FitlerGroup into a Portal Query
15397
+ * @param filter
15398
+ * @returns
15399
+ */
15400
+ function serializeFilter(filter) {
15401
+ var operation = filter.operation || "AND";
15402
+ var predicates = filter.predicates.map(expandPredicate);
15403
+ var predicateSearchOptions = predicates.map(serializePredicate);
15404
+ // combine these searchOptions
15405
+ var searchOptions = mergeSearchOptions(predicateSearchOptions, operation);
15406
+ // wrap in parens if we have more than one predicate
15407
+ if (predicates.length > 1) {
15408
+ searchOptions.q = "(" + searchOptions.q + ")";
15409
+ }
15410
+ return searchOptions;
15411
+ }
15412
+ /**
15413
+ * Serialize a Filter into a Portal Query
15414
+ * @param predicate
15415
+ * @returns
15416
+ */
15417
+ function serializePredicate(predicate) {
15418
+ var dateProps = ["created", "modified"];
15419
+ var boolProps = ["isopendata"];
15420
+ var passThroughProps = ["searchUserAccess", "searchUserName"];
15421
+ var specialProps = __spreadArrays([
15422
+ "filterType",
15423
+ "term"
15424
+ ], dateProps, boolProps, passThroughProps);
15425
+ var portalAllowList = [
15426
+ "access",
15427
+ "categories",
15428
+ "created",
15429
+ "description",
15430
+ "disabled",
15431
+ "email",
15432
+ "emailstatus",
15433
+ "firstname",
15434
+ "fullname",
15435
+ "group",
15436
+ "id",
15437
+ "isInvitationOnly",
15438
+ "isopendata",
15439
+ "joined",
15440
+ "lastlogin",
15441
+ "lastname",
15442
+ "memberType",
15443
+ "modified",
15444
+ "name",
15445
+ "orgid",
15446
+ "orgIds",
15447
+ "owner",
15448
+ "provider",
15449
+ "role",
15450
+ "searchUserAccess",
15451
+ "searchUserName",
15452
+ "snippet",
15453
+ "tags",
15454
+ "term",
15455
+ "type",
15456
+ "typekeywords",
15457
+ "userlicensetype",
15458
+ "username",
15459
+ ];
15460
+ var qCount = 0;
15461
+ // TODO: Look at using reduce vs .map and remove the `.filter`
15462
+ var opts = Object.entries(predicate)
15463
+ .map(function (_a) {
15464
+ var key = _a[0], value = _a[1];
15465
+ // When serializing for portal we limit predicate properties to
15466
+ // a list of known properties that the portal api accepts. This will
15467
+ // not attempt to ensure the properties are used in the correct combinations
15468
+ if (portalAllowList.includes(key)) {
15469
+ var so = { q: "" };
15470
+ if (!specialProps.includes(key)) {
15471
+ qCount++;
15472
+ so.q = serializeMatchOptions(key, value);
15473
+ }
15474
+ if (dateProps.includes(key)) {
15475
+ qCount++;
15476
+ so.q = serializeDateRange(key, value);
15477
+ }
15478
+ if (boolProps.includes(key)) {
15479
+ qCount++;
15480
+ so.q = key + ":" + value;
15481
+ }
15482
+ if (passThroughProps.includes(key)) {
15483
+ so[key] = value;
15484
+ }
15485
+ if (key === "term") {
15486
+ qCount++;
15487
+ so.q = value;
15488
+ }
15489
+ return so;
15490
+ }
15491
+ })
15492
+ .filter(function (e) { return e !== undefined; });
15493
+ // merge up all the searchOptions
15494
+ var searchOptions = mergeSearchOptions(opts, "AND");
15495
+ if (qCount > 1) {
15496
+ searchOptions.q = "(" + searchOptions.q + ")";
15497
+ }
15498
+ return searchOptions;
15499
+ }
15500
+ /**
15501
+ * Serialize MatchOptions into portal syntax
15502
+ * @param key
15503
+ * @param value
15504
+ * @returns
15505
+ */
15506
+ function serializeMatchOptions(key, value) {
15507
+ var result = "";
15508
+ if (value.any) {
15509
+ result = "" + serializeStringOrArray("OR", key, value.any);
15510
+ }
15511
+ if (value.all) {
15512
+ result =
15513
+ (result ? result + " AND " : "") +
15514
+ ("" + serializeStringOrArray("AND", key, value.all));
15515
+ }
15516
+ if (value.not) {
15517
+ // negate the entries if they are not
15518
+ result =
15519
+ (result ? result + " AND " : "") +
15520
+ ("" + serializeStringOrArray("OR", "-" + key, value.not));
15521
+ }
15522
+ return result;
15523
+ }
15524
+ /**
15525
+ * Serialize a date-range into Portal syntax
15526
+ * @param key
15527
+ * @param range
15528
+ * @returns
15529
+ */
15530
+ function serializeDateRange(key, range) {
15531
+ return key + ":[" + range.from + " TO " + range.to + "]";
15532
+ }
15533
+ /**
15534
+ * Serialize a `string` or `string[]` into a string
15535
+ * @param join
15536
+ * @param key
15537
+ * @param value
15538
+ * @returns
15539
+ */
15540
+ function serializeStringOrArray(join, key, value) {
15541
+ var q = "";
15542
+ if (Array.isArray(value)) {
15543
+ q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
15544
+ if (value.length > 1) {
15545
+ q = "(" + q + ")";
15546
+ }
15547
+ }
15548
+ else {
15549
+ q = key + ":\"" + value + "\"";
15550
+ }
15551
+ return q;
15552
+ }
15553
+
15335
15554
  /**
15336
15555
  * Fetch Page specific Enrichments
15337
15556
  * @param item
@@ -17849,12 +18068,12 @@
17849
18068
 
17850
18069
  /**
17851
18070
  * @private
17852
- * Portal Search Implementation for Items
18071
+ * DEPRECATED
17853
18072
  * @param filterGroups
17854
18073
  * @param options
17855
18074
  * @returns
17856
18075
  */
17857
- function portalSearchItems(filterGroups, options) {
18076
+ function portalSearchItemsFilterGroups(filterGroups, options) {
17858
18077
  var _a;
17859
18078
  return __awaiter(this, void 0, void 0, function () {
17860
18079
  var replaced, expandedGroups, so, props;
@@ -17862,7 +18081,7 @@
17862
18081
  if (!options.requestOptions) {
17863
18082
  throw new HubError$1("hubSearch", "requestOptions: IHubRequestOptions is required.");
17864
18083
  }
17865
- replaced = applyWellKnownItemFilters(filterGroups);
18084
+ replaced = applyWellKnownItemFilterGroups(filterGroups);
17866
18085
  expandedGroups = replaced.map(function (fg) {
17867
18086
  fg.filters = fg.filters.map(expandFilter);
17868
18087
  return fg;
@@ -17897,6 +18116,57 @@
17897
18116
  });
17898
18117
  });
17899
18118
  }
18119
+ /**
18120
+ * @private
18121
+ * Portal Search Implementation for Items
18122
+ * @param query
18123
+ * @param options
18124
+ * @returns
18125
+ */
18126
+ function portalSearchItems(query, options) {
18127
+ var _a;
18128
+ return __awaiter(this, void 0, void 0, function () {
18129
+ var updatedQuery, so, props;
18130
+ return __generator(this, function (_b) {
18131
+ if (!options.requestOptions) {
18132
+ throw new HubError$1("portalSearchItems", "options.requestOptions is required.");
18133
+ }
18134
+ updatedQuery = applyWellKnownItemPredicates(query);
18135
+ // Expand the individual predicates in each filter
18136
+ updatedQuery.filters = updatedQuery.filters.map(function (filter) {
18137
+ filter.predicates = filter.predicates.map(expandPredicate);
18138
+ return filter;
18139
+ });
18140
+ so = serializeQueryForPortal(updatedQuery);
18141
+ props = [
18142
+ "num",
18143
+ "sortField",
18144
+ "sortOrder",
18145
+ "include",
18146
+ "start",
18147
+ "requestOptions",
18148
+ ];
18149
+ // copy the props over
18150
+ props.forEach(function (prop) {
18151
+ if (options.hasOwnProperty(prop)) {
18152
+ so[prop] = options[prop];
18153
+ }
18154
+ });
18155
+ if (options.requestOptions.authentication) {
18156
+ so.authentication = options.requestOptions.authentication;
18157
+ }
18158
+ else {
18159
+ so.portal = options.requestOptions.portal;
18160
+ }
18161
+ // Aggregations
18162
+ if ((_a = options.aggFields) === null || _a === void 0 ? void 0 : _a.length) {
18163
+ so.countFields = options.aggFields.join(",");
18164
+ so.countSize = options.aggLimit || 10;
18165
+ }
18166
+ return [2 /*return*/, searchPortal$2(so)];
18167
+ });
18168
+ });
18169
+ }
17900
18170
  /**
17901
18171
  * Internal portal search, which then converts `IItem`s to `IHubSearchResult`s
17902
18172
  * handling enrichments & includes along the way
@@ -18137,7 +18407,36 @@
18137
18407
  * Only exported to enable extensive testing
18138
18408
  * @param filterGroups
18139
18409
  */
18140
- function applyWellKnownItemFilters(filterGroups) {
18410
+ function applyWellKnownItemPredicates(query) {
18411
+ var queryClone = cloneObject$1(query);
18412
+ // iterate the filters
18413
+ queryClone.filters = queryClone.filters.map(function (filter) {
18414
+ // replace predicates with well-known types
18415
+ filter.predicates = filter.predicates.reduce(function (acc, predicate) {
18416
+ // if the predicate has a well-known type
18417
+ // we replace it with the set of predicates defined
18418
+ // for the well-known type
18419
+ if (isWellKnownTypeFilter(predicate.type)) {
18420
+ var replacements = lookupTypePredicates(predicate.type);
18421
+ acc = __spreadArrays(acc, replacements);
18422
+ }
18423
+ else {
18424
+ // this predicate does not have a well-known type
18425
+ // so we just keep it
18426
+ acc.push(predicate);
18427
+ }
18428
+ return acc;
18429
+ }, []);
18430
+ return filter;
18431
+ });
18432
+ return queryClone;
18433
+ }
18434
+ /**
18435
+ * DEPRECATED
18436
+ * @param filterGroups
18437
+ * @returns
18438
+ */
18439
+ function applyWellKnownItemFilterGroups(filterGroups) {
18141
18440
  var clone = cloneObject$1(filterGroups);
18142
18441
  // iterate the filterGroups
18143
18442
  var result = clone.map(function (filterGroup) {
@@ -18189,6 +18488,16 @@
18189
18488
  function lookupTypeFilters(key) {
18190
18489
  return WellKnownItemFilters[key];
18191
18490
  }
18491
+ function lookupTypePredicates(key) {
18492
+ var rawPredicates = WellKnownItemFilters[key];
18493
+ // Remove the filterType property as it's not needed in an IPredicate
18494
+ var predicates = rawPredicates.map(function (entry) {
18495
+ var c = cloneObject$1(entry);
18496
+ delete c.filterType;
18497
+ return c;
18498
+ });
18499
+ return predicates;
18500
+ }
18192
18501
 
18193
18502
  // ## ## ####### ######## ########
18194
18503
  // ### ## ## ## ## ##
@@ -18392,12 +18701,13 @@
18392
18701
 
18393
18702
  /**
18394
18703
  * @private
18395
- * Portal Search Implementation for Items
18704
+ * DEPRECATED: Use `portalSerchGroups`
18705
+ * Portal Search Implementation for Groups
18396
18706
  * @param filterGroups
18397
18707
  * @param options
18398
18708
  * @returns
18399
18709
  */
18400
- function portalSearchGroups(filterGroups, options) {
18710
+ function portalSearchGroupsFilterGroups(filterGroups, options) {
18401
18711
  return __awaiter(this, void 0, void 0, function () {
18402
18712
  var api, expandedGroups, so, props;
18403
18713
  return __generator(this, function (_a) {
@@ -18444,6 +18754,51 @@
18444
18754
  });
18445
18755
  });
18446
18756
  }
18757
+ /**
18758
+ * @private
18759
+ * Portal Search Implementation for Groups
18760
+ * @param query
18761
+ * @param options
18762
+ * @returns
18763
+ */
18764
+ function portalSearchGroups(query, options) {
18765
+ return __awaiter(this, void 0, void 0, function () {
18766
+ var so, props;
18767
+ return __generator(this, function (_a) {
18768
+ if (!options.requestOptions) {
18769
+ throw new HubError$1("portalSearchGroups", "options.requestOptions is required.");
18770
+ }
18771
+ // Expand the individual predicates in each filter
18772
+ query.filters = query.filters.map(function (filter) {
18773
+ filter.predicates = filter.predicates.map(expandPredicate);
18774
+ return filter;
18775
+ });
18776
+ so = serializeQueryForPortal(query);
18777
+ props = [
18778
+ "num",
18779
+ "sortField",
18780
+ "sortOrder",
18781
+ "include",
18782
+ "start",
18783
+ "requestOptions",
18784
+ ];
18785
+ // copy the props over
18786
+ props.forEach(function (prop) {
18787
+ if (options.hasOwnProperty(prop)) {
18788
+ so[prop] = options[prop];
18789
+ }
18790
+ });
18791
+ // If we don't have auth, ensure we have .portal
18792
+ if (options.requestOptions.authentication) {
18793
+ so.authentication = options.requestOptions.authentication;
18794
+ }
18795
+ else {
18796
+ so.portal = options.requestOptions.portal;
18797
+ }
18798
+ return [2 /*return*/, searchPortal$1(so)];
18799
+ });
18800
+ });
18801
+ }
18447
18802
  /**
18448
18803
  * Internal portal search, which then converts `IGroup`s to `IHubSearchResult`s
18449
18804
  * handling enrichments & includes along the way
@@ -18501,11 +18856,12 @@
18501
18856
 
18502
18857
  /**
18503
18858
  * @private
18859
+ * DEPRECATED: Use `portalSearchUsers`
18504
18860
  * Portal Search implementation for Users
18505
18861
  * @param filterGroups
18506
18862
  * @param options
18507
18863
  */
18508
- function portalSearchUsers(filterGroups, options) {
18864
+ function portalSearchUsersFilterGroups(filterGroups, options) {
18509
18865
  return __awaiter(this, void 0, void 0, function () {
18510
18866
  var expandedGroups, so, props;
18511
18867
  return __generator(this, function (_a) {
@@ -18542,6 +18898,52 @@
18542
18898
  });
18543
18899
  });
18544
18900
  }
18901
+ /**
18902
+ * @private
18903
+ * Portal Search Implementation for Users
18904
+ * @param filterGroups
18905
+ * @param options
18906
+ * @returns
18907
+ */
18908
+ function portalSearchUsers(query, options) {
18909
+ return __awaiter(this, void 0, void 0, function () {
18910
+ var so, props;
18911
+ return __generator(this, function (_a) {
18912
+ // requestOptions is always required and user must be authd
18913
+ if (!options.requestOptions) {
18914
+ throw new HubError$1("portalSearchUsers", "requestOptions: IHubRequestOptions is required.");
18915
+ }
18916
+ if (!options.requestOptions.authentication) {
18917
+ throw new HubError$1("portalSearchUsers", "requestOptions must pass authentication.");
18918
+ }
18919
+ // Expand the individual predicates in each filter
18920
+ query.filters = query.filters.map(function (filter) {
18921
+ filter.predicates = filter.predicates.map(expandPredicate);
18922
+ return filter;
18923
+ });
18924
+ so = serializeQueryForPortal(query);
18925
+ props = [
18926
+ "num",
18927
+ "sortField",
18928
+ "sortOrder",
18929
+ "include",
18930
+ "start",
18931
+ "requestOptions",
18932
+ ];
18933
+ // copy the props over
18934
+ props.forEach(function (prop) {
18935
+ if (options.hasOwnProperty(prop)) {
18936
+ so[prop] = options[prop];
18937
+ }
18938
+ });
18939
+ // Unlike Groups and Item, the Users api *requires* authentication
18940
+ // so we set it directly
18941
+ so.authentication = options.requestOptions.authentication;
18942
+ // Execute search
18943
+ return [2 /*return*/, searchPortal(so)];
18944
+ });
18945
+ });
18946
+ }
18545
18947
  /**
18546
18948
  * Internal portal search, which then converts `IGroup`s to `IHubSearchResult`s
18547
18949
  * handling enrichments & includes along the way
@@ -18626,6 +19028,44 @@
18626
19028
  }
18627
19029
  filterType = filterGroups[0].filterType;
18628
19030
  apiType = expandApi(options.api || "arcgis").type;
19031
+ fnHash = {
19032
+ arcgis: {
19033
+ item: portalSearchItemsFilterGroups,
19034
+ group: portalSearchGroupsFilterGroups,
19035
+ user: portalSearchUsersFilterGroups,
19036
+ },
19037
+ "arcgis-hub": {
19038
+ item: hubSearchItems,
19039
+ },
19040
+ };
19041
+ fn = getProp(fnHash, apiType + "." + filterType);
19042
+ if (!fn) {
19043
+ throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented");
19044
+ }
19045
+ return [2 /*return*/, fn(cloneObject$1(filterGroups), options)];
19046
+ });
19047
+ });
19048
+ }
19049
+ function hubSearchQuery(query, options) {
19050
+ return __awaiter(this, void 0, void 0, function () {
19051
+ var filterType, apiType, fnHash, fn;
19052
+ return __generator(this, function (_a) {
19053
+ // Validate inputs
19054
+ if (!query) {
19055
+ throw new HubError$1("hubSearch", "Query is required.");
19056
+ }
19057
+ if (!query.filters || !query.filters.length) {
19058
+ throw new HubError$1("hubSearch", "Query must contain at least one Filter.");
19059
+ }
19060
+ if (!options.requestOptions) {
19061
+ throw new HubError$1("hubSearch", "requestOptions: IHubRequestOptions is required.");
19062
+ }
19063
+ // Ensure includes is an array
19064
+ if (!options.include) {
19065
+ options.include = [];
19066
+ }
19067
+ filterType = query.targetEntity;
19068
+ apiType = expandApi(options.api || "arcgis").type;
18629
19069
  fnHash = {
18630
19070
  arcgis: {
18631
19071
  item: portalSearchItems,
@@ -18640,7 +19080,7 @@
18640
19080
  if (!fn) {
18641
19081
  throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented");
18642
19082
  }
18643
- return [2 /*return*/, fn(cloneObject$1(filterGroups), options)];
19083
+ return [2 /*return*/, fn(cloneObject$1(query), options)];
18644
19084
  });
18645
19085
  });
18646
19086
  }
@@ -20479,6 +20919,7 @@
20479
20919
  exports.hubApiRequest = hubApiRequest;
20480
20920
  exports.hubApiSearch = hubApiSearch;
20481
20921
  exports.hubSearch = hubSearch;
20922
+ exports.hubSearchQuery = hubSearchQuery;
20482
20923
  exports.includes = includes;
20483
20924
  exports.incrementString = incrementString;
20484
20925
  exports.interpolate = interpolate;
@@ -20513,7 +20954,7 @@
20513
20954
  exports.mergeGroupFilters = mergeGroupFilters;
20514
20955
  exports.mergeMatchOptions = mergeMatchOptions;
20515
20956
  exports.mergeObjects = mergeObjects;
20516
- exports.mergeSearchOptions = mergeSearchOptions$1;
20957
+ exports.mergeSearchOptions = mergeSearchOptions$2;
20517
20958
  exports.mergeUserFilters = mergeUserFilters;
20518
20959
  exports.normalizeItemType = normalizeItemType;
20519
20960
  exports.normalizeSolutionTemplateItem = normalizeSolutionTemplateItem;
@@ -20538,13 +20979,13 @@
20538
20979
  exports.searchSites = searchSites;
20539
20980
  exports.serializeCollectionState = serializeCollectionState;
20540
20981
  exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
20541
- exports.serializeDateRange = serializeDateRange$1;
20982
+ exports.serializeDateRange = serializeDateRange$2;
20542
20983
  exports.serializeFilterGroupsForPortal = serializeFilterGroupsForPortal;
20543
20984
  exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
20544
- exports.serializeMatchOptions = serializeMatchOptions$1;
20985
+ exports.serializeMatchOptions = serializeMatchOptions$2;
20545
20986
  exports.serializeModel = serializeModel;
20546
20987
  exports.serializeSpatialReference = serializeSpatialReference;
20547
- exports.serializeStringOrArray = serializeStringOrArray$1;
20988
+ exports.serializeStringOrArray = serializeStringOrArray$2;
20548
20989
  exports.serializeUserFilterForPortal = serializeUserFilterForPortal;
20549
20990
  exports.setContentHubId = setContentHubId;
20550
20991
  exports.setContentSiteUrls = setContentSiteUrls;