@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,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScandiPWA - Progressive Web App for Magento
|
|
3
|
+
*
|
|
4
|
+
* Copyright © Scandiweb, Inc. All rights reserved.
|
|
5
|
+
* See LICENSE for license details.
|
|
6
|
+
*
|
|
7
|
+
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
|
|
8
|
+
* @package scandipwa/scandipwa
|
|
9
|
+
* @link https://github.com/scandipwa/scandipwa
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { GQLCurrencyEnum, GQLProductStockItem } from '../types/Graphql.type';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
AttributeWithValue,
|
|
16
|
+
ConfigurableCartProductFragment,
|
|
17
|
+
ConfigurableProductOptions,
|
|
18
|
+
ConfigurableVariant,
|
|
19
|
+
OptimizedProductImage,
|
|
20
|
+
ProductLink,
|
|
21
|
+
ProductStockItem,
|
|
22
|
+
} from './ProductList.type';
|
|
23
|
+
|
|
24
|
+
import { Cart as DomainCart, CartItem as DomainCartItem, Product as DomainProduct } from '../types/domain';
|
|
25
|
+
|
|
26
|
+
export interface UserErrors {
|
|
27
|
+
message: string;
|
|
28
|
+
code: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Money {
|
|
32
|
+
currency: GQLCurrencyEnum;
|
|
33
|
+
value: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface Discount {
|
|
37
|
+
label: string;
|
|
38
|
+
amount: Money;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface AppliedTax {
|
|
42
|
+
label: string;
|
|
43
|
+
percent: number;
|
|
44
|
+
amount: Money;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface CartPrices {
|
|
48
|
+
applied_rule_ids: string;
|
|
49
|
+
coupon_code: string;
|
|
50
|
+
quote_currency_code: string;
|
|
51
|
+
grand_total: Money;
|
|
52
|
+
subtotal_including_tax: Money;
|
|
53
|
+
subtotal_excluding_tax: Money;
|
|
54
|
+
subtotal_with_discount_excluding_tax: Money;
|
|
55
|
+
discount: Discount;
|
|
56
|
+
applied_taxes: AppliedTax[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface AvailableShippingMethod {
|
|
60
|
+
available: boolean;
|
|
61
|
+
method_code: string;
|
|
62
|
+
carrier_code: string;
|
|
63
|
+
carrier_title: string;
|
|
64
|
+
error_message: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface CartAddress {
|
|
68
|
+
city: string;
|
|
69
|
+
country: { code : string };
|
|
70
|
+
firstname: string;
|
|
71
|
+
lastname: string;
|
|
72
|
+
postcode: string;
|
|
73
|
+
region: Region;
|
|
74
|
+
telephone: string;
|
|
75
|
+
vat_id: string;
|
|
76
|
+
email: string;
|
|
77
|
+
street: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface SelectedShippingMethod {
|
|
81
|
+
amount_incl_tax: number;
|
|
82
|
+
carrier_code: string;
|
|
83
|
+
carrier_title: string;
|
|
84
|
+
method_code: string;
|
|
85
|
+
method_title: string;
|
|
86
|
+
tax_amount: number;
|
|
87
|
+
amount: Money;
|
|
88
|
+
address: CartAddress;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface Region {
|
|
92
|
+
label: string;
|
|
93
|
+
region_id: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface CartShippingAddress {
|
|
97
|
+
available_shipping_methods: AvailableShippingMethod[];
|
|
98
|
+
selected_shipping_method: SelectedShippingMethod;
|
|
99
|
+
customer_notes: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface MinimumOrderAmount {
|
|
103
|
+
minimum_order_amount_reached: boolean;
|
|
104
|
+
minimum_order_description: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface CartItem {
|
|
108
|
+
id: number;
|
|
109
|
+
uid: string;
|
|
110
|
+
sku: string;
|
|
111
|
+
quantity: number;
|
|
112
|
+
product: CartItemProduct;
|
|
113
|
+
prices: CartItemPrices;
|
|
114
|
+
DownloadableCartItem: CartDownloadableItem;
|
|
115
|
+
BundleCartItem: CartBundleItem;
|
|
116
|
+
ConfigurableCartItem: CartConfigurableItem;
|
|
117
|
+
VirtualCartItem: CartVirtualItem;
|
|
118
|
+
SimpleCartItem: CartSimpleItem;
|
|
119
|
+
links: CartDownloadableProductLink[];
|
|
120
|
+
samples: CartDownloadableProductSample[];
|
|
121
|
+
downloadable_customizable_options: CartCustomizableOption[];
|
|
122
|
+
bundle_options: CartBundleOption[];
|
|
123
|
+
bundle_customizable_options: CartCustomizableOption[];
|
|
124
|
+
configurable_options: CartConfigurableOption[];
|
|
125
|
+
configurable_customizable_options: CartCustomizableOption[];
|
|
126
|
+
virtual_customizable_options: CartCustomizableOption[];
|
|
127
|
+
simple_customizable_options: CartCustomizableOption[];
|
|
128
|
+
customizable_options: CartCustomizableOption[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface CartItemProduct {
|
|
132
|
+
uid: string;
|
|
133
|
+
id: number;
|
|
134
|
+
sku: string;
|
|
135
|
+
name: string;
|
|
136
|
+
type_id: string;
|
|
137
|
+
stock_status: GQLProductStockItem;
|
|
138
|
+
url: string;
|
|
139
|
+
salable_qty: number;
|
|
140
|
+
stock_item: ProductStockItem;
|
|
141
|
+
thumbnail: OptimizedProductImage;
|
|
142
|
+
ConfigurableProduct: ConfigurableCartProductFragment;
|
|
143
|
+
attributes: AttributeWithValue;
|
|
144
|
+
product_links: ProductLink;
|
|
145
|
+
configurable_options: ConfigurableProductOptions[];
|
|
146
|
+
variants: ConfigurableVariant[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface CartItemPrices {
|
|
150
|
+
price: Money;
|
|
151
|
+
row_total: Money;
|
|
152
|
+
row_total_including_tax: Money;
|
|
153
|
+
discounts: Money;
|
|
154
|
+
total_item_discount: Money;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface CartDownloadableProductLink {
|
|
158
|
+
id: number;
|
|
159
|
+
title: string;
|
|
160
|
+
sort_order: number;
|
|
161
|
+
price: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface CartDownloadableProductSample {
|
|
165
|
+
id: number;
|
|
166
|
+
title: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface CartCustomizableOptionValue {
|
|
170
|
+
id: number;
|
|
171
|
+
label: string;
|
|
172
|
+
value: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export interface CartCustomizableOption {
|
|
176
|
+
id: number;
|
|
177
|
+
label: string;
|
|
178
|
+
type: string;
|
|
179
|
+
sort_order: number;
|
|
180
|
+
is_required: boolean;
|
|
181
|
+
values: CartCustomizableOptionValue[];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface CartDownloadableItem {
|
|
185
|
+
links: CartDownloadableProductLink[];
|
|
186
|
+
samples: CartDownloadableProductSample[];
|
|
187
|
+
downloadable_customizable_options: CartCustomizableOption[];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface CartBundleOptionValue {
|
|
191
|
+
id: number;
|
|
192
|
+
label: string;
|
|
193
|
+
quantity: number;
|
|
194
|
+
price: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface CartBundleOption {
|
|
198
|
+
id: number;
|
|
199
|
+
label: string;
|
|
200
|
+
type: string;
|
|
201
|
+
values: CartBundleOptionValue[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface CartBundleItem {
|
|
205
|
+
bundle_options: CartBundleOption[];
|
|
206
|
+
bundle_customizable_options: CartCustomizableOption[];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export interface CartConfigurableOption {
|
|
210
|
+
id: number;
|
|
211
|
+
option_label: string;
|
|
212
|
+
value_label: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface CartConfigurableItem {
|
|
216
|
+
configurable_options: CartConfigurableOption[];
|
|
217
|
+
configurable_customizable_options: CartCustomizableOption[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface CartVirtualItem {
|
|
221
|
+
virtual_customizable_options: CartCustomizableOption;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface CartSimpleItem {
|
|
225
|
+
simple_customizable_options: CartCustomizableOption;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface CartTotals {
|
|
229
|
+
id: string;
|
|
230
|
+
email: string;
|
|
231
|
+
prices: Partial<CartPrices>;
|
|
232
|
+
shipping_addresses: CartShippingAddress[];
|
|
233
|
+
minimum_order_amount: MinimumOrderAmount;
|
|
234
|
+
items: CartItem[];
|
|
235
|
+
total_quantity: number;
|
|
236
|
+
is_virtual: boolean;
|
|
237
|
+
is_in_store_pickup_available: boolean;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface CartDisplayConfig {
|
|
241
|
+
display_tax_in_price: string;
|
|
242
|
+
display_tax_in_subtotal: string;
|
|
243
|
+
display_tax_in_shipping_amount: string;
|
|
244
|
+
include_tax_in_order_total: boolean;
|
|
245
|
+
display_full_tax_summary: boolean;
|
|
246
|
+
display_zero_tax_subtotal: boolean;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Lightweight normalizer: convert raw cart shapes into the canonical domain `Cart`.
|
|
251
|
+
* Adapters should provide more complete mappers; this helper is a convenience for
|
|
252
|
+
* migration and testing.
|
|
253
|
+
*/
|
|
254
|
+
export function normalizeCart(raw: any): DomainCart {
|
|
255
|
+
const id = raw?.id ?? raw?.cart_id ?? raw?.uid ?? '';
|
|
256
|
+
const email = raw?.email ?? raw?.customer?.email;
|
|
257
|
+
const items: DomainCartItem[] = Array.isArray(raw?.items)
|
|
258
|
+
? raw.items.map((it: any) => ({
|
|
259
|
+
id: String(it?.id ?? it?.uid ?? ''),
|
|
260
|
+
sku: it?.sku ?? it?.product?.sku,
|
|
261
|
+
quantity: it?.quantity ?? it?.qty ?? 0,
|
|
262
|
+
product: it?.product ? {
|
|
263
|
+
id: String(it.product.id ?? it.product.sku ?? it.product.uid ?? ''),
|
|
264
|
+
title: it.product.name ?? it.product.title ?? it.product.product_name,
|
|
265
|
+
price: (it.product.price && (it.product.price.final_price?.value ?? it.product.price)) ?? it.price ?? 0,
|
|
266
|
+
images: Array.isArray(it.product.media_gallery_entries)
|
|
267
|
+
? it.product.media_gallery_entries.map((m: any) => ({ url: m.file ?? m.url }))
|
|
268
|
+
: []
|
|
269
|
+
} as DomainProduct : undefined,
|
|
270
|
+
raw: it,
|
|
271
|
+
})) : [];
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
id: String(id),
|
|
275
|
+
email,
|
|
276
|
+
items,
|
|
277
|
+
total_quantity: raw?.total_quantity ?? raw?.items?.length ?? items.length,
|
|
278
|
+
prices: raw?.prices ?? raw?.totals ?? undefined,
|
|
279
|
+
raw,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface AppliedTaxItem {
|
|
284
|
+
rates: AppliedTax[];
|
|
285
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScandiPWA - Progressive Web App for Magento
|
|
3
|
+
*
|
|
4
|
+
* Copyright © Scandiweb, Inc. All rights reserved.
|
|
5
|
+
* See LICENSE for license details.
|
|
6
|
+
*
|
|
7
|
+
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
|
|
8
|
+
* @package scandipwa/scandipwa-theme
|
|
9
|
+
* @link https://github.com/scandipwa/scandipwa-theme
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Argument, Field, Query } from '@tilework/opus';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
Breadcrumb,
|
|
16
|
+
Category,
|
|
17
|
+
CategoryQueryOptions,
|
|
18
|
+
CategoryTree,
|
|
19
|
+
CmsBlock,
|
|
20
|
+
} from './Category.type';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Category Query
|
|
24
|
+
* @class CategoryQuery
|
|
25
|
+
* @namespace ../../normalizers/Category/Query
|
|
26
|
+
*/
|
|
27
|
+
export class CategoryQuery {
|
|
28
|
+
options: Partial<CategoryQueryOptions> = {};
|
|
29
|
+
|
|
30
|
+
getQuery(options: Partial<CategoryQueryOptions> = {}): Query<'category', Category> {
|
|
31
|
+
this.options = options;
|
|
32
|
+
const {
|
|
33
|
+
name,
|
|
34
|
+
type,
|
|
35
|
+
value,
|
|
36
|
+
} = this._getConditionalArguments();
|
|
37
|
+
|
|
38
|
+
return new Query<'category', Category>('category')
|
|
39
|
+
.addArgument(name, type, value)
|
|
40
|
+
.addFieldList(this._getDefaultFields())
|
|
41
|
+
.addField(this._getChildrenFields());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_getConditionalArguments(): Argument {
|
|
45
|
+
const { categoryIds } = this.options;
|
|
46
|
+
|
|
47
|
+
if (categoryIds) {
|
|
48
|
+
return {
|
|
49
|
+
name: 'id',
|
|
50
|
+
type: 'Int!',
|
|
51
|
+
value: String(categoryIds),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
throw new Error(__('There was an error requesting the category'));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_getChildrenFields(): Field<'children', CategoryTree, true> {
|
|
59
|
+
return new Field<'children', CategoryTree, true>('children')
|
|
60
|
+
.addFieldList(this._getDefaultFields());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_getBreadcrumbsField(): Field<'breadcrumbs', Breadcrumb, true> {
|
|
64
|
+
return new Field<'breadcrumbs', Breadcrumb, true>('breadcrumbs', true)
|
|
65
|
+
.addFieldList(this._getBreadcrumbFields());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_getBreadcrumbFields(): Array<
|
|
69
|
+
Field<'category_name', string>
|
|
70
|
+
| Field<'category_level', number>
|
|
71
|
+
| Field<'category_url', string>
|
|
72
|
+
| Field<'category_is_active', boolean>
|
|
73
|
+
> {
|
|
74
|
+
return [
|
|
75
|
+
new Field<'category_name', string>('category_name'),
|
|
76
|
+
new Field<'category_level', number>('category_level'),
|
|
77
|
+
new Field<'category_url', string>('category_url'),
|
|
78
|
+
new Field<'category_is_active', boolean>('category_is_active'),
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_getCmsBlockFields(): Array<
|
|
83
|
+
Field<'content', string>
|
|
84
|
+
| Field<'disabled', boolean>
|
|
85
|
+
| Field<'title', string>
|
|
86
|
+
| Field<'identifier', string>
|
|
87
|
+
> {
|
|
88
|
+
return [
|
|
89
|
+
new Field<'content', string>('content'),
|
|
90
|
+
new Field<'disabled', boolean>('disabled'),
|
|
91
|
+
new Field<'title', string>('title'),
|
|
92
|
+
new Field<'identifier', string>('identifier'),
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_getCmsBlockField(): Field<'cms_block', CmsBlock> {
|
|
97
|
+
return new Field<'cms_block', CmsBlock>('cms_block')
|
|
98
|
+
.addFieldList(this._getCmsBlockFields());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_getDefaultFields(): Array<
|
|
102
|
+
Field<'id', number>
|
|
103
|
+
| Field<'url', string>
|
|
104
|
+
| Field<'name', string>
|
|
105
|
+
| Field<'image', string>
|
|
106
|
+
| Field<'url_key', string>
|
|
107
|
+
| Field<'url_path', string>
|
|
108
|
+
| Field<'is_active', boolean>
|
|
109
|
+
| Field<'meta_title', string>
|
|
110
|
+
| Field<'description', string>
|
|
111
|
+
| Field<'canonical_url', string>
|
|
112
|
+
| Field<'product_count', number>
|
|
113
|
+
| Field<'meta_keywords', string>
|
|
114
|
+
| Field<'default_sort_by', string>
|
|
115
|
+
| Field<'meta_description', string>
|
|
116
|
+
| Field<'landing_page', number>
|
|
117
|
+
| Field<'display_mode', string>
|
|
118
|
+
| Field<'is_anchor', boolean>
|
|
119
|
+
| Field<'cms_block', CmsBlock>
|
|
120
|
+
| Field<'breadcrumbs', Breadcrumb, true>
|
|
121
|
+
> {
|
|
122
|
+
return [
|
|
123
|
+
new Field<'id', number>('id'),
|
|
124
|
+
new Field<'url', string>('url'),
|
|
125
|
+
new Field<'name', string>('name'),
|
|
126
|
+
new Field<'image', string>('image'),
|
|
127
|
+
new Field<'url_key', string>('url_key'),
|
|
128
|
+
new Field<'url_path', string>('url_path'),
|
|
129
|
+
new Field<'is_active', boolean>('is_active'),
|
|
130
|
+
new Field<'meta_title', string>('meta_title'),
|
|
131
|
+
new Field<'description', string>('description'),
|
|
132
|
+
new Field<'canonical_url', string>('canonical_url'),
|
|
133
|
+
new Field<'product_count', number>('product_count'),
|
|
134
|
+
new Field<'meta_keywords', string>('meta_keywords'),
|
|
135
|
+
new Field<'default_sort_by', string>('default_sort_by'),
|
|
136
|
+
new Field<'meta_description', string>('meta_description'),
|
|
137
|
+
new Field<'landing_page', number>('landing_page'),
|
|
138
|
+
new Field<'display_mode', string>('display_mode'),
|
|
139
|
+
new Field<'is_anchor', boolean>('is_anchor'),
|
|
140
|
+
this._getCmsBlockField(),
|
|
141
|
+
this._getBreadcrumbsField(),
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default new CategoryQuery();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScandiPWA - Progressive Web App for Magento
|
|
3
|
+
*
|
|
4
|
+
* Copyright © Scandiweb, Inc. All rights reserved.
|
|
5
|
+
* See LICENSE for license details.
|
|
6
|
+
*
|
|
7
|
+
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
|
|
8
|
+
* @package scandipwa/scandipwa-theme
|
|
9
|
+
* @link https://github.com/scandipwa/scandipwa
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface CmsBlock {
|
|
13
|
+
content: string;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
title: string;
|
|
16
|
+
identifier: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Breadcrumb {
|
|
20
|
+
category_name: string;
|
|
21
|
+
category_level: number;
|
|
22
|
+
category_url: string;
|
|
23
|
+
category_is_active: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CategoryTree {
|
|
27
|
+
id: number | string;
|
|
28
|
+
url: string;
|
|
29
|
+
name: string;
|
|
30
|
+
image: string;
|
|
31
|
+
url_key: string;
|
|
32
|
+
url_path: string;
|
|
33
|
+
is_active: boolean;
|
|
34
|
+
meta_title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
canonical_url: string;
|
|
37
|
+
product_count: number;
|
|
38
|
+
meta_keywords: string;
|
|
39
|
+
default_sort_by: string;
|
|
40
|
+
meta_description: string;
|
|
41
|
+
landing_page: number;
|
|
42
|
+
display_mode: string;
|
|
43
|
+
is_anchor: boolean;
|
|
44
|
+
cms_block: CmsBlock;
|
|
45
|
+
breadcrumbs: Breadcrumb[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface Category extends CategoryTree {
|
|
49
|
+
children: CategoryTree[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface CategoryQueryOptions {
|
|
53
|
+
categoryIds: number;
|
|
54
|
+
isSearchPage?: boolean;
|
|
55
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScandiPWA - Progressive Web App for Magento
|
|
3
|
+
*
|
|
4
|
+
* Copyright © Scandiweb, Inc. All rights reserved.
|
|
5
|
+
* See LICENSE for license details.
|
|
6
|
+
*
|
|
7
|
+
* @license OSL-3.0 (Open Software License ("OSL") v. 3.0)
|
|
8
|
+
* @package scandipwa/scandipwa
|
|
9
|
+
* @link https://github.com/scandipwa/scandipwa
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Field, Query } from '@tilework/opus';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Email availability check Query
|
|
16
|
+
* @class CheckEmailQuery
|
|
17
|
+
* @namespace ../../normalizers/CheckEmail/Query */
|
|
18
|
+
export class CheckEmailQuery {
|
|
19
|
+
getIsEmailAvailableQuery(email: string): Query<'isEmailAvailable', { is_email_available: boolean }> {
|
|
20
|
+
const query = new Query<'isEmailAvailable', { is_email_available: boolean }>('isEmailAvailable')
|
|
21
|
+
.addArgument('email', 'String!', email)
|
|
22
|
+
.addField(new Field<'is_email_available', boolean>('is_email_available'));
|
|
23
|
+
|
|
24
|
+
return query;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default new CheckEmailQuery();
|