@esri/hub-common 9.31.3 → 9.33.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 (86) hide show
  1. package/dist/es2017/content/_internal.js +1 -1
  2. package/dist/es2017/content/_internal.js.map +1 -1
  3. package/dist/es2017/core/types/index.js +1 -0
  4. package/dist/es2017/core/types/index.js.map +1 -1
  5. package/dist/es2017/core/types/types.js +1 -0
  6. package/dist/es2017/core/types/types.js.map +1 -0
  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/IHubApiSearchRequest.js +1 -0
  12. package/dist/es2017/search/types/IHubApiSearchRequest.js.map +1 -0
  13. package/dist/es2017/search/types/IHubSearchOptions.js +1 -0
  14. package/dist/es2017/search/types/IHubSearchOptions.js.map +1 -0
  15. package/dist/es2017/search/types/IHubSearchResponse.js +1 -0
  16. package/dist/es2017/search/types/IHubSearchResponse.js.map +1 -0
  17. package/dist/es2017/search/types/IHubSearchResult.js +1 -0
  18. package/dist/es2017/search/types/IHubSearchResult.js.map +1 -0
  19. package/dist/es2017/search/types/index.js +4 -0
  20. package/dist/es2017/search/types/index.js.map +1 -1
  21. package/dist/es2017/search/utils.js +5 -1
  22. package/dist/es2017/search/utils.js.map +1 -1
  23. package/dist/esm/content/_internal.js +1 -1
  24. package/dist/esm/content/_internal.js.map +1 -1
  25. package/dist/esm/core/types/index.js +1 -0
  26. package/dist/esm/core/types/index.js.map +1 -1
  27. package/dist/esm/core/types/types.js +1 -0
  28. package/dist/esm/core/types/types.js.map +1 -0
  29. package/dist/esm/search/filter-utils.js +152 -0
  30. package/dist/esm/search/filter-utils.js.map +1 -0
  31. package/dist/esm/search/index.js +1 -0
  32. package/dist/esm/search/index.js.map +1 -1
  33. package/dist/esm/search/types/IHubApiSearchRequest.js +1 -0
  34. package/dist/esm/search/types/IHubApiSearchRequest.js.map +1 -0
  35. package/dist/esm/search/types/IHubSearchOptions.js +1 -0
  36. package/dist/esm/search/types/IHubSearchOptions.js.map +1 -0
  37. package/dist/esm/search/types/IHubSearchResponse.js +1 -0
  38. package/dist/esm/search/types/IHubSearchResponse.js.map +1 -0
  39. package/dist/esm/search/types/IHubSearchResult.js +1 -0
  40. package/dist/esm/search/types/IHubSearchResult.js.map +1 -0
  41. package/dist/esm/search/types/index.js +4 -0
  42. package/dist/esm/search/types/index.js.map +1 -1
  43. package/dist/esm/search/utils.js +5 -1
  44. package/dist/esm/search/utils.js.map +1 -1
  45. package/dist/node/content/_internal.js +1 -1
  46. package/dist/node/content/_internal.js.map +1 -1
  47. package/dist/node/core/types/index.js +1 -0
  48. package/dist/node/core/types/index.js.map +1 -1
  49. package/dist/node/core/types/types.js +3 -0
  50. package/dist/node/core/types/types.js.map +1 -0
  51. package/dist/node/search/filter-utils.js +154 -0
  52. package/dist/node/search/filter-utils.js.map +1 -0
  53. package/dist/node/search/index.js +1 -0
  54. package/dist/node/search/index.js.map +1 -1
  55. package/dist/node/search/types/IHubApiSearchRequest.js +3 -0
  56. package/dist/node/search/types/IHubApiSearchRequest.js.map +1 -0
  57. package/dist/node/search/types/IHubSearchOptions.js +3 -0
  58. package/dist/node/search/types/IHubSearchOptions.js.map +1 -0
  59. package/dist/node/search/types/IHubSearchResponse.js +3 -0
  60. package/dist/node/search/types/IHubSearchResponse.js.map +1 -0
  61. package/dist/node/search/types/IHubSearchResult.js +3 -0
  62. package/dist/node/search/types/IHubSearchResult.js.map +1 -0
  63. package/dist/node/search/types/index.js +4 -0
  64. package/dist/node/search/types/index.js.map +1 -1
  65. package/dist/node/search/utils.js +5 -1
  66. package/dist/node/search/utils.js.map +1 -1
  67. package/dist/types/content/_internal.d.ts +1 -0
  68. package/dist/types/core/types/IHubEntityBase.d.ts +15 -5
  69. package/dist/types/core/types/IHubEntityManager.d.ts +2 -1
  70. package/dist/types/core/types/index.d.ts +1 -0
  71. package/dist/types/core/types/types.d.ts +4 -0
  72. package/dist/types/search/filter-utils.d.ts +18 -0
  73. package/dist/types/search/index.d.ts +1 -0
  74. package/dist/types/search/types/IFacet.d.ts +46 -5
  75. package/dist/types/search/types/IFacetOption.d.ts +23 -1
  76. package/dist/types/search/types/IHubApiSearchRequest.d.ts +16 -0
  77. package/dist/types/search/types/IHubSearchOptions.d.ts +26 -0
  78. package/dist/types/search/types/IHubSearchResponse.d.ts +17 -0
  79. package/dist/types/search/types/IHubSearchResult.d.ts +60 -0
  80. package/dist/types/search/types/index.d.ts +4 -0
  81. package/dist/types/search/types/types.d.ts +27 -25
  82. package/dist/types/search/utils.d.ts +1 -0
  83. package/dist/types/types.d.ts +1 -1
  84. package/dist/umd/common.umd.js +173 -19
  85. package/dist/umd/common.umd.js.map +1 -1
  86. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import { Filter, IFilterGroup, FilterType } from "./types";
2
+ import { IHubSearchOptions } from "./IHubSearchOptions";
3
+ /**
4
+ * Structure for making Hub API Search Requests
5
+ */
6
+ export interface IHubApiSearchRequest {
7
+ /**
8
+ * Can be a string like `term:"water"`, a single filter like `{ filterType: "item", term: "water" }`
9
+ * or an array of IFilterGroups, which allows for complex queries.
10
+ */
11
+ q: string | Filter<FilterType> | Array<IFilterGroup<FilterType>>;
12
+ /**
13
+ * Search options like the number of results to return, sorting, aggregations etc
14
+ */
15
+ options: IHubSearchOptions;
16
+ }
@@ -0,0 +1,26 @@
1
+ import { UserSession } from "@esri/arcgis-rest-auth";
2
+ import { IModel } from "../..";
3
+ import { NamedApis, IApiDefinition } from "./types";
4
+ /**
5
+ * Requestable Enrichments
6
+ */
7
+ export declare type Enrichments = "data" | "metadata" | "org" | "service" | "layers";
8
+ /**
9
+ * Search Options
10
+ */
11
+ export interface IHubSearchOptions {
12
+ aggFields?: string[];
13
+ aggLimit?: number;
14
+ api?: NamedApis | IApiDefinition;
15
+ authentication?: UserSession;
16
+ bbox?: string;
17
+ enrichments?: Enrichments[];
18
+ fields?: string;
19
+ num?: number;
20
+ page?: string;
21
+ sortField?: string;
22
+ sortOrder?: "desc" | "asc";
23
+ start?: number;
24
+ aggregations?: string[];
25
+ site?: IModel;
26
+ }
@@ -0,0 +1,17 @@
1
+ import { IFacet } from "./IFacet";
2
+ /**
3
+ * Defines a generic search response interface with parameterized result type
4
+ * for different types of searches
5
+ *
6
+ * total - total number of results
7
+ * results - potentially paginated list of results
8
+ * hasNext - boolean flag for if there are any more pages ofresults
9
+ * next - invokable function for obtaining next page of results
10
+ */
11
+ export interface IHubSearchResponse<T> {
12
+ total: number;
13
+ results: T[];
14
+ hasNext: boolean;
15
+ next: (params?: any) => Promise<IHubSearchResponse<T>>;
16
+ facets?: IFacet[];
17
+ }
@@ -0,0 +1,60 @@
1
+ import { HubFamily, IHubGeography } from "../..";
2
+ import { AccessLevel, IHubEntityBase } from "../../core";
3
+ /**
4
+ * Standardized light-weight search result structure, applicable to all
5
+ * types of search results - users, groups, content, events etc
6
+ */
7
+ export interface IHubSearchResult extends IHubEntityBase {
8
+ /**
9
+ * Access level of the backing entity
10
+ */
11
+ access: AccessLevel;
12
+ /**
13
+ * Hub Family
14
+ */
15
+ family: HubFamily;
16
+ /**
17
+ * Owner; Applies to Items and Groups
18
+ */
19
+ owner?: string;
20
+ /**
21
+ * Fully qualified thumbnail url for items, groups, users
22
+ * Will not have the token appended. Consuming app needs to
23
+ * check the value of `access` and apply the token as needed
24
+ */
25
+ thumbnailUrl: string;
26
+ /**
27
+ * Hash of pre-computed urls
28
+ */
29
+ urls: {
30
+ /**
31
+ * Canononical ArcGIS Online Url for this entity (if applicable)
32
+ */
33
+ portalHome?: string;
34
+ /**
35
+ * Relative url, which can be appended to a Site's root Url
36
+ * e.g. /datasets/3ef8c7a, or /events/june-meeting
37
+ * This is much easier than passing a Site into the search
38
+ * system so the full url can be computed
39
+ */
40
+ relative: string;
41
+ /**
42
+ * Allow for arbitrary other urls, including `.customUrl` which
43
+ * can ben generated client-side in the gallery via a callback
44
+ */
45
+ [key: string]: string;
46
+ };
47
+ /**
48
+ * Geometry connected to this entity
49
+ * For items, it will default to the extent,
50
+ * but may be derived from a boundary resource
51
+ * or the extent of a layer
52
+ */
53
+ geometry?: IHubGeography;
54
+ /**
55
+ * Optional metadata hash
56
+ * Any specified enrichments will be attached in here, as well
57
+ * as tags, typekeywords and culture
58
+ */
59
+ metadata?: Record<string, any>;
60
+ }
@@ -2,4 +2,8 @@ export * from "./ICatalog";
2
2
  export * from "./ICollection";
3
3
  export * from "./IFacet";
4
4
  export * from "./IFacetOption";
5
+ export * from "./IHubApiSearchRequest";
6
+ export * from "./IHubSearchOptions";
7
+ export * from "./IHubSearchResult";
8
+ export * from "./IHubSearchResponse";
5
9
  export * from "./types";
@@ -1,5 +1,5 @@
1
1
  import { UserSession } from "@esri/arcgis-rest-auth";
2
- import { IHubContent, IModel } from "../..";
2
+ import { IHubContent, AccessLevel } from "../..";
3
3
  import { IFacet } from "./IFacet";
4
4
  /**
5
5
  * Generic filter used with various search functions.
@@ -24,12 +24,27 @@ import { IFacet } from "./IFacet";
24
24
  export declare type Filter<T extends FilterType> = IFilterTypeMap[T] & {
25
25
  filterType: T;
26
26
  };
27
+ export interface IFilterGroup<T extends FilterType> {
28
+ operation?: "AND" | "OR";
29
+ filters: Array<Filter<T>>;
30
+ }
31
+ /**
32
+ * Groups of filters with an operation specifying how the
33
+ * filters should be connected when serialized
34
+ */
35
+ export interface IFilterGroup<T extends FilterType> {
36
+ operation?: "AND" | "OR";
37
+ filters: Array<Filter<T>>;
38
+ }
27
39
  /**
28
40
  * Defines the valid FilterTypes for use with `Filter<T extends FilterType>`
29
41
  * See [Filter](../Filter)
30
42
  */
31
43
  export interface IFilterTypeMap {
32
- any: IAnyFilterDefinition;
44
+ item: IItemFilter;
45
+ /**
46
+ * DEPRECATED use item
47
+ */
33
48
  content: IContentFilterDefinition;
34
49
  user: IUserFilterDefinition;
35
50
  group: IGroupFilterDefinition;
@@ -40,17 +55,22 @@ export declare type FilterType = keyof IFilterTypeMap;
40
55
  * Common set of fields that are reasonable to apply at the
41
56
  * top level of a Catalog
42
57
  */
43
- export interface IAnyFilterDefinition {
44
- title?: string | string[] | IMatchOptions;
45
- access?: string | string[] | IMatchOptions;
58
+ export interface IItemFilter {
59
+ access?: AccessLevel | AccessLevel[] | IMatchOptions;
46
60
  owner?: string | string[] | IMatchOptions;
47
61
  tags?: string | string[] | IMatchOptions;
48
62
  created?: IDateRange<number> | IRelativeDate;
49
- modified?: IDateRange<number> | IRelativeDate;
50
63
  description?: string | string[] | IMatchOptions;
64
+ snippet?: string | string[] | IMatchOptions;
51
65
  group?: string | string[] | IMatchOptions;
66
+ id?: string | string[] | IMatchOptions;
67
+ modified?: IDateRange<number> | IRelativeDate;
52
68
  orgid?: string | string[] | IMatchOptions;
53
- type?: string | NamedContentFilter | Array<string | NamedContentFilter> | IMatchOptions;
69
+ term?: string;
70
+ title?: string | string[] | IMatchOptions;
71
+ type?: string | string[] | IMatchOptions;
72
+ typekeywords?: string | string[] | IMatchOptions;
73
+ [key: string]: any;
54
74
  }
55
75
  /**
56
76
  * Fields related to Content based searches
@@ -194,24 +214,6 @@ export interface IMatchOptions {
194
214
  */
195
215
  exact?: string | string[];
196
216
  }
197
- /**
198
- * Search Options
199
- */
200
- export interface IHubSearchOptions {
201
- site?: IModel;
202
- authentication?: UserSession;
203
- sortField?: string;
204
- sortOrder?: "desc" | "asc";
205
- page?: string;
206
- start?: number;
207
- num?: number;
208
- aggFields?: string[];
209
- aggLimit?: number;
210
- bbox?: string;
211
- fields?: string;
212
- api?: NamedApis | IApiDefinition;
213
- aggregations?: string[];
214
- }
215
217
  /**
216
218
  * searchContent return
217
219
  */
@@ -69,6 +69,7 @@ export declare function mergeSearchOptions(so1: ISearchOptions, so2: ISearchOpti
69
69
  /**
70
70
  * @private
71
71
  * Serialize a `MatchOptions` into `q` or `filter` on an `ISearchOptions`
72
+ * DEPRECATED: Serialization should be handled in filter-utils.ts
72
73
  * @param key
73
74
  * @param opts
74
75
  * @returns
@@ -134,7 +134,7 @@ export declare type IRevertableTaskResult = IRevertableTaskSuccess | IRevertable
134
134
  * DEPRECATED: Use HubFamily instead
135
135
  */
136
136
  export declare type HubType = "member" | "team" | "event" | "dataset" | "document" | "map" | "app" | "site" | "initiative" | "template" | "organization";
137
- export declare type HubFamily = "people" | "team" | "event" | "dataset" | "document" | "feedback" | "map" | "app" | "site" | "initiative" | "template" | "content";
137
+ export declare type HubFamily = "app" | "content" | "dataset" | "document" | "event" | "feedback" | "initiative" | "map" | "people" | "site" | "team" | "template";
138
138
  /**
139
139
  * Visibility levels of a Hub resource
140
140
  */
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.31.2 - Thu May 12 2022 23:19:02 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.32.1 - Thu May 19 2022 17:14:39 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -6885,7 +6885,7 @@
6885
6885
  */
6886
6886
  var isDataSourceOfItem = function (resource, item) {
6887
6887
  var serviceUrl = item.url && parseServiceUrl(item.url);
6888
- return serviceUrl && resource.linkage.includes(serviceUrl);
6888
+ return (serviceUrl && resource.linkage && resource.linkage.includes(serviceUrl));
6889
6889
  };
6890
6890
  /**
6891
6891
  * Returns the url for an additional resource.
@@ -13141,11 +13141,12 @@
13141
13141
  /**
13142
13142
  * @private
13143
13143
  * Serialize a `MatchOptions` into `q` or `filter` on an `ISearchOptions`
13144
+ * DEPRECATED: Serialization should be handled in filter-utils.ts
13144
13145
  * @param key
13145
13146
  * @param opts
13146
13147
  * @returns
13147
13148
  */
13148
- function serializeMatchOptions(key, opts) {
13149
+ function serializeMatchOptions$1(key, opts) {
13149
13150
  var result = {
13150
13151
  q: "",
13151
13152
  filter: "",
@@ -13170,7 +13171,7 @@
13170
13171
  var groupFilterableFields = ["title", "typekeywords", "owner"];
13171
13172
  var filterableFields = __spreadArrays(userFilterableFields, itemFilterableFields, groupFilterableFields);
13172
13173
  if (filterableFields.includes(key)) {
13173
- result.filter = serializeStringOrArray("AND", key, opts.exact);
13174
+ result.filter = serializeStringOrArray$1("AND", key, opts.exact);
13174
13175
  }
13175
13176
  else {
13176
13177
  // Treat it the same as .all
@@ -13196,18 +13197,18 @@
13196
13197
  }
13197
13198
  // Handle the other props
13198
13199
  if (opts.any) {
13199
- result.q = serializeStringOrArray("OR", key, opts.any);
13200
+ result.q = serializeStringOrArray$1("OR", key, opts.any);
13200
13201
  }
13201
13202
  if (opts.all) {
13202
13203
  result.q =
13203
13204
  (result.q ? result.q + " AND " : "") +
13204
- serializeStringOrArray("AND", key, opts.all);
13205
+ serializeStringOrArray$1("AND", key, opts.all);
13205
13206
  }
13206
13207
  if (opts.not) {
13207
13208
  // negate the entries if they are not
13208
13209
  result.q =
13209
13210
  (result.q ? result.q + " AND " : "") +
13210
- serializeStringOrArray("OR", "-" + key, opts.not);
13211
+ serializeStringOrArray$1("OR", "-" + key, opts.not);
13211
13212
  }
13212
13213
  return result;
13213
13214
  }
@@ -13218,7 +13219,7 @@
13218
13219
  * @param range
13219
13220
  * @returns
13220
13221
  */
13221
- function serializeDateRange(key, range) {
13222
+ function serializeDateRange$1(key, range) {
13222
13223
  return {
13223
13224
  q: key + ":[" + range.from + " TO " + range.to + "]",
13224
13225
  filter: "",
@@ -13232,10 +13233,13 @@
13232
13233
  * @param value
13233
13234
  * @returns
13234
13235
  */
13235
- function serializeStringOrArray(join, key, value) {
13236
+ function serializeStringOrArray$1(join, key, value) {
13236
13237
  var q = "";
13237
13238
  if (Array.isArray(value)) {
13238
- q = "(" + key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\")";
13239
+ q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
13240
+ if (value.length > 1) {
13241
+ q = "(" + q + ")";
13242
+ }
13239
13243
  }
13240
13244
  else {
13241
13245
  q = key + ":\"" + value + "\"";
@@ -13716,11 +13720,11 @@
13716
13720
  var key = _a[0], value = _a[1];
13717
13721
  // MatchOptions may go into either q or filter
13718
13722
  if (!specialProps.includes(key)) {
13719
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
13723
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
13720
13724
  }
13721
13725
  // Dates only go into q
13722
13726
  if (dateProps.includes(key)) {
13723
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
13727
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
13724
13728
  }
13725
13729
  });
13726
13730
  return result;
@@ -15966,11 +15970,11 @@
15966
15970
  var key = _a[0], value = _a[1];
15967
15971
  // MatchOptions fields
15968
15972
  if (!specialProps.includes(key)) {
15969
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
15973
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
15970
15974
  }
15971
15975
  // Dates only go into q
15972
15976
  if (dateProps.includes(key)) {
15973
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
15977
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
15974
15978
  }
15975
15979
  });
15976
15980
  // searchUserAccess is also a top-level property
@@ -16099,11 +16103,11 @@
16099
16103
  var key = _a[0], value = _a[1];
16100
16104
  // MatchOptions fields
16101
16105
  if (!specialProps.includes(key)) {
16102
- result = mergeSearchOptions(result, serializeMatchOptions(key, value), "AND");
16106
+ result = mergeSearchOptions(result, serializeMatchOptions$1(key, value), "AND");
16103
16107
  }
16104
16108
  // Dates only go into q
16105
16109
  if (dateProps.includes(key)) {
16106
- result = mergeSearchOptions(result, serializeDateRange(key, value), "AND");
16110
+ result = mergeSearchOptions(result, serializeDateRange$1(key, value), "AND");
16107
16111
  }
16108
16112
  });
16109
16113
  // disabled is also a top-level property
@@ -16604,6 +16608,154 @@
16604
16608
  return catalog;
16605
16609
  }
16606
16610
 
16611
+ /**
16612
+ * Expand a Filter into it's more expressive structure so it can be
16613
+ * serialized deterministically.
16614
+ *
16615
+ * Props with type `string | string[] | MatchOptions` expand into `IMatchOptions`
16616
+ * Props relative-dates are expanded into formal date-ranges
16617
+ * @param filter
16618
+ * @returns
16619
+ */
16620
+ function expandFilter(filter) {
16621
+ var result = {};
16622
+ var dateProps = ["created", "modified", "lastlogin"];
16623
+ var copyProps = ["filterType", "term", "searchUserAccess"];
16624
+ var nonMatchOptionsFields = __spreadArrays(dateProps, copyProps);
16625
+ // Do the conversion
16626
+ Object.entries(filter).forEach(function (_a) {
16627
+ var key = _a[0], value = _a[1];
16628
+ // Handle MatchOptions fields
16629
+ if (!nonMatchOptionsFields.includes(key)) {
16630
+ // setProp side-steps typescript complaining
16631
+ setProp(key, valueToMatchOptions(value), result);
16632
+ }
16633
+ // Handle Date fields
16634
+ if (dateProps.includes(key)) {
16635
+ var dateFieldValue = cloneObject$1(getProp(filter, key));
16636
+ if (getProp(filter, key + ".type") === "relative-date") {
16637
+ setProp(key, relativeDateToDateRange(dateFieldValue), result);
16638
+ }
16639
+ else {
16640
+ setProp(key, dateFieldValue, result);
16641
+ }
16642
+ }
16643
+ // Handle fields that are just copied forward
16644
+ if (copyProps.includes(key) && filter.hasOwnProperty(key)) {
16645
+ setProp(key, value, result);
16646
+ }
16647
+ });
16648
+ return result;
16649
+ }
16650
+ /**
16651
+ * Serialize a FilterGroup of any type for Portal
16652
+ * @param filterGroups
16653
+ * @returns
16654
+ */
16655
+ function serializeFilterGroupsForPortal(filterGroups) {
16656
+ var result = {
16657
+ q: "",
16658
+ filter: "",
16659
+ };
16660
+ result.q = filterGroups.map(serializeGroup).join(" AND ");
16661
+ return result;
16662
+ }
16663
+ /**
16664
+ * Serialize the filters in a FitlerGroup into a Portal Query
16665
+ * @param group
16666
+ * @returns
16667
+ */
16668
+ function serializeGroup(group) {
16669
+ var operation = group.operation || "AND";
16670
+ var filters = group.filters.map(expandFilter);
16671
+ return filters.map(serializeFilter).join(" " + operation + " ");
16672
+ }
16673
+ /**
16674
+ * Serialize a Filter into a Portal Query
16675
+ * @param filter
16676
+ * @returns
16677
+ */
16678
+ function serializeFilter(filter) {
16679
+ var dateProps = ["created", "modified"];
16680
+ var specialProps = __spreadArrays(["filterType", "searchUserAccess", "term"], dateProps);
16681
+ // TODO: Look at using reduce vs .map and remove the `.filter`
16682
+ var stringFilters = Object.entries(filter)
16683
+ .map(function (_a) {
16684
+ var key = _a[0], value = _a[1];
16685
+ if (!specialProps.includes(key)) {
16686
+ return serializeMatchOptions(key, value);
16687
+ }
16688
+ if (dateProps.includes(key)) {
16689
+ return serializeDateRange(key, value);
16690
+ }
16691
+ if (key === "term") {
16692
+ return value;
16693
+ }
16694
+ })
16695
+ .filter(function (e) { return e !== undefined; });
16696
+ // eslint-disable-next-line unicorn/prefer-ternary
16697
+ if (stringFilters.length > 1) {
16698
+ return "(" + stringFilters.join(" AND ") + ")";
16699
+ }
16700
+ else {
16701
+ return stringFilters[0];
16702
+ }
16703
+ }
16704
+ /**
16705
+ * Serialize MatchOptions into portal syntax
16706
+ * @param key
16707
+ * @param value
16708
+ * @returns
16709
+ */
16710
+ function serializeMatchOptions(key, value) {
16711
+ var result = "";
16712
+ if (value.any) {
16713
+ result = "" + serializeStringOrArray("OR", key, value.any);
16714
+ }
16715
+ if (value.all) {
16716
+ result =
16717
+ (result ? result + " AND " : "") +
16718
+ ("" + serializeStringOrArray("AND", key, value.all));
16719
+ }
16720
+ if (value.not) {
16721
+ // negate the entries if they are not
16722
+ result =
16723
+ (result ? result + " AND " : "") +
16724
+ ("" + serializeStringOrArray("OR", "-" + key, value.not));
16725
+ }
16726
+ // TODO HANDLE EXACT
16727
+ return result;
16728
+ }
16729
+ /**
16730
+ * Serialize a date-range into Portal syntax
16731
+ * @param key
16732
+ * @param range
16733
+ * @returns
16734
+ */
16735
+ function serializeDateRange(key, range) {
16736
+ return key + ":[" + range.from + " TO " + range.to + "]";
16737
+ }
16738
+ /**
16739
+ * Serialize a `string` or `string[]` into a string
16740
+ * @param join
16741
+ * @param key
16742
+ * @param value
16743
+ * @returns
16744
+ */
16745
+ function serializeStringOrArray(join, key, value) {
16746
+ var q = "";
16747
+ if (Array.isArray(value)) {
16748
+ q = key + ":\"" + value.join("\" " + join + " " + key + ":\"") + "\"";
16749
+ if (value.length > 1) {
16750
+ q = "(" + q + ")";
16751
+ }
16752
+ }
16753
+ else {
16754
+ q = key + ":\"" + value + "\"";
16755
+ }
16756
+ return q;
16757
+ }
16758
+
16607
16759
  /**
16608
16760
  * Add telemetry config object
16609
16761
  * @private
@@ -18487,6 +18639,7 @@
18487
18639
  exports.expandApi = expandApi;
18488
18640
  exports.expandApis = expandApis;
18489
18641
  exports.expandContentFilter = expandContentFilter;
18642
+ exports.expandFilter = expandFilter;
18490
18643
  exports.expandGroupFilter = expandGroupFilter;
18491
18644
  exports.expandTypeField = expandTypeField;
18492
18645
  exports.expandUserFilter = expandUserFilter;
@@ -18629,12 +18782,13 @@
18629
18782
  exports.searchSites = searchSites;
18630
18783
  exports.serializeCollectionState = serializeCollectionState;
18631
18784
  exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
18632
- exports.serializeDateRange = serializeDateRange;
18785
+ exports.serializeDateRange = serializeDateRange$1;
18786
+ exports.serializeFilterGroupsForPortal = serializeFilterGroupsForPortal;
18633
18787
  exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
18634
- exports.serializeMatchOptions = serializeMatchOptions;
18788
+ exports.serializeMatchOptions = serializeMatchOptions$1;
18635
18789
  exports.serializeModel = serializeModel;
18636
18790
  exports.serializeSpatialReference = serializeSpatialReference;
18637
- exports.serializeStringOrArray = serializeStringOrArray;
18791
+ exports.serializeStringOrArray = serializeStringOrArray$1;
18638
18792
  exports.serializeUserFilterForPortal = serializeUserFilterForPortal;
18639
18793
  exports.setContentHubId = setContentHubId;
18640
18794
  exports.setContentSiteUrls = setContentSiteUrls;