@esri/hub-common 9.45.6 → 9.47.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 (108) hide show
  1. package/dist/es2017/projects/HubProjectManager.js +3 -3
  2. package/dist/es2017/projects/HubProjectManager.js.map +1 -1
  3. package/dist/es2017/projects/HubProjects.js +23 -13
  4. package/dist/es2017/projects/HubProjects.js.map +1 -1
  5. package/dist/es2017/search/_internal/createQueryFromString.js +22 -0
  6. package/dist/es2017/search/_internal/createQueryFromString.js.map +1 -0
  7. package/dist/es2017/search/_internal/hubSearchItems.js +1 -0
  8. package/dist/es2017/search/_internal/hubSearchItems.js.map +1 -1
  9. package/dist/es2017/search/_internal/index.js +2 -1
  10. package/dist/es2017/search/_internal/index.js.map +1 -1
  11. package/dist/es2017/search/_internal/ipredicate-utils.js +6 -0
  12. package/dist/es2017/search/_internal/ipredicate-utils.js.map +1 -1
  13. package/dist/es2017/search/_internal/portalSearchItems.js +8 -0
  14. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  15. package/dist/es2017/search/_internal/searchEntities.js +73 -0
  16. package/dist/es2017/search/_internal/searchEntities.js.map +1 -0
  17. package/dist/es2017/search/_internal/state.js +8 -0
  18. package/dist/es2017/search/_internal/state.js.map +1 -1
  19. package/dist/es2017/search/_searchContent.js +1 -0
  20. package/dist/es2017/search/_searchContent.js.map +1 -1
  21. package/dist/es2017/search/_searchGroups.js +1 -0
  22. package/dist/es2017/search/_searchGroups.js.map +1 -1
  23. package/dist/es2017/search/_searchUsers.js +1 -0
  24. package/dist/es2017/search/_searchUsers.js.map +1 -1
  25. package/dist/es2017/sites/HubSiteManager.js +2 -2
  26. package/dist/es2017/sites/HubSiteManager.js.map +1 -1
  27. package/dist/es2017/sites/HubSites.js +23 -12
  28. package/dist/es2017/sites/HubSites.js.map +1 -1
  29. package/dist/esm/projects/HubProjectManager.js +3 -3
  30. package/dist/esm/projects/HubProjectManager.js.map +1 -1
  31. package/dist/esm/projects/HubProjects.js +23 -12
  32. package/dist/esm/projects/HubProjects.js.map +1 -1
  33. package/dist/esm/search/_internal/createQueryFromString.js +22 -0
  34. package/dist/esm/search/_internal/createQueryFromString.js.map +1 -0
  35. package/dist/esm/search/_internal/hubSearchItems.js +1 -0
  36. package/dist/esm/search/_internal/hubSearchItems.js.map +1 -1
  37. package/dist/esm/search/_internal/index.js +2 -1
  38. package/dist/esm/search/_internal/index.js.map +1 -1
  39. package/dist/esm/search/_internal/ipredicate-utils.js +6 -0
  40. package/dist/esm/search/_internal/ipredicate-utils.js.map +1 -1
  41. package/dist/esm/search/_internal/portalSearchItems.js +8 -0
  42. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  43. package/dist/esm/search/_internal/{searchContentEntities.js → searchEntities.js} +21 -39
  44. package/dist/esm/search/_internal/searchEntities.js.map +1 -0
  45. package/dist/esm/search/_internal/state.js +8 -0
  46. package/dist/esm/search/_internal/state.js.map +1 -1
  47. package/dist/esm/search/_searchContent.js +1 -0
  48. package/dist/esm/search/_searchContent.js.map +1 -1
  49. package/dist/esm/search/_searchGroups.js +1 -0
  50. package/dist/esm/search/_searchGroups.js.map +1 -1
  51. package/dist/esm/search/_searchUsers.js +1 -0
  52. package/dist/esm/search/_searchUsers.js.map +1 -1
  53. package/dist/esm/sites/HubSiteManager.js +2 -2
  54. package/dist/esm/sites/HubSiteManager.js.map +1 -1
  55. package/dist/esm/sites/HubSites.js +23 -11
  56. package/dist/esm/sites/HubSites.js.map +1 -1
  57. package/dist/node/projects/HubProjectManager.js +3 -3
  58. package/dist/node/projects/HubProjectManager.js.map +1 -1
  59. package/dist/node/projects/HubProjects.js +32 -22
  60. package/dist/node/projects/HubProjects.js.map +1 -1
  61. package/dist/node/search/_internal/createQueryFromString.js +26 -0
  62. package/dist/node/search/_internal/createQueryFromString.js.map +1 -0
  63. package/dist/node/search/_internal/hubSearchItems.js +1 -0
  64. package/dist/node/search/_internal/hubSearchItems.js.map +1 -1
  65. package/dist/node/search/_internal/index.js +2 -1
  66. package/dist/node/search/_internal/index.js.map +1 -1
  67. package/dist/node/search/_internal/ipredicate-utils.js +6 -0
  68. package/dist/node/search/_internal/ipredicate-utils.js.map +1 -1
  69. package/dist/node/search/_internal/portalSearchItems.js +8 -0
  70. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  71. package/dist/node/search/_internal/searchEntities.js +78 -0
  72. package/dist/node/search/_internal/searchEntities.js.map +1 -0
  73. package/dist/node/search/_internal/state.js +8 -0
  74. package/dist/node/search/_internal/state.js.map +1 -1
  75. package/dist/node/search/_searchContent.js +1 -0
  76. package/dist/node/search/_searchContent.js.map +1 -1
  77. package/dist/node/search/_searchGroups.js +1 -0
  78. package/dist/node/search/_searchGroups.js.map +1 -1
  79. package/dist/node/search/_searchUsers.js +1 -0
  80. package/dist/node/search/_searchUsers.js.map +1 -1
  81. package/dist/node/sites/HubSiteManager.js +2 -2
  82. package/dist/node/sites/HubSiteManager.js.map +1 -1
  83. package/dist/node/sites/HubSites.js +52 -41
  84. package/dist/node/sites/HubSites.js.map +1 -1
  85. package/dist/types/core/types/IHubEntityManager.d.ts +3 -4
  86. package/dist/types/core/types/IHubTimeline.d.ts +15 -0
  87. package/dist/types/projects/HubProjectManager.d.ts +3 -3
  88. package/dist/types/projects/HubProjects.d.ts +4 -4
  89. package/dist/types/search/_internal/createQueryFromString.d.ts +10 -0
  90. package/dist/types/search/_internal/hubSearchItems.d.ts +1 -0
  91. package/dist/types/search/_internal/index.d.ts +2 -1
  92. package/dist/types/search/_internal/ipredicate-utils.d.ts +6 -0
  93. package/dist/types/search/_internal/searchEntities.d.ts +23 -0
  94. package/dist/types/search/_internal/state.d.ts +8 -0
  95. package/dist/types/search/_searchContent.d.ts +1 -0
  96. package/dist/types/search/_searchGroups.d.ts +1 -0
  97. package/dist/types/search/_searchUsers.d.ts +1 -0
  98. package/dist/types/sites/HubSiteManager.d.ts +2 -2
  99. package/dist/types/sites/HubSites.d.ts +2 -2
  100. package/dist/umd/common.umd.js +133 -83
  101. package/dist/umd/common.umd.js.map +1 -1
  102. package/package.json +1 -1
  103. package/dist/es2017/search/_internal/searchContentEntities.js +0 -89
  104. package/dist/es2017/search/_internal/searchContentEntities.js.map +0 -1
  105. package/dist/esm/search/_internal/searchContentEntities.js.map +0 -1
  106. package/dist/node/search/_internal/searchContentEntities.js +0 -94
  107. package/dist/node/search/_internal/searchContentEntities.js.map +0 -1
  108. package/dist/types/search/_internal/searchContentEntities.d.ts +0 -32
@@ -1,5 +1,6 @@
1
1
  import { IFacet, IFacetState, ISortOption } from "../types";
2
2
  /**
3
+ * @private
3
4
  * Apply the sortState to SortOptions
4
5
  *
5
6
  * @param sortOptions
@@ -8,6 +9,7 @@ import { IFacet, IFacetState, ISortOption } from "../types";
8
9
  */
9
10
  export declare function applySortState(sortOptions: ISortOption, sortState: string): ISortOption;
10
11
  /**
12
+ * @private
11
13
  * Apply FacetState to a Facet
12
14
  * @param facet
13
15
  * @param state
@@ -15,6 +17,7 @@ export declare function applySortState(sortOptions: ISortOption, sortState: stri
15
17
  */
16
18
  export declare function applyFacetState(facet: IFacet, state: IFacetState): IFacet;
17
19
  /**
20
+ * @private
18
21
  * Apply the Facet State onto a single-select facet
19
22
  *
20
23
  * Intentionally mutates the facet.
@@ -24,12 +27,14 @@ export declare function applyFacetState(facet: IFacet, state: IFacetState): IFac
24
27
  */
25
28
  export declare function applySingleSelectFacetState(facet: IFacet, state: IFacetState): IFacet;
26
29
  /**
30
+ * @private
27
31
  * Serialize single-select facet into IFacetState
28
32
  * @param facet
29
33
  * @returns
30
34
  */
31
35
  export declare function serializeSingleSelectFacetState(facet: IFacet): IFacetState;
32
36
  /**
37
+ * @private
33
38
  * Apply the Facet State onto a multi-select Facet
34
39
  *
35
40
  * Intentionally mutates the facet.
@@ -39,12 +44,14 @@ export declare function serializeSingleSelectFacetState(facet: IFacet): IFacetSt
39
44
  */
40
45
  export declare function applyMultiSelectFacetState(facet: IFacet, state: IFacetState): IFacet;
41
46
  /**
47
+ * @private
42
48
  * Serialize multi-select facet into IFacetState
43
49
  * @param facet
44
50
  * @returns
45
51
  */
46
52
  export declare function serializeMultiSelectFacetState(facet: IFacet): IFacetState;
47
53
  /**
54
+ * @private
48
55
  * Serialize the state of the SortOption into a key/value pair
49
56
  *
50
57
  * Called from the Sort component
@@ -53,6 +60,7 @@ export declare function serializeMultiSelectFacetState(facet: IFacet): IFacetSta
53
60
  */
54
61
  export declare function serializeSortState(sort: ISortOption): string;
55
62
  /**
63
+ * @private
56
64
  * Serialize the state of a facet into a key/value pair
57
65
  *
58
66
  * Called from the various facet components
@@ -1,6 +1,7 @@
1
1
  import { Filter, IHubSearchOptions } from "./types";
2
2
  import { IHubContent, ISearchResponse } from "..";
3
3
  /**
4
+ * @private
4
5
  * Search for content via the Portal or Hub API
5
6
  * @param filter
6
7
  * @param options
@@ -6,6 +6,7 @@ export interface IGroupSearchResult {
6
6
  facets: IFacet[];
7
7
  }
8
8
  /**
9
+ * @private
9
10
  * Search Groups using Filter<"group">
10
11
  *
11
12
  * Currently just returns ISearchResult<IGroup>
@@ -15,6 +15,7 @@ export interface IHubUser extends IUser {
15
15
  thumbnailUrl?: string;
16
16
  }
17
17
  /**
18
+ * @private
18
19
  * Search for Users via the Portal API.
19
20
  *
20
21
  * **Note** Authentication is required
@@ -2,7 +2,7 @@ import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
2
2
  import { IArcGISContext } from "../ArcGISContext";
3
3
  import { IHubEntityManager, IHubItemEntityManager, IHubSite } from "../core/types";
4
4
  import { ArcGISContextManager } from "../ArcGISContextManager";
5
- import { Filter, IHubSearchOptions } from "../search";
5
+ import { IHubSearchOptions, IQuery } from "../search";
6
6
  import { IHubRequestOptions, ISearchResponse } from "../types";
7
7
  import { IItem } from "@esri/arcgis-rest-types";
8
8
  import { IRequestOptions } from "@esri/arcgis-rest-request";
@@ -84,7 +84,7 @@ export declare class HubSiteManager implements IHubEntityManager<IHubSite>, IHub
84
84
  * @param filter
85
85
  * @param opts
86
86
  */
87
- search(filter: Filter<"content">, options: IHubSearchOptions): Promise<ISearchResponse<IHubSite>>;
87
+ search(query: string | IQuery, options: IHubSearchOptions): Promise<ISearchResponse<IHubSite>>;
88
88
  /**
89
89
  * Set the thumbnail for the Site
90
90
  * @param id
@@ -1,5 +1,5 @@
1
1
  import { IItem } from "@esri/arcgis-rest-portal";
2
- import { Filter, IHubRequestOptions, IHubSearchOptions, IHubSearchResult, IHubSite, ISearchResponse } from "..";
2
+ import { IHubRequestOptions, IHubSearchOptions, IHubSearchResponse, IHubSearchResult, IHubSite, IQuery } from "../index";
3
3
  import { IRequestOptions } from "@esri/arcgis-rest-request";
4
4
  export declare const HUB_SITE_ITEM_TYPE = "Hub Site Application";
5
5
  export declare const ENTERPRISE_SITE_ITEM_TYPE = "Site Application";
@@ -53,7 +53,7 @@ export declare function convertItemToSite(item: IItem, requestOptions: IRequestO
53
53
  * @param options
54
54
  * @returns
55
55
  */
56
- export declare function searchSites(filter: Filter<"content">, options: IHubSearchOptions): Promise<ISearchResponse<IHubSite>>;
56
+ export declare function searchSites(query: string | IQuery, options: IHubSearchOptions): Promise<IHubSearchResponse<IHubSite>>;
57
57
  /**
58
58
  * Fetch Site specific enrichments
59
59
  * @param item
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.45.5 - Thu Jul 07 2022 20:50:46 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.46.1 - Tue Jul 19 2022 15:08:51 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -14473,6 +14473,7 @@
14473
14473
 
14474
14474
  // TODO: Remove with _searchContent
14475
14475
  /**
14476
+ * @private
14476
14477
  * Search for content via the Portal or Hub API
14477
14478
  * @param filter
14478
14479
  * @param options
@@ -14584,6 +14585,7 @@
14584
14585
 
14585
14586
  // TODO: Remove with _searchContent
14586
14587
  /**
14588
+ * @private
14587
14589
  * Search Groups using Filter<"group">
14588
14590
  *
14589
14591
  * Currently just returns ISearchResult<IGroup>
@@ -14668,6 +14670,7 @@
14668
14670
 
14669
14671
  // TODO: Remove with _searchContent
14670
14672
  /**
14673
+ * @private
14671
14674
  * Search for Users via the Portal API.
14672
14675
  *
14673
14676
  * **Note** Authentication is required
@@ -14754,6 +14757,7 @@
14754
14757
  }
14755
14758
 
14756
14759
  /**
14760
+ * @private
14757
14761
  * Apply the sortState to SortOptions
14758
14762
  *
14759
14763
  * @param sortOptions
@@ -14771,6 +14775,7 @@
14771
14775
  return updated;
14772
14776
  }
14773
14777
  /**
14778
+ * @private
14774
14779
  * Apply FacetState to a Facet
14775
14780
  * @param facet
14776
14781
  * @param state
@@ -14789,6 +14794,7 @@
14789
14794
  return updated;
14790
14795
  }
14791
14796
  /**
14797
+ * @private
14792
14798
  * Apply the Facet State onto a single-select facet
14793
14799
  *
14794
14800
  * Intentionally mutates the facet.
@@ -14805,6 +14811,7 @@
14805
14811
  return updated;
14806
14812
  }
14807
14813
  /**
14814
+ * @private
14808
14815
  * Serialize single-select facet into IFacetState
14809
14816
  * @param facet
14810
14817
  * @returns
@@ -14821,6 +14828,7 @@
14821
14828
  return state;
14822
14829
  }
14823
14830
  /**
14831
+ * @private
14824
14832
  * Apply the Facet State onto a multi-select Facet
14825
14833
  *
14826
14834
  * Intentionally mutates the facet.
@@ -14839,6 +14847,7 @@
14839
14847
  return updated;
14840
14848
  }
14841
14849
  /**
14850
+ * @private
14842
14851
  * Serialize multi-select facet into IFacetState
14843
14852
  * @param facet
14844
14853
  * @returns
@@ -14856,6 +14865,7 @@
14856
14865
  return state;
14857
14866
  }
14858
14867
  /**
14868
+ * @private
14859
14869
  * Serialize the state of the SortOption into a key/value pair
14860
14870
  *
14861
14871
  * Called from the Sort component
@@ -14866,6 +14876,7 @@
14866
14876
  return sort.label + "|" + sort.attribute + "|" + sort.order;
14867
14877
  }
14868
14878
  /**
14879
+ * @private
14869
14880
  * Serialize the state of a facet into a key/value pair
14870
14881
  *
14871
14882
  * Called from the various facet components
@@ -15006,6 +15017,12 @@
15006
15017
  }
15007
15018
  }
15008
15019
 
15020
+ /**
15021
+ * @private
15022
+ * Expand a predicate
15023
+ * @param predicate
15024
+ * @returns
15025
+ */
15009
15026
  function expandPredicate(predicate) {
15010
15027
  var result = {};
15011
15028
  var dateProps = ["created", "modified", "lastlogin"];
@@ -15289,44 +15306,51 @@
15289
15306
  var HubError$1 = HubError;
15290
15307
 
15291
15308
  /**
15292
- * Generic search that returns Hub Entity types converted from items
15293
- * by the passed in `ItemToEntityFunction`
15294
- *
15295
- * This abstraction is used to ensure that searching from any of the
15296
- * entity managers / modules is consistent, and returns the entity
15297
- * types, instead of `IItem` or `IHubContent`
15298
- *
15299
- * @param filter
15309
+ * @private
15310
+ * Convert a portal aggregation structure into the HubAggregations structure
15311
+ * @param searchResults
15312
+ * @returns
15313
+ */
15314
+ function convertPortalAggregations(searchResults) {
15315
+ var _a;
15316
+ if ((_a = searchResults.aggregations) === null || _a === void 0 ? void 0 : _a.counts) {
15317
+ return searchResults.aggregations.counts.map(function (entry) {
15318
+ return {
15319
+ mode: "terms",
15320
+ field: entry.fieldName,
15321
+ values: entry.fieldValues,
15322
+ };
15323
+ });
15324
+ }
15325
+ else {
15326
+ return [];
15327
+ }
15328
+ }
15329
+
15330
+ /**
15331
+ * @private
15332
+ * Execute a search and convert to a specific entity
15333
+ * @param query
15300
15334
  * @param convertFn
15301
15335
  * @param options
15302
15336
  * @returns
15303
15337
  */
15304
- function searchContentEntities(filter, convertFn, options) {
15305
- var _a, _b;
15306
- // expand filter so we can serialize to either api
15307
- var expanded = expandContentFilter(filter);
15308
- var searchOptions = serializeContentFilterForPortal(expanded);
15309
- // DEPRECATION
15310
- /* istanbul ignore next */
15311
- if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
15312
- // tslint:disable-next-line:no-console
15313
- console.warn("IHubSearchOptions.aggregations is deprecated. Please use .aggFields instead.");
15314
- searchOptions.countFields = options.aggregations.join(",");
15315
- searchOptions.countSize = options.aggLimit || 10;
15316
- }
15338
+ function searchEntities(query, convertFn, options) {
15339
+ var _a;
15340
+ // serialize query to searchOptions
15341
+ var searchOptions = serializeQueryForPortal(query);
15317
15342
  // Aggregations
15318
- if ((_b = options.aggFields) === null || _b === void 0 ? void 0 : _b.length) {
15343
+ if ((_a = options.aggFields) === null || _a === void 0 ? void 0 : _a.length) {
15319
15344
  searchOptions.countFields = options.aggFields.join(",");
15320
15345
  searchOptions.countSize = options.aggLimit || 10;
15321
15346
  }
15322
15347
  // properties to copy from IHubSearchOptions to the ISearchOptions
15323
15348
  var props = [
15324
- "authentication",
15325
15349
  "num",
15326
15350
  "sortField",
15327
15351
  "sortOrder",
15328
- "site",
15329
15352
  "start",
15353
+ "requestOptions",
15330
15354
  ];
15331
15355
  // Include "start" here
15332
15356
  // copy the props over
@@ -15336,8 +15360,7 @@
15336
15360
  }
15337
15361
  });
15338
15362
  // create the entitySearchFn
15339
- var searchFn = createContentEntitySearchFn(convertFn);
15340
- // execute the search
15363
+ var searchFn = createEntitySearchFn(convertFn);
15341
15364
  // Add ArcGIS API
15342
15365
  if (options.api && !options.authentication) {
15343
15366
  var expandedApi = expandApi(options.api);
@@ -15346,20 +15369,17 @@
15346
15369
  return searchFn(searchOptions);
15347
15370
  }
15348
15371
  /**
15349
- * Return a function that holds a closure containing
15350
- * a hub entity specific conversion function. This
15351
- * allows the `.next()` function to use the function on
15352
- * subsequent calls
15372
+ * @private
15353
15373
  * @param convertFn
15354
15374
  * @returns
15355
15375
  */
15356
- function createContentEntitySearchFn(convertFn) {
15376
+ function createEntitySearchFn(convertFn) {
15357
15377
  // Return a function that does the search, with a closure over the
15358
15378
  // conversion function. Naming this function is important as it's
15359
15379
  // referenced in the `next` section below
15360
- return function searchEntities(searchOptions) {
15380
+ return function executeSearch(searchOptions) {
15361
15381
  return __awaiter(this, void 0, void 0, function () {
15362
- var response, entities, facets;
15382
+ var response, entities, aggregations;
15363
15383
  return __generator(this, function (_a) {
15364
15384
  switch (_a.label) {
15365
15385
  case 0: return [4 /*yield*/, searchItems(searchOptions)];
@@ -15370,13 +15390,13 @@
15370
15390
  }))];
15371
15391
  case 2:
15372
15392
  entities = _a.sent();
15373
- facets = convertPortalResponseToFacets(response);
15393
+ aggregations = convertPortalAggregations(response);
15374
15394
  return [2 /*return*/, {
15375
15395
  total: response.total,
15376
15396
  results: entities,
15377
- facets: facets,
15397
+ aggregations: aggregations,
15378
15398
  hasNext: response.nextStart > -1,
15379
- next: getNextFunction(searchOptions, response.nextStart, response.total, searchEntities),
15399
+ next: getNextFunction(searchOptions, response.nextStart, response.total, executeSearch),
15380
15400
  }];
15381
15401
  }
15382
15402
  });
@@ -15987,24 +16007,34 @@
15987
16007
  /**
15988
16008
  * Search for Projects, and get IHubProject results
15989
16009
  *
15990
- * Different from `searchContent` in that this returns the specific entity type
16010
+ * Different from `hubSearch` in that this returns the IHubProjects
15991
16011
  *
15992
16012
  * @param filter
15993
16013
  * @param options
15994
16014
  * @returns
15995
16015
  */
15996
- function searchProjects(filter, options) {
16016
+ function searchProjects(query, options) {
15997
16017
  return __awaiter(this, void 0, void 0, function () {
15998
- var scopingFilter, projectFilter;
16018
+ var qry, scopingFilters;
15999
16019
  return __generator(this, function (_a) {
16000
- scopingFilter = {
16001
- filterType: "content",
16002
- type: {
16003
- exact: ["Hub Project"],
16020
+ if (typeof query === "string") {
16021
+ qry = createQueryFromString(query, "term", "item");
16022
+ }
16023
+ else {
16024
+ qry = cloneObject$1(query);
16025
+ }
16026
+ scopingFilters = [
16027
+ {
16028
+ predicates: [
16029
+ {
16030
+ type: "Hub Project",
16031
+ },
16032
+ ],
16004
16033
  },
16005
- };
16006
- projectFilter = mergeContentFilter([scopingFilter, filter]);
16007
- return [2 /*return*/, searchContentEntities(projectFilter, convertItemToProject, options)];
16034
+ ];
16035
+ // add filters from the passed in query
16036
+ qry.filters = __spreadArrays(scopingFilters, qry.filters);
16037
+ return [2 /*return*/, searchEntities(qry, convertItemToProject, options)];
16008
16038
  });
16009
16039
  });
16010
16040
  }
@@ -16280,17 +16310,17 @@
16280
16310
  /**
16281
16311
  * Search for Projects
16282
16312
  *
16283
- * @param filter
16313
+ * @param query
16284
16314
  * @param options
16285
16315
  */
16286
- HubProjectManager.prototype.search = function (filter, options) {
16316
+ HubProjectManager.prototype.search = function (query, options) {
16287
16317
  return __awaiter(this, void 0, void 0, function () {
16288
16318
  return __generator(this, function (_a) {
16289
16319
  // if we were not passed auth, and we have a session, use it
16290
16320
  if (!options.authentication && this.context.session) {
16291
16321
  options.authentication = this.context.session;
16292
16322
  }
16293
- return [2 /*return*/, searchProjects(filter, options)];
16323
+ return [2 /*return*/, searchProjects(query, options)];
16294
16324
  });
16295
16325
  });
16296
16326
  };
@@ -16933,6 +16963,28 @@
16933
16963
  });
16934
16964
  }
16935
16965
 
16966
+ /**
16967
+ * @private
16968
+ * Construct a query from a string
16969
+ * @param value
16970
+ * @param predicateKey
16971
+ * @param targetEntity
16972
+ * @returns
16973
+ */
16974
+ function createQueryFromString(value, predicateKey, targetEntity) {
16975
+ var predicate = {};
16976
+ predicate[predicateKey] = value;
16977
+ var qry = {
16978
+ targetEntity: targetEntity,
16979
+ filters: [
16980
+ {
16981
+ predicates: [predicate],
16982
+ },
16983
+ ],
16984
+ };
16985
+ return qry;
16986
+ }
16987
+
16936
16988
  var HUB_SITE_ITEM_TYPE = "Hub Site Application";
16937
16989
  var ENTERPRISE_SITE_ITEM_TYPE = "Site Application";
16938
16990
  /**
@@ -17360,17 +17412,28 @@
17360
17412
  * @param options
17361
17413
  * @returns
17362
17414
  */
17363
- function searchSites(filter, options) {
17415
+ function searchSites(query, options) {
17364
17416
  return __awaiter(this, void 0, void 0, function () {
17365
- var scopingFilter, sitesFilter;
17417
+ var qry, scopingFilters;
17366
17418
  return __generator(this, function (_a) {
17367
- scopingFilter = {
17368
- filterType: "content",
17369
- type: "$site",
17370
- };
17371
- sitesFilter = mergeContentFilter([scopingFilter, filter]);
17372
- // delegate
17373
- return [2 /*return*/, searchContentEntities(sitesFilter, convertItemToSite, options)];
17419
+ if (typeof query === "string") {
17420
+ qry = createQueryFromString(query, "term", "item");
17421
+ }
17422
+ else {
17423
+ qry = cloneObject$1(query);
17424
+ }
17425
+ scopingFilters = [
17426
+ {
17427
+ predicates: [
17428
+ {
17429
+ type: "Hub Project",
17430
+ },
17431
+ ],
17432
+ },
17433
+ ];
17434
+ // add filters from the passed in query
17435
+ qry.filters = __spreadArrays(scopingFilters, qry.filters);
17436
+ return [2 /*return*/, searchEntities(qry, convertItemToSite, options)];
17374
17437
  });
17375
17438
  });
17376
17439
  }
@@ -17570,14 +17633,14 @@
17570
17633
  * @param filter
17571
17634
  * @param opts
17572
17635
  */
17573
- HubSiteManager.prototype.search = function (filter, options) {
17636
+ HubSiteManager.prototype.search = function (query, options) {
17574
17637
  return __awaiter(this, void 0, void 0, function () {
17575
17638
  return __generator(this, function (_a) {
17576
17639
  // if we were not passed auth, and we have a session, use it
17577
17640
  if (!options.authentication && this.context.session) {
17578
17641
  options.authentication = this.context.session;
17579
17642
  }
17580
- return [2 /*return*/, searchSites(filter, options)];
17643
+ return [2 /*return*/, searchSites(query, options)];
17581
17644
  });
17582
17645
  });
17583
17646
  };
@@ -17899,28 +17962,6 @@
17899
17962
  }
17900
17963
  }
17901
17964
 
17902
- /**
17903
- * @private
17904
- * Convert a portal aggregation structure into the HubAggregations structure
17905
- * @param searchResults
17906
- * @returns
17907
- */
17908
- function convertPortalAggregations(searchResults) {
17909
- var _a;
17910
- if ((_a = searchResults.aggregations) === null || _a === void 0 ? void 0 : _a.counts) {
17911
- return searchResults.aggregations.counts.map(function (entry) {
17912
- return {
17913
- mode: "terms",
17914
- field: entry.fieldName,
17915
- values: entry.fieldValues,
17916
- };
17917
- });
17918
- }
17919
- else {
17920
- return [];
17921
- }
17922
- }
17923
-
17924
17965
  /**
17925
17966
  * @private
17926
17967
  * Portal Search Implementation for Items
@@ -18219,6 +18260,7 @@
18219
18260
  // iterate the filters
18220
18261
  queryClone.filters = queryClone.filters.map(function (filter) {
18221
18262
  // replace predicates with well-known types
18263
+ var replacedPredicates = false;
18222
18264
  filter.predicates = filter.predicates.reduce(function (acc, predicate) {
18223
18265
  // if the predicate has a well-known type
18224
18266
  // we replace it with the set of predicates defined
@@ -18226,6 +18268,7 @@
18226
18268
  if (isWellKnownTypeFilter(predicate.type)) {
18227
18269
  var replacements = lookupTypePredicates(predicate.type);
18228
18270
  acc = __spreadArrays(acc, replacements);
18271
+ replacedPredicates = true;
18229
18272
  }
18230
18273
  else {
18231
18274
  // this predicate does not have a well-known type
@@ -18234,6 +18277,12 @@
18234
18277
  }
18235
18278
  return acc;
18236
18279
  }, []);
18280
+ if (replacedPredicates) {
18281
+ // Any filter who's predicates were replaced with
18282
+ // well-known predicates, needs to use "OR" to ensure
18283
+ // correct query logic
18284
+ filter.operation = "OR";
18285
+ }
18237
18286
  return filter;
18238
18287
  });
18239
18288
  return queryClone;
@@ -18280,6 +18329,7 @@
18280
18329
  //
18281
18330
  // Since Hub API is still in flux, there is no code coverage for this file
18282
18331
  /**
18332
+ * @private
18283
18333
  * Execute item search against the Hub API
18284
18334
  * @param filter
18285
18335
  * @param options