@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.
Files changed (355) hide show
  1. package/README.md +101 -0
  2. package/app/cart/useCart.ts +1 -0
  3. package/app/components/ChevronIcon/ChevronIcon.config.ts +17 -0
  4. package/app/components/DateSelect/DateSelect.config.ts +15 -0
  5. package/app/components/Field/Field.config.ts +14 -0
  6. package/app/components/FieldDate/FieldDate.config.ts +16 -0
  7. package/app/components/Form/Form.type.ts +8 -0
  8. package/app/components/Product/Product.config.ts +19 -0
  9. package/app/components/Product/Stock.config.ts +15 -0
  10. package/app/components/ProductCustomizableOption/ProductCustomizableOption.config.ts +5 -0
  11. package/app/components/ProductGallery/ProductGallery.config.ts +15 -0
  12. package/app/components/ProductReviews/ProductReviews.config.ts +8 -0
  13. package/app/composables/_types.ts +18 -0
  14. package/app/composables/adapters/abstract/cartAdapter.ts +0 -0
  15. package/app/composables/adapters/abstract/categoryAdapter.ts +0 -0
  16. package/app/composables/adapters/abstract/customerAdapter.ts +0 -0
  17. package/app/composables/adapters/abstract/inventoryAdapter.ts +0 -0
  18. package/app/composables/adapters/abstract/orderAdapter.ts +0 -0
  19. package/app/composables/adapters/abstract/productAdapter.ts +7 -0
  20. package/app/composables/cart/registry.ts +20 -0
  21. package/app/composables/cart/types.ts +18 -0
  22. package/app/composables/cart/useCart.ts +15 -0
  23. package/app/composables/config.ts +19 -0
  24. package/app/composables/defs/apiDefinitions.ts +55 -0
  25. package/app/composables/defs/extension.feature +40 -0
  26. package/app/composables/defs/extension.mocks.ts +39 -0
  27. package/app/composables/defs/extension.test.ts +280 -0
  28. package/app/composables/defs/extension.ts +236 -0
  29. package/app/composables/defs/index.ts +3 -0
  30. package/app/composables/defs/typeHelpers.ts +8 -0
  31. package/app/composables/defs/types.ts +136 -0
  32. package/app/composables/domain/product.ts +12 -0
  33. package/app/composables/featured-products.ts +20 -0
  34. package/app/composables/helpers/contextualizedNormalizers.feature +14 -0
  35. package/app/composables/helpers/contextualizedNormalizers.test.ts +85 -0
  36. package/app/composables/helpers/contextualizedNormalizers.ts +20 -0
  37. package/app/composables/helpers/index.ts +1 -0
  38. package/app/composables/index.ts +9 -0
  39. package/app/composables/methods/auth.ts +83 -0
  40. package/app/composables/methods/cart.ts +119 -0
  41. package/app/composables/methods/category.ts +27 -0
  42. package/app/composables/methods/checkout.ts +54 -0
  43. package/app/composables/methods/customer.ts +52 -0
  44. package/app/composables/methods/helpers.ts +5 -0
  45. package/app/composables/methods/index.ts +75 -0
  46. package/app/composables/methods/order.ts +39 -0
  47. package/app/composables/methods/product.ts +95 -0
  48. package/app/composables/methods/settings.ts +16 -0
  49. package/app/composables/models/cart.ts +95 -0
  50. package/app/composables/models/category.ts +13 -0
  51. package/app/composables/models/checkout.ts +17 -0
  52. package/app/composables/models/customer.ts +16 -0
  53. package/app/composables/models/facets.ts +25 -0
  54. package/app/composables/models/index.ts +94 -0
  55. package/app/composables/models/order.ts +43 -0
  56. package/app/composables/models/product.ts +73 -0
  57. package/app/composables/models/shared.ts +75 -0
  58. package/app/composables/orders.ts +69 -0
  59. package/app/composables/products/registry.ts +86 -0
  60. package/app/composables/products/types.ts +8 -0
  61. package/app/composables/products/useEvents.ts +26 -0
  62. package/app/composables/products/useGiftCards.ts +29 -0
  63. package/app/composables/products/useProducts.ts +12 -0
  64. package/app/composables/products/useSubscriptions.ts +29 -0
  65. package/app/composables/products.ts +30 -0
  66. package/app/composables/registry.ts +24 -0
  67. package/app/composables/useAuth.ts +43 -0
  68. package/app/composables/useBreakpoints/index.ts +1 -0
  69. package/app/composables/useBreakpoints/useBreakpoints.ts +28 -0
  70. package/app/composables/useCache.ts +38 -0
  71. package/app/composables/useCart/__tests__/useCart.spec.ts +11 -0
  72. package/app/composables/useCart/index.ts +1 -0
  73. package/app/composables/useCart/types.ts +17 -0
  74. package/app/composables/useCart/useCart.ts +46 -0
  75. package/app/composables/useCartShippingMethods/__tests__/useCartShippingMethods.spec.ts +11 -0
  76. package/app/composables/useCartShippingMethods/index.ts +1 -0
  77. package/app/composables/useCartShippingMethods/types.ts +17 -0
  78. package/app/composables/useCartShippingMethods/useCartShippingMethods.ts +47 -0
  79. package/app/composables/useCatalog.ts +26 -0
  80. package/app/composables/useContent.ts +26 -0
  81. package/app/composables/useCustomer/__tests__/useCustomer.spec.ts +25 -0
  82. package/app/composables/useCustomer/index.ts +2 -0
  83. package/app/composables/useCustomer/types.ts +17 -0
  84. package/app/composables/useCustomer/useCustomer.ts +40 -0
  85. package/app/composables/useCustomerAddress/__tests__/useCustomerAddress.spec.ts +11 -0
  86. package/app/composables/useCustomerAddress/index.ts +2 -0
  87. package/app/composables/useCustomerAddress/types.ts +17 -0
  88. package/app/composables/useCustomerAddress/useCustomerAddress.ts +55 -0
  89. package/app/composables/useCustomerOrder/__tests__/useCustomerOrder.spec.ts +11 -0
  90. package/app/composables/useCustomerOrder/adress.ts +10 -0
  91. package/app/composables/useCustomerOrder/index.ts +2 -0
  92. package/app/composables/useCustomerOrder/product.ts +37 -0
  93. package/app/composables/useCustomerOrder/types.ts +40 -0
  94. package/app/composables/useCustomerOrder/useCustomerOrder.ts +63 -0
  95. package/app/composables/useCustomerOrders/__tests__/useCustomerOrders.spec.ts +11 -0
  96. package/app/composables/useCustomerOrders/index.ts +2 -0
  97. package/app/composables/useCustomerOrders/types.ts +20 -0
  98. package/app/composables/useCustomerOrders/useCustomerOrders.ts +56 -0
  99. package/app/composables/useCustomerReturns/__tests__/useCustomerReturns.spec.ts +11 -0
  100. package/app/composables/useCustomerReturns/index.ts +2 -0
  101. package/app/composables/useCustomerReturns/types.ts +17 -0
  102. package/app/composables/useCustomerReturns/useCustomerReturns.ts +41 -0
  103. package/app/composables/useHandleError/index.ts +1 -0
  104. package/app/composables/useHandleError/types.ts +11 -0
  105. package/app/composables/useHandleError/useHandleError.ts +27 -0
  106. package/app/composables/useInventory.ts +29 -0
  107. package/app/composables/useLoading.ts +21 -0
  108. package/app/composables/useNotification.ts +21 -0
  109. package/app/composables/usePageTitle.ts +20 -0
  110. package/app/composables/useProduct/index.ts +2 -0
  111. package/app/composables/useProduct/types.ts +17 -0
  112. package/app/composables/useProduct/useProduct.ts +42 -0
  113. package/app/composables/useProductAttribute/__tests__/useProduct.mock.ts +31 -0
  114. package/app/composables/useProductAttribute/__tests__/useProductAttribute.spec.ts +14 -0
  115. package/app/composables/useProductAttribute/index.ts +1 -0
  116. package/app/composables/useProductAttribute/useProductAttribute.ts +37 -0
  117. package/app/composables/useProductRecommended/__tests__/useProductRecommended.spec.ts +12 -0
  118. package/app/composables/useProductRecommended/index.ts +1 -0
  119. package/app/composables/useProductRecommended/types.ts +17 -0
  120. package/app/composables/useProductRecommended/useProductRecommended.ts +43 -0
  121. package/app/composables/useProductReviews/__tests__/productReviews.mock.ts +20 -0
  122. package/app/composables/useProductReviews/__tests__/useProductReviews.spec.ts +22 -0
  123. package/app/composables/useProductReviews/index.ts +2 -0
  124. package/app/composables/useProductReviews/types.ts +17 -0
  125. package/app/composables/useProductReviews/useProductReviews.ts +46 -0
  126. package/app/composables/useProducts/__tests__/useProducts.spec.ts +11 -0
  127. package/app/composables/useProducts/types.ts +22 -0
  128. package/app/composables/useProducts/useProducts.ts +41 -0
  129. package/app/composables/useTax.ts +27 -0
  130. package/app/composables/validationRules/index.ts +1 -0
  131. package/app/composables/validationRules/password.feature +67 -0
  132. package/app/composables/validationRules/password.test.ts +89 -0
  133. package/app/composables/validationRules/password.ts +25 -0
  134. package/app/normalizers/Cart.query.ts +729 -0
  135. package/app/normalizers/Cart.type.ts +285 -0
  136. package/app/normalizers/Category.query.ts +146 -0
  137. package/app/normalizers/Category.type.ts +55 -0
  138. package/app/normalizers/CheckEmail.query.ts +28 -0
  139. package/app/normalizers/Checkout.query.ts +253 -0
  140. package/app/normalizers/Checkout.type.ts +77 -0
  141. package/app/normalizers/CmsBlock.query.ts +57 -0
  142. package/app/normalizers/CmsBlock.type.ts +25 -0
  143. package/app/normalizers/CmsPage.query.ts +59 -0
  144. package/app/normalizers/CmsPage.type.ts +26 -0
  145. package/app/normalizers/Config.query.ts +224 -0
  146. package/app/normalizers/Config.type.ts +196 -0
  147. package/app/normalizers/ContactForm.query.ts +49 -0
  148. package/app/normalizers/CreditMemo.type.ts +49 -0
  149. package/app/normalizers/GiftCard.type.ts +24 -0
  150. package/app/normalizers/Invoice.type.ts +58 -0
  151. package/app/normalizers/Menu.query.ts +54 -0
  152. package/app/normalizers/Menu.type.ts +22 -0
  153. package/app/normalizers/MyAccount.query.ts +268 -0
  154. package/app/normalizers/MyAccount.type.ts +129 -0
  155. package/app/normalizers/NewsletterSubscription.query.ts +38 -0
  156. package/app/normalizers/Order.query.ts +741 -0
  157. package/app/normalizers/Order.type.ts +268 -0
  158. package/app/normalizers/Payment.type.ts +28 -0
  159. package/app/normalizers/ProductAlerts.query.ts +23 -0
  160. package/app/normalizers/ProductCompare.query.ts +226 -0
  161. package/app/normalizers/ProductCompare.type.ts +90 -0
  162. package/app/normalizers/ProductList.query.ts +1620 -0
  163. package/app/normalizers/ProductList.type.ts +726 -0
  164. package/app/normalizers/Region.query.ts +58 -0
  165. package/app/normalizers/Region.type.ts +23 -0
  166. package/app/normalizers/Return.type.ts +50 -0
  167. package/app/normalizers/Review.query.ts +81 -0
  168. package/app/normalizers/Review.type.ts +42 -0
  169. package/app/normalizers/Slider.query.ts +72 -0
  170. package/app/normalizers/Slider.type.ts +26 -0
  171. package/app/normalizers/StoreInPickUp.query.ts +54 -0
  172. package/app/normalizers/StoreInPickUp.type.ts +59 -0
  173. package/app/normalizers/Subscription.type.ts +25 -0
  174. package/app/normalizers/Transaction.type.ts +20 -0
  175. package/app/normalizers/UrlRewrites.query.ts +55 -0
  176. package/app/normalizers/UrlRewrites.type.ts +25 -0
  177. package/app/normalizers/Wishlist.query.ts +202 -0
  178. package/app/normalizers/Wishlist.type.ts +42 -0
  179. package/app/pages/brand/[...slug].vue +76 -0
  180. package/app/pages/brands.vue +67 -0
  181. package/app/pages/cart.vue +142 -0
  182. package/app/pages/compare.vue +166 -0
  183. package/app/pages/departments/[...slug].vue +353 -0
  184. package/app/pages/departments/category/[...slug].vue +114 -0
  185. package/app/pages/incentive/[...id].vue +66 -0
  186. package/app/pages/invoice/[id].vue +309 -0
  187. package/app/pages/order/[id].vue +327 -0
  188. package/app/pages/product/[...id].vue +309 -0
  189. package/app/pages/product/showcases/index.vue +86 -0
  190. package/app/pages/shipment/[...id].vue +176 -0
  191. package/app/pages/shop/[...slug].vue +158 -0
  192. package/app/pages/shops.vue +76 -0
  193. package/app/pages/subscription/[...id].vue +147 -0
  194. package/app/pages/transaction/[...id].vue +74 -0
  195. package/app/routes/CategoryPage/CategoryPage.config.ts +28 -0
  196. package/app/routes/CategoryPage/CategoryPage.type.ts +8 -0
  197. package/app/routes/Checkout/Checkout.config.ts +3 -0
  198. package/app/routes/Checkout/Checkout.type.ts +14 -0
  199. package/app/routes/MyAccount/MyAccount.config.ts +1 -0
  200. package/app/routes/SearchPage/SearchPage.config.ts +1 -0
  201. package/app/routes/UrlRewrites/UrlRewrites.config.ts +5 -0
  202. package/app/stores/Cart/Cart.type.ts +26 -0
  203. package/app/stores/MyAccount/MyAccount.action.ts +7 -0
  204. package/app/stores/Notification/Notification.action.ts +40 -0
  205. package/app/stores/Notification/Notification.type.ts +16 -0
  206. package/app/stores/Popup/Popup.action.ts +30 -0
  207. package/app/stores/Product/Product.dispatcher.ts +53 -0
  208. package/app/stores/Product/Product.reducer.ts +12 -0
  209. package/app/stores/ProductList/ProductList.dispatcher.ts +35 -0
  210. package/app/stores/ProductList/ProductList.reducer.ts +13 -0
  211. package/app/stores/Store.type.ts +31 -0
  212. package/app/stores/Wishlist/Wishlist.type.ts +12 -0
  213. package/app/stores/cart.ts +218 -0
  214. package/app/stores/cartStore.ts +224 -0
  215. package/app/stores/checkout.ts +18 -0
  216. package/app/stores/compare.ts +65 -0
  217. package/app/stores/currency.js +29 -0
  218. package/app/stores/digital-products.js +11 -0
  219. package/app/stores/orders.ts +172 -0
  220. package/app/stores/product.ts +34 -0
  221. package/app/stores/productList.ts +35 -0
  222. package/app/stores/productListInfo.ts +0 -0
  223. package/app/stores/products.ts +118 -0
  224. package/app/stores/recentlyViewedProducts.ts +56 -0
  225. package/app/stores/review.ts +33 -0
  226. package/app/stores/storeInPickUp.ts +21 -0
  227. package/app/stores/user.ts +20 -0
  228. package/app/stores/wishlist.ts +46 -0
  229. package/app/types/Account.type.ts +141 -0
  230. package/app/types/Breadcrumbs.type.ts +23 -0
  231. package/app/types/CMS.type.ts +33 -0
  232. package/app/types/Category.type.ts +67 -0
  233. package/app/types/Checkout.type.ts +58 -0
  234. package/app/types/Common.type.ts +77 -0
  235. package/app/types/Config.type.ts +47 -0
  236. package/app/types/Device.type.ts +37 -0
  237. package/app/types/Direction.type.ts +23 -0
  238. package/app/types/Downloadable.type.ts +24 -0
  239. package/app/types/Error.type.ts +22 -0
  240. package/app/types/Field.type.ts +151 -0
  241. package/app/types/Global.type.ts +156 -0
  242. package/app/types/Graphql.type.ts +4497 -0
  243. package/app/types/Layout.type.ts +18 -0
  244. package/app/types/Menu.type.ts +39 -0
  245. package/app/types/MiniCart.type.ts +61 -0
  246. package/app/types/NotificationList.type.ts +34 -0
  247. package/app/types/Order.type.ts +174 -0
  248. package/app/types/Price.type.ts +72 -0
  249. package/app/types/ProductCompare.type.ts +24 -0
  250. package/app/types/ProductList.type.ts +351 -0
  251. package/app/types/Rating.type.ts +42 -0
  252. package/app/types/Router.type.ts +67 -0
  253. package/app/types/Slider.type.ts +25 -0
  254. package/app/types/StockStatus.type.ts +21 -0
  255. package/app/types/domain/index.ts +94 -0
  256. package/app/types/index.ts +33 -0
  257. package/app/types/shims.d.ts +52 -0
  258. package/app/types/tilework-opus.d.ts +48 -0
  259. package/app/utils/Address/Address.type.ts +28 -0
  260. package/app/utils/Address/index.ts +325 -0
  261. package/app/utils/Auth/IsSignedIn.ts +4 -0
  262. package/app/utils/Auth/Token.ts +9 -0
  263. package/app/utils/Base64/Base64.ts +16 -0
  264. package/app/utils/Base64/index.ts +12 -0
  265. package/app/utils/Browser/Browser.ts +29 -0
  266. package/app/utils/Browser/index.ts +12 -0
  267. package/app/utils/BrowserDatabase/BrowserDatabase.ts +70 -0
  268. package/app/utils/BrowserDatabase/index.ts +12 -0
  269. package/app/utils/CSS/CSS.ts +65 -0
  270. package/app/utils/CSS/index.ts +12 -0
  271. package/app/utils/Cache/Cache.ts +99 -0
  272. package/app/utils/Cart/Cart.ts +300 -0
  273. package/app/utils/Cart/Cart.type.ts +76 -0
  274. package/app/utils/Cart/Token.ts +59 -0
  275. package/app/utils/Cart/index.ts +13 -0
  276. package/app/utils/Category/Filters.ts +39 -0
  277. package/app/utils/Category/index.ts +12 -0
  278. package/app/utils/Common/index.ts +32 -0
  279. package/app/utils/Compare/Compare.ts +89 -0
  280. package/app/utils/Compare/index.ts +12 -0
  281. package/app/utils/Currency/Currency.ts +84 -0
  282. package/app/utils/Currency/index.ts +12 -0
  283. package/app/utils/DynamicReducer/DynamicReducer.type.ts +14 -0
  284. package/app/utils/DynamicReducer/Helper.ts +30 -0
  285. package/app/utils/DynamicReducer/index.tsx +35 -0
  286. package/app/utils/ElementTransition/ElementTransition.ts +100 -0
  287. package/app/utils/Form/Extract.ts +316 -0
  288. package/app/utils/Form/Form.ts +46 -0
  289. package/app/utils/Form/Form.type.ts +60 -0
  290. package/app/utils/Form/Transform.ts +33 -0
  291. package/app/utils/FormPortalCollector/index.ts +45 -0
  292. package/app/utils/History/History.type.ts +31 -0
  293. package/app/utils/History/index.ts +17 -0
  294. package/app/utils/Manipulations/Array.ts +18 -0
  295. package/app/utils/Manipulations/Date.ts +36 -0
  296. package/app/utils/Manipulations/index.ts +14 -0
  297. package/app/utils/Media/Media.ts +27 -0
  298. package/app/utils/Media/index.ts +13 -0
  299. package/app/utils/Menu/Menu.ts +116 -0
  300. package/app/utils/Menu/Menu.type.ts +37 -0
  301. package/app/utils/Menu/index.ts +12 -0
  302. package/app/utils/Mobile/index.ts +13 -0
  303. package/app/utils/Mobile/isMobile.ts +34 -0
  304. package/app/utils/Orders/Orders.ts +71 -0
  305. package/app/utils/Orders/Orders.type.ts +19 -0
  306. package/app/utils/Orders/index.ts +13 -0
  307. package/app/utils/Polyfill/index.ts +336 -0
  308. package/app/utils/Preload/CategoryPreload.ts +74 -0
  309. package/app/utils/Preload/ProductPreload.ts +28 -0
  310. package/app/utils/Preload/index.ts +75 -0
  311. package/app/utils/Price/Price.config.ts +189 -0
  312. package/app/utils/Price/Price.ts +63 -0
  313. package/app/utils/Price/index.ts +12 -0
  314. package/app/utils/Product/Extract.ts +652 -0
  315. package/app/utils/Product/Product.ts +575 -0
  316. package/app/utils/Product/Product.type.ts +260 -0
  317. package/app/utils/Product/Transform.ts +382 -0
  318. package/app/utils/Product/index.ts +12 -0
  319. package/app/utils/Promise/MakeCancelable.ts +44 -0
  320. package/app/utils/Promise/Promise.type.ts +15 -0
  321. package/app/utils/Promise/index.ts +13 -0
  322. package/app/utils/Query/Field.ts +71 -0
  323. package/app/utils/Query/Fragment.ts +22 -0
  324. package/app/utils/Query/PrepareDocument.ts +119 -0
  325. package/app/utils/Query/Query.type.ts +26 -0
  326. package/app/utils/Query/index.ts +15 -0
  327. package/app/utils/Request/Config.ts +21 -0
  328. package/app/utils/Request/DataContainer.ts +102 -0
  329. package/app/utils/Request/Debounce.ts +48 -0
  330. package/app/utils/Request/Error.ts +31 -0
  331. package/app/utils/Request/Hash.ts +88 -0
  332. package/app/utils/Request/LowPriorityLoad.ts +32 -0
  333. package/app/utils/Request/LowPriorityRender.ts +55 -0
  334. package/app/utils/Request/Mutation.ts +25 -0
  335. package/app/utils/Request/Query.ts +25 -0
  336. package/app/utils/Request/QueryDispatcher.ts +135 -0
  337. package/app/utils/Request/Request.ts +310 -0
  338. package/app/utils/Store/Store.type.ts +26 -0
  339. package/app/utils/Store/index.ts +71 -0
  340. package/app/utils/Url/Url.ts +297 -0
  341. package/app/utils/Url/index.ts +12 -0
  342. package/app/utils/Validator/Config.ts +96 -0
  343. package/app/utils/Validator/Validator.ts +268 -0
  344. package/app/utils/Validator/Validator.type.ts +47 -0
  345. package/app/utils/Validator/index.ts +12 -0
  346. package/app/utils/Wishlist/Wishlist.ts +65 -0
  347. package/app/utils/Wishlist/index.ts +12 -0
  348. package/app/utils/client.ts +280 -0
  349. package/app/utils/index.ts +53 -0
  350. package/app/utils/normalizer.ts +23 -0
  351. package/app/utils/normalizers/magento.ts +29 -0
  352. package/app/utils/normalizers/shopify.ts +29 -0
  353. package/nuxt.config.ts +11 -0
  354. package/package.json +43 -0
  355. package/tsconfig.json +45 -0
@@ -0,0 +1,224 @@
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, Query } from '@tilework/opus';
13
+
14
+ import { GQLCheckoutAgreementMode } from '../types/Graphql.type';
15
+
16
+ import {
17
+ AvailableCurrency,
18
+ CheckoutAgreement,
19
+ Currencies,
20
+ CurrencyData,
21
+ ExchangeRate,
22
+ PriceTaxDisplay,
23
+ StoreConfig,
24
+ StoreConfigFields,
25
+ StoreItem,
26
+ } from './Config.type';
27
+
28
+ /** @namespace ../../normalizers/Config/Query */
29
+ export class ConfigQuery {
30
+ getStoreListField(): Query<'storeList', StoreItem, true> {
31
+ return new Query<'storeList', StoreItem, true>('storeList', true)
32
+ .addFieldList(this._getStoreListFields());
33
+ }
34
+
35
+ getCheckoutAgreements(): Query<'checkoutAgreements', CheckoutAgreement, true> {
36
+ return new Query<'checkoutAgreements', CheckoutAgreement, true>('checkoutAgreements', true)
37
+ .addFieldList(this._getCheckoutAgreementFields());
38
+ }
39
+
40
+ getCurrencyData(): Query<'currencyData', CurrencyData> {
41
+ return new Query<'currencyData', CurrencyData>('currencyData')
42
+ .addFieldList([
43
+ this.getCurrencyFields(),
44
+ new Field<'current_currency_code', string>('current_currency_code'),
45
+ ]);
46
+ }
47
+
48
+ getCurrencyFields(): Field<'available_currencies_data', AvailableCurrency, true> {
49
+ return new Field<'available_currencies_data', AvailableCurrency, true>('available_currencies_data', true)
50
+ .addFieldList(this._getAvailableCurrenciesFields());
51
+ }
52
+
53
+ _getAvailableCurrenciesFields(): Array<
54
+ Field<'id', string>
55
+ | Field<'label', string>
56
+ | Field<'value', string>
57
+ > {
58
+ return [
59
+ new Field<'id', string>('id'),
60
+ new Field<'label', string>('label'),
61
+ new Field<'value', string>('value'),
62
+ ];
63
+ }
64
+
65
+ getCurrencyRates(): Query<'currency', Currencies> {
66
+ return new Query<'currency', Currencies>('currency').addFieldList(this.getCurrencyRatesFields());
67
+ }
68
+
69
+ getCurrencyRatesFields(): Array<
70
+ Field<'base_currency_code', string>
71
+ | Field<'exchange_rates', ExchangeRate, true>
72
+ > {
73
+ return [
74
+ new Field<'base_currency_code', string>('base_currency_code'),
75
+ new Field<
76
+ 'exchange_rates',
77
+ ExchangeRate,
78
+ true
79
+ >('exchange_rates').addFieldList(this._getExchangeRatesFields()),
80
+ ];
81
+ }
82
+
83
+ _getExchangeRatesFields(): Array<
84
+ Field<'currency_to', string>
85
+ | Field<'rate', string>
86
+ > {
87
+ return [
88
+ new Field<'currency_to', string>('currency_to'),
89
+ new Field<'rate', string>('rate'),
90
+ ];
91
+ }
92
+
93
+ _getPriceDisplayTypeField(): Field<'priceTaxDisplay', PriceTaxDisplay> {
94
+ return new Field<'priceTaxDisplay', PriceTaxDisplay>('priceTaxDisplay')
95
+ .addFieldList([
96
+ new Field<'product_price_display_type', string>('product_price_display_type'),
97
+ new Field<'shipping_price_display_type', string>('shipping_price_display_type'),
98
+ ]);
99
+ }
100
+
101
+ _getCheckoutAgreementFields(): Array<
102
+ Field<'agreement_id', number>
103
+ | Field<'checkbox_text', string>
104
+ | Field<'content', string>
105
+ | Field<'content_height', number>
106
+ | Field<'is_html', boolean>
107
+ | Field<'mode', GQLCheckoutAgreementMode>
108
+ | Field<'name', string>
109
+ > {
110
+ return [
111
+ new Field<'agreement_id', number>('agreement_id'),
112
+ new Field<'checkbox_text', string>('checkbox_text'),
113
+ new Field<'content', string>('content'),
114
+ new Field<'content_height', number>('content_height'),
115
+ new Field<'is_html', boolean>('is_html'),
116
+ new Field<'mode', GQLCheckoutAgreementMode>('mode'),
117
+ new Field<'name', string>('name'),
118
+ ];
119
+ }
120
+
121
+ _getStoreListFields(): Array<
122
+ Field<'name', string>
123
+ | Field<'is_active', boolean>
124
+ | Field<'base_url', string>
125
+ | Field<'base_link_url', string>
126
+ | Field<'code', string>
127
+ > {
128
+ return [
129
+ new Field<'name', string>('name'),
130
+ new Field<'is_active', boolean>('is_active'),
131
+ new Field<'base_url', string>('base_url'),
132
+ new Field<'base_link_url', string>('base_link_url'),
133
+ new Field<'code', string>('code'),
134
+ ];
135
+ }
136
+
137
+ getQuery(): Query<'storeConfig', StoreConfig> {
138
+ return new Query<'storeConfig', StoreConfig>('storeConfig')
139
+ .addFieldList(this._getStoreConfigFields());
140
+ }
141
+
142
+ _getTimeDateFormatFields(): Array<
143
+ Field<'use_calendar', boolean>
144
+ | Field<'year_range', string>
145
+ | Field<'date_fields_order', string>
146
+ | Field<'time_format', string>
147
+ > {
148
+ return [
149
+ new Field<'use_calendar', boolean>('use_calendar'),
150
+ new Field<'year_range', string>('year_range'),
151
+ new Field<'date_fields_order', string>('date_fields_order'),
152
+ new Field<'time_format', string>('time_format'),
153
+ ];
154
+ }
155
+
156
+ _getStoreConfigFields(): StoreConfigFields {
157
+ return [
158
+ new Field<'code', string>('code'),
159
+ new Field<'is_active', boolean>('is_active'),
160
+ new Field<'cms_home_page', string>('cms_home_page'),
161
+ new Field<'cms_no_route', string>('cms_no_route'),
162
+ new Field<'copyright', string>('copyright'),
163
+ new Field<'timezone', string>('timezone'),
164
+ new Field<'header_logo_src', string>('header_logo_src'),
165
+ new Field<'title_prefix', string>('title_prefix'),
166
+ new Field<'title_suffix', string>('title_suffix'),
167
+ new Field<'default_display_currency_code', string>('default_display_currency_code'),
168
+ new Field<'default_keywords', string>('default_keywords'),
169
+ new Field<'default_title', string>('default_title'),
170
+ new Field<'default_description', string>('default_description'),
171
+ new Field<'default_country', string>('default_country'),
172
+ new Field<'downloadable_links_target_new_window', boolean>('downloadable_links_target_new_window'),
173
+ new Field<'secure_base_media_url', string>('secure_base_media_url'),
174
+ new Field<'logo_alt', string>('logo_alt'),
175
+ new Field<'logo_height', number>('logo_height'),
176
+ new Field<'logo_width', number>('logo_width'),
177
+ new Field<'cookie_text', string>('cookie_text'),
178
+ new Field<'cookie_link', string>('cookie_link'),
179
+ new Field<'terms_are_enabled', boolean>('terms_are_enabled'),
180
+ new Field<'address_lines_quantity', number>('address_lines_quantity'),
181
+ new Field<'base_url', string>('base_url'),
182
+ new Field<'pagination_frame', number>('pagination_frame'),
183
+ new Field<'pagination_frame_skip', number>('pagination_frame_skip'),
184
+ new Field<'anchor_text_for_previous', string>('anchor_text_for_previous'),
185
+ new Field<'anchor_text_for_next', string>('anchor_text_for_next'),
186
+ new Field<'reviews_are_enabled', boolean>('reviews_are_enabled'),
187
+ new Field<'reviews_allow_guest', boolean>('reviews_allow_guest'),
188
+ new Field<'wishlist_general_active', boolean>('wishlist_general_active'),
189
+ new Field<'demo_notice', boolean>('demo_notice'),
190
+ new Field<'guest_checkout', boolean>('guest_checkout'),
191
+ new Field<'is_email_confirmation_required', boolean>('is_email_confirmation_required'),
192
+ new Field<'display_product_stock_status', boolean>('display_product_stock_status'),
193
+ new Field<'base_link_url', string>('base_link_url'),
194
+ new Field<'show_vat_number_on_storefront', boolean>('show_vat_number_on_storefront'),
195
+ new Field<'show_tax_vat_number', boolean>('show_tax_vat_number'),
196
+ new Field<'product_use_categories', boolean>('product_use_categories'),
197
+ new Field<'category_url_suffix', string>('category_url_suffix'),
198
+ new Field<'cookie_lifetime', string>('cookie_lifetime'),
199
+ new Field<'plp_list_mode', string>('plp_list_mode'),
200
+ new Field<'layered_navigation_product_count_enabled', boolean>('layered_navigation_product_count_enabled'),
201
+ new Field<'region_display_all', boolean>('region_display_all'),
202
+ new Field<'redirect_dashboard', boolean>('redirect_dashboard'),
203
+ new Field<'product_alert_allow_price', boolean>('product_alert_allow_price'),
204
+ new Field<'product_alert_allow_stock', boolean>('product_alert_allow_stock'),
205
+ new Field<'newsletter_general_active', boolean>('newsletter_general_active'),
206
+ new Field<'newsletter_subscription_allow_guest_subscribe', boolean>(
207
+ 'newsletter_subscription_allow_guest_subscribe',
208
+ ),
209
+ new Field<'newsletter_subscription_confirm', boolean>('newsletter_subscription_confirm'),
210
+ new Field<'delivery_instore_active', boolean>('delivery_instore_active'),
211
+ new Field<'access_token_lifetime', string>('access_token_lifetime'),
212
+ new Field<'is_allowed_reorder', boolean>('is_allowed_reorder'),
213
+ new Field<'rss_order_subscribe_allow', boolean>('rss_order_subscribe_allow'),
214
+ new Field<'downloadable_disable_guest_checkout', boolean>('downloadable_disable_guest_checkout'),
215
+ new Field<'minimun_password_length', number>('minimun_password_length'),
216
+ new Field<'required_character_classes_number', string>('required_character_classes_number'),
217
+ new Field<'catalog_default_sort_by', string>('catalog_default_sort_by'),
218
+ ...this._getTimeDateFormatFields(),
219
+ this._getPriceDisplayTypeField(),
220
+ ];
221
+ }
222
+ }
223
+
224
+ export default new ConfigQuery();
@@ -0,0 +1,196 @@
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 } from '@tilework/opus';
13
+
14
+ import { GQLCheckoutAgreementMode, GQLCurrencyEnum } from '../types/Graphql.type';
15
+
16
+ export interface PriceTaxDisplay {
17
+ product_price_display_type: string;
18
+ shipping_price_display_type: string;
19
+ }
20
+
21
+ export type StoreConfigFields = Array<
22
+ Field<'code', string>
23
+ | Field<'is_active', boolean>
24
+ | Field<'cms_home_page', string>
25
+ | Field<'cms_no_route', string>
26
+ | Field<'copyright', string>
27
+ | Field<'timezone', string>
28
+ | Field<'header_logo_src', string>
29
+ | Field<'title_prefix', string>
30
+ | Field<'title_suffix', string>
31
+ | Field<'default_display_currency_code', string>
32
+ | Field<'default_keywords', string>
33
+ | Field<'default_title', string>
34
+ | Field<'default_description', string>
35
+ | Field<'default_country', string>
36
+ | Field<'downloadable_links_target_new_window', boolean>
37
+ | Field<'secure_base_media_url', string>
38
+ | Field<'logo_alt', string>
39
+ | Field<'logo_height', number>
40
+ | Field<'logo_width', number>
41
+ | Field<'cookie_text', string>
42
+ | Field<'cookie_link', string>
43
+ | Field<'terms_are_enabled', boolean>
44
+ | Field<'address_lines_quantity', number>
45
+ | Field<'base_url', string>
46
+ | Field<'pagination_frame', number>
47
+ | Field<'pagination_frame_skip', number>
48
+ | Field<'anchor_text_for_previous', string>
49
+ | Field<'anchor_text_for_next', string>
50
+ | Field<'reviews_are_enabled', boolean>
51
+ | Field<'reviews_allow_guest', boolean>
52
+ | Field<'wishlist_general_active', boolean>
53
+ | Field<'demo_notice', boolean>
54
+ | Field<'guest_checkout', boolean>
55
+ | Field<'is_email_confirmation_required', boolean>
56
+ | Field<'display_product_stock_status', boolean>
57
+ | Field<'base_link_url', string>
58
+ | Field<'show_vat_number_on_storefront', boolean>
59
+ | Field<'show_tax_vat_number', boolean>
60
+ | Field<'product_use_categories', boolean>
61
+ | Field<'category_url_suffix', string>
62
+ | Field<'cookie_lifetime', string>
63
+ | Field<'plp_list_mode', string>
64
+ | Field<'layered_navigation_product_count_enabled', boolean>
65
+ | Field<'region_display_all', boolean>
66
+ | Field<'redirect_dashboard', boolean>
67
+ | Field<'product_alert_allow_price', boolean>
68
+ | Field<'product_alert_allow_stock', boolean>
69
+ | Field<'newsletter_general_active', boolean>
70
+ | Field<'newsletter_subscription_allow_guest_subscribe', boolean>
71
+ | Field<'newsletter_subscription_confirm', boolean>
72
+ | Field<'delivery_instore_active', boolean>
73
+ | Field<'access_token_lifetime', string>
74
+ | Field<'is_allowed_reorder', boolean>
75
+ | Field<'rss_order_subscribe_allow', boolean>
76
+ | Field<'downloadable_disable_guest_checkout', boolean>
77
+ | Field<'minimun_password_length', number>
78
+ | Field<'required_character_classes_number', string>
79
+ | Field<'use_calendar', boolean>
80
+ | Field<'year_range', string>
81
+ | Field<'date_fields_order', string>
82
+ | Field<'time_format', string>
83
+ | Field<'priceTaxDisplay', PriceTaxDisplay>
84
+ | Field<'catalog_default_sort_by', string>
85
+ >;
86
+
87
+ export interface StoreConfig {
88
+ code: string;
89
+ is_active: boolean;
90
+ cms_home_page: string;
91
+ cms_no_route: string;
92
+ copyright: string;
93
+ timezone: string;
94
+ header_logo_src: string;
95
+ title_prefix: string;
96
+ title_suffix: string;
97
+ default_display_currency_code: string;
98
+ default_keywords: string;
99
+ default_title: string;
100
+ default_description: string;
101
+ default_country: string;
102
+ downloadable_links_target_new_window: boolean;
103
+ secure_base_media_url: string;
104
+ logo_alt: string;
105
+ logo_height: number;
106
+ logo_width: number;
107
+ cookie_text: string;
108
+ cookie_link: string;
109
+ terms_are_enabled: boolean;
110
+ address_lines_quantity: number;
111
+ base_url: string;
112
+ pagination_frame: number;
113
+ pagination_frame_skip: number;
114
+ anchor_text_for_previous: string;
115
+ anchor_text_for_next: string;
116
+ reviews_are_enabled: boolean;
117
+ reviews_allow_guest: boolean;
118
+ wishlist_general_active: boolean;
119
+ demo_notice: boolean;
120
+ guest_checkout: boolean;
121
+ is_email_confirmation_required: boolean;
122
+ display_product_stock_status: boolean;
123
+ base_link_url: string;
124
+ show_vat_number_on_storefront: boolean;
125
+ show_tax_vat_number: string;
126
+ product_use_categories: boolean;
127
+ category_url_suffix: string;
128
+ cookie_lifetime: string;
129
+ plp_list_mode: string;
130
+ layered_navigation_product_count_enabled: boolean;
131
+ region_display_all: boolean;
132
+ redirect_dashboard: boolean;
133
+ product_alert_allow_price: boolean;
134
+ product_alert_allow_stock: boolean;
135
+ newsletter_general_active: boolean;
136
+ newsletter_subscription_allow_guest_subscribe: boolean;
137
+ newsletter_subscription_confirm: boolean;
138
+ delivery_instore_active: boolean;
139
+ access_token_lifetime: string;
140
+ is_allowed_reorder: boolean;
141
+ rss_order_subscribe_allow: boolean;
142
+ downloadable_disable_guest_checkout: boolean;
143
+ minimun_password_length: number;
144
+ required_character_classes_number: string;
145
+ use_calendar: boolean;
146
+ year_range: string;
147
+ date_fields_order: string;
148
+ time_format: string;
149
+ priceTaxDisplay: PriceTaxDisplay;
150
+ catalog_default_sort_by: string;
151
+ }
152
+
153
+ export interface StoreItem {
154
+ name: string;
155
+ is_active: boolean;
156
+ base_url: string;
157
+ base_link_url: string;
158
+ code: string;
159
+ }
160
+
161
+ export interface Currency {
162
+ id: string;
163
+ label: string;
164
+ value: string;
165
+ }
166
+
167
+ export interface CurrencyData {
168
+ available_currencies_data: Currency[];
169
+ current_currency_code: GQLCurrencyEnum;
170
+ }
171
+
172
+ export interface CheckoutAgreement {
173
+ agreement_id: number;
174
+ checkbox_text: string;
175
+ content: string;
176
+ content_height: number;
177
+ is_html: boolean;
178
+ mode: GQLCheckoutAgreementMode;
179
+ name: string;
180
+ }
181
+
182
+ export interface AvailableCurrency {
183
+ id: string;
184
+ label: string;
185
+ value: string;
186
+ }
187
+
188
+ export interface ExchangeRate {
189
+ currency_to: string;
190
+ rate: string;
191
+ }
192
+
193
+ export interface Currencies {
194
+ base_currency_code: string;
195
+ exchange_rates: ExchangeRate[];
196
+ }
@@ -0,0 +1,49 @@
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, Mutation, Query } from '@tilework/opus';
13
+
14
+ import { NetworkError } from '../types/Common.type';
15
+ import { GQLContactForm } from '../types/Graphql.type';
16
+
17
+ /** @namespace ../../normalizers/ContactForm/Query */
18
+ export class ContactFormQuery {
19
+ getSendContactFormMutation(options: GQLContactForm): Mutation<'contactForm', NetworkError> {
20
+ const mutation = new Mutation<'contactForm', NetworkError>('contactForm');
21
+
22
+ this._addSendContactFormMutationArguments(mutation, options);
23
+ mutation.addFieldList(this._getSendContactFormMutationResponse());
24
+
25
+ return mutation;
26
+ }
27
+
28
+ getContactPageConfigQuery(): Query<'contactPageConfig', { enabled: boolean }> {
29
+ return new Query<'contactPageConfig', { enabled: boolean }>('contactPageConfig')
30
+ .addFieldList(this._getContactPageConfigFields());
31
+ }
32
+
33
+ _addSendContactFormMutationArguments(
34
+ mutation: Mutation<'contactForm', NetworkError>,
35
+ options: GQLContactForm,
36
+ ): Mutation<'contactForm', NetworkError> {
37
+ return mutation.addArgument('contact', 'ContactForm!', options);
38
+ }
39
+
40
+ _getSendContactFormMutationResponse(): Field<'message', string>[] {
41
+ return [new Field<'message', string>('message')];
42
+ }
43
+
44
+ _getContactPageConfigFields(): Field<'enabled', boolean>[] {
45
+ return [new Field<'enabled', boolean>('enabled')];
46
+ }
47
+ }
48
+
49
+ export default new ContactFormQuery();
@@ -0,0 +1,49 @@
1
+ import { normalizeOrder } from './Order.type';
2
+ import type { Order as DomainOrder } from '../types/domain';
3
+
4
+ // Map credit memo (refund) shapes into a predictable structure. Keep a
5
+ // permissive fallback to `normalizeOrder` for unfamiliar shapes.
6
+ export function normalizeCreditMemo(raw: any): DomainOrder {
7
+ if (!raw) return raw;
8
+
9
+ const id = raw?.id ?? raw?.creditmemo_id ?? raw?.increment_id ?? '';
10
+ const number = raw?.increment_id ?? raw?.number ?? raw?.creditmemo_number ?? '';
11
+ const created_at = raw?.created_at ?? raw?.creditmemo_date ?? raw?.date;
12
+ const status = raw?.status ?? raw?.state ?? 'refunded';
13
+
14
+ const items = Array.isArray(raw?.items)
15
+ ? raw.items.map((it: any) => ({
16
+ id: String(it?.id ?? it?.item_id ?? ''),
17
+ sku: it?.sku ?? it?.product_sku ?? it?.product?.sku,
18
+ quantity: it?.quantity_refunded ?? it?.qty ?? it?.qty_refunded ?? 0,
19
+ price: it?.price ?? it?.row_subtotal ?? undefined,
20
+ product: it?.product ? {
21
+ id: String(it.product?.id ?? it.product?.sku ?? ''),
22
+ sku: it.product?.sku,
23
+ title: it.product?.name ?? it.product?.title,
24
+ } : undefined,
25
+ raw: it,
26
+ }))
27
+ : [];
28
+
29
+ const total = raw?.total ?? raw?.refund_amount ?? raw?.grand_total ?? raw?.amount;
30
+
31
+ if (!id && !number && !Array.isArray(raw?.items)) return normalizeOrder(raw);
32
+
33
+ return {
34
+ id: String(id),
35
+ number,
36
+ created_at,
37
+ status,
38
+ items,
39
+ total,
40
+ raw,
41
+ };
42
+ }
43
+
44
+ export const normalizeCreditMemos = (raw: any): DomainOrder[] => {
45
+ if (!raw) return [];
46
+ if (Array.isArray(raw)) return raw.map(normalizeCreditMemo);
47
+ if (Array.isArray(raw.items)) return raw.items.map(normalizeCreditMemo);
48
+ return [];
49
+ };
@@ -0,0 +1,24 @@
1
+ import { GiftCard as DomainGiftCard } from '../types/domain';
2
+
3
+ export interface GiftCardFragment {
4
+ code: string;
5
+ balance?: number;
6
+ currency?: string;
7
+ }
8
+
9
+ export function normalizeGiftCard(raw: any): DomainGiftCard {
10
+ if (!raw) return raw;
11
+ return {
12
+ code: raw?.code ?? raw?.giftcard_code ?? '',
13
+ balance: raw?.balance ?? raw?.amount ?? raw?.balance_amount,
14
+ currency: raw?.currency ?? raw?.currency_code,
15
+ raw,
16
+ } as DomainGiftCard;
17
+ }
18
+
19
+ export function normalizeGiftCards(raw: any): DomainGiftCard[] {
20
+ if (!raw) return [];
21
+ if (Array.isArray(raw)) return raw.map(normalizeGiftCard);
22
+ if (Array.isArray(raw?.items)) return raw.items.map(normalizeGiftCard);
23
+ return [];
24
+ }
@@ -0,0 +1,58 @@
1
+ import { normalizeOrder } from './Order.type';
2
+ import type { Order as DomainOrder } from '../types/domain';
3
+
4
+ // Provide a richer invoice normalizer that maps common invoice fields into
5
+ // a predictable shape consumers expect. We still fall back to `normalizeOrder`
6
+ // for unknown shapes to remain permissive.
7
+ export function normalizeInvoice(raw: any): DomainOrder {
8
+ if (!raw) return raw;
9
+
10
+ // Base fields: id/number/date/status/raw
11
+ const id = raw?.id ?? raw?.invoice_id ?? raw?.increment_id ?? '';
12
+ const number = raw?.increment_id ?? raw?.number ?? raw?.invoice_number ?? '';
13
+ const created_at = raw?.created_at ?? raw?.invoice_date ?? raw?.date;
14
+ const status = raw?.status ?? raw?.state;
15
+
16
+ // Normalize items: try common shapes (invoice.items, items, lines)
17
+ const items = Array.isArray(raw?.items)
18
+ ? raw.items.map((it: any) => ({
19
+ id: String(it?.id ?? it?.item_id ?? it?.uid ?? ''),
20
+ sku: it?.sku ?? it?.product_sku ?? it?.product?.sku,
21
+ quantity: it?.quantity ?? it?.qty ?? it?.quantity_invoiced ?? 0,
22
+ price: it?.price ?? it?.price_incl_tax ?? it?.row_subtotal ?? undefined,
23
+ product: it?.product ? {
24
+ id: String(it.product?.id ?? it.product?.sku ?? ''),
25
+ sku: it.product?.sku,
26
+ title: it.product?.name ?? it.product?.title,
27
+ price: (it.product?.price && (it.product.price.final_price?.value ?? it.product.price)) ?? undefined,
28
+ images: Array.isArray(it.product?.media_gallery_entries)
29
+ ? it.product.media_gallery_entries.map((m: any) => ({ url: m.file ?? m.url }))
30
+ : []
31
+ } : undefined,
32
+ raw: it,
33
+ }))
34
+ : [];
35
+
36
+ // Total mapping: prefer structured totals, fall back to simple grand_total
37
+ const total = raw?.total ?? raw?.grand_total ?? raw?.total_amount ?? raw?.amount;
38
+
39
+ // If the shape is unusual, fall back to order normalizer for maximum compatibility
40
+ if (!id && !number && !Array.isArray(raw?.items)) return normalizeOrder(raw);
41
+
42
+ return {
43
+ id: String(id),
44
+ number,
45
+ created_at,
46
+ status,
47
+ items,
48
+ total,
49
+ raw,
50
+ };
51
+ }
52
+
53
+ export const normalizeInvoices = (raw: any): DomainOrder[] => {
54
+ if (!raw) return [];
55
+ if (Array.isArray(raw)) return raw.map(normalizeInvoice);
56
+ if (Array.isArray(raw.items)) return raw.items.map(normalizeInvoice);
57
+ return [];
58
+ };
@@ -0,0 +1,54 @@
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, Query } from '@tilework/opus';
13
+
14
+ import { CategoryDisplayMode } from '../routes/CategoryPage/CategoryPage.config';
15
+
16
+ import { MenuItem } from './Menu.type';
17
+ /**
18
+ * Menu Query
19
+ * @class MenuQuery
20
+ * @namespace ../../normalizers/Menu/Query */
21
+ export class MenuQuery {
22
+ /**
23
+ * get Menu query
24
+ * @return {Field} Menu query
25
+ * @memberof MenuQuery
26
+ */
27
+ getQuery(): Query<'menu', MenuItem, true> {
28
+ return new Query<'menuItems', MenuItem, true>('menuItems', true)
29
+ .addFieldList(this._getMenuItemFields())
30
+ .setAlias('menu');
31
+ }
32
+
33
+ _getMenuItemFields(): Array<
34
+ Field<'url', string>
35
+ | Field<'title', string>
36
+ | Field<'item_id', string>
37
+ | Field<'position', number>
38
+ | Field<'parent_id', number>
39
+ | Field<'category_id', number>
40
+ | Field<'display_mode', CategoryDisplayMode>
41
+ > {
42
+ return [
43
+ new Field<'url', string>('url'),
44
+ new Field<'title', string>('title'),
45
+ new Field<'item_id', string>('item_id'),
46
+ new Field<'position', number>('position'),
47
+ new Field<'parent_id', number>('parent_id'),
48
+ new Field<'category_id', number>('category_id'),
49
+ new Field<'display_mode', CategoryDisplayMode>('display_mode'),
50
+ ];
51
+ }
52
+ }
53
+
54
+ export default new MenuQuery();
@@ -0,0 +1,22 @@
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 { CategoryDisplayMode } from '../routes/CategoryPage/CategoryPage.config';
13
+
14
+ export interface MenuItem {
15
+ url: string;
16
+ title: string;
17
+ item_id: string;
18
+ position: number;
19
+ parent_id: number;
20
+ category_id: number;
21
+ display_mode: CategoryDisplayMode;
22
+ }