@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,726 @@
|
|
|
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
|
+
import { Field, InlineFragment } from '@tilework/opus';
|
|
13
|
+
|
|
14
|
+
import { ProductType } from 'Component/Product/Product.config';
|
|
15
|
+
import { SortDirections } from '../routes/CategoryPage/CategoryPage.config';
|
|
16
|
+
import { CategorySortOptions } from '../routes/CategoryPage/CategoryPage.type';
|
|
17
|
+
import {
|
|
18
|
+
GQLCurrencyEnum,
|
|
19
|
+
GQLPriceTypeEnum,
|
|
20
|
+
GQLProductStockStatus,
|
|
21
|
+
GQLShipBundleItemsEnum,
|
|
22
|
+
} from '../types/Graphql.type';
|
|
23
|
+
|
|
24
|
+
import { Product as DomainProduct } from '../types/domain';
|
|
25
|
+
|
|
26
|
+
export interface ProductStockItem {
|
|
27
|
+
in_stock: boolean;
|
|
28
|
+
min_sale_qty: number;
|
|
29
|
+
max_sale_qty: number;
|
|
30
|
+
qty_increments: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface NormalizedProductsQueryOutput {
|
|
34
|
+
items: DomainProduct[];
|
|
35
|
+
sort_fields: SortFields;
|
|
36
|
+
filters: Aggregation[];
|
|
37
|
+
total_count: number;
|
|
38
|
+
page_info: SearchResultPageInfo;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Lightweight normalizer helpers to convert raw product shapes into the
|
|
43
|
+
* canonical `DomainProduct` used throughout the commerce layer. Adapters
|
|
44
|
+
* should implement more thorough mappers; these helpers provide a safe
|
|
45
|
+
* default to accelerate migration.
|
|
46
|
+
*/
|
|
47
|
+
export function normalizeProduct(raw: any): DomainProduct {
|
|
48
|
+
const id = raw?.id ?? raw?.sku ?? (raw?.uid && String(raw.uid)) ?? '';
|
|
49
|
+
const title = raw?.name ?? raw?.title ?? raw?.product_name ?? '';
|
|
50
|
+
const description = raw?.description ?? raw?.short_description ?? '';
|
|
51
|
+
let price: any = 0;
|
|
52
|
+
if (raw?.price?.final_price?.value != null) price = raw.price.final_price.value;
|
|
53
|
+
else if (raw?.price != null) price = raw.price;
|
|
54
|
+
else if (typeof raw === 'number') price = raw;
|
|
55
|
+
|
|
56
|
+
const images: string[] = [];
|
|
57
|
+
if (Array.isArray(raw?.media_gallery_entries)) {
|
|
58
|
+
for (const m of raw.media_gallery_entries) {
|
|
59
|
+
if (m?.file) images.push(m.file);
|
|
60
|
+
else if (m?.url) images.push(m.url);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const imageObjs = images.map((u) => ({ url: u }));
|
|
65
|
+
|
|
66
|
+
// Normalize attributes when available. Adapt to common shapes used by
|
|
67
|
+
// adapters: either an object map or an array of attribute entries.
|
|
68
|
+
let attributes: Record<string, any> | undefined = undefined;
|
|
69
|
+
if (raw?.attributes && !Array.isArray(raw.attributes) && typeof raw.attributes === 'object') {
|
|
70
|
+
attributes = raw.attributes as Record<string, any>;
|
|
71
|
+
} else if (Array.isArray(raw?.attributes)) {
|
|
72
|
+
attributes = {};
|
|
73
|
+
for (const a of raw.attributes) {
|
|
74
|
+
const code = a?.attribute_code ?? a?.attributeCode ?? a?.code ?? a?.name;
|
|
75
|
+
if (!code) continue;
|
|
76
|
+
// Prefer explicit value fields, fall back to label or option lists
|
|
77
|
+
const value = a?.attribute_value ?? a?.value ?? a?.value_string ?? a?.attribute_label ?? a?.label ?? (a?.attribute_options ? a.attribute_options.map((o: any) => o.label) : undefined);
|
|
78
|
+
attributes[code] = value;
|
|
79
|
+
}
|
|
80
|
+
} else if (raw?.s_attributes && Array.isArray(raw.s_attributes)) {
|
|
81
|
+
attributes = {};
|
|
82
|
+
for (const a of raw.s_attributes) {
|
|
83
|
+
const code = a?.attribute_code ?? a?.code;
|
|
84
|
+
if (!code) continue;
|
|
85
|
+
attributes[code] = a?.attribute_value ?? a?.value ?? undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
id: String(id),
|
|
91
|
+
title,
|
|
92
|
+
description,
|
|
93
|
+
price,
|
|
94
|
+
images: imageObjs,
|
|
95
|
+
attributes,
|
|
96
|
+
raw,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function normalizeProductsQueryOutput(raw: any): NormalizedProductsQueryOutput {
|
|
101
|
+
const items = Array.isArray(raw?.items) ? raw.items.map(normalizeProduct) : [];
|
|
102
|
+
return {
|
|
103
|
+
items,
|
|
104
|
+
sort_fields: raw?.sort_fields ?? { options: [] },
|
|
105
|
+
filters: raw?.filters ?? [],
|
|
106
|
+
total_count: raw?.total_count ?? (items.length || 0),
|
|
107
|
+
page_info: raw?.page_info ?? { current_page: 1, total_pages: 1 },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface OptimizedProductImage {
|
|
112
|
+
path: string;
|
|
113
|
+
url: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface SwatchData {
|
|
117
|
+
type: string;
|
|
118
|
+
value: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface AttributeWithValueOption {
|
|
122
|
+
label: string;
|
|
123
|
+
value: string;
|
|
124
|
+
swatch_data: SwatchData;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface AttributeWithValue {
|
|
128
|
+
attribute_id: number;
|
|
129
|
+
attribute_value: string;
|
|
130
|
+
attribute_code: string;
|
|
131
|
+
attribute_label: string;
|
|
132
|
+
attribute_type: string;
|
|
133
|
+
attribute_group_id: string;
|
|
134
|
+
attribute_group_name: string;
|
|
135
|
+
attribute_options: AttributeWithValueOption[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface ConfigurableProductOptionsValues {
|
|
139
|
+
value_index: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface ConfigurableProductOptions {
|
|
143
|
+
attribute_code: string;
|
|
144
|
+
values: ConfigurableProductOptionsValues[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface SimpleProduct {
|
|
148
|
+
id: number;
|
|
149
|
+
sku: string;
|
|
150
|
+
stock_status: GQLProductStockStatus;
|
|
151
|
+
salable_qty: number;
|
|
152
|
+
stock_item: ProductStockItem;
|
|
153
|
+
thumbnail: OptimizedProductImage;
|
|
154
|
+
attributes: AttributeWithValue[];
|
|
155
|
+
product_links: ProductLink[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ConfigurableVariant {
|
|
159
|
+
product: ProductItem;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ConfigurableCartProductFragment {
|
|
163
|
+
configurable_options: ConfigurableProductOptions[];
|
|
164
|
+
variants: ConfigurableVariant[];
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ProductLink {
|
|
169
|
+
position: number;
|
|
170
|
+
link_type: string;
|
|
171
|
+
linked_product_sku: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ProductDiscount {
|
|
175
|
+
amount_off: number;
|
|
176
|
+
percent_off: number;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface Money {
|
|
180
|
+
currency: GQLCurrencyEnum;
|
|
181
|
+
value: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ProductPrice {
|
|
185
|
+
discount: ProductDiscount;
|
|
186
|
+
final_price: Money;
|
|
187
|
+
final_price_excl_tax: Money;
|
|
188
|
+
regular_price: Money;
|
|
189
|
+
regular_price_excl_tax: Money;
|
|
190
|
+
default_price: Money;
|
|
191
|
+
default_final_price: Money;
|
|
192
|
+
default_final_price_excl_tax: Money;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface PriceRange {
|
|
196
|
+
minimum_price: ProductPrice;
|
|
197
|
+
maximum_price: ProductPrice;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface SearchResultPageInfo {
|
|
201
|
+
current_page: number;
|
|
202
|
+
total_pages: number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export interface AggregationOption {
|
|
206
|
+
label: string;
|
|
207
|
+
count: number;
|
|
208
|
+
value_string: string;
|
|
209
|
+
swatch_data: SwatchData;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface Aggregation {
|
|
213
|
+
name: string;
|
|
214
|
+
request_var: string;
|
|
215
|
+
is_boolean: boolean;
|
|
216
|
+
has_swatch: boolean;
|
|
217
|
+
position: number;
|
|
218
|
+
filter_items: AggregationOption[];
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface SortField {
|
|
222
|
+
value: string;
|
|
223
|
+
label: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface SortFields {
|
|
227
|
+
options: SortField[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface TierPrice {
|
|
231
|
+
discount: ProductDiscount;
|
|
232
|
+
final_price: Money;
|
|
233
|
+
quantity: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface CustomizableDateValue {
|
|
237
|
+
price: number;
|
|
238
|
+
priceInclTax: number;
|
|
239
|
+
priceExclTax: number;
|
|
240
|
+
price_type: GQLPriceTypeEnum;
|
|
241
|
+
currency: string;
|
|
242
|
+
sku: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface CustomizableDateOptionFragment {
|
|
246
|
+
value: CustomizableDateValue[];
|
|
247
|
+
product_sku: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface CustomizableFileValue {
|
|
251
|
+
price: number;
|
|
252
|
+
priceInclTax: number;
|
|
253
|
+
priceExclTax: number;
|
|
254
|
+
price_type: GQLPriceTypeEnum;
|
|
255
|
+
currency: string;
|
|
256
|
+
sku: string;
|
|
257
|
+
file_extension: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export interface CustomizableFieldValue {
|
|
261
|
+
price: number;
|
|
262
|
+
priceInclTax: number;
|
|
263
|
+
priceExclTax: number;
|
|
264
|
+
price_type: GQLPriceTypeEnum;
|
|
265
|
+
currency: string;
|
|
266
|
+
sku: string;
|
|
267
|
+
max_characters: number;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface CustomizableAreaOptionFragment {
|
|
271
|
+
areaValues: CustomizableFieldValue[];
|
|
272
|
+
product_sku: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface CustomizableFieldOptionFragment {
|
|
276
|
+
fieldValues: CustomizableFieldValue[];
|
|
277
|
+
product_sku: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export interface CustomizableSelectionValue {
|
|
281
|
+
uid: string;
|
|
282
|
+
option_type_id: number;
|
|
283
|
+
price: number;
|
|
284
|
+
priceInclTax: number;
|
|
285
|
+
priceExclTax: number;
|
|
286
|
+
price_type: GQLPriceTypeEnum;
|
|
287
|
+
currency: string;
|
|
288
|
+
sku: string;
|
|
289
|
+
title: string;
|
|
290
|
+
sort_order: number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type CustomizableProductFragmentOptionsFields = Array<
|
|
294
|
+
InlineFragment<'CustomizableDropDownOption', {
|
|
295
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
296
|
+
}>
|
|
297
|
+
| InlineFragment<'CustomizableRadioOption', {
|
|
298
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
299
|
+
}>
|
|
300
|
+
| InlineFragment<'CustomizableCheckboxOption', {
|
|
301
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
302
|
+
}>
|
|
303
|
+
| InlineFragment<'CustomizableMultipleOption', {
|
|
304
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
305
|
+
}>
|
|
306
|
+
| InlineFragment<'CustomizableFieldOption', CustomizableFieldOptionFragment>
|
|
307
|
+
| InlineFragment<'CustomizableAreaOption', CustomizableAreaOptionFragment>
|
|
308
|
+
| InlineFragment<'CustomizableFileOption', {
|
|
309
|
+
fileValues: CustomizableFileValue[];
|
|
310
|
+
}>
|
|
311
|
+
| InlineFragment<'CustomizableDateOption', CustomizableDateOptionFragment>
|
|
312
|
+
| Field<'title', string>
|
|
313
|
+
| Field<'required', boolean>
|
|
314
|
+
| Field<'sort_order', number>
|
|
315
|
+
| Field<'type', string>
|
|
316
|
+
| Field<'uid', string>
|
|
317
|
+
>;
|
|
318
|
+
|
|
319
|
+
export interface BaseCustomizableProductFragmentOptions {
|
|
320
|
+
CustomizableDropDownOption: {
|
|
321
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
322
|
+
};
|
|
323
|
+
CustomizableRadioOption: {
|
|
324
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
325
|
+
};
|
|
326
|
+
CustomizableCheckboxOption: {
|
|
327
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
328
|
+
};
|
|
329
|
+
CustomizableMultipleOption: {
|
|
330
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
331
|
+
};
|
|
332
|
+
CustomizableFieldOption: CustomizableFieldOptionFragment;
|
|
333
|
+
CustomizableAreaOption: CustomizableAreaOptionFragment;
|
|
334
|
+
CustomizableFileOption: {
|
|
335
|
+
fileValues: CustomizableFileValue[];
|
|
336
|
+
};
|
|
337
|
+
CustomizableDateOption: CustomizableDateOptionFragment;
|
|
338
|
+
title: string;
|
|
339
|
+
required: boolean;
|
|
340
|
+
sort_order: number;
|
|
341
|
+
type: string;
|
|
342
|
+
uid: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export type CustomizableProductFragmentOptions = BaseCustomizableProductFragmentOptions
|
|
346
|
+
& CustomizableFieldOptionFragment & CustomizableAreaOptionFragment & {
|
|
347
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
348
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
349
|
+
fileValues: CustomizableFileValue[];
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
export interface ComplexTextValue {
|
|
353
|
+
html: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export interface ProductBundleOption {
|
|
357
|
+
name: string;
|
|
358
|
+
stock_status: GQLProductStockStatus;
|
|
359
|
+
price_range: PriceRange;
|
|
360
|
+
type_id: any;
|
|
361
|
+
dynamic_price: boolean;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface BundleOption {
|
|
365
|
+
uid: string;
|
|
366
|
+
label: string;
|
|
367
|
+
quantity: number;
|
|
368
|
+
position: number;
|
|
369
|
+
is_default: boolean;
|
|
370
|
+
price: number;
|
|
371
|
+
price_type: GQLPriceTypeEnum;
|
|
372
|
+
can_change_quantity: boolean;
|
|
373
|
+
product: ProductBundleOption;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface BundleItem {
|
|
377
|
+
uid: string;
|
|
378
|
+
option_id: number;
|
|
379
|
+
title: string;
|
|
380
|
+
required: boolean;
|
|
381
|
+
type: string;
|
|
382
|
+
position: number;
|
|
383
|
+
sku: string;
|
|
384
|
+
options: BundleOption[];
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export interface BundleOptionSelection {
|
|
388
|
+
selection_id: number;
|
|
389
|
+
final_option_price: number;
|
|
390
|
+
final_option_price_excl_tax: number;
|
|
391
|
+
regular_option_price: number;
|
|
392
|
+
regular_option_price_excl_tax: number;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export interface BundlePriceOption {
|
|
396
|
+
option_id: number;
|
|
397
|
+
selection_details: BundleOptionSelection[];
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface BundleProductFragment {
|
|
401
|
+
dynamic_price: boolean;
|
|
402
|
+
dynamic_sku: boolean;
|
|
403
|
+
ship_bundle_items: GQLShipBundleItemsEnum;
|
|
404
|
+
dynamic_weight: boolean;
|
|
405
|
+
items: BundleItem[];
|
|
406
|
+
bundle_options: BundlePriceOption[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export interface UrlRewrite {
|
|
410
|
+
url: string;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export interface RatingsBreakdown {
|
|
414
|
+
rating_code: string;
|
|
415
|
+
value: string;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export interface ProductReview {
|
|
419
|
+
average_rating: number;
|
|
420
|
+
nickname: string;
|
|
421
|
+
title: string;
|
|
422
|
+
detail: string;
|
|
423
|
+
created_at: string;
|
|
424
|
+
rating_votes: RatingsBreakdown[];
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export interface ProductReviews {
|
|
428
|
+
items: ProductReview[];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface ProductMediaGalleryEntriesVideoContent {
|
|
432
|
+
media_type: string;
|
|
433
|
+
video_description: string;
|
|
434
|
+
video_metadata: string;
|
|
435
|
+
video_provider: string;
|
|
436
|
+
video_title: string;
|
|
437
|
+
video_url: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface MediaGalleryEntry {
|
|
441
|
+
id: number;
|
|
442
|
+
file: string;
|
|
443
|
+
label: string;
|
|
444
|
+
position: number;
|
|
445
|
+
disabled: boolean;
|
|
446
|
+
media_type: string;
|
|
447
|
+
types: string[];
|
|
448
|
+
video_content: ProductMediaGalleryEntriesVideoContent;
|
|
449
|
+
thumbnail: { url: string };
|
|
450
|
+
base: { url: string };
|
|
451
|
+
large: { url: string };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export interface Breadcrumb {
|
|
455
|
+
category_id: number;
|
|
456
|
+
category_name: string;
|
|
457
|
+
category_level: number;
|
|
458
|
+
category_url: string;
|
|
459
|
+
category_is_active: boolean;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export interface CategoryTreeFragment {
|
|
463
|
+
is_active: boolean;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface CategoryInterface {
|
|
467
|
+
id: string;
|
|
468
|
+
name: string;
|
|
469
|
+
url: string;
|
|
470
|
+
breadcrumbs: Breadcrumb[];
|
|
471
|
+
CategoryTree: CategoryTreeFragment;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export type Category = CategoryInterface & CategoryTreeFragment;
|
|
475
|
+
|
|
476
|
+
export interface DownloadableProductSamples {
|
|
477
|
+
title: string;
|
|
478
|
+
sort_order: number;
|
|
479
|
+
sample_url: string;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
export interface DownloadableProductLinks {
|
|
483
|
+
sample_url: string;
|
|
484
|
+
sort_order: number;
|
|
485
|
+
title: string;
|
|
486
|
+
id: number;
|
|
487
|
+
uid: string;
|
|
488
|
+
price: number;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export interface DownloadableProductFragment {
|
|
492
|
+
links_title: string;
|
|
493
|
+
samples_title: string;
|
|
494
|
+
links_purchased_separately: number;
|
|
495
|
+
downloadable_product_links: DownloadableProductLinks[];
|
|
496
|
+
downloadable_product_samples: DownloadableProductSamples[];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export type ProductItemFields = Array<
|
|
500
|
+
Field<'uid', string>
|
|
501
|
+
| Field<'id', number>
|
|
502
|
+
| Field<'sku', string>
|
|
503
|
+
| Field<'name', string>
|
|
504
|
+
| Field<'type_id', string>
|
|
505
|
+
| Field<'stock_status', GQLProductStockStatus>
|
|
506
|
+
| Field<'salable_qty', number>
|
|
507
|
+
| Field<'stock_item', ProductStockItem>
|
|
508
|
+
| Field<'price_range', PriceRange>
|
|
509
|
+
| Field<'image', OptimizedProductImage>
|
|
510
|
+
| Field<'thumbnail', OptimizedProductImage>
|
|
511
|
+
| Field<'small_image', OptimizedProductImage>
|
|
512
|
+
| Field<'short_description', ComplexTextValue>
|
|
513
|
+
| Field<'special_from_date', string>
|
|
514
|
+
| Field<'special_to_date', string>
|
|
515
|
+
| Field<'price_tiers', TierPrice, true>
|
|
516
|
+
| Field<'attributes', AttributeWithValue, true>
|
|
517
|
+
| Field<'url', string>
|
|
518
|
+
| Field<'url_rewrites', UrlRewrite, true>
|
|
519
|
+
| Field<'review_count', number>
|
|
520
|
+
| Field<'rating_summary', number>
|
|
521
|
+
| InlineFragment<'CustomizableProductInterface', {
|
|
522
|
+
options: CustomizableProductFragmentOptions[];
|
|
523
|
+
}>
|
|
524
|
+
| InlineFragment<'BundleProduct', BundleProductFragment>
|
|
525
|
+
| Field<'product_links', ProductLink, true>
|
|
526
|
+
| Field<'description', ComplexTextValue>
|
|
527
|
+
| Field<'media_gallery_entries', MediaGalleryEntry, true>
|
|
528
|
+
| InlineFragment<'SimpleProduct', {
|
|
529
|
+
price_tiers: TierPrice[];
|
|
530
|
+
}>
|
|
531
|
+
| Field<'canonical_url', string>
|
|
532
|
+
| Field<'meta_title', string>
|
|
533
|
+
| Field<'meta_keyword', string>
|
|
534
|
+
| Field<'meta_description', string>
|
|
535
|
+
| Field<'categories', CategoryInterface, true>
|
|
536
|
+
| Field<'reviews', ProductReviews>
|
|
537
|
+
| InlineFragment<'VirtualProduct', {
|
|
538
|
+
price_tiers: TierPrice[];
|
|
539
|
+
}>
|
|
540
|
+
| InlineFragment<'ConfigurableProduct', ConfigurableProductFragment>
|
|
541
|
+
| InlineFragment<'GroupedProduct', {
|
|
542
|
+
items: GroupedProductItem[];
|
|
543
|
+
}>
|
|
544
|
+
>;
|
|
545
|
+
|
|
546
|
+
export interface BaseProductItem {
|
|
547
|
+
uid: string;
|
|
548
|
+
id: number;
|
|
549
|
+
sku: string;
|
|
550
|
+
name: string;
|
|
551
|
+
type_id: string;
|
|
552
|
+
stock_status: GQLProductStockStatus;
|
|
553
|
+
salable_qty: number;
|
|
554
|
+
stock_item: ProductStockItem;
|
|
555
|
+
price_range: PriceRange;
|
|
556
|
+
image: OptimizedProductImage;
|
|
557
|
+
thumbnail: OptimizedProductImage;
|
|
558
|
+
small_image: OptimizedProductImage;
|
|
559
|
+
short_description: ComplexTextValue;
|
|
560
|
+
special_from_date: string;
|
|
561
|
+
special_to_date: string;
|
|
562
|
+
price_tiers: TierPrice[];
|
|
563
|
+
attributes: AttributeWithValue[];
|
|
564
|
+
url: string;
|
|
565
|
+
url_rewrites: UrlRewrite[];
|
|
566
|
+
review_count: number;
|
|
567
|
+
rating_summary: number;
|
|
568
|
+
product_links: ProductLink[];
|
|
569
|
+
description: ComplexTextValue;
|
|
570
|
+
media_gallery_entries: MediaGalleryEntry[];
|
|
571
|
+
canonical_url: string;
|
|
572
|
+
meta_title: string;
|
|
573
|
+
meta_keyword: string;
|
|
574
|
+
meta_description: string;
|
|
575
|
+
categories: Category[];
|
|
576
|
+
reviews: ProductReviews;
|
|
577
|
+
CustomizableProductInterface: {
|
|
578
|
+
options: CustomizableProductFragmentOptions[];
|
|
579
|
+
};
|
|
580
|
+
BundleProduct: BundleProductFragment;
|
|
581
|
+
SimpleProduct: {
|
|
582
|
+
price_tiers: TierPrice[];
|
|
583
|
+
};
|
|
584
|
+
VirtualProduct: {
|
|
585
|
+
price_tiers: TierPrice[];
|
|
586
|
+
};
|
|
587
|
+
ConfigurableProduct: ConfigurableProductFragment;
|
|
588
|
+
GroupedProduct: {
|
|
589
|
+
items: GroupedProductItem[];
|
|
590
|
+
};
|
|
591
|
+
DownloadableProduct: DownloadableProductFragment;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export type ProductItem = BaseProductItem
|
|
595
|
+
& BundleProductFragment
|
|
596
|
+
& ConfigurableProductFragment
|
|
597
|
+
& DownloadableProductFragment
|
|
598
|
+
& {
|
|
599
|
+
options: CustomizableProductFragmentOptions[];
|
|
600
|
+
price_tiers: TierPrice[];
|
|
601
|
+
items: GroupedProductItem[];
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
export interface ProductsQueryOutput {
|
|
605
|
+
items: ProductItem[];
|
|
606
|
+
sort_fields: SortFields;
|
|
607
|
+
filters: Aggregation[];
|
|
608
|
+
total_count: number;
|
|
609
|
+
page_info: SearchResultPageInfo;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
export interface GroupedProductItem {
|
|
613
|
+
product: ProductItem;
|
|
614
|
+
position: number;
|
|
615
|
+
qty: number;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export interface VariantItem {
|
|
619
|
+
product: ProductItem;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export interface ConfigurableProductFragment {
|
|
623
|
+
configurable_options: ConfigurableProductOptions[];
|
|
624
|
+
variants: VariantItem[];
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export interface ProductListOptions {
|
|
628
|
+
isSingleProduct: boolean;
|
|
629
|
+
isPlp: boolean;
|
|
630
|
+
isForWishlist: boolean;
|
|
631
|
+
isForLinkedProducts: boolean;
|
|
632
|
+
noAttributes: boolean;
|
|
633
|
+
noVariants: boolean;
|
|
634
|
+
noVariantAttributes: boolean;
|
|
635
|
+
requireInfo: boolean;
|
|
636
|
+
notRequireInfo: boolean;
|
|
637
|
+
categoryIds: number[];
|
|
638
|
+
args: ProductListOptionArgs;
|
|
639
|
+
isNext?: boolean;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export interface ProductListOptionArgs {
|
|
643
|
+
filter?: Partial<ProductAttributeFilterOptions>;
|
|
644
|
+
search?: string;
|
|
645
|
+
currentPage?: number;
|
|
646
|
+
sort?: CategorySortOptions | string;
|
|
647
|
+
pageSize?: number;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
export interface PriceRangeMap {
|
|
651
|
+
from?: number;
|
|
652
|
+
to?: number;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export type AttributeOptionField = Array<
|
|
656
|
+
Field<'label', string>
|
|
657
|
+
| Field<'value', string>
|
|
658
|
+
| Field<'swatch_data', SwatchData>
|
|
659
|
+
>;
|
|
660
|
+
|
|
661
|
+
export interface FilterPriceRange {
|
|
662
|
+
min: number;
|
|
663
|
+
max: number;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
export interface FilterArgumentMap {
|
|
667
|
+
categoryIds: (id: number | number[]) => ({ category_id: { eq: number | number[] } });
|
|
668
|
+
categoryUrlPath: (url: string) => ({ category_url_path: { eq: string } });
|
|
669
|
+
priceRange: (price: FilterPriceRange) => ({ price: PriceRangeMap });
|
|
670
|
+
productsSkuArray: (sku: string) => ({ sku: { in: string } });
|
|
671
|
+
productSKU: (sku: string) => ({ sku: { eq: string } });
|
|
672
|
+
productID: (id: number) => ({ id: { eq: number } });
|
|
673
|
+
productUrlPath: (url: string) => ({ url_key: { eq: string } });
|
|
674
|
+
customFilters: (filters: Record<string, string>) => Record<string, {
|
|
675
|
+
from?: string;
|
|
676
|
+
to?: string;
|
|
677
|
+
in?: string;
|
|
678
|
+
}>;
|
|
679
|
+
newToDate: (date: string) => ({ news_to_date: { gteq: string } });
|
|
680
|
+
conditions: (conditions: string) => ({ conditions: { eq: string } });
|
|
681
|
+
customerGroupId: (id: number) => ({ customer_group_id: { eq: number } });
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export interface ProductAttributeCustomFilterOptions {
|
|
685
|
+
category_id?: string;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export interface ProductAttributeFilterOptions {
|
|
689
|
+
categoryIds?: number | number[];
|
|
690
|
+
categoryUrlPath?: string;
|
|
691
|
+
priceRange?: FilterPriceRange;
|
|
692
|
+
productsSkuArray?: string[];
|
|
693
|
+
productSKU?: string;
|
|
694
|
+
productID?: number;
|
|
695
|
+
productUrlPath?: string;
|
|
696
|
+
customFilters?: ProductAttributeCustomFilterOptions;
|
|
697
|
+
newToDate?: string;
|
|
698
|
+
conditions?: string;
|
|
699
|
+
customerGroupId?: number;
|
|
700
|
+
price?: number[];
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export interface ArgumentsMap {
|
|
704
|
+
currentPage: {
|
|
705
|
+
type: string;
|
|
706
|
+
handler: undefined;
|
|
707
|
+
};
|
|
708
|
+
pageSize: {
|
|
709
|
+
type: string;
|
|
710
|
+
handler: (option: number) => number;
|
|
711
|
+
};
|
|
712
|
+
search: {
|
|
713
|
+
type: string;
|
|
714
|
+
handler: (option: string) => string;
|
|
715
|
+
};
|
|
716
|
+
sort: {
|
|
717
|
+
type: string;
|
|
718
|
+
handler: <SortKey extends string>(
|
|
719
|
+
option: { sortKey: SortKey; sortDirection: SortDirections }
|
|
720
|
+
) => Partial<Record<SortKey, SortDirections>>;
|
|
721
|
+
};
|
|
722
|
+
filter: {
|
|
723
|
+
type: string;
|
|
724
|
+
handler: (initialOptions: ProductAttributeFilterOptions) => Record<string, unknown>;
|
|
725
|
+
};
|
|
726
|
+
}
|