@usereactify/search 4.2.1 → 4.2.4

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.2.4](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.2.3...v4.2.4) (2022-06-23)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * add missing spread operator ([acc51cb](https://bitbucket.org/usereactify/reactify-search-ui/commit/acc51cb5c414831e3d0e919185d076895903d837))
11
+
12
+ ### [4.2.3](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.2.2...v4.2.3) (2022-06-23)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * include sorting by collection position when using global curation ([141c463](https://bitbucket.org/usereactify/reactify-search-ui/commit/141c46351711c3cff65275e47fdf8e9ed64b0ad8))
18
+
19
+ ### [4.2.2](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.2.1...v4.2.2) (2022-06-21)
20
+
21
+
22
+ ### Features
23
+
24
+ * merge global boosting rules with curation when empty ([248cbdd](https://bitbucket.org/usereactify/reactify-search-ui/commit/248cbdda01864c0d536f5e971f81e331de4c827d))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * pass on nocache url param to config endpoint to bust caching on worker side ([51b9dcf](https://bitbucket.org/usereactify/reactify-search-ui/commit/51b9dcf0b8145691a2dd00aedbe951f71bbc04b3))
30
+
5
31
  ### [4.2.1](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.2.0...v4.2.1) (2022-06-14)
6
32
 
7
33
  ## [4.2.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/v4.1.0...v4.2.0) (2022-06-14)
@@ -54,10 +54,15 @@ const useLiveConfig = (shopifyPermanentDomain, configId) => {
54
54
  if (configId) {
55
55
  searchParams.set("id", configId);
56
56
  }
57
+ const skipCache = new URLSearchParams(window.location.href.split("?")[1]).get("nocache") !== null;
58
+ if (skipCache) {
59
+ searchParams.set("nocache", "true");
60
+ }
57
61
  const json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
58
62
  setConfig(json.body);
59
63
  window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
60
64
  expiresAt: new Date().getTime() + CACHE_EXPIRY,
65
+ noCache: skipCache,
61
66
  config: json.body,
62
67
  }));
63
68
  }))();
package/dist/provider.js CHANGED
@@ -275,5 +275,20 @@ const useCuration = (config, collection, searchQuery) => react_1.default.useMemo
275
275
  normalisedHandleOrSearchTerm === normalisedCollectionHandle);
276
276
  return false;
277
277
  });
278
- return curation ? curation : globalCuration ? globalCuration : undefined;
278
+ const addGlobalBoosting = (curation) => {
279
+ const curationIsCollection = curation.type === "collection";
280
+ if (!curationIsCollection)
281
+ return curation;
282
+ const curationHasRules = !!curation.boosting.groupings.length ||
283
+ !!curation.boosting.sortings.length;
284
+ if (curationHasRules || !globalCuration)
285
+ return curation;
286
+ const curationWithGlobalBoosting = Object.assign(Object.assign({}, curation), { boosting: globalCuration.boosting });
287
+ return curationWithGlobalBoosting;
288
+ };
289
+ return curation
290
+ ? addGlobalBoosting(curation)
291
+ : globalCuration
292
+ ? globalCuration
293
+ : undefined;
279
294
  }, [config, collection, searchQuery]);
@@ -70,7 +70,10 @@ const buildSort = (args) => {
70
70
  }
71
71
  const sorts = [];
72
72
  // show pins first
73
- if (!globalCuration)
73
+ if (globalCuration && collection) {
74
+ sorts.push(...mapCollectionPositionSortClause(collection));
75
+ }
76
+ else {
74
77
  sorts.push({
75
78
  "curations.position": {
76
79
  unmapped_type: "long",
@@ -89,6 +92,7 @@ const buildSort = (args) => {
89
92
  },
90
93
  },
91
94
  });
95
+ }
92
96
  if (0 < curation.boosting.groupings.length) {
93
97
  const groupings = curation.boosting.groupings.sort((a, b) => a.position > b.position ? 1 : -1);
94
98
  for (const grouping of groupings) {
@@ -115,16 +119,15 @@ const buildSort = (args) => {
115
119
  }
116
120
  }
117
121
  }
118
- // finally, sort by elastic score or index order
119
- // using index order ensures a consistent output order for queries which don't really
120
- // use a relevance score like collections
121
- if ("collection" === curation.type)
122
+ // finally, for collections, if no other sorting is defined, sort by index order to provide
123
+ // a consistent order
124
+ if ("collection" === curation.type && sorts.length === 0) {
122
125
  sorts.push("_doc");
123
- else
126
+ }
127
+ // finally, for search, sort by score
128
+ if ("search" === curation.type) {
124
129
  sorts.push("_score");
125
- // @todo ideally, once pins are extinguished and there are no boost rules, the rest of the
126
- // result should be ordered by the shopify collection position rather than the index order,
127
- // but this will need some proper testing to ensure it does not break curations
130
+ }
128
131
  return sorts;
129
132
  };
130
133
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "4.2.1",
4
+ "version": "4.2.4",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -15,6 +15,7 @@
15
15
  "release": "standard-version",
16
16
  "release:patch": "standard-version --release-as patch",
17
17
  "release:beta": "standard-version --release-as minor --prerelease beta",
18
+ "release:local": "yalc publish",
18
19
  "build": "rimraf dist && tsc",
19
20
  "prettier": "prettier --write .",
20
21
  "storybook": "start-storybook -p 6006",