@reactionary/meilisearch 0.10.25 → 0.10.27

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.
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  ProductRecommendationsCapability,
3
3
  ImageSchema,
4
- ProductSearchResultItemVariantSchema
4
+ ProductSearchResultItemVariantSchema,
5
+ ProductSearchResultItemComplianceDataSchema
5
6
  } from "@reactionary/core";
6
7
  import { Meilisearch } from "meilisearch";
7
8
  import { getProductIndexNameForLocale } from "../core/index-utils.js";
@@ -62,10 +63,14 @@ class MeilisearchProductRecommendationsCapability extends ProductRecommendations
62
63
  identifier: { key: body.objectID },
63
64
  name: body.name || body.objectID,
64
65
  slug: body.slug || body.objectID,
65
- variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body))
66
+ variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body)),
67
+ complianceData: this.parseComplianceData(body)
66
68
  };
67
69
  return product;
68
70
  }
71
+ parseComplianceData(body) {
72
+ return body.complianceData ?? ProductSearchResultItemComplianceDataSchema.parse({});
73
+ }
69
74
  parseVariant(variant, product) {
70
75
  const result = ProductSearchResultItemVariantSchema.parse({
71
76
  variant: {
@@ -16,6 +16,7 @@ import {
16
16
  ProductSearchQueryByTermSchema,
17
17
  ProductSearchResultFacetSchema,
18
18
  ProductSearchResultFacetValueSchema,
19
+ ProductSearchResultItemComplianceDataSchema,
19
20
  ProductSearchResultItemVariantSchema,
20
21
  ProductSearchResultSchema,
21
22
  Reactionary,
@@ -107,11 +108,15 @@ class MeilisearchProductSearchCapability extends ProductSearchCapability {
107
108
  });
108
109
  return success(facetValueIdentifier);
109
110
  }
111
+ parseComplianceData(data) {
112
+ return data.complianceData ?? ProductSearchResultItemComplianceDataSchema.parse({});
113
+ }
110
114
  parseSingle(body) {
111
115
  const product = {
112
116
  identifier: { key: body.objectID },
113
117
  name: body.name || body.objectID,
114
118
  slug: body.slug || body.objectID,
119
+ complianceData: this.parseComplianceData(body),
115
120
  variants: [...body.variants || []].map((variant) => this.parseVariant(variant, body))
116
121
  };
117
122
  return product;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/meilisearch",
3
- "version": "0.10.25",
3
+ "version": "0.10.27",
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.25",
12
+ "@reactionary/core": "0.10.27",
13
13
  "zod": "4.1.9",
14
14
  "meilisearch": "^0.58.0"
15
15
  },
@@ -1,4 +1,4 @@
1
- import { type Cache, ProductRecommendationsCapability, type ProductRecommendation, type ProductRecommendationAlgorithmSimilarProductsQuery, type RequestContext, type ProductSearchResultItemVariant } from '@reactionary/core';
1
+ import { type Cache, ProductRecommendationsCapability, type ProductRecommendation, type ProductRecommendationAlgorithmSimilarProductsQuery, type RequestContext, type ProductSearchResultItemVariant, type ProductSearchResultItemComplianceData } from '@reactionary/core';
2
2
  import { type SearchResponse, type SearchSimilarDocumentsParams } from 'meilisearch';
3
3
  import type { MeilisearchConfiguration } from '../schema/configuration.schema.js';
4
4
  import type { MeilisearchNativeRecord, MeilisearchNativeVariant } from '../schema/index.js';
@@ -32,6 +32,8 @@ export declare class MeilisearchProductRecommendationsCapability extends Product
32
32
  name: string;
33
33
  slug: string;
34
34
  variants: ProductSearchResultItemVariant[];
35
+ complianceData: ProductSearchResultItemComplianceData;
35
36
  };
37
+ protected parseComplianceData(body: MeilisearchNativeRecord): ProductSearchResultItemComplianceData;
36
38
  protected parseVariant(variant: MeilisearchNativeVariant, product: MeilisearchNativeRecord): ProductSearchResultItemVariant;
37
39
  }
@@ -1,4 +1,4 @@
1
- import { type Cache, type FacetIdentifier, type FacetValueIdentifier, ProductSearchCapability, type ProductSearchFactory, type ProductSearchFactoryOutput, type ProductSearchFactoryWithOutput, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type ProductSearchResultFacet, type ProductSearchResultFacetValue, type ProductSearchResultItemVariant, type RequestContext, type Result } from '@reactionary/core';
1
+ import { type Cache, type FacetIdentifier, type FacetValueIdentifier, ProductSearchCapability, type ProductSearchFactory, type ProductSearchFactoryOutput, type ProductSearchFactoryWithOutput, type ProductSearchQueryByTerm, type ProductSearchQueryCreateNavigationFilter, type ProductSearchResultFacet, type ProductSearchResultFacetValue, type ProductSearchResultItemComplianceData, type ProductSearchResultItemVariant, type RequestContext, type Result } from '@reactionary/core';
2
2
  import { type SearchParams, type SearchResponse } from 'meilisearch';
3
3
  import type { MeilisearchConfiguration } from '../schema/configuration.schema.js';
4
4
  import type { MeilisearchNativeRecord, MeilisearchNativeVariant } from '../schema/search.schema.js';
@@ -10,12 +10,14 @@ export declare class MeilisearchProductSearchCapability<TFactory extends Product
10
10
  protected queryByTermPayload(payload: ProductSearchQueryByTerm): SearchParams;
11
11
  queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchFactoryOutput<TFactory>>>;
12
12
  createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
13
+ protected parseComplianceData(data: MeilisearchNativeRecord): ProductSearchResultItemComplianceData;
13
14
  protected parseSingle(body: MeilisearchNativeRecord): {
14
15
  identifier: {
15
16
  key: string;
16
17
  };
17
18
  name: string;
18
19
  slug: string;
20
+ complianceData: ProductSearchResultItemComplianceData;
19
21
  variants: ProductSearchResultItemVariant[];
20
22
  };
21
23
  protected parseVariant(variant: MeilisearchNativeVariant, product: MeilisearchNativeRecord): ProductSearchResultItemVariant;
@@ -44,6 +46,7 @@ export declare class MeilisearchProductSearchCapability<TFactory extends Product
44
46
  };
45
47
  name: string;
46
48
  slug: string;
49
+ complianceData: ProductSearchResultItemComplianceData;
47
50
  variants: ProductSearchResultItemVariant[];
48
51
  }[];
49
52
  facets: ProductSearchResultFacet[];
@@ -1,3 +1,4 @@
1
+ import { type ProductSearchResultItemComplianceData } from '@reactionary/core';
1
2
  import * as z from 'zod';
2
3
  export declare const MeilisearchProductSearchIdentifierSchema: z.ZodObject<{
3
4
  term: z.ZodString;
@@ -35,6 +36,14 @@ export declare const MeilisearchProductSearchResultSchema: z.ZodObject<{
35
36
  }, z.core.$loose>;
36
37
  name: z.ZodString;
37
38
  slug: z.ZodString;
39
+ complianceData: z.ZodOptional<z.ZodObject<{
40
+ ce_marking: z.ZodDefault<z.ZodBoolean>;
41
+ weee_symbol: z.ZodDefault<z.ZodBoolean>;
42
+ energy_class: z.ZodOptional<z.ZodString>;
43
+ garan_duration: z.ZodOptional<z.ZodNumber>;
44
+ is_organic: z.ZodOptional<z.ZodBoolean>;
45
+ organic_certification_type: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$loose>>;
38
47
  variants: z.ZodArray<z.ZodObject<{
39
48
  variant: z.ZodObject<{
40
49
  sku: z.ZodString;
@@ -116,4 +125,5 @@ export interface MeilisearchNativeRecord {
116
125
  slug?: string;
117
126
  name?: string;
118
127
  variants: Array<MeilisearchNativeVariant>;
128
+ complianceData?: ProductSearchResultItemComplianceData;
119
129
  }