@mframework/layer-commerce 0.0.3
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/README.md +101 -0
- package/app/cart/useCart.ts +1 -0
- package/app/components/ChevronIcon/ChevronIcon.config.ts +17 -0
- package/app/components/DateSelect/DateSelect.config.ts +15 -0
- package/app/components/Field/Field.config.ts +14 -0
- package/app/components/FieldDate/FieldDate.config.ts +16 -0
- package/app/components/Form/Form.type.ts +8 -0
- package/app/components/Product/Product.config.ts +19 -0
- package/app/components/Product/Stock.config.ts +15 -0
- package/app/components/ProductCustomizableOption/ProductCustomizableOption.config.ts +5 -0
- package/app/components/ProductGallery/ProductGallery.config.ts +15 -0
- package/app/components/ProductReviews/ProductReviews.config.ts +8 -0
- package/app/composables/_types.ts +18 -0
- package/app/composables/adapters/abstract/cartAdapter.ts +0 -0
- package/app/composables/adapters/abstract/categoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/customerAdapter.ts +0 -0
- package/app/composables/adapters/abstract/inventoryAdapter.ts +0 -0
- package/app/composables/adapters/abstract/orderAdapter.ts +0 -0
- package/app/composables/adapters/abstract/productAdapter.ts +7 -0
- package/app/composables/cart/registry.ts +20 -0
- package/app/composables/cart/types.ts +18 -0
- package/app/composables/cart/useCart.ts +15 -0
- package/app/composables/config.ts +19 -0
- package/app/composables/defs/apiDefinitions.ts +55 -0
- package/app/composables/defs/extension.feature +40 -0
- package/app/composables/defs/extension.mocks.ts +39 -0
- package/app/composables/defs/extension.test.ts +280 -0
- package/app/composables/defs/extension.ts +236 -0
- package/app/composables/defs/index.ts +3 -0
- package/app/composables/defs/typeHelpers.ts +8 -0
- package/app/composables/defs/types.ts +136 -0
- package/app/composables/domain/product.ts +12 -0
- package/app/composables/featured-products.ts +20 -0
- package/app/composables/helpers/contextualizedNormalizers.feature +14 -0
- package/app/composables/helpers/contextualizedNormalizers.test.ts +85 -0
- package/app/composables/helpers/contextualizedNormalizers.ts +20 -0
- package/app/composables/helpers/index.ts +1 -0
- package/app/composables/index.ts +9 -0
- package/app/composables/methods/auth.ts +83 -0
- package/app/composables/methods/cart.ts +119 -0
- package/app/composables/methods/category.ts +27 -0
- package/app/composables/methods/checkout.ts +54 -0
- package/app/composables/methods/customer.ts +52 -0
- package/app/composables/methods/helpers.ts +5 -0
- package/app/composables/methods/index.ts +75 -0
- package/app/composables/methods/order.ts +39 -0
- package/app/composables/methods/product.ts +95 -0
- package/app/composables/methods/settings.ts +16 -0
- package/app/composables/models/cart.ts +95 -0
- package/app/composables/models/category.ts +13 -0
- package/app/composables/models/checkout.ts +17 -0
- package/app/composables/models/customer.ts +16 -0
- package/app/composables/models/facets.ts +25 -0
- package/app/composables/models/index.ts +94 -0
- package/app/composables/models/order.ts +43 -0
- package/app/composables/models/product.ts +73 -0
- package/app/composables/models/shared.ts +75 -0
- package/app/composables/orders.ts +69 -0
- package/app/composables/products/registry.ts +86 -0
- package/app/composables/products/types.ts +8 -0
- package/app/composables/products/useEvents.ts +26 -0
- package/app/composables/products/useGiftCards.ts +29 -0
- package/app/composables/products/useProducts.ts +12 -0
- package/app/composables/products/useSubscriptions.ts +29 -0
- package/app/composables/products.ts +30 -0
- package/app/composables/registry.ts +24 -0
- package/app/composables/useAuth.ts +43 -0
- package/app/composables/useBreakpoints/index.ts +1 -0
- package/app/composables/useBreakpoints/useBreakpoints.ts +28 -0
- package/app/composables/useCache.ts +38 -0
- package/app/composables/useCart/__tests__/useCart.spec.ts +11 -0
- package/app/composables/useCart/index.ts +1 -0
- package/app/composables/useCart/types.ts +17 -0
- package/app/composables/useCart/useCart.ts +46 -0
- package/app/composables/useCartShippingMethods/__tests__/useCartShippingMethods.spec.ts +11 -0
- package/app/composables/useCartShippingMethods/index.ts +1 -0
- package/app/composables/useCartShippingMethods/types.ts +17 -0
- package/app/composables/useCartShippingMethods/useCartShippingMethods.ts +47 -0
- package/app/composables/useCatalog.ts +26 -0
- package/app/composables/useContent.ts +26 -0
- package/app/composables/useCustomer/__tests__/useCustomer.spec.ts +25 -0
- package/app/composables/useCustomer/index.ts +2 -0
- package/app/composables/useCustomer/types.ts +17 -0
- package/app/composables/useCustomer/useCustomer.ts +40 -0
- package/app/composables/useCustomerAddress/__tests__/useCustomerAddress.spec.ts +11 -0
- package/app/composables/useCustomerAddress/index.ts +2 -0
- package/app/composables/useCustomerAddress/types.ts +17 -0
- package/app/composables/useCustomerAddress/useCustomerAddress.ts +55 -0
- package/app/composables/useCustomerOrder/__tests__/useCustomerOrder.spec.ts +11 -0
- package/app/composables/useCustomerOrder/adress.ts +10 -0
- package/app/composables/useCustomerOrder/index.ts +2 -0
- package/app/composables/useCustomerOrder/product.ts +37 -0
- package/app/composables/useCustomerOrder/types.ts +40 -0
- package/app/composables/useCustomerOrder/useCustomerOrder.ts +63 -0
- package/app/composables/useCustomerOrders/__tests__/useCustomerOrders.spec.ts +11 -0
- package/app/composables/useCustomerOrders/index.ts +2 -0
- package/app/composables/useCustomerOrders/types.ts +20 -0
- package/app/composables/useCustomerOrders/useCustomerOrders.ts +56 -0
- package/app/composables/useCustomerReturns/__tests__/useCustomerReturns.spec.ts +11 -0
- package/app/composables/useCustomerReturns/index.ts +2 -0
- package/app/composables/useCustomerReturns/types.ts +17 -0
- package/app/composables/useCustomerReturns/useCustomerReturns.ts +41 -0
- package/app/composables/useHandleError/index.ts +1 -0
- package/app/composables/useHandleError/types.ts +11 -0
- package/app/composables/useHandleError/useHandleError.ts +27 -0
- package/app/composables/useInventory.ts +29 -0
- package/app/composables/useLoading.ts +21 -0
- package/app/composables/useNotification.ts +21 -0
- package/app/composables/usePageTitle.ts +20 -0
- package/app/composables/useProduct/index.ts +2 -0
- package/app/composables/useProduct/types.ts +17 -0
- package/app/composables/useProduct/useProduct.ts +42 -0
- package/app/composables/useProductAttribute/__tests__/useProduct.mock.ts +31 -0
- package/app/composables/useProductAttribute/__tests__/useProductAttribute.spec.ts +14 -0
- package/app/composables/useProductAttribute/index.ts +1 -0
- package/app/composables/useProductAttribute/useProductAttribute.ts +37 -0
- package/app/composables/useProductRecommended/__tests__/useProductRecommended.spec.ts +12 -0
- package/app/composables/useProductRecommended/index.ts +1 -0
- package/app/composables/useProductRecommended/types.ts +17 -0
- package/app/composables/useProductRecommended/useProductRecommended.ts +43 -0
- package/app/composables/useProductReviews/__tests__/productReviews.mock.ts +20 -0
- package/app/composables/useProductReviews/__tests__/useProductReviews.spec.ts +22 -0
- package/app/composables/useProductReviews/index.ts +2 -0
- package/app/composables/useProductReviews/types.ts +17 -0
- package/app/composables/useProductReviews/useProductReviews.ts +46 -0
- package/app/composables/useProducts/__tests__/useProducts.spec.ts +11 -0
- package/app/composables/useProducts/types.ts +22 -0
- package/app/composables/useProducts/useProducts.ts +41 -0
- package/app/composables/useTax.ts +27 -0
- package/app/composables/validationRules/index.ts +1 -0
- package/app/composables/validationRules/password.feature +67 -0
- package/app/composables/validationRules/password.test.ts +89 -0
- package/app/composables/validationRules/password.ts +25 -0
- package/app/normalizers/Cart.query.ts +729 -0
- package/app/normalizers/Cart.type.ts +285 -0
- package/app/normalizers/Category.query.ts +146 -0
- package/app/normalizers/Category.type.ts +55 -0
- package/app/normalizers/CheckEmail.query.ts +28 -0
- package/app/normalizers/Checkout.query.ts +253 -0
- package/app/normalizers/Checkout.type.ts +77 -0
- package/app/normalizers/CmsBlock.query.ts +57 -0
- package/app/normalizers/CmsBlock.type.ts +25 -0
- package/app/normalizers/CmsPage.query.ts +59 -0
- package/app/normalizers/CmsPage.type.ts +26 -0
- package/app/normalizers/Config.query.ts +224 -0
- package/app/normalizers/Config.type.ts +196 -0
- package/app/normalizers/ContactForm.query.ts +49 -0
- package/app/normalizers/CreditMemo.type.ts +49 -0
- package/app/normalizers/GiftCard.type.ts +24 -0
- package/app/normalizers/Invoice.type.ts +58 -0
- package/app/normalizers/Menu.query.ts +54 -0
- package/app/normalizers/Menu.type.ts +22 -0
- package/app/normalizers/MyAccount.query.ts +268 -0
- package/app/normalizers/MyAccount.type.ts +129 -0
- package/app/normalizers/NewsletterSubscription.query.ts +38 -0
- package/app/normalizers/Order.query.ts +741 -0
- package/app/normalizers/Order.type.ts +268 -0
- package/app/normalizers/Payment.type.ts +28 -0
- package/app/normalizers/ProductAlerts.query.ts +23 -0
- package/app/normalizers/ProductCompare.query.ts +226 -0
- package/app/normalizers/ProductCompare.type.ts +90 -0
- package/app/normalizers/ProductList.query.ts +1620 -0
- package/app/normalizers/ProductList.type.ts +726 -0
- package/app/normalizers/Region.query.ts +58 -0
- package/app/normalizers/Region.type.ts +23 -0
- package/app/normalizers/Return.type.ts +50 -0
- package/app/normalizers/Review.query.ts +81 -0
- package/app/normalizers/Review.type.ts +42 -0
- package/app/normalizers/Slider.query.ts +72 -0
- package/app/normalizers/Slider.type.ts +26 -0
- package/app/normalizers/StoreInPickUp.query.ts +54 -0
- package/app/normalizers/StoreInPickUp.type.ts +59 -0
- package/app/normalizers/Subscription.type.ts +25 -0
- package/app/normalizers/Transaction.type.ts +20 -0
- package/app/normalizers/UrlRewrites.query.ts +55 -0
- package/app/normalizers/UrlRewrites.type.ts +25 -0
- package/app/normalizers/Wishlist.query.ts +202 -0
- package/app/normalizers/Wishlist.type.ts +42 -0
- package/app/pages/brand/[...slug].vue +76 -0
- package/app/pages/brands.vue +67 -0
- package/app/pages/cart.vue +142 -0
- package/app/pages/compare.vue +166 -0
- package/app/pages/departments/[...slug].vue +353 -0
- package/app/pages/departments/category/[...slug].vue +114 -0
- package/app/pages/incentive/[...id].vue +66 -0
- package/app/pages/invoice/[id].vue +309 -0
- package/app/pages/order/[id].vue +327 -0
- package/app/pages/product/[...id].vue +309 -0
- package/app/pages/product/showcases/index.vue +86 -0
- package/app/pages/shipment/[...id].vue +176 -0
- package/app/pages/shop/[...slug].vue +158 -0
- package/app/pages/shops.vue +76 -0
- package/app/pages/subscription/[...id].vue +147 -0
- package/app/pages/transaction/[...id].vue +74 -0
- package/app/routes/CategoryPage/CategoryPage.config.ts +28 -0
- package/app/routes/CategoryPage/CategoryPage.type.ts +8 -0
- package/app/routes/Checkout/Checkout.config.ts +3 -0
- package/app/routes/Checkout/Checkout.type.ts +14 -0
- package/app/routes/MyAccount/MyAccount.config.ts +1 -0
- package/app/routes/SearchPage/SearchPage.config.ts +1 -0
- package/app/routes/UrlRewrites/UrlRewrites.config.ts +5 -0
- package/app/stores/Cart/Cart.type.ts +26 -0
- package/app/stores/MyAccount/MyAccount.action.ts +7 -0
- package/app/stores/Notification/Notification.action.ts +40 -0
- package/app/stores/Notification/Notification.type.ts +16 -0
- package/app/stores/Popup/Popup.action.ts +30 -0
- package/app/stores/Product/Product.dispatcher.ts +53 -0
- package/app/stores/Product/Product.reducer.ts +12 -0
- package/app/stores/ProductList/ProductList.dispatcher.ts +35 -0
- package/app/stores/ProductList/ProductList.reducer.ts +13 -0
- package/app/stores/Store.type.ts +31 -0
- package/app/stores/Wishlist/Wishlist.type.ts +12 -0
- package/app/stores/cart.ts +218 -0
- package/app/stores/cartStore.ts +224 -0
- package/app/stores/checkout.ts +18 -0
- package/app/stores/compare.ts +65 -0
- package/app/stores/currency.js +29 -0
- package/app/stores/digital-products.js +11 -0
- package/app/stores/orders.ts +172 -0
- package/app/stores/product.ts +34 -0
- package/app/stores/productList.ts +35 -0
- package/app/stores/productListInfo.ts +0 -0
- package/app/stores/products.ts +118 -0
- package/app/stores/recentlyViewedProducts.ts +56 -0
- package/app/stores/review.ts +33 -0
- package/app/stores/storeInPickUp.ts +21 -0
- package/app/stores/user.ts +20 -0
- package/app/stores/wishlist.ts +46 -0
- package/app/types/Account.type.ts +141 -0
- package/app/types/Breadcrumbs.type.ts +23 -0
- package/app/types/CMS.type.ts +33 -0
- package/app/types/Category.type.ts +67 -0
- package/app/types/Checkout.type.ts +58 -0
- package/app/types/Common.type.ts +77 -0
- package/app/types/Config.type.ts +47 -0
- package/app/types/Device.type.ts +37 -0
- package/app/types/Direction.type.ts +23 -0
- package/app/types/Downloadable.type.ts +24 -0
- package/app/types/Error.type.ts +22 -0
- package/app/types/Field.type.ts +151 -0
- package/app/types/Global.type.ts +156 -0
- package/app/types/Graphql.type.ts +4497 -0
- package/app/types/Layout.type.ts +18 -0
- package/app/types/Menu.type.ts +39 -0
- package/app/types/MiniCart.type.ts +61 -0
- package/app/types/NotificationList.type.ts +34 -0
- package/app/types/Order.type.ts +174 -0
- package/app/types/Price.type.ts +72 -0
- package/app/types/ProductCompare.type.ts +24 -0
- package/app/types/ProductList.type.ts +351 -0
- package/app/types/Rating.type.ts +42 -0
- package/app/types/Router.type.ts +67 -0
- package/app/types/Slider.type.ts +25 -0
- package/app/types/StockStatus.type.ts +21 -0
- package/app/types/domain/index.ts +94 -0
- package/app/types/index.ts +33 -0
- package/app/types/shims.d.ts +52 -0
- package/app/types/tilework-opus.d.ts +48 -0
- package/app/utils/Address/Address.type.ts +28 -0
- package/app/utils/Address/index.ts +325 -0
- package/app/utils/Auth/IsSignedIn.ts +4 -0
- package/app/utils/Auth/Token.ts +9 -0
- package/app/utils/Base64/Base64.ts +16 -0
- package/app/utils/Base64/index.ts +12 -0
- package/app/utils/Browser/Browser.ts +29 -0
- package/app/utils/Browser/index.ts +12 -0
- package/app/utils/BrowserDatabase/BrowserDatabase.ts +70 -0
- package/app/utils/BrowserDatabase/index.ts +12 -0
- package/app/utils/CSS/CSS.ts +65 -0
- package/app/utils/CSS/index.ts +12 -0
- package/app/utils/Cache/Cache.ts +99 -0
- package/app/utils/Cart/Cart.ts +300 -0
- package/app/utils/Cart/Cart.type.ts +76 -0
- package/app/utils/Cart/Token.ts +59 -0
- package/app/utils/Cart/index.ts +13 -0
- package/app/utils/Category/Filters.ts +39 -0
- package/app/utils/Category/index.ts +12 -0
- package/app/utils/Common/index.ts +32 -0
- package/app/utils/Compare/Compare.ts +89 -0
- package/app/utils/Compare/index.ts +12 -0
- package/app/utils/Currency/Currency.ts +84 -0
- package/app/utils/Currency/index.ts +12 -0
- package/app/utils/DynamicReducer/DynamicReducer.type.ts +14 -0
- package/app/utils/DynamicReducer/Helper.ts +30 -0
- package/app/utils/DynamicReducer/index.tsx +35 -0
- package/app/utils/ElementTransition/ElementTransition.ts +100 -0
- package/app/utils/Form/Extract.ts +316 -0
- package/app/utils/Form/Form.ts +46 -0
- package/app/utils/Form/Form.type.ts +60 -0
- package/app/utils/Form/Transform.ts +33 -0
- package/app/utils/FormPortalCollector/index.ts +45 -0
- package/app/utils/History/History.type.ts +31 -0
- package/app/utils/History/index.ts +17 -0
- package/app/utils/Manipulations/Array.ts +18 -0
- package/app/utils/Manipulations/Date.ts +36 -0
- package/app/utils/Manipulations/index.ts +14 -0
- package/app/utils/Media/Media.ts +27 -0
- package/app/utils/Media/index.ts +13 -0
- package/app/utils/Menu/Menu.ts +116 -0
- package/app/utils/Menu/Menu.type.ts +37 -0
- package/app/utils/Menu/index.ts +12 -0
- package/app/utils/Mobile/index.ts +13 -0
- package/app/utils/Mobile/isMobile.ts +34 -0
- package/app/utils/Orders/Orders.ts +71 -0
- package/app/utils/Orders/Orders.type.ts +19 -0
- package/app/utils/Orders/index.ts +13 -0
- package/app/utils/Polyfill/index.ts +336 -0
- package/app/utils/Preload/CategoryPreload.ts +74 -0
- package/app/utils/Preload/ProductPreload.ts +28 -0
- package/app/utils/Preload/index.ts +75 -0
- package/app/utils/Price/Price.config.ts +189 -0
- package/app/utils/Price/Price.ts +63 -0
- package/app/utils/Price/index.ts +12 -0
- package/app/utils/Product/Extract.ts +652 -0
- package/app/utils/Product/Product.ts +575 -0
- package/app/utils/Product/Product.type.ts +260 -0
- package/app/utils/Product/Transform.ts +382 -0
- package/app/utils/Product/index.ts +12 -0
- package/app/utils/Promise/MakeCancelable.ts +44 -0
- package/app/utils/Promise/Promise.type.ts +15 -0
- package/app/utils/Promise/index.ts +13 -0
- package/app/utils/Query/Field.ts +71 -0
- package/app/utils/Query/Fragment.ts +22 -0
- package/app/utils/Query/PrepareDocument.ts +119 -0
- package/app/utils/Query/Query.type.ts +26 -0
- package/app/utils/Query/index.ts +15 -0
- package/app/utils/Request/Config.ts +21 -0
- package/app/utils/Request/DataContainer.ts +102 -0
- package/app/utils/Request/Debounce.ts +48 -0
- package/app/utils/Request/Error.ts +31 -0
- package/app/utils/Request/Hash.ts +88 -0
- package/app/utils/Request/LowPriorityLoad.ts +32 -0
- package/app/utils/Request/LowPriorityRender.ts +55 -0
- package/app/utils/Request/Mutation.ts +25 -0
- package/app/utils/Request/Query.ts +25 -0
- package/app/utils/Request/QueryDispatcher.ts +135 -0
- package/app/utils/Request/Request.ts +310 -0
- package/app/utils/Store/Store.type.ts +26 -0
- package/app/utils/Store/index.ts +71 -0
- package/app/utils/Url/Url.ts +297 -0
- package/app/utils/Url/index.ts +12 -0
- package/app/utils/Validator/Config.ts +96 -0
- package/app/utils/Validator/Validator.ts +268 -0
- package/app/utils/Validator/Validator.type.ts +47 -0
- package/app/utils/Validator/index.ts +12 -0
- package/app/utils/Wishlist/Wishlist.ts +65 -0
- package/app/utils/Wishlist/index.ts +12 -0
- package/app/utils/client.ts +280 -0
- package/app/utils/index.ts +53 -0
- package/app/utils/normalizer.ts +23 -0
- package/app/utils/normalizers/magento.ts +29 -0
- package/app/utils/normalizers/shopify.ts +29 -0
- package/nuxt.config.ts +11 -0
- package/package.json +43 -0
- package/tsconfig.json +45 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Feature: Contextualized normalizers
|
|
2
|
+
|
|
3
|
+
Scenario: Context is passed to normalizers
|
|
4
|
+
Given a normalizer that requires a context as a second argument
|
|
5
|
+
When toContextualizedNormalizers function is called
|
|
6
|
+
And the normalizer is called with just an input
|
|
7
|
+
Then the normalizer should also receive the context
|
|
8
|
+
|
|
9
|
+
Scenario: Context changes
|
|
10
|
+
Given a normalizer that requires a context as a second argument
|
|
11
|
+
When toContextualizedNormalizers function is called
|
|
12
|
+
And the context changes
|
|
13
|
+
And the normalizer is called with just an input
|
|
14
|
+
Then the normalizer should use the recent version of the context
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { defineFeature, loadFeature } from "jest-cucumber";
|
|
2
|
+
import type { ContextualizedNormalizers } from "./contextualizedNormalizers";
|
|
3
|
+
import { toContextualizedNormalizers } from "./contextualizedNormalizers";
|
|
4
|
+
import type { SfMoney } from "../models";
|
|
5
|
+
import { beforeEach, expect, vi } from "vitest";
|
|
6
|
+
|
|
7
|
+
const feature = loadFeature("./contextualizedNormalizers.feature", { loadRelativePath: true });
|
|
8
|
+
|
|
9
|
+
defineFeature(feature, (test) => {
|
|
10
|
+
type TestContext = {
|
|
11
|
+
locale: string;
|
|
12
|
+
currency: string;
|
|
13
|
+
};
|
|
14
|
+
type Normalizers = {
|
|
15
|
+
normalizeMoney(context: TestContext, input: number): SfMoney;
|
|
16
|
+
};
|
|
17
|
+
let testNormalizers: Normalizers;
|
|
18
|
+
let output: ContextualizedNormalizers<Normalizers>;
|
|
19
|
+
let context: TestContext;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
context = {
|
|
23
|
+
currency: "USD",
|
|
24
|
+
locale: "en",
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("Context is passed to normalizers", ({ given, when, and, then }) => {
|
|
29
|
+
given("a normalizer that requires a context as a second argument", () => {
|
|
30
|
+
testNormalizers = {
|
|
31
|
+
normalizeMoney: vi.fn((context, input) => {
|
|
32
|
+
return {
|
|
33
|
+
amount: input,
|
|
34
|
+
currency: context.currency,
|
|
35
|
+
precisionAmount: input.toFixed(2),
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
when("toContextualizedNormalizers function is called", () => {
|
|
42
|
+
output = toContextualizedNormalizers(testNormalizers, () => context);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
and("the normalizer is called with just an input", () => {
|
|
46
|
+
output.normalizeMoney(100);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
then("the normalizer should also receive the context", () => {
|
|
50
|
+
expect(testNormalizers.normalizeMoney).toHaveBeenCalledWith(context, 100);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
test("Context changes", ({ given, when, and, then }) => {
|
|
54
|
+
given("a normalizer that requires a context as a second argument", () => {
|
|
55
|
+
testNormalizers = {
|
|
56
|
+
normalizeMoney: vi.fn((context, input) => {
|
|
57
|
+
return {
|
|
58
|
+
amount: input,
|
|
59
|
+
currency: context.currency,
|
|
60
|
+
precisionAmount: input.toFixed(2),
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
when("toContextualizedNormalizers function is called", () => {
|
|
67
|
+
output = toContextualizedNormalizers(testNormalizers, () => context);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
and("the context changes", () => {
|
|
71
|
+
context.currency = "EUR";
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
and("the normalizer is called with just an input", () => {
|
|
75
|
+
output.normalizeMoney(100);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
then("the normalizer should use the recent version of the context", () => {
|
|
79
|
+
expect(testNormalizers.normalizeMoney).toHaveBeenCalledWith(
|
|
80
|
+
expect.objectContaining({ currency: "EUR" }),
|
|
81
|
+
expect.anything(),
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NormalizersConstraint } from "../defs";
|
|
2
|
+
|
|
3
|
+
export type ContextualizedNormalizers<TNormalizers extends NormalizersConstraint> = {
|
|
4
|
+
[TKey in keyof TNormalizers]: (
|
|
5
|
+
input: Parameters<TNormalizers[TKey]>[1],
|
|
6
|
+
) => ReturnType<TNormalizers[TKey]>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function toContextualizedNormalizers<
|
|
10
|
+
TNormalizers extends NormalizersConstraint,
|
|
11
|
+
TNormalizerContext extends Record<string, any>,
|
|
12
|
+
>(
|
|
13
|
+
normalizers: TNormalizers,
|
|
14
|
+
getContext: () => TNormalizerContext,
|
|
15
|
+
): ContextualizedNormalizers<TNormalizers> {
|
|
16
|
+
return Object.keys(normalizers).reduce((acc: any, key) => {
|
|
17
|
+
acc[key] = (input: any) => normalizers[key]!(getContext(), input);
|
|
18
|
+
return { ...acc };
|
|
19
|
+
}, {});
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./contextualizedNormalizers";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./defs";
|
|
2
|
+
export * from "./helpers";
|
|
3
|
+
export * from "./methods";
|
|
4
|
+
export * from "./models";
|
|
5
|
+
export * from "./validationRules";
|
|
6
|
+
export * from "./registry";
|
|
7
|
+
export { useCatalogFallback } from "./useCatalog";
|
|
8
|
+
export { usePageTitle } from "./usePageTitle";
|
|
9
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { Maybe, SfCustomer } from "../models";
|
|
3
|
+
|
|
4
|
+
export interface RegisterCustomerExtendedArgs {}
|
|
5
|
+
export interface RegisterCustomerCustomArgs {}
|
|
6
|
+
|
|
7
|
+
export type RegisterCustomerArgs = {
|
|
8
|
+
email: string;
|
|
9
|
+
firstName: string;
|
|
10
|
+
lastName: string;
|
|
11
|
+
password: string;
|
|
12
|
+
//$extended?: RegisterCustomerExtendedArgs;
|
|
13
|
+
//$custom?: RegisterCustomerCustomArgs;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type RegisterCustomer = (args: Simplify<RegisterCustomerArgs>) => Promise<{
|
|
17
|
+
customer: SfCustomer;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export interface LoginCustomerExtendedArgs {}
|
|
21
|
+
export interface LoginCustomerCustomArgs {}
|
|
22
|
+
|
|
23
|
+
export type LoginCustomerArgs = {
|
|
24
|
+
email: string;
|
|
25
|
+
password: string;
|
|
26
|
+
//$extended?: LoginCustomerExtendedArgs;
|
|
27
|
+
//$custom?: LoginCustomerCustomArgs;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type LoginCustomer = (args: Simplify<LoginCustomerArgs>) => Promise<{
|
|
31
|
+
customer: SfCustomer;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
export interface GetCustomerExtendedArgs {}
|
|
35
|
+
export interface GetCustomerCustomArgs {}
|
|
36
|
+
|
|
37
|
+
export type GetCustomerArgs = {
|
|
38
|
+
//$extended?: GetCustomerExtendedArgs;
|
|
39
|
+
//$custom?: GetCustomerCustomArgs;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type GetCustomer = (args?: Simplify<GetCustomerArgs>) => Promise<{
|
|
43
|
+
customer: Maybe<SfCustomer>;
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
export interface LogoutCustomerExtendedArgs {}
|
|
47
|
+
export interface LogoutCustomerCustomArgs {}
|
|
48
|
+
|
|
49
|
+
export type LogoutCustomerArgs = {
|
|
50
|
+
//$extended?: LogoutCustomerExtendedArgs;
|
|
51
|
+
//$custom?: LogoutCustomerCustomArgs;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type LogoutCustomer = (args?: Simplify<LogoutCustomerArgs>) => Promise<void>;
|
|
55
|
+
|
|
56
|
+
export interface UpdateCustomerExtendedArgs {}
|
|
57
|
+
export interface UpdateCustomerCustomArgs {}
|
|
58
|
+
|
|
59
|
+
export type UpdateCustomerArgs = {
|
|
60
|
+
email?: string;
|
|
61
|
+
firstName?: string;
|
|
62
|
+
lastName?: string;
|
|
63
|
+
//$extended?: UpdateCustomerExtendedArgs;
|
|
64
|
+
//$custom?: UpdateCustomerCustomArgs;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type UpdateCustomer = (args: Simplify<UpdateCustomerArgs>) => Promise<{
|
|
68
|
+
customer: SfCustomer;
|
|
69
|
+
}>;
|
|
70
|
+
|
|
71
|
+
export interface ChangeCustomerPasswordExtendedArgs {}
|
|
72
|
+
export interface ChangeCustomerPasswordCustomArgs {}
|
|
73
|
+
|
|
74
|
+
export type ChangeCustomerPasswordArgs = {
|
|
75
|
+
currentPassword: string;
|
|
76
|
+
// eslint-disable-next-line unicorn/no-keyword-prefix
|
|
77
|
+
newPassword: string;
|
|
78
|
+
confirmPassword: string;
|
|
79
|
+
//$extended?: ChangeCustomerPasswordExtendedArgs;
|
|
80
|
+
//$custom?: ChangeCustomerPasswordCustomArgs;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type ChangeCustomerPassword = (args: Simplify<ChangeCustomerPasswordArgs>) => Promise<void>;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { Maybe, SfCart } from "../models";
|
|
3
|
+
|
|
4
|
+
export interface GetCartExtendedArgs {}
|
|
5
|
+
export interface GetCartCustomArgs {}
|
|
6
|
+
|
|
7
|
+
export type GetCartArgs = {
|
|
8
|
+
/**
|
|
9
|
+
* Unique identifier of cart
|
|
10
|
+
*/
|
|
11
|
+
cartId?: string;
|
|
12
|
+
//$extended?: GetCartExtendedArgs;
|
|
13
|
+
//$custom?: GetCartCustomArgs;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export interface AddCartLineItemExtendedArgs {}
|
|
17
|
+
export interface AddCartLineItemCustomArgs {}
|
|
18
|
+
|
|
19
|
+
export type AddCartLineItemArgs = {
|
|
20
|
+
/**
|
|
21
|
+
* Product unique identifier - for commercetools it's a SKU, for sap it's a product code
|
|
22
|
+
*/
|
|
23
|
+
productId: string;
|
|
24
|
+
sku: Maybe<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Quantity of product to add to cart
|
|
27
|
+
* @default 1
|
|
28
|
+
*/
|
|
29
|
+
quantity?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Unique identifier of cart
|
|
32
|
+
*/
|
|
33
|
+
cartId?: string;
|
|
34
|
+
//$extended?: AddCartLineItemExtendedArgs;
|
|
35
|
+
//$custom?: AddCartLineItemCustomArgs;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface UpdateCartLineItemExtendedArgs {}
|
|
39
|
+
export interface UpdateCartLineItemCustomArgs {}
|
|
40
|
+
|
|
41
|
+
export type UpdateCartLineItemArgs = {
|
|
42
|
+
lineItemId: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
/**
|
|
45
|
+
* Unique identifier of cart
|
|
46
|
+
*/
|
|
47
|
+
cartId?: string;
|
|
48
|
+
//$extended?: UpdateCartLineItemExtendedArgs;
|
|
49
|
+
//$custom?: UpdateCartLineItemCustomArgs;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export interface RemoveCartLineItemExtendedArgs {}
|
|
53
|
+
export interface RemoveCartLineItemCustomArgs {}
|
|
54
|
+
|
|
55
|
+
export type RemoveCartLineItemArgs = {
|
|
56
|
+
lineItemId: string;
|
|
57
|
+
/**
|
|
58
|
+
* Unique identifier of cart
|
|
59
|
+
*/
|
|
60
|
+
cartId?: string;
|
|
61
|
+
//$extended?: RemoveCartLineItemExtendedArgs;
|
|
62
|
+
//$custom?: RemoveCartLineItemCustomArgs;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface ApplyCouponToCartExtendedArgs {}
|
|
66
|
+
export interface ApplyCouponToCartCustomArgs {}
|
|
67
|
+
|
|
68
|
+
export type ApplyCouponToCartArgs = {
|
|
69
|
+
couponCode: string;
|
|
70
|
+
/**
|
|
71
|
+
* Unique identifier of cart
|
|
72
|
+
*/
|
|
73
|
+
cartId?: string;
|
|
74
|
+
//$extended?: ApplyCouponToCartExtendedArgs;
|
|
75
|
+
//$custom?: ApplyCouponToCartCustomArgs;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export interface RemoveCouponFromCartExtendedArgs {}
|
|
79
|
+
export interface RemoveCouponFromCartCustomArgs {}
|
|
80
|
+
|
|
81
|
+
export type RemoveCouponFromCartArgs = {
|
|
82
|
+
/**
|
|
83
|
+
* Don't confuse it with coupon code. It can be retrieved from cart.appliedCoupons
|
|
84
|
+
*/
|
|
85
|
+
couponId: string;
|
|
86
|
+
/**
|
|
87
|
+
* Unique identifier of cart
|
|
88
|
+
*/
|
|
89
|
+
cartId?: string;
|
|
90
|
+
//$extended?: RemoveCouponFromCartExtendedArgs;
|
|
91
|
+
//$custom?: RemoveCouponFromCartCustomArgs;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get all information about customer's cart
|
|
96
|
+
*/
|
|
97
|
+
export type GetCart = (args?: Simplify<GetCartArgs>) => Promise<SfCart>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Add product to cart
|
|
101
|
+
*/
|
|
102
|
+
export type AddCartLineItem = (args: Simplify<AddCartLineItemArgs>) => Promise<SfCart>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Update product quantity in cart
|
|
106
|
+
*/
|
|
107
|
+
export type UpdateCartLineItem = (args: Simplify<UpdateCartLineItemArgs>) => Promise<SfCart>;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Remove product from cart
|
|
111
|
+
*/
|
|
112
|
+
export type RemoveCartLineItem = (args: Simplify<RemoveCartLineItemArgs>) => Promise<SfCart>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Apply a coupon to cart to get a discount
|
|
116
|
+
*/
|
|
117
|
+
export type ApplyCouponToCart = (args: Simplify<ApplyCouponToCartArgs>) => Promise<SfCart>;
|
|
118
|
+
|
|
119
|
+
export type RemoveCouponFromCart = (args: Simplify<RemoveCouponFromCartArgs>) => Promise<SfCart>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { SfCategory } from "../models";
|
|
3
|
+
|
|
4
|
+
export interface GetCategoriesExtendedArgs {}
|
|
5
|
+
export interface GetCategoriesCustomArgs {}
|
|
6
|
+
|
|
7
|
+
export type GetCategoriesArgs = {
|
|
8
|
+
ids?: string[];
|
|
9
|
+
slugs?: string[];
|
|
10
|
+
//$extended?: GetCategoriesExtendedArgs;
|
|
11
|
+
//$custom?: GetCategoriesCustomArgs;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type GetCategories = (args?: Simplify<GetCategoriesArgs>) => Promise<SfCategory[]>;
|
|
15
|
+
|
|
16
|
+
export interface GetCategoryExtendedArgs {}
|
|
17
|
+
export interface GetCategoryCustomArgs {}
|
|
18
|
+
export type GetCategoryArgs = {
|
|
19
|
+
id: string;
|
|
20
|
+
//$extended?: GetCategoryExtendedArgs;
|
|
21
|
+
//$custom?: GetCategoryCustomArgs;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type GetCategory = (args: Simplify<GetCategoryArgs>) => Promise<{
|
|
25
|
+
ancestors: SfCategory[];
|
|
26
|
+
category: SfCategory;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { SfCart, SfCreateAddressBody, SfCustomerAddress, SfShippingMethods } from "../models";
|
|
3
|
+
|
|
4
|
+
export interface SetCustomerEmailExtendedArgs {}
|
|
5
|
+
export interface SetCustomerEmailCustomArgs {}
|
|
6
|
+
|
|
7
|
+
export type SetCustomerEmailArgs = {
|
|
8
|
+
email: string;
|
|
9
|
+
//$extended?: SetCustomerEmailExtendedArgs;
|
|
10
|
+
//$custom?: SetCustomerEmailCustomArgs;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type SetShippingAddress = {
|
|
14
|
+
shippingAddress: SfCreateAddressBody | SfCustomerAddress;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export interface SetCartAddressExtendedArgs {}
|
|
18
|
+
export interface SetCartAddressCustomArgs {}
|
|
19
|
+
|
|
20
|
+
export type SetCartAddressArgs = SetShippingAddress & {
|
|
21
|
+
//$extended?: SetCartAddressExtendedArgs;
|
|
22
|
+
//$custom?: SetCartAddressCustomArgs;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface SetShippingMethodExtendedArgs {}
|
|
26
|
+
export interface SetShippingMethodCustomArgs {}
|
|
27
|
+
|
|
28
|
+
export type SetShippingMethodArgs = {
|
|
29
|
+
shippingMethodId: string;
|
|
30
|
+
//$extended?: SetShippingMethodExtendedArgs;
|
|
31
|
+
//$custom?: SetShippingMethodCustomArgs;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set an email of active customer
|
|
36
|
+
*/
|
|
37
|
+
export type SetCustomerEmail = (args: Simplify<SetCustomerEmailArgs>) => Promise<SfCart>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Set customers adddress
|
|
41
|
+
* @example Set shipping address first
|
|
42
|
+
* setCartAddress({ shippingAddress: { ... } })
|
|
43
|
+
*/
|
|
44
|
+
export type SetCartAddress = (args: Simplify<SetCartAddressArgs>) => Promise<SfCart>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get available shipping methods based on customer's shipping address
|
|
48
|
+
*/
|
|
49
|
+
export type GetAvailableShippingMethods = () => Promise<SfShippingMethods>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Choose a one shipping method from available shipping methods
|
|
53
|
+
*/
|
|
54
|
+
export type SetShippingMethod = (args: Simplify<SetShippingMethodArgs>) => Promise<SfCart>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { SfCreateAddressBody, SfCustomerAddress, SfId } from "../models";
|
|
3
|
+
|
|
4
|
+
export interface CreateCustomerAddressExtendedArgs {}
|
|
5
|
+
export interface CreateCustomerAddressCustomArgs {}
|
|
6
|
+
|
|
7
|
+
export type CreateCustomerAddressArgs = {
|
|
8
|
+
address: SfCreateAddressBody;
|
|
9
|
+
//$extended?: CreateCustomerAddressExtendedArgs;
|
|
10
|
+
//$custom?: CreateCustomerAddressCustomArgs;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type CreateCustomerAddress = (args: Simplify<CreateCustomerAddressArgs>) => Promise<{
|
|
14
|
+
address: SfCustomerAddress;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
export interface UpdateCustomerAddressExtendedArgs {}
|
|
18
|
+
export interface UpdateCustomerAddressCustomArgs {}
|
|
19
|
+
|
|
20
|
+
export type UpdateCustomerAddressArgs = {
|
|
21
|
+
id: SfId;
|
|
22
|
+
address: SfCreateAddressBody;
|
|
23
|
+
//$extended?: UpdateCustomerAddressExtendedArgs;
|
|
24
|
+
//$custom?: UpdateCustomerAddressCustomArgs;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type UpdateCustomerAddress = (args: Simplify<UpdateCustomerAddressArgs>) => Promise<{
|
|
28
|
+
address: SfCustomerAddress;
|
|
29
|
+
}>;
|
|
30
|
+
|
|
31
|
+
export interface DeleteCustomerAddressExtendedArgs {}
|
|
32
|
+
export interface DeleteCustomerAddressCustomArgs {}
|
|
33
|
+
|
|
34
|
+
export type DeleteCustomerAddressArgs = {
|
|
35
|
+
id: SfId;
|
|
36
|
+
//$extended?: DeleteCustomerAddressExtendedArgs;
|
|
37
|
+
//$custom?: DeleteCustomerAddressCustomArgs;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type DeleteCustomerAddress = (args: Simplify<DeleteCustomerAddressArgs>) => Promise<void>;
|
|
41
|
+
|
|
42
|
+
export interface GetCustomerAddressesExtendedArgs {}
|
|
43
|
+
export interface GetCustomerAddressesCustomArgs {}
|
|
44
|
+
|
|
45
|
+
export type GetCustomerAddressesArgs = {
|
|
46
|
+
//$extended?: GetCustomerAddressesExtendedArgs;
|
|
47
|
+
//$custom?: GetCustomerAddressesCustomArgs;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type GetCustomerAddresses = (args?: Simplify<GetCustomerAddressesArgs>) => Promise<{
|
|
51
|
+
addresses: SfCustomerAddress[];
|
|
52
|
+
}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GetCustomer,
|
|
3
|
+
LoginCustomer,
|
|
4
|
+
LogoutCustomer,
|
|
5
|
+
RegisterCustomer,
|
|
6
|
+
UpdateCustomer,
|
|
7
|
+
ChangeCustomerPassword,
|
|
8
|
+
} from "./auth";
|
|
9
|
+
import type {
|
|
10
|
+
GetCart,
|
|
11
|
+
AddCartLineItem,
|
|
12
|
+
UpdateCartLineItem,
|
|
13
|
+
RemoveCartLineItem,
|
|
14
|
+
ApplyCouponToCart,
|
|
15
|
+
RemoveCouponFromCart,
|
|
16
|
+
} from "./cart";
|
|
17
|
+
import type { GetCategories, GetCategory } from "./category";
|
|
18
|
+
import type {
|
|
19
|
+
GetAvailableShippingMethods,
|
|
20
|
+
SetCartAddress,
|
|
21
|
+
SetCustomerEmail,
|
|
22
|
+
SetShippingMethod,
|
|
23
|
+
} from "./checkout";
|
|
24
|
+
import type {
|
|
25
|
+
CreateCustomerAddress,
|
|
26
|
+
DeleteCustomerAddress,
|
|
27
|
+
UpdateCustomerAddress,
|
|
28
|
+
GetCustomerAddresses,
|
|
29
|
+
} from "./customer";
|
|
30
|
+
import type { GetOrders, GetOrderDetails, PlaceOrder } from "./order";
|
|
31
|
+
import type { GetProducts, GetProductDetails, GetProductReviews, SearchProducts } from "./product";
|
|
32
|
+
import type { GetCurrencies } from "./settings";
|
|
33
|
+
|
|
34
|
+
export * from "./auth";
|
|
35
|
+
export * from "./cart";
|
|
36
|
+
export * from "./category";
|
|
37
|
+
export * from "./checkout";
|
|
38
|
+
export * from "./customer";
|
|
39
|
+
export * from "./helpers";
|
|
40
|
+
export * from "./product";
|
|
41
|
+
export * from "./settings";
|
|
42
|
+
export * from "./order";
|
|
43
|
+
|
|
44
|
+
export type UnifiedMethods = {
|
|
45
|
+
getCart: GetCart;
|
|
46
|
+
addCartLineItem: AddCartLineItem;
|
|
47
|
+
updateCartLineItem: UpdateCartLineItem;
|
|
48
|
+
removeCartLineItem: RemoveCartLineItem;
|
|
49
|
+
applyCouponToCart: ApplyCouponToCart;
|
|
50
|
+
removeCouponFromCart: RemoveCouponFromCart;
|
|
51
|
+
getCategories: GetCategories;
|
|
52
|
+
getCategory: GetCategory;
|
|
53
|
+
getCustomer: GetCustomer;
|
|
54
|
+
loginCustomer: LoginCustomer;
|
|
55
|
+
logoutCustomer: LogoutCustomer;
|
|
56
|
+
registerCustomer: RegisterCustomer;
|
|
57
|
+
updateCustomer: UpdateCustomer;
|
|
58
|
+
changeCustomerPassword: ChangeCustomerPassword;
|
|
59
|
+
getProducts: GetProducts;
|
|
60
|
+
getProductDetails: GetProductDetails;
|
|
61
|
+
getProductReviews: GetProductReviews;
|
|
62
|
+
searchProducts: SearchProducts;
|
|
63
|
+
getAvailableShippingMethods: GetAvailableShippingMethods;
|
|
64
|
+
setCartAddress: SetCartAddress;
|
|
65
|
+
setCustomerEmail: SetCustomerEmail;
|
|
66
|
+
setShippingMethod: SetShippingMethod;
|
|
67
|
+
createCustomerAddress: CreateCustomerAddress;
|
|
68
|
+
deleteCustomerAddress: DeleteCustomerAddress;
|
|
69
|
+
updateCustomerAddress: UpdateCustomerAddress;
|
|
70
|
+
getCustomerAddresses: GetCustomerAddresses;
|
|
71
|
+
getCurrencies: GetCurrencies;
|
|
72
|
+
getOrders: GetOrders;
|
|
73
|
+
getOrderDetails: GetOrderDetails;
|
|
74
|
+
placeOrder: PlaceOrder;
|
|
75
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type { SfPagination } from "../models";
|
|
3
|
+
import type { SfOrder, SfOrderListItem } from "../models/order";
|
|
4
|
+
|
|
5
|
+
export interface GetOrdersExtendedArgs {}
|
|
6
|
+
export interface GetOrdersCustomArgs {}
|
|
7
|
+
|
|
8
|
+
export type GetOrdersArgs = {
|
|
9
|
+
pageSize?: number;
|
|
10
|
+
currentPage?: number;
|
|
11
|
+
//$extended?: GetOrdersExtendedArgs;
|
|
12
|
+
//$custom?: GetOrdersCustomArgs;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type GetOrders = (args?: Simplify<GetOrdersArgs>) => Promise<{
|
|
16
|
+
orders: SfOrderListItem[];
|
|
17
|
+
pagination: SfPagination;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export interface GetOrderExtendedArgs {}
|
|
21
|
+
export interface GetOrderCustomArgs {}
|
|
22
|
+
|
|
23
|
+
export type GetOrderArgs = {
|
|
24
|
+
id: string;
|
|
25
|
+
//$extended?: GetOrderExtendedArgs;
|
|
26
|
+
//$custom?: GetOrderCustomArgs;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type GetOrderDetails = (args: Simplify<GetOrderArgs>) => Promise<SfOrder>;
|
|
30
|
+
|
|
31
|
+
export interface PlaceOrderExtendedArgs {}
|
|
32
|
+
export interface PlaceOrderCustomArgs {}
|
|
33
|
+
|
|
34
|
+
export type PlaceOrderArgs = {
|
|
35
|
+
//$extended?: PlaceOrderExtendedArgs;
|
|
36
|
+
//$custom?: PlaceOrderCustomArgs;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type PlaceOrder = (args?: Simplify<PlaceOrderArgs>) => Promise<SfOrder>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Simplify } from '../defs/typeHelpers';
|
|
2
|
+
import type {
|
|
3
|
+
SfCategory,
|
|
4
|
+
SfFacet,
|
|
5
|
+
SfId,
|
|
6
|
+
SfPagination,
|
|
7
|
+
SfProduct,
|
|
8
|
+
SfProductCatalogItem,
|
|
9
|
+
SfProductReview,
|
|
10
|
+
} from "../models";
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
13
|
+
export interface SfSortBy {}
|
|
14
|
+
|
|
15
|
+
export interface SearchProductsExtendedArgs {}
|
|
16
|
+
export interface SearchProductsCustomArgs {}
|
|
17
|
+
|
|
18
|
+
export type SearchProductsArgs = {
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
currentPage?: number;
|
|
21
|
+
sortBy?: "relevant" | "price-low-to-high" | "price-high-to-low" | (string & {});
|
|
22
|
+
search?: string;
|
|
23
|
+
category?: SfCategory["id"];
|
|
24
|
+
facets?: {
|
|
25
|
+
[name: string]: string[];
|
|
26
|
+
};
|
|
27
|
+
//$extended?: SearchProductsExtendedArgs;
|
|
28
|
+
//$custom?: SearchProductsCustomArgs;
|
|
29
|
+
} & SfSortBy;
|
|
30
|
+
|
|
31
|
+
export type SearchProducts = (args: Simplify<SearchProductsArgs>) => Promise<{
|
|
32
|
+
products: SfProductCatalogItem[];
|
|
33
|
+
pagination: SfPagination;
|
|
34
|
+
facets: SfFacet[];
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export interface GetProductsExtendedArgs {}
|
|
38
|
+
export interface GetProductsCustomArgs {}
|
|
39
|
+
|
|
40
|
+
export type GetProductsArgs = {
|
|
41
|
+
ids?: string[];
|
|
42
|
+
skus?: string[];
|
|
43
|
+
//$extended?: GetProductsExtendedArgs;
|
|
44
|
+
//$custom?: GetProductsCustomArgs;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type GetProducts = (args: Simplify<GetProductsArgs>) => Promise<{
|
|
48
|
+
products: SfProductCatalogItem[];
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
export interface GetProductDetailsExtendedArgs {}
|
|
52
|
+
export interface GetProductDetailsCustomArgs {}
|
|
53
|
+
|
|
54
|
+
export type GetProductDetailsArgs = {
|
|
55
|
+
id: SfId;
|
|
56
|
+
sku?: string;
|
|
57
|
+
//$extended?: GetProductDetailsExtendedArgs;
|
|
58
|
+
//$custom?: GetProductDetailsCustomArgs;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type GetProductDetails = (args: Simplify<GetProductDetailsArgs>) => Promise<{
|
|
62
|
+
product: SfProduct;
|
|
63
|
+
categoryHierarchy: SfCategory[];
|
|
64
|
+
}>;
|
|
65
|
+
|
|
66
|
+
export interface GetProductReviewsExtendedArgs {}
|
|
67
|
+
export interface GetProductReviewsCustomArgs {}
|
|
68
|
+
|
|
69
|
+
export type GetProductReviewsArgs = {
|
|
70
|
+
productId: SfId;
|
|
71
|
+
pageSize?: number;
|
|
72
|
+
currentPage?: number;
|
|
73
|
+
//$extended?: GetProductReviewsExtendedArgs;
|
|
74
|
+
//$custom?: GetProductReviewsCustomArgs;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type GetProductReviews = (args: Simplify<GetProductReviewsArgs>) => Promise<{
|
|
78
|
+
reviews: SfProductReview[];
|
|
79
|
+
pagination: SfPagination;
|
|
80
|
+
}>;
|
|
81
|
+
|
|
82
|
+
export interface AddProductReviewExtendedArgs {}
|
|
83
|
+
export interface AddProductReviewCustomArgs {}
|
|
84
|
+
|
|
85
|
+
export type AddProductReviewArgs = {
|
|
86
|
+
productId: SfId;
|
|
87
|
+
productSku?: string;
|
|
88
|
+
review: Pick<SfProductReview, "title" | "text" | "rating" | "reviewer">;
|
|
89
|
+
//$extended?: AddProductReviewExtendedArgs;
|
|
90
|
+
//$custom?: AddProductReviewCustomArgs;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type AddProductReview = (args: Simplify<AddProductReviewArgs>) => Promise<{
|
|
94
|
+
review: SfProductReview;
|
|
95
|
+
}>;
|