@reactionary/core 0.0.73 → 0.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
@@ -1,5 +1,8 @@
1
1
  import { BaseProvider } from "./base.provider.js";
2
2
  class CheckoutProvider extends BaseProvider {
3
+ getResourceName() {
4
+ return "checkout";
5
+ }
3
6
  }
4
7
  export {
5
8
  CheckoutProvider
@@ -25,7 +25,7 @@ const CheckoutSchema = BaseModelSchema.extend({
25
25
  price: CostBreakDownSchema.default(() => CostBreakDownSchema.parse({})),
26
26
  name: z.string().default(""),
27
27
  description: z.string().default(""),
28
- billingAddress: AddressSchema.optional(),
28
+ billingAddress: AddressSchema.optional().nullable(),
29
29
  /**
30
30
  * Shipping and billing details can be changed on the checkout, but not items or quantities.
31
31
  */
@@ -1,9 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { BaseModelSchema } from "./base.model.js";
3
- import { InventoryIdentifierSchema } from "./identifiers.model.js";
3
+ import { InventoryIdentifierSchema, ProductVariantIdentifierSchema } from "./identifiers.model.js";
4
4
  const InventorySchema = BaseModelSchema.extend({
5
5
  identifier: InventoryIdentifierSchema.default(() => InventoryIdentifierSchema.parse({})),
6
- sku: z.string().default(""),
7
6
  quantity: z.number().default(0),
8
7
  status: z.enum(["inStock", "outOfStock", "onBackOrder", "preOrder", "discontinued"]).default("inStock")
9
8
  });
@@ -5,7 +5,7 @@ const ProductQueryBySlugSchema = BaseQuerySchema.extend({
5
5
  slug: z.string()
6
6
  });
7
7
  const ProductQueryByIdSchema = BaseQuerySchema.extend({
8
- id: z.string()
8
+ identifier: ProductIdentifierSchema.required()
9
9
  });
10
10
  const ProductQueryBySKUSchema = BaseQuerySchema.extend({
11
11
  variant: ProductVariantIdentifierSchema.default(() => ProductVariantIdentifierSchema.parse({}))
@@ -1,8 +1,8 @@
1
- import { BaseProvider } from "./base.provider.js";
2
1
  import type { Cart } from "../schemas/models/cart.model.js";
2
+ import type { CartIdentifier } from "../schemas/models/identifiers.model.js";
3
+ import type { CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationDeleteCart, CartMutationItemAdd, CartMutationItemQuantityChange, CartMutationItemRemove, CartMutationRemoveCoupon } from "../schemas/mutations/cart.mutation.js";
3
4
  import type { CartQueryById } from "../schemas/queries/cart.query.js";
4
- import type { CartMutationApplyCoupon, CartMutationChangeCurrency, CartMutationCheckout, CartMutationDeleteCart, CartMutationItemAdd, CartMutationItemQuantityChange, CartMutationItemRemove, CartMutationRemoveCoupon, CartMutationSetBillingAddress, CartMutationSetShippingInfo } from "../schemas/mutations/cart.mutation.js";
5
- import type { CartIdentifier, OrderIdentifier } from "../schemas/models/identifiers.model.js";
5
+ import { BaseProvider } from "./base.provider.js";
6
6
  export declare abstract class CartProvider<T extends Cart = Cart> extends BaseProvider<T> {
7
7
  /**
8
8
  * Get cart by ID.
@@ -55,23 +55,6 @@ export declare abstract class CartProvider<T extends Cart = Cart> extends BasePr
55
55
  * @param session
56
56
  */
57
57
  abstract deleteCart(payload: CartMutationDeleteCart): Promise<T>;
58
- /**
59
- * Sets shipping method and address on the cart. Returns the updated and recalculated cart.
60
- *
61
- * Usecase: User selects shipping method during checkout.
62
- * @param payload
63
- * @param session
64
- */
65
- abstract setShippingInfo(payload: CartMutationSetShippingInfo): Promise<T>;
66
- /**
67
- * Sets billing address on the cart. Returns the updated and recalculated cart.
68
- *
69
- * Usecase: User enters billing address during checkout.
70
- *
71
- * @param payload
72
- * @param session
73
- */
74
- abstract setBillingAddress(payload: CartMutationSetBillingAddress): Promise<T>;
75
58
  /**
76
59
  * Applies a coupon code to the cart. Returns the updated and recalculated cart.
77
60
  *
@@ -88,15 +71,6 @@ export declare abstract class CartProvider<T extends Cart = Cart> extends BasePr
88
71
  * @param session
89
72
  */
90
73
  abstract removeCouponCode(payload: CartMutationRemoveCoupon): Promise<T>;
91
- /**
92
- * Checks out the cart. Returns the order identifier of the newly created order.
93
- *
94
- * Usecase: User proceeds to checkout.
95
- *
96
- * @param payload
97
- * @param session
98
- */
99
- abstract checkout(payload: CartMutationCheckout): Promise<OrderIdentifier>;
100
74
  /**
101
75
  * Changes the currency of the cart.
102
76
  *
@@ -82,6 +82,7 @@ export declare abstract class CheckoutProvider<T extends Checkout = Checkout> ex
82
82
  * @param reqCtx
83
83
  */
84
84
  abstract finalizeCheckout(payload: CheckoutMutationFinalizeCheckout): Promise<T>;
85
+ getResourceName(): string;
85
86
  }
86
87
  /**
87
88
  *
@@ -2653,7 +2653,7 @@ export declare const CheckoutSchema: z.ZodObject<{
2653
2653
  }, z.core.$loose>>;
2654
2654
  name: z.ZodDefault<z.ZodString>;
2655
2655
  description: z.ZodDefault<z.ZodString>;
2656
- billingAddress: z.ZodOptional<z.ZodObject<{
2656
+ billingAddress: z.ZodNullable<z.ZodOptional<z.ZodObject<{
2657
2657
  meta: z.ZodDefault<z.ZodObject<{
2658
2658
  cache: z.ZodDefault<z.ZodObject<{
2659
2659
  hit: z.ZodDefault<z.ZodBoolean>;
@@ -2672,7 +2672,7 @@ export declare const CheckoutSchema: z.ZodObject<{
2672
2672
  region: z.ZodDefault<z.ZodString>;
2673
2673
  postalCode: z.ZodDefault<z.ZodString>;
2674
2674
  countryCode: z.ZodDefault<z.ZodString>;
2675
- }, z.core.$loose>>;
2675
+ }, z.core.$loose>>>;
2676
2676
  shippingAddress: z.ZodOptional<z.ZodObject<{
2677
2677
  meta: z.ZodDefault<z.ZodObject<{
2678
2678
  cache: z.ZodDefault<z.ZodObject<{
@@ -15,7 +15,6 @@ export declare const InventorySchema: z.ZodObject<{
15
15
  key: z.ZodNonOptional<z.ZodDefault<z.ZodString>>;
16
16
  }, z.core.$loose>>;
17
17
  }, z.core.$loose>>;
18
- sku: z.ZodDefault<z.ZodString>;
19
18
  quantity: z.ZodDefault<z.ZodNumber>;
20
19
  status: z.ZodDefault<z.ZodEnum<{
21
20
  inStock: "inStock";
@@ -3,7 +3,9 @@ export declare const ProductQueryBySlugSchema: z.ZodObject<{
3
3
  slug: z.ZodString;
4
4
  }, z.core.$loose>;
5
5
  export declare const ProductQueryByIdSchema: z.ZodObject<{
6
- id: z.ZodString;
6
+ identifier: z.ZodObject<{
7
+ key: z.ZodNonOptional<z.ZodDefault<z.ZodString>>;
8
+ }, z.core.$loose>;
7
9
  }, z.core.$loose>;
8
10
  export declare const ProductQueryBySKUSchema: z.ZodObject<{
9
11
  variant: z.ZodDefault<z.ZodObject<{