@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,1620 @@
|
|
|
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 { Field, InlineFragment, Query } from '@tilework/opus';
|
|
13
|
+
|
|
14
|
+
import { SortDirections } from '../routes/CategoryPage/CategoryPage.config';
|
|
15
|
+
import { CUSTOMER } from '../routes/MyAccount/MyAccount.config';
|
|
16
|
+
import { NONE_SORT_OPTION_VALUE } from '../routes/SearchPage/SearchPage.config';
|
|
17
|
+
import {
|
|
18
|
+
GQLCurrencyEnum,
|
|
19
|
+
GQLPriceTypeEnum,
|
|
20
|
+
GQLProductStockStatus,
|
|
21
|
+
GQLShipBundleItemsEnum,
|
|
22
|
+
} from '../types/Graphql.type';
|
|
23
|
+
import BrowserDatabase from '../utils/BrowserDatabase';
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
Aggregation,
|
|
27
|
+
AggregationOption,
|
|
28
|
+
ArgumentsMap,
|
|
29
|
+
AttributeOptionField,
|
|
30
|
+
AttributeWithValue,
|
|
31
|
+
AttributeWithValueOption,
|
|
32
|
+
Breadcrumb,
|
|
33
|
+
BundleItem,
|
|
34
|
+
BundleOption,
|
|
35
|
+
BundleOptionSelection,
|
|
36
|
+
BundlePriceOption,
|
|
37
|
+
BundleProductFragment,
|
|
38
|
+
CategoryInterface,
|
|
39
|
+
CategoryTreeFragment,
|
|
40
|
+
ComplexTextValue,
|
|
41
|
+
ConfigurableCartProductFragment,
|
|
42
|
+
ConfigurableProductFragment,
|
|
43
|
+
ConfigurableProductOptions,
|
|
44
|
+
ConfigurableProductOptionsValues,
|
|
45
|
+
ConfigurableVariant,
|
|
46
|
+
CustomizableAreaOptionFragment,
|
|
47
|
+
CustomizableDateOptionFragment,
|
|
48
|
+
CustomizableDateValue,
|
|
49
|
+
CustomizableFieldOptionFragment,
|
|
50
|
+
CustomizableFieldValue,
|
|
51
|
+
CustomizableFileValue,
|
|
52
|
+
CustomizableProductFragmentOptions,
|
|
53
|
+
CustomizableProductFragmentOptionsFields,
|
|
54
|
+
CustomizableSelectionValue,
|
|
55
|
+
DownloadableProductFragment,
|
|
56
|
+
DownloadableProductLinks,
|
|
57
|
+
DownloadableProductSamples,
|
|
58
|
+
FilterArgumentMap,
|
|
59
|
+
FilterPriceRange,
|
|
60
|
+
GroupedProductItem,
|
|
61
|
+
MediaGalleryEntry,
|
|
62
|
+
Money,
|
|
63
|
+
OptimizedProductImage,
|
|
64
|
+
PriceRange,
|
|
65
|
+
PriceRangeMap,
|
|
66
|
+
ProductAttributeFilterOptions,
|
|
67
|
+
ProductBundleOption,
|
|
68
|
+
ProductDiscount,
|
|
69
|
+
ProductItem,
|
|
70
|
+
ProductItemFields,
|
|
71
|
+
ProductLink,
|
|
72
|
+
ProductListOptions,
|
|
73
|
+
ProductMediaGalleryEntriesVideoContent,
|
|
74
|
+
ProductPrice,
|
|
75
|
+
ProductReview,
|
|
76
|
+
ProductReviews,
|
|
77
|
+
ProductsQueryOutput,
|
|
78
|
+
ProductStockItem,
|
|
79
|
+
RatingsBreakdown,
|
|
80
|
+
SearchResultPageInfo,
|
|
81
|
+
SortField,
|
|
82
|
+
SortFields,
|
|
83
|
+
SwatchData,
|
|
84
|
+
TierPrice,
|
|
85
|
+
UrlRewrite,
|
|
86
|
+
VariantItem,
|
|
87
|
+
} from './ProductList.type';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Product List Query
|
|
91
|
+
* @class ProductListQuery
|
|
92
|
+
* @namespace ../../normalizers/ProductList/Query */
|
|
93
|
+
export class ProductListQuery {
|
|
94
|
+
options: Partial<ProductListOptions> = {};
|
|
95
|
+
|
|
96
|
+
getQuery(options: Partial<ProductListOptions>): Query<'products', ProductsQueryOutput> {
|
|
97
|
+
if (!options) {
|
|
98
|
+
throw new Error('Missing argument `options`');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.options = options;
|
|
102
|
+
|
|
103
|
+
return this._getProductsField();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
_getProductsField(): Query<'products', ProductsQueryOutput> {
|
|
107
|
+
const products = new Query<'products', ProductsQueryOutput>('products')
|
|
108
|
+
.addFieldList(this._getProductFields());
|
|
109
|
+
|
|
110
|
+
this._getProductArguments().forEach((arg) => products.addArgument(...arg));
|
|
111
|
+
|
|
112
|
+
return products;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_getPriceFilter(key: string, value: string): Record<string, { from?: string; to?: string }> {
|
|
116
|
+
const [from, to] = value[0].split('_');
|
|
117
|
+
|
|
118
|
+
if (from === '*') {
|
|
119
|
+
return { [key]: { to } };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (to === '*') {
|
|
123
|
+
return { [key]: { from } };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
[key]: { from, to },
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_getCustomFilters(
|
|
132
|
+
filters: Record<string, string> = {},
|
|
133
|
+
): Record<string, { from?: string; to?: string; in?: string }> {
|
|
134
|
+
return Object.entries(filters)
|
|
135
|
+
.reduce((acc, [key, attribute]: [string, string]) => {
|
|
136
|
+
if (!attribute.length) {
|
|
137
|
+
return acc;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (key === 'price') {
|
|
141
|
+
return {
|
|
142
|
+
...acc,
|
|
143
|
+
...this._getPriceFilter(key, attribute),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
...acc,
|
|
149
|
+
[key]: { in: attribute },
|
|
150
|
+
};
|
|
151
|
+
}, {});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_getFilterArgumentMap(): FilterArgumentMap {
|
|
155
|
+
return {
|
|
156
|
+
categoryIds: (id: number | number[]) => ({ category_id: { eq: id } }),
|
|
157
|
+
categoryUrlPath: (url: string) => ({ category_url_path: { eq: url } }),
|
|
158
|
+
priceRange: ({ min, max }: FilterPriceRange) => {
|
|
159
|
+
const price: PriceRangeMap = {};
|
|
160
|
+
|
|
161
|
+
if (min) {
|
|
162
|
+
price.from = min;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (max) {
|
|
166
|
+
price.to = max;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return { price };
|
|
170
|
+
},
|
|
171
|
+
productsSkuArray: (sku: string) => ({ sku: { in: sku } }),
|
|
172
|
+
productSKU: (sku: string) => ({ sku: { eq: sku } }),
|
|
173
|
+
productID: (id: number) => ({ id: { eq: id } }),
|
|
174
|
+
productUrlPath: (url: string) => ({ url_key: { eq: url } }),
|
|
175
|
+
customFilters: this._getCustomFilters.bind(this),
|
|
176
|
+
newToDate: (date: string) => ({ news_to_date: { gteq: date } }),
|
|
177
|
+
conditions: (conditions: string) => ({ conditions: { eq: conditions } }),
|
|
178
|
+
customerGroupId: (id: number) => ({ customer_group_id: { eq: id } }),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
_getArgumentsMap(): ArgumentsMap {
|
|
183
|
+
const { requireInfo } = this.options;
|
|
184
|
+
const filterArgumentMap = this._getFilterArgumentMap();
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
currentPage: {
|
|
188
|
+
type: 'Int!',
|
|
189
|
+
handler: undefined,
|
|
190
|
+
},
|
|
191
|
+
pageSize: {
|
|
192
|
+
type: 'Int!',
|
|
193
|
+
handler: (option: number) => (requireInfo ? 1 : option),
|
|
194
|
+
},
|
|
195
|
+
search: {
|
|
196
|
+
type: 'String!',
|
|
197
|
+
handler: (option: string) => option.replace(/\+/g, ' '),
|
|
198
|
+
},
|
|
199
|
+
sort: {
|
|
200
|
+
type: 'ProductAttributeSortInput!',
|
|
201
|
+
handler: <SortKey extends string>(
|
|
202
|
+
{ sortKey, sortDirection }: { sortKey: SortKey; sortDirection: SortDirections },
|
|
203
|
+
): Partial<Record<SortKey, SortDirections>> => {
|
|
204
|
+
if (!sortKey || sortKey === NONE_SORT_OPTION_VALUE) {
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return { [sortKey]: sortDirection || SortDirections.ASC } as Record<SortKey, SortDirections>;
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
filter: {
|
|
212
|
+
type: 'ProductAttributeFilterInput!',
|
|
213
|
+
handler: (initialOptions = {}) => {
|
|
214
|
+
// add customer group by default to all requests
|
|
215
|
+
const { group_id }: { group_id?: number } = BrowserDatabase.getItem(CUSTOMER) || {};
|
|
216
|
+
|
|
217
|
+
const options: ProductAttributeFilterOptions = {
|
|
218
|
+
...initialOptions,
|
|
219
|
+
customerGroupId: group_id || 0,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const {
|
|
223
|
+
customFilters: { category_id } = {},
|
|
224
|
+
} = options;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Remove category ID from select, if there is a custom filter
|
|
228
|
+
* of category already selected in filtering options.
|
|
229
|
+
*/
|
|
230
|
+
if (category_id) {
|
|
231
|
+
// eslint-disable-next-line fp/no-delete
|
|
232
|
+
options.categoryIds = undefined;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
type FilterArgumentMapKey = keyof FilterArgumentMap;
|
|
236
|
+
|
|
237
|
+
const parsedOptions: Record<string, unknown> = Object.entries(options).reduce(
|
|
238
|
+
(acc, [key, option]) => {
|
|
239
|
+
// if there is no value, or if the key is just not present in options object
|
|
240
|
+
if (!option || !filterArgumentMap[key as FilterArgumentMapKey]) {
|
|
241
|
+
return acc;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return {
|
|
245
|
+
...acc,
|
|
246
|
+
...filterArgumentMap[key as FilterArgumentMapKey](option as never),
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
{} as Record<string, unknown>,
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
return parsedOptions;
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
_getProductArguments(): Array<[string, string, unknown]> {
|
|
259
|
+
const { args = [] } = this.options;
|
|
260
|
+
const argumentMap = this._getArgumentsMap();
|
|
261
|
+
|
|
262
|
+
type ArgumentsMapKey = keyof ArgumentsMap;
|
|
263
|
+
|
|
264
|
+
return Object.entries(args).reduce((
|
|
265
|
+
acc,
|
|
266
|
+
[key, arg],
|
|
267
|
+
) => {
|
|
268
|
+
if (!arg) {
|
|
269
|
+
return acc;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const {
|
|
273
|
+
type,
|
|
274
|
+
handler = (option: unknown): unknown => option,
|
|
275
|
+
} = argumentMap[key as ArgumentsMapKey];
|
|
276
|
+
|
|
277
|
+
return [
|
|
278
|
+
...acc,
|
|
279
|
+
[key, type, handler(arg as never)],
|
|
280
|
+
];
|
|
281
|
+
}, [] as [string, string, unknown][]);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
_getProductFields(): Array<
|
|
285
|
+
Field<'items', ProductItem & {
|
|
286
|
+
DownloadableProduct: DownloadableProductFragment;
|
|
287
|
+
}, true>
|
|
288
|
+
| Field<'sort_fields', SortFields>
|
|
289
|
+
| Field<'filters', Aggregation, true>
|
|
290
|
+
| Field<'total_count', number>
|
|
291
|
+
| Field<'page_info', SearchResultPageInfo>
|
|
292
|
+
> {
|
|
293
|
+
const { requireInfo, isSingleProduct, notRequireInfo } = this.options;
|
|
294
|
+
|
|
295
|
+
// do not request total count for PDP
|
|
296
|
+
if (isSingleProduct || notRequireInfo) {
|
|
297
|
+
return [
|
|
298
|
+
this._getItemsField(),
|
|
299
|
+
];
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// for filters only request
|
|
303
|
+
if (requireInfo) {
|
|
304
|
+
return [
|
|
305
|
+
this._getSortField(),
|
|
306
|
+
this._getAggregationsField(),
|
|
307
|
+
];
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return [
|
|
311
|
+
new Field<'total_count', number>('total_count'),
|
|
312
|
+
this._getItemsField(),
|
|
313
|
+
this._getPageInfoField(),
|
|
314
|
+
];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
_getCartProductInterfaceFields(): Array<
|
|
318
|
+
Field<'uid', string>
|
|
319
|
+
| Field<'id', number>
|
|
320
|
+
| Field<'sku', string>
|
|
321
|
+
| Field<'name', string>
|
|
322
|
+
| Field<'type_id', string>
|
|
323
|
+
| Field<'stock_status', GQLProductStockStatus>
|
|
324
|
+
| Field<'url', string>
|
|
325
|
+
| Field<'salable_qty', number>
|
|
326
|
+
| Field<'stock_item', ProductStockItem>
|
|
327
|
+
| Field<'thumbnail', OptimizedProductImage>
|
|
328
|
+
| InlineFragment<'ConfigurableProduct', ConfigurableCartProductFragment>
|
|
329
|
+
| Field<'attributes', AttributeWithValue, true>
|
|
330
|
+
| Field<'product_links', ProductLink, true>
|
|
331
|
+
> {
|
|
332
|
+
return [
|
|
333
|
+
new Field<'uid', string>('uid'),
|
|
334
|
+
new Field<'id', number>('id'),
|
|
335
|
+
new Field<'sku', string>('sku'),
|
|
336
|
+
new Field<'name', string>('name'),
|
|
337
|
+
new Field<'type_id', string>('type_id'),
|
|
338
|
+
new Field<'stock_status', GQLProductStockStatus>('stock_status'),
|
|
339
|
+
new Field<'url', string>('url'),
|
|
340
|
+
new Field<'salable_qty', number>('salable_qty'),
|
|
341
|
+
this._getStockItemField(),
|
|
342
|
+
this._getProductThumbnailField(),
|
|
343
|
+
this._getCartConfigurableProductFragment(),
|
|
344
|
+
this._getAttributesField(false, true),
|
|
345
|
+
this._getProductLinksField(),
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
_getCartConfigurableProductFragment(): InlineFragment<'ConfigurableProduct', ConfigurableCartProductFragment> {
|
|
350
|
+
return new InlineFragment<'ConfigurableProduct', ConfigurableCartProductFragment>('ConfigurableProduct')
|
|
351
|
+
.addFieldList([
|
|
352
|
+
this._getConfigurableOptionsField(),
|
|
353
|
+
this._getCartVariantsField(),
|
|
354
|
+
]);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
_getCartVariantsField(): Field<'variants', ConfigurableVariant, true> {
|
|
358
|
+
return new Field<'variants', ConfigurableVariant, true>('variants', true)
|
|
359
|
+
.addFieldList(this._getCartVariantFields());
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
_getCartVariantFields(): Field<'product', ProductItem>[] {
|
|
363
|
+
return [
|
|
364
|
+
this._getCartProductField(),
|
|
365
|
+
];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
_getCartProductField(): Field<'product', ProductItem> {
|
|
369
|
+
return new Field<'product', ProductItem>('product')
|
|
370
|
+
.addFieldList(this._getCartProductFields());
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
_getCartProductFields(): Array<
|
|
374
|
+
Field<'id', number>
|
|
375
|
+
| Field<'sku', string>
|
|
376
|
+
| Field<'stock_status', GQLProductStockStatus>
|
|
377
|
+
| Field<'salable_qty', number>
|
|
378
|
+
| Field<'stock_item', ProductStockItem>
|
|
379
|
+
| Field<'thumbnail', OptimizedProductImage>
|
|
380
|
+
| Field<'attributes', AttributeWithValue, true>
|
|
381
|
+
> {
|
|
382
|
+
return [
|
|
383
|
+
new Field<'id', number>('id'),
|
|
384
|
+
new Field<'sku', string>('sku'),
|
|
385
|
+
new Field<'stock_status', GQLProductStockStatus>('stock_status'),
|
|
386
|
+
new Field<'salable_qty', number>('salable_qty'),
|
|
387
|
+
this._getStockItemField(),
|
|
388
|
+
this._getProductThumbnailField(),
|
|
389
|
+
this._getAttributesField(true, true),
|
|
390
|
+
];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
_getProductInterfaceFields(
|
|
394
|
+
isVariant: boolean,
|
|
395
|
+
isForLinkedProducts = false,
|
|
396
|
+
isForWishlist = false,
|
|
397
|
+
): ProductItemFields {
|
|
398
|
+
const {
|
|
399
|
+
isPlp = false,
|
|
400
|
+
isSingleProduct,
|
|
401
|
+
noAttributes = false,
|
|
402
|
+
noVariants = false,
|
|
403
|
+
noVariantAttributes = false,
|
|
404
|
+
} = this.options;
|
|
405
|
+
|
|
406
|
+
// set option to always request images for product variants if they're requested for wishlist
|
|
407
|
+
if (isForWishlist) {
|
|
408
|
+
this.options.isForWishlist = true;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Basic fields returned always
|
|
412
|
+
const fields: ProductItemFields = [
|
|
413
|
+
new Field<'uid', string>('uid'),
|
|
414
|
+
new Field<'id', number>('id'),
|
|
415
|
+
new Field<'sku', string>('sku'),
|
|
416
|
+
new Field<'name', string>('name'),
|
|
417
|
+
new Field<'type_id', string>('type_id'),
|
|
418
|
+
new Field<'stock_status', GQLProductStockStatus>('stock_status'),
|
|
419
|
+
new Field<'salable_qty', number>('salable_qty'),
|
|
420
|
+
this._getStockItemField(),
|
|
421
|
+
this._getPriceRangeField(),
|
|
422
|
+
];
|
|
423
|
+
|
|
424
|
+
// Additional fields, which we want to return always, except when it's variants on PLP (due to hugh number of items)
|
|
425
|
+
if (!(isPlp && isVariant) || isForWishlist) {
|
|
426
|
+
fields.push(
|
|
427
|
+
this._getProductImageField(),
|
|
428
|
+
this._getProductThumbnailField(),
|
|
429
|
+
this._getProductSmallField(),
|
|
430
|
+
this._getShortDescriptionField(),
|
|
431
|
+
new Field<'special_from_date', string>('special_from_date'),
|
|
432
|
+
new Field<'special_to_date', string>('special_to_date'),
|
|
433
|
+
this._getTierPricesField(),
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// if it is normal product and we need attributes
|
|
438
|
+
// or if, it is variant, but we need variant attributes or variants them-self
|
|
439
|
+
if ((!isVariant && !noAttributes) || (isVariant && !noVariantAttributes && !noVariants)) {
|
|
440
|
+
fields.push(this._getAttributesField(isVariant, false));
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// to all products (non-variants)
|
|
444
|
+
if (!isVariant) {
|
|
445
|
+
fields.push(
|
|
446
|
+
new Field<'url', string>('url'),
|
|
447
|
+
this._getUrlRewritesFields(),
|
|
448
|
+
this._getReviewCountField(),
|
|
449
|
+
this._getRatingSummaryField(),
|
|
450
|
+
this._getCustomizableProductFragment(),
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
// if variants are not needed
|
|
454
|
+
if (!noVariants) {
|
|
455
|
+
fields.push(
|
|
456
|
+
this._getConfigurableProductFragment(),
|
|
457
|
+
this._getBundleProductFragment(),
|
|
458
|
+
this._getGroupedProductItems(),
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// prevent linked products from looping
|
|
464
|
+
if (isForLinkedProducts) {
|
|
465
|
+
fields.push(this._getProductLinksField());
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// additional information to PDP loads
|
|
469
|
+
if (isSingleProduct) {
|
|
470
|
+
fields.push(
|
|
471
|
+
new Field<'stock_status', GQLProductStockStatus>('stock_status'),
|
|
472
|
+
this._getDescriptionField(),
|
|
473
|
+
this._getMediaGalleryField(),
|
|
474
|
+
this._getSimpleProductFragment(),
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
// for variants of PDP requested product
|
|
478
|
+
if (!isVariant) {
|
|
479
|
+
fields.push(
|
|
480
|
+
new Field<'canonical_url', string>('canonical_url'),
|
|
481
|
+
new Field<'meta_title', string>('meta_title'),
|
|
482
|
+
new Field<'meta_keyword', string>('meta_keyword'),
|
|
483
|
+
new Field<'meta_description', string>('meta_description'),
|
|
484
|
+
this._getCategoriesField(),
|
|
485
|
+
this._getReviewsField(),
|
|
486
|
+
this._getVirtualProductFragment(),
|
|
487
|
+
this._getCustomizableProductFragment(),
|
|
488
|
+
this._getProductLinksField(),
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return fields;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* For grouped products, returns the subfields of the elements of the `items` field
|
|
498
|
+
* @returns {*[]}
|
|
499
|
+
* @private
|
|
500
|
+
*/
|
|
501
|
+
_getGroupedProductItemFields(): Array<
|
|
502
|
+
Field<'product', ProductItem>
|
|
503
|
+
| Field<'position', number>
|
|
504
|
+
| Field<'qty', number>
|
|
505
|
+
> {
|
|
506
|
+
return [
|
|
507
|
+
this._getProductField(),
|
|
508
|
+
new Field<'position', number>('position'),
|
|
509
|
+
new Field<'qty', number>('qty'),
|
|
510
|
+
];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* A GroupedProduct-specific field that queries the products that are grouped under this product
|
|
515
|
+
* @returns {Field}
|
|
516
|
+
* @protected
|
|
517
|
+
*/
|
|
518
|
+
_getGroupedProductItems(): InlineFragment<'GroupedProduct', {
|
|
519
|
+
items: GroupedProductItem[];
|
|
520
|
+
}> {
|
|
521
|
+
return new InlineFragment<'GroupedProduct', {
|
|
522
|
+
items: GroupedProductItem[];
|
|
523
|
+
}>('GroupedProduct').addField(
|
|
524
|
+
new Field<'items', GroupedProductItem, true>('items', true)
|
|
525
|
+
.addFieldList(this._getGroupedProductItemFields()),
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* A DownloadableProduct-specific field that queries the links and samples
|
|
531
|
+
* @returns {Field}
|
|
532
|
+
* @private
|
|
533
|
+
*/
|
|
534
|
+
_getDownloadableProductFields(): InlineFragment<'DownloadableProduct', DownloadableProductFragment> {
|
|
535
|
+
return new InlineFragment<'DownloadableProduct', DownloadableProductFragment>('DownloadableProduct')
|
|
536
|
+
.addFieldList(this._getDownloadableProductLinks());
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
_getDownloadableProductLinks(): Array<
|
|
540
|
+
Field<'links_title', string>
|
|
541
|
+
| Field<'samples_title', string>
|
|
542
|
+
| Field<'links_purchased_separately', number>
|
|
543
|
+
| Field<'downloadable_product_links', DownloadableProductLinks, true>
|
|
544
|
+
| Field<'downloadable_product_samples', DownloadableProductSamples, true>
|
|
545
|
+
> {
|
|
546
|
+
return [
|
|
547
|
+
new Field<'links_title', string>('links_title'),
|
|
548
|
+
new Field<'samples_title', string>('samples_title'),
|
|
549
|
+
new Field<'links_purchased_separately', number>('links_purchased_separately'),
|
|
550
|
+
this._getDownloadableProductLinkField(),
|
|
551
|
+
this._getDownloadableProductSampleField(),
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
_getDownloadableProductLinksRequired(): InlineFragment<'DownloadableProduct', DownloadableProductFragment> {
|
|
556
|
+
return new InlineFragment<'DownloadableProduct', DownloadableProductFragment>('DownloadableProduct')
|
|
557
|
+
.addFieldList(this._getDownloadableProductLinksRequiredFields());
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
_getDownloadableProductLinksRequiredFields(): Field<'links_purchased_separately', number>[] {
|
|
561
|
+
return [
|
|
562
|
+
new Field<'links_purchased_separately', number>('links_purchased_separately'),
|
|
563
|
+
];
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
_getDownloadableProductLinkField(): Field<'downloadable_product_links', DownloadableProductLinks, true> {
|
|
567
|
+
return new Field<'downloadable_product_links', DownloadableProductLinks, true>(
|
|
568
|
+
'downloadable_product_links',
|
|
569
|
+
true,
|
|
570
|
+
)
|
|
571
|
+
.addFieldList(this._getDownloadableProductLinkFields());
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
_getDownloadableProductLinkFields(): Array<
|
|
575
|
+
Field<'sample_url', string>
|
|
576
|
+
| Field<'sort_order', number>
|
|
577
|
+
| Field<'title', string>
|
|
578
|
+
| Field<'id', number>
|
|
579
|
+
| Field<'uid', string>
|
|
580
|
+
| Field<'price', number>
|
|
581
|
+
> {
|
|
582
|
+
return [
|
|
583
|
+
new Field<'sample_url', string>('sample_url'),
|
|
584
|
+
new Field<'sort_order', number>('sort_order'),
|
|
585
|
+
new Field<'title', string>('title'),
|
|
586
|
+
new Field<'id', number>('id'),
|
|
587
|
+
new Field<'uid', string>('uid'),
|
|
588
|
+
new Field<'price', number>('price'),
|
|
589
|
+
];
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
_getDownloadableProductSampleField(): Field<'downloadable_product_samples', DownloadableProductSamples, true> {
|
|
593
|
+
return new Field<'downloadable_product_samples', DownloadableProductSamples, true>(
|
|
594
|
+
'downloadable_product_samples',
|
|
595
|
+
true,
|
|
596
|
+
)
|
|
597
|
+
.addFieldList(this._getDownloadableProductSampleFields());
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
_getDownloadableProductSampleFields(): Array<
|
|
601
|
+
Field<'title', string>
|
|
602
|
+
| Field<'sort_order', number>
|
|
603
|
+
| Field<'sample_url', string>
|
|
604
|
+
> {
|
|
605
|
+
return [
|
|
606
|
+
new Field<'title', string>('title'),
|
|
607
|
+
new Field<'sort_order', number>('sort_order'),
|
|
608
|
+
new Field<'sample_url', string>('sample_url'),
|
|
609
|
+
];
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
_getItemsField(): Field<'items', ProductItem & {
|
|
613
|
+
DownloadableProduct: DownloadableProductFragment;
|
|
614
|
+
}, true> {
|
|
615
|
+
const { isSingleProduct } = this.options;
|
|
616
|
+
|
|
617
|
+
const items = new Field<'items', ProductItem & {
|
|
618
|
+
DownloadableProduct: DownloadableProductFragment;
|
|
619
|
+
}, true>('items', true)
|
|
620
|
+
.addFieldList(this._getProductInterfaceFields(false));
|
|
621
|
+
|
|
622
|
+
if (isSingleProduct) {
|
|
623
|
+
// items.addField(this._getGroupedProductItems());
|
|
624
|
+
items.addField(this._getDownloadableProductFields());
|
|
625
|
+
} else {
|
|
626
|
+
items.addField(this._getDownloadableProductLinksRequired());
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
return items;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
_getProductField(): Field<'product', ProductItem> {
|
|
633
|
+
const { isForLinkedProducts, isForWishlist = false } = this.options;
|
|
634
|
+
|
|
635
|
+
return new Field<'product', ProductItem>('product')
|
|
636
|
+
.addFieldList(this._getProductInterfaceFields(true, isForLinkedProducts, isForWishlist));
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
_getShortDescriptionFields(): Field<'html', string>[] {
|
|
640
|
+
return [
|
|
641
|
+
new Field<'html', string>('html'),
|
|
642
|
+
];
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
_getShortDescriptionField(): Field<'short_description', ComplexTextValue> {
|
|
646
|
+
return new Field<'short_description', ComplexTextValue>('short_description')
|
|
647
|
+
.addFieldList(this._getShortDescriptionFields());
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
_getStockItemField(): Field<'stock_item', ProductStockItem> {
|
|
651
|
+
return new Field<'stock_item', ProductStockItem>('stock_item')
|
|
652
|
+
.addFieldList(this._getStockItemFields());
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
_getStockItemFields(): Array<
|
|
656
|
+
Field<'in_stock', boolean>
|
|
657
|
+
| Field<'min_sale_qty', number>
|
|
658
|
+
| Field<'max_sale_qty', number>
|
|
659
|
+
| Field<'qty_increments', number>
|
|
660
|
+
> {
|
|
661
|
+
return [
|
|
662
|
+
new Field<'in_stock', boolean>('in_stock'),
|
|
663
|
+
new Field<'min_sale_qty', number>('min_sale_qty'),
|
|
664
|
+
new Field<'max_sale_qty', number>('max_sale_qty'),
|
|
665
|
+
new Field<'qty_increments', number>('qty_increments'),
|
|
666
|
+
];
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
_getBreadcrumbFields(): Array<
|
|
670
|
+
Field<'category_id', number>
|
|
671
|
+
| Field<'category_name', string>
|
|
672
|
+
| Field<'category_level', number>
|
|
673
|
+
| Field<'category_url', string>
|
|
674
|
+
| Field<'category_is_active', boolean>
|
|
675
|
+
> {
|
|
676
|
+
return [
|
|
677
|
+
new Field<'category_id', number>('category_id'),
|
|
678
|
+
new Field<'category_name', string>('category_name'),
|
|
679
|
+
new Field<'category_level', number>('category_level'),
|
|
680
|
+
new Field<'category_url', string>('category_url'),
|
|
681
|
+
new Field<'category_is_active', boolean>('category_is_active'),
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
_getBreadcrumbsField(): Field<'breadcrumbs', Breadcrumb, true> {
|
|
686
|
+
return new Field<'breadcrumbs', Breadcrumb, true>('breadcrumbs', true)
|
|
687
|
+
.addFieldList(this._getBreadcrumbFields());
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
_getCategoryFields(): Array<
|
|
691
|
+
Field<'id', string>
|
|
692
|
+
| Field<'name', string>
|
|
693
|
+
| Field<'url', string>
|
|
694
|
+
| Field<'breadcrumbs', Breadcrumb, true>
|
|
695
|
+
| InlineFragment<'CategoryTree', CategoryTreeFragment>
|
|
696
|
+
> {
|
|
697
|
+
return [
|
|
698
|
+
new Field<'id', string>('id'),
|
|
699
|
+
new Field<'name', string>('name'),
|
|
700
|
+
new Field<'url', string>('url'),
|
|
701
|
+
this._getIsCategoryActive(),
|
|
702
|
+
this._getBreadcrumbsField(),
|
|
703
|
+
];
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
_getIsCategoryActive(): InlineFragment<'CategoryTree', CategoryTreeFragment> {
|
|
707
|
+
return new InlineFragment<'CategoryTree', CategoryTreeFragment>('CategoryTree').addField('is_active');
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
_getCategoriesField(): Field<'categories', CategoryInterface, true> {
|
|
711
|
+
return new Field<'categories', CategoryInterface, true>('categories', true)
|
|
712
|
+
.addFieldList(this._getCategoryFields());
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
_getMinimalPriceFields(): Array<
|
|
716
|
+
Field<'discount', ProductDiscount>
|
|
717
|
+
| Field<'final_price', Money>
|
|
718
|
+
| Field<'final_price_excl_tax', Money>
|
|
719
|
+
| Field<'regular_price', Money>
|
|
720
|
+
| Field<'regular_price_excl_tax', Money>
|
|
721
|
+
| Field<'default_price', Money>
|
|
722
|
+
| Field<'default_final_price', Money>
|
|
723
|
+
| Field<'default_final_price_excl_tax', Money>
|
|
724
|
+
> {
|
|
725
|
+
return [
|
|
726
|
+
this._getDiscountField(),
|
|
727
|
+
this._getFinalPriceField(),
|
|
728
|
+
this._getFinalPriceExclTaxField(),
|
|
729
|
+
this._getRegularPriceField(),
|
|
730
|
+
this._getRegularPriceExclTaxField(),
|
|
731
|
+
this._getDefaultPriceField(),
|
|
732
|
+
this._getDefaultFinalPriceField(),
|
|
733
|
+
this._getDefaultFinalPriceExclTaxField(),
|
|
734
|
+
];
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
_getMinimalPriceField(): Field<'minimum_price', ProductPrice> {
|
|
738
|
+
return new Field<'minimum_price', ProductPrice>('minimum_price')
|
|
739
|
+
.addFieldList(this._getMinimalPriceFields());
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
_getMaximalPriceField(): Field<'maximum_price', ProductPrice> {
|
|
743
|
+
return new Field<'maximum_price', ProductPrice>('maximum_price')
|
|
744
|
+
.addFieldList(this._getMinimalPriceFields());
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
_getPriceRangeFields(): Array<
|
|
748
|
+
Field<'minimum_price', ProductPrice>
|
|
749
|
+
| Field<'maximum_price', ProductPrice>
|
|
750
|
+
> {
|
|
751
|
+
// Using an array as potentially would want to add maximum price
|
|
752
|
+
return [
|
|
753
|
+
this._getMinimalPriceField(),
|
|
754
|
+
this._getMaximalPriceField(),
|
|
755
|
+
];
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
_getPriceRangeField(): Field<'price_range', PriceRange> {
|
|
759
|
+
return new Field<'price_range', PriceRange>('price_range')
|
|
760
|
+
.addFieldList(this._getPriceRangeFields());
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* @returns {[string]} an array representing the subfields of the product thumbnail
|
|
765
|
+
* @private
|
|
766
|
+
*/
|
|
767
|
+
_getProductThumbnailFields(): Array<
|
|
768
|
+
Field<'path', string>
|
|
769
|
+
| Field<'url', string>
|
|
770
|
+
> {
|
|
771
|
+
return [
|
|
772
|
+
new Field<'path', string>('path'),
|
|
773
|
+
new Field<'url', string>('url'),
|
|
774
|
+
];
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
_getProductSmallFields(): Array<
|
|
778
|
+
Field<'path', string>
|
|
779
|
+
| Field<'url', string>
|
|
780
|
+
> {
|
|
781
|
+
return this._getProductThumbnailFields();
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Returns the field for fetching the thumbnail of a product.
|
|
786
|
+
* Not to be confused with the media thumbnail field, which has the same name but is a subfield of media_gallery_entries
|
|
787
|
+
* @returns {Field}
|
|
788
|
+
* @private
|
|
789
|
+
*/
|
|
790
|
+
_getProductThumbnailField(): Field<'thumbnail', OptimizedProductImage> {
|
|
791
|
+
return new Field<'thumbnail', OptimizedProductImage>('thumbnail')
|
|
792
|
+
.addFieldList(this._getProductThumbnailFields());
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
_getProductSmallField(): Field<'small_image', OptimizedProductImage> {
|
|
796
|
+
return new Field<'small_image', OptimizedProductImage>('small_image')
|
|
797
|
+
.addFieldList(this._getProductSmallFields());
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
_getProductImageField(): Field<'image', OptimizedProductImage> {
|
|
801
|
+
return new Field<'image', OptimizedProductImage>('image')
|
|
802
|
+
.addFieldList(this._getProductThumbnailFields());
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
_getAttributeOptionField(noSwatches: boolean): AttributeOptionField {
|
|
806
|
+
const fields: AttributeOptionField = [
|
|
807
|
+
new Field<'label', string>('label'),
|
|
808
|
+
new Field<'value', string>('value'),
|
|
809
|
+
];
|
|
810
|
+
|
|
811
|
+
if (!noSwatches) {
|
|
812
|
+
fields.push(this._getSwatchDataField());
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
return fields;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
_getAttributeOptionsField(noSwatches: boolean): Field<'attribute_options', AttributeWithValueOption, true> {
|
|
819
|
+
return new Field<'attribute_options', AttributeWithValueOption, true>('attribute_options', true)
|
|
820
|
+
.addFieldList(this._getAttributeOptionField(noSwatches));
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
_getAdditionalAttributeFields(isCart: boolean): Array<
|
|
824
|
+
Field<'attribute_type', string>
|
|
825
|
+
| Field<'attribute_group_id', string>
|
|
826
|
+
| Field<'attribute_group_name', string>
|
|
827
|
+
> {
|
|
828
|
+
if (isCart) {
|
|
829
|
+
return [];
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
return [
|
|
833
|
+
new Field<'attribute_type', string>('attribute_type'),
|
|
834
|
+
new Field<'attribute_group_id', string>('attribute_group_id'),
|
|
835
|
+
new Field<'attribute_group_name', string>('attribute_group_name'),
|
|
836
|
+
];
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
_getAttributeOptionsFields(isVariant: boolean): Field<'attribute_options', AttributeWithValueOption, true>[] {
|
|
840
|
+
if (isVariant) {
|
|
841
|
+
return [];
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return [
|
|
845
|
+
this._getAttributeOptionsField(false),
|
|
846
|
+
];
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
_getAttributeFields(isVariant = false, isCart = false): Array<
|
|
850
|
+
Field<'attribute_id', number>
|
|
851
|
+
| Field<'attribute_value', string>
|
|
852
|
+
| Field<'attribute_code', string>
|
|
853
|
+
| Field<'attribute_label', string>
|
|
854
|
+
| Field<'attribute_type', string>
|
|
855
|
+
| Field<'attribute_group_id', string>
|
|
856
|
+
| Field<'attribute_group_name', string>
|
|
857
|
+
| Field<'attribute_options', AttributeWithValueOption, true>
|
|
858
|
+
> {
|
|
859
|
+
return [
|
|
860
|
+
new Field<'attribute_id', number>('attribute_id'),
|
|
861
|
+
new Field<'attribute_value', string>('attribute_value'),
|
|
862
|
+
new Field<'attribute_code', string>('attribute_code'),
|
|
863
|
+
new Field<'attribute_label', string>('attribute_label'),
|
|
864
|
+
...this._getAdditionalAttributeFields(isCart),
|
|
865
|
+
...this._getAttributeOptionsFields(isVariant),
|
|
866
|
+
];
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
_getAttributesField(isVariant: boolean, isCart: boolean): Field<'attributes', AttributeWithValue, true> {
|
|
870
|
+
return new Field<'s_attributes', AttributeWithValue, true>('s_attributes', true)
|
|
871
|
+
.setAlias('attributes')
|
|
872
|
+
.addFieldList(this._getAttributeFields(isVariant, isCart));
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
_getMediaGalleryFields(): Array<
|
|
876
|
+
Field<'id', number>
|
|
877
|
+
| Field<'file', string>
|
|
878
|
+
| Field<'label', string>
|
|
879
|
+
| Field<'position', number>
|
|
880
|
+
| Field<'disabled', boolean>
|
|
881
|
+
| Field<'media_type', string>
|
|
882
|
+
| Field<'types', string, true>
|
|
883
|
+
| Field<'video_content', ProductMediaGalleryEntriesVideoContent>
|
|
884
|
+
| Field<'thumbnail', { url: string }>
|
|
885
|
+
| Field<'base', { url: string }>
|
|
886
|
+
| Field<'large', { url: string }>
|
|
887
|
+
> {
|
|
888
|
+
return [
|
|
889
|
+
new Field<'id', number>('id'),
|
|
890
|
+
new Field<'file', string>('file'),
|
|
891
|
+
new Field<'label', string>('label'),
|
|
892
|
+
new Field<'position', number>('position'),
|
|
893
|
+
new Field<'disabled', boolean>('disabled'),
|
|
894
|
+
new Field<'media_type', string>('media_type'),
|
|
895
|
+
new Field<'types', string, true>('types', true),
|
|
896
|
+
this._getVideoContentField(),
|
|
897
|
+
this._getMediaThumbnailField(),
|
|
898
|
+
this._getMediaBaseField(),
|
|
899
|
+
this._getMediaLargeField(),
|
|
900
|
+
];
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Returns a field querying video-specific data for a media gallery entry.
|
|
905
|
+
* @returns {Field} the video_content field
|
|
906
|
+
* @private
|
|
907
|
+
*/
|
|
908
|
+
_getVideoContentField(): Field<'video_content', ProductMediaGalleryEntriesVideoContent> {
|
|
909
|
+
return new Field<'video_content', ProductMediaGalleryEntriesVideoContent>('video_content').addFieldList([
|
|
910
|
+
new Field<'media_type', string>('media_type'),
|
|
911
|
+
new Field<'video_description', string>('video_description'),
|
|
912
|
+
new Field<'video_metadata', string>('video_metadata'),
|
|
913
|
+
new Field<'video_provider', string>('video_provider'),
|
|
914
|
+
new Field<'video_title', string>('video_title'),
|
|
915
|
+
new Field<'video_url', string>('video_url'),
|
|
916
|
+
]);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* Returns a field querying the thumbnail of a media gallery entry.
|
|
921
|
+
* Not to be confused with the product thumbnail field, which has the same name but is a direct subfield of the product
|
|
922
|
+
* @returns {Field}
|
|
923
|
+
* @private
|
|
924
|
+
*/
|
|
925
|
+
_getMediaThumbnailField(): Field<'thumbnail', { url: string }> {
|
|
926
|
+
return new Field<'thumbnail', { url: string }>('thumbnail').addField('url');
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
_getMediaBaseField(): Field<'base', { url: string }> {
|
|
930
|
+
return new Field<'base', { url: string }>('base').addField('url');
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
_getMediaLargeField(): Field<'large', { url: string }> {
|
|
934
|
+
return new Field<'large', { url: string }>('large').addField('url');
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
_getMediaGalleryField(): Field<'media_gallery_entries', MediaGalleryEntry, true> {
|
|
938
|
+
return new Field<'media_gallery_entries', MediaGalleryEntry, true>('media_gallery_entries', true)
|
|
939
|
+
.addFieldList(this._getMediaGalleryFields());
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
_getProductLinksField(): Field<'product_links', ProductLink, true> {
|
|
943
|
+
return new Field<'product_links', ProductLink, true>('product_links', true)
|
|
944
|
+
.addFieldList(this._getProductLinkFields());
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
_getDescriptionFields(): Field<'html', string>[] {
|
|
948
|
+
return [
|
|
949
|
+
new Field<'html', string>('html'),
|
|
950
|
+
];
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
_getDescriptionField(): Field<'description', ComplexTextValue> {
|
|
954
|
+
return new Field<'description', ComplexTextValue>('description')
|
|
955
|
+
.addFieldList(this._getDescriptionFields());
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
_getUrlRewritesFields(): Field<'url_rewrites', UrlRewrite, true> {
|
|
959
|
+
return new Field<'url_rewrites', UrlRewrite, true>('url_rewrites')
|
|
960
|
+
.addFieldList([new Field<'url', string>('url')]);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
_getProductLinkFields(): Array<
|
|
964
|
+
Field<'position', number>
|
|
965
|
+
| Field<'link_type', string>
|
|
966
|
+
| Field<'linked_product_sku', string>
|
|
967
|
+
> {
|
|
968
|
+
return [
|
|
969
|
+
new Field<'position', number>('position'),
|
|
970
|
+
new Field<'link_type', string>('link_type'),
|
|
971
|
+
new Field<'linked_product_sku', string>('linked_product_sku'),
|
|
972
|
+
];
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
_getRatingsBreakdownFields(): Array<
|
|
976
|
+
Field<'rating_code', string>
|
|
977
|
+
| Field<'value', string>
|
|
978
|
+
> {
|
|
979
|
+
return [
|
|
980
|
+
new Field<'name', string>('name').setAlias('rating_code'),
|
|
981
|
+
new Field<'value', string>('value'),
|
|
982
|
+
];
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
_getRatingsBreakdownField(): Field<'rating_votes', RatingsBreakdown, true> {
|
|
986
|
+
return new Field<'ratings_breakdown', RatingsBreakdown, true>('ratings_breakdown', true)
|
|
987
|
+
.setAlias('rating_votes')
|
|
988
|
+
.addFieldList(this._getRatingsBreakdownFields());
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
_getReviewItemsFields(): Array<
|
|
992
|
+
Field<'average_rating', number>
|
|
993
|
+
| Field<'nickname', string>
|
|
994
|
+
| Field<'title', string>
|
|
995
|
+
| Field<'detail', string>
|
|
996
|
+
| Field<'created_at', string>
|
|
997
|
+
| Field<'rating_votes', RatingsBreakdown, true>
|
|
998
|
+
> {
|
|
999
|
+
return [
|
|
1000
|
+
new Field<'average_rating', number>('average_rating'),
|
|
1001
|
+
new Field<'nickname', string>('nickname'),
|
|
1002
|
+
new Field<'summary', string>('summary').setAlias('title'),
|
|
1003
|
+
new Field<'text', string>('text').setAlias('detail'),
|
|
1004
|
+
new Field<'created_at', string>('created_at'),
|
|
1005
|
+
this._getRatingsBreakdownField(),
|
|
1006
|
+
];
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
_getReviewItemsField(): Field<'items', ProductReview, true> {
|
|
1010
|
+
return new Field<'items', ProductReview, true>('items', true)
|
|
1011
|
+
.addFieldList(this._getReviewItemsFields());
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
_getReviewsFields(): Field<'items', ProductReview, true>[] {
|
|
1015
|
+
return [
|
|
1016
|
+
this._getReviewItemsField(),
|
|
1017
|
+
];
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
_getReviewsField(): Field<'reviews', ProductReviews> {
|
|
1021
|
+
return new Field<'reviews', ProductReviews>('reviews')
|
|
1022
|
+
// Hard-coded pages, it will be very hard to
|
|
1023
|
+
// paginate using current implementation
|
|
1024
|
+
// eslint-disable-next-line no-magic-numbers
|
|
1025
|
+
.addArgument('pageSize', 'Int', 20)
|
|
1026
|
+
.addArgument('currentPage', 'Int', 1)
|
|
1027
|
+
.addFieldList(this._getReviewsFields());
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
_getReviewCountField(): Field<'review_count', number> {
|
|
1031
|
+
return new Field<'review_count', number>('review_count');
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
_getRatingSummaryField(): Field<'rating_summary', number> {
|
|
1035
|
+
return new Field<'rating_summary', number>('rating_summary');
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
_getBundleOptionsFields(): Array<
|
|
1039
|
+
Field<'uid', string>
|
|
1040
|
+
| Field<'label', string>
|
|
1041
|
+
| Field<'quantity', number>
|
|
1042
|
+
| Field<'position', number>
|
|
1043
|
+
| Field<'is_default', boolean>
|
|
1044
|
+
| Field<'price', number>
|
|
1045
|
+
| Field<'price_type', GQLPriceTypeEnum>
|
|
1046
|
+
| Field<'can_change_quantity', boolean>
|
|
1047
|
+
| Field<'product', ProductBundleOption>
|
|
1048
|
+
> {
|
|
1049
|
+
return [
|
|
1050
|
+
new Field<'uid', string>('uid'),
|
|
1051
|
+
new Field<'label', string>('label'),
|
|
1052
|
+
new Field<'quantity', number>('quantity'),
|
|
1053
|
+
new Field<'position', number>('position'),
|
|
1054
|
+
new Field<'is_default', boolean>('is_default'),
|
|
1055
|
+
new Field<'price', number>('price'),
|
|
1056
|
+
new Field<'price_type', GQLPriceTypeEnum>('price_type'),
|
|
1057
|
+
new Field<'can_change_quantity', boolean>('can_change_quantity'),
|
|
1058
|
+
this._getProductBundleOptionField(),
|
|
1059
|
+
];
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
_getProductBundleOptionField(): Field<'product', ProductBundleOption> {
|
|
1063
|
+
return new Field<'product', ProductBundleOption>('product')
|
|
1064
|
+
.addFieldList(this._getProductBundleOptionFields());
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
_getProductBundleOptionFields(): Array<
|
|
1068
|
+
Field<'name', string>
|
|
1069
|
+
| Field<'stock_status', GQLProductStockStatus>
|
|
1070
|
+
| Field<'price_range', PriceRange>
|
|
1071
|
+
> {
|
|
1072
|
+
return [
|
|
1073
|
+
new Field<'name', string>('name'),
|
|
1074
|
+
new Field<'stock_status', GQLProductStockStatus>('stock_status'),
|
|
1075
|
+
this._getPriceRangeField(),
|
|
1076
|
+
];
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
_getBundleOptionsField(): Field<'options', BundleOption, true> {
|
|
1080
|
+
return new Field<'options', BundleOption, true>('options', true)
|
|
1081
|
+
.addFieldList(this._getBundleOptionsFields());
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
_getBundleItemsFields(): Array<
|
|
1085
|
+
Field<'uid', string>
|
|
1086
|
+
| Field<'option_id', number>
|
|
1087
|
+
| Field<'title', string>
|
|
1088
|
+
| Field<'required', boolean>
|
|
1089
|
+
| Field<'type', string>
|
|
1090
|
+
| Field<'position', number>
|
|
1091
|
+
| Field<'sku', string>
|
|
1092
|
+
| Field<'options', BundleOption, true>
|
|
1093
|
+
> {
|
|
1094
|
+
return [
|
|
1095
|
+
new Field<'uid', string>('uid'),
|
|
1096
|
+
new Field<'option_id', number>('option_id'),
|
|
1097
|
+
new Field<'title', string>('title'),
|
|
1098
|
+
new Field<'required', boolean>('required'),
|
|
1099
|
+
new Field<'type', string>('type'),
|
|
1100
|
+
new Field<'position', number>('position'),
|
|
1101
|
+
new Field<'sku', string>('sku'),
|
|
1102
|
+
this._getBundleOptionsField(),
|
|
1103
|
+
];
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
_getBundleItemsField(): Field<'items', BundleItem, true> {
|
|
1107
|
+
return new Field<'items', BundleItem, true>('items', true)
|
|
1108
|
+
.addFieldList(this._getBundleItemsFields());
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
_getBundlePriceOptionSelectionFields(): Array<
|
|
1112
|
+
Field<'selection_id', number>
|
|
1113
|
+
| Field<'final_option_price', number>
|
|
1114
|
+
| Field<'final_option_price_excl_tax', number>
|
|
1115
|
+
| Field<'regular_option_price', number>
|
|
1116
|
+
| Field<'regular_option_price_excl_tax', number>
|
|
1117
|
+
> {
|
|
1118
|
+
return [
|
|
1119
|
+
new Field<'selection_id', number>('selection_id'),
|
|
1120
|
+
new Field<'final_option_price', number>('final_option_price'),
|
|
1121
|
+
new Field<'final_option_price_excl_tax', number>('final_option_price_excl_tax'),
|
|
1122
|
+
new Field<'regular_option_price', number>('regular_option_price'),
|
|
1123
|
+
new Field<'regular_option_price_excl_tax', number>('regular_option_price_excl_tax'),
|
|
1124
|
+
];
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
_getBundlePriceOptionFields(): Array<
|
|
1128
|
+
Field<'option_id', number>
|
|
1129
|
+
| Field<'selection_details', BundleOptionSelection, true>
|
|
1130
|
+
> {
|
|
1131
|
+
return [
|
|
1132
|
+
new Field<'option_id', number>('option_id'),
|
|
1133
|
+
new Field<'selection_details', BundleOptionSelection, true>('selection_details', true)
|
|
1134
|
+
.addFieldList(this._getBundlePriceOptionSelectionFields()),
|
|
1135
|
+
];
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
_getBundlePriceOptionsField(): Field<'bundle_options', BundlePriceOption, true> {
|
|
1139
|
+
return new Field<'bundle_options', BundlePriceOption, true>('bundle_options', true)
|
|
1140
|
+
.addFieldList(this._getBundlePriceOptionFields());
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
_getBundleProductFragmentFields(): Array<
|
|
1144
|
+
Field<'dynamic_price', boolean>
|
|
1145
|
+
| Field<'dynamic_sku', boolean>
|
|
1146
|
+
| Field<'ship_bundle_items', GQLShipBundleItemsEnum>
|
|
1147
|
+
| Field<'dynamic_weight', boolean>
|
|
1148
|
+
| Field<'items', BundleItem, true>
|
|
1149
|
+
| Field<'bundle_options', BundlePriceOption, true>
|
|
1150
|
+
> {
|
|
1151
|
+
return [
|
|
1152
|
+
new Field<'dynamic_price', boolean>('dynamic_price'),
|
|
1153
|
+
new Field<'dynamic_sku', boolean>('dynamic_sku'),
|
|
1154
|
+
new Field<'ship_bundle_items', GQLShipBundleItemsEnum>('ship_bundle_items'),
|
|
1155
|
+
new Field<'dynamic_weight', boolean>('dynamic_weight'),
|
|
1156
|
+
this._getBundleItemsField(),
|
|
1157
|
+
this._getBundlePriceOptionsField(),
|
|
1158
|
+
];
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
_getValueFields(): Field<'value_index', number>[] {
|
|
1162
|
+
return [
|
|
1163
|
+
new Field<'value_index', number>('value_index'),
|
|
1164
|
+
];
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
_getValuesField(): Field<'values', ConfigurableProductOptionsValues, true> {
|
|
1168
|
+
return new Field<'values', ConfigurableProductOptionsValues, true>('values', true)
|
|
1169
|
+
.addFieldList(this._getValueFields());
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
_getConfigurableOptionFields(): Array<
|
|
1173
|
+
Field<'attribute_code', string>
|
|
1174
|
+
| Field<'values', ConfigurableProductOptionsValues, true>
|
|
1175
|
+
> {
|
|
1176
|
+
return [
|
|
1177
|
+
new Field<'attribute_code', string>('attribute_code'),
|
|
1178
|
+
this._getValuesField(),
|
|
1179
|
+
];
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
_getConfigurableOptionsField(): Field<'configurable_options', ConfigurableProductOptions, true> {
|
|
1183
|
+
return new Field<'configurable_options', ConfigurableProductOptions, true>('configurable_options', true)
|
|
1184
|
+
.addFieldList(this._getConfigurableOptionFields());
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
_getVariantFields(): Field<'product', ProductItem>[] {
|
|
1188
|
+
return [
|
|
1189
|
+
this._getProductField(),
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
_getVariantsField(): Field<'variants', VariantItem, true> {
|
|
1194
|
+
const { isPlp = false, isForWishlist = false } = this.options;
|
|
1195
|
+
|
|
1196
|
+
// For PLP page we have optimized variants graphql field
|
|
1197
|
+
const variantsField = isPlp && !isForWishlist ? 'variants_plp' : 'variants';
|
|
1198
|
+
|
|
1199
|
+
return new Field<'variants_plp' | 'variants', VariantItem, true>(variantsField, true)
|
|
1200
|
+
.setAlias('variants')
|
|
1201
|
+
.addFieldList(this._getVariantFields());
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
_getConfigurableProductFragmentFields(): Array<
|
|
1205
|
+
Field<'configurable_options', ConfigurableProductOptions, true>
|
|
1206
|
+
| Field<'variants', VariantItem, true>
|
|
1207
|
+
> {
|
|
1208
|
+
return [
|
|
1209
|
+
this._getConfigurableOptionsField(),
|
|
1210
|
+
this._getVariantsField(),
|
|
1211
|
+
];
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
_getCustomizableTextValueFields(): Array<
|
|
1215
|
+
Field<'price', number>
|
|
1216
|
+
| Field<'priceInclTax', number>
|
|
1217
|
+
| Field<'priceExclTax', number>
|
|
1218
|
+
| Field<'price_type', GQLPriceTypeEnum>
|
|
1219
|
+
| Field<'currency', string>
|
|
1220
|
+
| Field<'sku', string>
|
|
1221
|
+
| Field<'max_characters', number>
|
|
1222
|
+
> {
|
|
1223
|
+
return [
|
|
1224
|
+
new Field<'price', number>('price'),
|
|
1225
|
+
new Field<'priceInclTax', number>('priceInclTax'),
|
|
1226
|
+
new Field<'priceExclTax', number>('priceExclTax'),
|
|
1227
|
+
new Field<'price_type', GQLPriceTypeEnum>('price_type'),
|
|
1228
|
+
new Field<'currency', string>('currency'),
|
|
1229
|
+
new Field<'sku', string>('sku'),
|
|
1230
|
+
new Field<'max_characters', number>('max_characters'),
|
|
1231
|
+
];
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
_getCustomizableTextValueField<A extends string>(alias: A): Field<A, CustomizableFieldValue> {
|
|
1235
|
+
return new Field<'value', CustomizableFieldValue>('value')
|
|
1236
|
+
.addFieldList(this._getCustomizableTextValueFields())
|
|
1237
|
+
.setAlias(alias);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
_getCustomizableTextFields<A extends string>(alias: A): Array<
|
|
1241
|
+
Field<A, CustomizableFieldValue>
|
|
1242
|
+
| Field<'product_sku', string>
|
|
1243
|
+
> {
|
|
1244
|
+
return [
|
|
1245
|
+
this._getCustomizableTextValueField(alias),
|
|
1246
|
+
new Field<'product_sku', string>('product_sku'),
|
|
1247
|
+
];
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
_getCustomizableFileValueField<A extends string>(alias: A): Field<A, CustomizableFileValue, true> {
|
|
1251
|
+
return new Field<'value', CustomizableFileValue, true>('value', true)
|
|
1252
|
+
.addFieldList([
|
|
1253
|
+
new Field<'price', number>('price'),
|
|
1254
|
+
new Field<'priceInclTax', number>('priceInclTax'),
|
|
1255
|
+
new Field<'priceExclTax', number>('priceExclTax'),
|
|
1256
|
+
new Field<'price_type', GQLPriceTypeEnum>('price_type'),
|
|
1257
|
+
new Field<'currency', string>('currency'),
|
|
1258
|
+
new Field<'sku', string>('sku'),
|
|
1259
|
+
new Field<'file_extension', string>('file_extension'),
|
|
1260
|
+
])
|
|
1261
|
+
.setAlias(alias);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
_getCustomizableAreaOption(): InlineFragment<'CustomizableAreaOption', CustomizableAreaOptionFragment> {
|
|
1265
|
+
return new InlineFragment<'CustomizableAreaOption', CustomizableAreaOptionFragment>('CustomizableAreaOption')
|
|
1266
|
+
.addFieldList(this._getCustomizableTextFields('areaValues'));
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
_getCustomizableFieldOption(): InlineFragment<'CustomizableFieldOption', CustomizableFieldOptionFragment> {
|
|
1270
|
+
return new InlineFragment<'CustomizableFieldOption', CustomizableFieldOptionFragment>('CustomizableFieldOption')
|
|
1271
|
+
.addFieldList(this._getCustomizableTextFields('fieldValues'));
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
_getCustomizableFileOption(): InlineFragment<'CustomizableFileOption', {
|
|
1275
|
+
fileValues: CustomizableFileValue[];
|
|
1276
|
+
}> {
|
|
1277
|
+
return new InlineFragment<'CustomizableFileOption', {
|
|
1278
|
+
fileValues: CustomizableFileValue[];
|
|
1279
|
+
}>('CustomizableFileOption')
|
|
1280
|
+
.addFieldList([this._getCustomizableFileValueField('fileValues')]);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
_getCustomizableDateValueFields(): Array<
|
|
1284
|
+
Field<'price', number>
|
|
1285
|
+
| Field<'priceInclTax', number>
|
|
1286
|
+
| Field<'priceExclTax', number>
|
|
1287
|
+
| Field<'price_type', GQLPriceTypeEnum>
|
|
1288
|
+
| Field<'currency', string>
|
|
1289
|
+
| Field<'sku', string>
|
|
1290
|
+
> {
|
|
1291
|
+
return [
|
|
1292
|
+
new Field<'price', number>('price'),
|
|
1293
|
+
new Field<'priceInclTax', number>('priceInclTax'),
|
|
1294
|
+
new Field<'priceExclTax', number>('priceExclTax'),
|
|
1295
|
+
new Field<'price_type', GQLPriceTypeEnum>('price_type'),
|
|
1296
|
+
new Field<'currency', string>('currency'),
|
|
1297
|
+
new Field<'sku', string>('sku'),
|
|
1298
|
+
];
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
_getCustomizableDateValueField(): Field<'value', CustomizableDateValue, true> {
|
|
1302
|
+
return new Field<'value', CustomizableDateValue, true>('value', true)
|
|
1303
|
+
.addFieldList(this._getCustomizableDateValueFields());
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
_getCustomizableDateFields(): Array<
|
|
1307
|
+
Field<'value', CustomizableDateValue, true>
|
|
1308
|
+
| Field<'product_sku', string>
|
|
1309
|
+
> {
|
|
1310
|
+
return [
|
|
1311
|
+
this._getCustomizableDateValueField(),
|
|
1312
|
+
new Field<'product_sku', string>('product_sku'),
|
|
1313
|
+
];
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
_getCustomizableDateOption(): InlineFragment<'CustomizableDateOption', CustomizableDateOptionFragment> {
|
|
1317
|
+
return new InlineFragment<'CustomizableDateOption', CustomizableDateOptionFragment>('CustomizableDateOption')
|
|
1318
|
+
.addFieldList(this._getCustomizableDateFields());
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
_getCustomizableSelectionValueFields(): Array<
|
|
1322
|
+
Field<'uid', string>
|
|
1323
|
+
| Field<'option_type_id', number>
|
|
1324
|
+
| Field<'price', number>
|
|
1325
|
+
| Field<'priceInclTax', number>
|
|
1326
|
+
| Field<'priceExclTax', number>
|
|
1327
|
+
| Field<'price_type', GQLPriceTypeEnum>
|
|
1328
|
+
| Field<'currency', string>
|
|
1329
|
+
| Field<'sku', string>
|
|
1330
|
+
| Field<'title', string>
|
|
1331
|
+
| Field<'sort_order', number>
|
|
1332
|
+
> {
|
|
1333
|
+
return [
|
|
1334
|
+
new Field<'uid', string>('uid'),
|
|
1335
|
+
new Field<'option_type_id', number>('option_type_id'),
|
|
1336
|
+
new Field<'price', number>('price'),
|
|
1337
|
+
new Field<'priceInclTax', number>('priceInclTax'),
|
|
1338
|
+
new Field<'priceExclTax', number>('priceExclTax'),
|
|
1339
|
+
new Field<'price_type', GQLPriceTypeEnum>('price_type'),
|
|
1340
|
+
new Field<'currency', string>('currency'),
|
|
1341
|
+
new Field<'sku', string>('sku'),
|
|
1342
|
+
new Field<'title', string>('title'),
|
|
1343
|
+
new Field<'sort_order', number>('sort_order'),
|
|
1344
|
+
];
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
_getCustomizableSelectionValueField<A extends string>(alias: A): Field<A, CustomizableSelectionValue, true> {
|
|
1348
|
+
return new Field<'value', CustomizableSelectionValue, true>('value', true)
|
|
1349
|
+
.addFieldList(this._getCustomizableSelectionValueFields())
|
|
1350
|
+
.setAlias(alias);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
_getCustomizableCheckboxOption(): InlineFragment<'CustomizableCheckboxOption', {
|
|
1354
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
1355
|
+
}> {
|
|
1356
|
+
return new InlineFragment<'CustomizableCheckboxOption', { checkboxValues: CustomizableSelectionValue[] }>(
|
|
1357
|
+
'CustomizableCheckboxOption',
|
|
1358
|
+
)
|
|
1359
|
+
.addFieldList([this._getCustomizableSelectionValueField('checkboxValues')]);
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
_getCustomizableMultiOption(): InlineFragment<'CustomizableMultipleOption', {
|
|
1363
|
+
checkboxValues: CustomizableSelectionValue[];
|
|
1364
|
+
}> {
|
|
1365
|
+
return new InlineFragment<'CustomizableMultipleOption', { checkboxValues: CustomizableSelectionValue[] }>(
|
|
1366
|
+
'CustomizableMultipleOption',
|
|
1367
|
+
)
|
|
1368
|
+
.addFieldList([this._getCustomizableSelectionValueField('checkboxValues')]); // same as checkbox
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
_getCustomizableDropdownOption(): InlineFragment<'CustomizableDropDownOption', {
|
|
1372
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
1373
|
+
}> {
|
|
1374
|
+
return new InlineFragment<'CustomizableDropDownOption', { dropdownValues: CustomizableSelectionValue[] }>(
|
|
1375
|
+
'CustomizableDropDownOption',
|
|
1376
|
+
)
|
|
1377
|
+
.addFieldList([this._getCustomizableSelectionValueField('dropdownValues')]);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
_getCustomizableRadioOption(): InlineFragment<'CustomizableRadioOption', {
|
|
1381
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
1382
|
+
}> {
|
|
1383
|
+
return new InlineFragment<'CustomizableRadioOption', {
|
|
1384
|
+
dropdownValues: CustomizableSelectionValue[];
|
|
1385
|
+
}>('CustomizableRadioOption')
|
|
1386
|
+
.addFieldList([this._getCustomizableSelectionValueField('dropdownValues')]); // same as dropdown
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
_getCustomizableProductFragmentOptionsFields(): CustomizableProductFragmentOptionsFields {
|
|
1390
|
+
return [
|
|
1391
|
+
this._getCustomizableDropdownOption(),
|
|
1392
|
+
this._getCustomizableRadioOption(),
|
|
1393
|
+
this._getCustomizableCheckboxOption(),
|
|
1394
|
+
this._getCustomizableMultiOption(),
|
|
1395
|
+
this._getCustomizableFieldOption(),
|
|
1396
|
+
this._getCustomizableAreaOption(),
|
|
1397
|
+
this._getCustomizableFileOption(),
|
|
1398
|
+
this._getCustomizableDateOption(),
|
|
1399
|
+
new Field<'title', string>('title'),
|
|
1400
|
+
new Field<'required', boolean>('required'),
|
|
1401
|
+
new Field<'sort_order', number>('sort_order'),
|
|
1402
|
+
new Field<'type', string>('type'),
|
|
1403
|
+
new Field<'uid', string>('uid'),
|
|
1404
|
+
];
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
_getCustomizableProductFragmentOptionsField(): Field<'options', CustomizableProductFragmentOptions, true> {
|
|
1408
|
+
return new Field<'options', CustomizableProductFragmentOptions, true>('options', true)
|
|
1409
|
+
.addFieldList(this._getCustomizableProductFragmentOptionsFields());
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
_getCustomizableProductFragment(): InlineFragment<'CustomizableProductInterface', {
|
|
1413
|
+
options: CustomizableProductFragmentOptions[];
|
|
1414
|
+
}> {
|
|
1415
|
+
return new InlineFragment<'CustomizableProductInterface', {
|
|
1416
|
+
options: CustomizableProductFragmentOptions[];
|
|
1417
|
+
}>(
|
|
1418
|
+
'CustomizableProductInterface',
|
|
1419
|
+
)
|
|
1420
|
+
.addFieldList([this._getCustomizableProductFragmentOptionsField()]);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
_getSimpleProductFragmentFields(): Field<'price_tiers', TierPrice, true>[] {
|
|
1424
|
+
return [
|
|
1425
|
+
this._getTierPricesField(),
|
|
1426
|
+
];
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
_getVirtualProductFragmentFields(): Field<'price_tiers', TierPrice, true>[] {
|
|
1430
|
+
return [
|
|
1431
|
+
this._getTierPricesField(),
|
|
1432
|
+
];
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
_getTierPricesField(): Field<'price_tiers', TierPrice, true> {
|
|
1436
|
+
return new Field<'price_tiers', TierPrice, true>('price_tiers', true)
|
|
1437
|
+
.addFieldList(this._getTierPricesFields());
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
_getTierPricesFields(): Array<
|
|
1441
|
+
Field<'discount', ProductDiscount>
|
|
1442
|
+
| Field<'final_price', Money>
|
|
1443
|
+
| Field<'quantity', number>
|
|
1444
|
+
> {
|
|
1445
|
+
return [
|
|
1446
|
+
this._getDiscountField(),
|
|
1447
|
+
this._getFinalPriceField(),
|
|
1448
|
+
new Field<'quantity', number>('quantity'),
|
|
1449
|
+
];
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
_getDiscountField(): Field<'discount', ProductDiscount> {
|
|
1453
|
+
return new Field<'discount', ProductDiscount>('discount')
|
|
1454
|
+
.addField(new Field<'amount_off', number>('amount_off'))
|
|
1455
|
+
.addField(new Field<'percent_off', number>('percent_off'));
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
_getFinalPriceField(): Field<'final_price', Money> {
|
|
1459
|
+
return new Field<'final_price', Required<Money>>('final_price')
|
|
1460
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1461
|
+
.addField(new Field<'value', number>('value'));
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
_getFinalPriceExclTaxField(): Field<'final_price_excl_tax', Money> {
|
|
1465
|
+
return new Field<'final_price_excl_tax', Money>('final_price_excl_tax')
|
|
1466
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1467
|
+
.addField(new Field<'value', number>('value'));
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
_getRegularPriceField(): Field<'regular_price', Money> {
|
|
1471
|
+
return new Field<'regular_price', Money>('regular_price')
|
|
1472
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1473
|
+
.addField(new Field<'value', number>('value'));
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
_getRegularPriceExclTaxField(): Field<'regular_price_excl_tax', Money> {
|
|
1477
|
+
return new Field<'regular_price_excl_tax', Money>('regular_price_excl_tax')
|
|
1478
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1479
|
+
.addField(new Field<'value', number>('value'));
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
_getDefaultFinalPriceExclTaxField(): Field<'default_final_price_excl_tax', Money> {
|
|
1483
|
+
return new Field<'default_final_price_excl_tax', Money>('default_final_price_excl_tax')
|
|
1484
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1485
|
+
.addField(new Field<'value', number>('value'));
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
_getDefaultPriceField(): Field<'default_price', Money> {
|
|
1489
|
+
return new Field<'default_price', Money>('default_price')
|
|
1490
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1491
|
+
.addField(new Field<'value', number>('value'));
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
_getDefaultFinalPriceField(): Field<'default_final_price', Money> {
|
|
1495
|
+
return new Field<'default_final_price', Money>('default_final_price')
|
|
1496
|
+
.addField(new Field<'currency', GQLCurrencyEnum>('currency'))
|
|
1497
|
+
.addField(new Field<'value', number>('value'));
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
_getBundleProductFragment(): InlineFragment<'BundleProduct', BundleProductFragment> {
|
|
1501
|
+
return new InlineFragment<'BundleProduct', BundleProductFragment>('BundleProduct')
|
|
1502
|
+
.addFieldList(this._getBundleProductFragmentFields());
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
_getConfigurableProductFragment(): InlineFragment<'ConfigurableProduct', ConfigurableProductFragment> {
|
|
1506
|
+
return new InlineFragment<'ConfigurableProduct', ConfigurableProductFragment>('ConfigurableProduct')
|
|
1507
|
+
.addFieldList(this._getConfigurableProductFragmentFields());
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
_getSimpleProductFragment(): InlineFragment<'SimpleProduct', {
|
|
1511
|
+
price_tiers: TierPrice[];
|
|
1512
|
+
}> {
|
|
1513
|
+
return new InlineFragment<'SimpleProduct', {
|
|
1514
|
+
price_tiers: TierPrice[];
|
|
1515
|
+
}>('SimpleProduct')
|
|
1516
|
+
.addFieldList(this._getSimpleProductFragmentFields());
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
_getVirtualProductFragment(): InlineFragment<'VirtualProduct', {
|
|
1520
|
+
price_tiers: TierPrice[];
|
|
1521
|
+
}> {
|
|
1522
|
+
return new InlineFragment<'VirtualProduct', {
|
|
1523
|
+
price_tiers: TierPrice[];
|
|
1524
|
+
}>('VirtualProduct')
|
|
1525
|
+
.addFieldList(this._getVirtualProductFragmentFields());
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
_getSortOptionFields(): Array<
|
|
1529
|
+
Field<'value', string>
|
|
1530
|
+
| Field<'label', string>
|
|
1531
|
+
> {
|
|
1532
|
+
return [
|
|
1533
|
+
new Field<'value', string>('value'),
|
|
1534
|
+
new Field<'label', string>('label'),
|
|
1535
|
+
];
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
_getSortOptionsField(): Field<'options', SortField, true> {
|
|
1539
|
+
return new Field<'options', SortField, true>('options', true)
|
|
1540
|
+
.addFieldList(this._getSortOptionFields());
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
_getSortFields(): Field<'options', SortField, true>[] {
|
|
1544
|
+
return [
|
|
1545
|
+
this._getSortOptionsField(),
|
|
1546
|
+
];
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
_getSortField(): Field<'sort_fields', SortFields> {
|
|
1550
|
+
return new Field<'sort_fields', SortFields>('sort_fields')
|
|
1551
|
+
.addFieldList(this._getSortFields());
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
_getSwatchDataFields(): Array<
|
|
1555
|
+
Field<'type', string>
|
|
1556
|
+
| Field<'value', string>
|
|
1557
|
+
> {
|
|
1558
|
+
return [
|
|
1559
|
+
new Field<'type', string>('type'),
|
|
1560
|
+
new Field<'value', string>('value'),
|
|
1561
|
+
];
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
_getSwatchDataField(): Field<'swatch_data', SwatchData> {
|
|
1565
|
+
return new Field<'swatch_data', SwatchData>('swatch_data')
|
|
1566
|
+
.addFieldList(this._getSwatchDataFields());
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
_getAggregationsField(): Field<'filters', Aggregation, true> {
|
|
1570
|
+
return new Field<'aggregations', Aggregation, true>('aggregations', true)
|
|
1571
|
+
.setAlias('filters')
|
|
1572
|
+
.addFieldList(this._getAggregationsFields());
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
_getAggregationsFields(): Array<
|
|
1576
|
+
Field<'name', string>
|
|
1577
|
+
| Field<'request_var', string>
|
|
1578
|
+
| Field<'is_boolean', boolean>
|
|
1579
|
+
| Field<'has_swatch', boolean>
|
|
1580
|
+
| Field<'position', number>
|
|
1581
|
+
| Field<'filter_items', AggregationOption, true>
|
|
1582
|
+
> {
|
|
1583
|
+
return [
|
|
1584
|
+
new Field<'label', string>('label').setAlias('name'),
|
|
1585
|
+
new Field<'attribute_code', string>('attribute_code').setAlias('request_var'),
|
|
1586
|
+
new Field<'is_boolean', boolean>('is_boolean'),
|
|
1587
|
+
new Field<'has_swatch', boolean>('has_swatch'),
|
|
1588
|
+
new Field<'position', number>('position'),
|
|
1589
|
+
this._getAggregationsOptionsField(),
|
|
1590
|
+
];
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
_getAggregationsOptionsField(): Field<'filter_items', AggregationOption, true> {
|
|
1594
|
+
return new Field<'options', AggregationOption, true>('options', true)
|
|
1595
|
+
.setAlias('filter_items')
|
|
1596
|
+
.addFieldList(this._getAggregationsOptionsFields());
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
_getAggregationsOptionsFields(): Array<
|
|
1600
|
+
Field<'label', string>
|
|
1601
|
+
| Field<'count', number>
|
|
1602
|
+
| Field<'value_string', string>
|
|
1603
|
+
| Field<'swatch_data', SwatchData>
|
|
1604
|
+
> {
|
|
1605
|
+
return [
|
|
1606
|
+
new Field<'label', string>('label'),
|
|
1607
|
+
new Field<'count', number>('count'),
|
|
1608
|
+
new Field<'value', string>('value').setAlias('value_string'),
|
|
1609
|
+
this._getSwatchDataField(),
|
|
1610
|
+
];
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
_getPageInfoField(): Field<'page_info', SearchResultPageInfo> {
|
|
1614
|
+
return new Field<'page_info', SearchResultPageInfo>('page_info')
|
|
1615
|
+
.addField(new Field<'current_page', number>('current_page'))
|
|
1616
|
+
.addField(new Field<'total_pages', number>('total_pages'));
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
export default new ProductListQuery();
|