@zengenti/contensis-react-base 3.0.0-beta.6 → 3.0.0-beta.60

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 (164) hide show
  1. package/README.md +4 -4
  2. package/cjs/{App-3324f784.js → App-36c7bf3a.js} +124 -140
  3. package/cjs/App-36c7bf3a.js.map +1 -0
  4. package/cjs/{RouteLoader-c7957b14.js → RouteLoader-ece762dc.js} +31 -23
  5. package/cjs/RouteLoader-ece762dc.js.map +1 -0
  6. package/cjs/ToJs-09204afd.js +129 -0
  7. package/cjs/ToJs-09204afd.js.map +1 -0
  8. package/cjs/VersionInfo-df35c917.js +181 -0
  9. package/cjs/VersionInfo-df35c917.js.map +1 -0
  10. package/cjs/{actions-a24bf46e.js → actions-6b9ef168.js} +5 -4
  11. package/cjs/actions-6b9ef168.js.map +1 -0
  12. package/cjs/client.js +16 -21
  13. package/cjs/client.js.map +1 -1
  14. package/cjs/contensis-react-base.js +3583 -38
  15. package/cjs/contensis-react-base.js.map +1 -1
  16. package/cjs/forms.js +4114 -195
  17. package/cjs/forms.js.map +1 -1
  18. package/cjs/{fromJSLeaveImmer-c00d597f.js → fromJSLeaveImmer-e74c673c.js} +2 -16
  19. package/cjs/fromJSLeaveImmer-e74c673c.js.map +1 -0
  20. package/cjs/{login-c810cc4c.js → login-d67b82aa.js} +92 -55
  21. package/cjs/login-d67b82aa.js.map +1 -0
  22. package/cjs/{reducers-fde41d6b.js → reducers-3a4f8971.js} +26 -25
  23. package/cjs/reducers-3a4f8971.js.map +1 -0
  24. package/cjs/redux.js +6 -5
  25. package/cjs/redux.js.map +1 -1
  26. package/cjs/routing.js +5 -4
  27. package/cjs/routing.js.map +1 -1
  28. package/cjs/sagas-8cf21563.js +2038 -0
  29. package/cjs/sagas-8cf21563.js.map +1 -0
  30. package/cjs/search.js +280 -1907
  31. package/cjs/search.js.map +1 -1
  32. package/cjs/{selectors-0ec95076.js → selectors-2c1b1183.js} +7 -3
  33. package/cjs/selectors-2c1b1183.js.map +1 -0
  34. package/cjs/user.js +21 -12
  35. package/cjs/user.js.map +1 -1
  36. package/cjs/util.js +55 -212
  37. package/cjs/util.js.map +1 -1
  38. package/cjs/{version-4f0f5fa6.js → version-ca4173a8.js} +28 -20
  39. package/cjs/version-ca4173a8.js.map +1 -0
  40. package/cjs/{version-085d203d.js → version-dcfdafd9.js} +5 -5
  41. package/cjs/version-dcfdafd9.js.map +1 -0
  42. package/esm/{App-1b05ab11.js → App-61bf1832.js} +124 -141
  43. package/esm/App-61bf1832.js.map +1 -0
  44. package/esm/{RouteLoader-e5f0e8cb.js → RouteLoader-7749ad3f.js} +31 -23
  45. package/esm/RouteLoader-7749ad3f.js.map +1 -0
  46. package/esm/ToJs-2627ce21.js +99 -0
  47. package/esm/ToJs-2627ce21.js.map +1 -0
  48. package/esm/VersionInfo-add96cdb.js +172 -0
  49. package/esm/VersionInfo-add96cdb.js.map +1 -0
  50. package/esm/{actions-927d9698.js → actions-5437f43d.js} +5 -4
  51. package/esm/actions-5437f43d.js.map +1 -0
  52. package/esm/client.js +17 -22
  53. package/esm/client.js.map +1 -1
  54. package/esm/contensis-react-base.js +3581 -37
  55. package/esm/contensis-react-base.js.map +1 -1
  56. package/esm/forms.js +4114 -198
  57. package/esm/forms.js.map +1 -1
  58. package/esm/{fromJSLeaveImmer-392af4e3.js → fromJSLeaveImmer-0114ffcf.js} +2 -16
  59. package/esm/fromJSLeaveImmer-0114ffcf.js.map +1 -0
  60. package/esm/{login-f8ba3aeb.js → login-f6dfbe1b.js} +92 -55
  61. package/esm/login-f6dfbe1b.js.map +1 -0
  62. package/esm/{reducers-d6c0edb1.js → reducers-8e5d6232.js} +26 -25
  63. package/esm/reducers-8e5d6232.js.map +1 -0
  64. package/esm/redux.js +8 -7
  65. package/esm/redux.js.map +1 -1
  66. package/esm/routing.js +5 -4
  67. package/esm/routing.js.map +1 -1
  68. package/esm/sagas-a22fc54a.js +1952 -0
  69. package/esm/sagas-a22fc54a.js.map +1 -0
  70. package/esm/search.js +240 -1848
  71. package/esm/search.js.map +1 -1
  72. package/esm/{selectors-b98d5c76.js → selectors-65f0f31c.js} +7 -4
  73. package/esm/selectors-65f0f31c.js.map +1 -0
  74. package/esm/user.js +23 -14
  75. package/esm/user.js.map +1 -1
  76. package/esm/util.js +54 -209
  77. package/esm/util.js.map +1 -1
  78. package/esm/{version-16aa83eb.js → version-1d46bde8.js} +27 -20
  79. package/esm/version-1d46bde8.js.map +1 -0
  80. package/esm/version-696796d7.js +15 -0
  81. package/esm/version-696796d7.js.map +1 -0
  82. package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
  83. package/models/forms/index.d.ts +2 -0
  84. package/models/index.d.ts +1 -0
  85. package/models/redux/appstate.d.ts +5 -10
  86. package/models/redux/selectors/navigation.d.ts +2 -1
  87. package/models/routing/components/RouteLoader.d.ts +2 -19
  88. package/models/routing/redux/actions.d.ts +1 -1
  89. package/models/routing/redux/selectors.d.ts +1 -1
  90. package/models/routing/routes.d.ts +3 -2
  91. package/models/routing/util/expressions.d.ts +3 -2
  92. package/models/routing/util/queries.d.ts +1 -1
  93. package/models/search/containers/withListing.d.ts +1 -1
  94. package/models/search/containers/withSearch.d.ts +1 -1
  95. package/models/search/hooks/useFacets.hook.d.ts +3 -0
  96. package/models/search/hooks/useListing.hook.d.ts +3 -0
  97. package/models/search/hooks/useMinilist.hook.d.ts +2 -9
  98. package/models/search/index.d.ts +4 -1
  99. package/models/search/models/Queries.d.ts +8 -5
  100. package/models/search/models/Search.d.ts +60 -28
  101. package/models/search/models/SearchActions.d.ts +4 -3
  102. package/models/search/models/SearchProps.d.ts +52 -7
  103. package/models/search/models/SearchState.d.ts +5 -1
  104. package/models/search/models/index.d.ts +3 -1
  105. package/models/search/redux/actions.d.ts +2 -1
  106. package/models/search/redux/reducers.d.ts +230 -314
  107. package/models/search/redux/sagas.d.ts +5 -5
  108. package/models/search/redux/selectors.d.ts +19 -22
  109. package/models/search/search/ContensisDeliveryApi.d.ts +1 -0
  110. package/models/search/search/expressions.d.ts +3 -6
  111. package/models/search/{redux → search}/queries.d.ts +0 -0
  112. package/models/search/transformations/entry-to-filteritem.mapper.d.ts +2 -1
  113. package/models/search/transformations/filter-to-filterexpression.mapper.d.ts +6 -0
  114. package/models/search/transformations/filters-to-filterexpressions.mapper.d.ts +3 -0
  115. package/models/search/transformations/index.d.ts +3 -0
  116. package/models/search/transformations/queryParams-to-customapi.mapper.d.ts +3 -0
  117. package/models/search/transformations/state-to-searchuri.d.ts +2 -13
  118. package/models/server/features/linkdepth-api/api.d.ts +12 -0
  119. package/models/server/features/linkdepth-api/events-api.config.d.ts +37 -0
  120. package/models/server/middleware/bundleManipulation.d.ts +2 -1
  121. package/models/server/util/headers.d.ts +3 -2
  122. package/models/user/components/Login.d.ts +1 -2
  123. package/models/user/components/LoginForm.d.ts +1 -2
  124. package/models/user/hocs/withLogin.d.ts +4 -2
  125. package/models/user/hocs/withRegistration.d.ts +4 -2
  126. package/models/user/hooks/useChangePassword.d.ts +5 -5
  127. package/models/user/hooks/useForgotPassword.d.ts +6 -6
  128. package/models/user/hooks/useLogin.d.ts +9 -45
  129. package/models/user/hooks/useRegistration.d.ts +4 -4
  130. package/models/user/redux/reducers.d.ts +4 -5
  131. package/models/user/redux/sagas/login.d.ts +11 -8
  132. package/models/user/redux/selectors.d.ts +33 -71
  133. package/models/user/util/LoginHelper.class.d.ts +4 -3
  134. package/models/util/ContensisDeliveryApi.d.ts +1 -3
  135. package/models/util/json-mapper.d.ts +9 -3
  136. package/models/util/merge.d.ts +1 -0
  137. package/package-lock.json +2690 -3400
  138. package/package.json +60 -55
  139. package/cjs/App-3324f784.js.map +0 -1
  140. package/cjs/RouteLoader-c7957b14.js.map +0 -1
  141. package/cjs/ToJs-a38fa20e.js +0 -230
  142. package/cjs/ToJs-a38fa20e.js.map +0 -1
  143. package/cjs/actions-a24bf46e.js.map +0 -1
  144. package/cjs/fromJSLeaveImmer-c00d597f.js.map +0 -1
  145. package/cjs/login-c810cc4c.js.map +0 -1
  146. package/cjs/reducers-fde41d6b.js.map +0 -1
  147. package/cjs/selectors-0ec95076.js.map +0 -1
  148. package/cjs/version-085d203d.js.map +0 -1
  149. package/cjs/version-4f0f5fa6.js.map +0 -1
  150. package/esm/App-1b05ab11.js.map +0 -1
  151. package/esm/RouteLoader-e5f0e8cb.js.map +0 -1
  152. package/esm/ToJs-879a5a85.js +0 -199
  153. package/esm/ToJs-879a5a85.js.map +0 -1
  154. package/esm/actions-927d9698.js.map +0 -1
  155. package/esm/fromJSLeaveImmer-392af4e3.js.map +0 -1
  156. package/esm/login-f8ba3aeb.js.map +0 -1
  157. package/esm/reducers-d6c0edb1.js.map +0 -1
  158. package/esm/selectors-b98d5c76.js.map +0 -1
  159. package/esm/version-16aa83eb.js.map +0 -1
  160. package/esm/version-3833e8b5.js +0 -15
  161. package/esm/version-3833e8b5.js.map +0 -1
  162. package/models/search/transformations/filters-to-filterexpression.d.ts +0 -1
  163. package/models/search/transformations/filters-to-filterexpression.mapper.d.ts +0 -2
  164. package/models/server/features/caching/cacheHashing.d.ts +0 -1
@@ -0,0 +1,1952 @@
1
+ import * as log from 'loglevel';
2
+ import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
3
+ import { Client } from 'contensis-delivery-api';
4
+ import { stringify, parse } from 'query-string';
5
+ import mapJson, { jpath } from 'jsonpath-mapper';
6
+ import { Op, OrderBy, Query } from 'contensis-core-api';
7
+ import merge from 'deepmerge';
8
+
9
+ const ACTION_PREFIX = '@SEARCH/';
10
+ const APPLY_CONFIG = `${ACTION_PREFIX}APPLY_CONFIG`;
11
+ const CLEAR_FILTERS = `${ACTION_PREFIX}CLEAR_FILTERS`;
12
+ const DO_SEARCH = `${ACTION_PREFIX}DO_SEARCH`;
13
+ const EXECUTE_SEARCH = `${ACTION_PREFIX}EXECUTE_SEARCH`;
14
+ const EXECUTE_SEARCH_ERROR = `${ACTION_PREFIX}EXECUTE_SEARCH_ERROR`;
15
+ const EXECUTE_SEARCH_PRELOAD = `${ACTION_PREFIX}EXECUTE_SEARCH_PRELOAD`;
16
+ const LOAD_FILTERS = `${ACTION_PREFIX}LOAD_FILTERS`;
17
+ const LOAD_FILTERS_COMPLETE = `${ACTION_PREFIX}LOAD_FILTERS_COMPLETE`;
18
+ const LOAD_FILTERS_ERROR = `${ACTION_PREFIX}LOAD_FILTERS_ERROR`;
19
+ const SET_FEATURED_ENTRIES = `${ACTION_PREFIX}SET_FEATURED_ENTRIES`;
20
+ const SET_ROUTE_FILTERS = `${ACTION_PREFIX}SET_ROUTE_FILTERS`;
21
+ const SET_SEARCH_FILTERS = `${ACTION_PREFIX}SET_SEARCH_FILTERS`;
22
+ const SET_SEARCH_ENTRIES = `${ACTION_PREFIX}SET_SEARCH_ENTRIES`;
23
+ const SET_SELECTED_FILTER = `${ACTION_PREFIX}SET_SELECTED_FILTER`;
24
+ const UPDATE_CURRENT_FACET = `${ACTION_PREFIX}UPDATE_CURRENT_FACET`;
25
+ const UPDATE_CURRENT_TAB = `${ACTION_PREFIX}UPDATE_CURRENT_TAB`;
26
+ const UPDATE_SORT_ORDER = `${ACTION_PREFIX}UPDATE_SORT_ORDER`;
27
+ const UPDATE_PAGE_INDEX = `${ACTION_PREFIX}UPDATE_PAGE_INDEX`;
28
+ const UPDATE_SEARCH_TERM = `${ACTION_PREFIX}UPDATE_SEARCH_TERM`;
29
+ const UPDATE_SELECTED_FILTERS = `${ACTION_PREFIX}UPDATE_SELECTED_FILTERS`;
30
+
31
+ var types = /*#__PURE__*/Object.freeze({
32
+ __proto__: null,
33
+ APPLY_CONFIG: APPLY_CONFIG,
34
+ CLEAR_FILTERS: CLEAR_FILTERS,
35
+ DO_SEARCH: DO_SEARCH,
36
+ EXECUTE_SEARCH: EXECUTE_SEARCH,
37
+ EXECUTE_SEARCH_ERROR: EXECUTE_SEARCH_ERROR,
38
+ EXECUTE_SEARCH_PRELOAD: EXECUTE_SEARCH_PRELOAD,
39
+ LOAD_FILTERS: LOAD_FILTERS,
40
+ LOAD_FILTERS_COMPLETE: LOAD_FILTERS_COMPLETE,
41
+ LOAD_FILTERS_ERROR: LOAD_FILTERS_ERROR,
42
+ SET_FEATURED_ENTRIES: SET_FEATURED_ENTRIES,
43
+ SET_ROUTE_FILTERS: SET_ROUTE_FILTERS,
44
+ SET_SEARCH_FILTERS: SET_SEARCH_FILTERS,
45
+ SET_SEARCH_ENTRIES: SET_SEARCH_ENTRIES,
46
+ SET_SELECTED_FILTER: SET_SELECTED_FILTER,
47
+ UPDATE_CURRENT_FACET: UPDATE_CURRENT_FACET,
48
+ UPDATE_CURRENT_TAB: UPDATE_CURRENT_TAB,
49
+ UPDATE_SORT_ORDER: UPDATE_SORT_ORDER,
50
+ UPDATE_PAGE_INDEX: UPDATE_PAGE_INDEX,
51
+ UPDATE_SEARCH_TERM: UPDATE_SEARCH_TERM,
52
+ UPDATE_SELECTED_FILTERS: UPDATE_SELECTED_FILTERS
53
+ });
54
+
55
+ const withMappers = (action, mappers) => {
56
+ return { ...action,
57
+ mappers
58
+ };
59
+ }; // export const withMappers2 = (actionFunc, args, mappers) => {
60
+ // return () => ({ ...actionFunc(args), mappers });
61
+ // };
62
+
63
+ const triggerSearch = ({
64
+ config,
65
+ context,
66
+ debug,
67
+ defaultLang,
68
+ excludeIds,
69
+ facet,
70
+ mapper,
71
+ params
72
+ }) => {
73
+ return {
74
+ type: DO_SEARCH,
75
+ config,
76
+ context,
77
+ debug,
78
+ defaultLang,
79
+ excludeIds,
80
+ facet,
81
+ mapper,
82
+ params
83
+ };
84
+ };
85
+ const initListing = ({
86
+ context,
87
+ facet,
88
+ mapper,
89
+ params
90
+ }) => {
91
+ return {
92
+ type: SET_ROUTE_FILTERS,
93
+ context,
94
+ facet,
95
+ mapper,
96
+ params
97
+ };
98
+ };
99
+ const navigate = (path, state) => {
100
+ return {
101
+ type: '@ROUTING/_SET_ROUTE',
102
+ path,
103
+ state
104
+ };
105
+ };
106
+ const clearFilters$1 = () => {
107
+ return {
108
+ type: CLEAR_FILTERS
109
+ };
110
+ };
111
+ const updatePageIndex$1 = pageIndex => {
112
+ return {
113
+ type: UPDATE_PAGE_INDEX,
114
+ pageIndex
115
+ };
116
+ };
117
+ const updateCurrentFacet$1 = facet => {
118
+ return {
119
+ type: UPDATE_CURRENT_FACET,
120
+ facet
121
+ };
122
+ };
123
+ const updateCurrentTab$1 = id => {
124
+ return {
125
+ type: UPDATE_CURRENT_TAB,
126
+ id
127
+ };
128
+ };
129
+ const updateSearchTerm$1 = term => {
130
+ return {
131
+ type: UPDATE_SEARCH_TERM,
132
+ term
133
+ };
134
+ };
135
+ const updateSelectedFilters = (filter, key, isUnknownItem = false) => {
136
+ return {
137
+ type: UPDATE_SELECTED_FILTERS,
138
+ filter,
139
+ key,
140
+ isUnknownItem
141
+ };
142
+ };
143
+ const updateSortOrder$1 = (orderBy, facet) => {
144
+ return {
145
+ type: UPDATE_SORT_ORDER,
146
+ orderBy,
147
+ facet
148
+ };
149
+ };
150
+
151
+ var actions = /*#__PURE__*/Object.freeze({
152
+ __proto__: null,
153
+ withMappers: withMappers,
154
+ triggerSearch: triggerSearch,
155
+ initListing: initListing,
156
+ navigate: navigate,
157
+ clearFilters: clearFilters$1,
158
+ updatePageIndex: updatePageIndex$1,
159
+ updateCurrentFacet: updateCurrentFacet$1,
160
+ updateCurrentTab: updateCurrentTab$1,
161
+ updateSearchTerm: updateSearchTerm$1,
162
+ updateSelectedFilters: updateSelectedFilters,
163
+ updateSortOrder: updateSortOrder$1
164
+ });
165
+
166
+ let Context; // export type Context = 'facets' | 'listings' | 'minilist';
167
+
168
+ (function (Context) {
169
+ Context["facets"] = "facets";
170
+ Context["listings"] = "listings";
171
+ Context["minilist"] = "minilist";
172
+ })(Context || (Context = {}));
173
+
174
+ // or replace with a stub function for non-immutable gets
175
+
176
+ const makeFromJS = (returnType = globalThis.STATE_TYPE || 'immutable') => {
177
+ var _immutable, _immutable2;
178
+
179
+ return returnType === 'immutable' ? ((_immutable = globalThis.immutable) === null || _immutable === void 0 ? void 0 : _immutable.fromJSOrdered) || ((_immutable2 = globalThis.immutable) === null || _immutable2 === void 0 ? void 0 : _immutable2.fromJS) || (v => v) : v => v;
180
+ };
181
+
182
+ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThis.STATE_TYPE || 'immutable') => {
183
+ // Find a fromJS function from global that is dynamically loaded in createStore
184
+ // or replace with a stub function for non-immutable gets
185
+ const fromJS = makeFromJS(returnType);
186
+
187
+ if (state && 'get' in state && typeof state.get === 'function' && 'getIn' in state && typeof state.getIn === 'function' && 'toJS' in state && typeof state.toJS === 'function') {
188
+ if (Array.isArray(stateKey)) return fromJS(state.getIn(stateKey, fallbackValue));
189
+ return fromJS(state.get(stateKey, fallbackValue));
190
+ }
191
+
192
+ if (Array.isArray(stateKey) && state && typeof state === 'object') {
193
+ const result = jpath(stateKey.join('.'), state);
194
+ if (typeof result === 'undefined') return fallbackValue;
195
+ return result;
196
+ }
197
+
198
+ const result = state && typeof state === 'object' ? state[stateKey] : undefined;
199
+ if (typeof result === 'undefined') return fallbackValue;
200
+ return result;
201
+ };
202
+
203
+ const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context.facets);
204
+ const getCurrent = (state, context = Context.facets) => context === Context.facets ? getCurrentFacet(state) : getCurrentListing(state);
205
+ const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
206
+ const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
207
+ const getCurrentTab = state => getImmutableOrJS(state, ['search', Context.facets, getCurrentFacet(state), 'tabId'], 0);
208
+ const getFacets = (state, returnType) => getImmutableOrJS(state, ['search', Context.facets], {}, returnType);
209
+ const getTabFacets = state => Object.fromEntries(Object.entries(getFacets(state, 'js')).filter(([key]) => getImmutableOrJS(getFacets(state), [key, 'tabId'], 0) === getCurrentTab(state)));
210
+ const getFacetTitles = state => Object.entries(getFacets(state, 'js')).map(([key, facet = {}]) => {
211
+ var _facet$pagingInfo;
212
+
213
+ return {
214
+ isSelected: getCurrentFacet(state) === key,
215
+ key,
216
+ title: facet.title,
217
+ totalCount: (_facet$pagingInfo = facet.pagingInfo) === null || _facet$pagingInfo === void 0 ? void 0 : _facet$pagingInfo.totalCount
218
+ };
219
+ });
220
+ const getFacet = (state, facetName = '', context = Context.facets, returnType) => {
221
+ const currentFacet = facetName || getCurrentFacet(state);
222
+ return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
223
+ };
224
+ const getListing = (state, listing = '') => {
225
+ const currentListing = listing || getCurrentListing(state);
226
+ return getImmutableOrJS(state, ['search', Context.listings, currentListing], {});
227
+ };
228
+ const getFilters = (state, facet, context = Context.facets, returnType) => {
229
+ return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
230
+ };
231
+ const getRenderableFilters = (state, facet = '', context = Context.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
232
+ const getFiltersToLoad = (state, facet, context = Context.facets, returnType) => {
233
+ const filters = getFilters(state, facet, context, returnType);
234
+ const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
235
+ const title = i === null || i === void 0 ? void 0 : i.title;
236
+ return typeof title !== 'undefined' && !!title;
237
+ }).length > 0 && (f.isError || false) === false]);
238
+ return loadedFilters.map(([filterKey, isLoaded]) => !isLoaded ? filterKey : null).filter(f => !!f);
239
+ }; // We lowercase the filter key unless it's an ISO date string where the T must be uppercase
240
+
241
+ const getSelectedFilters = (state, facet = '', context = Context.facets, returnType) => {
242
+ const filters = getFilters(state, facet, context, 'js');
243
+ const isoDateRegex = RegExp(/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d/);
244
+ const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
245
+ const key = (item === null || item === void 0 ? void 0 : item.key) || '';
246
+ const isIsoDate = isoDateRegex.test(key);
247
+ return isIsoDate ? key : typeof key.toLowerCase !== 'undefined' ? key.toLowerCase() : key;
248
+ })]));
249
+ const fromJS = makeFromJS(returnType);
250
+ return fromJS(selectedFilters);
251
+ };
252
+ const getResults = (state, current = '', context = Context.facets, returnType) => {
253
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
254
+ };
255
+ const getIsInternalPaging = (state, current, context = Context.facets) => {
256
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
257
+ };
258
+ const getIsLoaded = (state, context = Context.facets, facet) => {
259
+ return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
260
+ };
261
+ const getIsLoading = (state, context = Context.facets, facet) => {
262
+ return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
263
+ };
264
+ const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
265
+ const getFeaturedResults = (state, current = '', context = Context.facets, returnType) => {
266
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], [], returnType);
267
+ };
268
+ const getPaging = (state, current = '', context = Context.facets, returnType) => {
269
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
270
+ };
271
+ const getPageIndex = (state, current = '', context = Context.facets) => {
272
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
273
+ };
274
+ const getPrevPageIndex = (state, current = '', context = Context.facets) => {
275
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
276
+ };
277
+ const getPageIsLoading = (state, current = '', context = Context.facets) => {
278
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
279
+ };
280
+ const getPagesLoaded = (state, current = '', context = Context.facets) => {
281
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
282
+ };
283
+ const getTotalCount = (state, current = '', context = Context.facets) => {
284
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
285
+ };
286
+ const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
287
+ const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
288
+ const getQueryParams = (state, current = '', context = Context.facets) => {
289
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
290
+ };
291
+ const getQueryParameter = ({
292
+ state,
293
+ facet,
294
+ context = Context.facets
295
+ }, key, ifnull = null) => {
296
+ return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
297
+ };
298
+ const getCustomApi = (state, current, context = Context.facets, returnType) => {
299
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
300
+ };
301
+ const getCustomEnv = (state, current, context = Context.facets) => {
302
+ return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
303
+ };
304
+ const getTabsAndFacets = (state, returnType) => {
305
+ const tabs = getSearchTabs(state, 'js');
306
+ const facets = getFacets(state, 'js');
307
+ const tabsAndFacets = (tabs || []).map((tab = {}) => {
308
+ const fieldsToCount = tab.totalCount;
309
+ let countFields;
310
+ if (typeof fieldsToCount === 'string') countFields = [[fieldsToCount]];
311
+ const thisTabFacets = Object.entries(facets).filter(([key]) => getImmutableOrJS(facets, [key, 'tabId'], 0) === tab.id);
312
+ const thisTabTotal = thisTabFacets.map(([facetName, facet = {}]) => {
313
+ if (!countFields || countFields.find((f = []) => (f === null || f === void 0 ? void 0 : f[0]) === facetName)) return getImmutableOrJS(facet, ['pagingInfo', 'totalCount']);
314
+ return 0;
315
+ }).reduce((a, b) => a + b, 0);
316
+ return { ...tab,
317
+ [Context.facets]: Object.fromEntries(thisTabFacets),
318
+ totalCount: thisTabTotal
319
+ };
320
+ });
321
+ const fromJS = makeFromJS(returnType);
322
+ return fromJS(tabsAndFacets);
323
+ };
324
+ const getSearchTotalCount = state => {
325
+ const tabsAndFacets = getTabsAndFacets(state, 'js');
326
+ const wholeSearchTotal = tabsAndFacets.map((t = {}) => t.totalCount).reduce((a, b) => a + b, 0);
327
+ return wholeSearchTotal;
328
+ };
329
+ const getFacetsTotalCount = state => {
330
+ const facets = getFacets(state);
331
+ const wholeSearchTotal = Object.entries(facets).map(([, t = {}]) => {
332
+ var _t$pagingInfo;
333
+
334
+ return ((_t$pagingInfo = t.pagingInfo) === null || _t$pagingInfo === void 0 ? void 0 : _t$pagingInfo.totalCount) || 0;
335
+ }).reduce((a, b) => a + b, 0);
336
+ return wholeSearchTotal;
337
+ }; // An exported copy of the relevant selectors scoped by default to a facets context
338
+
339
+ const selectFacets = {
340
+ getCurrent: getCurrentFacet,
341
+ getCurrentTab,
342
+ getCustomApi,
343
+ getCustomEnv,
344
+ getFacet,
345
+ getFacetTitles,
346
+ getFacets,
347
+ getFacetsTotalCount,
348
+ getFeaturedResults,
349
+ getFilters,
350
+ getFiltersToLoad,
351
+ getIsLoaded,
352
+ getIsLoading,
353
+ getPageIndex,
354
+ getPageIsLoading,
355
+ getPagesLoaded,
356
+ getPaging,
357
+ getQueryParams: (state, facet) => getQueryParams(state, facet, Context.facets),
358
+ getQueryParameter: ({
359
+ state,
360
+ facet
361
+ }, key, ifnull) => getQueryParameter({
362
+ state,
363
+ facet,
364
+ context: Context.facets
365
+ }, key, ifnull),
366
+ getRenderableFilters,
367
+ getResults,
368
+ getTabFacets,
369
+ getTabsAndFacets,
370
+ getTotalCount,
371
+ getSearchTabs,
372
+ getSearchTerm,
373
+ getSearchTotalCount,
374
+ getSelectedFilters
375
+ }; // An exported copy of the relevant selectors pre-scoped to a listing context
376
+
377
+ const selectListing = {
378
+ getCurrent: getCurrentListing,
379
+ getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context.listings, 'js'),
380
+ getFilters: (state, listing = '') => getFilters(state, listing, Context.listings, 'js'),
381
+ getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context.listings),
382
+ getListing,
383
+ getIsLoaded: state => getIsLoaded(state, Context.listings),
384
+ getIsLoading: state => getIsLoading(state, Context.listings),
385
+ getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context.listings),
386
+ getPaging: (state, listing = '') => getPaging(state, listing, Context.listings, 'js'),
387
+ getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context.listings),
388
+ getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context.listings),
389
+ getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context.listings),
390
+ getQueryParameter: ({
391
+ state,
392
+ facet
393
+ }, key, ifnull) => getQueryParameter({
394
+ state,
395
+ facet,
396
+ context: Context.listings
397
+ }, key, ifnull),
398
+ getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context.listings),
399
+ getResults: (state, listing = '') => getResults(state, listing, Context.listings, 'js'),
400
+ getSearchTerm,
401
+ getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context.listings),
402
+ getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context.listings, 'js')
403
+ };
404
+ const selectCurrentPath = state => getImmutableOrJS(state, ['routing', 'currentPath']);
405
+ const selectCurrentProject = state => getImmutableOrJS(state, ['routing', 'currentProject']);
406
+ const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'contensisVersionStatus']);
407
+
408
+ var selectors = /*#__PURE__*/Object.freeze({
409
+ __proto__: null,
410
+ getSearchContext: getSearchContext,
411
+ getCurrent: getCurrent,
412
+ getCurrentFacet: getCurrentFacet,
413
+ getCurrentListing: getCurrentListing,
414
+ getCurrentTab: getCurrentTab,
415
+ getFacets: getFacets,
416
+ getTabFacets: getTabFacets,
417
+ getFacetTitles: getFacetTitles,
418
+ getFacet: getFacet,
419
+ getListing: getListing,
420
+ getFilters: getFilters,
421
+ getRenderableFilters: getRenderableFilters,
422
+ getFiltersToLoad: getFiltersToLoad,
423
+ getSelectedFilters: getSelectedFilters,
424
+ getResults: getResults,
425
+ getIsInternalPaging: getIsInternalPaging,
426
+ getIsLoaded: getIsLoaded,
427
+ getIsLoading: getIsLoading,
428
+ getIsSsr: getIsSsr,
429
+ getFeaturedResults: getFeaturedResults,
430
+ getPaging: getPaging,
431
+ getPageIndex: getPageIndex,
432
+ getPrevPageIndex: getPrevPageIndex,
433
+ getPageIsLoading: getPageIsLoading,
434
+ getPagesLoaded: getPagesLoaded,
435
+ getTotalCount: getTotalCount,
436
+ getSearchTerm: getSearchTerm,
437
+ getSearchTabs: getSearchTabs,
438
+ getQueryParams: getQueryParams,
439
+ getQueryParameter: getQueryParameter,
440
+ getCustomApi: getCustomApi,
441
+ getCustomEnv: getCustomEnv,
442
+ getTabsAndFacets: getTabsAndFacets,
443
+ getSearchTotalCount: getSearchTotalCount,
444
+ getFacetsTotalCount: getFacetsTotalCount,
445
+ selectFacets: selectFacets,
446
+ selectListing: selectListing,
447
+ selectCurrentPath: selectCurrentPath,
448
+ selectCurrentProject: selectCurrentProject,
449
+ selectVersionStatus: selectVersionStatus
450
+ });
451
+
452
+ const getClientConfig = (project, env) => {
453
+ let config = DELIVERY_API_CONFIG;
454
+ /* global DELIVERY_API_CONFIG */
455
+
456
+ if (project) {
457
+ config.projectId = project;
458
+ }
459
+
460
+ if (typeof window != 'undefined' && PROXY_DELIVERY_API
461
+ /* global PROXY_DELIVERY_API */
462
+ ) {
463
+ // ensure a relative url is used to bypass the need for CORS (separate OPTIONS calls)
464
+ config.rootUrl = env || '';
465
+ config.responseHandler = {
466
+ 404: () => null
467
+ };
468
+ }
469
+
470
+ return config;
471
+ };
472
+
473
+ class CacheNode {
474
+ constructor(key, value) {
475
+ this.key = key;
476
+ this.value = value;
477
+ this.next = null;
478
+ this.prev = null;
479
+ }
480
+
481
+ }
482
+
483
+ class LruCache {
484
+ constructor(limit = 100) {
485
+ this.map = {};
486
+ this.head = null;
487
+ this.tail = null;
488
+ this.limit = limit || 100;
489
+ this.size = 0;
490
+ }
491
+
492
+ get(key) {
493
+ if (this.map[key]) {
494
+ let value = this.map[key].value;
495
+ let node = new CacheNode(key, value);
496
+ this.remove(key);
497
+ this.setHead(node);
498
+ return value;
499
+ }
500
+ }
501
+
502
+ set(key, value) {
503
+ let node = new CacheNode(key, value);
504
+
505
+ if (this.map[key]) {
506
+ this.remove(key);
507
+ } else {
508
+ if (this.size >= this.limit) {
509
+ delete this.map[this.tail.key];
510
+ this.size--;
511
+ this.tail = this.tail.prev;
512
+ this.tail.next = null;
513
+ }
514
+ }
515
+
516
+ this.setHead(node);
517
+ }
518
+
519
+ setHead(node) {
520
+ node.next = this.head;
521
+ node.prev = null;
522
+
523
+ if (this.head) {
524
+ this.head.prev = node;
525
+ }
526
+
527
+ this.head = node;
528
+
529
+ if (!this.tail) {
530
+ this.tail = node;
531
+ }
532
+
533
+ this.size++;
534
+ this.map[node.key] = node;
535
+ }
536
+
537
+ remove(key) {
538
+ let node = this.map[key];
539
+
540
+ if (node.prev) {
541
+ node.prev.next = node.next;
542
+ } else {
543
+ this.head = node.next;
544
+ }
545
+
546
+ if (node.next) {
547
+ node.next.prev = node.prev;
548
+ } else {
549
+ this.tail = node.prev;
550
+ }
551
+
552
+ delete this.map[key];
553
+ this.size--;
554
+ }
555
+
556
+ }
557
+
558
+ class CachedSearch {
559
+ constructor() {
560
+ this.cache = new LruCache();
561
+ this.taxonomyLookup = {};
562
+ }
563
+
564
+ search(query, linkDepth, project, env) {
565
+ const client = Client.create(getClientConfig(project, env));
566
+ return this.request(project + JSON.stringify(query) + linkDepth.toString(), () => client.entries.search(query, linkDepth));
567
+ }
568
+
569
+ getTaxonomyNodeByPath(path, project, env) {
570
+ const client = Client.create(getClientConfig(project, env));
571
+ return this.request(`[TAXONOMY NODE] ${path}`, () => client.taxonomy.getNodeByPath({
572
+ path: path,
573
+ order: 'defined',
574
+ childDepth: 2
575
+ }).then(node => this.extendTaxonomyNode(node)));
576
+ }
577
+
578
+ request(key, execute) {
579
+ if (!this.cache.get(key) || typeof window == 'undefined') {
580
+ let promise = execute();
581
+ this.cache.set(key, promise);
582
+ promise.catch(() => {
583
+ this.cache.remove(key);
584
+ });
585
+ }
586
+
587
+ return this.cache.get(key);
588
+ }
589
+
590
+ extendTaxonomyNode(node) {
591
+ let id = this.getTaxonomyId(node);
592
+ this.taxonomyLookup[id] = node.key;
593
+ return { ...node,
594
+ id,
595
+ children: node.children ? node.children.map(n => this.extendTaxonomyNode(n)) : null
596
+ };
597
+ }
598
+
599
+ getTaxonomyId(node) {
600
+ if (node.key) {
601
+ let parts = node.key.split('/');
602
+ return parts[parts.length - 1];
603
+ }
604
+
605
+ return '';
606
+ }
607
+
608
+ fetch(uri, opts = {}) {
609
+ return this.request(`[FETCH] ${uri} ${JSON.stringify(opts)}`, () => fetch(uri, opts));
610
+ }
611
+
612
+ }
613
+
614
+ const cachedSearch = new CachedSearch();
615
+
616
+ const now = () => {
617
+ if (typeof window == 'undefined') {
618
+ return Date.now();
619
+ }
620
+
621
+ return window.performance.now();
622
+ };
623
+
624
+ // eslint-disable-next-line import/default
625
+ function fixFreeTextForElastic(s) {
626
+ const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
627
+ const illegalRegEx = new RegExp(illegalChars.map(c => '\\' + c).join('|'), 'g');
628
+ s = s.replace(illegalRegEx, ''); // s = s.replace(encodedRegEx, ''); // (m) => '\\\\' + m);
629
+
630
+ return s;
631
+ }
632
+ const timedSearch = async (query, linkDepth = 0, projectId, env) => {
633
+ if (!query) return null;
634
+ let duration = 0;
635
+ const start = now();
636
+ const payload = await cachedSearch.search(query, linkDepth, projectId, env);
637
+ const end = now();
638
+ duration = end - start;
639
+ return {
640
+ duration,
641
+ payload
642
+ };
643
+ };
644
+ const getItemsFromResult = result => {
645
+ const {
646
+ payload
647
+ } = result || {};
648
+
649
+ if (payload) {
650
+ if (Array.isArray(payload)) return payload;
651
+ if (Array.isArray(payload.items)) return payload.items;
652
+ return payload;
653
+ }
654
+
655
+ return [];
656
+ };
657
+ const extractQuotedPhrases = searchTerm => {
658
+ const pattern = new RegExp(/(?=["'])(?:"[^"\\]*(?:\\[\s\S][^"\\]*)*"|'[^'\\]*(?:\\[\s\S][^'\\]*)*')/gm);
659
+ return (searchTerm.match(pattern) || []).map(match => match.replace(/"/g, ''));
660
+ };
661
+ const buildUrl = (route, params) => {
662
+ const qs = stringify(params);
663
+ const path = qs ? `${route}?${qs}` : route;
664
+ return path;
665
+ };
666
+ const callCustomApi = async (customApi, filters) => {
667
+ const apiUri = customApi.uri || '';
668
+ let uri = buildUrl(apiUri, filters);
669
+ if (!uri) throw new Error('uri is required to use customApi');
670
+ if (typeof window == 'undefined' && uri.startsWith('/')) uri = `http://localhost:3001${uri}`;
671
+ const response = await cachedSearch.fetch(uri);
672
+ return await response.clone().json();
673
+ };
674
+ const removeEmptyAttributes = obj => {
675
+ Object.entries(obj).forEach(([key, val]) => val && typeof val === 'object' && removeEmptyAttributes(val) || (typeof val === 'undefined' || val === null || val === '') && delete obj[key]);
676
+ return obj;
677
+ };
678
+ const toArray = (obj, seperator = ',') => typeof obj === 'undefined' || obj === null ? obj : Array.isArray(obj) ? obj : obj.split(seperator); // assumes array elements are primitive types
679
+
680
+ const areArraysEqualSets = (a1, a2) => {
681
+ const superSet = {};
682
+
683
+ for (const ai of a1) {
684
+ const e = ai + typeof ai;
685
+ superSet[e] = 1;
686
+ }
687
+
688
+ for (const ai of a2) {
689
+ const e = ai + typeof ai;
690
+
691
+ if (!superSet[e]) {
692
+ return false;
693
+ }
694
+
695
+ superSet[e] = 2;
696
+ }
697
+
698
+ for (const e in superSet) {
699
+ if (superSet[e] === 1) {
700
+ return false;
701
+ }
702
+ }
703
+
704
+ return true;
705
+ };
706
+
707
+ const DataFormats = {
708
+ asset: 'asset',
709
+ entry: 'entry',
710
+ webpage: 'webpage'
711
+ };
712
+ const FilterExpressionTypes = {
713
+ contentType: 'contentType',
714
+ field: 'field'
715
+ };
716
+ const sys = {
717
+ allUris: 'sys.allUris',
718
+ contentTypeId: 'sys.contentTypeId',
719
+ dataFormat: 'sys.dataFormat',
720
+ filename: 'sys.properties.filename',
721
+ id: 'sys.id',
722
+ includeInSearch: 'sys.metadata.includeInSearch',
723
+ language: 'sys.language',
724
+ uri: 'sys.uri',
725
+ versionStatus: 'sys.versionStatus'
726
+ };
727
+ const Fields = {
728
+ entryDescription: 'entryDescription',
729
+ entryTitle: 'entryTitle',
730
+ keywords: 'keywords',
731
+ searchContent: 'searchContent',
732
+ sys,
733
+ contentTypeId: 'sys.contentTypeId',
734
+ wildcard: '*'
735
+ };
736
+
737
+ const fieldExpression = (field, value, operator = 'equalTo', weight) => {
738
+ if (!field || !value || Array.isArray(value) && value.length === 0) return [];
739
+ if (Array.isArray(field)) // If an array of fieldIds have been provided, call self for each fieldId
740
+ // to generate expressions that are combined with an 'or' operator
741
+ return [Op.or(...field.map(fieldId => fieldExpression(fieldId, value, operator, weight)).flat())];
742
+ if (operator === 'between') return between(field, value);
743
+ if (Array.isArray(value)) return equalToOrIn(field, value, operator);else return !weight ? equalToOrIn(field, value, operator) : [equalToOrIn(field, value, operator)[0].weight(weight)];
744
+ };
745
+ const contentTypeIdExpression = (contentTypeIds, webpageTemplates, assetTypes) => {
746
+ const expressions = [];
747
+ if (!contentTypeIds && !webpageTemplates && !assetTypes) return expressions;
748
+
749
+ if (contentTypeIds && contentTypeIds.length > 0) {
750
+ expressions.push(...dataFormatExpression(contentTypeIds, DataFormats.entry));
751
+ }
752
+
753
+ if (webpageTemplates && webpageTemplates.length > 0) {
754
+ expressions.push(...dataFormatExpression(webpageTemplates, DataFormats.webpage));
755
+ }
756
+
757
+ if (assetTypes && assetTypes.length > 0) {
758
+ expressions.push(...dataFormatExpression(assetTypes, DataFormats.asset));
759
+ }
760
+
761
+ if (expressions.length > 1) return [Op.or(...expressions)];
762
+ return expressions;
763
+ };
764
+ const filterExpressions = (filters, isOptional = false) => {
765
+ if (!filters) return [];
766
+ const expressions = [];
767
+ filters.map(selectedFilter => {
768
+ if (selectedFilter.logicOperator === 'and') // using 'and' logic operator we loop through each filter
769
+ // and loop through all values to add an expression for each filter value
770
+ selectedFilter.values.forEach(value => expressions.push(...fieldExpression(selectedFilter.key, value, selectedFilter.fieldOperator || 'equalTo')));else if (selectedFilter.logicOperator === 'not') {
771
+ const fieldExpressions = fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in');
772
+ fieldExpressions.forEach(expr => {
773
+ expressions.push(Op.not(expr));
774
+ });
775
+ } // using 'or' logic operator we loop over each filter
776
+ // and simply add the array of values to an expression with an 'in' operator
777
+ else expressions.push(...fieldExpression(selectedFilter.key, selectedFilter.values, selectedFilter.fieldOperator || 'in'));
778
+ if (isOptional) expressions.push(Op.not(fieldExpression(selectedFilter.key, true, 'exists')[0]));
779
+ });
780
+ return expressions;
781
+ };
782
+ const dataFormatExpression = (contentTypeIds, dataFormat = DataFormats.entry) => {
783
+ if (contentTypeIds && contentTypeIds.length > 0) {
784
+ /**
785
+ * We have an array of contentTypeIds some may be prefixed with a "!"
786
+ * to indicate this is a "not" expression
787
+ */
788
+ const withContentTypeIds = contentTypeIds.filter(c => !c.startsWith('!'));
789
+ const notContentTypeIds = contentTypeIds.filter(c => c.startsWith('!')).map(id => id.substring(1));
790
+ const andExpr = Op.and();
791
+ const dataFormatExpr = fieldExpression(Fields.sys.dataFormat, dataFormat)[0];
792
+ const withExpr = fieldExpression(Fields.sys.contentTypeId, withContentTypeIds)[0];
793
+ const notExpr = Op.not(fieldExpression(Fields.sys.contentTypeId, notContentTypeIds)[0]);
794
+ andExpr.add(dataFormatExpr);
795
+ if (withContentTypeIds.length > 0 && withExpr) andExpr.add(withExpr);
796
+ if (notContentTypeIds.length > 0 && notExpr) andExpr.add(notExpr);
797
+ return [andExpr];
798
+ }
799
+
800
+ return [];
801
+ };
802
+ const featuredResultsExpression = ({
803
+ contentTypeId,
804
+ fieldId,
805
+ fieldValue = true
806
+ } = {}) => {
807
+ const expressions = [];
808
+
809
+ if (contentTypeId) {
810
+ expressions.push(...contentTypeIdExpression(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId]));
811
+ }
812
+
813
+ if (fieldId && fieldValue) {
814
+ expressions.push(...fieldExpression(fieldId, fieldValue));
815
+ }
816
+
817
+ return expressions;
818
+ };
819
+ const languagesExpression = languages => fieldExpression(Fields.sys.language, languages);
820
+ const includeInSearchExpressions = (webpageTemplates, includeInSearchFields) => {
821
+ const expressions = []; // Or include this expression if we have explicity specified non-default includeInSearch fields
822
+
823
+ if (Array.isArray(includeInSearchFields)) expressions.push(...includeInSearchFields.map(includeInSearchField => Op.or(Op.and(Op.exists(includeInSearchField, true), Op.equalTo(includeInSearchField, true)), Op.exists(includeInSearchField, false)))); // If webpageTemplates have been specified, include this expression
824
+ // with the default includeInSearch field from classic Contensis.
825
+
826
+ if (Array.isArray(webpageTemplates) && webpageTemplates.length > 0) expressions.push(Op.or(Op.and(Op.exists(Fields.sys.includeInSearch, true), Op.equalTo(Fields.sys.includeInSearch, true)), Op.exists(Fields.sys.includeInSearch, false)));
827
+ return expressions;
828
+ };
829
+ const defaultExpressions = versionStatus => {
830
+ return [Op.equalTo(Fields.sys.versionStatus, versionStatus)];
831
+ };
832
+ const includeIdsExpression = includeIds => {
833
+ if (Array.isArray(includeIds) && includeIds.length > 0) {
834
+ return fieldExpression(Fields.sys.id, includeIds);
835
+ } else return [];
836
+ };
837
+ const excludeIdsExpression = excludeIds => {
838
+ if (Array.isArray(excludeIds) && excludeIds.length > 0) {
839
+ const [expr] = fieldExpression(Fields.sys.id, excludeIds);
840
+ return [Op.not(expr)];
841
+ } else return [];
842
+ };
843
+ const orderByExpression = orderBy => {
844
+ let expression = OrderBy;
845
+
846
+ if (orderBy && orderBy.length > 0) {
847
+ orderBy.map(ob => expression = ob.startsWith('-') ? expression.desc(ob.substring(1)) : expression.asc(ob));
848
+ }
849
+
850
+ return expression;
851
+ };
852
+
853
+ const equalToOrIn = (field, value, operator = 'equalTo') => {
854
+ if (value.length === 0) return [];
855
+
856
+ if (Array.isArray(value)) {
857
+ if (operator === 'equalTo' || operator === 'in') return [Op.in(field, ...value)];
858
+ const expressions = value.map(innerValue => {
859
+ var _between, _distanceWithin;
860
+
861
+ switch (operator) {
862
+ case 'between':
863
+ return (_between = between(field, innerValue)) === null || _between === void 0 ? void 0 : _between[0];
864
+
865
+ case 'distanceWithin':
866
+ return (_distanceWithin = distanceWithin(field, innerValue)) === null || _distanceWithin === void 0 ? void 0 : _distanceWithin[0];
867
+
868
+ case 'exists':
869
+ return Op.exists(field, innerValue);
870
+
871
+ case 'freeText':
872
+ // TODO: Potentially needs further implementation of new options
873
+ return Op[operator](field, innerValue, false, undefined);
874
+
875
+ default:
876
+ return Op[operator](field, innerValue);
877
+ }
878
+ });
879
+ return (expressions === null || expressions === void 0 ? void 0 : expressions.length) > 1 ? [Op.or(...expressions)] : expressions || [];
880
+ }
881
+
882
+ switch (operator) {
883
+ case 'between':
884
+ return between(field, value);
885
+
886
+ case 'distanceWithin':
887
+ return distanceWithin(field, value);
888
+
889
+ case 'freeText':
890
+ // TODO: Potentially needs further implementation of new options
891
+ return [Op.freeText(field, value, false, undefined)];
892
+
893
+ default:
894
+ return [Op[operator](field, value)];
895
+ }
896
+ };
897
+
898
+ const between = (field, value) => {
899
+ const handle = betweenValue => {
900
+ const valArr = betweenValue.split('--');
901
+
902
+ if (valArr.length > 1) {
903
+ const [minimum, maximum] = valArr;
904
+ return Op.between(field, minimum, maximum);
905
+ } else {
906
+ // eslint-disable-next-line no-console
907
+ console.log(`[search] You have supplied only one value to a "between" operator which must have two values. Your supplied value "${valArr.length && valArr[0]}" has been discarded.`);
908
+ return false;
909
+ }
910
+ };
911
+
912
+ if (value.length === 0) return [];
913
+ if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
914
+ const op = handle(value);
915
+ return op ? [op] : [];
916
+ };
917
+
918
+ const distanceWithin = (field, value) => {
919
+ const handle = distanceValue => {
920
+ const valArr = distanceValue.split(' ');
921
+
922
+ if (valArr.length > 1) {
923
+ const [lat, lon] = valArr;
924
+ return Op.distanceWithin(field, Number(lat), Number(lon), (valArr === null || valArr === void 0 ? void 0 : valArr[2]) || '10mi');
925
+ } else {
926
+ // eslint-disable-next-line no-console
927
+ console.log(`[search] You have supplied only one value to a "distanceWithin" operator which must be made up of "lat,lon,distance". Your supplied value "${valArr.length && valArr[0]}" has been discarded.`);
928
+ return false;
929
+ }
930
+ };
931
+
932
+ if (value.length === 0) return [];
933
+ if (Array.isArray(value)) return [Op.or(...value.map(handle).filter(bc => bc !== false))];
934
+ const op = handle(value);
935
+ return op ? [op] : [];
936
+ };
937
+ /**
938
+ * Accept HTTP style objects and map them to
939
+ * their equivalent JS client "Op" expressions
940
+ * @param {array} where the where array as you'd provide it to the HTTP API
941
+ * @returns {array} array of constructed Delivery API Operators
942
+ */
943
+
944
+
945
+ const customWhereExpressions = where => {
946
+ if (!where || !Array.isArray(where)) return []; // Map each clause inside the where array
947
+
948
+ return where.map(clause => {
949
+ let expression; // Map through each property in the clause so we can
950
+ // capture the values required and reconstruct them as
951
+ // a Delivery API expression
952
+
953
+ let operator;
954
+ Object.keys(clause).map((key, idx) => {
955
+ // The clause may contain only one key
956
+ if (idx === 0) operator = key;
957
+ const field = clause.field;
958
+ const value = clause[Object.keys(clause).find(k => !['field', 'weight'].includes(k)) || ''];
959
+ const weight = clause.weight;
960
+
961
+ if (idx === 0) {
962
+ if (operator === 'and' || operator === 'or') {
963
+ // These are array expressions so we can call ourself recursively
964
+ // to map these inner values to expressions
965
+ const recurseExpr = customWhereExpressions(clause[operator]);
966
+ expression = Op[operator](...recurseExpr);
967
+ }
968
+
969
+ if (['not'].includes(operator)) {
970
+ // A 'not' expression is an object with only one inner field and inner operator
971
+ Object.keys(value).map((notKey, notIdx) => {
972
+ const innerOperator = notKey;
973
+ const innerValue = value[notKey];
974
+ const innerField = value.field; // Map the expression when we've looped and scoped to
975
+ // the second property inside the clause
976
+
977
+ if (notIdx === 1) expression = Op.not(makeJsExpression(innerOperator, innerField, innerValue));
978
+ });
979
+ }
980
+ } // Map the expression when we've looped and scoped to
981
+ // the second property inside the clause
982
+
983
+
984
+ operator = Object.keys(clause).find(clauseKey => !['field', 'weight'].includes(clauseKey));
985
+
986
+ if (idx === 1) {
987
+ expression = makeJsExpression(operator, field, value);
988
+ if (typeof weight === 'number') expression = expression.weight(weight);
989
+ }
990
+ });
991
+ return expression;
992
+ });
993
+ };
994
+
995
+ const makeJsExpression = (operator, field, value) => operator === 'freeText' || operator === 'contains' ? Op[operator](field, value) : operator === 'in' ? Op[operator](field, ...value) : operator === 'exists' ? Op[operator](field, value) : operator === 'between' ? Op[operator](field, value[0], value[1]) : operator === 'distanceWithin' ? Op[operator](field, value === null || value === void 0 ? void 0 : value.lat, value === null || value === void 0 ? void 0 : value.lon, value === null || value === void 0 ? void 0 : value.distance) : Op[operator](field, value);
996
+
997
+ const termExpressions = (searchTerm, weightedSearchFields) => {
998
+ if (searchTerm && weightedSearchFields && weightedSearchFields.length > 0) {
999
+ // Extract any phrases in quotes to array
1000
+ const quotedPhrases = extractQuotedPhrases(searchTerm); // Modify the search term to remove any quoted phrases to leave any remaining terms
1001
+
1002
+ let modifiedSearchTerm = searchTerm;
1003
+ quotedPhrases.forEach(qp => modifiedSearchTerm = modifiedSearchTerm.replace(qp, '').replace('""', '').trim()); // Push to the operators array to include in the query
1004
+
1005
+ const operators = []; // Helper functions to generate Op expressions
1006
+
1007
+ const containsOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'contains', f.weight);
1008
+
1009
+ const freeTextOp = (f, term) => fieldExpression(f.fieldId, fixFreeTextForElastic(term), 'freeText', f.weight); // For each weighted search field
1010
+
1011
+
1012
+ weightedSearchFields.forEach(wsf => {
1013
+ // Push to field operators
1014
+ const fieldOperators = []; // Add operator expressions for modified search term
1015
+
1016
+ if (modifiedSearchTerm) {
1017
+ if ([Fields.keywords, Fields.sys.filename, Fields.sys.uri].includes(wsf.fieldId)) {
1018
+ fieldOperators.push(...containsOp(wsf, modifiedSearchTerm));
1019
+ } else {
1020
+ if ([Fields.entryTitle].includes(wsf.fieldId)) {
1021
+ fieldOperators.push(Op.or(...containsOp(wsf, modifiedSearchTerm), ...freeTextOp(wsf, modifiedSearchTerm)));
1022
+ } else {
1023
+ fieldOperators.push(...freeTextOp(wsf, modifiedSearchTerm));
1024
+ }
1025
+ }
1026
+ } // Add operator expressions for any quoted phrases
1027
+
1028
+
1029
+ quotedPhrases.forEach(qp => fieldOperators.push(...containsOp(wsf, qp))); // If we are using multiple operators for a field we will
1030
+ // wrap each field inside an And operator so we will match
1031
+ // all terms/phrases rather than any terms/phrases
1032
+
1033
+ if (fieldOperators.length > 1) {
1034
+ operators.push(Op.and(...fieldOperators));
1035
+ } else {
1036
+ operators.push(...fieldOperators);
1037
+ }
1038
+ }); // Wrap operators in an Or operator
1039
+
1040
+ return [Op.or().addRange(operators).add(Op.freeText(Fields.searchContent, searchTerm))];
1041
+ } else if (searchTerm) {
1042
+ // Searching without weightedSearchFields defined will fall back
1043
+ // to a default set of search fields with arbritary weights set.
1044
+ return [Op.or(Op.equalTo(Fields.entryTitle, searchTerm).weight(10), Op.freeText(Fields.entryTitle, searchTerm).weight(2), Op.freeText(Fields.entryDescription, searchTerm).weight(2), Op.contains(Fields.keywords, searchTerm).weight(2), Op.contains(Fields.sys.uri, searchTerm).weight(2), Op.contains(Fields.sys.allUris, searchTerm), Op.freeText(Fields.searchContent, searchTerm))];
1045
+ } else {
1046
+ return [];
1047
+ }
1048
+ };
1049
+
1050
+ var expressions = /*#__PURE__*/Object.freeze({
1051
+ __proto__: null,
1052
+ fieldExpression: fieldExpression,
1053
+ contentTypeIdExpression: contentTypeIdExpression,
1054
+ filterExpressions: filterExpressions,
1055
+ dataFormatExpression: dataFormatExpression,
1056
+ featuredResultsExpression: featuredResultsExpression,
1057
+ languagesExpression: languagesExpression,
1058
+ includeInSearchExpressions: includeInSearchExpressions,
1059
+ defaultExpressions: defaultExpressions,
1060
+ includeIdsExpression: includeIdsExpression,
1061
+ excludeIdsExpression: excludeIdsExpression,
1062
+ orderByExpression: orderByExpression,
1063
+ customWhereExpressions: customWhereExpressions,
1064
+ termExpressions: termExpressions
1065
+ });
1066
+
1067
+ const filterQuery = (contentTypeIds, versionStatus, customWhere) => {
1068
+ const query = new Query(...[...contentTypeIdExpression(contentTypeIds), ...defaultExpressions(versionStatus), ...customWhereExpressions(customWhere)]);
1069
+ query.orderBy = OrderBy.asc(Fields.entryTitle);
1070
+ query.pageSize = 100;
1071
+ return query;
1072
+ };
1073
+ const searchQuery = ({
1074
+ assetTypes,
1075
+ contentTypeIds,
1076
+ customWhere,
1077
+ dynamicOrderBy,
1078
+ excludeIds,
1079
+ featuredResults,
1080
+ fields,
1081
+ filters,
1082
+ includeInSearchFields,
1083
+ languages,
1084
+ pageSize,
1085
+ pageIndex,
1086
+ orderBy,
1087
+ searchTerm,
1088
+ versionStatus,
1089
+ webpageTemplates,
1090
+ weightedSearchFields
1091
+ }, isFeatured = false) => {
1092
+ let expressions = [...termExpressions(searchTerm, weightedSearchFields), ...defaultExpressions(versionStatus), ...includeInSearchExpressions(webpageTemplates, includeInSearchFields), ...languagesExpression(languages), ...customWhereExpressions(customWhere), ...excludeIdsExpression(excludeIds)];
1093
+ if (isFeatured) expressions = [...expressions, ...featuredResultsExpression(featuredResults)];
1094
+ if (!isFeatured || featuredResults && !featuredResults.contentTypeId) expressions = [...expressions, ...filterExpressions(filters), ...contentTypeIdExpression(contentTypeIds, webpageTemplates, assetTypes)];
1095
+ const query = new Query(...expressions);
1096
+ if (!searchTerm) query.orderBy = orderByExpression(orderBy);
1097
+ if (dynamicOrderBy && dynamicOrderBy.length) query.orderBy = orderByExpression(dynamicOrderBy);
1098
+
1099
+ if (fields && fields.length > 0 && !isFeatured) {
1100
+ query.fields = fields;
1101
+ }
1102
+
1103
+ query.pageIndex = isFeatured ? 0 : pageIndex;
1104
+ query.pageSize = isFeatured && typeof featuredResults.count === 'number' ? featuredResults.count : pageSize;
1105
+ return query;
1106
+ };
1107
+
1108
+ var queries = /*#__PURE__*/Object.freeze({
1109
+ __proto__: null,
1110
+ filterQuery: filterQuery,
1111
+ searchQuery: searchQuery
1112
+ });
1113
+
1114
+ const searchUriTemplate = {
1115
+ path: ({
1116
+ state,
1117
+ facet,
1118
+ pageIndex
1119
+ }) => {
1120
+ const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
1121
+ const currentPath = selectCurrentPath(state) || '/search';
1122
+ const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
1123
+ if (pageIndex) return `${newPath}/${pageIndex + 1}`;
1124
+ return newPath;
1125
+ },
1126
+ search: ({
1127
+ state,
1128
+ facet,
1129
+ orderBy,
1130
+ term
1131
+ }) => {
1132
+ const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
1133
+ // term is passed via an argument
1134
+
1135
+ const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
1136
+ const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
1137
+ const currentQs = removeEmptyAttributes(parse(currentSearch));
1138
+ if (orderBy) currentQs.orderBy = orderBy;
1139
+ const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
1140
+
1141
+ const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
1142
+ term: searchTerm
1143
+ });
1144
+ return stringify(mergedSearch);
1145
+ },
1146
+ hash: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
1147
+ };
1148
+
1149
+ const mapStateToSearchUri = params => mapJson(params, searchUriTemplate);
1150
+
1151
+ const mapEntriesToSearchResults = ({
1152
+ mappers,
1153
+ mapper,
1154
+ context,
1155
+ facet
1156
+ }, items, state) => {
1157
+ const mapperFunc = mapper || mappers && mappers.results;
1158
+ return items && typeof mapperFunc === 'function' ? mapperFunc(items, facet, context, state) : [];
1159
+ };
1160
+
1161
+ const facetTemplate = {
1162
+ type: () => SET_SEARCH_ENTRIES,
1163
+ context: 'action.context',
1164
+ facet: 'action.facet',
1165
+ mappers: 'action.mappers',
1166
+ nextFacet: {
1167
+ entries: {
1168
+ isLoading: () => false,
1169
+ isError: () => false
1170
+ },
1171
+ featuredEntries: {
1172
+ isLoading: () => false,
1173
+ isError: () => false
1174
+ },
1175
+ featuredResults: ({
1176
+ action,
1177
+ featuredResult,
1178
+ state
1179
+ }) => mapEntriesToSearchResults(action, getItemsFromResult(featuredResult), state),
1180
+ queryDuration: 'result.duration',
1181
+ pagingInfo: {
1182
+ isLoading: () => false,
1183
+ pageCount: {
1184
+ $path: 'result.payload.pageCount',
1185
+ $default: 0
1186
+ },
1187
+ totalCount: {
1188
+ $path: 'result.payload.totalCount',
1189
+ $default: 0
1190
+ },
1191
+ pageSize: {
1192
+ $path: 'result.payload.pageSize',
1193
+ $default: 0
1194
+ },
1195
+ pageIndex: 'pageIndex',
1196
+ pagesLoaded: {
1197
+ $path: 'action.queryParams',
1198
+ $formatting: ({
1199
+ pageIndex,
1200
+ pagesLoaded
1201
+ }) => {
1202
+ const loaded = [...(pagesLoaded || [])];
1203
+
1204
+ if (isNaN(loaded.find(l => l === pageIndex))) {
1205
+ loaded.push(pageIndex);
1206
+ }
1207
+
1208
+ return loaded.sort((a, b) => a - b);
1209
+ }
1210
+ },
1211
+ prevPageIndex: 'action.queryParams.prevPageIndex'
1212
+ },
1213
+ preloaded: {
1214
+ $path: 'preload',
1215
+ $default: false
1216
+ },
1217
+ results: ({
1218
+ action,
1219
+ pageIndex,
1220
+ result,
1221
+ prevResults,
1222
+ state
1223
+ }) => {
1224
+ const {
1225
+ loadMorePaging,
1226
+ pagesLoaded,
1227
+ prevPageIndex
1228
+ } = action.queryParams;
1229
+ const results = mapEntriesToSearchResults(action, getItemsFromResult(result), state);
1230
+ if (!loadMorePaging) return results; // add a _pageIndex property to the returned results to help us later
1231
+
1232
+ const nextResults = results.map((r, idx) => ({
1233
+ _pageIndex: pageIndex,
1234
+ _pagePosition: idx,
1235
+ ...r
1236
+ }));
1237
+ const loadedPages = pagesLoaded || []; // if pageIndex is found in loadedPages, we have already loaded this page
1238
+
1239
+ if (!isNaN(loadedPages.find(l => l === pageIndex))) return prevResults; // Determine where we put the results depending on if we
1240
+ // are paging forwards, backwards, or doing a new search
1241
+
1242
+ const firstResultSet = pageIndex > prevPageIndex ? prevResults || [] : nextResults;
1243
+ const secondResultSet = pageIndex > prevPageIndex ? nextResults : prevResults || [];
1244
+ const onlyResultSet = loadedPages.length === 0 ? nextResults : false;
1245
+ return onlyResultSet || [...firstResultSet, ...secondResultSet];
1246
+ }
1247
+ },
1248
+ preload: 'action.preload',
1249
+ ogState: 'action.ogState',
1250
+ debug: 'action.debug'
1251
+ };
1252
+ const filterTemplate = {
1253
+ type: ({
1254
+ type
1255
+ }) => type || LOAD_FILTERS_COMPLETE,
1256
+ context: 'context',
1257
+ facetKey: 'facetKey',
1258
+ filterKey: 'filterKey',
1259
+ nextFilter: {
1260
+ isLoading: () => false,
1261
+ isError: ({
1262
+ type
1263
+ }) => type === LOAD_FILTERS_ERROR,
1264
+ items: ({
1265
+ payload,
1266
+ selectedKeys,
1267
+ mapper
1268
+ }) => {
1269
+ if (payload && (payload.items || payload.children)) {
1270
+ const items = (payload.items || payload.children).map(item => {
1271
+ var _item$sys;
1272
+
1273
+ item.isSelected = selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.includes((item === null || item === void 0 ? void 0 : (_item$sys = item.sys) === null || _item$sys === void 0 ? void 0 : _item$sys.id) || item.key);
1274
+ return item;
1275
+ });
1276
+ return mapper(items);
1277
+ }
1278
+
1279
+ return [];
1280
+ }
1281
+ },
1282
+ error: {
1283
+ $path: 'error',
1284
+ $disable: e => !e
1285
+ }
1286
+ };
1287
+
1288
+ const filterExpressionMapper = {
1289
+ // Expression type: so we can identify how to build the query
1290
+ expressionType: ({
1291
+ contentTypeId
1292
+ }) => contentTypeId ? FilterExpressionTypes.contentType : FilterExpressionTypes.field,
1293
+ // Key: so we can target the query to a specific field
1294
+ key: 'fieldId',
1295
+ // Value: so we can filter a specific field by an array of values
1296
+ // e.g. taxonomy key or contentTypeId array
1297
+ values: 'selectedValues',
1298
+ fieldOperator: 'fieldOperator',
1299
+ logicOperator: 'logicOperator'
1300
+ };
1301
+
1302
+ const mapFilterToFilterExpression = filter => mapJson(filter, filterExpressionMapper);
1303
+
1304
+ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
1305
+ if (!selectedFilters || Object.keys(selectedFilters).length === 0) return [];
1306
+ const filterExpressions = []; // Iterate through the keys in selectedFilters and locate
1307
+ // the items that are selected and queryable
1308
+
1309
+ Object.entries(selectedFilters).map(([fkey, selectedValues]) => {
1310
+ const filter = filters[fkey];
1311
+
1312
+ if (selectedValues && filter) {
1313
+ // Where we have a value for a selectedFilter
1314
+ // and a filter is found for the current key
1315
+ // map the filter to a filterExpression object
1316
+ const expr = mapFilterToFilterExpression({ ...filter,
1317
+ selectedValues
1318
+ });
1319
+ filterExpressions.push(expr);
1320
+ }
1321
+ });
1322
+ return filterExpressions;
1323
+ };
1324
+
1325
+ const queryParamsTemplate = {
1326
+ assetTypes: root => getQueryParameter(root, 'assetTypes', []),
1327
+ contentTypeIds: root => getQueryParameter(root, 'contentTypeIds', []),
1328
+ customWhere: root => getQueryParameter(root, 'customWhere', []),
1329
+ dynamicOrderBy: root => getQueryParameter(root, 'dynamicOrderBy', []),
1330
+ env: ({
1331
+ state,
1332
+ facet,
1333
+ context
1334
+ }) => getCustomEnv(state, facet, context),
1335
+ excludeIds: ({
1336
+ action: {
1337
+ excludeIds
1338
+ }
1339
+ }) => {
1340
+ // Exclude current route entry id from minilist searches or any supplied ids
1341
+ if (excludeIds) return Array.isArray(excludeIds) ? excludeIds : excludeIds.split(',').map(id => id.trim());
1342
+ return null;
1343
+ },
1344
+ featuredResults: root => getQueryParameter(root, 'featuredResults', null),
1345
+ fields: root => getQueryParameter(root, 'fields', []),
1346
+ filters: ({
1347
+ state,
1348
+ facet,
1349
+ context
1350
+ }) => {
1351
+ const stateFilters = getFilters(state, facet, context, 'js');
1352
+ const selectedFilters = getSelectedFilters(state, facet, context, 'js'); // Use another mapping function to map the filter parameters for the query
1353
+
1354
+ const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
1355
+ return filterParams;
1356
+ },
1357
+ includeInSearchFields: root => getQueryParameter(root, 'includeInSearch', []),
1358
+ internalPageIndex: ({
1359
+ action,
1360
+ state
1361
+ }) => getPageIndex(state, '', action.context),
1362
+ internalPaging: root => getQueryParameter(root, 'internalPaging', false),
1363
+ languages: ({
1364
+ action
1365
+ }) => action.defaultLang ? [action.defaultLang] : [],
1366
+ linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
1367
+ loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
1368
+ orderBy: root => getQueryParameter(root, 'orderBy', []),
1369
+ pageIndex: root => {
1370
+ const {
1371
+ action,
1372
+ state
1373
+ } = root;
1374
+ if (getQueryParameter(root, 'internalPaging', false)) return 0;
1375
+ if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
1376
+ return !action.preload ? getPageIndex(state, action.facet, action.context) : 0;
1377
+ },
1378
+ pageSize: root => getQueryParameter(root, 'pageSize'),
1379
+ pagesLoaded: ({
1380
+ state,
1381
+ facet,
1382
+ context
1383
+ }) => getPagesLoaded(state, facet, context),
1384
+ prevPageIndex: ({
1385
+ state,
1386
+ facet,
1387
+ context
1388
+ }) => getPrevPageIndex(state, facet, context),
1389
+ projectId: ({
1390
+ state,
1391
+ facet,
1392
+ context
1393
+ }) => {
1394
+ var _getFacet;
1395
+
1396
+ return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
1397
+ },
1398
+ searchTerm: root => root.context !== Context.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
1399
+ selectedFilters: ({
1400
+ state,
1401
+ facet,
1402
+ context
1403
+ }) => Object.fromEntries(Object.entries(getSelectedFilters(state, facet, context, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')])),
1404
+ versionStatus: ({
1405
+ state
1406
+ }) => selectVersionStatus(state),
1407
+ weightedSearchFields: root => {
1408
+ const wsf = getQueryParameter(root, 'weightedSearchFields', []);
1409
+ const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
1410
+ return deduped; // return wsf;
1411
+ },
1412
+ webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
1413
+ };
1414
+
1415
+ const mapStateToQueryParams = sourceJson => mapJson(sourceJson, queryParamsTemplate);
1416
+
1417
+ /**
1418
+ * 1, Generates all the parameters required to run the search query.
1419
+ * 2, Tells us if we should run the search.
1420
+ * @param {object} action
1421
+ * @param {AppState} state
1422
+ * @returns [queryParams, runSearch]
1423
+ */
1424
+ const generateQueryParams = (action, state) => {
1425
+ const {
1426
+ context,
1427
+ facet
1428
+ } = action; // Map parameters using state and some additional
1429
+ // inputs from the action
1430
+
1431
+ const queryParams = mapStateToQueryParams({
1432
+ context,
1433
+ facet,
1434
+ action,
1435
+ state
1436
+ });
1437
+ return [queryParams, runSearch(action, state, queryParams)];
1438
+ };
1439
+ /**
1440
+ * Checks if we have already loaded everything we're asking for and tells us to run the search or not
1441
+ * @param action
1442
+ * @param state
1443
+ */
1444
+
1445
+ const runSearch = (action, state, queryParams) => {
1446
+ const {
1447
+ context,
1448
+ defaultLang,
1449
+ facet,
1450
+ ogState = state,
1451
+ preload,
1452
+ ssr
1453
+ } = action;
1454
+ let willRun = false;
1455
+ const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
1456
+ const stateParams = { ...getQueryParams(ogState, facet, context)
1457
+ };
1458
+ stateParams.pageIndex = getPageIndex(ogState, facet, context);
1459
+ stateParams.searchTerm = getSearchTerm(ogState);
1460
+
1461
+ if (context === Context.facets && ssr || // context === Context.minilist ||
1462
+ preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
1463
+ willRun = true;
1464
+ } else {
1465
+ // Don't execute the search if the inbound query params
1466
+ // are the same as what we already have in state
1467
+ Object.entries(stateParams).forEach(([param, value]) => {
1468
+ const queryParam = queryParams[param];
1469
+
1470
+ if (JSON.stringify(value) !== JSON.stringify(queryParam)) {
1471
+ willRun = true;
1472
+ }
1473
+ });
1474
+ }
1475
+
1476
+ const internalPaging = getIsInternalPaging(ogState, facet, context);
1477
+
1478
+ if (internalPaging && facetIsLoaded) {
1479
+ willRun = false;
1480
+ }
1481
+
1482
+ return willRun;
1483
+ };
1484
+ /**
1485
+ * This will tell us if filter parameters have been
1486
+ * changed by some external event such as a route change
1487
+ * @param action
1488
+ * @returns true or false
1489
+ */
1490
+
1491
+ const filterParamsChanged = (action, state) => {
1492
+ const {
1493
+ context,
1494
+ facet,
1495
+ params,
1496
+ ogState = state
1497
+ } = action;
1498
+ const selectedFilters = getSelectedFilters(ogState, facet, context, 'js');
1499
+ const paramsChanged = Object.entries(selectedFilters).map(([filterKey, selectedValues]) => {
1500
+ const inboundValues = params && params[filterKey] && params[filterKey].split(',') || [];
1501
+ if (!areArraysEqualSets(selectedValues, inboundValues)) return true;
1502
+ });
1503
+ return paramsChanged.filter(f => f === true).length > 0;
1504
+ };
1505
+ /* eslint-disable no-console */
1506
+
1507
+ const debugExecuteSearch = (action, state) => {
1508
+ const [queryParams, runSearch] = generateQueryParams(action, state);
1509
+ console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
1510
+ const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
1511
+ pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
1512
+ searchTerm: getSearchTerm(action.ogState || state)
1513
+ };
1514
+ console.log(stateParams, queryParams);
1515
+ console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
1516
+ };
1517
+
1518
+ // Base mapping, fields that are the same across all mappings
1519
+ // to save repeating these elements in every mapper, spread this
1520
+ // into your discrete mappings
1521
+
1522
+ const base = {
1523
+ contentTypeId: Fields.sys.contentTypeId,
1524
+ title: 'entryTitle',
1525
+ key: 'sys.id',
1526
+ path: 'sys.slug',
1527
+ isSelected: 'isSelected'
1528
+ };
1529
+
1530
+ const mapEntriesToFilterItems = entries => {
1531
+ if (!entries) return [];
1532
+ return entries.map(entry => {
1533
+ const template = base;
1534
+
1535
+ if (template) {
1536
+ return mapJson(entry, template);
1537
+ }
1538
+
1539
+ return entry;
1540
+ });
1541
+ };
1542
+
1543
+ const mapQueryParamsToCustomApi = queryParams => {
1544
+ const customApiMapping = {
1545
+ fields: ({
1546
+ fields
1547
+ }) => JSON.stringify(fields),
1548
+ orderBy: 'orderBy',
1549
+ linkDepth: 'linkDepth',
1550
+ pageSize: 'pageSize',
1551
+ pageIndex: 'pageIndex',
1552
+ term: {
1553
+ $path: 'searchTerm',
1554
+ $disable: t => !t
1555
+ },
1556
+ versionStatus: 'versionStatus'
1557
+ };
1558
+ Object.keys(queryParams.selectedFilters).forEach(k => {
1559
+ customApiMapping[k] = {
1560
+ $path: `selectedFilters.${k}`,
1561
+ $disable: f => !f
1562
+ };
1563
+ });
1564
+ return mapJson(queryParams, customApiMapping);
1565
+ };
1566
+
1567
+ const searchSagas = [takeEvery(CLEAR_FILTERS, clearFilters), takeEvery(DO_SEARCH, doSearch), takeEvery(SET_ROUTE_FILTERS, loadFilters), takeEvery(SET_SEARCH_ENTRIES, preloadOtherFacets), takeEvery(UPDATE_CURRENT_FACET, updateCurrentFacet), takeEvery(UPDATE_CURRENT_TAB, updateCurrentTab), takeEvery(UPDATE_PAGE_INDEX, updatePageIndex), takeEvery(UPDATE_SEARCH_TERM, updateSearchTerm), takeEvery(UPDATE_SORT_ORDER, updateSortOrder), takeEvery(UPDATE_SELECTED_FILTERS, applySearchFilter)];
1568
+
1569
+ const toJS = obj => obj && 'toJS' in obj && typeof obj.toJS === 'function' ? obj.toJS() : obj;
1570
+
1571
+ function* setRouteFilters(action) {
1572
+ const {
1573
+ mappers,
1574
+ params,
1575
+ listingType,
1576
+ defaultLang,
1577
+ debug
1578
+ } = action;
1579
+ const context = listingType ? Context.listings : Context.facets;
1580
+ const state = toJS(yield select());
1581
+ const ssr = getIsSsr(state); // Get current facet from params or state
1582
+
1583
+ let currentFacet = params && params.facet || listingType; // Pick the default facet from initialState
1584
+
1585
+ if (!currentFacet) {
1586
+ var _Object$keys;
1587
+
1588
+ const tabs = getSearchTabs(state, 'js');
1589
+ currentFacet = (tabs === null || tabs === void 0 ? void 0 : tabs[0].defaultFacet) || ((_Object$keys = Object.keys(getFacets(state, 'js'))) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0]) || '';
1590
+ }
1591
+
1592
+ const nextAction = {
1593
+ type: SET_ROUTE_FILTERS,
1594
+ context,
1595
+ facet: currentFacet,
1596
+ mappers,
1597
+ params,
1598
+ defaultLang,
1599
+ ssr,
1600
+ debug
1601
+ };
1602
+ yield put(nextAction); // keep track of this state ref for comparing changes to params later
1603
+
1604
+ const ogState = {
1605
+ search: state.search
1606
+ }; // Using call instead of triggering from the put
1607
+ // to allow this exported saga to continue during SSR
1608
+
1609
+ yield call(ensureSearch, { ...nextAction,
1610
+ ogState
1611
+ });
1612
+ }
1613
+ function* doSearch(action) {
1614
+ var _action$params;
1615
+
1616
+ const state = toJS(yield select());
1617
+
1618
+ if (action.config) {
1619
+ // If the action contains a config object, we can add this to the
1620
+ // state at runtime
1621
+ yield put({ ...action,
1622
+ type: APPLY_CONFIG
1623
+ });
1624
+ }
1625
+
1626
+ const nextAction = { ...action,
1627
+ type: SET_SEARCH_FILTERS,
1628
+ ssr: getIsSsr(state),
1629
+ facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
1630
+ };
1631
+
1632
+ if (nextAction.facet && (action.config || Object.keys(getFacet(state, nextAction.facet, action.context, 'js')).length > 0)) {
1633
+ yield put(nextAction); // keep track of this state ref for comparing changes to params later
1634
+
1635
+ const ogState = {
1636
+ search: state.search
1637
+ };
1638
+ yield call(ensureSearch, { ...nextAction,
1639
+ ogState
1640
+ });
1641
+ }
1642
+ }
1643
+
1644
+ function* loadFilters(action) {
1645
+ const {
1646
+ facet: facetKey,
1647
+ context,
1648
+ mappers = {}
1649
+ } = action;
1650
+ const filtersToLoad = yield select(getFiltersToLoad, facetKey, context, 'js');
1651
+
1652
+ if (filtersToLoad.length > 0) {
1653
+ yield put({
1654
+ type: LOAD_FILTERS,
1655
+ filtersToLoad,
1656
+ facetKey,
1657
+ context
1658
+ });
1659
+ const selectedKeys = yield select(getSelectedFilters, facetKey, context, 'js');
1660
+ const facet = yield select(getFacet, facetKey, context, 'js');
1661
+ const filters = facet.filters || {};
1662
+ const projectId = facet.projectId;
1663
+ const filtersToLoadSagas = filters && filtersToLoad.map((filterKey = '') => {
1664
+ return call(loadFilter, {
1665
+ facetKey,
1666
+ filterKey,
1667
+ filter: filters[filterKey],
1668
+ projectId,
1669
+ selectedKeys: selectedKeys[filterKey],
1670
+ context,
1671
+ mapper: 'filterItems' in mappers && mappers.filterItems || mapEntriesToFilterItems
1672
+ });
1673
+ });
1674
+ if (filtersToLoadSagas) yield all(filtersToLoadSagas);
1675
+ }
1676
+ }
1677
+
1678
+ function* loadFilter(action) {
1679
+ const {
1680
+ facetKey,
1681
+ filterKey,
1682
+ filter,
1683
+ projectId,
1684
+ selectedKeys,
1685
+ context,
1686
+ mapper
1687
+ } = action;
1688
+ const {
1689
+ contentTypeId,
1690
+ customWhere,
1691
+ path
1692
+ } = filter;
1693
+ const createStateFrom = {
1694
+ type: LOAD_FILTERS_COMPLETE,
1695
+ context,
1696
+ error: undefined,
1697
+ facetKey,
1698
+ filterKey,
1699
+ payload: {},
1700
+ selectedKeys,
1701
+ mapper
1702
+ };
1703
+
1704
+ try {
1705
+ if (contentTypeId) {
1706
+ const versionStatus = yield select(selectVersionStatus);
1707
+ const query = filterQuery(Array.isArray(contentTypeId) ? contentTypeId : [contentTypeId], versionStatus, customWhere);
1708
+ const payload = yield cachedSearch.search(query, 0, projectId);
1709
+ if (!payload) throw new Error('No payload returned by search');
1710
+ if (payload.type === 'error') throw payload;
1711
+ createStateFrom.payload = payload;
1712
+ }
1713
+
1714
+ if (path) {
1715
+ const payload = yield cachedSearch.getTaxonomyNodeByPath(path, projectId);
1716
+ if (!payload) throw new Error(`No payload returned for taxonomy path: '${path}'`);
1717
+ if (payload.type === 'error') throw payload;
1718
+ createStateFrom.payload = payload;
1719
+ }
1720
+ } catch (error) {
1721
+ createStateFrom.type = LOAD_FILTERS_ERROR;
1722
+ createStateFrom.error = error;
1723
+ }
1724
+
1725
+ const nextAction = mapJson(createStateFrom, filterTemplate);
1726
+ yield put(nextAction);
1727
+ }
1728
+
1729
+ function* ensureSearch(action) {
1730
+ const {
1731
+ context,
1732
+ facet,
1733
+ debug
1734
+ } = action;
1735
+
1736
+ try {
1737
+ const state = yield select();
1738
+ const nextAction = { ...action,
1739
+ ogState: action.ogState || {
1740
+ search: state.search
1741
+ }
1742
+ };
1743
+ const [queryParams, runSearch] = generateQueryParams(nextAction, state);
1744
+ if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
1745
+
1746
+ if (runSearch) {
1747
+ yield put({
1748
+ type: EXECUTE_SEARCH,
1749
+ facet,
1750
+ context
1751
+ });
1752
+ yield call(executeSearch, { ...nextAction,
1753
+ context,
1754
+ facet,
1755
+ queryParams,
1756
+ debug
1757
+ });
1758
+ }
1759
+ } catch (error) {
1760
+ // eslint-disable-next-line import/namespace
1761
+ log.error(...['Error running search saga:', error, error.stack]);
1762
+ }
1763
+ }
1764
+
1765
+ function* executeSearch(action) {
1766
+ const {
1767
+ context,
1768
+ facet,
1769
+ queryParams,
1770
+ mappers
1771
+ } = action;
1772
+
1773
+ try {
1774
+ const state = yield select();
1775
+ let result = {};
1776
+ let featuredResult;
1777
+ let featuredQuery;
1778
+ const customApi = getCustomApi(state, facet, context, 'js');
1779
+
1780
+ if (customApi) {
1781
+ const apiParams = typeof mappers === 'object' && typeof mappers.customApi === 'function' && mappers.customApi(queryParams) || mapQueryParamsToCustomApi(queryParams);
1782
+ result.payload = yield callCustomApi(customApi, apiParams);
1783
+ result.duration = 1;
1784
+ } else {
1785
+ if (queryParams.featuredResults) {
1786
+ featuredQuery = searchQuery(queryParams, true);
1787
+ featuredResult = yield timedSearch(featuredQuery, queryParams.linkDepth, queryParams.projectId, queryParams.env); // eslint-disable-next-line require-atomic-updates
1788
+
1789
+ queryParams.excludeIds = getItemsFromResult(featuredResult).map(fi => {
1790
+ var _fi$sys;
1791
+
1792
+ return fi === null || fi === void 0 ? void 0 : (_fi$sys = fi.sys) === null || _fi$sys === void 0 ? void 0 : _fi$sys.id;
1793
+ }).filter(fi => typeof fi === 'string');
1794
+ }
1795
+
1796
+ const query = searchQuery(queryParams);
1797
+ result = yield timedSearch(query, queryParams.linkDepth, queryParams.projectId, queryParams.env);
1798
+ }
1799
+
1800
+ const createStateFrom = {
1801
+ action,
1802
+ featuredResult,
1803
+ pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
1804
+ prevResults: getResults(state, facet, action.context, 'js'),
1805
+ result,
1806
+ state
1807
+ };
1808
+ const nextAction = mapJson(createStateFrom, facetTemplate);
1809
+ yield put(nextAction);
1810
+ } catch (error) {
1811
+ // eslint-disable-next-line import/namespace
1812
+ log.error(...['Error running search saga:', error, error.stack]);
1813
+ }
1814
+ }
1815
+
1816
+ function* preloadOtherFacets(action) {
1817
+ const {
1818
+ preload,
1819
+ context,
1820
+ facet,
1821
+ debug
1822
+ } = action;
1823
+ const state = yield select();
1824
+ const currentFacet = getCurrentFacet(state);
1825
+
1826
+ if (!preload && facet === currentFacet && context !== Context.listings) {
1827
+ const allFacets = getFacets(state, 'js');
1828
+ const otherFacets = Object.keys(allFacets).filter(f => f !== currentFacet);
1829
+ yield all(otherFacets.map((preloadFacet = '') => {
1830
+ const preloadAction = { ...action,
1831
+ facet: preloadFacet,
1832
+ preload: true
1833
+ };
1834
+ const [queryParams, runSearch] = generateQueryParams(preloadAction, state);
1835
+ if (debug && (debug === true || debug.preloadOtherFacets)) debugExecuteSearch(preloadAction, state);
1836
+ return runSearch && call(executeSearch, { ...action,
1837
+ type: EXECUTE_SEARCH_PRELOAD,
1838
+ preload: true,
1839
+ facet: preloadFacet,
1840
+ queryParams
1841
+ });
1842
+ }));
1843
+ }
1844
+ }
1845
+
1846
+ function* updateCurrentTab(action) {
1847
+ const {
1848
+ id,
1849
+ mappers
1850
+ } = action;
1851
+ const state = yield select();
1852
+ const facets = getFacets(state, 'js');
1853
+ const tabs = getSearchTabs(state, 'js');
1854
+ let nextFacet = tabs === null || tabs === void 0 ? void 0 : tabs[id].currentFacet;
1855
+
1856
+ if (!nextFacet) {
1857
+ Object.entries(facets).map(([facetName, facet]) => {
1858
+ if (facet.tabId === id && (tabs === null || tabs === void 0 ? void 0 : tabs[id].defaultFacet) === facetName) nextFacet = facetName;
1859
+ });
1860
+ } // If the next Tab does not have a defaultFacet,
1861
+ // take the first facet for that tab
1862
+
1863
+
1864
+ if (!nextFacet) nextFacet = Object.entries(facets).filter(([, f]) => f.tabId === id)[0][0];
1865
+ yield put(withMappers(updateCurrentFacet$1(nextFacet), mappers));
1866
+ }
1867
+
1868
+ function* clearFilters(action) {
1869
+ const {
1870
+ mappers
1871
+ } = action;
1872
+ const uri = yield buildUri({}, mappers);
1873
+ yield put(navigate(uri));
1874
+ }
1875
+
1876
+ function* updateCurrentFacet(action) {
1877
+ const {
1878
+ facet,
1879
+ mappers
1880
+ } = action;
1881
+ const pageIndex = yield select(getPageIndex, facet);
1882
+ const uri = yield buildUri({
1883
+ facet,
1884
+ pageIndex
1885
+ }, mappers);
1886
+ yield put(navigate(uri));
1887
+ }
1888
+
1889
+ function* updateSearchTerm(action) {
1890
+ const {
1891
+ term,
1892
+ mappers
1893
+ } = action;
1894
+ const uri = yield buildUri({
1895
+ term
1896
+ }, mappers);
1897
+ yield put(navigate(uri));
1898
+ }
1899
+
1900
+ function* updateSortOrder(action) {
1901
+ const {
1902
+ orderBy,
1903
+ facet,
1904
+ mappers
1905
+ } = action;
1906
+ const uri = yield buildUri({
1907
+ orderBy,
1908
+ facet
1909
+ }, mappers);
1910
+ yield put(navigate(uri));
1911
+ }
1912
+
1913
+ function* updatePageIndex(action) {
1914
+ const {
1915
+ pageIndex,
1916
+ mappers
1917
+ } = action;
1918
+ const uri = yield buildUri({
1919
+ pageIndex
1920
+ }, mappers);
1921
+ yield put(navigate(uri));
1922
+ }
1923
+
1924
+ function* applySearchFilter(action) {
1925
+ const {
1926
+ mappers
1927
+ } = action;
1928
+ const uri = yield buildUri({}, mappers);
1929
+ yield put(navigate(uri));
1930
+ }
1931
+
1932
+ function* buildUri({
1933
+ facet,
1934
+ orderBy,
1935
+ pageIndex = 0,
1936
+ term
1937
+ }, mappers) {
1938
+ const state = yield select();
1939
+ const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
1940
+ const uri = mapUri({
1941
+ state,
1942
+ facet,
1943
+ orderBy,
1944
+ pageIndex,
1945
+ term
1946
+ }); // return uri;
1947
+
1948
+ return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
1949
+ }
1950
+
1951
+ export { APPLY_CONFIG as $, clearFilters$1 as A, updateCurrentFacet$1 as B, updateCurrentTab$1 as C, updatePageIndex$1 as D, updateSearchTerm$1 as E, updateSelectedFilters as F, updateSortOrder$1 as G, selectListing as H, mapStateToSearchUri as I, Context as J, selectFacets as K, triggerSearch as L, getFilters as M, toArray as N, UPDATE_SELECTED_FILTERS as O, UPDATE_SEARCH_TERM as P, UPDATE_PAGE_INDEX as Q, SET_SEARCH_ENTRIES as R, SET_SEARCH_FILTERS as S, SET_ROUTE_FILTERS as T, UPDATE_SORT_ORDER as U, LOAD_FILTERS_COMPLETE as V, LOAD_FILTERS_ERROR as W, LOAD_FILTERS as X, EXECUTE_SEARCH_ERROR as Y, EXECUTE_SEARCH as Z, CLEAR_FILTERS as _, customWhereExpressions as a, actions as a0, expressions as a1, queries as a2, selectors as a3, types as a4, doSearch as a5, setRouteFilters as a6, searchSagas as a7, getPageIndex as b, contentTypeIdExpression as c, defaultExpressions as d, getCurrentTab as e, filterExpressions as f, getCurrentFacet as g, getFacet as h, getTabFacets as i, getFacetsTotalCount as j, getFacetTitles as k, getFeaturedResults as l, getRenderableFilters as m, getIsLoading as n, orderByExpression as o, getPaging as p, getPageIsLoading as q, getResults as r, getSearchTerm as s, termExpressions as t, getSearchTotalCount as u, getSelectedFilters as v, getQueryParameter as w, getTabsAndFacets as x, getTotalCount as y, withMappers as z };
1952
+ //# sourceMappingURL=sagas-a22fc54a.js.map