@reactionary/provider-algolia 0.3.17 → 0.3.18

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@reactionary/provider-algolia",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
- "@reactionary/core": "0.3.17",
7
+ "@reactionary/core": "0.3.18",
8
8
  "algoliasearch": "^5.48.0",
9
9
  "zod": "4.1.9"
10
10
  },
@@ -28,8 +28,7 @@ class AlgoliaProductSearchProvider extends ProductSearchProvider {
28
28
  super(cache, context);
29
29
  this.config = config;
30
30
  }
31
- async queryByTerm(payload) {
32
- const client = algoliasearch(this.config.appId, this.config.apiKey);
31
+ queryByTermPayload(payload) {
33
32
  const facetsThatAreNotCategory = payload.search.facets.filter((x) => x.facet.key !== "categories");
34
33
  const categoryFacet = payload.search.facets.find((x) => x.facet.key === "categories") || payload.search.categoryFilter;
35
34
  const finalFilters = [...payload.search.filters || []];
@@ -41,19 +40,23 @@ class AlgoliaProductSearchProvider extends ProductSearchProvider {
41
40
  if (categoryFacet) {
42
41
  finalFilters.push(`categories:"${categoryFacet.key}"`);
43
42
  }
43
+ return {
44
+ indexName: this.config.indexName,
45
+ query: payload.search.term,
46
+ page: payload.search.paginationOptions.pageNumber - 1,
47
+ hitsPerPage: payload.search.paginationOptions.pageSize,
48
+ facets: ["*"],
49
+ analytics: true,
50
+ clickAnalytics: true,
51
+ facetFilters: finalFacetFilters,
52
+ filters: (finalFilters || []).join(" AND ")
53
+ };
54
+ }
55
+ async queryByTerm(payload) {
56
+ const client = algoliasearch(this.config.appId, this.config.apiKey);
44
57
  const remote = await client.search({
45
58
  requests: [
46
- {
47
- indexName: this.config.indexName,
48
- query: payload.search.term,
49
- page: payload.search.paginationOptions.pageNumber - 1,
50
- hitsPerPage: payload.search.paginationOptions.pageSize,
51
- facets: ["*"],
52
- analytics: true,
53
- clickAnalytics: true,
54
- facetFilters: finalFacetFilters,
55
- filters: (finalFilters || []).join(" AND ")
56
- }
59
+ this.queryByTermPayload(payload)
57
60
  ]
58
61
  });
59
62
  const input = remote.results[0];
@@ -5,6 +5,17 @@ import type { AlgoliaNativeRecord, AlgoliaNativeVariant } from '../schema/search
5
5
  export declare class AlgoliaProductSearchProvider extends ProductSearchProvider {
6
6
  protected config: AlgoliaConfiguration;
7
7
  constructor(cache: Cache, context: RequestContext, config: AlgoliaConfiguration);
8
+ protected queryByTermPayload(payload: ProductSearchQueryByTerm): {
9
+ indexName: string;
10
+ query: string;
11
+ page: number;
12
+ hitsPerPage: number;
13
+ facets: string[];
14
+ analytics: boolean;
15
+ clickAnalytics: boolean;
16
+ facetFilters: string[];
17
+ filters: string;
18
+ };
8
19
  queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchResult>>;
9
20
  createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
10
21
  protected parseSingle(body: AlgoliaNativeRecord): {