@reactionary/source 0.0.41 → 0.0.48
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/.claude/settings.local.json +28 -0
- package/.env-template +8 -5
- package/.vscode/settings.json +5 -0
- package/README.md +41 -0
- package/core/package.json +3 -1
- package/core/src/cache/cache.interface.ts +14 -18
- package/core/src/cache/memory-cache.ts +56 -0
- package/core/src/cache/noop-cache.ts +5 -23
- package/core/src/cache/redis-cache.ts +28 -38
- package/core/src/client/client-builder.ts +3 -3
- package/core/src/client/client.ts +11 -9
- package/core/src/decorators/reactionary.decorator.ts +80 -8
- package/core/src/index.ts +5 -29
- package/core/src/initialization.ts +43 -0
- package/core/src/providers/analytics.provider.ts +1 -1
- package/core/src/providers/base.provider.ts +61 -25
- package/core/src/providers/cart-payment.provider.ts +57 -0
- package/core/src/providers/cart.provider.ts +131 -8
- package/core/src/providers/category.provider.ts +9 -9
- package/core/src/providers/identity.provider.ts +8 -7
- package/core/src/providers/index.ts +12 -0
- package/core/src/providers/inventory.provider.ts +4 -4
- package/core/src/providers/price.provider.ts +7 -7
- package/core/src/providers/product.provider.ts +17 -5
- package/core/src/providers/profile.provider.ts +22 -0
- package/core/src/providers/search.provider.ts +4 -4
- package/core/src/providers/store.provider.ts +14 -0
- package/core/src/schemas/capabilities.schema.ts +3 -1
- package/core/src/schemas/models/analytics.model.ts +1 -1
- package/core/src/schemas/models/cart.model.ts +16 -3
- package/core/src/schemas/models/identifiers.model.ts +90 -22
- package/core/src/schemas/models/identity.model.ts +23 -7
- package/core/src/schemas/models/index.ts +15 -0
- package/core/src/schemas/models/payment.model.ts +41 -0
- package/core/src/schemas/models/profile.model.ts +35 -0
- package/core/src/schemas/models/shipping-method.model.ts +14 -0
- package/core/src/schemas/models/store.model.ts +11 -0
- package/core/src/schemas/mutations/cart-payment.mutation.ts +21 -0
- package/core/src/schemas/mutations/cart.mutation.ts +62 -3
- package/core/src/schemas/mutations/identity.mutation.ts +8 -1
- package/core/src/schemas/mutations/index.ts +10 -0
- package/core/src/schemas/mutations/profile.mutation.ts +9 -0
- package/core/src/schemas/queries/cart-payment.query.ts +12 -0
- package/core/src/schemas/queries/cart.query.ts +1 -1
- package/core/src/schemas/queries/identity.query.ts +1 -1
- package/core/src/schemas/queries/index.ts +3 -0
- package/core/src/schemas/queries/inventory.query.ts +4 -12
- package/core/src/schemas/queries/price.query.ts +1 -1
- package/core/src/schemas/queries/profile.query.ts +7 -0
- package/core/src/schemas/queries/search.query.ts +1 -1
- package/core/src/schemas/queries/store.query.ts +11 -0
- package/core/src/schemas/session.schema.ts +31 -6
- package/eslint.config.mjs +7 -0
- package/examples/next/src/app/page.tsx +4 -12
- package/examples/node/package.json +1 -3
- package/examples/node/src/basic/basic-node-provider-model-extension.spec.ts +9 -8
- package/examples/node/src/basic/basic-node-provider-query-extension.spec.ts +4 -3
- package/examples/node/src/basic/basic-node-setup.spec.ts +4 -5
- package/nx.json +1 -0
- package/otel/src/metrics.ts +2 -1
- package/otel/src/provider-instrumentation.ts +2 -1
- package/otel/src/tracer.ts +7 -6
- package/otel/src/trpc-middleware.ts +3 -2
- package/package.json +2 -1
- package/providers/algolia/src/core/initialize.ts +4 -3
- package/providers/algolia/src/providers/product.provider.ts +15 -13
- package/providers/algolia/src/providers/search.provider.ts +9 -9
- package/providers/algolia/src/schema/capabilities.schema.ts +1 -1
- package/providers/algolia/src/test/search.provider.spec.ts +10 -10
- package/providers/algolia/src/test/test-utils.ts +9 -4
- package/providers/commercetools/README.md +27 -0
- package/providers/commercetools/src/core/client.ts +164 -117
- package/providers/commercetools/src/core/initialize.ts +24 -14
- package/providers/commercetools/src/providers/cart-payment.provider.ts +193 -0
- package/providers/commercetools/src/providers/cart.provider.ts +402 -125
- package/providers/commercetools/src/providers/category.provider.ts +35 -35
- package/providers/commercetools/src/providers/identity.provider.ts +23 -75
- package/providers/commercetools/src/providers/index.ts +2 -0
- package/providers/commercetools/src/providers/inventory.provider.ts +69 -40
- package/providers/commercetools/src/providers/price.provider.ts +79 -47
- package/providers/commercetools/src/providers/product.provider.ts +36 -30
- package/providers/commercetools/src/providers/profile.provider.ts +61 -0
- package/providers/commercetools/src/providers/search.provider.ts +16 -12
- package/providers/commercetools/src/providers/store.provider.ts +78 -0
- package/providers/commercetools/src/schema/capabilities.schema.ts +3 -1
- package/providers/commercetools/src/schema/commercetools.schema.ts +18 -0
- package/providers/commercetools/src/schema/configuration.schema.ts +2 -1
- package/providers/commercetools/src/test/cart-payment.provider.spec.ts +145 -0
- package/providers/commercetools/src/test/cart.provider.spec.ts +82 -22
- package/providers/commercetools/src/test/category.provider.spec.ts +18 -17
- package/providers/commercetools/src/test/identity.provider.spec.ts +88 -0
- package/providers/commercetools/src/test/inventory.provider.spec.ts +41 -0
- package/providers/commercetools/src/test/price.provider.spec.ts +9 -8
- package/providers/commercetools/src/test/product.provider.spec.ts +33 -5
- package/providers/commercetools/src/test/profile.provider.spec.ts +49 -0
- package/providers/commercetools/src/test/search.provider.spec.ts +8 -7
- package/providers/commercetools/src/test/store.provider.spec.ts +37 -0
- package/providers/commercetools/src/test/test-utils.ts +7 -31
- package/providers/fake/src/core/initialize.ts +96 -38
- package/providers/fake/src/providers/analytics.provider.ts +6 -5
- package/providers/fake/src/providers/cart.provider.ts +66 -19
- package/providers/fake/src/providers/category.provider.ts +12 -12
- package/providers/fake/src/providers/identity.provider.ts +22 -14
- package/providers/fake/src/providers/index.ts +1 -0
- package/providers/fake/src/providers/inventory.provider.ts +13 -13
- package/providers/fake/src/providers/price.provider.ts +13 -13
- package/providers/fake/src/providers/product.provider.ts +13 -10
- package/providers/fake/src/providers/search.provider.ts +7 -5
- package/providers/fake/src/providers/store.provider.ts +47 -0
- package/providers/fake/src/schema/capabilities.schema.ts +4 -1
- package/providers/fake/src/test/cart.provider.spec.ts +18 -18
- package/providers/fake/src/test/category.provider.spec.ts +55 -37
- package/providers/fake/src/test/price.provider.spec.ts +9 -14
- package/providers/fake/src/test/product.provider.spec.ts +27 -0
- package/providers/fake/src/test/test-utils.ts +2 -28
- package/providers/posthog/src/core/initialize.ts +3 -3
- package/providers/posthog/src/schema/capabilities.schema.ts +1 -1
- package/trpc/src/client.ts +42 -41
- package/trpc/src/index.ts +4 -3
- package/trpc/src/integration.spec.ts +11 -11
- package/trpc/src/server.ts +26 -24
- package/trpc/src/test-utils.ts +9 -4
- package/trpc/src/types.ts +24 -22
- package/core/src/cache/cache-evaluation.interface.ts +0 -19
- package/examples/node/src/test-utils.ts +0 -26
|
@@ -1,61 +1,96 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
export const FacetIdentifierSchema = z.looseObject({
|
|
4
|
-
|
|
4
|
+
key: z.string().default('').nonoptional(),
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
export const FacetValueIdentifierSchema = z.looseObject({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
facet: FacetIdentifierSchema.default(() => FacetIdentifierSchema.parse({})),
|
|
9
|
+
key: z.string().default(''),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
export const SKUIdentifierSchema = z.looseObject({
|
|
13
|
-
|
|
13
|
+
key: z.string().default('').nonoptional(),
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export const ProductIdentifierSchema = z.looseObject({
|
|
17
|
-
|
|
17
|
+
key: z.string().default(''),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
export const SearchIdentifierSchema = z.looseObject({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
term: z.string().default(''),
|
|
22
|
+
page: z.number().default(0),
|
|
23
|
+
pageSize: z.number().default(20),
|
|
24
|
+
facets: z.array(FacetValueIdentifierSchema.required()).default(() => []),
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
export const CartIdentifierSchema = z.looseObject({
|
|
28
|
-
|
|
28
|
+
key: z.string().default(''),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
export const CartItemIdentifierSchema = z.looseObject({
|
|
32
|
-
|
|
32
|
+
key: z.string().default(''),
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
export const PriceIdentifierSchema = z.looseObject({
|
|
36
|
-
|
|
36
|
+
sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
export const CategoryIdentifierSchema = z.looseObject({
|
|
40
|
-
key: z.string().default('').nonoptional()
|
|
40
|
+
key: z.string().default('').nonoptional(),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const StoreIdentifierSchema = z.looseObject({
|
|
44
|
+
key: z.string().default('').optional(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const OrderIdentifierSchema = z.looseObject({
|
|
48
|
+
key: z.string().default('').nonoptional(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const OrderItemIdentifierSchema = z.looseObject({
|
|
52
|
+
key: z.string().default('').nonoptional(),
|
|
41
53
|
});
|
|
42
54
|
|
|
43
55
|
/**
|
|
44
56
|
* The target store the user is interacting with. Can change over time, and is not necessarily the same as the default store.
|
|
45
57
|
*/
|
|
46
58
|
export const WebStoreIdentifierSchema = z.looseObject({
|
|
47
|
-
|
|
59
|
+
key: z.string().default('').nonoptional(),
|
|
48
60
|
});
|
|
49
61
|
|
|
50
|
-
export const
|
|
51
|
-
|
|
62
|
+
export const FulfillmentCenterIdentifierSchema = z.looseObject({
|
|
63
|
+
key: z.string().default('').nonoptional(),
|
|
52
64
|
});
|
|
53
65
|
|
|
54
66
|
export const InventoryIdentifierSchema = z.looseObject({
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
|
|
68
|
+
fulfillmentCenter: FulfillmentCenterIdentifierSchema.default(() =>
|
|
69
|
+
FulfillmentCenterIdentifierSchema.parse({})
|
|
70
|
+
),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const IdentityIdentifierSchema = z.looseObject({
|
|
74
|
+
userId: z.string().default('').nonoptional(),
|
|
57
75
|
});
|
|
58
76
|
|
|
77
|
+
export const ShippingMethodIdentifierSchema = z.looseObject({
|
|
78
|
+
key: z.string().default('').nonoptional(),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const PaymentMethodIdentifierSchema = z.looseObject({
|
|
82
|
+
method: z.string().default('').nonoptional(),
|
|
83
|
+
name: z.string().default('').nonoptional(),
|
|
84
|
+
paymentProcessor: z.string().default('').nonoptional(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const AddressIdentifierSchema = z.looseObject({
|
|
88
|
+
nickName: z.string().default('').nonoptional(),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const PaymentInstructionIdentifierSchema = z.looseObject({
|
|
92
|
+
key: z.string().default('').nonoptional(),
|
|
93
|
+
});
|
|
59
94
|
|
|
60
95
|
export type ProductIdentifier = z.infer<typeof ProductIdentifierSchema>;
|
|
61
96
|
export type SearchIdentifier = z.infer<typeof SearchIdentifierSchema>;
|
|
@@ -67,7 +102,40 @@ export type PriceIdentifier = z.infer<typeof PriceIdentifierSchema>;
|
|
|
67
102
|
export type CategoryIdentifier = z.infer<typeof CategoryIdentifierSchema>;
|
|
68
103
|
export type WebStoreIdentifier = z.infer<typeof WebStoreIdentifierSchema>;
|
|
69
104
|
export type InventoryIdentifier = z.infer<typeof InventoryIdentifierSchema>;
|
|
70
|
-
export type
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export type
|
|
105
|
+
export type FulfillmentCenterIdentifier = z.infer<
|
|
106
|
+
typeof FulfillmentCenterIdentifierSchema
|
|
107
|
+
>;
|
|
108
|
+
export type IdentityIdentifier = z.infer<typeof IdentityIdentifierSchema>;
|
|
109
|
+
export type ShippingMethodIdentifier = z.infer<
|
|
110
|
+
typeof ShippingMethodIdentifierSchema
|
|
111
|
+
>;
|
|
112
|
+
export type PaymentMethodIdentifier = z.infer<
|
|
113
|
+
typeof PaymentMethodIdentifierSchema
|
|
114
|
+
>;
|
|
115
|
+
export type AddressIdentifier = z.infer<typeof AddressIdentifierSchema>;
|
|
116
|
+
export type PaymentInstructionIdentifier = z.infer<
|
|
117
|
+
typeof PaymentInstructionIdentifierSchema
|
|
118
|
+
>;
|
|
119
|
+
export type OrderIdentifier = z.infer<typeof OrderIdentifierSchema>;
|
|
120
|
+
export type OrderItemIdentifier = z.infer<typeof OrderItemIdentifierSchema>;
|
|
121
|
+
export type StoreIdentifier = z.infer<typeof StoreIdentifierSchema>;
|
|
122
|
+
|
|
123
|
+
export type IdentifierType =
|
|
124
|
+
| ProductIdentifier
|
|
125
|
+
| SearchIdentifier
|
|
126
|
+
| FacetIdentifier
|
|
127
|
+
| FacetValueIdentifier
|
|
128
|
+
| CartIdentifier
|
|
129
|
+
| CartItemIdentifier
|
|
130
|
+
| PriceIdentifier
|
|
131
|
+
| CategoryIdentifier
|
|
132
|
+
| WebStoreIdentifier
|
|
133
|
+
| InventoryIdentifier
|
|
134
|
+
| FulfillmentCenterIdentifier
|
|
135
|
+
| IdentityIdentifier
|
|
136
|
+
| ShippingMethodIdentifier
|
|
137
|
+
| PaymentMethodIdentifier
|
|
138
|
+
| AddressIdentifier
|
|
139
|
+
| PaymentInstructionIdentifier
|
|
140
|
+
| OrderIdentifier
|
|
141
|
+
| OrderItemIdentifier;
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseModelSchema } from './base.model';
|
|
3
|
+
import { IdentityIdentifierSchema } from './identifiers.model';
|
|
3
4
|
|
|
4
|
-
export const
|
|
5
|
+
export const AnonymousIdentitySchema = BaseModelSchema.extend({
|
|
6
|
+
type: z.literal('Anonymous')
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const GuestIdentitySchema = BaseModelSchema.extend({
|
|
10
|
+
id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
|
|
11
|
+
type: z.literal('Guest'),
|
|
12
|
+
token: z.string().optional(),
|
|
13
|
+
refresh_token: z.string().optional(),
|
|
14
|
+
expiry: z.coerce.date().default(new Date())
|
|
15
|
+
});
|
|
5
16
|
|
|
6
|
-
export const
|
|
7
|
-
id:
|
|
8
|
-
type:
|
|
17
|
+
export const RegisteredIdentitySchema = BaseModelSchema.extend({
|
|
18
|
+
id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
|
|
19
|
+
type: z.literal('Registered'),
|
|
20
|
+
logonId: z.string().default(''),
|
|
9
21
|
token: z.string().optional(),
|
|
10
|
-
|
|
22
|
+
refresh_token: z.string().optional(),
|
|
11
23
|
expiry: z.coerce.date().default(new Date())
|
|
12
24
|
});
|
|
13
25
|
|
|
14
|
-
export
|
|
15
|
-
|
|
26
|
+
export const IdentitySchema = z.discriminatedUnion('type', [ AnonymousIdentitySchema, GuestIdentitySchema, RegisteredIdentitySchema]);
|
|
27
|
+
|
|
28
|
+
export type AnonymousIdentity = z.infer<typeof AnonymousIdentitySchema>;
|
|
29
|
+
export type GuestIdentity = z.infer<typeof GuestIdentitySchema>;
|
|
30
|
+
export type RegisteredIdentity = z.infer<typeof RegisteredIdentitySchema>;
|
|
31
|
+
export type Identity = z.infer<typeof IdentitySchema>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './analytics.model';
|
|
2
|
+
export * from './base.model';
|
|
3
|
+
export * from './cart.model';
|
|
4
|
+
export * from './category.model';
|
|
5
|
+
export * from './currency.model';
|
|
6
|
+
export * from './identifiers.model';
|
|
7
|
+
export * from './identity.model';
|
|
8
|
+
export * from './inventory.model';
|
|
9
|
+
export * from './payment.model';
|
|
10
|
+
export * from './price.model';
|
|
11
|
+
export * from './product.model';
|
|
12
|
+
export * from './profile.model';
|
|
13
|
+
export * from './search.model';
|
|
14
|
+
export * from './shipping-method.model';
|
|
15
|
+
export * from './store.model';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseModelSchema, ImageSchema } from './base.model';
|
|
3
|
+
import { CartIdentifierSchema, InventoryIdentifierSchema, PaymentInstructionIdentifierSchema, PaymentMethodIdentifierSchema } from './identifiers.model';
|
|
4
|
+
import { MonetaryAmountSchema } from './price.model';
|
|
5
|
+
import { describe } from 'node:test';
|
|
6
|
+
|
|
7
|
+
export const PaymentStatusSchema = z.enum(['pending', 'authorized', 'canceled', 'capture', 'partial_capture', 'refunded', 'partial_refund']);
|
|
8
|
+
|
|
9
|
+
export const PaymentProtocolDataSchema = z.looseObject({
|
|
10
|
+
key: z.string().default(''),
|
|
11
|
+
value: z.string().default(''),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const PaymentMethodSchema = BaseModelSchema.extend({
|
|
16
|
+
identifier: PaymentMethodIdentifierSchema.default(() => PaymentMethodIdentifierSchema.parse({})),
|
|
17
|
+
logo: ImageSchema.optional(),
|
|
18
|
+
description: z.string().default(''),
|
|
19
|
+
isPunchOut: z.boolean().default(true)
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const PaymentInstructionSchema = BaseModelSchema.extend({
|
|
23
|
+
identifier: PaymentInstructionIdentifierSchema.default(() => PaymentInstructionIdentifierSchema.parse({})),
|
|
24
|
+
amount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})),
|
|
25
|
+
paymentMethod: PaymentMethodIdentifierSchema.default(() => PaymentMethodIdentifierSchema.parse({})),
|
|
26
|
+
protocolData: z.array(PaymentProtocolDataSchema).default(() => []).describe('Additional protocol-specific data for processing the payment.'),
|
|
27
|
+
status: PaymentStatusSchema.default('pending'),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const CartPaymentInstructionSchema = PaymentInstructionSchema.extend({
|
|
31
|
+
cart: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({}))
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export const OrderPaymentInstructionSchema = PaymentInstructionSchema.extend({
|
|
35
|
+
order: z.string().default('') // OrderIdentifierSchema
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type CartPaymentInstruction = z.infer<typeof CartPaymentInstructionSchema>;
|
|
39
|
+
export type OrderPaymentInstruction = z.infer<typeof OrderPaymentInstructionSchema>;
|
|
40
|
+
export type PaymentInstruction = z.infer<typeof PaymentInstructionSchema>;
|
|
41
|
+
export type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { AddressIdentifierSchema, IdentityIdentifierSchema } from "./identifiers.model";
|
|
3
|
+
import { BaseModelSchema } from "./base.model";
|
|
4
|
+
|
|
5
|
+
export const AddressSchema = BaseModelSchema.extend({
|
|
6
|
+
identifier: AddressIdentifierSchema.default(() => AddressIdentifierSchema.parse({})),
|
|
7
|
+
firstName: z.string().default(''),
|
|
8
|
+
lastName: z.string().default(''),
|
|
9
|
+
streetAddress: z.string().default(''),
|
|
10
|
+
streetNumber: z.string().default(''),
|
|
11
|
+
city: z.string().default(''),
|
|
12
|
+
region: z.string().default(''),
|
|
13
|
+
postalCode: z.string().default(''),
|
|
14
|
+
countryCode: z.string().default('US'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const ProfileSchema = BaseModelSchema.extend({
|
|
18
|
+
identifier: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
|
|
19
|
+
email: z.string().email().default(''),
|
|
20
|
+
phone: z.string().default(''),
|
|
21
|
+
|
|
22
|
+
emailVerified: z.boolean().default(false),
|
|
23
|
+
phoneVerified: z.boolean().default(false),
|
|
24
|
+
|
|
25
|
+
createdAt: z.string().default(() => new Date().toISOString()),
|
|
26
|
+
updatedAt: z.string().default(() => new Date().toISOString()),
|
|
27
|
+
|
|
28
|
+
shippingAddress: AddressSchema.optional(),
|
|
29
|
+
billingAddress: AddressSchema.optional(),
|
|
30
|
+
|
|
31
|
+
alternateShippingAddresses: z.array(AddressSchema).default(() => []),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type Address = z.infer<typeof AddressSchema>;
|
|
35
|
+
export type Profile = z.infer<typeof ProfileSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { ShippingMethodIdentifierSchema } from "./identifiers.model";
|
|
3
|
+
import { MonetaryAmountSchema } from "./price.model";
|
|
4
|
+
import { ImageSchema } from "./base.model";
|
|
5
|
+
|
|
6
|
+
export const ShippingMethodSchema = z.looseObject({
|
|
7
|
+
identifier: ShippingMethodIdentifierSchema.default(() => ShippingMethodIdentifierSchema.parse({})),
|
|
8
|
+
name: z.string().default(''),
|
|
9
|
+
description: z.string().default(''),
|
|
10
|
+
logo: ImageSchema.optional(),
|
|
11
|
+
price: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})),
|
|
12
|
+
deliveryTime: z.string().default(''),
|
|
13
|
+
});
|
|
14
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseModelSchema } from './base.model';
|
|
3
|
+
import { FulfillmentCenterIdentifierSchema, StoreIdentifierSchema } from './identifiers.model';
|
|
4
|
+
|
|
5
|
+
export const StoreSchema = BaseModelSchema.extend({
|
|
6
|
+
identifier: StoreIdentifierSchema.default(() => StoreIdentifierSchema.parse({})),
|
|
7
|
+
name: z.string().default(''),
|
|
8
|
+
fulfillmentCenter: FulfillmentCenterIdentifierSchema.default(() => FulfillmentCenterIdentifierSchema.parse({}))
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type Store = z.infer<typeof StoreSchema>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type z from "zod";
|
|
2
|
+
import { CartIdentifierSchema, PaymentInstructionIdentifierSchema } from "../models/identifiers.model";
|
|
3
|
+
import { PaymentInstructionSchema } from "../models/payment.model";
|
|
4
|
+
import { BaseMutationSchema } from "./base.mutation";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const CartPaymentMutationAddPayment = BaseMutationSchema.extend({
|
|
9
|
+
paymentInstruction: PaymentInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
|
|
10
|
+
cart: CartIdentifierSchema.required()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const CartPaymentMutationCancelPayment = BaseMutationSchema.extend({
|
|
14
|
+
paymentInstruction: PaymentInstructionIdentifierSchema.required(),
|
|
15
|
+
cart: CartIdentifierSchema.required()
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export type CartPaymentMutationAddPayment = z.infer<typeof CartPaymentMutationAddPayment>;
|
|
21
|
+
export type CartPaymentMutationCancelPayment = z.infer<typeof CartPaymentMutationCancelPayment>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BaseMutationSchema } from './base.mutation';
|
|
3
|
-
import { CartIdentifierSchema, CartItemIdentifierSchema,
|
|
3
|
+
import { CartIdentifierSchema, CartItemIdentifierSchema, PaymentMethodIdentifierSchema, ShippingMethodIdentifierSchema, SKUIdentifierSchema } from '../models/identifiers.model';
|
|
4
|
+
import { AddressSchema } from '../models/profile.model';
|
|
5
|
+
import { CurrencySchema } from '../models/currency.model';
|
|
6
|
+
import { MonetaryAmountSchema } from '../models/price.model';
|
|
4
7
|
|
|
5
8
|
export const CartMutationItemAddSchema = BaseMutationSchema.extend({
|
|
6
9
|
cart: CartIdentifierSchema.nonoptional(),
|
|
7
|
-
|
|
10
|
+
sku: SKUIdentifierSchema.nonoptional(),
|
|
8
11
|
quantity: z.number()
|
|
9
12
|
});
|
|
10
13
|
|
|
@@ -19,6 +22,62 @@ export const CartMutationItemQuantityChangeSchema = BaseMutationSchema.extend({
|
|
|
19
22
|
quantity: z.number()
|
|
20
23
|
});
|
|
21
24
|
|
|
25
|
+
export const CartMutationDeleteCartSchema = BaseMutationSchema.extend({
|
|
26
|
+
cart: CartIdentifierSchema.required()
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const CartMutationSetShippingInfoSchema = BaseMutationSchema.extend({
|
|
30
|
+
cart: CartIdentifierSchema.required(),
|
|
31
|
+
shippingMethod: ShippingMethodIdentifierSchema.optional(),
|
|
32
|
+
shippingAddress: AddressSchema.optional(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const CartMutationSetBillingAddressSchema = BaseMutationSchema.extend({
|
|
36
|
+
cart: CartIdentifierSchema.required(),
|
|
37
|
+
billingAddress: AddressSchema.required(),
|
|
38
|
+
notificationEmailAddress: z.string().optional(),
|
|
39
|
+
notificationPhoneNumber: z.string().optional(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const CartMutationApplyCouponSchema = BaseMutationSchema.extend({
|
|
43
|
+
cart: CartIdentifierSchema.required(),
|
|
44
|
+
couponCode: z.string().default('').nonoptional()
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const CartMutationRemoveCouponSchema = BaseMutationSchema.extend({
|
|
48
|
+
cart: CartIdentifierSchema.required(),
|
|
49
|
+
couponCode: z.string().default('').nonoptional()
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const CartMutationCheckoutSchema = BaseMutationSchema.extend({
|
|
53
|
+
cart: CartIdentifierSchema.required()
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const CartMutationAddPaymentMethodSchema = BaseMutationSchema.extend({
|
|
57
|
+
cart: CartIdentifierSchema.required(),
|
|
58
|
+
paymentMethodId: PaymentMethodIdentifierSchema.required(),
|
|
59
|
+
amount: MonetaryAmountSchema.optional().describe('The amount to authorize for the payment method. If not provided, the full remaining balance of the cart will be authorized.')
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export const CartMutationRemovePaymentMethodSchema = BaseMutationSchema.extend({
|
|
63
|
+
cart: CartIdentifierSchema.required(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const CartMutationChangeCurrencySchema = BaseMutationSchema.extend({
|
|
67
|
+
cart: CartIdentifierSchema.required(),
|
|
68
|
+
newCurrency: CurrencySchema.default(() => CurrencySchema.parse({})).describe('The new currency to set for the cart.')
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
export type CartMutationChangeCurrency = z.infer<typeof CartMutationChangeCurrencySchema>;
|
|
73
|
+
export type CartMutationAddPaymentMethod = z.infer<typeof CartMutationAddPaymentMethodSchema>;
|
|
74
|
+
export type CartMutationRemovePaymentMethod = z.infer<typeof CartMutationRemovePaymentMethodSchema>;
|
|
75
|
+
export type CartMutationCheckout = z.infer<typeof CartMutationCheckoutSchema>;
|
|
22
76
|
export type CartMutationItemAdd = z.infer<typeof CartMutationItemAddSchema>;
|
|
23
77
|
export type CartMutationItemRemove = z.infer<typeof CartMutationItemRemoveSchema>;
|
|
24
|
-
export type CartMutationItemQuantityChange = z.infer<typeof CartMutationItemQuantityChangeSchema>;
|
|
78
|
+
export type CartMutationItemQuantityChange = z.infer<typeof CartMutationItemQuantityChangeSchema>;
|
|
79
|
+
export type CartMutationDeleteCart = z.infer<typeof CartMutationDeleteCartSchema>;
|
|
80
|
+
export type CartMutationSetShippingInfo = z.infer<typeof CartMutationSetShippingInfoSchema>;
|
|
81
|
+
export type CartMutationSetBillingAddress = z.infer<typeof CartMutationSetBillingAddressSchema>;
|
|
82
|
+
export type CartMutationApplyCoupon = z.infer<typeof CartMutationApplyCouponSchema>;
|
|
83
|
+
export type CartMutationRemoveCoupon = z.infer<typeof CartMutationRemoveCouponSchema>;
|
|
@@ -9,5 +9,12 @@ export const IdentityMutationLoginSchema = BaseMutationSchema.extend({
|
|
|
9
9
|
export const IdentityMutationLogoutSchema = BaseMutationSchema.extend({
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
export const IdentityMutationRegisterSchema = BaseMutationSchema.extend({
|
|
13
|
+
username: z.string(),
|
|
14
|
+
password: z.string()
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
export type IdentityMutationLogin = z.infer<typeof IdentityMutationLoginSchema>;
|
|
13
|
-
export type IdentityMutationLogout = z.infer<typeof IdentityMutationLogoutSchema>;
|
|
19
|
+
export type IdentityMutationLogout = z.infer<typeof IdentityMutationLogoutSchema>;
|
|
20
|
+
export type IdentityMutationRegister = z.infer<typeof IdentityMutationRegisterSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './analytics.mutation';
|
|
2
|
+
export * from './base.mutation';
|
|
3
|
+
export * from './cart-payment.mutation';
|
|
4
|
+
export * from './cart.mutation';
|
|
5
|
+
export * from './identity.mutation';
|
|
6
|
+
export * from './inventory.mutation';
|
|
7
|
+
export * from './price.mutation';
|
|
8
|
+
export * from './product.mutation';
|
|
9
|
+
export * from './profile.mutation';
|
|
10
|
+
export * from './search.mutation';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseMutationSchema } from './base.mutation';
|
|
3
|
+
|
|
4
|
+
export const ProfileMutationUpdateSchema = BaseMutationSchema.extend({
|
|
5
|
+
email: z.email().default('base@example.com'),
|
|
6
|
+
phone: z.string().default(''),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export type ProfileMutationUpdate = z.infer<typeof ProfileMutationUpdateSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { CartIdentifierSchema } from "../models/identifiers.model";
|
|
3
|
+
import { PaymentStatusSchema } from "../models/payment.model";
|
|
4
|
+
import { BaseQuerySchema } from "./base.query";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const CartPaymentQueryByCartSchema = BaseQuerySchema.extend({
|
|
8
|
+
cart: CartIdentifierSchema.required(),
|
|
9
|
+
status: z.array(PaymentStatusSchema).optional().describe('Optional status to filter payment instructions by'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type CartPaymentQueryByCart = z.infer<typeof CartPaymentQueryByCartSchema>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export * from './analytics.query';
|
|
2
2
|
export * from './base.query';
|
|
3
|
+
export * from './cart-payment.query';
|
|
3
4
|
export * from './cart.query';
|
|
4
5
|
export * from './category.query';
|
|
5
6
|
export * from './identity.query';
|
|
6
7
|
export * from './inventory.query';
|
|
7
8
|
export * from './price.query';
|
|
8
9
|
export * from './product.query';
|
|
10
|
+
export * from './profile.query';
|
|
9
11
|
export * from './search.query';
|
|
12
|
+
export * from './store.query';
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import type { z } from 'zod';
|
|
2
2
|
import { BaseQuerySchema } from './base.query';
|
|
3
|
-
import {
|
|
3
|
+
import { FulfillmentCenterIdentifierSchema, ProductIdentifierSchema } from '../models/identifiers.model';
|
|
4
4
|
|
|
5
5
|
export const InventoryQueryBySKUSchema = BaseQuerySchema.extend({
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
sku: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})).nonoptional(),
|
|
7
|
+
fulfilmentCenter: FulfillmentCenterIdentifierSchema.default(() => FulfillmentCenterIdentifierSchema.parse({})).nonoptional()
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
//export type InventoryQuery = z.infer<typeof InventoryQuerySchema>;
|
|
11
11
|
export type InventoryQueryBySKU = z.infer<typeof InventoryQueryBySKUSchema>;
|
|
12
|
-
|
|
13
|
-
export interface InventoryQueries {
|
|
14
|
-
"sku": { sku: ProductIdentifier }
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type InventoryQuery = {
|
|
18
|
-
[K in keyof InventoryQueries]: { type: K } & InventoryQueries[K];
|
|
19
|
-
}[keyof InventoryQueries];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseQuerySchema } from './base.query';
|
|
3
|
+
|
|
4
|
+
export const StoreQueryByProximitySchema = BaseQuerySchema.extend({
|
|
5
|
+
longitude: z.number().default(0),
|
|
6
|
+
latitude: z.number().default(0),
|
|
7
|
+
distance: z.number().default(0),
|
|
8
|
+
limit: z.number().default(10)
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type StoreQueryByProximity = z.infer<typeof StoreQueryByProximitySchema>;
|
|
@@ -3,18 +3,43 @@ import { IdentitySchema } from './models/identity.model';
|
|
|
3
3
|
import { WebStoreIdentifierSchema } from './models/identifiers.model';
|
|
4
4
|
import { CurrencySchema } from './models/currency.model';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The language and locale context for the current request.
|
|
8
|
+
*/
|
|
6
9
|
export const LanguageContextSchema = z.looseObject( {
|
|
7
10
|
locale: z.string().default('en-US'),
|
|
8
11
|
currencyCode: CurrencySchema.default(() => CurrencySchema.parse({})),
|
|
9
|
-
countryCode: z.string().default('US'),
|
|
10
12
|
})
|
|
11
13
|
|
|
12
|
-
export const SessionSchema = z.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export const SessionSchema = z.record( z.string(), z.any());
|
|
15
|
+
|
|
16
|
+
export const TaxJurisdictionSchema = z.object( {
|
|
17
|
+
countryCode: z.string().default('US'),
|
|
18
|
+
stateCode: z.string().default(''),
|
|
19
|
+
countyCode: z.string().default(''),
|
|
20
|
+
cityCode: z.string().default(''),
|
|
17
21
|
});
|
|
18
22
|
|
|
23
|
+
export const RequestContextSchema = z.looseObject( {
|
|
24
|
+
identity: IdentitySchema.default(() => IdentitySchema.parse({})).describe('Read/Write. The identity of the current user. Caller is responsible for persisting any changes to the identity'),
|
|
25
|
+
session: SessionSchema.default(() => SessionSchema.parse({})).describe('Read/Write session storage. Caller is responsible for persisting any changes. Providers will prefix own values'),
|
|
26
|
+
|
|
27
|
+
languageContext: LanguageContextSchema.default(() => LanguageContextSchema.parse({})).describe('ReadOnly. The language and locale context for the current request.'),
|
|
28
|
+
storeIdentifier: WebStoreIdentifierSchema.default(() => WebStoreIdentifierSchema.parse({})).describe('ReadOnly. The identifier of the current web store making the request.'),
|
|
29
|
+
taxJurisdiction: TaxJurisdictionSchema.default(() => TaxJurisdictionSchema.parse({})).describe('ReadOnly. The tax jurisdiction for the current request, typically derived from the store location or carts billing address'),
|
|
30
|
+
|
|
31
|
+
correlationId: z.string().default('').describe('A unique identifier for the request, can be used for tracing and logging purposes.'),
|
|
32
|
+
isBot: z.boolean().default(false).describe('Indicates if the request is made by a bot or crawler.'),
|
|
33
|
+
|
|
34
|
+
clientIp: z.string().default('').describe('The IP address of the client making the request, if available. Mostly for logging purposes'),
|
|
35
|
+
userAgent: z.string().default('').describe('The user agent string of the client making the request, if available.'),
|
|
36
|
+
referrer: z.string().default('').describe('The referrer URL, if available.'),
|
|
37
|
+
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
19
42
|
export type Session = z.infer<typeof SessionSchema>;
|
|
20
43
|
export type LanguageContext = z.infer<typeof LanguageContextSchema>;
|
|
44
|
+
export type RequestContext = z.infer<typeof RequestContextSchema>;
|
|
45
|
+
export type TaxJurisdiction = z.infer<typeof TaxJurisdictionSchema>;
|