@meeovi/layer-commerce 1.0.3 → 1.0.5

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 (358) hide show
  1. package/app/components/catalog/product/ProductAccordion/types.ts +3 -3
  2. package/app/components/catalog/product/ProductProperties/types.ts +3 -3
  3. package/app/components/catalog/product/ProductSlider/types.ts +5 -5
  4. package/app/components/catalog/product/RecommendedProducts/types.ts +3 -3
  5. package/app/components/catalog/product/bestsellers.vue +8 -20
  6. package/app/components/catalog/product/deals.vue +7 -22
  7. package/app/components/catalog/product/exclusives.vue +8 -10
  8. package/app/components/catalog/product/featuredproducts.vue +8 -20
  9. package/app/components/catalog/product/latestproducts.vue +8 -20
  10. package/app/components/catalog/product/productCard.vue +55 -21
  11. package/app/components/catalog/product/productDetails.vue +20 -14
  12. package/app/components/catalog/product/relatedproducts.vue +5 -20
  13. package/app/components/catalog/product/sizeOptions.vue +3 -8
  14. package/app/components/catalog/shops/relatedstores.vue +6 -21
  15. package/app/components/categories/chart/[id].vue +200 -0
  16. package/app/components/categories/chart/add-chart.vue +142 -0
  17. package/app/components/categories/chart/chart.vue +82 -0
  18. package/app/components/categories/chart/monthlyChart.vue +46 -0
  19. package/app/components/categories/chart/weeklyChart.vue +46 -0
  20. package/app/components/categories/chart/yearlyChart.vue +46 -0
  21. package/app/components/categories/charts.vue +118 -0
  22. package/app/components/categories/deals.vue +101 -0
  23. package/app/components/categories/eats.vue +49 -0
  24. package/app/components/categories/restaurants.vue +26 -0
  25. package/app/components/categories/station/[id].vue +72 -0
  26. package/app/components/categories/stations.vue +124 -0
  27. package/app/components/categories/time/time.vue +63 -0
  28. package/app/components/categories/travel.vue +75 -0
  29. package/app/components/categories/weather/weather.vue +44 -0
  30. package/app/components/content/pages/showcases.vue +1 -1
  31. package/app/components/marketing/promotions/giftcards.vue +20 -45
  32. package/app/components/marketing/promotions/subscriptions.vue +8 -21
  33. package/app/components/placeholders/Comments.vue +15 -0
  34. package/app/components/placeholders/CreateListBtn.vue +7 -0
  35. package/app/components/placeholders/Event.vue +9 -0
  36. package/app/components/placeholders/ListShowcases.vue +9 -0
  37. package/app/components/placeholders/Short.vue +9 -0
  38. package/app/components/placeholders/Space.vue +9 -0
  39. package/app/components/placeholders/Tag.vue +7 -0
  40. package/app/components/sales/CheckoutAddress/types.ts +12 -11
  41. package/app/components/sales/OrderSummary/types.ts +3 -3
  42. package/app/components/sales/incentives.vue +13 -37
  43. package/app/composables/_types.ts +6 -5
  44. package/app/composables/cart/registry.ts +7 -0
  45. package/app/composables/index.ts +1 -0
  46. package/app/composables/products/registry.ts +7 -0
  47. package/app/composables/registry.ts +21 -0
  48. package/app/composables/stores/cart.ts +2 -2
  49. package/app/composables/useCatalog.ts +64 -0
  50. package/app/composables/useContent.ts +57 -0
  51. package/app/composables/useProductReviews/useProductReviews.ts +1 -1
  52. package/app/composables/useProducts/types.ts +15 -10
  53. package/app/modules/vue-head/composables/useHead.ts +3 -0
  54. package/app/pages/brand/[...slug].vue +1 -1
  55. package/app/pages/departments/[...slug].vue +385 -0
  56. package/app/pages/departments/category/[...slug].vue +135 -0
  57. package/app/pages/product/[...id].vue +3 -3
  58. package/app/pages/shop/[...slug].vue +12 -18
  59. package/app/pages/shops.vue +18 -25
  60. package/dist/components/catalog/product/ProductAccordion/types.d.ts +4 -0
  61. package/dist/components/catalog/product/ProductAccordion/types.js +1 -0
  62. package/dist/components/catalog/product/ProductProperties/types.d.ts +4 -0
  63. package/dist/components/catalog/product/ProductProperties/types.js +1 -0
  64. package/dist/components/catalog/product/ProductSlider/types.d.ts +6 -0
  65. package/dist/components/catalog/product/ProductSlider/types.js +1 -0
  66. package/dist/components/catalog/product/RecommendedProducts/types.d.ts +4 -0
  67. package/dist/components/catalog/product/RecommendedProducts/types.js +1 -0
  68. package/dist/components/sales/CheckoutAddress/types.d.ts +14 -0
  69. package/dist/components/sales/CheckoutAddress/types.js +1 -0
  70. package/dist/components/sales/CheckoutPayment/types.d.ts +10 -0
  71. package/dist/components/sales/CheckoutPayment/types.js +7 -0
  72. package/dist/components/sales/OrderSummary/types.d.ts +4 -0
  73. package/dist/components/sales/OrderSummary/types.js +1 -0
  74. package/dist/composables/_types.d.ts +11 -0
  75. package/dist/composables/_types.js +1 -0
  76. package/dist/composables/adapters/abstract/cartAdapter.d.ts +0 -0
  77. package/dist/composables/adapters/abstract/cartAdapter.js +0 -0
  78. package/dist/composables/adapters/abstract/categoryAdapter.d.ts +0 -0
  79. package/dist/composables/adapters/abstract/categoryAdapter.js +0 -0
  80. package/dist/composables/adapters/abstract/customerAdapter.d.ts +0 -0
  81. package/dist/composables/adapters/abstract/customerAdapter.js +0 -0
  82. package/dist/composables/adapters/abstract/inventoryAdapter.d.ts +0 -0
  83. package/dist/composables/adapters/abstract/inventoryAdapter.js +0 -0
  84. package/dist/composables/adapters/abstract/orderAdapter.d.ts +0 -0
  85. package/dist/composables/adapters/abstract/orderAdapter.js +0 -0
  86. package/dist/composables/adapters/abstract/productAdapter.d.ts +6 -0
  87. package/dist/composables/adapters/abstract/productAdapter.js +1 -0
  88. package/dist/composables/cart/registry.d.ts +4 -0
  89. package/dist/composables/cart/registry.js +16 -0
  90. package/dist/composables/cart/types.d.ts +16 -0
  91. package/dist/composables/cart/types.js +1 -0
  92. package/dist/composables/cart/useCart.d.ts +6 -0
  93. package/dist/composables/cart/useCart.js +13 -0
  94. package/dist/composables/config.d.ts +7 -0
  95. package/dist/composables/config.js +11 -0
  96. package/dist/composables/defs/apiDefinitions.d.ts +7 -0
  97. package/dist/composables/defs/apiDefinitions.js +39 -0
  98. package/dist/composables/defs/extension.d.ts +91 -0
  99. package/dist/composables/defs/extension.js +154 -0
  100. package/dist/composables/defs/extension.mocks.d.ts +30 -0
  101. package/dist/composables/defs/extension.mocks.js +23 -0
  102. package/dist/composables/defs/extension.test.d.ts +1 -0
  103. package/dist/composables/defs/extension.test.js +233 -0
  104. package/dist/composables/defs/index.d.ts +3 -0
  105. package/dist/composables/defs/index.js +3 -0
  106. package/dist/composables/defs/types.d.ts +81 -0
  107. package/dist/composables/defs/types.js +1 -0
  108. package/dist/composables/domain/cart.d.ts +0 -0
  109. package/dist/composables/domain/cart.js +0 -0
  110. package/dist/composables/domain/category.d.ts +0 -0
  111. package/dist/composables/domain/category.js +0 -0
  112. package/dist/composables/domain/order.d.ts +0 -0
  113. package/dist/composables/domain/order.js +0 -0
  114. package/dist/composables/domain/price.d.ts +0 -0
  115. package/dist/composables/domain/price.js +0 -0
  116. package/dist/composables/domain/product.d.ts +8 -0
  117. package/dist/composables/domain/product.js +1 -0
  118. package/dist/composables/domain/reward.d.ts +0 -0
  119. package/dist/composables/domain/reward.js +0 -0
  120. package/dist/composables/domain/transactions.d.ts +0 -0
  121. package/dist/composables/domain/transactions.js +0 -0
  122. package/dist/composables/helpers/contextualizedNormalizers.d.ts +5 -0
  123. package/dist/composables/helpers/contextualizedNormalizers.js +6 -0
  124. package/dist/composables/helpers/contextualizedNormalizers.test.d.ts +1 -0
  125. package/dist/composables/helpers/contextualizedNormalizers.test.js +62 -0
  126. package/dist/composables/helpers/index.d.ts +1 -0
  127. package/dist/composables/helpers/index.js +1 -0
  128. package/dist/composables/index.d.ts +6 -0
  129. package/dist/composables/index.js +6 -0
  130. package/dist/composables/methods/auth.d.ts +62 -0
  131. package/dist/composables/methods/auth.js +1 -0
  132. package/dist/composables/methods/cart.d.ts +101 -0
  133. package/dist/composables/methods/cart.js +1 -0
  134. package/dist/composables/methods/category.d.ts +22 -0
  135. package/dist/composables/methods/category.js +1 -0
  136. package/dist/composables/methods/checkout.d.ts +42 -0
  137. package/dist/composables/methods/checkout.js +1 -0
  138. package/dist/composables/methods/customer.d.ts +39 -0
  139. package/dist/composables/methods/customer.js +1 -0
  140. package/dist/composables/methods/helpers.d.ts +2 -0
  141. package/dist/composables/methods/helpers.js +3 -0
  142. package/dist/composables/methods/index.d.ts +49 -0
  143. package/dist/composables/methods/index.js +9 -0
  144. package/dist/composables/methods/order.d.ts +29 -0
  145. package/dist/composables/methods/order.js +1 -0
  146. package/dist/composables/methods/product.d.ts +71 -0
  147. package/dist/composables/methods/product.js +1 -0
  148. package/dist/composables/methods/settings.d.ts +12 -0
  149. package/dist/composables/methods/settings.js +1 -0
  150. package/dist/composables/models/cart.d.ts +84 -0
  151. package/dist/composables/models/cart.js +1 -0
  152. package/dist/composables/models/category.d.ts +12 -0
  153. package/dist/composables/models/category.js +1 -0
  154. package/dist/composables/models/checkout.d.ts +15 -0
  155. package/dist/composables/models/checkout.js +1 -0
  156. package/dist/composables/models/customer.d.ts +14 -0
  157. package/dist/composables/models/customer.js +1 -0
  158. package/dist/composables/models/facets.d.ts +21 -0
  159. package/dist/composables/models/facets.js +5 -0
  160. package/dist/composables/models/index.d.ts +62 -0
  161. package/dist/composables/models/index.js +8 -0
  162. package/dist/composables/models/order.d.ts +39 -0
  163. package/dist/composables/models/order.js +1 -0
  164. package/dist/composables/models/product.d.ts +55 -0
  165. package/dist/composables/models/product.js +1 -0
  166. package/dist/composables/models/shared.d.ts +66 -0
  167. package/dist/composables/models/shared.js +1 -0
  168. package/dist/composables/products/registry.d.ts +4 -0
  169. package/dist/composables/products/registry.js +16 -0
  170. package/dist/composables/products/types.d.ts +12 -0
  171. package/dist/composables/products/types.js +1 -0
  172. package/dist/composables/products/useEvents.d.ts +0 -0
  173. package/dist/composables/products/useEvents.js +0 -0
  174. package/dist/composables/products/useGiftCards.d.ts +0 -0
  175. package/dist/composables/products/useGiftCards.js +0 -0
  176. package/dist/composables/products/useProducts.d.ts +4 -0
  177. package/dist/composables/products/useProducts.js +10 -0
  178. package/dist/composables/products/useSubscriptions.d.ts +0 -0
  179. package/dist/composables/products/useSubscriptions.js +0 -0
  180. package/dist/composables/registry.d.ts +9 -0
  181. package/dist/composables/registry.js +13 -0
  182. package/dist/composables/stores/cart.d.ts +1 -0
  183. package/dist/composables/stores/cart.js +203 -0
  184. package/dist/composables/stores/cartStore.d.ts +1 -0
  185. package/dist/composables/stores/cartStore.js +246 -0
  186. package/dist/composables/stores/checkout.d.ts +1 -0
  187. package/dist/composables/stores/checkout.js +17 -0
  188. package/dist/composables/stores/compare.d.ts +1 -0
  189. package/dist/composables/stores/compare.js +50 -0
  190. package/dist/composables/stores/orders.d.ts +1 -0
  191. package/dist/composables/stores/orders.js +156 -0
  192. package/dist/composables/stores/product.d.ts +1 -0
  193. package/dist/composables/stores/product.js +26 -0
  194. package/dist/composables/stores/productList.d.ts +0 -0
  195. package/dist/composables/stores/productList.js +0 -0
  196. package/dist/composables/stores/productListInfo.d.ts +0 -0
  197. package/dist/composables/stores/productListInfo.js +0 -0
  198. package/dist/composables/stores/products.d.ts +1 -0
  199. package/dist/composables/stores/products.js +106 -0
  200. package/dist/composables/stores/recentlyViewedProducts.d.ts +0 -0
  201. package/dist/composables/stores/recentlyViewedProducts.js +0 -0
  202. package/dist/composables/stores/review.d.ts +1 -0
  203. package/dist/composables/stores/review.js +25 -0
  204. package/dist/composables/stores/storeInPickUp.d.ts +1 -0
  205. package/dist/composables/stores/storeInPickUp.js +21 -0
  206. package/dist/composables/stores/user.d.ts +1 -0
  207. package/dist/composables/stores/user.js +16 -0
  208. package/dist/composables/stores/wishlist.d.ts +1 -0
  209. package/dist/composables/stores/wishlist.js +17 -0
  210. package/dist/composables/types/Order.type.d.ts +141 -0
  211. package/dist/composables/types/Order.type.js +1 -0
  212. package/dist/composables/types/index.d.ts +265 -0
  213. package/dist/composables/types/index.js +3 -0
  214. package/dist/composables/types/product.d.ts +13 -0
  215. package/dist/composables/types/product.js +1 -0
  216. package/dist/composables/useBreakpoints/index.d.ts +1 -0
  217. package/dist/composables/useBreakpoints/index.js +1 -0
  218. package/dist/composables/useBreakpoints/useBreakpoints.d.ts +10 -0
  219. package/dist/composables/useBreakpoints/useBreakpoints.js +24 -0
  220. package/dist/composables/useCart/index.d.ts +1 -0
  221. package/dist/composables/useCart/index.js +1 -0
  222. package/dist/composables/useCart/types.d.ts +13 -0
  223. package/dist/composables/useCart/types.js +1 -0
  224. package/dist/composables/useCart/useCart.d.ts +8 -0
  225. package/dist/composables/useCart/useCart.js +43 -0
  226. package/dist/composables/useCartShippingMethods/index.d.ts +1 -0
  227. package/dist/composables/useCartShippingMethods/index.js +1 -0
  228. package/dist/composables/useCartShippingMethods/types.d.ts +13 -0
  229. package/dist/composables/useCartShippingMethods/types.js +1 -0
  230. package/dist/composables/useCartShippingMethods/useCartShippingMethods.d.ts +7 -0
  231. package/dist/composables/useCartShippingMethods/useCartShippingMethods.js +35 -0
  232. package/dist/composables/useCatalog.d.ts +13 -0
  233. package/dist/composables/useCatalog.js +61 -0
  234. package/dist/composables/useContent/index.d.ts +1 -0
  235. package/dist/composables/useContent/index.js +1 -0
  236. package/dist/composables/useContent/types.d.ts +32 -0
  237. package/dist/composables/useContent/types.js +1 -0
  238. package/dist/composables/useContent/useContent.d.ts +9 -0
  239. package/dist/composables/useContent/useContent.js +43 -0
  240. package/dist/composables/useContent.d.ts +14 -0
  241. package/dist/composables/useContent.js +55 -0
  242. package/dist/composables/useCustomer/index.d.ts +2 -0
  243. package/dist/composables/useCustomer/index.js +2 -0
  244. package/dist/composables/useCustomer/types.d.ts +13 -0
  245. package/dist/composables/useCustomer/types.js +1 -0
  246. package/dist/composables/useCustomer/useCustomer.d.ts +8 -0
  247. package/dist/composables/useCustomer/useCustomer.js +34 -0
  248. package/dist/composables/useCustomerAddress/index.d.ts +2 -0
  249. package/dist/composables/useCustomerAddress/index.js +2 -0
  250. package/dist/composables/useCustomerAddress/types.d.ts +13 -0
  251. package/dist/composables/useCustomerAddress/types.js +1 -0
  252. package/dist/composables/useCustomerAddress/useCustomerAddress.d.ts +8 -0
  253. package/dist/composables/useCustomerAddress/useCustomerAddress.js +43 -0
  254. package/dist/composables/useCustomerOrder/adress.d.ts +11 -0
  255. package/dist/composables/useCustomerOrder/adress.js +10 -0
  256. package/dist/composables/useCustomerOrder/index.d.ts +2 -0
  257. package/dist/composables/useCustomerOrder/index.js +2 -0
  258. package/dist/composables/useCustomerOrder/product.d.ts +28 -0
  259. package/dist/composables/useCustomerOrder/product.js +37 -0
  260. package/dist/composables/useCustomerOrder/types.d.ts +32 -0
  261. package/dist/composables/useCustomerOrder/types.js +1 -0
  262. package/dist/composables/useCustomerOrder/useCustomerOrder.d.ts +8 -0
  263. package/dist/composables/useCustomerOrder/useCustomerOrder.js +52 -0
  264. package/dist/composables/useCustomerOrders/index.d.ts +2 -0
  265. package/dist/composables/useCustomerOrders/index.js +2 -0
  266. package/dist/composables/useCustomerOrders/types.d.ts +15 -0
  267. package/dist/composables/useCustomerOrders/types.js +1 -0
  268. package/dist/composables/useCustomerOrders/useCustomerOrders.d.ts +8 -0
  269. package/dist/composables/useCustomerOrders/useCustomerOrders.js +42 -0
  270. package/dist/composables/useCustomerReturns/index.d.ts +2 -0
  271. package/dist/composables/useCustomerReturns/index.js +2 -0
  272. package/dist/composables/useCustomerReturns/types.d.ts +13 -0
  273. package/dist/composables/useCustomerReturns/types.js +1 -0
  274. package/dist/composables/useCustomerReturns/useCustomerReturns.d.ts +8 -0
  275. package/dist/composables/useCustomerReturns/useCustomerReturns.js +32 -0
  276. package/dist/composables/useHandleError/index.d.ts +1 -0
  277. package/dist/composables/useHandleError/index.js +1 -0
  278. package/dist/composables/useHandleError/types.d.ts +7 -0
  279. package/dist/composables/useHandleError/types.js +1 -0
  280. package/dist/composables/useHandleError/useHandleError.d.ts +10 -0
  281. package/dist/composables/useHandleError/useHandleError.js +24 -0
  282. package/dist/composables/usePageTitle.d.ts +5 -0
  283. package/dist/composables/usePageTitle.js +14 -0
  284. package/dist/composables/useProduct/index.d.ts +2 -0
  285. package/dist/composables/useProduct/index.js +2 -0
  286. package/dist/composables/useProduct/types.d.ts +13 -0
  287. package/dist/composables/useProduct/types.js +1 -0
  288. package/dist/composables/useProduct/useProduct.d.ts +9 -0
  289. package/dist/composables/useProduct/useProduct.js +36 -0
  290. package/dist/composables/useProductAttribute/index.d.ts +1 -0
  291. package/dist/composables/useProductAttribute/index.js +1 -0
  292. package/dist/composables/useProductAttribute/useProductAttribute.d.ts +11 -0
  293. package/dist/composables/useProductAttribute/useProductAttribute.js +25 -0
  294. package/dist/composables/useProductRecommended/index.d.ts +1 -0
  295. package/dist/composables/useProductRecommended/index.js +1 -0
  296. package/dist/composables/useProductRecommended/types.d.ts +13 -0
  297. package/dist/composables/useProductRecommended/types.js +1 -0
  298. package/dist/composables/useProductRecommended/useProductRecommended.d.ts +6 -0
  299. package/dist/composables/useProductRecommended/useProductRecommended.js +33 -0
  300. package/dist/composables/useProductReviews/index.d.ts +2 -0
  301. package/dist/composables/useProductReviews/index.js +2 -0
  302. package/dist/composables/useProductReviews/types.d.ts +13 -0
  303. package/dist/composables/useProductReviews/types.js +1 -0
  304. package/dist/composables/useProductReviews/useProductReviews.d.ts +9 -0
  305. package/dist/composables/useProductReviews/useProductReviews.js +36 -0
  306. package/dist/composables/useProducts/types.d.ts +18 -0
  307. package/dist/composables/useProducts/types.js +1 -0
  308. package/dist/composables/useProducts/useProducts.d.ts +8 -0
  309. package/dist/composables/useProducts/useProducts.js +35 -0
  310. package/dist/composables/utils/countryList.d.ts +5 -0
  311. package/dist/composables/utils/countryList.js +14 -0
  312. package/dist/composables/utils/glossary.d.ts +0 -0
  313. package/dist/composables/utils/glossary.js +0 -0
  314. package/dist/composables/utils/importExport.d.ts +0 -0
  315. package/dist/composables/utils/importExport.js +0 -0
  316. package/dist/composables/utils/print.d.ts +0 -0
  317. package/dist/composables/utils/print.js +0 -0
  318. package/dist/composables/utils/shopThemes.d.ts +0 -0
  319. package/dist/composables/utils/shopThemes.js +0 -0
  320. package/dist/composables/utils/statistics.d.ts +0 -0
  321. package/dist/composables/utils/statistics.js +0 -0
  322. package/dist/composables/utils/stock.d.ts +0 -0
  323. package/dist/composables/utils/stock.js +0 -0
  324. package/dist/composables/utils/stripe.d.ts +7 -0
  325. package/dist/composables/utils/stripe.js +14 -0
  326. package/dist/composables/utils/taxation.d.ts +0 -0
  327. package/dist/composables/utils/taxation.js +0 -0
  328. package/dist/composables/utils/tellFriends.d.ts +0 -0
  329. package/dist/composables/utils/tellFriends.js +0 -0
  330. package/dist/composables/validationRules/index.d.ts +1 -0
  331. package/dist/composables/validationRules/index.js +1 -0
  332. package/dist/composables/validationRules/password.d.ts +1 -0
  333. package/dist/composables/validationRules/password.js +20 -0
  334. package/dist/composables/validationRules/password.test.d.ts +1 -0
  335. package/dist/composables/validationRules/password.test.js +68 -0
  336. package/dist/composables/vendors/index.d.ts +0 -0
  337. package/dist/composables/vendors/index.js +0 -0
  338. package/dist/composables/vendors/registry.d.ts +0 -0
  339. package/dist/composables/vendors/registry.js +0 -0
  340. package/dist/composables/vendors/useAffiliates.d.ts +0 -0
  341. package/dist/composables/vendors/useAffiliates.js +0 -0
  342. package/dist/composables/vendors/useCommission.d.ts +0 -0
  343. package/dist/composables/vendors/useCommission.js +0 -0
  344. package/dist/modules/vue-head/composables/useHead.d.ts +1 -0
  345. package/dist/modules/vue-head/composables/useHead.js +3 -0
  346. package/dist/utils/client.d.ts +6 -0
  347. package/dist/utils/client.js +23 -0
  348. package/dist/utils/index.d.ts +15 -0
  349. package/dist/utils/index.js +38 -0
  350. package/dist/utils/normalizer.d.ts +12 -0
  351. package/dist/utils/normalizer.js +13 -0
  352. package/dist/utils/normalizers/magento.d.ts +3 -0
  353. package/dist/utils/normalizers/magento.js +23 -0
  354. package/dist/utils/normalizers/shopify.d.ts +3 -0
  355. package/dist/utils/normalizers/shopify.js +24 -0
  356. package/global.d.ts +149 -0
  357. package/package.json +2 -1
  358. package/tsconfig.json +19 -3
@@ -0,0 +1,23 @@
1
+ export const normalizers = {
2
+ normalizeMoney: (rawMoney, ctx) => ({
3
+ amount: rawMoney.amount,
4
+ currency: ctx.currency,
5
+ }),
6
+ normalizeProductCatalogItem: (rawProduct) => ({
7
+ id: rawProduct.id,
8
+ name: rawProduct.name,
9
+ }),
10
+ };
11
+ export const rawMoneyMock = {
12
+ amount: 10,
13
+ formattedAmount: "10.00",
14
+ decimalPlaces: 2,
15
+ };
16
+ export const methods = {
17
+ getSuccess() {
18
+ return Promise.resolve({ ok: true });
19
+ },
20
+ };
21
+ export const getAdditionalNormalizerContext = () => ({
22
+ sku: "123",
23
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,233 @@
1
+ import { defineFeature, loadFeature } from "jest-cucumber";
2
+ import { beforeEach, expect } from "vitest";
3
+ import { unifiedExtensionFactory } from "./extension";
4
+ import { getAdditionalNormalizerContext, methods, normalizers, rawMoneyMock, } from "./extension.mocks";
5
+ const feature = loadFeature("./extension.feature", {
6
+ loadRelativePath: true,
7
+ });
8
+ defineFeature(feature, (test) => {
9
+ let overrideNormalizers;
10
+ let addCustomFields;
11
+ let overrideApiMethods;
12
+ const createUnifiedExtension = unifiedExtensionFactory({
13
+ normalizers,
14
+ extendApiMethods: methods,
15
+ getAdditionalNormalizerContext,
16
+ });
17
+ let extension;
18
+ beforeEach(() => {
19
+ overrideNormalizers = {};
20
+ addCustomFields = [{}];
21
+ overrideApiMethods = {};
22
+ });
23
+ function whenTheExtensionIsCreated(when) {
24
+ when("extension is created", () => {
25
+ extension = createUnifiedExtension({
26
+ normalizers: {
27
+ override: overrideNormalizers,
28
+ addCustomFields,
29
+ },
30
+ methods: {
31
+ override: overrideApiMethods,
32
+ },
33
+ config: {},
34
+ });
35
+ });
36
+ }
37
+ test("Overriding normalizer", ({ given, when, and, then }) => {
38
+ let result;
39
+ given("one of the normalizers is overridden", () => {
40
+ overrideNormalizers = {
41
+ normalizeMoney(rawMoney) {
42
+ return {
43
+ amount: rawMoney.amount,
44
+ currency: "USD",
45
+ };
46
+ },
47
+ };
48
+ });
49
+ whenTheExtensionIsCreated(when);
50
+ and("the normalizer is called", () => {
51
+ result = extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" });
52
+ });
53
+ then("the overridden normalizer should be called", () => {
54
+ expect(result).toMatchInlineSnapshot(`
55
+ {
56
+ "amount": 10,
57
+ "currency": "USD",
58
+ }
59
+ `);
60
+ });
61
+ and("remaining normalizers should be unchanged", () => {
62
+ expect(extension.normalizers.normalizeProductCatalogItem).toBeDefined();
63
+ });
64
+ });
65
+ test("Add custom fields array with a single element", ({ given, when, and, then }) => {
66
+ let result;
67
+ given("a custom field is added to one of the normalizers", () => {
68
+ addCustomFields = [
69
+ {
70
+ normalizeMoney: ({ formattedAmount }) => ({
71
+ formattedAmount,
72
+ }),
73
+ },
74
+ ];
75
+ });
76
+ whenTheExtensionIsCreated(when);
77
+ and("the normalizer is called", () => {
78
+ result = extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" });
79
+ });
80
+ then("the custom field should be present in the $custom object", () => {
81
+ expect(result).toMatchInlineSnapshot(`
82
+ {
83
+ "$custom": {
84
+ "formattedAmount": "10.00",
85
+ },
86
+ "amount": 10,
87
+ "currency": "PLN",
88
+ }
89
+ `);
90
+ });
91
+ and("remaining normalizers should be unchanged", () => {
92
+ expect(extension.normalizers.normalizeProductCatalogItem).toBeDefined();
93
+ });
94
+ });
95
+ test("Add custom fields array with multiple elements", ({ given, when, and, then }) => {
96
+ given("multiple elements of the addCustomFields array override the same normalizer", () => {
97
+ addCustomFields = [
98
+ {
99
+ normalizeMoney: ({ formattedAmount }) => ({
100
+ formattedAmount,
101
+ }),
102
+ },
103
+ {
104
+ normalizeMoney: ({ decimalPlaces }) => ({
105
+ decimalPlaces,
106
+ }),
107
+ },
108
+ ];
109
+ });
110
+ whenTheExtensionIsCreated(when);
111
+ and("the normalizer is called", () => {
112
+ extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" });
113
+ });
114
+ then("all custom fields should be present in the $custom object", () => {
115
+ expect(extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" }))
116
+ .toMatchInlineSnapshot(`
117
+ {
118
+ "$custom": {
119
+ "decimalPlaces": 2,
120
+ "formattedAmount": "10.00",
121
+ },
122
+ "amount": 10,
123
+ "currency": "PLN",
124
+ }
125
+ `);
126
+ });
127
+ });
128
+ test("Nested custom fields", ({ given, and, when, then }) => {
129
+ let result;
130
+ given("multiple elements of the addCustomFields array override the same normalizer", () => {
131
+ addCustomFields = [
132
+ {
133
+ normalizeMoney: () => ({
134
+ nested: {
135
+ nested_field1: "value1",
136
+ nestedLvl2: {
137
+ nestedLvl2_field1: "value1",
138
+ },
139
+ },
140
+ }),
141
+ },
142
+ {
143
+ normalizeMoney: () => ({
144
+ nested: {
145
+ nested_field2: "value2",
146
+ },
147
+ nested2: {
148
+ nested2_field1: "value3",
149
+ },
150
+ }),
151
+ },
152
+ ];
153
+ });
154
+ and("custom fields are objects", () => { });
155
+ whenTheExtensionIsCreated(when);
156
+ and("the normalizer is called", () => {
157
+ result = extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" });
158
+ });
159
+ then("objects should be merged into the $custom object", () => {
160
+ expect(result).toMatchInlineSnapshot(`
161
+ {
162
+ "$custom": {
163
+ "nested": {
164
+ "nestedLvl2": {
165
+ "nestedLvl2_field1": "value1",
166
+ },
167
+ "nested_field1": "value1",
168
+ "nested_field2": "value2",
169
+ },
170
+ "nested2": {
171
+ "nested2_field1": "value3",
172
+ },
173
+ },
174
+ "amount": 10,
175
+ "currency": "PLN",
176
+ }
177
+ `);
178
+ });
179
+ });
180
+ test("Adding the same custom fields more than once", ({ given, when, and, then }) => {
181
+ let result;
182
+ given("multiple elements of the addCustomFields array add the same custom field", () => {
183
+ addCustomFields = [
184
+ {
185
+ normalizeMoney: ({ formattedAmount, decimalPlaces }) => ({
186
+ formattedAmount,
187
+ decimalPlaces,
188
+ }),
189
+ },
190
+ {
191
+ normalizeMoney: () => ({
192
+ formattedAmount: "overridden",
193
+ }),
194
+ },
195
+ ];
196
+ });
197
+ whenTheExtensionIsCreated(when);
198
+ and("the normalizer is called", () => {
199
+ result = extension.normalizers.normalizeMoney(rawMoneyMock, { currency: "PLN" });
200
+ });
201
+ then("the custom field should have value based on the last element of the addCustomFields array", () => {
202
+ expect(result).toMatchInlineSnapshot(`
203
+ {
204
+ "$custom": {
205
+ "decimalPlaces": 2,
206
+ "formattedAmount": "overridden",
207
+ },
208
+ "amount": 10,
209
+ "currency": "PLN",
210
+ }
211
+ `);
212
+ });
213
+ });
214
+ test("Overriding api method", ({ given, when, and, then }) => {
215
+ let result;
216
+ given("one of the api methods is overridden", () => {
217
+ overrideApiMethods = {
218
+ getSuccess: () => Promise.resolve({ ok: false }),
219
+ };
220
+ });
221
+ whenTheExtensionIsCreated(when);
222
+ and("the api method is called", async () => {
223
+ result = await extension.extendApiMethods.getSuccess();
224
+ });
225
+ then("the overridden api method should be called", () => {
226
+ expect(result).toMatchInlineSnapshot(`
227
+ {
228
+ "ok": false,
229
+ }
230
+ `);
231
+ });
232
+ });
233
+ });
@@ -0,0 +1,3 @@
1
+ export * from "./apiDefinitions";
2
+ export * from "./extension";
3
+ export * from "./types";
@@ -0,0 +1,3 @@
1
+ export * from "./apiDefinitions";
2
+ export * from "./extension";
3
+ export * from "./types";
@@ -0,0 +1,81 @@
1
+ type ApiMethods = Record<string, (...args: any[]) => any>;
2
+ import type { MergeDeep } from "type-fest";
3
+ import type { ContextualizedNormalizers } from "../helpers";
4
+ import type { Maybe, SfCurrency, SfFacetType } from "../models";
5
+ export interface IntegrationContext<CLIENT = any, CONFIG = any, API = any> {
6
+ client: CLIENT;
7
+ config: CONFIG;
8
+ api: API;
9
+ req?: any;
10
+ res?: any;
11
+ [x: string]: any;
12
+ }
13
+ export interface VSFLogger {
14
+ debug(message?: any, ...args: any[]): void;
15
+ info(message?: any, ...args: any[]): void;
16
+ warn(message?: any, ...args: any[]): void;
17
+ error(message?: any, ...args: any[]): void;
18
+ }
19
+ export interface UnifiedConfig {
20
+ currencies?: SfCurrency[];
21
+ defaultCurrency: SfCurrency;
22
+ }
23
+ export interface BaseNormalizerContext<TNormalizers extends NormalizersConstraint = any> {
24
+ locale: string;
25
+ currency: string;
26
+ normalizers: ContextualizedNormalizers<TNormalizers>;
27
+ logger: VSFLogger;
28
+ }
29
+ export type NormalizerConstraint<TNormalizerContext extends BaseNormalizerContext = BaseNormalizerContext> = (rawData: any, context: TNormalizerContext) => any;
30
+ export type NormalizersConstraint<TNormalizerContext extends BaseNormalizerContext = any> = Record<string, NormalizerConstraint<TNormalizerContext>>;
31
+ export type UnifiedExtensionContextConstraint<TNormalizerContext extends BaseNormalizerContext = any> = IntegrationContext & {
32
+ config: {
33
+ normalizerContext: TNormalizerContext;
34
+ };
35
+ };
36
+ export type GetFacetTypeFn<TInput> = (input: TInput) => Maybe<SfFacetType | string>;
37
+ export type FilterFacetsFn<TInput> = (input: TInput) => boolean;
38
+ export type GetAdditionalNormalizerContextParams<TConfig extends Record<string, any> = any> = {
39
+ req: IntegrationContext["req"];
40
+ res: IntegrationContext["res"];
41
+ config: TConfig;
42
+ };
43
+ export type GetAdditionalNormalizerContextConstraint = (params: GetAdditionalNormalizerContextParams) => any;
44
+ export type GetAdditionalNormalizerContext<TIntegrationContext extends IntegrationContext, TNormalizerContext extends BaseNormalizerContext> = (params: GetAdditionalNormalizerContextParams<TIntegrationContext["config"]>) => Omit<TNormalizerContext, keyof BaseNormalizerContext>;
45
+ export interface AddCustomFields {
46
+ }
47
+ export type InferAddCustomFieldsFromArray<TArray extends Record<string, (...args: any) => any>[], TResult = {}> = TArray extends [
48
+ infer THead extends Record<string, (...args: any) => any>,
49
+ ...infer TTail extends Record<string, (...args: any) => any>[]
50
+ ] ? InferAddCustomFieldsFromArray<TTail, MergeDeep<TResult, {
51
+ [TKey in keyof THead]: Exclude<ReturnType<THead[TKey]>, null | undefined>;
52
+ }>> : TResult;
53
+ export type InferAddCustomFields<TUnifiedExtension extends {
54
+ _addCustomFields: any;
55
+ }> = InferAddCustomFieldsFromArray<TUnifiedExtension["_addCustomFields"]>;
56
+ export type InferCustom<TNormalizer extends string> = AddCustomFields extends Record<TNormalizer, infer TCustom> ? TCustom : object;
57
+ export type DefineAddCustomFields<TNormalizers extends NormalizersConstraint> = {
58
+ [Key in keyof TNormalizers]?: (...args: Parameters<TNormalizers[Key]>) => any;
59
+ };
60
+ export interface NormalizersConfig<TNormalizers extends NormalizersConstraint, TAddCustomFieldsArray> {
61
+ override?: Partial<TNormalizers>;
62
+ addCustomFields: TAddCustomFieldsArray;
63
+ }
64
+ export interface UnifiedExtensionFactoryParams<TApiMethods extends ApiMethods, TNormalizers extends NormalizersConstraint> {
65
+ normalizers: TNormalizers;
66
+ extendApiMethods: TApiMethods;
67
+ getAdditionalNormalizerContext: GetAdditionalNormalizerContextConstraint;
68
+ isNamespaced?: boolean;
69
+ }
70
+ export interface CreateUnifiedExtensionParams<TConfig extends Record<string, any>, TApiMethods extends ApiMethods, TNormalizers extends NormalizersConstraint, TAddCustomFieldsArray extends DefineAddCustomFields<TNormalizers>[]> {
71
+ config: TConfig;
72
+ normalizers: NormalizersConfig<TNormalizers, TAddCustomFieldsArray>;
73
+ methods?: {
74
+ override?: Partial<TApiMethods>;
75
+ };
76
+ isNamespaced?: boolean;
77
+ }
78
+ export interface UnifiedCmsConfig<TNormalizers extends NormalizersConstraint, TAddCustomFieldsArray = DefineAddCustomFields<TNormalizers>[]> {
79
+ normalizers?: NormalizersConfig<TNormalizers, TAddCustomFieldsArray>;
80
+ }
81
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ export interface Product {
2
+ id: string;
3
+ title: string;
4
+ description: string;
5
+ images: string[];
6
+ price: Price;
7
+ variants?: ProductVariant[];
8
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ import type { NormalizersConstraint } from "../defs";
2
+ export type ContextualizedNormalizers<TNormalizers extends NormalizersConstraint> = {
3
+ [TKey in keyof TNormalizers]: (input: Parameters<TNormalizers[TKey]>[1]) => ReturnType<TNormalizers[TKey]>;
4
+ };
5
+ export declare function toContextualizedNormalizers<TNormalizers extends NormalizersConstraint, TNormalizerContext extends Record<string, any>>(normalizers: TNormalizers, getContext: () => TNormalizerContext): ContextualizedNormalizers<TNormalizers>;
@@ -0,0 +1,6 @@
1
+ export function toContextualizedNormalizers(normalizers, getContext) {
2
+ return Object.keys(normalizers).reduce((acc, key) => {
3
+ acc[key] = (input) => normalizers[key](getContext(), input);
4
+ return { ...acc };
5
+ }, {});
6
+ }
@@ -0,0 +1,62 @@
1
+ import { defineFeature, loadFeature } from "jest-cucumber";
2
+ import { toContextualizedNormalizers } from "./contextualizedNormalizers";
3
+ import { beforeEach, expect, vi } from "vitest";
4
+ const feature = loadFeature("./contextualizedNormalizers.feature", { loadRelativePath: true });
5
+ defineFeature(feature, (test) => {
6
+ let testNormalizers;
7
+ let output;
8
+ let context;
9
+ beforeEach(() => {
10
+ context = {
11
+ currency: "USD",
12
+ locale: "en",
13
+ };
14
+ });
15
+ test("Context is passed to normalizers", ({ given, when, and, then }) => {
16
+ given("a normalizer that requires a context as a second argument", () => {
17
+ testNormalizers = {
18
+ normalizeMoney: vi.fn((context, input) => {
19
+ return {
20
+ amount: input,
21
+ currency: context.currency,
22
+ precisionAmount: input.toFixed(2),
23
+ };
24
+ }),
25
+ };
26
+ });
27
+ when("toContextualizedNormalizers function is called", () => {
28
+ output = toContextualizedNormalizers(testNormalizers, () => context);
29
+ });
30
+ and("the normalizer is called with just an input", () => {
31
+ output.normalizeMoney(100);
32
+ });
33
+ then("the normalizer should also receive the context", () => {
34
+ expect(testNormalizers.normalizeMoney).toHaveBeenCalledWith(context, 100);
35
+ });
36
+ });
37
+ test("Context changes", ({ given, when, and, then }) => {
38
+ given("a normalizer that requires a context as a second argument", () => {
39
+ testNormalizers = {
40
+ normalizeMoney: vi.fn((context, input) => {
41
+ return {
42
+ amount: input,
43
+ currency: context.currency,
44
+ precisionAmount: input.toFixed(2),
45
+ };
46
+ }),
47
+ };
48
+ });
49
+ when("toContextualizedNormalizers function is called", () => {
50
+ output = toContextualizedNormalizers(testNormalizers, () => context);
51
+ });
52
+ and("the context changes", () => {
53
+ context.currency = "EUR";
54
+ });
55
+ and("the normalizer is called with just an input", () => {
56
+ output.normalizeMoney(100);
57
+ });
58
+ then("the normalizer should use the recent version of the context", () => {
59
+ expect(testNormalizers.normalizeMoney).toHaveBeenCalledWith(expect.objectContaining({ currency: "EUR" }), expect.anything());
60
+ });
61
+ });
62
+ });
@@ -0,0 +1 @@
1
+ export * from "./contextualizedNormalizers";
@@ -0,0 +1 @@
1
+ export * from "./contextualizedNormalizers";
@@ -0,0 +1,6 @@
1
+ export * from "./defs";
2
+ export * from "./helpers";
3
+ export * from "./methods";
4
+ export * from "./models";
5
+ export * from "./validationRules";
6
+ export * from "./registry";
@@ -0,0 +1,6 @@
1
+ export * from "./defs";
2
+ export * from "./helpers";
3
+ export * from "./methods";
4
+ export * from "./models";
5
+ export * from "./validationRules";
6
+ export * from "./registry";
@@ -0,0 +1,62 @@
1
+ import type { Simplify } from "type-fest";
2
+ import type { Maybe, SfCustomer } from "../models";
3
+ export interface RegisterCustomerExtendedArgs {
4
+ }
5
+ export interface RegisterCustomerCustomArgs {
6
+ }
7
+ export type RegisterCustomerArgs = {
8
+ email: string;
9
+ firstName: string;
10
+ lastName: string;
11
+ password: string;
12
+ };
13
+ export type RegisterCustomer = (args: Simplify<RegisterCustomerArgs>) => Promise<{
14
+ customer: SfCustomer;
15
+ }>;
16
+ export interface LoginCustomerExtendedArgs {
17
+ }
18
+ export interface LoginCustomerCustomArgs {
19
+ }
20
+ export type LoginCustomerArgs = {
21
+ email: string;
22
+ password: string;
23
+ };
24
+ export type LoginCustomer = (args: Simplify<LoginCustomerArgs>) => Promise<{
25
+ customer: SfCustomer;
26
+ }>;
27
+ export interface GetCustomerExtendedArgs {
28
+ }
29
+ export interface GetCustomerCustomArgs {
30
+ }
31
+ export type GetCustomerArgs = {};
32
+ export type GetCustomer = (args?: Simplify<GetCustomerArgs>) => Promise<{
33
+ customer: Maybe<SfCustomer>;
34
+ }>;
35
+ export interface LogoutCustomerExtendedArgs {
36
+ }
37
+ export interface LogoutCustomerCustomArgs {
38
+ }
39
+ export type LogoutCustomerArgs = {};
40
+ export type LogoutCustomer = (args?: Simplify<LogoutCustomerArgs>) => Promise<void>;
41
+ export interface UpdateCustomerExtendedArgs {
42
+ }
43
+ export interface UpdateCustomerCustomArgs {
44
+ }
45
+ export type UpdateCustomerArgs = {
46
+ email?: string;
47
+ firstName?: string;
48
+ lastName?: string;
49
+ };
50
+ export type UpdateCustomer = (args: Simplify<UpdateCustomerArgs>) => Promise<{
51
+ customer: SfCustomer;
52
+ }>;
53
+ export interface ChangeCustomerPasswordExtendedArgs {
54
+ }
55
+ export interface ChangeCustomerPasswordCustomArgs {
56
+ }
57
+ export type ChangeCustomerPasswordArgs = {
58
+ currentPassword: string;
59
+ newPassword: string;
60
+ confirmPassword: string;
61
+ };
62
+ export type ChangeCustomerPassword = (args: Simplify<ChangeCustomerPasswordArgs>) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import type { Simplify } from "type-fest";
2
+ import type { Maybe, SfCart } from "../models";
3
+ export interface GetCartExtendedArgs {
4
+ }
5
+ export interface GetCartCustomArgs {
6
+ }
7
+ export type GetCartArgs = {
8
+ /**
9
+ * Unique identifier of cart
10
+ */
11
+ cartId?: string;
12
+ };
13
+ export interface AddCartLineItemExtendedArgs {
14
+ }
15
+ export interface AddCartLineItemCustomArgs {
16
+ }
17
+ export type AddCartLineItemArgs = {
18
+ /**
19
+ * Product unique identifier - for commercetools it's a SKU, for sap it's a product code
20
+ */
21
+ productId: string;
22
+ sku: Maybe<string>;
23
+ /**
24
+ * Quantity of product to add to cart
25
+ * @default 1
26
+ */
27
+ quantity?: number;
28
+ /**
29
+ * Unique identifier of cart
30
+ */
31
+ cartId?: string;
32
+ };
33
+ export interface UpdateCartLineItemExtendedArgs {
34
+ }
35
+ export interface UpdateCartLineItemCustomArgs {
36
+ }
37
+ export type UpdateCartLineItemArgs = {
38
+ lineItemId: string;
39
+ quantity: number;
40
+ /**
41
+ * Unique identifier of cart
42
+ */
43
+ cartId?: string;
44
+ };
45
+ export interface RemoveCartLineItemExtendedArgs {
46
+ }
47
+ export interface RemoveCartLineItemCustomArgs {
48
+ }
49
+ export type RemoveCartLineItemArgs = {
50
+ lineItemId: string;
51
+ /**
52
+ * Unique identifier of cart
53
+ */
54
+ cartId?: string;
55
+ };
56
+ export interface ApplyCouponToCartExtendedArgs {
57
+ }
58
+ export interface ApplyCouponToCartCustomArgs {
59
+ }
60
+ export type ApplyCouponToCartArgs = {
61
+ couponCode: string;
62
+ /**
63
+ * Unique identifier of cart
64
+ */
65
+ cartId?: string;
66
+ };
67
+ export interface RemoveCouponFromCartExtendedArgs {
68
+ }
69
+ export interface RemoveCouponFromCartCustomArgs {
70
+ }
71
+ export type RemoveCouponFromCartArgs = {
72
+ /**
73
+ * Don't confuse it with coupon code. It can be retrieved from cart.appliedCoupons
74
+ */
75
+ couponId: string;
76
+ /**
77
+ * Unique identifier of cart
78
+ */
79
+ cartId?: string;
80
+ };
81
+ /**
82
+ * Get all information about customer's cart
83
+ */
84
+ export type GetCart = (args?: Simplify<GetCartArgs>) => Promise<SfCart>;
85
+ /**
86
+ * Add product to cart
87
+ */
88
+ export type AddCartLineItem = (args: Simplify<AddCartLineItemArgs>) => Promise<SfCart>;
89
+ /**
90
+ * Update product quantity in cart
91
+ */
92
+ export type UpdateCartLineItem = (args: Simplify<UpdateCartLineItemArgs>) => Promise<SfCart>;
93
+ /**
94
+ * Remove product from cart
95
+ */
96
+ export type RemoveCartLineItem = (args: Simplify<RemoveCartLineItemArgs>) => Promise<SfCart>;
97
+ /**
98
+ * Apply a coupon to cart to get a discount
99
+ */
100
+ export type ApplyCouponToCart = (args: Simplify<ApplyCouponToCartArgs>) => Promise<SfCart>;
101
+ export type RemoveCouponFromCart = (args: Simplify<RemoveCouponFromCartArgs>) => Promise<SfCart>;
@@ -0,0 +1 @@
1
+ export {};