@reactionary/core 0.3.6 → 0.3.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
@@ -1,9 +1,24 @@
1
1
  import z from "zod";
2
2
  import { ProductIdentifierSchema, ProductRecommendationIdentifierSchema, ProductVariantIdentifierSchema } from "./identifiers.model.js";
3
- const ProductRecommendationSchema = z.looseObject({
4
- recommendationIdentifier: ProductRecommendationIdentifierSchema.describe("The identifier for the product recommendation, which includes a key and an algorithm and any other vendor specific/instance specific data "),
3
+ import { ProductSearchResultItemSchema } from "./product-search.model.js";
4
+ const BaseProductRecommendationSchema = z.looseObject({
5
+ recommendationIdentifier: ProductRecommendationIdentifierSchema.describe("The identifier for the product recommendation, which includes a key and an algorithm and any other vendor specific/instance specific data ")
6
+ });
7
+ const ProductRecommendationIdOnlySchema = BaseProductRecommendationSchema.extend({
8
+ recommendationReturnType: z.literal("idOnly").describe("The type of recommendation return"),
5
9
  product: ProductIdentifierSchema.describe("The identifier for the recommended product.")
6
10
  });
11
+ const ProductRecommendationProductSearchResultItemSchema = BaseProductRecommendationSchema.extend({
12
+ recommendationReturnType: z.literal("productSearchResultItem").describe("The type of recommendation return"),
13
+ product: ProductSearchResultItemSchema.describe("The recommended product, including its identifier, name, slug, and variants. This can be used to display the recommended product directly on the frontend without needing to make an additional request to fetch the product details.")
14
+ });
15
+ const ProductRecommendationSchema = z.discriminatedUnion("recommendationReturnType", [
16
+ ProductRecommendationIdOnlySchema,
17
+ ProductRecommendationProductSearchResultItemSchema
18
+ ]);
7
19
  export {
20
+ BaseProductRecommendationSchema,
21
+ ProductRecommendationIdOnlySchema,
22
+ ProductRecommendationProductSearchResultItemSchema,
8
23
  ProductRecommendationSchema
9
24
  };
@@ -1,11 +1,109 @@
1
1
  import z from "zod";
2
- export declare const ProductRecommendationSchema: z.ZodObject<{
2
+ export declare const BaseProductRecommendationSchema: z.ZodObject<{
3
3
  recommendationIdentifier: z.ZodObject<{
4
4
  key: z.ZodString;
5
5
  algorithm: z.ZodString;
6
6
  }, z.z.core.$loose>;
7
+ }, z.z.core.$loose>;
8
+ export declare const ProductRecommendationIdOnlySchema: z.ZodObject<{
9
+ recommendationIdentifier: z.ZodObject<{
10
+ key: z.ZodString;
11
+ algorithm: z.ZodString;
12
+ }, z.z.core.$loose>;
13
+ recommendationReturnType: z.ZodLiteral<"idOnly">;
7
14
  product: z.ZodObject<{
8
15
  key: z.ZodString;
9
16
  }, z.z.core.$loose>;
10
17
  }, z.z.core.$loose>;
18
+ export declare const ProductRecommendationProductSearchResultItemSchema: z.ZodObject<{
19
+ recommendationIdentifier: z.ZodObject<{
20
+ key: z.ZodString;
21
+ algorithm: z.ZodString;
22
+ }, z.z.core.$loose>;
23
+ recommendationReturnType: z.ZodLiteral<"productSearchResultItem">;
24
+ product: z.ZodObject<{
25
+ identifier: z.ZodObject<{
26
+ key: z.ZodString;
27
+ }, z.z.core.$loose>;
28
+ name: z.ZodString;
29
+ slug: z.ZodString;
30
+ variants: z.ZodArray<z.ZodObject<{
31
+ variant: z.ZodObject<{
32
+ sku: z.ZodString;
33
+ }, z.z.core.$loose>;
34
+ image: z.ZodObject<{
35
+ sourceUrl: z.ZodDefault<z.ZodString>;
36
+ altText: z.ZodDefault<z.ZodString>;
37
+ width: z.ZodOptional<z.ZodNumber>;
38
+ height: z.ZodOptional<z.ZodNumber>;
39
+ }, z.z.core.$loose>;
40
+ options: z.ZodOptional<z.ZodObject<{
41
+ identifier: z.ZodObject<{
42
+ key: z.ZodString;
43
+ }, z.z.core.$loose>;
44
+ name: z.ZodString;
45
+ value: z.ZodObject<{
46
+ identifier: z.ZodObject<{
47
+ option: z.ZodObject<{
48
+ key: z.ZodString;
49
+ }, z.z.core.$loose>;
50
+ key: z.ZodString;
51
+ }, z.z.core.$loose>;
52
+ label: z.ZodString;
53
+ }, z.z.core.$loose>;
54
+ }, z.z.core.$loose>>;
55
+ }, z.z.core.$loose>>;
56
+ }, z.z.core.$loose>;
57
+ }, z.z.core.$loose>;
58
+ export declare const ProductRecommendationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
+ recommendationIdentifier: z.ZodObject<{
60
+ key: z.ZodString;
61
+ algorithm: z.ZodString;
62
+ }, z.z.core.$loose>;
63
+ recommendationReturnType: z.ZodLiteral<"idOnly">;
64
+ product: z.ZodObject<{
65
+ key: z.ZodString;
66
+ }, z.z.core.$loose>;
67
+ }, z.z.core.$loose>, z.ZodObject<{
68
+ recommendationIdentifier: z.ZodObject<{
69
+ key: z.ZodString;
70
+ algorithm: z.ZodString;
71
+ }, z.z.core.$loose>;
72
+ recommendationReturnType: z.ZodLiteral<"productSearchResultItem">;
73
+ product: z.ZodObject<{
74
+ identifier: z.ZodObject<{
75
+ key: z.ZodString;
76
+ }, z.z.core.$loose>;
77
+ name: z.ZodString;
78
+ slug: z.ZodString;
79
+ variants: z.ZodArray<z.ZodObject<{
80
+ variant: z.ZodObject<{
81
+ sku: z.ZodString;
82
+ }, z.z.core.$loose>;
83
+ image: z.ZodObject<{
84
+ sourceUrl: z.ZodDefault<z.ZodString>;
85
+ altText: z.ZodDefault<z.ZodString>;
86
+ width: z.ZodOptional<z.ZodNumber>;
87
+ height: z.ZodOptional<z.ZodNumber>;
88
+ }, z.z.core.$loose>;
89
+ options: z.ZodOptional<z.ZodObject<{
90
+ identifier: z.ZodObject<{
91
+ key: z.ZodString;
92
+ }, z.z.core.$loose>;
93
+ name: z.ZodString;
94
+ value: z.ZodObject<{
95
+ identifier: z.ZodObject<{
96
+ option: z.ZodObject<{
97
+ key: z.ZodString;
98
+ }, z.z.core.$loose>;
99
+ key: z.ZodString;
100
+ }, z.z.core.$loose>;
101
+ label: z.ZodString;
102
+ }, z.z.core.$loose>;
103
+ }, z.z.core.$loose>>;
104
+ }, z.z.core.$loose>>;
105
+ }, z.z.core.$loose>;
106
+ }, z.z.core.$loose>], "recommendationReturnType">;
107
+ export type ProductRecommendationIdOnly = z.infer<typeof ProductRecommendationIdOnlySchema>;
108
+ export type ProductRecommendationSearchItem = z.infer<typeof ProductRecommendationProductSearchResultItemSchema>;
11
109
  export type ProductRecommendation = z.infer<typeof ProductRecommendationSchema>;