@esri/hub-common 9.49.1 → 10.0.0-next.3

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 (256) hide show
  1. package/dist/es2017/categories.js +4 -2
  2. package/dist/es2017/categories.js.map +1 -1
  3. package/dist/es2017/collections.js +3 -8
  4. package/dist/es2017/collections.js.map +1 -1
  5. package/dist/es2017/content/compose.js +1 -18
  6. package/dist/es2017/content/compose.js.map +1 -1
  7. package/dist/es2017/content/get-family.js +1 -3
  8. package/dist/es2017/content/get-family.js.map +1 -1
  9. package/dist/es2017/content/index.js +8 -71
  10. package/dist/es2017/content/index.js.map +1 -1
  11. package/dist/es2017/extent.js +1 -14
  12. package/dist/es2017/extent.js.map +1 -1
  13. package/dist/es2017/index.js +1 -0
  14. package/dist/es2017/index.js.map +1 -1
  15. package/dist/es2017/projects/HubProjectManager.js +0 -8
  16. package/dist/es2017/projects/HubProjectManager.js.map +1 -1
  17. package/dist/es2017/projects/HubProjects.js.map +1 -1
  18. package/dist/es2017/search/_internal/hubSearchItems.js +3 -137
  19. package/dist/es2017/search/_internal/hubSearchItems.js.map +1 -1
  20. package/dist/es2017/search/_internal/index.js +0 -1
  21. package/dist/es2017/search/_internal/index.js.map +1 -1
  22. package/dist/es2017/search/_internal/portalSearchGroups.js +0 -1
  23. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  24. package/dist/es2017/search/_internal/portalSearchItems.js +4 -29
  25. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  26. package/dist/es2017/search/_internal/portalSearchUsers.js +0 -1
  27. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
  28. package/dist/es2017/search/hubSearch.js +0 -16
  29. package/dist/es2017/search/hubSearch.js.map +1 -1
  30. package/dist/es2017/search/index.js +0 -9
  31. package/dist/es2017/search/index.js.map +1 -1
  32. package/dist/es2017/search/serializeQueryForPortal.js +0 -1
  33. package/dist/es2017/search/serializeQueryForPortal.js.map +1 -1
  34. package/dist/es2017/search/types/index.js +0 -5
  35. package/dist/es2017/search/types/index.js.map +1 -1
  36. package/dist/es2017/search/upgradeCatalogSchema.js +0 -8
  37. package/dist/es2017/search/upgradeCatalogSchema.js.map +1 -1
  38. package/dist/es2017/search/utils.js +1 -207
  39. package/dist/es2017/search/utils.js.map +1 -1
  40. package/dist/es2017/sites/fetchSiteModel.js +0 -9
  41. package/dist/es2017/sites/fetchSiteModel.js.map +1 -1
  42. package/dist/es2017/types.js.map +1 -1
  43. package/dist/esm/categories.js +4 -2
  44. package/dist/esm/categories.js.map +1 -1
  45. package/dist/esm/collections.js +3 -8
  46. package/dist/esm/collections.js.map +1 -1
  47. package/dist/esm/content/compose.js +1 -18
  48. package/dist/esm/content/compose.js.map +1 -1
  49. package/dist/esm/content/get-family.js +1 -3
  50. package/dist/esm/content/get-family.js.map +1 -1
  51. package/dist/esm/content/index.js +8 -71
  52. package/dist/esm/content/index.js.map +1 -1
  53. package/dist/esm/extent.js +1 -14
  54. package/dist/esm/extent.js.map +1 -1
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/index.js.map +1 -1
  57. package/dist/esm/projects/HubProjectManager.js +0 -12
  58. package/dist/esm/projects/HubProjectManager.js.map +1 -1
  59. package/dist/esm/projects/HubProjects.js.map +1 -1
  60. package/dist/esm/search/_internal/hubSearchItems.js +4 -146
  61. package/dist/esm/search/_internal/hubSearchItems.js.map +1 -1
  62. package/dist/esm/search/_internal/index.js +0 -1
  63. package/dist/esm/search/_internal/index.js.map +1 -1
  64. package/dist/esm/search/_internal/portalSearchGroups.js +0 -1
  65. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  66. package/dist/esm/search/_internal/portalSearchItems.js +5 -29
  67. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  68. package/dist/esm/search/_internal/portalSearchUsers.js +0 -1
  69. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
  70. package/dist/esm/search/hubSearch.js +0 -20
  71. package/dist/esm/search/hubSearch.js.map +1 -1
  72. package/dist/esm/search/index.js +0 -9
  73. package/dist/esm/search/index.js.map +1 -1
  74. package/dist/esm/search/serializeQueryForPortal.js +0 -1
  75. package/dist/esm/search/serializeQueryForPortal.js.map +1 -1
  76. package/dist/esm/search/types/index.js +0 -5
  77. package/dist/esm/search/types/index.js.map +1 -1
  78. package/dist/esm/search/upgradeCatalogSchema.js +0 -8
  79. package/dist/esm/search/upgradeCatalogSchema.js.map +1 -1
  80. package/dist/esm/search/utils.js +1 -204
  81. package/dist/esm/search/utils.js.map +1 -1
  82. package/dist/esm/sites/fetchSiteModel.js +0 -9
  83. package/dist/esm/sites/fetchSiteModel.js.map +1 -1
  84. package/dist/esm/types.js.map +1 -1
  85. package/dist/node/categories.js +4 -2
  86. package/dist/node/categories.js.map +1 -1
  87. package/dist/node/collections.js +3 -8
  88. package/dist/node/collections.js.map +1 -1
  89. package/dist/node/content/compose.js +1 -18
  90. package/dist/node/content/compose.js.map +1 -1
  91. package/dist/node/content/get-family.js +1 -3
  92. package/dist/node/content/get-family.js.map +1 -1
  93. package/dist/node/content/index.js +9 -73
  94. package/dist/node/content/index.js.map +1 -1
  95. package/dist/node/extent.js +2 -16
  96. package/dist/node/extent.js.map +1 -1
  97. package/dist/node/index.js +1 -0
  98. package/dist/node/index.js.map +1 -1
  99. package/dist/node/projects/HubProjectManager.js +0 -8
  100. package/dist/node/projects/HubProjectManager.js.map +1 -1
  101. package/dist/node/projects/HubProjects.js.map +1 -1
  102. package/dist/node/search/_internal/hubSearchItems.js +4 -139
  103. package/dist/node/search/_internal/hubSearchItems.js.map +1 -1
  104. package/dist/node/search/_internal/index.js +0 -1
  105. package/dist/node/search/_internal/index.js.map +1 -1
  106. package/dist/node/search/_internal/portalSearchGroups.js +0 -1
  107. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  108. package/dist/node/search/_internal/portalSearchItems.js +4 -29
  109. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  110. package/dist/node/search/_internal/portalSearchUsers.js +0 -1
  111. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
  112. package/dist/node/search/hubSearch.js +1 -18
  113. package/dist/node/search/hubSearch.js.map +1 -1
  114. package/dist/node/search/index.js +0 -9
  115. package/dist/node/search/index.js.map +1 -1
  116. package/dist/node/search/serializeQueryForPortal.js +0 -1
  117. package/dist/node/search/serializeQueryForPortal.js.map +1 -1
  118. package/dist/node/search/types/index.js +0 -5
  119. package/dist/node/search/types/index.js.map +1 -1
  120. package/dist/node/search/upgradeCatalogSchema.js +1 -10
  121. package/dist/node/search/upgradeCatalogSchema.js.map +1 -1
  122. package/dist/node/search/utils.js +1 -213
  123. package/dist/node/search/utils.js.map +1 -1
  124. package/dist/node/sites/fetchSiteModel.js +1 -11
  125. package/dist/node/sites/fetchSiteModel.js.map +1 -1
  126. package/dist/node/types.js.map +1 -1
  127. package/dist/types/collections.d.ts +1 -6
  128. package/dist/types/content/_internal.d.ts +0 -3
  129. package/dist/types/content/get-family.d.ts +1 -1
  130. package/dist/types/content/index.d.ts +3 -36
  131. package/dist/types/core/types/IHubContent.d.ts +0 -3
  132. package/dist/types/core/types/IServerEnrichments.d.ts +0 -2
  133. package/dist/types/extent.d.ts +0 -2
  134. package/dist/types/projects/HubProjectManager.d.ts +0 -1
  135. package/dist/types/search/_internal/hubSearchItems.d.ts +3 -4
  136. package/dist/types/search/_internal/index.d.ts +0 -1
  137. package/dist/types/search/_internal/portalSearchItems.d.ts +15 -15
  138. package/dist/types/search/hubSearch.d.ts +0 -13
  139. package/dist/types/search/index.d.ts +0 -9
  140. package/dist/types/search/types/IHubSearchOptions.d.ts +1 -17
  141. package/dist/types/search/types/IHubSearchResponse.d.ts +0 -5
  142. package/dist/types/search/types/IHubSearchResult.d.ts +0 -39
  143. package/dist/types/search/types/index.d.ts +0 -5
  144. package/dist/types/search/types/types.d.ts +0 -206
  145. package/dist/types/search/upgradeCatalogSchema.d.ts +0 -5
  146. package/dist/types/search/utils.d.ts +2 -58
  147. package/dist/types/sites/fetchSiteModel.d.ts +2 -6
  148. package/dist/types/types.d.ts +0 -70
  149. package/dist/umd/common.umd.js +42 -1900
  150. package/dist/umd/common.umd.js.map +1 -1
  151. package/package.json +1 -1
  152. package/dist/es2017/search/_internal/state.js +0 -155
  153. package/dist/es2017/search/_internal/state.js.map +0 -1
  154. package/dist/es2017/search/_searchContent.js +0 -116
  155. package/dist/es2017/search/_searchContent.js.map +0 -1
  156. package/dist/es2017/search/_searchGroups.js +0 -88
  157. package/dist/es2017/search/_searchGroups.js.map +0 -1
  158. package/dist/es2017/search/_searchUsers.js +0 -89
  159. package/dist/es2017/search/_searchUsers.js.map +0 -1
  160. package/dist/es2017/search/collectionState.js +0 -60
  161. package/dist/es2017/search/collectionState.js.map +0 -1
  162. package/dist/es2017/search/content-utils.js +0 -455
  163. package/dist/es2017/search/content-utils.js.map +0 -1
  164. package/dist/es2017/search/filter-utils.js +0 -31
  165. package/dist/es2017/search/filter-utils.js.map +0 -1
  166. package/dist/es2017/search/group-utils.js +0 -142
  167. package/dist/es2017/search/group-utils.js.map +0 -1
  168. package/dist/es2017/search/hub-api-search.js +0 -19
  169. package/dist/es2017/search/hub-api-search.js.map +0 -1
  170. package/dist/es2017/search/types/ICatalog.js +0 -1
  171. package/dist/es2017/search/types/ICatalog.js.map +0 -1
  172. package/dist/es2017/search/types/ICollection.js +0 -1
  173. package/dist/es2017/search/types/ICollection.js.map +0 -1
  174. package/dist/es2017/search/types/IFacet.js +0 -1
  175. package/dist/es2017/search/types/IFacet.js.map +0 -1
  176. package/dist/es2017/search/types/IFacetOption.js +0 -1
  177. package/dist/es2017/search/types/IFacetOption.js.map +0 -1
  178. package/dist/es2017/search/types/IHubApiSearchRequest.js +0 -1
  179. package/dist/es2017/search/types/IHubApiSearchRequest.js.map +0 -1
  180. package/dist/es2017/search/user-utils.js +0 -139
  181. package/dist/es2017/search/user-utils.js.map +0 -1
  182. package/dist/esm/search/_internal/state.js +0 -155
  183. package/dist/esm/search/_internal/state.js.map +0 -1
  184. package/dist/esm/search/_searchContent.js +0 -118
  185. package/dist/esm/search/_searchContent.js.map +0 -1
  186. package/dist/esm/search/_searchGroups.js +0 -91
  187. package/dist/esm/search/_searchGroups.js.map +0 -1
  188. package/dist/esm/search/_searchUsers.js +0 -92
  189. package/dist/esm/search/_searchUsers.js.map +0 -1
  190. package/dist/esm/search/collectionState.js +0 -61
  191. package/dist/esm/search/collectionState.js.map +0 -1
  192. package/dist/esm/search/content-utils.js +0 -462
  193. package/dist/esm/search/content-utils.js.map +0 -1
  194. package/dist/esm/search/filter-utils.js +0 -31
  195. package/dist/esm/search/filter-utils.js.map +0 -1
  196. package/dist/esm/search/group-utils.js +0 -146
  197. package/dist/esm/search/group-utils.js.map +0 -1
  198. package/dist/esm/search/hub-api-search.js +0 -20
  199. package/dist/esm/search/hub-api-search.js.map +0 -1
  200. package/dist/esm/search/types/ICatalog.js +0 -1
  201. package/dist/esm/search/types/ICatalog.js.map +0 -1
  202. package/dist/esm/search/types/ICollection.js +0 -1
  203. package/dist/esm/search/types/ICollection.js.map +0 -1
  204. package/dist/esm/search/types/IFacet.js +0 -1
  205. package/dist/esm/search/types/IFacet.js.map +0 -1
  206. package/dist/esm/search/types/IFacetOption.js +0 -1
  207. package/dist/esm/search/types/IFacetOption.js.map +0 -1
  208. package/dist/esm/search/types/IHubApiSearchRequest.js +0 -1
  209. package/dist/esm/search/types/IHubApiSearchRequest.js.map +0 -1
  210. package/dist/esm/search/user-utils.js +0 -143
  211. package/dist/esm/search/user-utils.js.map +0 -1
  212. package/dist/node/search/_internal/state.js +0 -166
  213. package/dist/node/search/_internal/state.js.map +0 -1
  214. package/dist/node/search/_searchContent.js +0 -120
  215. package/dist/node/search/_searchContent.js.map +0 -1
  216. package/dist/node/search/_searchGroups.js +0 -92
  217. package/dist/node/search/_searchGroups.js.map +0 -1
  218. package/dist/node/search/_searchUsers.js +0 -93
  219. package/dist/node/search/_searchUsers.js.map +0 -1
  220. package/dist/node/search/collectionState.js +0 -65
  221. package/dist/node/search/collectionState.js.map +0 -1
  222. package/dist/node/search/content-utils.js +0 -466
  223. package/dist/node/search/content-utils.js.map +0 -1
  224. package/dist/node/search/filter-utils.js +0 -36
  225. package/dist/node/search/filter-utils.js.map +0 -1
  226. package/dist/node/search/group-utils.js +0 -148
  227. package/dist/node/search/group-utils.js.map +0 -1
  228. package/dist/node/search/hub-api-search.js +0 -23
  229. package/dist/node/search/hub-api-search.js.map +0 -1
  230. package/dist/node/search/types/ICatalog.js +0 -3
  231. package/dist/node/search/types/ICatalog.js.map +0 -1
  232. package/dist/node/search/types/ICollection.js +0 -3
  233. package/dist/node/search/types/ICollection.js.map +0 -1
  234. package/dist/node/search/types/IFacet.js +0 -3
  235. package/dist/node/search/types/IFacet.js.map +0 -1
  236. package/dist/node/search/types/IFacetOption.js +0 -3
  237. package/dist/node/search/types/IFacetOption.js.map +0 -1
  238. package/dist/node/search/types/IHubApiSearchRequest.js +0 -3
  239. package/dist/node/search/types/IHubApiSearchRequest.js.map +0 -1
  240. package/dist/node/search/user-utils.js +0 -145
  241. package/dist/node/search/user-utils.js.map +0 -1
  242. package/dist/types/search/_internal/state.d.ts +0 -70
  243. package/dist/types/search/_searchContent.d.ts +0 -9
  244. package/dist/types/search/_searchGroups.d.ts +0 -17
  245. package/dist/types/search/_searchUsers.d.ts +0 -31
  246. package/dist/types/search/collectionState.d.ts +0 -19
  247. package/dist/types/search/content-utils.d.ts +0 -83
  248. package/dist/types/search/filter-utils.d.ts +0 -13
  249. package/dist/types/search/group-utils.d.ts +0 -36
  250. package/dist/types/search/hub-api-search.d.ts +0 -10
  251. package/dist/types/search/types/ICatalog.d.ts +0 -87
  252. package/dist/types/search/types/ICollection.d.ts +0 -28
  253. package/dist/types/search/types/IFacet.d.ts +0 -62
  254. package/dist/types/search/types/IFacetOption.d.ts +0 -30
  255. package/dist/types/search/types/IHubApiSearchRequest.d.ts +0 -16
  256. package/dist/types/search/user-utils.d.ts +0 -35
@@ -1,466 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertContentFilterToSearchOptions = exports.serializeContentFilterForPortal = exports.convertContentDefinitionToFilter = exports.expandTypeField = exports.expandContentFilter = exports.mergeContentFilter = exports.convertPortalItemResponseToFacets = exports.convertPortalResponseToFacets = void 0;
4
- const __1 = require("..");
5
- const utils_1 = require("./utils");
6
- // TODO: Remove with _searchContent
7
- // TODO: Implement $dataset
8
- const ContentFilterExpansions = {
9
- $apps: [
10
- {
11
- type: {
12
- any: [
13
- "Code Sample",
14
- "Web Mapping Application",
15
- "Mobile Application",
16
- "Application",
17
- "Desktop Application Template",
18
- "Desktop Application",
19
- "Operation View",
20
- "Dashboard",
21
- "Operations Dashboard Extension",
22
- "Workforce Project",
23
- "Insights Workbook",
24
- "Insights Page",
25
- "Insights Model",
26
- "Hub Page",
27
- "Hub Initiative",
28
- "Hub Site Application",
29
- "StoryMap",
30
- "Web Experience",
31
- "Web Experience Template",
32
- "Form",
33
- ],
34
- not: [
35
- "Code Attachment",
36
- "Featured Items",
37
- "Symbol Set",
38
- "Color Set",
39
- "Windows Viewer Add In",
40
- "Windows Viewer Configuration",
41
- "Map Area",
42
- "Indoors Map Configuration",
43
- ],
44
- },
45
- typekeywords: {
46
- not: ["MapAreaPackage", "SMX"],
47
- },
48
- },
49
- ],
50
- $storymap: [
51
- {
52
- type: "StoryMap",
53
- },
54
- {
55
- type: "Web Mapping Application",
56
- typekeywords: ["Story Map"],
57
- },
58
- ],
59
- $dashboard: [
60
- {
61
- type: "Dashboard",
62
- typekeywords: {
63
- any: ["Dashboard"],
64
- not: ["ArcGIS Operation View", "Add In", "Extension"],
65
- },
66
- },
67
- ],
68
- $dataset: [],
69
- $experience: [
70
- {
71
- type: {
72
- any: ["Web Experience"],
73
- not: ["Web Experience Template"],
74
- },
75
- },
76
- ],
77
- $site: [
78
- {
79
- type: ["Hub Site Application", "Site Application"],
80
- },
81
- {
82
- type: ["Web Mapping Application"],
83
- typekeywords: ["hubSite"],
84
- },
85
- ],
86
- $initiative: [
87
- {
88
- type: {
89
- any: "Hub Initiative",
90
- not: "Hub Initiative Template",
91
- },
92
- },
93
- ],
94
- $document: [
95
- {
96
- typekeywords: {
97
- any: "Document",
98
- not: ["MapAreaPackage", "SMX"],
99
- },
100
- type: {
101
- any: [
102
- "Image",
103
- "Layout",
104
- "Desktop Style",
105
- "Project Template",
106
- "Report Template",
107
- "Pro Report",
108
- "Statistical Data Collection",
109
- "360 VR Experience",
110
- "netCDF",
111
- "PDF",
112
- "CSV",
113
- "Administrative Report",
114
- "Raster function template",
115
- ],
116
- not: [
117
- "Image Service",
118
- "Explorer Document",
119
- "Explorer Map",
120
- "Globe Document",
121
- "Scene Document",
122
- "Code Attachment",
123
- "Featured Items",
124
- "Symbol Set",
125
- "ColorSet",
126
- "Windows Viewer Add In",
127
- "Windows Viewer Configuration",
128
- "Map Area",
129
- "Indoors Map Configuration",
130
- ],
131
- },
132
- },
133
- ],
134
- };
135
- /**
136
- * @private
137
- * Convert portal search response to facets
138
- * Note: Only applicable to an item search
139
- * @param response
140
- * @returns
141
- */
142
- // TODO: Remove with _searchContent
143
- function convertPortalResponseToFacets(response, operation = "OR") {
144
- // delegate to a more future-friendly version
145
- return convertPortalItemResponseToFacets(response, operation, "filter");
146
- }
147
- exports.convertPortalResponseToFacets = convertPortalResponseToFacets;
148
- /**
149
- * @private
150
- * Convert portal search response to facets
151
- * Note: Only applicable to an item search
152
- * @param response
153
- * @returns
154
- */
155
- function convertPortalItemResponseToFacets(response, operation = "OR", optionProp = "filters" // TODO: Remove with _searchContent and use `filters`
156
- ) {
157
- var _a;
158
- // TODO: move into portalSearchItems
159
- const result = [];
160
- if ((_a = response.aggregations) === null || _a === void 0 ? void 0 : _a.counts) {
161
- response.aggregations.counts.forEach((entry) => {
162
- const facet = {
163
- label: entry.fieldName,
164
- key: entry.fieldName,
165
- aggField: entry.fieldName,
166
- display: "multi-select",
167
- };
168
- const options = [];
169
- entry.fieldValues.forEach((fv) => {
170
- const filter = {
171
- filterType: "item",
172
- };
173
- // construct the filter based on the operation
174
- const matchKey = operation === "OR" ? "any" : "all";
175
- const filterMatchOption = {};
176
- filterMatchOption[matchKey] = [fv.value];
177
- filter[entry.fieldName] = filterMatchOption;
178
- // construct the FacetOption
179
- const fo = {
180
- label: `${fv.value} (${fv.count})`,
181
- key: fv.value,
182
- count: fv.count,
183
- selected: false,
184
- };
185
- // Temporary to ensure the old fn can delegate to this
186
- // but we can still return the correct structure
187
- // TODO: Remove with _searchContent
188
- /* istanbul ignore next */
189
- if (optionProp === "filter") {
190
- fo.filter = filter;
191
- }
192
- else {
193
- fo.filters = [filter];
194
- }
195
- options.push(fo);
196
- });
197
- facet.options = options;
198
- result.push(facet);
199
- });
200
- }
201
- return result;
202
- }
203
- exports.convertPortalItemResponseToFacets = convertPortalItemResponseToFacets;
204
- /**
205
- * Merge `Filter<"content">` objects
206
- *
207
- * Useful in components which may get partial filters from a variety of
208
- * sub-components, which are then combined into a single filter prior
209
- * to executing the search.
210
- * @param filters
211
- * @returns
212
- */
213
- function mergeContentFilter(filters) {
214
- __1.Logger.warn(`DEPRECATION: mergeContentFilter will be removed and filters should not longer be merged. Work with IFilterGroups instead`);
215
- // expand all the filters so all prop types are consistent
216
- const expanded = filters.map(expandContentFilter);
217
- // now we can merge based on fields
218
- const dateFields = ["created", "modified"];
219
- const specialFields = ["filterType", "subFilters", "term", ...dateFields];
220
- const result = expanded.reduce((acc, entry) => {
221
- // process fields
222
- Object.entries(entry).forEach(([key, value]) => {
223
- if (acc.hasOwnProperty(key)) {
224
- /* istanbul ignore else */
225
- if (!specialFields.includes(key)) {
226
- acc[key] = utils_1.mergeMatchOptions(acc[key], value);
227
- }
228
- else if (dateFields.includes(key)) {
229
- acc[key] = utils_1.mergeDateRange(acc[key], value);
230
- }
231
- else if (key === "term") {
232
- acc[key] = `${acc[key]} ${value}`;
233
- }
234
- else if (key === "subFilters") {
235
- acc[key] = mergeSubFilters(acc[key], value);
236
- }
237
- }
238
- else {
239
- acc[key] = __1.cloneObject(value);
240
- }
241
- });
242
- return acc;
243
- }, {});
244
- result.filterType = "content";
245
- return result;
246
- }
247
- exports.mergeContentFilter = mergeContentFilter;
248
- function mergeSubFilters(sf1, sf2) {
249
- // Simplistic implementation: we just merge the arrays
250
- // in the future we may try to de-dupe things as a safeguard
251
- return [...sf1, ...sf2];
252
- }
253
- /**
254
- * Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
255
- *
256
- * Filter's can express their intent in a very terse form, but to ensure consistent structures
257
- * we expand them into their more verbose form.
258
- *
259
- * i.e. `title: "Water"` expands into `title: { any: ["Water"]}`
260
- *
261
- * - "well known" type values are expanded
262
- * - i.e. `type: "$storymap"` expands into two `subFilter` entries
263
- * - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
264
- * - RelativeDate fields are converted to DateRange<number>
265
- *
266
- * @param filter
267
- * @returns
268
- */
269
- function expandContentFilter(filter) {
270
- __1.Logger.warn(`DEPRECATION: expandContentFilter will be removed. Work with IFilterGroups<"item"> instead`);
271
- // Expand filter.type first
272
- const expandedTypeFilter = expandTypeField(filter);
273
- // Expand subfilters
274
- // Guard - JS Clients could send in anything...
275
- if (Array.isArray(filter.subFilters)) {
276
- // Convert any strings into the coresponding ContentFilterDefinition
277
- expandedTypeFilter.subFilters = expandedTypeFilter.subFilters.reduce((acc, entry) => {
278
- if (typeof entry === "string") {
279
- // if the entry is not a key of ContentFilterExpansions
280
- // we just skip over it
281
- if (ContentFilterExpansions[entry]) {
282
- acc = acc.concat(ContentFilterExpansions[entry]);
283
- }
284
- }
285
- else {
286
- acc.push(entry); // should be a ContentFilterDefinition
287
- }
288
- return acc;
289
- }, []);
290
- }
291
- // Convert all props into MatchOptions/DateRanges
292
- return convertContentDefinitionToFilter(expandedTypeFilter);
293
- }
294
- exports.expandContentFilter = expandContentFilter;
295
- /**
296
- * @private
297
- * Expand from a well-known "type" into it's longer form
298
- *
299
- * i.e. `type: "$storymap"` expands into two subFilters entries
300
- *
301
- * @param filter
302
- * @returns
303
- */
304
- function expandTypeField(filter) {
305
- const clone = __1.cloneObject(filter);
306
- // ensure subFilters is defined as an array
307
- clone.subFilters = clone.subFilters || [];
308
- if (clone.type) {
309
- // if .type is an Array...
310
- if (Array.isArray(clone.type)) {
311
- // remove any well-known-keys and move their expansions into subfilters
312
- clone.type = clone.type.reduce((acc, entry) => {
313
- if (isWellKnownType(entry)) {
314
- // working with dynamic objects in typescript requires some assertions
315
- const key = entry;
316
- clone.subFilters = clone.subFilters.concat(lookupTypeFilters(key));
317
- }
318
- else {
319
- acc.push(entry);
320
- }
321
- return acc;
322
- }, []);
323
- }
324
- else if (isWellKnownType(clone.type)) {
325
- const key = clone.type;
326
- clone.subFilters = clone.subFilters.concat(lookupTypeFilters(key));
327
- delete clone.type;
328
- }
329
- else {
330
- // Future?: implement "expansions" inside MatchOptions
331
- // For now, we only attempt expansions for filter.type
332
- // if it's a string, or for strings inside an array
333
- // Unclear if it's of value to allow short-cuts inside MatchOptions
334
- }
335
- }
336
- return clone;
337
- }
338
- exports.expandTypeField = expandTypeField;
339
- /**
340
- * Is the argument a well-known type "key"
341
- *
342
- * Accepts `string`, `string[]` or `IMatchOptions`
343
- * but only string values can possibly be properties
344
- * on `ContentFilterExpansions`
345
- * @param key
346
- * @returns
347
- */
348
- function isWellKnownType(key) {
349
- let result = false;
350
- if (typeof key === "string") {
351
- result = key in ContentFilterExpansions;
352
- }
353
- return result;
354
- }
355
- function lookupTypeFilters(key) {
356
- return ContentFilterExpansions[key];
357
- }
358
- /**
359
- * @private
360
- * Convert a `ContentFilterDefinition` to a `ContentFilter`
361
- *
362
- * ContentFilter is a narrower version of ContentFilterDefinition, without
363
- * the union types. Using a ContentFilter makes working with the structure
364
- * in typescript much easier.
365
- *
366
- * @param filter
367
- * @returns
368
- */
369
- function convertContentDefinitionToFilter(filter) {
370
- // TODO: Remove with _searchContent
371
- __1.Logger.warn(`DEPRECATION: convertContentDefinitionToFilter will be removed. Work with IFilterGroups<"item"> instead`);
372
- const result = {};
373
- if (filter.term) {
374
- result.term = filter.term;
375
- }
376
- const dateProps = ["created", "modified"];
377
- // Some properties should not get converted to MatchOptions
378
- const specialProps = ["filterType", "subFilters", "term", ...dateProps];
379
- // Do the conversion
380
- Object.entries(filter).forEach(([key, value]) => {
381
- if (!specialProps.includes(key)) {
382
- result[key] = utils_1.valueToMatchOptions(value);
383
- }
384
- });
385
- // Special Cases
386
- // subFilters; Array of ContentFilterDefinitions
387
- if (filter.subFilters && Array.isArray(filter.subFilters)) {
388
- // downcast - would be nice to skip this or use some other constuct
389
- const sf = filter.subFilters;
390
- result.subFilters = sf.map(convertContentDefinitionToFilter);
391
- }
392
- // Dates; Ensure they are all DateRange<number>
393
- dateProps.forEach((fld) => {
394
- if (filter[fld]) {
395
- if (filter[fld].type === "relative-date") {
396
- result[fld] = utils_1.relativeDateToDateRange(filter[fld]);
397
- }
398
- else {
399
- result[fld] = __1.cloneObject(filter[fld]);
400
- }
401
- }
402
- });
403
- return result;
404
- }
405
- exports.convertContentDefinitionToFilter = convertContentDefinitionToFilter;
406
- /**
407
- * @private
408
- * Serialize a `ContentFilter` into an `ISearchOptions` for use with `searchItems`
409
- * @param filter
410
- * @returns
411
- */
412
- function serializeContentFilterForPortal(filter) {
413
- // TODO: Remove with _searchContent
414
- __1.Logger.warn(`DEPRECATION: serializeContentFilterForPortal will be removed. Work with IFilterGroups<"item"> and hubSearch() instead`);
415
- let searchOptions = convertContentFilterToSearchOptions(filter);
416
- if (filter.subFilters) {
417
- const subFilterOptions = filter.subFilters.reduce((acc, entry) => {
418
- // Next guard is present b/c this can be used from javascript
419
- // but our tests are written in typescript which prevents us
420
- // from hitting the else
421
- /* istanbul ignore else */
422
- if (typeof entry === "object") {
423
- acc = utils_1.mergeSearchOptions(acc, convertContentFilterToSearchOptions(entry), "OR");
424
- }
425
- return acc;
426
- }, { q: "", filter: "" });
427
- // merge with searchOptions using AND
428
- searchOptions = utils_1.mergeSearchOptions(searchOptions, subFilterOptions, "AND");
429
- }
430
- // term is always last, and pre-pended on searchOptions.q
431
- if (filter.term) {
432
- searchOptions.q = `${filter.term} ${searchOptions.q}`.trim();
433
- }
434
- return searchOptions;
435
- }
436
- exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
437
- /**
438
- * @private
439
- * Convert a ContentFilter to a SearchOptions
440
- *
441
- * @param filter
442
- * @returns
443
- */
444
- function convertContentFilterToSearchOptions(filter) {
445
- // TODO: Remove with _searchContent
446
- __1.Logger.warn(`DEPRECATION: convertContentFilterToSearchOptions will be removed. Work with IFilterGroups<"item"> and hubSearch() instead`);
447
- let result = {
448
- q: "",
449
- filter: "",
450
- };
451
- const dateProps = ["created", "modified"];
452
- const specialProps = ["filterType", "subFilters", "term", ...dateProps];
453
- Object.entries(filter).forEach(([key, value]) => {
454
- // MatchOptions may go into either q or filter
455
- if (!specialProps.includes(key)) {
456
- result = utils_1.mergeSearchOptions(result, utils_1.serializeMatchOptions(key, value), "AND");
457
- }
458
- // Dates only go into q
459
- if (dateProps.includes(key)) {
460
- result = utils_1.mergeSearchOptions(result, utils_1.serializeDateRange(key, value), "AND");
461
- }
462
- });
463
- return result;
464
- }
465
- exports.convertContentFilterToSearchOptions = convertContentFilterToSearchOptions;
466
- //# sourceMappingURL=content-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content-utils.js","sourceRoot":"","sources":["../../../src/search/content-utils.ts"],"names":[],"mappings":";;;AAMA,0BAAyC;AAYzC,mCAQiB;AAEjB,mCAAmC;AAEnC,2BAA2B;AAC3B,MAAM,uBAAuB,GAA6B;IACxD,KAAK,EAAE;QACL;YACE,IAAI,EAAE;gBACJ,GAAG,EAAE;oBACH,aAAa;oBACb,yBAAyB;oBACzB,oBAAoB;oBACpB,aAAa;oBACb,8BAA8B;oBAC9B,qBAAqB;oBACrB,gBAAgB;oBAChB,WAAW;oBACX,gCAAgC;oBAChC,mBAAmB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;;;;;GAMG;AACH,SAAgB,mCAAmC,CACjD,MAAsB;IAEtB,mCAAmC;IACnC,UAAM,CAAC,IAAI,CACT,2HAA2H,CAC5H,CAAC;IACF,IAAI,MAAM,GAAG;QACX,CAAC,EAAE,EAAE;QACL,MAAM,EAAE,EAAE;KACO,CAAC;IAEpB,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACxE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC9C,8CAA8C;QAC9C,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC/B,MAAM,GAAG,0BAAkB,CACzB,MAAM,EACN,6BAAqB,CAAC,GAAG,EAAE,KAAK,CAAC,EACjC,KAAK,CACN,CAAC;SACH;QACD,uBAAuB;QACvB,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,GAAG,0BAAkB,CACzB,MAAM,EACN,0BAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,EAC9B,KAAK,CACN,CAAC;SACH;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAlCD,kFAkCC"}
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmptyFilterGroup = exports.isEmptyFilter = void 0;
4
- /**
5
- * Determine if a Filter is "empty"
6
- * @param filter
7
- * @returns
8
- */
9
- function isEmptyFilter(filter) {
10
- // if it has one property, filterType, it's empty
11
- return (Object.keys(filter).length === 1 && filter.hasOwnProperty("filterType"));
12
- }
13
- exports.isEmptyFilter = isEmptyFilter;
14
- /**
15
- * Determine if a filterGroup is "empty"
16
- * @param filterGroup
17
- * @returns
18
- */
19
- function isEmptyFilterGroup(filterGroup) {
20
- // if filters array is empty
21
- if (filterGroup.filters.length === 0) {
22
- return true;
23
- }
24
- else {
25
- // if all filters are empty
26
- const result = filterGroup.filters.reduce((acc, entry) => {
27
- if (acc) {
28
- acc = isEmptyFilter(entry);
29
- }
30
- return acc;
31
- }, true);
32
- return result;
33
- }
34
- }
35
- exports.isEmptyFilterGroup = isEmptyFilterGroup;
36
- //# sourceMappingURL=filter-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"filter-utils.js","sourceRoot":"","sources":["../../../src/search/filter-utils.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,aAAa,CAAC,MAA0B;IACtD,iDAAiD;IACjD,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CACxE,CAAC;AACJ,CAAC;AALD,sCAKC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAChC,WAAqC;IAErC,4BAA4B;IAC5B,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACpC,OAAO,IAAI,CAAC;KACb;SAAM;QACL,2BAA2B;QAC3B,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACvD,IAAI,GAAG,EAAE;gBACP,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;aAC5B;YACD,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AAhBD,gDAgBC"}
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeGroupFilterForPortal = exports.expandGroupFilter = exports.mergeGroupFilters = void 0;
4
- const _1 = require(".");
5
- const __1 = require("..");
6
- // TODO: Remove with _searchContent
7
- /**
8
- *
9
- * Merge `Filter<"group">` objects
10
- *
11
- * Useful in components which may get partial filters from a variety of
12
- * sub-components, which are then combined into a single filter prior
13
- * to executing the search.
14
- * @param filters
15
- * @returns
16
- */
17
- function mergeGroupFilters(filters) {
18
- // TODO: Remove with _searchContent
19
- __1.Logger.warn(`DEPRECATION: mergeGroupFilters will be removed. Work with IFilterGroups<"group"> and hubSearch() instead`);
20
- // expand all the filters so all prop types are consistent
21
- const expanded = filters.map(expandGroupFilter);
22
- // now we can merge based on fields
23
- const dateFields = ["created", "modified"];
24
- const specialFields = ["filterType", "term", ...dateFields];
25
- // acc is initialized as Filter<group> but also needs it
26
- // in the function signature... for reasons?!
27
- const result = expanded.reduce((acc, entry) => {
28
- // process fields
29
- Object.entries(entry).forEach(([key, value]) => {
30
- // Note: getProp/setProp are used to get around
31
- // typescript issues with string indexing
32
- if (acc.hasOwnProperty(key)) {
33
- const existingValue = __1.getProp(acc, key);
34
- // if the key is not to a special field
35
- if (!specialFields.includes(key)) {
36
- // treat as an IMatchOptions
37
- __1.setProp(key, _1.mergeMatchOptions(existingValue, value), acc);
38
- }
39
- else if (dateFields.includes(key)) {
40
- // treat as IDateRange
41
- __1.setProp(key, _1.mergeDateRange(existingValue, value), acc);
42
- }
43
- else if (key === "term") {
44
- // append terms
45
- acc[key] = `${acc[key]} ${value}`;
46
- }
47
- }
48
- else {
49
- // Acc does not have an entry for this yet
50
- // so just clone it
51
- __1.setProp(key, __1.cloneObject(value), acc);
52
- }
53
- });
54
- return acc;
55
- }, {
56
- filterType: "group",
57
- });
58
- return result;
59
- }
60
- exports.mergeGroupFilters = mergeGroupFilters;
61
- /**
62
- * Prior to serialization into the query syntax for the backing APIs, we first expand [Filters](../Filter)
63
- *
64
- * Filter's can express their intent in a very terse form, but to ensure consistent structures
65
- * we expand them into their more verbose form.
66
- *
67
- * i.e. `title: "Water"` expands into `title: { any: ["Water"]}`
68
- *
69
- * - Fields defined as `string | string[] | MatchOptions` will be converted to a `MatchOptions`
70
- * - RelativeDate fields are converted to DateRange<number>
71
- *
72
- * @param filter
73
- * @returns
74
- */
75
- function expandGroupFilter(filter) {
76
- // TODO: Remove with _searchContent
77
- __1.Logger.warn(`DEPRECATION: expandGroupFilters will be removed. Work with IFilterGroups<"group"> and hubSearch() instead`);
78
- const result = {};
79
- const dateProps = ["created", "modified"];
80
- // Some properties should not get converted to MatchOptions
81
- const specialProps = ["term", "searchUserAccess", ...dateProps];
82
- // Do the conversion
83
- Object.entries(filter).forEach(([key, value]) => {
84
- // handle Matchish fields
85
- if (!specialProps.includes(key)) {
86
- // setProp side-steps typescript complaining
87
- __1.setProp(key, _1.valueToMatchOptions(value), result);
88
- }
89
- // Handle date fields
90
- if (dateProps.includes(key)) {
91
- const dateFieldValue = __1.cloneObject(__1.getProp(filter, key));
92
- if (__1.getProp(filter, `${key}.type`) === "relative-date") {
93
- __1.setProp(key, _1.relativeDateToDateRange(dateFieldValue), result);
94
- }
95
- else {
96
- __1.setProp(key, dateFieldValue, result);
97
- }
98
- }
99
- });
100
- // searchUserAccess is boolean, so we check if the prop exists
101
- // vs checking if the value is truthy
102
- if (filter.hasOwnProperty("searchUserAccess")) {
103
- result.searchUserAccess = filter.searchUserAccess;
104
- }
105
- if (filter.term) {
106
- result.term = filter.term;
107
- }
108
- return result;
109
- }
110
- exports.expandGroupFilter = expandGroupFilter;
111
- /**
112
- * @private
113
- * Serialize an `IGroupFilterDefinition` into an `ISearchOptions` for use
114
- * with `searchGroups`
115
- * @param filter
116
- * @returns
117
- */
118
- function serializeGroupFilterForPortal(filter) {
119
- // TODO: Remove with _searchContent
120
- __1.Logger.warn(`DEPRECATION: serializeGroupFilterForPortal will be removed. Work with IFilterGroups<"group"> and hubSearch() instead`);
121
- let result = {
122
- q: "",
123
- filter: "",
124
- };
125
- const dateProps = ["created", "modified"];
126
- const specialProps = ["term", "searchUserAccess", "filterType", ...dateProps];
127
- Object.entries(filter).forEach(([key, value]) => {
128
- // MatchOptions fields
129
- if (!specialProps.includes(key)) {
130
- result = _1.mergeSearchOptions(result, _1.serializeMatchOptions(key, value), "AND");
131
- }
132
- // Dates only go into q
133
- if (dateProps.includes(key)) {
134
- result = _1.mergeSearchOptions(result, _1.serializeDateRange(key, value), "AND");
135
- }
136
- });
137
- // searchUserAccess is also a top-level property
138
- if (filter.hasOwnProperty("searchUserAccess")) {
139
- result.searchUserAccess = filter.searchUserAccess;
140
- }
141
- // add the term
142
- if (filter.term) {
143
- result.q = `${filter.term} ${result.q}`.trim();
144
- }
145
- return result;
146
- }
147
- exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
148
- //# sourceMappingURL=group-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"group-utils.js","sourceRoot":"","sources":["../../../src/search/group-utils.ts"],"names":[],"mappings":";;;AACA,wBAUW;AACX,0BAA2D;AAE3D,mCAAmC;AAEnC;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAC/B,OAA+B;IAE/B,mCAAmC;IACnC,UAAM,CAAC,IAAI,CACT,0GAA0G,CAC3G,CAAC;IACF,0DAA0D;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAChD,mCAAmC;IACnC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC;IAE5D,wDAAwD;IACxD,6CAA6C;IAC7C,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAC5B,CAAC,GAAoB,EAAE,KAAK,EAAE,EAAE;QAC9B,iBAAiB;QACjB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC7C,+CAA+C;YAC/C,yCAAyC;YAEzC,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG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