@reactionary/meilisearch 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.
@@ -59,11 +59,13 @@ class MeilisearchProductRecommendationsCapability extends ProductRecommendations
59
59
  }));
60
60
  }
61
61
  parseSearchResultItem(body) {
62
+ const variants = [...body.variants || []].map((variant) => this.parseVariant(variant, body));
62
63
  const product = {
63
64
  identifier: { key: body.objectID },
64
65
  name: body.name || body.objectID,
65
66
  slug: body.slug || body.objectID,
66
- variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body)),
67
+ canAddToCartDirectly: body.canAddToCartDirectly ?? variants.length === 1,
68
+ variants,
67
69
  complianceData: this.parseComplianceData(body)
68
70
  };
69
71
  return product;
@@ -112,12 +112,14 @@ class MeilisearchProductSearchCapability extends ProductSearchCapability {
112
112
  return data.complianceData ?? ProductSearchResultItemComplianceDataSchema.parse({});
113
113
  }
114
114
  parseSingle(body) {
115
+ const variants = [...body.variants || []].map((variant) => this.parseVariant(variant, body));
115
116
  const product = {
116
117
  identifier: { key: body.objectID },
117
118
  name: body.name || body.objectID,
118
119
  slug: body.slug || body.objectID,
119
120
  complianceData: this.parseComplianceData(body),
120
- variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body))
121
+ canAddToCartDirectly: body.canAddToCartDirectly ?? variants.length === 1,
122
+ variants
121
123
  };
122
124
  return product;
123
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/meilisearch",
3
- "version": "0.10.56",
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.56",
12
+ "@reactionary/core": "0.10.57",
13
13
  "zod": "4.1.9",
14
14
  "meilisearch": "^0.58.0"
15
15
  },
@@ -31,6 +31,7 @@ export declare class MeilisearchProductRecommendationsCapability extends Product
31
31
  };
32
32
  name: string;
33
33
  slug: string;
34
+ canAddToCartDirectly: boolean;
34
35
  variants: ProductSearchResultItemVariant[];
35
36
  complianceData: ProductSearchResultItemComplianceData;
36
37
  };
@@ -18,6 +18,7 @@ export declare class MeilisearchProductSearchCapability<TFactory extends Product
18
18
  name: string;
19
19
  slug: string;
20
20
  complianceData: ProductSearchResultItemComplianceData;
21
+ canAddToCartDirectly: boolean;
21
22
  variants: ProductSearchResultItemVariant[];
22
23
  };
23
24
  protected parseVariant(variant: MeilisearchNativeVariant, product: MeilisearchNativeRecord): ProductSearchResultItemVariant;
@@ -47,6 +48,7 @@ export declare class MeilisearchProductSearchCapability<TFactory extends Product
47
48
  name: string;
48
49
  slug: string;
49
50
  complianceData: ProductSearchResultItemComplianceData;
51
+ canAddToCartDirectly: boolean;
50
52
  variants: ProductSearchResultItemVariant[];
51
53
  }[];
52
54
  facets: ProductSearchResultFacet[];
@@ -47,6 +47,7 @@ export declare const MeilisearchProductSearchResultSchema: 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 MeilisearchNativeRecord {
129
130
  name?: string;
130
131
  variants: Array<MeilisearchNativeVariant>;
131
132
  complianceData?: ProductSearchResultItemComplianceData;
133
+ canAddToCartDirectly?: boolean;
132
134
  }