@reactionary/algolia 0.10.56 → 0.10.57
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/capabilities/product-recommendations.capability.js +3 -1
- package/factories/product-search/product-search.factory.js +5 -3
- package/package.json +2 -2
- package/schema/configuration.schema.js +1 -1
- package/src/capabilities/product-recommendations.capability.d.ts +1 -0
- package/src/schema/search.schema.d.ts +2 -0
- package/test/client-builder-product-search-extension.example.js +1 -1
|
@@ -192,11 +192,13 @@ class AlgoliaProductRecommendationsCapability extends ProductRecommendationsCapa
|
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
194
|
parseSearchResultItem(body) {
|
|
195
|
+
const variants = [...body.variants || []].map((variant) => this.parseVariant(variant, body));
|
|
195
196
|
const product = {
|
|
196
197
|
identifier: { key: body.objectID },
|
|
197
198
|
name: body.name || body.objectID,
|
|
198
199
|
slug: body.slug || body.objectID,
|
|
199
|
-
|
|
200
|
+
canAddToCartDirectly: body.canAddToCartDirectly ?? variants.length === 1,
|
|
201
|
+
variants,
|
|
200
202
|
complianceData: this.parseComplianceData(body)
|
|
201
203
|
};
|
|
202
204
|
return product;
|
|
@@ -66,14 +66,16 @@ class AlgoliaProductSearchFactory {
|
|
|
66
66
|
return data.complianceData ?? ProductSearchResultItemComplianceDataSchema.parse({});
|
|
67
67
|
}
|
|
68
68
|
parseSingle(body) {
|
|
69
|
+
const variants = [...body.variants || []].map(
|
|
70
|
+
(variant) => this.parseVariant(variant, body)
|
|
71
|
+
);
|
|
69
72
|
return {
|
|
70
73
|
identifier: { key: body.objectID },
|
|
71
74
|
name: body.name || body.objectID,
|
|
72
75
|
slug: body.slug || body.objectID,
|
|
73
76
|
complianceData: this.parseComplianceData(body),
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
+
canAddToCartDirectly: body.canAddToCartDirectly ?? variants.length === 1,
|
|
78
|
+
variants
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
81
|
parseVariant(variant, product) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactionary/algolia",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/Solteq/reactionary.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@reactionary/core": "0.10.
|
|
12
|
+
"@reactionary/core": "0.10.57",
|
|
13
13
|
"zod": "4.1.9",
|
|
14
14
|
"algoliasearch": "^5.48.0"
|
|
15
15
|
},
|
|
@@ -4,7 +4,7 @@ const AlgoliaConfigurationSchema = z.looseObject({
|
|
|
4
4
|
apiKey: z.string(),
|
|
5
5
|
indexName: z.string(),
|
|
6
6
|
useRecommendationsForBots: z.boolean().default(false).meta({ description: "Whether to use recommendations for bot traffic. By default, recommendations are not used for bots to save on API costs, but enabling this can provide a better experience for bot traffic such as search engine crawlers." }),
|
|
7
|
-
useBaseIndexNameForEnglishLocale: z.boolean().default(
|
|
7
|
+
useBaseIndexNameForEnglishLocale: z.boolean().default(false).meta({ description: "Deprecated. Whether to use the base index name, without locale suffix, for the English locale. By default, this is disabled and every locale, including English, uses an index with a locale suffix (e.g. products_en), which is what recalcitrant writes. Enable only for legacy setups with an unsuffixed English index.", deprecated: true })
|
|
8
8
|
});
|
|
9
9
|
export {
|
|
10
10
|
AlgoliaConfigurationSchema
|
|
@@ -47,6 +47,7 @@ export declare const AlgoliaProductSearchResultSchema: z.ZodObject<{
|
|
|
47
47
|
is_organic: z.ZodOptional<z.ZodBoolean>;
|
|
48
48
|
organic_certification_type: z.ZodOptional<z.ZodString>;
|
|
49
49
|
}, z.core.$loose>>;
|
|
50
|
+
canAddToCartDirectly: z.ZodDefault<z.ZodBoolean>;
|
|
50
51
|
variants: z.ZodArray<z.ZodObject<{
|
|
51
52
|
variant: z.ZodObject<{
|
|
52
53
|
sku: z.ZodString;
|
|
@@ -129,4 +130,5 @@ export interface AlgoliaNativeRecord {
|
|
|
129
130
|
name?: string;
|
|
130
131
|
variants: Array<AlgoliaNativeVariant>;
|
|
131
132
|
complianceData?: ProductSearchResultItemComplianceData;
|
|
133
|
+
canAddToCartDirectly?: boolean;
|
|
132
134
|
}
|
|
@@ -35,7 +35,7 @@ const config = {
|
|
|
35
35
|
apiKey: "ALGOLIA_API_KEY",
|
|
36
36
|
indexName: "ALGOLIA_INDEX",
|
|
37
37
|
useRecommendationsForBots: false,
|
|
38
|
-
useBaseIndexNameForEnglishLocale:
|
|
38
|
+
useBaseIndexNameForEnglishLocale: false
|
|
39
39
|
};
|
|
40
40
|
const client = new ClientBuilder(createInitialRequestContext()).withCache(new NoOpCache()).withCapability(
|
|
41
41
|
withAlgoliaCapabilities(config, {
|