@reactionary/source 0.0.48 → 0.0.52

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.
Files changed (175) hide show
  1. package/core/package.json +4 -3
  2. package/core/src/cache/cache.interface.ts +1 -1
  3. package/core/src/cache/memory-cache.ts +2 -2
  4. package/core/src/cache/noop-cache.ts +1 -1
  5. package/core/src/cache/redis-cache.ts +1 -1
  6. package/core/src/client/client-builder.ts +4 -4
  7. package/core/src/client/client.ts +12 -12
  8. package/core/src/decorators/reactionary.decorator.ts +22 -2
  9. package/core/src/index.ts +14 -14
  10. package/core/src/initialization.ts +1 -1
  11. package/core/src/providers/analytics.provider.ts +2 -2
  12. package/core/src/providers/base.provider.ts +5 -5
  13. package/core/src/providers/cart.provider.ts +6 -6
  14. package/core/src/providers/category.provider.ts +4 -9
  15. package/core/src/providers/checkout.provider.ts +156 -0
  16. package/core/src/providers/identity.provider.ts +5 -5
  17. package/core/src/providers/index.ts +13 -12
  18. package/core/src/providers/inventory.provider.ts +4 -4
  19. package/core/src/providers/order.provider.ts +31 -0
  20. package/core/src/providers/price.provider.ts +5 -5
  21. package/core/src/providers/product.provider.ts +5 -5
  22. package/core/src/providers/profile.provider.ts +5 -5
  23. package/core/src/providers/search.provider.ts +4 -4
  24. package/core/src/providers/store.provider.ts +4 -4
  25. package/core/src/schemas/capabilities.schema.ts +2 -1
  26. package/core/src/schemas/models/analytics.model.ts +1 -1
  27. package/core/src/schemas/models/cart.model.ts +3 -28
  28. package/core/src/schemas/models/category.model.ts +2 -2
  29. package/core/src/schemas/models/checkout.model.ts +66 -0
  30. package/core/src/schemas/models/cost.model.ts +21 -0
  31. package/core/src/schemas/models/identifiers.model.ts +23 -2
  32. package/core/src/schemas/models/identity.model.ts +8 -5
  33. package/core/src/schemas/models/index.ts +19 -15
  34. package/core/src/schemas/models/inventory.model.ts +2 -2
  35. package/core/src/schemas/models/order.model.ts +46 -0
  36. package/core/src/schemas/models/payment.model.ts +5 -12
  37. package/core/src/schemas/models/price.model.ts +3 -3
  38. package/core/src/schemas/models/product.model.ts +6 -3
  39. package/core/src/schemas/models/profile.model.ts +2 -2
  40. package/core/src/schemas/models/search.model.ts +2 -3
  41. package/core/src/schemas/models/shipping-method.model.ts +34 -3
  42. package/core/src/schemas/models/store.model.ts +2 -2
  43. package/core/src/schemas/mutations/analytics.mutation.ts +2 -2
  44. package/core/src/schemas/mutations/cart.mutation.ts +5 -5
  45. package/core/src/schemas/mutations/checkout.mutation.ts +50 -0
  46. package/core/src/schemas/mutations/identity.mutation.ts +1 -1
  47. package/core/src/schemas/mutations/index.ts +10 -10
  48. package/core/src/schemas/mutations/profile.mutation.ts +1 -1
  49. package/core/src/schemas/queries/cart.query.ts +2 -2
  50. package/core/src/schemas/queries/category.query.ts +3 -3
  51. package/core/src/schemas/queries/checkout.query.ts +22 -0
  52. package/core/src/schemas/queries/identity.query.ts +1 -1
  53. package/core/src/schemas/queries/index.ts +13 -12
  54. package/core/src/schemas/queries/inventory.query.ts +2 -2
  55. package/core/src/schemas/queries/order.query.ts +9 -0
  56. package/core/src/schemas/queries/price.query.ts +2 -2
  57. package/core/src/schemas/queries/product.query.ts +9 -2
  58. package/core/src/schemas/queries/profile.query.ts +1 -1
  59. package/core/src/schemas/queries/search.query.ts +2 -2
  60. package/core/src/schemas/queries/store.query.ts +1 -1
  61. package/core/src/schemas/session.schema.ts +3 -3
  62. package/core/tsconfig.json +3 -2
  63. package/examples/next/next.config.js +17 -6
  64. package/examples/next/src/app/page.tsx +1 -2
  65. package/examples/node/package.json +2 -1
  66. package/examples/node/src/basic/basic-node-setup.spec.ts +1 -1
  67. package/examples/node/tsconfig.json +2 -1
  68. package/examples/node/tsconfig.spec.json +3 -2
  69. package/package.json +3 -1
  70. package/providers/algolia/package.json +2 -1
  71. package/providers/algolia/src/core/initialize.ts +5 -5
  72. package/providers/algolia/src/index.ts +5 -5
  73. package/providers/algolia/src/providers/product.provider.ts +8 -2
  74. package/providers/algolia/src/providers/search.provider.ts +1 -1
  75. package/providers/algolia/src/test/search.provider.spec.ts +1 -1
  76. package/providers/algolia/tsconfig.json +2 -1
  77. package/providers/algolia/tsconfig.spec.json +3 -2
  78. package/providers/commercetools/{jest.config.ts → jest.config.cjs} +1 -1
  79. package/providers/commercetools/package.json +3 -2
  80. package/providers/commercetools/src/core/client.ts +63 -32
  81. package/providers/commercetools/src/core/initialize.ts +20 -16
  82. package/providers/commercetools/src/index.ts +10 -10
  83. package/providers/commercetools/src/providers/cart.provider.ts +14 -19
  84. package/providers/commercetools/src/providers/category.provider.ts +3 -12
  85. package/providers/commercetools/src/providers/checkout.provider.ts +644 -0
  86. package/providers/commercetools/src/providers/identity.provider.ts +8 -8
  87. package/providers/commercetools/src/providers/index.ts +12 -9
  88. package/providers/commercetools/src/providers/inventory.provider.ts +2 -4
  89. package/providers/commercetools/src/providers/order.provider.ts +163 -0
  90. package/providers/commercetools/src/providers/price.provider.ts +3 -3
  91. package/providers/commercetools/src/providers/product.provider.ts +24 -6
  92. package/providers/commercetools/src/providers/profile.provider.ts +2 -2
  93. package/providers/commercetools/src/providers/search.provider.ts +3 -5
  94. package/providers/commercetools/src/providers/store.provider.ts +3 -3
  95. package/providers/commercetools/src/schema/capabilities.schema.ts +2 -1
  96. package/providers/commercetools/src/schema/commercetools.schema.ts +7 -5
  97. package/providers/commercetools/src/schema/configuration.schema.ts +2 -0
  98. package/providers/commercetools/src/test/cart.provider.spec.ts +24 -4
  99. package/providers/commercetools/src/test/category.provider.spec.ts +3 -3
  100. package/providers/commercetools/src/test/checkout.provider.spec.ts +312 -0
  101. package/providers/commercetools/src/test/identity.provider.spec.ts +3 -3
  102. package/providers/commercetools/src/test/inventory.provider.spec.ts +2 -2
  103. package/providers/commercetools/src/test/price.provider.spec.ts +4 -4
  104. package/providers/commercetools/src/test/product.provider.spec.ts +22 -5
  105. package/providers/commercetools/src/test/profile.provider.spec.ts +3 -3
  106. package/providers/commercetools/src/test/search.provider.spec.ts +2 -2
  107. package/providers/commercetools/src/test/store.provider.spec.ts +2 -2
  108. package/providers/commercetools/src/test/test-utils.ts +14 -0
  109. package/providers/commercetools/tsconfig.json +2 -1
  110. package/providers/commercetools/tsconfig.spec.json +4 -3
  111. package/providers/fake/{jest.config.ts → jest.config.cjs} +1 -1
  112. package/providers/fake/package.json +2 -2
  113. package/providers/fake/src/core/initialize.ts +6 -6
  114. package/providers/fake/src/index.ts +4 -4
  115. package/providers/fake/src/providers/analytics.provider.ts +1 -1
  116. package/providers/fake/src/providers/cart.provider.ts +2 -2
  117. package/providers/fake/src/providers/category.provider.ts +7 -3
  118. package/providers/fake/src/providers/identity.provider.ts +1 -1
  119. package/providers/fake/src/providers/index.ts +9 -9
  120. package/providers/fake/src/providers/inventory.provider.ts +1 -1
  121. package/providers/fake/src/providers/price.provider.ts +1 -1
  122. package/providers/fake/src/providers/product.provider.ts +10 -4
  123. package/providers/fake/src/providers/search.provider.ts +2 -5
  124. package/providers/fake/src/providers/store.provider.ts +2 -3
  125. package/providers/fake/src/test/cart.provider.spec.ts +3 -3
  126. package/providers/fake/src/test/category.provider.spec.ts +2 -2
  127. package/providers/fake/src/test/price.provider.spec.ts +2 -2
  128. package/providers/fake/src/test/product.provider.spec.ts +8 -8
  129. package/providers/fake/src/test/test-utils.ts +1 -1
  130. package/providers/fake/tsconfig.json +2 -1
  131. package/providers/fake/tsconfig.spec.json +1 -3
  132. package/providers/posthog/package.json +4 -4
  133. package/providers/posthog/project.json +2 -2
  134. package/providers/posthog/src/core/initialize.ts +2 -2
  135. package/providers/posthog/src/index.ts +3 -3
  136. package/providers/posthog/tsconfig.json +2 -1
  137. package/tsconfig.base.json +3 -4
  138. package/.claude/settings.local.json +0 -28
  139. package/core/src/providers/cart-payment.provider.ts +0 -57
  140. package/core/src/schemas/mutations/cart-payment.mutation.ts +0 -21
  141. package/core/src/schemas/queries/cart-payment.query.ts +0 -12
  142. package/otel/README.md +0 -227
  143. package/otel/eslint.config.mjs +0 -23
  144. package/otel/package.json +0 -11
  145. package/otel/pnpm-lock.yaml +0 -805
  146. package/otel/project.json +0 -33
  147. package/otel/src/index.ts +0 -22
  148. package/otel/src/metrics.ts +0 -76
  149. package/otel/src/provider-instrumentation.ts +0 -108
  150. package/otel/src/test/otel.spec.ts +0 -8
  151. package/otel/src/trace-decorator.ts +0 -226
  152. package/otel/src/tracer.ts +0 -83
  153. package/otel/src/trpc-middleware.ts +0 -128
  154. package/otel/tsconfig.json +0 -23
  155. package/otel/tsconfig.lib.json +0 -23
  156. package/otel/tsconfig.spec.json +0 -28
  157. package/otel/vite.config.ts +0 -24
  158. package/providers/commercetools/src/providers/cart-payment.provider.ts +0 -193
  159. package/providers/commercetools/src/test/cart-payment.provider.spec.ts +0 -145
  160. package/trpc/README.md +0 -7
  161. package/trpc/__mocks__/superjson.js +0 -25
  162. package/trpc/eslint.config.mjs +0 -19
  163. package/trpc/jest.config.ts +0 -14
  164. package/trpc/package.json +0 -14
  165. package/trpc/project.json +0 -31
  166. package/trpc/src/client.ts +0 -175
  167. package/trpc/src/index.ts +0 -44
  168. package/trpc/src/integration.spec.ts +0 -223
  169. package/trpc/src/server.ts +0 -125
  170. package/trpc/src/test-utils.ts +0 -31
  171. package/trpc/src/transparent-client.spec.ts +0 -162
  172. package/trpc/src/types.ts +0 -144
  173. package/trpc/tsconfig.json +0 -16
  174. package/trpc/tsconfig.lib.json +0 -10
  175. package/trpc/tsconfig.spec.json +0 -15
@@ -0,0 +1,66 @@
1
+
2
+
3
+ import { z } from 'zod';
4
+ import { BaseModelSchema } from './base.model.js';
5
+ import { CartIdentifierSchema, CheckoutIdentifierSchema, CheckoutItemIdentifierSchema, OrderIdentifierSchema, SKUIdentifierSchema } from './identifiers.model.js';
6
+ import { CostBreakDownSchema, ItemCostBreakdownSchema } from './cost.model.js';
7
+ import { AddressSchema } from './profile.model.js';
8
+ import { ShippingInstructionSchema } from './shipping-method.model.js';
9
+ import { PaymentInstructionSchema } from './payment.model.js';
10
+
11
+ export const CheckoutItemSchema = z.looseObject({
12
+ identifier: CheckoutItemIdentifierSchema.default(() => CheckoutItemIdentifierSchema.parse({})),
13
+ sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
14
+ quantity: z.number().default(0),
15
+ price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({})),
16
+ });
17
+
18
+
19
+ /**
20
+ * A checkout represents the data entity that is used to create an order.
21
+ * The checkout is "stable", meaning you cannot change items or quantities on it. Only shipping, billing, and payment details.
22
+ *
23
+ * This means, a cart is never checked out. Rather you provide the cart and other fixed info to the checkout, and from there you get
24
+ * payments and shipping methods.
25
+ */
26
+ export const CheckoutSchema = BaseModelSchema.extend({
27
+ identifier: CheckoutIdentifierSchema.default(() => CheckoutIdentifierSchema.parse({})),
28
+
29
+ /**
30
+ * Do we need this?
31
+ */
32
+ originalCartReference: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
33
+
34
+ /**
35
+ * If the checkout has been completed, this will point to the resulting order.
36
+ */
37
+ resultingOrder: OrderIdentifierSchema.optional(),
38
+
39
+ items: z.array(CheckoutItemSchema).default(() => []),
40
+ price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
41
+
42
+ name: z.string().default(''),
43
+ description: z.string().default(''),
44
+
45
+
46
+ billingAddress: AddressSchema.optional(),
47
+
48
+ /**
49
+ * Shipping and billing details can be changed on the checkout, but not items or quantities.
50
+ */
51
+ shippingAddress: AddressSchema.optional(),
52
+ shippingInstruction: ShippingInstructionSchema.optional(),
53
+ paymentInstructions: z.array(PaymentInstructionSchema).default(() => []),
54
+
55
+ /**
56
+ * Indicates if the checkout has all the required information to be finalized into an order.
57
+ * This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present.
58
+ */
59
+ readyForFinalization: z.boolean().default(false).describe('Indicates if the checkout has all the required information to be finalized into an order. This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present.'),
60
+ });
61
+
62
+
63
+
64
+
65
+ export type CheckoutItem = z.infer<typeof CheckoutItemSchema>;
66
+ export type Checkout = z.infer<typeof CheckoutSchema>;
@@ -0,0 +1,21 @@
1
+ import z from "zod";
2
+ import { MonetaryAmountSchema } from "./price.model.js";
3
+
4
+ export const CostBreakDownSchema = z.looseObject({
5
+ totalTax: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The amount of tax paid on the cart. This may include VAT, GST, sales tax, etc.'),
6
+ totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The amount of discount applied to the cart.'),
7
+ totalSurcharge: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The amount of surcharge applied to the cart.'),
8
+ totalShipping: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The amount of shipping fees for the cart.'),
9
+ totalProductPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The total price of products in the cart.'),
10
+ grandTotal: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The total price for the cart including all taxes, discounts, and shipping.'),
11
+ });
12
+
13
+ export const ItemCostBreakdownSchema = z.looseObject({
14
+ unitPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The price per single unit of the item.'),
15
+ unitDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The discount applied per single unit of the item.'),
16
+ totalPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The total price for all units of the item.'),
17
+ totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe('The total discount applied to all units of the item.'),
18
+ });
19
+
20
+ export type CostBreakDown = z.infer<typeof CostBreakDownSchema>;
21
+ export type ItemCostBreakdown = z.infer<typeof ItemCostBreakdownSchema>;
@@ -52,6 +52,15 @@ export const OrderItemIdentifierSchema = z.looseObject({
52
52
  key: z.string().default('').nonoptional(),
53
53
  });
54
54
 
55
+
56
+ export const CheckoutIdentifierSchema = z.looseObject({
57
+ key: z.string().default('').nonoptional()
58
+ });
59
+
60
+ export const CheckoutItemIdentifierSchema = z.looseObject({
61
+ key: z.string().default('').nonoptional()
62
+ });
63
+
55
64
  /**
56
65
  * The target store the user is interacting with. Can change over time, and is not necessarily the same as the default store.
57
66
  */
@@ -75,7 +84,7 @@ export const IdentityIdentifierSchema = z.looseObject({
75
84
  });
76
85
 
77
86
  export const ShippingMethodIdentifierSchema = z.looseObject({
78
- key: z.string().default('').nonoptional(),
87
+ key: z.string().default('').nonoptional(),
79
88
  });
80
89
 
81
90
  export const PaymentMethodIdentifierSchema = z.looseObject({
@@ -92,6 +101,10 @@ export const PaymentInstructionIdentifierSchema = z.looseObject({
92
101
  key: z.string().default('').nonoptional(),
93
102
  });
94
103
 
104
+ export const PickupPointIdentifierSchema = z.looseObject({
105
+ key: z.string().default('').nonoptional()
106
+ });
107
+
95
108
  export type ProductIdentifier = z.infer<typeof ProductIdentifierSchema>;
96
109
  export type SearchIdentifier = z.infer<typeof SearchIdentifierSchema>;
97
110
  export type FacetIdentifier = z.infer<typeof FacetIdentifierSchema>;
@@ -118,6 +131,10 @@ export type PaymentInstructionIdentifier = z.infer<
118
131
  >;
119
132
  export type OrderIdentifier = z.infer<typeof OrderIdentifierSchema>;
120
133
  export type OrderItemIdentifier = z.infer<typeof OrderItemIdentifierSchema>;
134
+
135
+ export type CheckoutIdentifier = z.infer<typeof CheckoutIdentifierSchema>;
136
+ export type CheckoutItemIdentifier = z.infer<typeof CheckoutItemIdentifierSchema>;
137
+ export type PickupPointIdentifier = z.infer<typeof PickupPointIdentifierSchema>;
121
138
  export type StoreIdentifier = z.infer<typeof StoreIdentifierSchema>;
122
139
 
123
140
  export type IdentifierType =
@@ -138,4 +155,8 @@ export type IdentifierType =
138
155
  | AddressIdentifier
139
156
  | PaymentInstructionIdentifier
140
157
  | OrderIdentifier
141
- | OrderItemIdentifier;
158
+ | OrderItemIdentifier
159
+ | CheckoutIdentifier
160
+ | CheckoutItemIdentifier
161
+ | StoreIdentifier
162
+ | PickupPointIdentifier;
@@ -1,14 +1,17 @@
1
1
  import { z } from 'zod';
2
- import { BaseModelSchema } from './base.model';
3
- import { IdentityIdentifierSchema } from './identifiers.model';
2
+ import { BaseModelSchema } from './base.model.js';
3
+ import { IdentityIdentifierSchema } from './identifiers.model.js';
4
4
 
5
5
  export const AnonymousIdentitySchema = BaseModelSchema.extend({
6
- type: z.literal('Anonymous')
6
+ type: z.literal('Anonymous').default('Anonymous'),
7
+ token: z.string().optional(),
8
+ refresh_token: z.string().optional(),
9
+ expiry: z.coerce.date().default(new Date())
7
10
  });
8
11
 
9
12
  export const GuestIdentitySchema = BaseModelSchema.extend({
10
13
  id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
11
- type: z.literal('Guest'),
14
+ type: z.literal('Guest').default('Guest'),
12
15
  token: z.string().optional(),
13
16
  refresh_token: z.string().optional(),
14
17
  expiry: z.coerce.date().default(new Date())
@@ -16,7 +19,7 @@ export const GuestIdentitySchema = BaseModelSchema.extend({
16
19
 
17
20
  export const RegisteredIdentitySchema = BaseModelSchema.extend({
18
21
  id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
19
- type: z.literal('Registered'),
22
+ type: z.literal('Registered').default('Registered'),
20
23
  logonId: z.string().default(''),
21
24
  token: z.string().optional(),
22
25
  refresh_token: z.string().optional(),
@@ -1,15 +1,19 @@
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';
1
+ export * from './analytics.model.js';
2
+ export * from './base.model.js';
3
+ export * from './cart.model.js';
4
+ export * from './category.model.js';
5
+ export * from './currency.model.js';
6
+ export * from './identifiers.model.js';
7
+ export * from './identity.model.js';
8
+ export * from './inventory.model.js';
9
+ export * from './payment.model.js';
10
+ export * from './price.model.js';
11
+ export * from './product.model.js';
12
+ export * from './profile.model.js';
13
+ export * from './search.model.js';
14
+ export * from './shipping-method.model.js';
15
+ export * from './store.model.js';
16
+ export * from './order.model.js';
17
+ export * from './cost.model.js';
18
+ export * from './checkout.model.js';
19
+ export * from './payment.model.js';
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { BaseModelSchema } from './base.model';
3
- import { InventoryIdentifierSchema } from './identifiers.model';
2
+ import { BaseModelSchema } from './base.model.js';
3
+ import { InventoryIdentifierSchema } from './identifiers.model.js';
4
4
 
5
5
  export const InventorySchema = BaseModelSchema.extend({
6
6
  identifier: InventoryIdentifierSchema.default(() => InventoryIdentifierSchema.parse({})),
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { CartIdentifierSchema, CartItemIdentifierSchema, IdentityIdentifierSchema, SKUIdentifierSchema } from '../models/identifiers.model.js';
3
+ import { BaseModelSchema } from './base.model.js';
4
+ import { AddressSchema } from './profile.model.js';
5
+ import { ShippingMethodSchema } from './shipping-method.model.js';
6
+ import { CostBreakDownSchema, ItemCostBreakdownSchema } from './cost.model.js';
7
+ import { PaymentInstructionSchema } from './payment.model.js';
8
+
9
+ export const OrderStatusSchema = z.enum(['AwaitingPayment', 'ReleasedToFulfillment', 'Shipped', 'Cancelled']).default('AwaitingPayment').describe('The current status of the order.');
10
+ export const OrderInventoryStatusSchema = z.enum(['NotAllocated', 'Allocated', 'Backordered', 'Preordered']).default('Allocated').describe('The inventory release status of the order.');
11
+
12
+
13
+ export const OrderItemSchema = z.looseObject({
14
+ identifier: CartItemIdentifierSchema.default(() => CartItemIdentifierSchema.parse({})),
15
+ sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
16
+ quantity: z.number().default(0),
17
+ price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({})),
18
+
19
+ inventoryStatus: OrderInventoryStatusSchema.default('Allocated').describe('The inventory release status of the order item.'),
20
+ });
21
+
22
+ export const OrderSchema = BaseModelSchema.extend({
23
+ identifier: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
24
+
25
+ userId: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
26
+
27
+ items: z.array(OrderItemSchema).default(() => []),
28
+ price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
29
+ name: z.string().default(''),
30
+ description: z.string().default(''),
31
+
32
+ shippingAddress: AddressSchema.optional(),
33
+ billingAddress: AddressSchema.optional(),
34
+ shippingMethod: ShippingMethodSchema.optional(),
35
+
36
+ orderStatus: OrderStatusSchema.default('AwaitingPayment'),
37
+ inventoryStatus: OrderInventoryStatusSchema.default('Allocated'),
38
+
39
+ paymentInstructions: z.array(PaymentInstructionSchema).default(() => []),
40
+ cartReference: CartIdentifierSchema.optional().describe('Reference to the cart from which this order was created.'),
41
+ });
42
+
43
+
44
+
45
+ export type OrderItem = z.infer<typeof OrderItemSchema>;
46
+ export type Order = z.infer<typeof OrderSchema>;
@@ -1,8 +1,7 @@
1
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';
2
+ import { BaseModelSchema, ImageSchema } from './base.model.js';
3
+ import { PaymentInstructionIdentifierSchema, PaymentMethodIdentifierSchema } from './identifiers.model.js';
4
+ import { MonetaryAmountSchema } from './price.model.js';
6
5
 
7
6
  export const PaymentStatusSchema = z.enum(['pending', 'authorized', 'canceled', 'capture', 'partial_capture', 'refunded', 'partial_refund']);
8
7
 
@@ -27,15 +26,9 @@ export const PaymentInstructionSchema = BaseModelSchema.extend({
27
26
  status: PaymentStatusSchema.default('pending'),
28
27
  });
29
28
 
30
- export const CartPaymentInstructionSchema = PaymentInstructionSchema.extend({
31
- cart: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({}))
32
- });
33
29
 
34
- export const OrderPaymentInstructionSchema = PaymentInstructionSchema.extend({
35
- order: z.string().default('') // OrderIdentifierSchema
36
- });
37
30
 
38
- export type CartPaymentInstruction = z.infer<typeof CartPaymentInstructionSchema>;
39
- export type OrderPaymentInstruction = z.infer<typeof OrderPaymentInstructionSchema>;
31
+
40
32
  export type PaymentInstruction = z.infer<typeof PaymentInstructionSchema>;
41
33
  export type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
34
+ export type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { BaseModelSchema } from './base.model';
3
- import { PriceIdentifierSchema } from './identifiers.model';
4
- import { CurrencySchema } from './currency.model';
2
+ import { BaseModelSchema } from './base.model.js';
3
+ import { PriceIdentifierSchema } from './identifiers.model.js';
4
+ import { CurrencySchema } from './currency.model.js';
5
5
 
6
6
  export const MonetaryAmountSchema = z.looseObject({
7
7
  value: z.number().default(0).describe('The monetary amount in decimal-precision.'),
@@ -1,9 +1,12 @@
1
1
  import { z } from 'zod';
2
- import { ProductIdentifierSchema } from './identifiers.model';
3
- import { BaseModelSchema } from './base.model';
2
+ import { ProductIdentifierSchema, SKUIdentifierSchema } from './identifiers.model.js';
3
+ import { BaseModelSchema } from './base.model.js';
4
4
 
5
5
  export const SKUSchema = z.looseObject({
6
- identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
6
+ identifier: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
7
+ /* name: z.string().default(''),
8
+ slug: z.string().default(''),
9
+ image: ImageSchema.default(() => ImageSchema.parse({})), */
7
10
  });
8
11
 
9
12
  export const ProductAttributeSchema = z.looseObject({
@@ -1,6 +1,6 @@
1
1
  import z from "zod";
2
- import { AddressIdentifierSchema, IdentityIdentifierSchema } from "./identifiers.model";
3
- import { BaseModelSchema } from "./base.model";
2
+ import { AddressIdentifierSchema, IdentityIdentifierSchema } from "./identifiers.model.js";
3
+ import { BaseModelSchema } from "./base.model.js";
4
4
 
5
5
  export const AddressSchema = BaseModelSchema.extend({
6
6
  identifier: AddressIdentifierSchema.default(() => AddressIdentifierSchema.parse({})),
@@ -1,7 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSchema, SearchIdentifierSchema } from './identifiers.model';
3
- import { BaseModelSchema, createPaginatedResponseSchema } from './base.model';
4
- import { create } from 'domain';
2
+ import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSchema, SearchIdentifierSchema } from './identifiers.model.js';
3
+ import { BaseModelSchema } from './base.model.js';
5
4
 
6
5
  export const SearchResultProductSchema = z.looseObject({
7
6
  identifier: ProductIdentifierSchema.default(ProductIdentifierSchema.parse({})),
@@ -1,7 +1,25 @@
1
1
  import z from "zod";
2
- import { ShippingMethodIdentifierSchema } from "./identifiers.model";
3
- import { MonetaryAmountSchema } from "./price.model";
4
- import { ImageSchema } from "./base.model";
2
+ import { ShippingMethodIdentifierSchema } from "./identifiers.model.js";
3
+ import { MonetaryAmountSchema } from "./price.model.js";
4
+ import { BaseModelSchema, ImageSchema } from "./base.model.js";
5
+ import { AddressSchema } from "./profile.model.js";
6
+
7
+
8
+
9
+
10
+ export const PickupPointSchema = z.looseObject({
11
+ identifier: z.object({
12
+ key: z.string().default('').nonoptional()
13
+ }).default(() => ({ key: '' })),
14
+ name: z.string().default(''),
15
+ description: z.string().default(''),
16
+ address: AddressSchema.default(() => AddressSchema.parse({})),
17
+ openingHours: z.string().default('').optional().describe('The opening hours of the pickup point, if applicable. This could be a string like "Mon-Fri 9am-5pm".'),
18
+ contactPhone: z.string().default('').optional().describe('The contact phone number for the pickup point, if applicable.'),
19
+ contactEmail: z.string().default('').optional().describe('The contact email for the pickup point, if applicable.'),
20
+ instructions: z.string().default('').optional().describe('Any special instructions for picking up from this point.'),
21
+ });
22
+
5
23
 
6
24
  export const ShippingMethodSchema = z.looseObject({
7
25
  identifier: ShippingMethodIdentifierSchema.default(() => ShippingMethodIdentifierSchema.parse({})),
@@ -10,5 +28,18 @@ export const ShippingMethodSchema = z.looseObject({
10
28
  logo: ImageSchema.optional(),
11
29
  price: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})),
12
30
  deliveryTime: z.string().default(''),
31
+ carrier: z.string().default('').optional(),
32
+ });
33
+
34
+
35
+ export const ShippingInstructionSchema = BaseModelSchema.extend({
36
+ shippingMethod: ShippingMethodIdentifierSchema.default(() => ShippingMethodIdentifierSchema.parse({})),
37
+ pickupPoint: z.string().default('').describe('An optional pickup point for the shipping method. This could be a physical store, a locker, or similar. If not set, it means home delivery to the shipping address.'),
38
+ instructions: z.string().default('').describe('Optional instructions for the shipping. This could be delivery instructions, or similar.'),
39
+ consentForUnattendedDelivery: z.boolean().default(false).describe('Indicates if the customer has given consent for unattended delivery, if applicable.'),
13
40
  });
14
41
 
42
+
43
+ export type ShippingMethod = z.infer<typeof ShippingMethodSchema>;
44
+ export type PickupPoint = z.infer<typeof PickupPointSchema>;
45
+ export type ShippingInstruction = z.infer<typeof ShippingInstructionSchema>;
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { BaseModelSchema } from './base.model';
3
- import { FulfillmentCenterIdentifierSchema, StoreIdentifierSchema } from './identifiers.model';
2
+ import { BaseModelSchema } from './base.model.js';
3
+ import { FulfillmentCenterIdentifierSchema, StoreIdentifierSchema } from './identifiers.model.js';
4
4
 
5
5
  export const StoreSchema = BaseModelSchema.extend({
6
6
  identifier: StoreIdentifierSchema.default(() => StoreIdentifierSchema.parse({})),
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { BaseMutationSchema } from './base.mutation';
3
- import { ProductIdentifierSchema, SearchIdentifierSchema } from '../models/identifiers.model';
2
+ import { BaseMutationSchema } from './base.mutation.js';
3
+ import { ProductIdentifierSchema, SearchIdentifierSchema } from '../models/identifiers.model.js';
4
4
 
5
5
  export const AnalyticsMutationSearchEventSchema = BaseMutationSchema.extend({
6
6
  mutation: z.literal('search'),
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { BaseMutationSchema } from './base.mutation';
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';
2
+ import { BaseMutationSchema } from './base.mutation.js';
3
+ import { CartIdentifierSchema, CartItemIdentifierSchema, PaymentMethodIdentifierSchema, ShippingMethodIdentifierSchema, SKUIdentifierSchema } from '../models/identifiers.model.js';
4
+ import { AddressSchema } from '../models/profile.model.js';
5
+ import { CurrencySchema } from '../models/currency.model.js';
6
+ import { MonetaryAmountSchema } from '../models/price.model.js';
7
7
 
8
8
  export const CartMutationItemAddSchema = BaseMutationSchema.extend({
9
9
  cart: CartIdentifierSchema.nonoptional(),
@@ -0,0 +1,50 @@
1
+ import z from "zod";
2
+ import { CartIdentifierSchema, AddressSchema, PaymentInstructionIdentifierSchema, PaymentInstructionSchema, ShippingInstructionSchema } from "../models/index.js";
3
+ import { BaseMutationSchema } from "./base.mutation.js";
4
+
5
+
6
+ export const CheckoutMutationInitiateCheckoutSchema = BaseMutationSchema.extend({
7
+ cart: CartIdentifierSchema.required(),
8
+ billingAddress: AddressSchema.omit({identifier: true}).optional(),
9
+ notificationEmail: z.string().optional(),
10
+ notificationPhone: z.string().optional(),
11
+ });
12
+
13
+ export const CheckoutMutationSetShippingAddressSchema = BaseMutationSchema.extend({
14
+ checkout: CartIdentifierSchema.required(),
15
+ shippingAddress: AddressSchema.omit({identifier: true}).required(),
16
+ });
17
+
18
+
19
+ export const CheckoutMutationFinalizeCheckoutSchema = BaseMutationSchema.extend({
20
+ checkout: CartIdentifierSchema.required(),
21
+ });
22
+
23
+
24
+ export const CheckoutMutationAddPaymentInstruction = BaseMutationSchema.extend({
25
+ paymentInstruction: PaymentInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
26
+ checkout: CartIdentifierSchema.required()
27
+ });
28
+
29
+ export const CheckoutMutationRemovePaymentInstruction = BaseMutationSchema.extend({
30
+ paymentInstruction: PaymentInstructionIdentifierSchema.required(),
31
+ checkout: CartIdentifierSchema.required()
32
+ });
33
+
34
+
35
+
36
+ export const CheckoutMutationSetShippingInstruction = BaseMutationSchema.extend({
37
+ shippingInstruction: ShippingInstructionSchema.omit({ meta: true, status: true, identifier: true }).required(),
38
+ checkout: CartIdentifierSchema.required()
39
+ });
40
+
41
+
42
+
43
+
44
+
45
+ export type CheckoutMutationInitiateCheckout = z.infer<typeof CheckoutMutationInitiateCheckoutSchema>;
46
+ export type CheckoutMutationSetShippingAddress = z.infer<typeof CheckoutMutationSetShippingAddressSchema>;
47
+ export type CheckoutMutationFinalizeCheckout = z.infer<typeof CheckoutMutationFinalizeCheckoutSchema>;
48
+ export type CheckoutMutationAddPaymentInstruction = z.infer<typeof CheckoutMutationAddPaymentInstruction>;
49
+ export type CheckoutMutationRemovePaymentInstruction = z.infer<typeof CheckoutMutationRemovePaymentInstruction>;
50
+ export type CheckoutMutationSetShippingInstruction = z.infer<typeof CheckoutMutationSetShippingInstruction>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { BaseMutationSchema } from './base.mutation';
2
+ import { BaseMutationSchema } from './base.mutation.js';
3
3
 
4
4
  export const IdentityMutationLoginSchema = BaseMutationSchema.extend({
5
5
  username: z.string(),
@@ -1,10 +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';
1
+ export * from './analytics.mutation.js';
2
+ export * from './base.mutation.js';
3
+ export * from './cart.mutation.js';
4
+ export * from './identity.mutation.js';
5
+ export * from './inventory.mutation.js';
6
+ export * from './price.mutation.js';
7
+ export * from './product.mutation.js';
8
+ export * from './profile.mutation.js';
9
+ export * from './search.mutation.js';
10
+ export * from './checkout.mutation.js';
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { BaseMutationSchema } from './base.mutation';
2
+ import { BaseMutationSchema } from './base.mutation.js';
3
3
 
4
4
  export const ProfileMutationUpdateSchema = BaseMutationSchema.extend({
5
5
  email: z.email().default('base@example.com'),
@@ -1,6 +1,6 @@
1
1
  import type { z } from 'zod';
2
- import { BaseQuerySchema } from './base.query';
3
- import { CartIdentifierSchema } from '../models/identifiers.model';
2
+ import { BaseQuerySchema } from './base.query.js';
3
+ import { CartIdentifierSchema } from '../models/identifiers.model.js';
4
4
 
5
5
  export const CartQueryByIdSchema = BaseQuerySchema.extend({
6
6
  cart: CartIdentifierSchema.required()
@@ -1,7 +1,7 @@
1
1
  import z from "zod";
2
- import { CategoryIdentifierSchema } from "../models/identifiers.model";
3
- import { BaseQuerySchema } from "./base.query";
4
- import { PaginationOptionsSchema } from "../models/base.model";
2
+ import { CategoryIdentifierSchema } from "../models/identifiers.model.js";
3
+ import { BaseQuerySchema } from "./base.query.js";
4
+ import { PaginationOptionsSchema } from "../models/base.model.js";
5
5
 
6
6
  export const CategoryQueryById = BaseQuerySchema.extend({
7
7
  id: CategoryIdentifierSchema.default(() => CategoryIdentifierSchema.parse({})),
@@ -0,0 +1,22 @@
1
+ import type { z } from 'zod';
2
+ import { BaseQuerySchema } from './base.query.js';
3
+ import { CheckoutIdentifierSchema } from '../models/identifiers.model.js';
4
+
5
+ export const CheckoutQueryByIdSchema = BaseQuerySchema.extend({
6
+ identifier: CheckoutIdentifierSchema.required()
7
+ });
8
+
9
+
10
+ export const CheckoutQueryForAvailableShippingMethodsSchema = BaseQuerySchema.extend({
11
+ checkout: CheckoutIdentifierSchema.required()
12
+ });
13
+
14
+ export const CheckoutQueryForAvailablePaymentMethodsSchema = BaseQuerySchema.extend({
15
+ checkout: CheckoutIdentifierSchema.required()
16
+ });
17
+
18
+
19
+
20
+ export type CheckoutQueryForAvailableShippingMethods = z.infer<typeof CheckoutQueryForAvailableShippingMethodsSchema>;
21
+ export type CheckoutQueryForAvailablePaymentMethods = z.infer<typeof CheckoutQueryForAvailablePaymentMethodsSchema>;
22
+ export type CheckoutQueryById = z.infer<typeof CheckoutQueryByIdSchema>;
@@ -1,5 +1,5 @@
1
1
  import type { z } from 'zod';
2
- import { BaseQuerySchema } from './base.query';
2
+ import { BaseQuerySchema } from './base.query.js';
3
3
 
4
4
  export const IdentityQuerySelfSchema = BaseQuerySchema.extend({
5
5
 
@@ -1,12 +1,13 @@
1
- export * from './analytics.query';
2
- export * from './base.query';
3
- export * from './cart-payment.query';
4
- export * from './cart.query';
5
- export * from './category.query';
6
- export * from './identity.query';
7
- export * from './inventory.query';
8
- export * from './price.query';
9
- export * from './product.query';
10
- export * from './profile.query';
11
- export * from './search.query';
12
- export * from './store.query';
1
+ export * from './analytics.query.js';
2
+ export * from './base.query.js';
3
+ export * from './cart.query.js';
4
+ export * from './category.query.js';
5
+ export * from './identity.query.js';
6
+ export * from './inventory.query.js';
7
+ export * from './price.query.js';
8
+ export * from './product.query.js';
9
+ export * from './profile.query.js';
10
+ export * from './search.query.js';
11
+ export * from './store.query.js';
12
+ export * from './order.query.js';
13
+ export * from './checkout.query.js';
@@ -1,6 +1,6 @@
1
1
  import type { z } from 'zod';
2
- import { BaseQuerySchema } from './base.query';
3
- import { FulfillmentCenterIdentifierSchema, ProductIdentifierSchema } from '../models/identifiers.model';
2
+ import { BaseQuerySchema } from './base.query.js';
3
+ import { FulfillmentCenterIdentifierSchema, ProductIdentifierSchema } from '../models/identifiers.model.js';
4
4
 
5
5
  export const InventoryQueryBySKUSchema = BaseQuerySchema.extend({
6
6
  sku: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})).nonoptional(),
@@ -0,0 +1,9 @@
1
+ import type { z } from 'zod';
2
+ import { BaseQuerySchema } from './base.query.js';
3
+ import { OrderIdentifierSchema } from '../models/identifiers.model.js';
4
+
5
+ export const OrderQueryByIdSchema = BaseQuerySchema.extend({
6
+ order: OrderIdentifierSchema.required()
7
+ });
8
+
9
+ export type OrderQueryById = z.infer<typeof OrderQueryByIdSchema>;
@@ -1,6 +1,6 @@
1
1
  import type { z } from 'zod';
2
- import { BaseQuerySchema } from './base.query';
3
- import { SKUIdentifierSchema } from '../models/identifiers.model';
2
+ import { BaseQuerySchema } from './base.query.js';
3
+ import { SKUIdentifierSchema } from '../models/identifiers.model.js';
4
4
 
5
5
  export const PriceQueryBySkuSchema = BaseQuerySchema.extend({
6
6
  sku: SKUIdentifierSchema.required(),