@reactionary/core 0.3.5 → 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,9 +1,24 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
2
|
import { ProductIdentifierSchema, ProductRecommendationIdentifierSchema, ProductVariantIdentifierSchema } from "./identifiers.model.js";
|
|
3
|
-
|
|
4
|
-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { WebStoreIdentifierSchema } from "./models/identifiers.model.js";
|
|
3
3
|
import { CurrencySchema } from "./models/currency.model.js";
|
|
4
4
|
import { IdentitySchema } from "./models/identity.model.js";
|
|
5
5
|
const LanguageContextSchema = z.looseObject({
|
|
@@ -9,11 +9,11 @@ const LanguageContextSchema = z.looseObject({
|
|
|
9
9
|
const IdentityContextSchema = z.looseObject({
|
|
10
10
|
identity: IdentitySchema,
|
|
11
11
|
personalizationKey: z.string(),
|
|
12
|
-
lastUpdated: z.date()
|
|
12
|
+
lastUpdated: z.coerce.date()
|
|
13
13
|
});
|
|
14
|
-
const SessionSchema = z.
|
|
14
|
+
const SessionSchema = z.looseObject({
|
|
15
15
|
identityContext: IdentityContextSchema
|
|
16
|
-
})
|
|
16
|
+
});
|
|
17
17
|
const TaxJurisdictionSchema = z.object({
|
|
18
18
|
countryCode: z.string().default("US"),
|
|
19
19
|
stateCode: z.string().default(""),
|
|
@@ -1,11 +1,109 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export declare const
|
|
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>;
|
|
@@ -203,9 +203,9 @@ export declare const IdentityContextSchema: z.ZodObject<{
|
|
|
203
203
|
type: z.ZodLiteral<"Registered">;
|
|
204
204
|
}, z.core.$loose>], "type">;
|
|
205
205
|
personalizationKey: z.ZodString;
|
|
206
|
-
lastUpdated: z.
|
|
206
|
+
lastUpdated: z.ZodCoercedDate<unknown>;
|
|
207
207
|
}, z.core.$loose>;
|
|
208
|
-
export declare const SessionSchema: z.
|
|
208
|
+
export declare const SessionSchema: z.ZodObject<{
|
|
209
209
|
identityContext: z.ZodObject<{
|
|
210
210
|
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
211
211
|
type: z.ZodLiteral<"Anonymous">;
|
|
@@ -221,9 +221,9 @@ export declare const SessionSchema: z.ZodIntersection<z.ZodRecord<z.ZodString, z
|
|
|
221
221
|
type: z.ZodLiteral<"Registered">;
|
|
222
222
|
}, z.core.$loose>], "type">;
|
|
223
223
|
personalizationKey: z.ZodString;
|
|
224
|
-
lastUpdated: z.
|
|
224
|
+
lastUpdated: z.ZodCoercedDate<unknown>;
|
|
225
225
|
}, z.core.$loose>;
|
|
226
|
-
}, z.core.$
|
|
226
|
+
}, z.core.$loose>;
|
|
227
227
|
export declare const TaxJurisdictionSchema: z.ZodObject<{
|
|
228
228
|
countryCode: z.ZodDefault<z.ZodString>;
|
|
229
229
|
stateCode: z.ZodDefault<z.ZodString>;
|
|
@@ -231,7 +231,7 @@ export declare const TaxJurisdictionSchema: z.ZodObject<{
|
|
|
231
231
|
cityCode: z.ZodDefault<z.ZodString>;
|
|
232
232
|
}, z.core.$strip>;
|
|
233
233
|
export declare const RequestContextSchema: z.ZodObject<{
|
|
234
|
-
session: z.ZodDefault<z.
|
|
234
|
+
session: z.ZodDefault<z.ZodObject<{
|
|
235
235
|
identityContext: z.ZodObject<{
|
|
236
236
|
identity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
237
237
|
type: z.ZodLiteral<"Anonymous">;
|
|
@@ -247,9 +247,9 @@ export declare const RequestContextSchema: z.ZodObject<{
|
|
|
247
247
|
type: z.ZodLiteral<"Registered">;
|
|
248
248
|
}, z.core.$loose>], "type">;
|
|
249
249
|
personalizationKey: z.ZodString;
|
|
250
|
-
lastUpdated: z.
|
|
250
|
+
lastUpdated: z.ZodCoercedDate<unknown>;
|
|
251
251
|
}, z.core.$loose>;
|
|
252
|
-
}, z.core.$
|
|
252
|
+
}, z.core.$loose>>;
|
|
253
253
|
languageContext: z.ZodDefault<z.ZodObject<{
|
|
254
254
|
locale: z.ZodDefault<z.ZodString>;
|
|
255
255
|
currencyCode: z.ZodDefault<z.ZodEnum<{
|