@reactionary/provider-algolia 0.1.13 → 0.2.2
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
|
+
"version": "0.2.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@reactionary/core": "0.
|
|
7
|
+
"@reactionary/core": "0.2.2",
|
|
8
8
|
"algoliasearch": "^5.23.4",
|
|
9
9
|
"zod": "4.1.9"
|
|
10
10
|
},
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
ProductSearchResultFacetValueSchema,
|
|
20
20
|
ProductSearchResultItemVariantSchema,
|
|
21
21
|
ProductSearchResultSchema,
|
|
22
|
-
Reactionary
|
|
22
|
+
Reactionary,
|
|
23
|
+
success
|
|
23
24
|
} from "@reactionary/core";
|
|
24
25
|
import { algoliasearch } from "algoliasearch";
|
|
25
26
|
class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
@@ -66,9 +67,9 @@ class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
return result;
|
|
70
|
+
return success(result);
|
|
70
71
|
}
|
|
71
|
-
createCategoryNavigationFilter(payload) {
|
|
72
|
+
async createCategoryNavigationFilter(payload) {
|
|
72
73
|
const facetIdentifier = FacetIdentifierSchema.parse({
|
|
73
74
|
key: "categories"
|
|
74
75
|
});
|
|
@@ -76,21 +77,14 @@ class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
76
77
|
facet: facetIdentifier,
|
|
77
78
|
key: payload.categoryPath.map((c) => c.name).join(" > ")
|
|
78
79
|
});
|
|
79
|
-
return
|
|
80
|
+
return success(facetValueIdentifier);
|
|
80
81
|
}
|
|
81
82
|
parseSingle(body) {
|
|
82
83
|
const product = {
|
|
83
84
|
identifier: { key: body.objectID },
|
|
84
85
|
name: body.name || body.objectID,
|
|
85
86
|
slug: body.slug || body.objectID,
|
|
86
|
-
variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body))
|
|
87
|
-
meta: {
|
|
88
|
-
placeholder: false,
|
|
89
|
-
cache: {
|
|
90
|
-
hit: false,
|
|
91
|
-
key: ""
|
|
92
|
-
}
|
|
93
|
-
}
|
|
87
|
+
variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body))
|
|
94
88
|
};
|
|
95
89
|
return product;
|
|
96
90
|
}
|
|
@@ -144,10 +138,6 @@ class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
144
138
|
filters: query.search.filters,
|
|
145
139
|
paginationOptions: query.search.paginationOptions
|
|
146
140
|
},
|
|
147
|
-
meta: {
|
|
148
|
-
cache: { hit: false, key: "unknown" },
|
|
149
|
-
placeholder: false
|
|
150
|
-
},
|
|
151
141
|
pageNumber: (body.page || 0) + 1,
|
|
152
142
|
pageSize: body.hitsPerPage || 0,
|
|
153
143
|
totalCount: body.nbHits || 0,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Cache, type FacetIdentifier, type FacetValueIdentifier, ProductSearchProvider, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type ProductSearchResult, type ProductSearchResultFacet, type ProductSearchResultFacetValue, type ProductSearchResultItemVariant, type RequestContext } from '@reactionary/core';
|
|
1
|
+
import { type Cache, type FacetIdentifier, type FacetValueIdentifier, ProductSearchProvider, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type ProductSearchResult, type ProductSearchResultFacet, type ProductSearchResultFacetValue, type ProductSearchResultItemVariant, type RequestContext, type Result } from '@reactionary/core';
|
|
2
2
|
import { type SearchResponse } from 'algoliasearch';
|
|
3
3
|
import type { AlgoliaConfiguration } from '../schema/configuration.schema.js';
|
|
4
4
|
interface AlgoliaNativeVariant {
|
|
@@ -14,8 +14,8 @@ interface AlgoliaNativeRecord {
|
|
|
14
14
|
export declare class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
15
15
|
protected config: AlgoliaConfiguration;
|
|
16
16
|
constructor(config: AlgoliaConfiguration, cache: Cache, context: RequestContext);
|
|
17
|
-
queryByTerm(payload: ProductSearchQueryByTerm): Promise<ProductSearchResult
|
|
18
|
-
createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<FacetValueIdentifier
|
|
17
|
+
queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchResult>>;
|
|
18
|
+
createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
|
|
19
19
|
protected parseSingle(body: AlgoliaNativeRecord): {
|
|
20
20
|
identifier: {
|
|
21
21
|
key: string;
|
|
@@ -48,13 +48,6 @@ export declare class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
48
48
|
};
|
|
49
49
|
} | undefined;
|
|
50
50
|
}[];
|
|
51
|
-
meta: {
|
|
52
|
-
placeholder: false;
|
|
53
|
-
cache: {
|
|
54
|
-
hit: false;
|
|
55
|
-
key: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
51
|
};
|
|
59
52
|
protected parseVariant(variant: AlgoliaNativeVariant, product: AlgoliaNativeRecord): ProductSearchResultItemVariant;
|
|
60
53
|
protected parsePaginatedResult(body: SearchResponse<AlgoliaNativeRecord>, query: ProductSearchQueryByTerm): {
|
|
@@ -72,13 +65,6 @@ export declare class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
72
65
|
pageSize: number;
|
|
73
66
|
};
|
|
74
67
|
};
|
|
75
|
-
meta: {
|
|
76
|
-
cache: {
|
|
77
|
-
hit: false;
|
|
78
|
-
key: string;
|
|
79
|
-
};
|
|
80
|
-
placeholder: false;
|
|
81
|
-
};
|
|
82
68
|
pageNumber: number;
|
|
83
69
|
pageSize: number;
|
|
84
70
|
totalCount: number;
|
|
@@ -115,13 +101,6 @@ export declare class AlgoliaSearchProvider extends ProductSearchProvider {
|
|
|
115
101
|
};
|
|
116
102
|
} | undefined;
|
|
117
103
|
}[];
|
|
118
|
-
meta: {
|
|
119
|
-
placeholder: false;
|
|
120
|
-
cache: {
|
|
121
|
-
hit: false;
|
|
122
|
-
key: string;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
104
|
}[];
|
|
126
105
|
facets: {
|
|
127
106
|
identifier: {
|
|
@@ -22,25 +22,11 @@ export declare const AlgoliaProductSearchIdentifierSchema: z.ZodObject<{
|
|
|
22
22
|
index: z.ZodString;
|
|
23
23
|
}, z.core.$loose>;
|
|
24
24
|
export declare const AlgoliaProductSearchResultSchema: z.ZodObject<{
|
|
25
|
-
meta: z.ZodDefault<z.ZodObject<{
|
|
26
|
-
cache: z.ZodDefault<z.ZodObject<{
|
|
27
|
-
hit: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
-
key: z.ZodDefault<z.ZodString>;
|
|
29
|
-
}, z.core.$loose>>;
|
|
30
|
-
placeholder: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
-
}, z.core.$loose>>;
|
|
32
25
|
pageNumber: z.ZodNumber;
|
|
33
26
|
pageSize: z.ZodNumber;
|
|
34
27
|
totalCount: z.ZodNumber;
|
|
35
28
|
totalPages: z.ZodNumber;
|
|
36
29
|
items: z.ZodArray<z.ZodObject<{
|
|
37
|
-
meta: z.ZodDefault<z.ZodObject<{
|
|
38
|
-
cache: z.ZodDefault<z.ZodObject<{
|
|
39
|
-
hit: z.ZodDefault<z.ZodBoolean>;
|
|
40
|
-
key: z.ZodDefault<z.ZodString>;
|
|
41
|
-
}, z.core.$loose>>;
|
|
42
|
-
placeholder: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
-
}, z.core.$loose>>;
|
|
44
30
|
identifier: z.ZodObject<{
|
|
45
31
|
key: z.ZodString;
|
|
46
32
|
}, z.core.$loose>;
|