@reactionary/core 0.1.13 → 0.2.2

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 (63) hide show
  1. package/cache/memory-cache.js +1 -1
  2. package/decorators/reactionary.decorator.js +50 -16
  3. package/package.json +1 -1
  4. package/providers/base.provider.js +0 -15
  5. package/providers/cart.provider.js +0 -39
  6. package/providers/inventory.provider.js +1 -8
  7. package/providers/order.provider.js +0 -1
  8. package/providers/price.provider.js +0 -7
  9. package/providers/product.provider.js +0 -7
  10. package/schemas/errors/generic.error.js +8 -0
  11. package/schemas/errors/index.js +4 -0
  12. package/schemas/errors/invalid-input.error.js +8 -0
  13. package/schemas/errors/invalid-output.error.js +8 -0
  14. package/schemas/errors/not-found.error.js +8 -0
  15. package/schemas/index.js +2 -0
  16. package/schemas/models/base.model.js +1 -14
  17. package/schemas/models/profile.model.js +1 -1
  18. package/schemas/mutations/cart.mutation.js +1 -1
  19. package/schemas/mutations/checkout.mutation.js +4 -4
  20. package/schemas/mutations/profile.mutation.js +31 -3
  21. package/schemas/queries/profile.query.js +5 -2
  22. package/schemas/result.js +51 -0
  23. package/src/cache/memory-cache.d.ts +2 -1
  24. package/src/decorators/reactionary.decorator.d.ts +3 -2
  25. package/src/providers/base.provider.d.ts +0 -3
  26. package/src/providers/cart.provider.d.ts +11 -10
  27. package/src/providers/category.provider.d.ts +6 -6
  28. package/src/providers/checkout.provider.d.ts +11 -9
  29. package/src/providers/identity.provider.d.ts +5 -4
  30. package/src/providers/inventory.provider.d.ts +3 -1
  31. package/src/providers/order.provider.d.ts +3 -1
  32. package/src/providers/price.provider.d.ts +3 -3
  33. package/src/providers/product-search.provider.d.ts +3 -3
  34. package/src/providers/product.provider.d.ts +5 -3
  35. package/src/providers/profile.provider.d.ts +66 -4
  36. package/src/providers/store.provider.d.ts +2 -1
  37. package/src/schemas/errors/generic.error.d.ts +7 -0
  38. package/src/schemas/errors/index.d.ts +4 -0
  39. package/src/schemas/errors/invalid-input.error.d.ts +7 -0
  40. package/src/schemas/errors/invalid-output.error.d.ts +7 -0
  41. package/src/schemas/errors/not-found.error.d.ts +7 -0
  42. package/src/schemas/index.d.ts +2 -0
  43. package/src/schemas/models/analytics.model.d.ts +1 -9
  44. package/src/schemas/models/base.model.d.ts +1 -29
  45. package/src/schemas/models/cart.model.d.ts +0 -7
  46. package/src/schemas/models/category.model.d.ts +0 -21
  47. package/src/schemas/models/checkout.model.d.ts +0 -35
  48. package/src/schemas/models/identity.model.d.ts +0 -42
  49. package/src/schemas/models/inventory.model.d.ts +0 -7
  50. package/src/schemas/models/order.model.d.ts +0 -28
  51. package/src/schemas/models/payment.model.d.ts +0 -14
  52. package/src/schemas/models/price.model.d.ts +0 -7
  53. package/src/schemas/models/product-search.model.d.ts +0 -21
  54. package/src/schemas/models/product.model.d.ts +0 -7
  55. package/src/schemas/models/profile.model.d.ts +2 -37
  56. package/src/schemas/models/shipping-method.model.d.ts +0 -14
  57. package/src/schemas/models/store.model.d.ts +0 -7
  58. package/src/schemas/mutations/cart.mutation.d.ts +2 -16
  59. package/src/schemas/mutations/checkout.mutation.d.ts +1 -8
  60. package/src/schemas/mutations/profile.mutation.d.ts +78 -0
  61. package/src/schemas/queries/product-search.query.d.ts +0 -7
  62. package/src/schemas/queries/profile.query.d.ts +6 -2
  63. package/src/schemas/result.d.ts +55 -0
@@ -1,4 +1,4 @@
1
- import type { Category, CategoryPaginatedResult } from "../schemas/index.js";
1
+ import type { Category, CategoryPaginatedResult, NotFoundError, Result } from "../schemas/index.js";
2
2
  import type { CategoryQueryById, CategoryQueryBySlug, CategoryQueryForBreadcrumb, CategoryQueryForChildCategories, CategoryQueryForTopCategories } from "../schemas/queries/category.query.js";
3
3
  import { BaseProvider } from "./base.provider.js";
4
4
  /**
@@ -25,7 +25,7 @@ export declare abstract class CategoryProvider extends BaseProvider {
25
25
  * @param id
26
26
  * @param session
27
27
  */
28
- abstract getById(payload: CategoryQueryById): Promise<Category>;
28
+ abstract getById(payload: CategoryQueryById): Promise<Result<Category, NotFoundError>>;
29
29
  /**
30
30
  * Gets a single category by its seo slug
31
31
  *
@@ -33,7 +33,7 @@ export declare abstract class CategoryProvider extends BaseProvider {
33
33
  * @param slug the slug
34
34
  * @param session
35
35
  */
36
- abstract getBySlug(payload: CategoryQueryBySlug): Promise<Category | null>;
36
+ abstract getBySlug(payload: CategoryQueryBySlug): Promise<Result<Category, NotFoundError>>;
37
37
  /**
38
38
  * Gets the breadcrumb path to the category, i.e. all parents up to the root.
39
39
  * The returned order is from root to leaf.
@@ -42,7 +42,7 @@ export declare abstract class CategoryProvider extends BaseProvider {
42
42
  * @param id
43
43
  * @param session
44
44
  */
45
- abstract getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Category[]>;
45
+ abstract getBreadcrumbPathToCategory(payload: CategoryQueryForBreadcrumb): Promise<Result<Category[]>>;
46
46
  /**
47
47
  * Finds all child categories of a given category.
48
48
  *
@@ -53,7 +53,7 @@ export declare abstract class CategoryProvider extends BaseProvider {
53
53
  * @param id The ID of the parent category.
54
54
  * @param session The session information.
55
55
  */
56
- abstract findChildCategories(payload: CategoryQueryForChildCategories): Promise<CategoryPaginatedResult>;
56
+ abstract findChildCategories(payload: CategoryQueryForChildCategories): Promise<Result<CategoryPaginatedResult>>;
57
57
  /**
58
58
  * Returns all top categories, i.e. categories without a parent.
59
59
  *
@@ -61,6 +61,6 @@ export declare abstract class CategoryProvider extends BaseProvider {
61
61
  * @param paginationOptions
62
62
  * @param session
63
63
  */
64
- abstract findTopCategories(payload: CategoryQueryForTopCategories): Promise<CategoryPaginatedResult>;
64
+ abstract findTopCategories(payload: CategoryQueryForTopCategories): Promise<Result<CategoryPaginatedResult>>;
65
65
  protected getResourceName(): string;
66
66
  }
@@ -2,6 +2,8 @@ import type { Checkout, PaymentMethod, ShippingMethod } from "../schemas/models/
2
2
  import { BaseProvider } from "./base.provider.js";
3
3
  import type { CheckoutMutationFinalizeCheckout, CheckoutMutationInitiateCheckout, CheckoutMutationSetShippingAddress, CheckoutMutationAddPaymentInstruction, CheckoutMutationRemovePaymentInstruction, CheckoutMutationSetShippingInstruction } from "../schemas/mutations/checkout.mutation.js";
4
4
  import type { CheckoutQueryById, CheckoutQueryForAvailablePaymentMethods, CheckoutQueryForAvailableShippingMethods } from "../schemas/queries/index.js";
5
+ import type { Result } from "../schemas/result.js";
6
+ import type { NotFoundError } from "../schemas/index.js";
5
7
  export declare abstract class CheckoutProvider extends BaseProvider {
6
8
  /**
7
9
  * This starts a new checkout session for the given cart. The checkout might duplicate the cart, or just reference it, depending on implementation, but changes to the cart,
@@ -13,7 +15,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
13
15
  * @param billingAddress the billing/shipping address to start with. This affects available shipping methods, and may be required by some payment providers.
14
16
  * @param reqCtx
15
17
  */
16
- abstract initiateCheckoutForCart(payload: CheckoutMutationInitiateCheckout): Promise<Checkout>;
18
+ abstract initiateCheckoutForCart(payload: CheckoutMutationInitiateCheckout): Promise<Result<Checkout>>;
17
19
  /**
18
20
  * Fetches an existing checkout by its identifier.
19
21
  *
@@ -21,7 +23,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
21
23
  * @param payload
22
24
  * @param reqCtx
23
25
  */
24
- abstract getById(payload: CheckoutQueryById): Promise<Checkout | null>;
26
+ abstract getById(payload: CheckoutQueryById): Promise<Result<Checkout, NotFoundError>>;
25
27
  /**
26
28
  * Updates the shipping address for the checkout and recalculates the shipping methods and totals.
27
29
  *
@@ -30,7 +32,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
30
32
  * NOTE: Unsure this is really needed.
31
33
  * @param shippingAddress The updated shipping address. Note: This may also be the billing address, if your store does not differentiate.
32
34
  */
33
- abstract setShippingAddress(payload: CheckoutMutationSetShippingAddress): Promise<Checkout>;
35
+ abstract setShippingAddress(payload: CheckoutMutationSetShippingAddress): Promise<Result<Checkout>>;
34
36
  /**
35
37
  * Returns all available shipping methods for the given checkout. This will typically depend on the shipping address, and possibly also the items in the checkout.
36
38
  *
@@ -39,7 +41,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
39
41
  * @param checkoutId The checkout you want to get shipping methods for.
40
42
  * @param reqCtx
41
43
  */
42
- abstract getAvailableShippingMethods(payload: CheckoutQueryForAvailableShippingMethods): Promise<ShippingMethod[]>;
44
+ abstract getAvailableShippingMethods(payload: CheckoutQueryForAvailableShippingMethods): Promise<Result<ShippingMethod[]>>;
43
45
  /**
44
46
  * Returns all available payment methods for the given checkout. This will typically depend mostly on the billing address and jurisdiction.
45
47
  *
@@ -48,20 +50,20 @@ export declare abstract class CheckoutProvider extends BaseProvider {
48
50
  * @param checkoutId The checkout you want to get payment methods for.
49
51
  * @param reqCtx
50
52
  */
51
- abstract getAvailablePaymentMethods(payload: CheckoutQueryForAvailablePaymentMethods): Promise<PaymentMethod[]>;
53
+ abstract getAvailablePaymentMethods(payload: CheckoutQueryForAvailablePaymentMethods): Promise<Result<PaymentMethod[]>>;
52
54
  /**
53
55
  * Adds a payment instruction to the checkout. This will typically create a payment intent in the payment provider, and return whatever is needed to continue the payment process, e.g. a client secret for Stripe, or a redirect URL for PayPal.
54
56
  *
55
57
  * Usecase: User has chosen a payment method, and you need to start the payment process.
56
58
  */
57
- abstract addPaymentInstruction(payload: CheckoutMutationAddPaymentInstruction): Promise<Checkout>;
59
+ abstract addPaymentInstruction(payload: CheckoutMutationAddPaymentInstruction): Promise<Result<Checkout>>;
58
60
  /**
59
61
  * Removes a payment instruction from the checkout. This will typically void the payment intent in the payment provider, and remove the payment instruction from the checkout.
60
62
  *
61
63
  * Usecase: User has decided to change payment method, or has cancelled the payment process.
62
64
  * @param paymentInstructionId
63
65
  */
64
- abstract removePaymentInstruction(payload: CheckoutMutationRemovePaymentInstruction): Promise<Checkout>;
66
+ abstract removePaymentInstruction(payload: CheckoutMutationRemovePaymentInstruction): Promise<Result<Checkout>>;
65
67
  /**
66
68
  * Sets the shipping method and optional pickup point for the checkout. The pickup point can be a physical store, a locker, or similar.
67
69
  * If it is unset, it means home delivery to the shipping address.
@@ -72,7 +74,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
72
74
  * @param shippingMethodId
73
75
  * @param pickupPoint
74
76
  */
75
- abstract setShippingInstruction(payload: CheckoutMutationSetShippingInstruction): Promise<Checkout>;
77
+ abstract setShippingInstruction(payload: CheckoutMutationSetShippingInstruction): Promise<Result<Checkout>>;
76
78
  /**
77
79
  * Finalizes the checkout process. This typically involves creating an order from the checkout and processing payment.
78
80
  *
@@ -81,7 +83,7 @@ export declare abstract class CheckoutProvider extends BaseProvider {
81
83
  * @param payload
82
84
  * @param reqCtx
83
85
  */
84
- abstract finalizeCheckout(payload: CheckoutMutationFinalizeCheckout): Promise<Checkout>;
86
+ abstract finalizeCheckout(payload: CheckoutMutationFinalizeCheckout): Promise<Result<Checkout>>;
85
87
  getResourceName(): string;
86
88
  }
87
89
  /**
@@ -1,11 +1,12 @@
1
1
  import type { Identity } from "../schemas/models/identity.model.js";
2
2
  import type { IdentityMutationLogin, IdentityMutationLogout, IdentityMutationRegister } from "../schemas/mutations/identity.mutation.js";
3
3
  import type { IdentityQuerySelf } from "../schemas/queries/identity.query.js";
4
+ import type { Result } from "../schemas/result.js";
4
5
  import { BaseProvider } from "./base.provider.js";
5
6
  export declare abstract class IdentityProvider extends BaseProvider {
6
- abstract getSelf(payload: IdentityQuerySelf): Promise<Identity>;
7
- abstract login(payload: IdentityMutationLogin): Promise<Identity>;
8
- abstract logout(payload: IdentityMutationLogout): Promise<Identity>;
9
- abstract register(payload: IdentityMutationRegister): Promise<Identity>;
7
+ abstract getSelf(payload: IdentityQuerySelf): Promise<Result<Identity>>;
8
+ abstract login(payload: IdentityMutationLogin): Promise<Result<Identity>>;
9
+ abstract logout(payload: IdentityMutationLogout): Promise<Result<Identity>>;
10
+ abstract register(payload: IdentityMutationRegister): Promise<Result<Identity>>;
10
11
  protected getResourceName(): string;
11
12
  }
@@ -1,9 +1,11 @@
1
+ import type { NotFoundError } from '../schemas/index.js';
1
2
  import type { InventoryIdentifier } from '../schemas/models/identifiers.model.js';
2
3
  import type { Inventory } from '../schemas/models/inventory.model.js';
3
4
  import type { InventoryQueryBySKU } from '../schemas/queries/inventory.query.js';
5
+ import type { Result } from '../schemas/result.js';
4
6
  import { BaseProvider } from './base.provider.js';
5
7
  export declare abstract class InventoryProvider extends BaseProvider {
6
- abstract getBySKU(payload: InventoryQueryBySKU): Promise<Inventory>;
8
+ abstract getBySKU(payload: InventoryQueryBySKU): Promise<Result<Inventory, NotFoundError>>;
7
9
  protected getResourceName(): string;
8
10
  protected createEmptyInventory(key: InventoryIdentifier): Inventory;
9
11
  }
@@ -1,6 +1,8 @@
1
1
  import { BaseProvider } from './base.provider.js';
2
2
  import type { Order } from '../schemas/models/index.js';
3
3
  import type { OrderQueryById } from '../schemas/queries/index.js';
4
+ import type { Result } from '../schemas/result.js';
5
+ import type { NotFoundError } from '../schemas/index.js';
4
6
  export declare abstract class OrderProvider extends BaseProvider {
5
7
  /**
6
8
  * Get order by ID.
@@ -9,7 +11,7 @@ export declare abstract class OrderProvider extends BaseProvider {
9
11
  * @param payload
10
12
  * @param session
11
13
  */
12
- abstract getById(payload: OrderQueryById): Promise<Order>;
14
+ abstract getById(payload: OrderQueryById): Promise<Result<Order, NotFoundError>>;
13
15
  protected createEmptyOrder(): Order;
14
16
  protected getResourceName(): string;
15
17
  }
@@ -1,4 +1,4 @@
1
- import type { Price } from '../schemas/index.js';
1
+ import type { Price, Result } from '../schemas/index.js';
2
2
  import type { CustomerPriceQuery, ListPriceQuery } from '../schemas/queries/price.query.js';
3
3
  import { BaseProvider } from './base.provider.js';
4
4
  export declare abstract class PriceProvider extends BaseProvider {
@@ -10,7 +10,7 @@ export declare abstract class PriceProvider extends BaseProvider {
10
10
  * @param payload The SKU to query
11
11
  * @param session The session information
12
12
  */
13
- abstract getListPrice(payload: ListPriceQuery): Promise<Price>;
13
+ abstract getListPrice(payload: ListPriceQuery): Promise<Result<Price>>;
14
14
  /**
15
15
  * Get a customer-specific price by SKU.
16
16
  *
@@ -20,7 +20,7 @@ export declare abstract class PriceProvider extends BaseProvider {
20
20
  * @param payload The SKU to query
21
21
  * @param session The session information
22
22
  */
23
- abstract getCustomerPrice(payload: CustomerPriceQuery): Promise<Price>;
23
+ abstract getCustomerPrice(payload: CustomerPriceQuery): Promise<Result<Price>>;
24
24
  /**
25
25
  * Utility function to create an empty price result, with a value of -1.
26
26
  * This is used when no price is found for a given SKU + currency combination.
@@ -1,10 +1,10 @@
1
- import type { FacetIdentifier, FacetValueIdentifier } from '../index.js';
1
+ import type { FacetIdentifier, FacetValueIdentifier, Result } from '../index.js';
2
2
  import type { ProductSearchResult, ProductSearchResultFacet, ProductSearchResultFacetValue, ProductSearchResultItemVariant } from '../schemas/models/product-search.model.js';
3
3
  import type { ProductSearchQueryByTerm, ProductSearchQueryCreateNavigationFilter } from '../schemas/queries/product-search.query.js';
4
4
  import { BaseProvider } from './base.provider.js';
5
5
  export declare abstract class ProductSearchProvider extends BaseProvider {
6
6
  protected getResourceName(): string;
7
- abstract queryByTerm(payload: ProductSearchQueryByTerm): Promise<ProductSearchResult>;
7
+ abstract queryByTerm(payload: ProductSearchQueryByTerm): Promise<Result<ProductSearchResult>>;
8
8
  /**
9
9
  * Since each platform has it own way of representing categories and their hierarchy, we leave it to the platform to tell us how to get from a
10
10
  * category breadcrumb path to a global category navigation filter that can be applied to product searches.
@@ -23,7 +23,7 @@ export declare abstract class ProductSearchProvider extends BaseProvider {
23
23
  *
24
24
  * @param categoryPath
25
25
  */
26
- abstract createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<FacetValueIdentifier>;
26
+ abstract createCategoryNavigationFilter(payload: ProductSearchQueryCreateNavigationFilter): Promise<Result<FacetValueIdentifier>>;
27
27
  /**
28
28
  * Parses a facet value from the search response.
29
29
  * @param facetValueIdentifier The identifier for the facet value.
@@ -1,6 +1,8 @@
1
1
  import type { Product } from '../schemas/models/product.model.js';
2
2
  import { BaseProvider } from './base.provider.js';
3
3
  import type { ProductQueryById, ProductQueryBySKU, ProductQueryBySlug } from '../schemas/queries/product.query.js';
4
+ import type { Result } from '../schemas/result.js';
5
+ import type { NotFoundError } from '../schemas/index.js';
4
6
  export declare abstract class ProductProvider extends BaseProvider {
5
7
  /**
6
8
  * Get a product by its ID.
@@ -12,7 +14,7 @@ export declare abstract class ProductProvider extends BaseProvider {
12
14
  * Marketing will TYPICALLY recommend products, and in some cases maybe HeroVariants of a product.
13
15
  * In that case, you would need to resolve the product to its hero variant first, and then get the SKU from there.
14
16
  */
15
- abstract getById(payload: ProductQueryById): Promise<Product>;
17
+ abstract getById(payload: ProductQueryById): Promise<Result<Product>>;
16
18
  /**
17
19
  * Get a product by its slug.
18
20
  * @param payload The query payload containing the product slug.
@@ -20,7 +22,7 @@ export declare abstract class ProductProvider extends BaseProvider {
20
22
  *
21
23
  * Usecase: You are rendering a product detail page, and you need to fetch the product by its slug.
22
24
  */
23
- abstract getBySlug(payload: ProductQueryBySlug): Promise<Product | null>;
25
+ abstract getBySlug(payload: ProductQueryBySlug): Promise<Result<Product, NotFoundError>>;
24
26
  /**
25
27
  * Get a product by its SKU
26
28
  * @param payload
@@ -30,7 +32,7 @@ export declare abstract class ProductProvider extends BaseProvider {
30
32
  * and you need to fetch the product details for that SKU. You will get the a Product back, with the variant matching the SKU set as heroSku.
31
33
  * It might also be used on a quick-order page, or product recommendations from external system.
32
34
  */
33
- abstract getBySKU(payload: ProductQueryBySKU): Promise<Product>;
35
+ abstract getBySKU(payload: ProductQueryBySKU): Promise<Result<Product>>;
34
36
  protected createEmptyProduct(id: string): Product;
35
37
  /**
36
38
  * The resource name, used for caching and logging.
@@ -1,9 +1,71 @@
1
+ import type { NotFoundError } from '../schemas/index.js';
1
2
  import type { Profile } from '../schemas/models/index.js';
2
- import type { ProfileMutationUpdate } from '../schemas/mutations/index.js';
3
- import type { ProfileQuerySelf } from '../schemas/queries/index.js';
3
+ import type { ProfileMutationAddShippingAddress, ProfileMutationMakeShippingAddressDefault, ProfileMutationRemoveShippingAddress, ProfileMutationSetBillingAddress, ProfileMutationUpdate, ProfileMutationUpdateShippingAddress } from '../schemas/mutations/index.js';
4
+ import type { ProfileQuerySelf as ProfileQueryById } from '../schemas/queries/index.js';
5
+ import type { Result } from '../schemas/result.js';
4
6
  import { BaseProvider } from './base.provider.js';
5
7
  export declare abstract class ProfileProvider extends BaseProvider {
6
- abstract getSelf(payload: ProfileQuerySelf): Promise<Profile>;
7
- abstract update(payload: ProfileMutationUpdate): Promise<Profile>;
8
+ /**
9
+ * Returns the profile of the currently authenticated (registered) user.
10
+ *
11
+ * Usecase: Fetch the profile of the logged-in user for display in header, or account settings.
12
+ * @param payload
13
+ */
14
+ abstract getById(payload: ProfileQueryById): Promise<Result<Profile, NotFoundError>>;
15
+ /**
16
+ * Updates the base profile information of the currently authenticated (registered) user.
17
+ *
18
+ * TODO: This should include first/lastname.
19
+ * TODO: In some systems, updating email/phone may require re-verification.
20
+ * TODO: Handle conflicts if email/phone is already in use by another user.
21
+ * TODO: In some systems the email might not be editable.
22
+ *
23
+ * Usecase: Update the user's name, email, or phone number.
24
+ * @param payload
25
+ */
26
+ abstract update(payload: ProfileMutationUpdate): Promise<Result<Profile, NotFoundError>>;
27
+ /**
28
+ * Creates a new shipping address for the currently authenticated (registered) user.
29
+ * Does not set it as default automatically.
30
+ *
31
+ * Usecase: User adds a new shipping address in their profile or during checkout. Ideally, any address manipulation
32
+ * done at checkout should be considered local to that session, unless the addressbook is empty.
33
+ * @param payload
34
+ */
35
+ abstract addShippingAddress(payload: ProfileMutationAddShippingAddress): Promise<Result<Profile, NotFoundError>>;
36
+ /**
37
+ * Updates an existing shipping address for the currently authenticated (registered) user.
38
+ *
39
+ * Usecase: User edits an existing shipping address in their profile. Ideally, any address manipulation
40
+ * done at checkout should be considered local to that session/order, unless the addressbook is empty.
41
+ * @param payload
42
+ */
43
+ abstract updateShippingAddress(payload: ProfileMutationUpdateShippingAddress): Promise<Result<Profile, NotFoundError>>;
44
+ /**
45
+ * Removes an existing shipping address for the currently authenticated (registered) user.
46
+ *
47
+ * If the removed address was the default shipping address, the default shipping address is set to a random other address.
48
+ *
49
+ * Usecase: User deletes a shipping address from their profile.
50
+ * @param payload
51
+ */
52
+ abstract removeShippingAddress(payload: ProfileMutationRemoveShippingAddress): Promise<Result<Profile, NotFoundError>>;
53
+ /**
54
+ * Configures an existing shipping address as the default shipping address for the currently authenticated (registered) user.
55
+ *
56
+ * Usecase: User selects a default shipping address in their profile.
57
+ * @param payload
58
+ */
59
+ abstract makeShippingAddressDefault(payload: ProfileMutationMakeShippingAddressDefault): Promise<Result<Profile, NotFoundError>>;
60
+ /**
61
+ * Sets the current/active billing address for the currently authenticated (registered) user.
62
+ *
63
+ * Usecase: User sets or updates their billing address in their profile or during checkout.
64
+ *
65
+ * It was a design decision not to support multiple billing addresses. The billing address represents who you are as the commercial
66
+ * entity being billed, and as such it makes sense to have a single authoritative billing address.
67
+ * @param payload
68
+ */
69
+ abstract setBillingAddress(payload: ProfileMutationSetBillingAddress): Promise<Result<Profile, NotFoundError>>;
8
70
  protected getResourceName(): string;
9
71
  }
@@ -1,7 +1,8 @@
1
1
  import type { Store } from '../schemas/models/store.model.js';
2
2
  import type { StoreQueryByProximity } from '../schemas/queries/index.js';
3
+ import type { Result } from '../schemas/result.js';
3
4
  import { BaseProvider } from './base.provider.js';
4
5
  export declare abstract class StoreProvider extends BaseProvider {
5
- abstract queryByProximity(payload: StoreQueryByProximity): Promise<Array<Store>>;
6
+ abstract queryByProximity(payload: StoreQueryByProximity): Promise<Result<Array<Store>>>;
6
7
  protected getResourceName(): string;
7
8
  }
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
3
+ export declare const GenericErrorSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"Generic">;
5
+ message: z.ZodString;
6
+ }, z.core.$loose>;
7
+ export type GenericError = InferType<typeof GenericErrorSchema>;
@@ -0,0 +1,4 @@
1
+ export * from './generic.error.js';
2
+ export * from './invalid-input.error.js';
3
+ export * from './invalid-output.error.js';
4
+ export * from './not-found.error.js';
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
3
+ export declare const InvalidInputErrorSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"InvalidInput">;
5
+ error: z.core.$constructor<z.ZodError<unknown>, z.core.$ZodIssue[]>;
6
+ }, z.core.$loose>;
7
+ export type InvalidInputError = InferType<typeof InvalidInputErrorSchema>;
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
3
+ export declare const InvalidOutputErrorSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"InvalidOutput">;
5
+ error: z.core.$constructor<z.ZodError<unknown>, z.core.$ZodIssue[]>;
6
+ }, z.core.$loose>;
7
+ export type InvalidOutputError = InferType<typeof InvalidOutputErrorSchema>;
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { InferType } from '../../zod-utils.js';
3
+ export declare const NotFoundErrorSchema: z.ZodObject<{
4
+ type: z.ZodLiteral<"NotFound">;
5
+ identifier: z.ZodUnknown;
6
+ }, z.core.$loose>;
7
+ export type NotFoundError = InferType<typeof NotFoundErrorSchema>;
@@ -1,5 +1,7 @@
1
+ export * from './errors/index.js';
1
2
  export * from './models/index.js';
2
3
  export * from './mutations/index.js';
3
4
  export * from './queries/index.js';
4
5
  export * from './capabilities.schema.js';
5
6
  export * from './session.schema.js';
7
+ export * from './result.js';
@@ -1,12 +1,4 @@
1
1
  import type { z } from 'zod';
2
2
  import type { InferType } from '../../zod-utils.js';
3
- export declare const AnalyticsEventSchema: z.ZodObject<{
4
- meta: z.ZodDefault<z.ZodObject<{
5
- cache: z.ZodDefault<z.ZodObject<{
6
- hit: z.ZodDefault<z.ZodBoolean>;
7
- key: z.ZodDefault<z.ZodString>;
8
- }, z.core.$loose>>;
9
- placeholder: z.ZodDefault<z.ZodBoolean>;
10
- }, z.core.$loose>>;
11
- }, z.core.$loose>;
3
+ export declare const AnalyticsEventSchema: z.ZodObject<{}, z.core.$loose>;
12
4
  export type AnalyticsEvent = InferType<typeof AnalyticsEventSchema>;
@@ -1,25 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import type { InferType } from '../../zod-utils.js';
3
- export declare const CacheInformationSchema: z.ZodObject<{
4
- hit: z.ZodDefault<z.ZodBoolean>;
5
- key: z.ZodDefault<z.ZodString>;
6
- }, z.core.$loose>;
7
- export declare const MetaSchema: z.ZodObject<{
8
- cache: z.ZodDefault<z.ZodObject<{
9
- hit: z.ZodDefault<z.ZodBoolean>;
10
- key: z.ZodDefault<z.ZodString>;
11
- }, z.core.$loose>>;
12
- placeholder: z.ZodDefault<z.ZodBoolean>;
13
- }, z.core.$loose>;
14
- export declare const BaseModelSchema: z.ZodObject<{
15
- meta: z.ZodDefault<z.ZodObject<{
16
- cache: z.ZodDefault<z.ZodObject<{
17
- hit: z.ZodDefault<z.ZodBoolean>;
18
- key: z.ZodDefault<z.ZodString>;
19
- }, z.core.$loose>>;
20
- placeholder: z.ZodDefault<z.ZodBoolean>;
21
- }, z.core.$loose>>;
22
- }, z.core.$loose>;
3
+ export declare const BaseModelSchema: z.ZodObject<{}, z.core.$loose>;
23
4
  export declare const PaginationOptionsSchema: z.ZodObject<{
24
5
  pageNumber: z.ZodDefault<z.ZodNumber>;
25
6
  pageSize: z.ZodDefault<z.ZodNumber>;
@@ -29,13 +10,6 @@ export declare const PaginationOptionsSchema: z.ZodObject<{
29
10
  *
30
11
  **/
31
12
  export declare function createPaginatedResponseSchema<ItemType extends z.ZodTypeAny>(itemSchema: ItemType): z.ZodObject<{
32
- meta: z.ZodDefault<z.ZodObject<{
33
- cache: z.ZodDefault<z.ZodObject<{
34
- hit: z.ZodDefault<z.ZodBoolean>;
35
- key: z.ZodDefault<z.ZodString>;
36
- }, z.core.$loose>>;
37
- placeholder: z.ZodDefault<z.ZodBoolean>;
38
- }, z.core.$loose>>;
39
13
  pageNumber: z.ZodNumber;
40
14
  pageSize: z.ZodNumber;
41
15
  totalCount: z.ZodNumber;
@@ -55,6 +29,4 @@ export declare const ImageSchema: z.ZodObject<{
55
29
  }, z.core.$loose>;
56
30
  export type Image = InferType<typeof ImageSchema>;
57
31
  export type PaginationOptions = InferType<typeof PaginationOptionsSchema>;
58
- export type CacheInformation = InferType<typeof CacheInformationSchema>;
59
- export type Meta = InferType<typeof MetaSchema>;
60
32
  export type BaseModel = InferType<typeof BaseModelSchema>;
@@ -759,13 +759,6 @@ export declare const CartItemSchema: z.ZodObject<{
759
759
  }, z.core.$loose>>;
760
760
  }, z.core.$loose>;
761
761
  export declare const CartSchema: z.ZodObject<{
762
- meta: z.ZodDefault<z.ZodObject<{
763
- cache: z.ZodDefault<z.ZodObject<{
764
- hit: z.ZodDefault<z.ZodBoolean>;
765
- key: z.ZodDefault<z.ZodString>;
766
- }, z.core.$loose>>;
767
- placeholder: z.ZodDefault<z.ZodBoolean>;
768
- }, z.core.$loose>>;
769
762
  identifier: z.ZodDefault<z.ZodObject<{
770
763
  key: z.ZodString;
771
764
  }, z.core.$loose>>;
@@ -1,13 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import type { InferType } from '../../zod-utils.js';
3
3
  export declare const CategorySchema: z.ZodObject<{
4
- meta: z.ZodDefault<z.ZodObject<{
5
- cache: z.ZodDefault<z.ZodObject<{
6
- hit: z.ZodDefault<z.ZodBoolean>;
7
- key: z.ZodDefault<z.ZodString>;
8
- }, z.core.$loose>>;
9
- placeholder: z.ZodDefault<z.ZodBoolean>;
10
- }, z.core.$loose>>;
11
4
  identifier: z.ZodDefault<z.ZodObject<{
12
5
  key: z.ZodString;
13
6
  }, z.core.$loose>>;
@@ -26,25 +19,11 @@ export declare const CategorySchema: z.ZodObject<{
26
19
  }, z.core.$loose>;
27
20
  export type Category = InferType<typeof CategorySchema>;
28
21
  export declare const CategoryPaginatedResultSchema: z.ZodObject<{
29
- meta: z.ZodDefault<z.ZodObject<{
30
- cache: z.ZodDefault<z.ZodObject<{
31
- hit: z.ZodDefault<z.ZodBoolean>;
32
- key: z.ZodDefault<z.ZodString>;
33
- }, z.core.$loose>>;
34
- placeholder: z.ZodDefault<z.ZodBoolean>;
35
- }, z.core.$loose>>;
36
22
  pageNumber: z.ZodNumber;
37
23
  pageSize: z.ZodNumber;
38
24
  totalCount: z.ZodNumber;
39
25
  totalPages: z.ZodNumber;
40
26
  items: z.ZodArray<z.ZodObject<{
41
- meta: z.ZodDefault<z.ZodObject<{
42
- cache: z.ZodDefault<z.ZodObject<{
43
- hit: z.ZodDefault<z.ZodBoolean>;
44
- key: z.ZodDefault<z.ZodString>;
45
- }, z.core.$loose>>;
46
- placeholder: z.ZodDefault<z.ZodBoolean>;
47
- }, z.core.$loose>>;
48
27
  identifier: z.ZodDefault<z.ZodObject<{
49
28
  key: z.ZodString;
50
29
  }, z.core.$loose>>;
@@ -763,13 +763,6 @@ export declare const CheckoutItemSchema: z.ZodObject<{
763
763
  * payments and shipping methods.
764
764
  */
765
765
  export declare const CheckoutSchema: z.ZodObject<{
766
- meta: z.ZodDefault<z.ZodObject<{
767
- cache: z.ZodDefault<z.ZodObject<{
768
- hit: z.ZodDefault<z.ZodBoolean>;
769
- key: z.ZodDefault<z.ZodString>;
770
- }, z.core.$loose>>;
771
- placeholder: z.ZodDefault<z.ZodBoolean>;
772
- }, z.core.$loose>>;
773
766
  identifier: z.ZodDefault<z.ZodObject<{
774
767
  key: z.ZodString;
775
768
  }, z.core.$loose>>;
@@ -2655,13 +2648,6 @@ export declare const CheckoutSchema: z.ZodObject<{
2655
2648
  name: z.ZodDefault<z.ZodString>;
2656
2649
  description: z.ZodDefault<z.ZodString>;
2657
2650
  billingAddress: z.ZodNullable<z.ZodOptional<z.ZodObject<{
2658
- meta: z.ZodDefault<z.ZodObject<{
2659
- cache: z.ZodDefault<z.ZodObject<{
2660
- hit: z.ZodDefault<z.ZodBoolean>;
2661
- key: z.ZodDefault<z.ZodString>;
2662
- }, z.core.$loose>>;
2663
- placeholder: z.ZodDefault<z.ZodBoolean>;
2664
- }, z.core.$loose>>;
2665
2651
  identifier: z.ZodDefault<z.ZodObject<{
2666
2652
  nickName: z.ZodString;
2667
2653
  }, z.core.$loose>>;
@@ -2675,13 +2661,6 @@ export declare const CheckoutSchema: z.ZodObject<{
2675
2661
  countryCode: z.ZodString;
2676
2662
  }, z.core.$loose>>>;
2677
2663
  shippingAddress: z.ZodOptional<z.ZodObject<{
2678
- meta: z.ZodDefault<z.ZodObject<{
2679
- cache: z.ZodDefault<z.ZodObject<{
2680
- hit: z.ZodDefault<z.ZodBoolean>;
2681
- key: z.ZodDefault<z.ZodString>;
2682
- }, z.core.$loose>>;
2683
- placeholder: z.ZodDefault<z.ZodBoolean>;
2684
- }, z.core.$loose>>;
2685
2664
  identifier: z.ZodDefault<z.ZodObject<{
2686
2665
  nickName: z.ZodString;
2687
2666
  }, z.core.$loose>>;
@@ -2695,13 +2674,6 @@ export declare const CheckoutSchema: z.ZodObject<{
2695
2674
  countryCode: z.ZodString;
2696
2675
  }, z.core.$loose>>;
2697
2676
  shippingInstruction: z.ZodOptional<z.ZodObject<{
2698
- meta: z.ZodDefault<z.ZodObject<{
2699
- cache: z.ZodDefault<z.ZodObject<{
2700
- hit: z.ZodDefault<z.ZodBoolean>;
2701
- key: z.ZodDefault<z.ZodString>;
2702
- }, z.core.$loose>>;
2703
- placeholder: z.ZodDefault<z.ZodBoolean>;
2704
- }, z.core.$loose>>;
2705
2677
  shippingMethod: z.ZodObject<{
2706
2678
  key: z.ZodString;
2707
2679
  }, z.core.$loose>;
@@ -2710,13 +2682,6 @@ export declare const CheckoutSchema: z.ZodObject<{
2710
2682
  consentForUnattendedDelivery: z.ZodBoolean;
2711
2683
  }, z.core.$loose>>;
2712
2684
  paymentInstructions: z.ZodDefault<z.ZodArray<z.ZodObject<{
2713
- meta: z.ZodDefault<z.ZodObject<{
2714
- cache: z.ZodDefault<z.ZodObject<{
2715
- hit: z.ZodDefault<z.ZodBoolean>;
2716
- key: z.ZodDefault<z.ZodString>;
2717
- }, z.core.$loose>>;
2718
- placeholder: z.ZodDefault<z.ZodBoolean>;
2719
- }, z.core.$loose>>;
2720
2685
  identifier: z.ZodObject<{
2721
2686
  key: z.ZodString;
2722
2687
  }, z.core.$loose>;