@reactionary/core 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 (109) hide show
  1. package/client/client-builder.js +1 -1
  2. package/client/client.js +1 -1
  3. package/decorators/reactionary.decorator.js +15 -2
  4. package/index.js +14 -14
  5. package/package.json +5 -4
  6. package/providers/analytics.provider.js +1 -1
  7. package/providers/base.provider.js +1 -1
  8. package/providers/cart.provider.js +1 -1
  9. package/providers/category.provider.js +1 -1
  10. package/providers/checkout.provider.js +6 -0
  11. package/providers/identity.provider.js +1 -1
  12. package/providers/index.js +13 -12
  13. package/providers/inventory.provider.js +1 -1
  14. package/providers/order.provider.js +15 -0
  15. package/providers/price.provider.js +1 -1
  16. package/providers/product.provider.js +1 -1
  17. package/providers/profile.provider.js +1 -1
  18. package/providers/search.provider.js +1 -1
  19. package/providers/store.provider.js +1 -1
  20. package/schemas/capabilities.schema.js +2 -1
  21. package/schemas/models/analytics.model.js +1 -1
  22. package/schemas/models/cart.model.js +5 -26
  23. package/schemas/models/category.model.js +2 -2
  24. package/schemas/models/checkout.model.js +44 -0
  25. package/schemas/models/cost.model.js +20 -0
  26. package/schemas/models/identifiers.model.js +12 -0
  27. package/schemas/models/identity.model.js +8 -5
  28. package/schemas/models/index.js +19 -15
  29. package/schemas/models/inventory.model.js +2 -2
  30. package/schemas/models/order.model.js +37 -0
  31. package/schemas/models/payment.model.js +3 -12
  32. package/schemas/models/price.model.js +3 -3
  33. package/schemas/models/product.model.js +6 -3
  34. package/schemas/models/profile.model.js +2 -2
  35. package/schemas/models/search.model.js +2 -2
  36. package/schemas/models/shipping-method.model.js +26 -4
  37. package/schemas/models/store.model.js +2 -2
  38. package/schemas/mutations/analytics.mutation.js +2 -2
  39. package/schemas/mutations/cart.mutation.js +5 -5
  40. package/schemas/mutations/checkout.mutation.js +36 -0
  41. package/schemas/mutations/identity.mutation.js +1 -1
  42. package/schemas/mutations/index.js +10 -10
  43. package/schemas/mutations/inventory.mutation.js +1 -0
  44. package/schemas/mutations/price.mutation.js +1 -0
  45. package/schemas/mutations/product.mutation.js +1 -0
  46. package/schemas/mutations/profile.mutation.js +1 -1
  47. package/schemas/mutations/search.mutation.js +1 -0
  48. package/schemas/queries/analytics.query.js +1 -0
  49. package/schemas/queries/cart.query.js +2 -2
  50. package/schemas/queries/category.query.js +3 -3
  51. package/schemas/queries/checkout.query.js +16 -0
  52. package/schemas/queries/identity.query.js +1 -1
  53. package/schemas/queries/index.js +13 -12
  54. package/schemas/queries/inventory.query.js +2 -2
  55. package/schemas/queries/order.query.js +8 -0
  56. package/schemas/queries/price.query.js +2 -2
  57. package/schemas/queries/product.query.js +6 -1
  58. package/schemas/queries/profile.query.js +1 -1
  59. package/schemas/queries/search.query.js +2 -2
  60. package/schemas/queries/store.query.js +1 -1
  61. package/schemas/session.schema.js +3 -3
  62. package/src/cache/cache.interface.d.ts +1 -1
  63. package/src/cache/memory-cache.d.ts +2 -2
  64. package/src/cache/noop-cache.d.ts +1 -1
  65. package/src/cache/redis-cache.d.ts +1 -1
  66. package/src/client/client-builder.d.ts +2 -2
  67. package/src/client/client.d.ts +11 -11
  68. package/src/decorators/reactionary.decorator.d.ts +3 -1
  69. package/src/index.d.ts +14 -14
  70. package/src/initialization.d.ts +1 -1
  71. package/src/providers/analytics.provider.d.ts +2 -2
  72. package/src/providers/base.provider.d.ts +5 -5
  73. package/src/providers/cart.provider.d.ts +6 -6
  74. package/src/providers/category.provider.d.ts +4 -4
  75. package/src/providers/checkout.provider.d.ts +135 -0
  76. package/src/providers/identity.provider.d.ts +5 -5
  77. package/src/providers/index.d.ts +13 -12
  78. package/src/providers/inventory.provider.d.ts +4 -4
  79. package/src/providers/order.provider.d.ts +16 -0
  80. package/src/providers/price.provider.d.ts +5 -5
  81. package/src/providers/product.provider.d.ts +5 -4
  82. package/src/providers/profile.provider.d.ts +5 -5
  83. package/src/providers/search.provider.d.ts +4 -4
  84. package/src/providers/store.provider.d.ts +4 -4
  85. package/src/schemas/capabilities.schema.d.ts +2 -1
  86. package/src/schemas/models/cart.model.d.ts +0 -2106
  87. package/src/schemas/models/checkout.model.d.ts +2930 -0
  88. package/src/schemas/models/cost.model.d.ts +1867 -0
  89. package/src/schemas/models/identifiers.model.d.ts +13 -1
  90. package/src/schemas/models/identity.model.d.ts +12 -6
  91. package/src/schemas/models/index.d.ts +19 -15
  92. package/src/schemas/models/order.model.d.ts +3144 -0
  93. package/src/schemas/models/payment.model.d.ts +1 -438
  94. package/src/schemas/models/product.model.d.ts +2 -2
  95. package/src/schemas/models/profile.model.d.ts +20 -20
  96. package/src/schemas/models/shipping-method.model.d.ts +54 -4
  97. package/src/schemas/mutations/{cart-payment.mutation.d.ts → checkout.mutation.d.ts} +84 -16
  98. package/src/schemas/mutations/index.d.ts +10 -10
  99. package/src/schemas/queries/category.query.d.ts +10 -10
  100. package/src/schemas/queries/checkout.query.d.ts +19 -0
  101. package/src/schemas/queries/index.d.ts +13 -12
  102. package/src/schemas/queries/order.query.d.ts +7 -0
  103. package/src/schemas/queries/product.query.d.ts +6 -0
  104. package/src/schemas/session.schema.d.ts +6 -3
  105. package/providers/cart-payment.provider.js +0 -9
  106. package/schemas/mutations/cart-payment.mutation.js +0 -15
  107. package/schemas/queries/cart-payment.query.js +0 -11
  108. package/src/providers/cart-payment.provider.d.ts +0 -42
  109. package/src/schemas/queries/cart-payment.query.d.ts +0 -16
@@ -1,4 +1,4 @@
1
- import { NoOpCache } from "../cache/noop-cache";
1
+ import { NoOpCache } from "../cache/noop-cache.js";
2
2
  class ClientBuilder {
3
3
  constructor() {
4
4
  this.factories = [];
package/client/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RedisCache } from "../cache/redis-cache";
1
+ import { RedisCache } from "../cache/redis-cache.js";
2
2
  function buildClient(providerFactories, options = {}) {
3
3
  let client = {};
4
4
  const sharedCache = options.cache || new RedisCache();
@@ -1,4 +1,16 @@
1
- import { getTracer, SpanKind } from "@reactionary/otel";
1
+ import {
2
+ trace,
3
+ SpanKind
4
+ } from "@opentelemetry/api";
5
+ const TRACER_NAME = "@reactionary";
6
+ const TRACER_VERSION = "0.0.1";
7
+ let globalTracer = null;
8
+ function getTracer() {
9
+ if (!globalTracer) {
10
+ globalTracer = trace.getTracer(TRACER_NAME, TRACER_VERSION);
11
+ }
12
+ return globalTracer;
13
+ }
2
14
  class ReactionaryDecoratorOptions {
3
15
  constructor() {
4
16
  /**
@@ -62,5 +74,6 @@ function Reactionary(options) {
62
74
  }
63
75
  export {
64
76
  Reactionary,
65
- ReactionaryDecoratorOptions
77
+ ReactionaryDecoratorOptions,
78
+ getTracer
66
79
  };
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
- export * from "./cache/cache.interface";
2
- export * from "./cache/redis-cache";
3
- export * from "./cache/memory-cache";
4
- export * from "./cache/noop-cache";
5
- export * from "./client/client";
6
- export * from "./client/client-builder";
7
- export * from "./decorators/reactionary.decorator";
8
- export * from "./providers/";
9
- export * from "./schemas/capabilities.schema";
10
- export * from "./schemas/session.schema";
11
- export * from "./schemas/models/";
12
- export * from "./schemas/mutations/";
13
- export * from "./schemas/queries";
14
- export * from "./initialization";
1
+ export * from "./cache/cache.interface.js";
2
+ export * from "./cache/redis-cache.js";
3
+ export * from "./cache/memory-cache.js";
4
+ export * from "./cache/noop-cache.js";
5
+ export * from "./client/client.js";
6
+ export * from "./client/client-builder.js";
7
+ export * from "./decorators/reactionary.decorator.js";
8
+ export * from "./providers/index.js";
9
+ export * from "./schemas/capabilities.schema.js";
10
+ export * from "./schemas/session.schema.js";
11
+ export * from "./schemas/models/index.js";
12
+ export * from "./schemas/mutations/index.js";
13
+ export * from "./schemas/queries/index.js";
14
+ export * from "./initialization.js";
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.0.48",
3
+ "version": "0.0.52",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
7
7
  "zod": "4.1.9",
8
8
  "@upstash/redis": "^1.34.9",
9
- "@reactionary/otel": "0.0.48",
10
- "node-object-hash": "^3.1.1"
11
- }
9
+ "node-object-hash": "^3.1.1",
10
+ "@opentelemetry/api": "^1.9.0"
11
+ },
12
+ "type": "module"
12
13
  }
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class AnalyticsProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "analytics";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPaginatedResponseSchema
3
- } from "../schemas/models/base.model";
3
+ } from "../schemas/models/base.model.js";
4
4
  import { hasher } from "node-object-hash";
5
5
  class BaseProvider {
6
6
  constructor(schema, cache) {
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class CartProvider extends BaseProvider {
3
3
  createEmptyCart() {
4
4
  const cart = this.newModel();
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class CategoryProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "category";
@@ -0,0 +1,6 @@
1
+ import { BaseProvider } from "./base.provider.js";
2
+ class CheckoutProvider extends BaseProvider {
3
+ }
4
+ export {
5
+ CheckoutProvider
6
+ };
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class IdentityProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "identity";
@@ -1,12 +1,13 @@
1
- export * from "./analytics.provider";
2
- export * from "./base.provider";
3
- export * from "./cart-payment.provider";
4
- export * from "./cart.provider";
5
- export * from "./category.provider";
6
- export * from "./identity.provider";
7
- export * from "./inventory.provider";
8
- export * from "./price.provider";
9
- export * from "./product.provider";
10
- export * from "./profile.provider";
11
- export * from "./search.provider";
12
- export * from "./store.provider";
1
+ export * from "./analytics.provider.js";
2
+ export * from "./base.provider.js";
3
+ export * from "./cart.provider.js";
4
+ export * from "./category.provider.js";
5
+ export * from "./checkout.provider.js";
6
+ export * from "./identity.provider.js";
7
+ export * from "./inventory.provider.js";
8
+ export * from "./price.provider.js";
9
+ export * from "./product.provider.js";
10
+ export * from "./profile.provider.js";
11
+ export * from "./search.provider.js";
12
+ export * from "./store.provider.js";
13
+ export * from "./order.provider.js";
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class InventoryProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "inventory";
@@ -0,0 +1,15 @@
1
+ import { BaseProvider } from "./base.provider.js";
2
+ class OrderProvider extends BaseProvider {
3
+ createEmptyOrder() {
4
+ const order = this.newModel();
5
+ order.meta = { placeholder: true, cache: { hit: true, key: "empty-order" } };
6
+ order.identifier = { key: "" };
7
+ return order;
8
+ }
9
+ getResourceName() {
10
+ return "order";
11
+ }
12
+ }
13
+ export {
14
+ OrderProvider
15
+ };
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class PriceProvider extends BaseProvider {
3
3
  /**
4
4
  * Utility function to create an empty price result, with a value of -1.
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class ProductProvider extends BaseProvider {
3
3
  createEmptyProduct(id) {
4
4
  const product = this.newModel();
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class ProfileProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "profile";
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class SearchProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "product-search";
@@ -1,4 +1,4 @@
1
- import { BaseProvider } from "./base.provider";
1
+ import { BaseProvider } from "./base.provider.js";
2
2
  class StoreProvider extends BaseProvider {
3
3
  getResourceName() {
4
4
  return "store";
@@ -5,7 +5,8 @@ const CapabilitiesSchema = z.looseObject({
5
5
  analytics: z.boolean(),
6
6
  identity: z.boolean(),
7
7
  cart: z.boolean(),
8
- cartPayment: z.boolean(),
8
+ checkout: z.boolean(),
9
+ order: z.boolean(),
9
10
  inventory: z.boolean(),
10
11
  price: z.boolean(),
11
12
  category: z.boolean(),
@@ -1,4 +1,4 @@
1
- import { BaseModelSchema } from "./base.model";
1
+ import { BaseModelSchema } from "./base.model.js";
2
2
  const AnalyticsEventSchema = BaseModelSchema.extend({});
3
3
  export {
4
4
  AnalyticsEventSchema
@@ -1,23 +1,7 @@
1
1
  import { z } from "zod";
2
- import { CartIdentifierSchema, CartItemIdentifierSchema, IdentityIdentifierSchema, ProductIdentifierSchema, SKUIdentifierSchema } from "../models/identifiers.model";
3
- import { BaseModelSchema } from "./base.model";
4
- import { MonetaryAmountSchema } from "./price.model";
5
- import { AddressSchema } from "./profile.model";
6
- import { ShippingMethodSchema } from "./shipping-method.model";
7
- const CostBreakDownSchema = z.looseObject({
8
- totalTax: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of tax paid on the cart. This may include VAT, GST, sales tax, etc."),
9
- totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of discount applied to the cart."),
10
- totalSurcharge: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of surcharge applied to the cart."),
11
- totalShipping: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of shipping fees for the cart."),
12
- totalProductPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price of products in the cart."),
13
- grandTotal: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price for the cart including all taxes, discounts, and shipping.")
14
- });
15
- const ItemCostBreakdownSchema = z.looseObject({
16
- unitPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The price per single unit of the item."),
17
- unitDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The discount applied per single unit of the item."),
18
- totalPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price for all units of the item."),
19
- totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total discount applied to all units of the item.")
20
- });
2
+ import { CartIdentifierSchema, CartItemIdentifierSchema, IdentityIdentifierSchema, ProductIdentifierSchema, SKUIdentifierSchema } from "../models/identifiers.model.js";
3
+ import { CostBreakDownSchema, ItemCostBreakdownSchema } from "./cost.model.js";
4
+ import { BaseModelSchema } from "./base.model.js";
21
5
  const CartItemSchema = z.looseObject({
22
6
  identifier: CartItemIdentifierSchema.default(() => CartItemIdentifierSchema.parse({})),
23
7
  product: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({})),
@@ -31,14 +15,9 @@ const CartSchema = BaseModelSchema.extend({
31
15
  items: z.array(CartItemSchema).default(() => []),
32
16
  price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
33
17
  name: z.string().default(""),
34
- description: z.string().default(""),
35
- shippingAddress: AddressSchema.optional(),
36
- billingAddress: AddressSchema.optional(),
37
- shippingMethod: ShippingMethodSchema.optional()
18
+ description: z.string().default("")
38
19
  });
39
20
  export {
40
21
  CartItemSchema,
41
- CartSchema,
42
- CostBreakDownSchema,
43
- ItemCostBreakdownSchema
22
+ CartSchema
44
23
  };
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { BaseModelSchema, createPaginatedResponseSchema, ImageSchema } from "./base.model";
3
- import { CategoryIdentifierSchema } from "./identifiers.model";
2
+ import { BaseModelSchema, createPaginatedResponseSchema, ImageSchema } from "./base.model.js";
3
+ import { CategoryIdentifierSchema } from "./identifiers.model.js";
4
4
  const CategorySchema = BaseModelSchema.extend({
5
5
  identifier: CategoryIdentifierSchema.default(() => CategoryIdentifierSchema.parse({})),
6
6
  name: z.string().default(""),
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import { BaseModelSchema } from "./base.model.js";
3
+ import { CartIdentifierSchema, CheckoutIdentifierSchema, CheckoutItemIdentifierSchema, OrderIdentifierSchema, SKUIdentifierSchema } from "./identifiers.model.js";
4
+ import { CostBreakDownSchema, ItemCostBreakdownSchema } from "./cost.model.js";
5
+ import { AddressSchema } from "./profile.model.js";
6
+ import { ShippingInstructionSchema } from "./shipping-method.model.js";
7
+ import { PaymentInstructionSchema } from "./payment.model.js";
8
+ const CheckoutItemSchema = z.looseObject({
9
+ identifier: CheckoutItemIdentifierSchema.default(() => CheckoutItemIdentifierSchema.parse({})),
10
+ sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
11
+ quantity: z.number().default(0),
12
+ price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({}))
13
+ });
14
+ const CheckoutSchema = BaseModelSchema.extend({
15
+ identifier: CheckoutIdentifierSchema.default(() => CheckoutIdentifierSchema.parse({})),
16
+ /**
17
+ * Do we need this?
18
+ */
19
+ originalCartReference: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
20
+ /**
21
+ * If the checkout has been completed, this will point to the resulting order.
22
+ */
23
+ resultingOrder: OrderIdentifierSchema.optional(),
24
+ items: z.array(CheckoutItemSchema).default(() => []),
25
+ price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
26
+ name: z.string().default(""),
27
+ description: z.string().default(""),
28
+ billingAddress: AddressSchema.optional(),
29
+ /**
30
+ * Shipping and billing details can be changed on the checkout, but not items or quantities.
31
+ */
32
+ shippingAddress: AddressSchema.optional(),
33
+ shippingInstruction: ShippingInstructionSchema.optional(),
34
+ paymentInstructions: z.array(PaymentInstructionSchema).default(() => []),
35
+ /**
36
+ * Indicates if the checkout has all the required information to be finalized into an order.
37
+ * This does not mean it will succeed, as there may be issues with payment or shipping, but all required information is present.
38
+ */
39
+ 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.")
40
+ });
41
+ export {
42
+ CheckoutItemSchema,
43
+ CheckoutSchema
44
+ };
@@ -0,0 +1,20 @@
1
+ import z from "zod";
2
+ import { MonetaryAmountSchema } from "./price.model.js";
3
+ const CostBreakDownSchema = z.looseObject({
4
+ totalTax: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of tax paid on the cart. This may include VAT, GST, sales tax, etc."),
5
+ totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of discount applied to the cart."),
6
+ totalSurcharge: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of surcharge applied to the cart."),
7
+ totalShipping: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The amount of shipping fees for the cart."),
8
+ totalProductPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price of products in the cart."),
9
+ grandTotal: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price for the cart including all taxes, discounts, and shipping.")
10
+ });
11
+ const ItemCostBreakdownSchema = z.looseObject({
12
+ unitPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The price per single unit of the item."),
13
+ unitDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The discount applied per single unit of the item."),
14
+ totalPrice: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total price for all units of the item."),
15
+ totalDiscount: MonetaryAmountSchema.default(() => MonetaryAmountSchema.parse({})).describe("The total discount applied to all units of the item.")
16
+ });
17
+ export {
18
+ CostBreakDownSchema,
19
+ ItemCostBreakdownSchema
20
+ };
@@ -39,6 +39,12 @@ const OrderIdentifierSchema = z.looseObject({
39
39
  const OrderItemIdentifierSchema = z.looseObject({
40
40
  key: z.string().default("").nonoptional()
41
41
  });
42
+ const CheckoutIdentifierSchema = z.looseObject({
43
+ key: z.string().default("").nonoptional()
44
+ });
45
+ const CheckoutItemIdentifierSchema = z.looseObject({
46
+ key: z.string().default("").nonoptional()
47
+ });
42
48
  const WebStoreIdentifierSchema = z.looseObject({
43
49
  key: z.string().default("").nonoptional()
44
50
  });
@@ -68,11 +74,16 @@ const AddressIdentifierSchema = z.looseObject({
68
74
  const PaymentInstructionIdentifierSchema = z.looseObject({
69
75
  key: z.string().default("").nonoptional()
70
76
  });
77
+ const PickupPointIdentifierSchema = z.looseObject({
78
+ key: z.string().default("").nonoptional()
79
+ });
71
80
  export {
72
81
  AddressIdentifierSchema,
73
82
  CartIdentifierSchema,
74
83
  CartItemIdentifierSchema,
75
84
  CategoryIdentifierSchema,
85
+ CheckoutIdentifierSchema,
86
+ CheckoutItemIdentifierSchema,
76
87
  FacetIdentifierSchema,
77
88
  FacetValueIdentifierSchema,
78
89
  FulfillmentCenterIdentifierSchema,
@@ -82,6 +93,7 @@ export {
82
93
  OrderItemIdentifierSchema,
83
94
  PaymentInstructionIdentifierSchema,
84
95
  PaymentMethodIdentifierSchema,
96
+ PickupPointIdentifierSchema,
85
97
  PriceIdentifierSchema,
86
98
  ProductIdentifierSchema,
87
99
  SKUIdentifierSchema,
@@ -1,19 +1,22 @@
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
  const AnonymousIdentitySchema = BaseModelSchema.extend({
5
- type: z.literal("Anonymous")
5
+ type: z.literal("Anonymous").default("Anonymous"),
6
+ token: z.string().optional(),
7
+ refresh_token: z.string().optional(),
8
+ expiry: z.coerce.date().default(/* @__PURE__ */ new Date())
6
9
  });
7
10
  const GuestIdentitySchema = BaseModelSchema.extend({
8
11
  id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
9
- type: z.literal("Guest"),
12
+ type: z.literal("Guest").default("Guest"),
10
13
  token: z.string().optional(),
11
14
  refresh_token: z.string().optional(),
12
15
  expiry: z.coerce.date().default(/* @__PURE__ */ new Date())
13
16
  });
14
17
  const RegisteredIdentitySchema = BaseModelSchema.extend({
15
18
  id: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
16
- type: z.literal("Registered"),
19
+ type: z.literal("Registered").default("Registered"),
17
20
  logonId: z.string().default(""),
18
21
  token: z.string().optional(),
19
22
  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
  const InventorySchema = BaseModelSchema.extend({
5
5
  identifier: InventoryIdentifierSchema.default(() => InventoryIdentifierSchema.parse({})),
6
6
  sku: z.string().default(""),
@@ -0,0 +1,37 @@
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
+ const OrderStatusSchema = z.enum(["AwaitingPayment", "ReleasedToFulfillment", "Shipped", "Cancelled"]).default("AwaitingPayment").describe("The current status of the order.");
9
+ const OrderInventoryStatusSchema = z.enum(["NotAllocated", "Allocated", "Backordered", "Preordered"]).default("Allocated").describe("The inventory release status of the order.");
10
+ const OrderItemSchema = z.looseObject({
11
+ identifier: CartItemIdentifierSchema.default(() => CartItemIdentifierSchema.parse({})),
12
+ sku: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({})),
13
+ quantity: z.number().default(0),
14
+ price: ItemCostBreakdownSchema.default(() => ItemCostBreakdownSchema.parse({})),
15
+ inventoryStatus: OrderInventoryStatusSchema.default("Allocated").describe("The inventory release status of the order item.")
16
+ });
17
+ const OrderSchema = BaseModelSchema.extend({
18
+ identifier: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({})),
19
+ userId: IdentityIdentifierSchema.default(() => IdentityIdentifierSchema.parse({})),
20
+ items: z.array(OrderItemSchema).default(() => []),
21
+ price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
22
+ name: z.string().default(""),
23
+ description: z.string().default(""),
24
+ shippingAddress: AddressSchema.optional(),
25
+ billingAddress: AddressSchema.optional(),
26
+ shippingMethod: ShippingMethodSchema.optional(),
27
+ orderStatus: OrderStatusSchema.default("AwaitingPayment"),
28
+ inventoryStatus: OrderInventoryStatusSchema.default("Allocated"),
29
+ paymentInstructions: z.array(PaymentInstructionSchema).default(() => []),
30
+ cartReference: CartIdentifierSchema.optional().describe("Reference to the cart from which this order was created.")
31
+ });
32
+ export {
33
+ OrderInventoryStatusSchema,
34
+ OrderItemSchema,
35
+ OrderSchema,
36
+ OrderStatusSchema
37
+ };
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
- import { BaseModelSchema, ImageSchema } from "./base.model";
3
- import { CartIdentifierSchema, PaymentInstructionIdentifierSchema, PaymentMethodIdentifierSchema } from "./identifiers.model";
4
- import { MonetaryAmountSchema } from "./price.model";
2
+ import { BaseModelSchema, ImageSchema } from "./base.model.js";
3
+ import { PaymentInstructionIdentifierSchema, PaymentMethodIdentifierSchema } from "./identifiers.model.js";
4
+ import { MonetaryAmountSchema } from "./price.model.js";
5
5
  const PaymentStatusSchema = z.enum(["pending", "authorized", "canceled", "capture", "partial_capture", "refunded", "partial_refund"]);
6
6
  const PaymentProtocolDataSchema = z.looseObject({
7
7
  key: z.string().default(""),
@@ -20,16 +20,7 @@ const PaymentInstructionSchema = BaseModelSchema.extend({
20
20
  protocolData: z.array(PaymentProtocolDataSchema).default(() => []).describe("Additional protocol-specific data for processing the payment."),
21
21
  status: PaymentStatusSchema.default("pending")
22
22
  });
23
- const CartPaymentInstructionSchema = PaymentInstructionSchema.extend({
24
- cart: CartIdentifierSchema.default(() => CartIdentifierSchema.parse({}))
25
- });
26
- const OrderPaymentInstructionSchema = PaymentInstructionSchema.extend({
27
- order: z.string().default("")
28
- // OrderIdentifierSchema
29
- });
30
23
  export {
31
- CartPaymentInstructionSchema,
32
- OrderPaymentInstructionSchema,
33
24
  PaymentInstructionSchema,
34
25
  PaymentMethodSchema,
35
26
  PaymentProtocolDataSchema,
@@ -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
  const MonetaryAmountSchema = z.looseObject({
6
6
  value: z.number().default(0).describe("The monetary amount in decimal-precision."),
7
7
  currency: CurrencySchema.default("XXX").describe("The currency associated with the amount, as a ISO 4217 standardized code.")
@@ -1,8 +1,11 @@
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
  const SKUSchema = z.looseObject({
5
- identifier: ProductIdentifierSchema.default(() => ProductIdentifierSchema.parse({}))
5
+ identifier: SKUIdentifierSchema.default(() => SKUIdentifierSchema.parse({}))
6
+ /* name: z.string().default(''),
7
+ slug: z.string().default(''),
8
+ image: ImageSchema.default(() => ImageSchema.parse({})), */
6
9
  });
7
10
  const ProductAttributeSchema = z.looseObject({
8
11
  id: z.string(),
@@ -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
  const AddressSchema = BaseModelSchema.extend({
5
5
  identifier: AddressIdentifierSchema.default(() => AddressIdentifierSchema.parse({})),
6
6
  firstName: z.string().default(""),
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSchema, SearchIdentifierSchema } from "./identifiers.model";
3
- import { BaseModelSchema } from "./base.model";
2
+ import { ProductIdentifierSchema, FacetValueIdentifierSchema, FacetIdentifierSchema, SearchIdentifierSchema } from "./identifiers.model.js";
3
+ import { BaseModelSchema } from "./base.model.js";
4
4
  const SearchResultProductSchema = z.looseObject({
5
5
  identifier: ProductIdentifierSchema.default(ProductIdentifierSchema.parse({})),
6
6
  name: z.string().default(""),