@usereactify/search 5.47.0 → 5.48.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/package.json +1 -1
  3. package/dist/src/components/Filter/Filter.js +45 -10
  4. package/dist/src/components/Filter/Filter.js.map +1 -1
  5. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +1 -1
  6. package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
  7. package/dist/src/components/Result/Results.d.ts +0 -2
  8. package/dist/src/components/Result/Results.js +9 -21
  9. package/dist/src/components/Result/Results.js.map +1 -1
  10. package/dist/src/components/Sensor/SensorCollection.js +8 -80
  11. package/dist/src/components/Sensor/SensorCollection.js.map +1 -1
  12. package/dist/src/components/Sensor/SensorCustom.js +6 -2
  13. package/dist/src/components/Sensor/SensorCustom.js.map +1 -1
  14. package/dist/src/components/Sensor/SensorInventoryAvailable.js +8 -44
  15. package/dist/src/components/Sensor/SensorInventoryAvailable.js.map +1 -1
  16. package/dist/src/components/Sensor/SensorPublished.js +7 -27
  17. package/dist/src/components/Sensor/SensorPublished.js.map +1 -1
  18. package/dist/src/components/Sensor/SensorSort.js +10 -203
  19. package/dist/src/components/Sensor/SensorSort.js.map +1 -1
  20. package/dist/src/hooks/reactivesearch/index.d.ts +0 -6
  21. package/dist/src/hooks/reactivesearch/index.js +0 -6
  22. package/dist/src/hooks/reactivesearch/index.js.map +1 -1
  23. package/dist/src/hooks/usePagination.js +1 -1
  24. package/dist/src/hooks/usePagination.js.map +1 -1
  25. package/dist/src/hooks/useSortBy.js +14 -17
  26. package/dist/src/hooks/useSortBy.js.map +1 -1
  27. package/dist/src/utility/curation.d.ts +7 -0
  28. package/dist/src/utility/curation.js +85 -0
  29. package/dist/src/utility/curation.js.map +1 -0
  30. package/dist/src/utility/filters.d.ts +6 -0
  31. package/dist/src/utility/filters.js +36 -0
  32. package/dist/src/utility/filters.js.map +1 -0
  33. package/dist/src/utility/props.d.ts +143 -10
  34. package/dist/src/utility/props.js +241 -25
  35. package/dist/src/utility/props.js.map +1 -1
  36. package/dist/src/utility/server.js +1 -1
  37. package/dist/src/utility/server.js.map +1 -1
  38. package/dist/src/utility/sortOption.d.ts +22 -0
  39. package/dist/src/utility/sortOption.js +198 -0
  40. package/dist/src/utility/sortOption.js.map +1 -0
  41. package/package.json +1 -1
  42. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.d.ts +0 -84
  43. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js +0 -21
  44. package/dist/src/hooks/reactivesearch/useReactiveFilterListProps.js.map +0 -1
  45. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.d.ts +0 -86
  46. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js +0 -32
  47. package/dist/src/hooks/reactivesearch/useReactiveFilterRangeProps.js.map +0 -1
  48. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.d.ts +0 -77
  49. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js +0 -124
  50. package/dist/src/hooks/reactivesearch/useReactiveFilterSharedProps.js.map +0 -1
  51. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.d.ts +0 -83
  52. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js +0 -28
  53. package/dist/src/hooks/reactivesearch/useReactiveFilterSliderProps.js.map +0 -1
  54. package/dist/src/hooks/reactivesearch/useReactiveReactProp.d.ts +0 -4
  55. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js +0 -32
  56. package/dist/src/hooks/reactivesearch/useReactiveReactProp.js.map +0 -1
  57. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.d.ts +0 -6
  58. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js +0 -38
  59. package/dist/src/hooks/reactivesearch/useReactiveReactiveListProps.js.map +0 -1
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
3
+ exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsSensorSort = exports.getPropsSensorInventoryAvailable = exports.getPropsSensorPublished = exports.getPropsSensorCollection = exports.getPropsSensorCustom = exports.getPropsSensors = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
4
4
  const reactivesearch_1 = require("@appbaseio/reactivesearch");
5
5
  const components_1 = require("../components");
6
+ const curation_1 = require("./curation");
7
+ const sortOption_1 = require("./sortOption");
8
+ const filters_1 = require("./filters");
6
9
  const getPropsFilterGroup = (options) => {
10
+ var _a, _b;
7
11
  return [
8
- ...options.filterGroup.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption)),
12
+ ...(_b = (_a = options.filterGroup) === null || _a === void 0 ? void 0 : _a.options.map((filterGroupOption) => (0, exports.getPropsFilterGroupOption)(options, filterGroupOption))) !== null && _b !== void 0 ? _b : [],
13
+ ...(0, exports.getPropsSensors)(options),
9
14
  (0, exports.getPropsResults)(options),
10
15
  ];
11
16
  };
@@ -27,12 +32,226 @@ const getPropsFilterGroupOption = (options, filterGroupOption) => {
27
32
  return Object.assign(Object.assign({}, sharedProps), filterProps);
28
33
  };
29
34
  exports.getPropsFilterGroupOption = getPropsFilterGroupOption;
35
+ const getPropsSensors = (options) => {
36
+ return [
37
+ ...(0, exports.getPropsSensorCustom)(options),
38
+ (0, exports.getPropsSensorCollection)(options),
39
+ (0, exports.getPropsSensorPublished)(options),
40
+ (0, exports.getPropsSensorInventoryAvailable)(options),
41
+ (0, exports.getPropsSensorSort)(options),
42
+ ].filter(Boolean);
43
+ };
44
+ exports.getPropsSensors = getPropsSensors;
45
+ const getPropsSensorCustom = (options) => {
46
+ const sensors = options.provider.mode === "collection" ? options.config.sensors.collection : options.config.sensors.search;
47
+ return sensors.map((sensor, index) => ({
48
+ componentId: `SensorCustom_${index}`,
49
+ customQuery: () => sensor,
50
+ source: reactivesearch_1.ReactiveComponent,
51
+ }));
52
+ };
53
+ exports.getPropsSensorCustom = getPropsSensorCustom;
54
+ const getPropsSensorCollection = (options) => {
55
+ if (options.provider.mode !== "collection") {
56
+ return null;
57
+ }
58
+ return {
59
+ componentId: "SensorCollection",
60
+ customQuery: () => {
61
+ if (options.provider.mode !== "collection") {
62
+ return null;
63
+ }
64
+ const conditions = [];
65
+ if (options.provider.market) {
66
+ conditions.push({
67
+ nested: {
68
+ path: "curations",
69
+ query: {
70
+ bool: {
71
+ should: [
72
+ {
73
+ nested: {
74
+ path: "collections",
75
+ query: {
76
+ term: {
77
+ "collections.handle.keyword": options.provider.collectionHandle,
78
+ },
79
+ },
80
+ },
81
+ },
82
+ {
83
+ nested: {
84
+ path: "curations",
85
+ query: {
86
+ term: {
87
+ "curations.collectionHandle.keyword": options.provider.collectionHandle,
88
+ },
89
+ },
90
+ },
91
+ },
92
+ ],
93
+ must: [{
94
+ nested: {
95
+ path: "curations",
96
+ query: {
97
+ term: {
98
+ "curations.markets.keyword": options.provider.market,
99
+ },
100
+ },
101
+ },
102
+ }]
103
+ },
104
+ },
105
+ },
106
+ });
107
+ }
108
+ return {
109
+ query: {
110
+ bool: {
111
+ should: [
112
+ {
113
+ nested: {
114
+ path: "collections",
115
+ query: {
116
+ term: {
117
+ "collections.handle.keyword": options.provider.collectionHandle,
118
+ },
119
+ },
120
+ },
121
+ },
122
+ {
123
+ nested: {
124
+ path: "curations",
125
+ query: {
126
+ term: {
127
+ "curations.collectionHandle.keyword": options.provider.collectionHandle,
128
+ },
129
+ },
130
+ },
131
+ },
132
+ ],
133
+ },
134
+ },
135
+ };
136
+ },
137
+ source: reactivesearch_1.ReactiveComponent,
138
+ };
139
+ };
140
+ exports.getPropsSensorCollection = getPropsSensorCollection;
141
+ const getPropsSensorPublished = (options) => {
142
+ return {
143
+ componentId: "SensorPublished",
144
+ customQuery: () => {
145
+ if (options.provider.market) {
146
+ return {
147
+ query: {
148
+ bool: {
149
+ must: [{
150
+ match: {
151
+ markets: options.provider.market,
152
+ },
153
+ }, {
154
+ match: {
155
+ published: true,
156
+ },
157
+ }]
158
+ },
159
+ },
160
+ };
161
+ }
162
+ return {
163
+ query: {
164
+ match: {
165
+ published: true,
166
+ },
167
+ },
168
+ };
169
+ },
170
+ source: reactivesearch_1.ReactiveComponent,
171
+ };
172
+ };
173
+ exports.getPropsSensorPublished = getPropsSensorPublished;
174
+ const getPropsSensorInventoryAvailable = (options) => {
175
+ const filterStack = (0, filters_1.getFilterStack)(options);
176
+ if (!filterStack || "show_all" === filterStack.inventoryVisibility) {
177
+ return null;
178
+ }
179
+ return {
180
+ componentId: "SensorInventoryAvailable",
181
+ customQuery: () => ({
182
+ query: {
183
+ bool: {
184
+ should: [
185
+ {
186
+ bool: {
187
+ must: [
188
+ {
189
+ term: {
190
+ type: {
191
+ value: "product",
192
+ },
193
+ },
194
+ },
195
+ {
196
+ nested: {
197
+ path: "variants",
198
+ query: {
199
+ match: { "variants.available": true },
200
+ },
201
+ },
202
+ },
203
+ ],
204
+ },
205
+ },
206
+ ...(options.provider.mode === "instant-search"
207
+ ? []
208
+ : [
209
+ {
210
+ term: {
211
+ type: {
212
+ value: "callout",
213
+ },
214
+ },
215
+ },
216
+ ]),
217
+ ],
218
+ minimum_should_match: "1",
219
+ },
220
+ },
221
+ }),
222
+ source: reactivesearch_1.ReactiveComponent,
223
+ };
224
+ };
225
+ exports.getPropsSensorInventoryAvailable = getPropsSensorInventoryAvailable;
226
+ const getPropsSensorSort = (options) => {
227
+ const curation = (0, curation_1.getCuration)(options);
228
+ const sortOption = (0, sortOption_1.getSortOption)(options);
229
+ const sort = (0, sortOption_1.generateSortSort)({
230
+ provider: options.provider,
231
+ config: options.config,
232
+ curation: curation,
233
+ sortOption: sortOption,
234
+ });
235
+ const query = (0, sortOption_1.generateSortQuery)({
236
+ sortOption: sortOption,
237
+ curation: curation,
238
+ });
239
+ return {
240
+ componentId: "SensorInventoryAvailable",
241
+ customQuery: () => ({
242
+ sort,
243
+ query,
244
+ }),
245
+ source: reactivesearch_1.ReactiveComponent,
246
+ };
247
+ };
248
+ exports.getPropsSensorSort = getPropsSensorSort;
30
249
  const getPropsResults = (options) => {
31
- var _a, _b;
250
+ var _a, _b, _c, _d, _e;
32
251
  const includeFieldsProp = (() => {
33
252
  var _a;
34
253
  return [
35
- ...((_a = options.includeFields) !== null && _a !== void 0 ? _a : []),
254
+ ...((_a = options.provider.includeFields) !== null && _a !== void 0 ? _a : []),
36
255
  "id",
37
256
  "title",
38
257
  "type",
@@ -45,10 +264,10 @@ const getPropsResults = (options) => {
45
264
  })();
46
265
  const excludeFieldsProp = (() => {
47
266
  var _a;
48
- return [...((_a = options.excludeFields) !== null && _a !== void 0 ? _a : [])];
267
+ return [...((_a = options.provider.excludeFields) !== null && _a !== void 0 ? _a : [])];
49
268
  })();
50
269
  return {
51
- size: options.filterGroup.pageSize,
270
+ size: (_c = (_a = options.pageSize) !== null && _a !== void 0 ? _a : (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.pageSize) !== null && _c !== void 0 ? _c : 20,
52
271
  URLParams: true,
53
272
  showLoader: false,
54
273
  dataField: "title",
@@ -56,18 +275,18 @@ const getPropsResults = (options) => {
56
275
  react: (0, exports.getPropsReact)(options),
57
276
  includeFields: includeFieldsProp,
58
277
  excludeFields: excludeFieldsProp,
59
- // scrollTarget: options.scrollTarget,
278
+ scrollTarget: options.scrollTarget,
60
279
  componentId: "page",
61
280
  scrollOnChange: false,
62
- pagination: ((_a = options.filterGroup) === null || _a === void 0 ? void 0 : _a.paginationType) !== "infinite_scroll",
63
- infiniteScroll: ((_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.paginationType) === "infinite_scroll",
281
+ pagination: ((_d = options.filterGroup) === null || _d === void 0 ? void 0 : _d.paginationType) !== "infinite_scroll",
282
+ infiniteScroll: ((_e = options.filterGroup) === null || _e === void 0 ? void 0 : _e.paginationType) === "infinite_scroll",
64
283
  renderNoResults: () => null,
65
284
  source: reactivesearch_1.ReactiveList,
66
285
  };
67
286
  };
68
287
  exports.getPropsResults = getPropsResults;
69
288
  const getPropsReact = (options, filterGroupOption) => {
70
- const sensorIds = (0, components_1.SENSOR_IDS)(options.mode, options.config);
289
+ const sensorIds = (0, components_1.SENSOR_IDS)(options.provider.mode, options.config);
71
290
  const reactProp = (() => {
72
291
  var _a, _b, _c;
73
292
  if (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.settingsShowEmptyValues) {
@@ -78,7 +297,7 @@ const getPropsReact = (options, filterGroupOption) => {
78
297
  return {
79
298
  and: [
80
299
  ...sensorIds,
81
- ...((_a = options.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
300
+ ...((_a = options.provider.additionalComponentIds) !== null && _a !== void 0 ? _a : []),
82
301
  ...((_c = (_b = options.filterGroup) === null || _b === void 0 ? void 0 : _b.options.map((filter) => filter.handle)) !== null && _c !== void 0 ? _c : []),
83
302
  ].filter((handle) => handle !== (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.handle)),
84
303
  };
@@ -227,21 +446,18 @@ const getPropsFilterList = (filterGroupOption) => {
227
446
  };
228
447
  exports.getPropsFilterList = getPropsFilterList;
229
448
  const getPropsFilterRange = (filterGroupOption) => {
230
- var _a, _b;
231
- const data = (() => {
232
- var _a, _b;
233
- return ((_b = (_a = filterGroupOption.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
234
- const [label, start, end] = option.split(":");
235
- return {
236
- label: label,
237
- start: start ? parseInt(start) : 0,
238
- end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
239
- };
240
- })) !== null && _b !== void 0 ? _b : []);
241
- })();
449
+ var _a, _b, _c, _d;
450
+ const data = (_b = (_a = filterGroupOption.displayRangeOptions) === null || _a === void 0 ? void 0 : _a.map((option) => {
451
+ const [label, start, end] = option.split(":");
452
+ return {
453
+ label: label,
454
+ start: start ? parseInt(start) : 0,
455
+ end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,
456
+ };
457
+ })) !== null && _b !== void 0 ? _b : [];
242
458
  return {
243
- queryFormat: (_a = filterGroupOption.settingsFilterLogic) !== null && _a !== void 0 ? _a : "or",
244
- showFilter: (_b = filterGroupOption.settingsShowFilter) !== null && _b !== void 0 ? _b : true,
459
+ queryFormat: (_c = filterGroupOption.settingsFilterLogic) !== null && _c !== void 0 ? _c : "or",
460
+ showFilter: (_d = filterGroupOption.settingsShowFilter) !== null && _d !== void 0 ? _d : true,
245
461
  showRadio: false,
246
462
  showCheckbox: false,
247
463
  data: data,
@@ -1 +1 @@
1
- {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.tsx"],"names":[],"mappings":";;;AAAA,8DAA4H;AAC5H,8CAA2C;AAapC,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;IAC9E,OAAO;QACL,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAChH,IAAA,uBAAe,EAAC,OAAO,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAwC,EAAE,iBAAqC,EAAE,EAAE;IAC3H,IAAI,WAAW,GAA4B,EAAE,CAAC;IAE9C,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,EAAE;QAC9C,WAAW,GAAG,IAAA,4BAAoB,EAAC,iBAAiB,CAAC,CAAC;KACvD;IAED,IAAI,iBAAiB,CAAC,WAAW,KAAK,QAAQ,IAAI,iBAAiB,CAAC,WAAW,K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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO;gBACL,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB;aACnD,CAAC;QACJ,CAAC,CAAC,mCAAI,EAAE,CACT,CAAC;IACJ,CAAC,CAAC,EAAE,CAAC;IAEL,OAAO;QACL,WAAW,EAAE,MAAA,iBAAiB,CAAC,mBAAmB,mCAAI,IAAI;QAC1D,UAAU,EAAE,MAAA,iBAAiB,CAAC,kBAAkB,mCAAI,IAAI;QACxD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,mBAAmB,uBAqB9B;AAEK,MAAM,oBAAoB,GAAG,CAAC,iBAAqC,EAAE,EAAE;IAC5E,OAAO,EAAE,CAAA;AACX,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@appbaseio/reactivesearch\";\nimport { SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterOption } from \"../types\";\n\nexport type GeneratePropsFilterGroupOptions = {\n mode: \"search\" | \"instant-search\" | \"collection\";\n config: Config;\n filterGroup: ConfigFilter;\n\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n filterProps = getPropsFilterSlider(filterGroupOption);\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.excludeFields ?? [])];\n })();\n\n return {\n size: options.filterGroup.pageSize,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n // scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterOption) => {\n const sensorIds = SENSOR_IDS(options.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterOption) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterOption) => {\n const data = (() => {\n return (\n filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? []\n );\n })();\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterOption) => {\n return {}\n};"]}
1
+ {"version":3,"file":"props.js","sourceRoot":"","sources":["../../../src/utility/props.ts"],"names":[],"mappings":";;;AAAA,8DAA4H;AAC5H,8CAAwE;AAExE,yCAAyC;AACzC,6CAAkF;AAClF,uCAA2C;AAapC,MAAM,mBAAmB,GAAG,CAAC,OAAwC,EAAE,EAAE;;IAC9E,OAAO;QACL,GAAG,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,OAAO,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,IAAA,iCAAyB,EAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,mC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A,iBAAiB,CAAC,kBAAkB,mCAAI,KAAK;QACzD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B;AAEK,MAAM,mBAAmB,GAAG,CAAC,iBAAqC,EAAE,EAAE;;IAC3E,MAAM,IAAI,GAAG,MAAA,MAAA,iBAAiB,CAAC,mBAAmB,0CAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACjE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB;SACnD,CAAC;IACJ,CAAC,CAAC,mCAAI,EAAE,CAAC;IAET,OAAO;QACL,WAAW,EAAE,MAAA,iBAAiB,CAAC,mBAAmB,mCAAI,IAAI;QAC1D,UAAU,EAAE,MAAA,iBAAiB,CAAC,kBAAkB,mCAAI,IAAI;QACxD,SAAS,EAAE,KAAK;QAChB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B;AAEK,MAAM,oBAAoB,GAAG,CAAC,iBAAqC,EAAE,EAAE;IAC5E,OAAO,EAAE,CAAA;AACX,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B","sourcesContent":["import { MultiList, MultiRange, ReactiveComponent, ReactiveList, SingleList, SingleRange } from \"@appbaseio/reactivesearch\";\nimport { ReactifySearchProviderProps, SENSOR_IDS } from \"../components\";\nimport { Config, ConfigFilter, ConfigFilterOption } from \"../types\";\nimport { getCuration } from \"./curation\";\nimport { generateSortQuery, generateSortSort, getSortOption } from \"./sortOption\";\nimport { getFilterStack } from \"./filters\";\n\nexport type GeneratePropsFilterGroupOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n filterGroup?: ConfigFilter;\n};\n\nexport type GeneratePropsSensorOptions = {\n provider: ReactifySearchProviderProps;\n config: Config;\n};\n\nexport const getPropsFilterGroup = (options: GeneratePropsFilterGroupOptions) => {\n return [\n ...options.filterGroup?.options.map((filterGroupOption) => getPropsFilterGroupOption(options, filterGroupOption)) ?? [],\n ...getPropsSensors(options),\n getPropsResults(options),\n ];\n};\n\nexport const getPropsFilterGroupOption = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n let filterProps: Record<string, unknown> = {};\n\n if (filterGroupOption.displayType === \"slider\") {\n filterProps = getPropsFilterSlider(filterGroupOption);\n }\n\n if (filterGroupOption.displayType === \"single\" || filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n filterProps = getPropsFilterRange(filterGroupOption);\n } else {\n filterProps = getPropsFilterList(filterGroupOption);\n }\n }\n\n const sharedProps = getPropsShared(options, filterGroupOption);\n\n return {\n ...sharedProps,\n ...filterProps,\n };\n};\n\nexport const getPropsSensors = (options: GeneratePropsSensorOptions) => {\n return [\n ...getPropsSensorCustom(options),\n getPropsSensorCollection(options),\n getPropsSensorPublished(options),\n getPropsSensorInventoryAvailable(options),\n getPropsSensorSort(options),\n ].filter(Boolean);\n}\n\nexport const getPropsSensorCustom = (options: GeneratePropsSensorOptions) => {\n const sensors = options.provider.mode === \"collection\" ? options.config.sensors.collection : options.config.sensors.search;\n\n return sensors.map((sensor, index) => ({\n componentId: `SensorCustom_${index}`,\n customQuery: () => sensor,\n source: ReactiveComponent,\n }));\n}\n\nexport const getPropsSensorCollection = (options: GeneratePropsSensorOptions) => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n \n return {\n componentId: \"SensorCollection\",\n customQuery: () => {\n if (options.provider.mode !== \"collection\") {\n return null;\n }\n\n const conditions: Array<unknown> = [];\n\n if (options.provider.market) {\n conditions.push({\n nested: {\n path: \"curations\",\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n must: [{\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.markets.keyword\": options.provider.market,\n },\n },\n },\n }]\n },\n },\n },\n });\n }\n \n return {\n query: {\n bool: {\n should: [\n {\n nested: {\n path: \"collections\",\n query: {\n term: {\n \"collections.handle.keyword\": options.provider.collectionHandle,\n },\n },\n },\n },\n {\n nested: {\n path: \"curations\",\n query: {\n term: {\n \"curations.collectionHandle.keyword\":\n options.provider.collectionHandle,\n },\n },\n },\n },\n ],\n },\n },\n } \n },\n source: ReactiveComponent,\n };\n}\n\nexport const getPropsSensorPublished = (options: GeneratePropsSensorOptions) => {\n return {\n componentId: \"SensorPublished\",\n customQuery: () => {\n if (options.provider.market) {\n return {\n query: {\n bool: {\n must:[{\n match: {\n markets: options.provider.market,\n },\n },{\n match: {\n published: true,\n },\n }]\n },\n },\n };\n }\n\n return {\n query: {\n match: {\n published: true,\n },\n },\n }\n },\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorInventoryAvailable = (options: GeneratePropsSensorOptions) => {\n const filterStack = getFilterStack(options);\n\n if (!filterStack || \"show_all\" === filterStack.inventoryVisibility) {\n return null;\n }\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n query: {\n bool: {\n should: [\n {\n bool: {\n must: [\n {\n term: {\n type: {\n value: \"product\",\n },\n },\n },\n {\n nested: {\n path: \"variants\",\n query: {\n match: { \"variants.available\": true },\n },\n },\n },\n ],\n },\n },\n ...(options.provider.mode === \"instant-search\"\n ? []\n : [\n {\n term: {\n type: {\n value: \"callout\",\n },\n },\n },\n ]),\n ],\n minimum_should_match: \"1\",\n },\n },\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsSensorSort = (options: GeneratePropsSensorOptions & { searchTerm?: string; sortOption?: string; }) => {\n const curation = getCuration(options);\n const sortOption = getSortOption(options);\n\n const sort = generateSortSort({\n provider: options.provider,\n config: options.config,\n curation: curation,\n sortOption: sortOption,\n });\n const query = generateSortQuery({\n sortOption: sortOption,\n curation: curation,\n });\n\n return {\n componentId: \"SensorInventoryAvailable\",\n customQuery: () => ({\n sort,\n query,\n }),\n source: ReactiveComponent,\n }\n}\n\nexport const getPropsResults = (options: GeneratePropsFilterGroupOptions & { scrollTarget?: string | Element | HTMLDocument; pageSize?: number; }) => {\n const includeFieldsProp = (() => {\n return [\n ...(options.provider.includeFields ?? []),\n \"id\",\n \"title\",\n \"type\",\n \"handle\",\n \"image\",\n \"variants.id\",\n \"variants.presentment_prices\",\n \"callout\",\n ];\n })();\n const excludeFieldsProp = (() => {\n return [...(options.provider.excludeFields ?? [])];\n })();\n\n return {\n size: options.pageSize ?? options.filterGroup?.pageSize ?? 20,\n URLParams: true,\n showLoader: false,\n dataField: \"title\",\n showResultStats: false,\n react: getPropsReact(options),\n includeFields: includeFieldsProp,\n excludeFields: excludeFieldsProp,\n scrollTarget: options.scrollTarget,\n componentId: \"page\", // this sets ?page= in the URL\n scrollOnChange: false, // @todo make this better, it's really janky when enabled\n pagination: options.filterGroup?.paginationType !== \"infinite_scroll\",\n infiniteScroll: options.filterGroup?.paginationType === \"infinite_scroll\",\n renderNoResults: () => null, // always use only render, otherwise both are shown\n source: ReactiveList,\n }\n}\n\nexport const getPropsReact = (options: GeneratePropsFilterGroupOptions, filterGroupOption?: ConfigFilterOption) => {\n const sensorIds = SENSOR_IDS(options.provider.mode, options.config);\n const reactProp = (() => {\n if (filterGroupOption?.settingsShowEmptyValues) {\n return {\n and: sensorIds,\n };\n }\n\n return {\n and: [\n ...sensorIds,\n ...(options.provider.additionalComponentIds ?? []),\n ...(options.filterGroup?.options.map((filter) => filter.handle) ?? []),\n ].filter((handle) => handle !== filterGroupOption?.handle),\n };\n })();\n\n return reactProp;\n};\n\nexport const getPropsShared = (options: GeneratePropsFilterGroupOptions, filterGroupOption: ConfigFilterOption) => {\n const reactProp = getPropsReact(options, filterGroupOption);\n const nestedFieldProp = (() => {\n const nestedFields = [\"variants\"];\n const topField = filterGroupOption.field.split(\".\")[0];\n if (nestedFields.includes(topField)) {\n return topField;\n }\n return undefined;\n })();\n const customQueryProp = (() => {\n if (\n !filterGroupOption.settingsHideUnavailable ||\n !filterGroupOption.field.startsWith(\"variants.\")\n )\n return undefined;\n\n return (value?: string | string[]) => {\n if (!value) return {};\n\n // reactivesearch sometimes returns string, sometimes string[]\n const valueArray = \"string\" === typeof value ? [value] : value;\n\n if (0 === valueArray.length) return {};\n\n return {\n query: {\n nested: {\n path: \"variants\",\n query: {\n bool: {\n must: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n terms: {\n [filterGroupOption.field]: valueArray,\n },\n },\n ],\n },\n },\n },\n },\n };\n };\n })();\n const defaultQueryProp = (() => {\n if (!filterGroupOption.field.startsWith(\"variants.\")) {\n return undefined;\n }\n\n // override the aggregation query to filter the results by the variants.available attribute\n return () => {\n return {\n aggs: {\n reactivesearch_nested: {\n nested: { path: \"variants\" },\n aggs: {\n reactify_nested_outer: {\n filter: {\n bool: {\n minimum_should_match: 1,\n should: [\n {\n match: {\n \"variants.available\": \"true\",\n },\n },\n {\n match: {\n \"variants.available\": filterGroupOption.settingsHideUnavailable\n ? \"true\"\n : \"false\",\n },\n },\n ],\n },\n },\n aggs: {\n [filterGroupOption.field]: {\n terms: {\n field: filterGroupOption.field,\n size: 100,\n order: { _count: \"desc\" },\n },\n aggs: {\n parent_docs: { reverse_nested: {} },\n },\n },\n },\n },\n },\n },\n },\n };\n };\n })();\n const sourceProp = (() => {\n if (filterGroupOption.displayType === \"slider\") {\n return ReactiveComponent;\n }\n if (filterGroupOption.displayType === \"single\") {\n if (filterGroupOption.displayView === \"range\") {\n return SingleRange;\n }\n return SingleList;\n }\n if (filterGroupOption.displayType === \"multi\") {\n if (filterGroupOption.displayView === \"range\") {\n return MultiRange;\n }\n return MultiList;\n }\n \n return;\n })();\n\n return {\n URLParams: true,\n componentId: filterGroupOption.handle,\n dataField: filterGroupOption.field,\n filterLabel: filterGroupOption.name,\n nestedField: nestedFieldProp,\n customQuery: customQueryProp,\n defaultQuery: defaultQueryProp,\n source: sourceProp,\n react: reactProp,\n }\n};\n\nexport const getPropsFilterList = (filterGroupOption: ConfigFilterOption) => {\n return {\n size: parseInt(filterGroupOption.displaySize) || undefined,\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showLoadMore: filterGroupOption.settingsShowMore ?? false,\n showSearch: filterGroupOption.settingsShowSearch ?? false,\n showRadio: false,\n showCheckbox: false,\n };\n};\n\nexport const getPropsFilterRange = (filterGroupOption: ConfigFilterOption) => {\n const data = filterGroupOption.displayRangeOptions?.map((option) => {\n const [label, start, end] = option.split(\":\");\n return {\n label: label,\n start: start ? parseInt(start) : 0,\n end: end ? parseInt(end) : Number.MAX_SAFE_INTEGER,\n };\n }) ?? [];\n\n return {\n queryFormat: filterGroupOption.settingsFilterLogic ?? \"or\",\n showFilter: filterGroupOption.settingsShowFilter ?? true,\n showRadio: false,\n showCheckbox: false,\n data: data,\n };\n};\n\nexport const getPropsFilterSlider = (filterGroupOption: ConfigFilterOption) => {\n return {}\n};"]}
@@ -20,7 +20,7 @@ const props_1 = require("./props");
20
20
  const generateProviderProps = (options) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  const config = yield (0, config_1.getConfig)(options.shopifyPermanentDomain);
22
22
  const props = (0, props_1.getPropsFilterGroup)({
23
- mode: options.mode,
23
+ provider: options,
24
24
  config: config,
25
25
  filterGroup: config.filters[0],
26
26
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/utility/server.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,kFAAsE;AAEtE,qCAAqC;AACrC,mCAA8C;AAIvC,MAAM,qBAAqB,GAAG,CAAO,OAAoC,EAAwC,EAAE;IACxH,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC;QAChC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/B,CAAC,CAAC;IAEH,uCACK,OAAO,KACV,OAAO,EAAE;YACP,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM,IAAA,gBAAkB,EAAC,KAAK,EAAE,IAAI,EAAE;gBAC3C,GAAG,EAAE,MAAM,CAAC,KAAK;gBACjB,GAAG,EAAE,MAAM,CAAC,QAAQ;aACrB,CAAC;SACH,IACF;AACH,CAAC,CAAA,CAAA;AAlBY,QAAA,qBAAqB,yBAkBjC","sourcesContent":["// @ts-expect-error missing types\nimport initReactivesearch from \"@appbaseio/reactivesearch/lib/server\";\n\nimport { getConfig } from \"./config\";\nimport { getPropsFilterGroup } from \"./props\";\nimport { ReactifySearchProviderProps } from \"../components\";\n\n\nexport const generateProviderProps = async (options: ReactifySearchProviderProps): Promise<ReactifySearchProviderProps> => {\n const config = await getConfig(options.shopifyPermanentDomain);\n const props = getPropsFilterGroup({\n mode: options.mode,\n config: config,\n filterGroup: config.filters[0],\n });\n\n return {\n ...options,\n preload: {\n config: config,\n state: await initReactivesearch(props, null, {\n app: config.index,\n url: config.endpoint,\n }),\n }\n }\n}"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/utility/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,kFAAsE;AAEtE,qCAAqC;AACrC,mCAA8C;AAIvC,MAAM,qBAAqB,GAAG,CAAO,OAAoC,EAAwC,EAAE;IACxH,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,IAAA,2BAAmB,EAAC;QAChC,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;KAC/B,CAAC,CAAC;IAEH,uCACK,OAAO,KACV,OAAO,EAAE;YACP,MAAM,EAAE,MAAM;YACd,KAAK,EAAE,MAAM,IAAA,gBAAkB,EAAC,KAAK,EAAE,IAAI,EAAE;gBAC3C,GAAG,EAAE,MAAM,CAAC,KAAK;gBACjB,GAAG,EAAE,MAAM,CAAC,QAAQ;aACrB,CAAC;SACH,IACF;AACH,CAAC,CAAA,CAAA;AAlBY,QAAA,qBAAqB,yBAkBjC","sourcesContent":["// @ts-expect-error missing types\nimport initReactivesearch from \"@appbaseio/reactivesearch/lib/server\";\n\nimport { getConfig } from \"./config\";\nimport { getPropsFilterGroup } from \"./props\";\nimport { ReactifySearchProviderProps } from \"../components\";\n\n\nexport const generateProviderProps = async (options: ReactifySearchProviderProps): Promise<ReactifySearchProviderProps> => {\n const config = await getConfig(options.shopifyPermanentDomain);\n const props = getPropsFilterGroup({\n provider: options,\n config: config,\n filterGroup: config.filters[0],\n });\n\n return {\n ...options,\n preload: {\n config: config,\n state: await initReactivesearch(props, null, {\n app: config.index,\n url: config.endpoint,\n }),\n }\n }\n}"]}
@@ -0,0 +1,22 @@
1
+ import { ReactifySearchProviderProps } from "../components";
2
+ import { Config, ConfigCuration, ConfigSort } from "../types";
3
+ export declare const getSortOptions: (options: {
4
+ provider: ReactifySearchProviderProps;
5
+ config: Config;
6
+ sortOption?: string;
7
+ }) => ConfigSort[];
8
+ export declare const getSortOption: (options: {
9
+ provider: ReactifySearchProviderProps;
10
+ config: Config;
11
+ sortOption?: string;
12
+ }) => ConfigSort;
13
+ export declare const generateSortSort: (options: {
14
+ provider: ReactifySearchProviderProps;
15
+ config: Config;
16
+ curation?: ConfigCuration;
17
+ sortOption?: ConfigSort;
18
+ }) => any[];
19
+ export declare const generateSortQuery: (options: {
20
+ curation?: ConfigCuration;
21
+ sortOption?: ConfigSort;
22
+ }) => Record<string, any> | undefined;
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSortQuery = exports.generateSortSort = exports.getSortOption = exports.getSortOptions = void 0;
4
+ const getSortOptions = (options) => {
5
+ return options.config.sort
6
+ .sort((a, b) => {
7
+ const aInt = typeof a.position === "string"
8
+ ? parseInt(a.position, 10)
9
+ : a.position;
10
+ const bInt = typeof b.position === "string"
11
+ ? parseInt(b.position, 10)
12
+ : b.position;
13
+ return aInt - bInt;
14
+ })
15
+ .filter(({ visibility }) => ["all", options.provider.mode].includes(visibility));
16
+ };
17
+ exports.getSortOptions = getSortOptions;
18
+ const getSortOption = (options) => {
19
+ var _a;
20
+ const sortOptions = (0, exports.getSortOptions)(options);
21
+ return (_a = sortOptions.find(({ handle }) => handle === options.sortOption)) !== null && _a !== void 0 ? _a : sortOptions[0];
22
+ };
23
+ exports.getSortOption = getSortOption;
24
+ const generateSortSort = (options) => {
25
+ var _a, _b;
26
+ // curation positions are only applied for the default `collections.position` or `_score` sort
27
+ // if the sort is something else, apply a normal sort which applies what the user has requested
28
+ if (options.provider.mode !== "instant-search") {
29
+ if (options.sortOption &&
30
+ !["_score", "collections.position"].includes(options.sortOption.field)) {
31
+ return [{ [options.sortOption.field]: options.sortOption.direction }];
32
+ }
33
+ }
34
+ const sorts = [];
35
+ // collection curation pin sorting
36
+ if (options.provider.mode === "collection" && options.provider.collectionHandle) {
37
+ if ((_a = options.curation) === null || _a === void 0 ? void 0 : _a.collectionHandle) {
38
+ const queries = [{
39
+ term: {
40
+ "curations.collectionHandle.keyword": options.curation.collectionHandle,
41
+ },
42
+ }];
43
+ if (options.provider.market) {
44
+ queries.push({
45
+ term: {
46
+ "curations.markets.keyword": options.provider.market,
47
+ },
48
+ });
49
+ }
50
+ sorts.push({
51
+ "curations.position": {
52
+ unmapped_type: "long",
53
+ order: "asc",
54
+ nested: {
55
+ path: "curations",
56
+ filter: {
57
+ bool: {
58
+ must: queries
59
+ }
60
+ }
61
+ },
62
+ },
63
+ });
64
+ }
65
+ }
66
+ // search options.curation pin sorting
67
+ if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
68
+ if ((_b = options.curation) === null || _b === void 0 ? void 0 : _b.searchTerm) {
69
+ const queries = [{
70
+ term: {
71
+ "curations.searchTerm.keyword": options.curation.searchTerm.toLowerCase(),
72
+ },
73
+ }];
74
+ if (options.provider.market) {
75
+ queries.push({
76
+ term: {
77
+ "curations.markets.keyword": options.provider.market,
78
+ },
79
+ });
80
+ }
81
+ sorts.push({
82
+ "curations.position": {
83
+ unmapped_type: "long",
84
+ order: "asc",
85
+ nested: {
86
+ path: "curations",
87
+ filter: {
88
+ bool: {
89
+ must: queries
90
+ }
91
+ }
92
+ },
93
+ },
94
+ });
95
+ }
96
+ }
97
+ // options.curation boost sorting
98
+ if (options.curation) {
99
+ if (0 < options.curation.boosting.groupings.length) {
100
+ const groupings = options.curation.boosting.groupings.sort((a, b) => a.position > b.position ? 1 : -1);
101
+ for (const grouping of groupings) {
102
+ try {
103
+ const query = JSON.parse(grouping.query);
104
+ if (query)
105
+ sorts.push(query);
106
+ }
107
+ catch (_c) {
108
+ console.error(`query could not be parsed for boost grouping`, grouping);
109
+ }
110
+ }
111
+ }
112
+ if (0 < options.curation.boosting.sortings.length) {
113
+ const sortings = options.curation.boosting.sortings.sort((a, b) => a.position > b.position ? 1 : -1);
114
+ for (const sorting of sortings) {
115
+ try {
116
+ const query = JSON.parse(sorting.query);
117
+ if (query)
118
+ sorts.push(query);
119
+ }
120
+ catch (_d) {
121
+ console.error(`query could not be parsed for boost sorting`, sorting);
122
+ }
123
+ }
124
+ }
125
+ }
126
+ // default collection sorting
127
+ if (options.provider.mode === "collection" && options.provider.collectionHandle) {
128
+ sorts.push({
129
+ "collections.position": {
130
+ order: "asc",
131
+ nested: {
132
+ path: "collections",
133
+ filter: {
134
+ term: {
135
+ "collections.handle.keyword": options.provider.collectionHandle,
136
+ },
137
+ },
138
+ },
139
+ },
140
+ });
141
+ }
142
+ // default search sorting
143
+ if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
144
+ sorts.push("_score");
145
+ }
146
+ return sorts;
147
+ };
148
+ exports.generateSortSort = generateSortSort;
149
+ const generateSortQuery = (options) => {
150
+ var _a;
151
+ if (!options.curation || options.curation.id.includes("global")) {
152
+ return undefined;
153
+ }
154
+ return {
155
+ bool: {
156
+ must_not: [
157
+ {
158
+ nested: {
159
+ path: "curations",
160
+ query: {
161
+ bool: {
162
+ must: [
163
+ {
164
+ term: {
165
+ [`curations.${"collection" === options.curation.type
166
+ ? "collectionHandle"
167
+ : "searchTerm"}.keyword`]: "collection" === options.curation.type
168
+ ? options.curation.collectionHandle
169
+ : (_a = options.curation.searchTerm) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
170
+ },
171
+ },
172
+ {
173
+ term: {
174
+ "curations.hidden": true,
175
+ },
176
+ },
177
+ ],
178
+ },
179
+ },
180
+ },
181
+ },
182
+ // hide callout when not sorting by _score or collections.position
183
+ ...(options.sortOption &&
184
+ !["_score", "collections.position"].includes(options.sortOption.field)
185
+ ? [
186
+ {
187
+ term: {
188
+ type: "callout",
189
+ },
190
+ },
191
+ ]
192
+ : []),
193
+ ],
194
+ },
195
+ };
196
+ };
197
+ exports.generateSortQuery = generateSortQuery;
198
+ //# sourceMappingURL=sortOption.js.map