@unchainedshop/core 3.0.0-alpha7 → 3.0.0-rc10

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 (462) hide show
  1. package/lib/core-index.d.ts +8 -61
  2. package/lib/core-index.d.ts.map +1 -1
  3. package/lib/core-index.js +9 -140
  4. package/lib/core-index.js.map +1 -1
  5. package/lib/directors/BaseDiscountAdapter.d.ts +36 -0
  6. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -0
  7. package/lib/directors/BaseDiscountAdapter.js +48 -0
  8. package/lib/directors/BaseDiscountAdapter.js.map +1 -0
  9. package/lib/directors/BaseDiscountDirector.d.ts +15 -0
  10. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -0
  11. package/lib/directors/BaseDiscountDirector.js +45 -0
  12. package/lib/directors/BaseDiscountDirector.js.map +1 -0
  13. package/lib/directors/BasePricingAdapter.d.ts +34 -0
  14. package/lib/directors/BasePricingAdapter.d.ts.map +1 -0
  15. package/lib/directors/BasePricingAdapter.js +25 -0
  16. package/lib/directors/BasePricingAdapter.js.map +1 -0
  17. package/lib/directors/BasePricingDirector.d.ts +17 -0
  18. package/lib/directors/BasePricingDirector.d.ts.map +1 -0
  19. package/lib/directors/BasePricingDirector.js +70 -0
  20. package/lib/directors/BasePricingDirector.js.map +1 -0
  21. package/lib/directors/BasePricingSheet.d.ts +46 -0
  22. package/lib/directors/BasePricingSheet.d.ts.map +1 -0
  23. package/lib/directors/BasePricingSheet.js +74 -0
  24. package/lib/directors/BasePricingSheet.js.map +1 -0
  25. package/lib/directors/DeliveryAdapter.d.ts +46 -0
  26. package/lib/directors/DeliveryAdapter.d.ts.map +1 -0
  27. package/lib/directors/DeliveryAdapter.js +50 -0
  28. package/lib/directors/DeliveryAdapter.js.map +1 -0
  29. package/lib/directors/DeliveryDirector.d.ts +15 -0
  30. package/lib/directors/DeliveryDirector.d.ts.map +1 -0
  31. package/lib/directors/DeliveryDirector.js +96 -0
  32. package/lib/directors/DeliveryDirector.js.map +1 -0
  33. package/lib/directors/DeliveryPricingAdapter.d.ts +49 -0
  34. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -0
  35. package/lib/directors/DeliveryPricingAdapter.js +25 -0
  36. package/lib/directors/DeliveryPricingAdapter.js.map +1 -0
  37. package/lib/directors/DeliveryPricingDirector.d.ts +20 -0
  38. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -0
  39. package/lib/directors/DeliveryPricingDirector.js +50 -0
  40. package/lib/directors/DeliveryPricingDirector.js.map +1 -0
  41. package/lib/directors/DeliveryPricingSheet.d.ts +10 -0
  42. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -0
  43. package/lib/directors/DeliveryPricingSheet.js +75 -0
  44. package/lib/directors/DeliveryPricingSheet.js.map +1 -0
  45. package/lib/directors/EnrollmentAdapter.d.ts +27 -0
  46. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -0
  47. package/lib/directors/EnrollmentAdapter.js +73 -0
  48. package/lib/directors/EnrollmentAdapter.js.map +1 -0
  49. package/lib/directors/EnrollmentDirector.d.ts +14 -0
  50. package/lib/directors/EnrollmentDirector.d.ts.map +1 -0
  51. package/lib/directors/EnrollmentDirector.js +44 -0
  52. package/lib/directors/EnrollmentDirector.js.map +1 -0
  53. package/lib/directors/FilterAdapter.d.ts +54 -0
  54. package/lib/directors/FilterAdapter.d.ts.map +1 -0
  55. package/lib/directors/FilterAdapter.js +38 -0
  56. package/lib/directors/FilterAdapter.js.map +1 -0
  57. package/lib/directors/FilterDirector.d.ts +40 -0
  58. package/lib/directors/FilterDirector.d.ts.map +1 -0
  59. package/lib/directors/FilterDirector.js +173 -0
  60. package/lib/directors/FilterDirector.js.map +1 -0
  61. package/lib/directors/MessagingDirector.d.ts +46 -0
  62. package/lib/directors/MessagingDirector.d.ts.map +1 -0
  63. package/lib/directors/MessagingDirector.js +10 -0
  64. package/lib/directors/MessagingDirector.js.map +1 -0
  65. package/lib/directors/OrderDiscountAdapter.d.ts +3 -0
  66. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -0
  67. package/lib/directors/OrderDiscountAdapter.js +3 -0
  68. package/lib/directors/OrderDiscountAdapter.js.map +1 -0
  69. package/lib/directors/OrderDiscountConfiguration.d.ts +6 -0
  70. package/lib/directors/OrderDiscountConfiguration.d.ts.map +1 -0
  71. package/lib/directors/OrderDiscountConfiguration.js +2 -0
  72. package/lib/directors/OrderDiscountConfiguration.js.map +1 -0
  73. package/lib/directors/OrderDiscountDirector.d.ts +3 -0
  74. package/lib/directors/OrderDiscountDirector.d.ts.map +1 -0
  75. package/lib/directors/OrderDiscountDirector.js +3 -0
  76. package/lib/directors/OrderDiscountDirector.js.map +1 -0
  77. package/lib/directors/OrderPricingAdapter.d.ts +18 -0
  78. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -0
  79. package/lib/directors/OrderPricingAdapter.js +24 -0
  80. package/lib/directors/OrderPricingAdapter.js.map +1 -0
  81. package/lib/directors/OrderPricingDirector.d.ts +18 -0
  82. package/lib/directors/OrderPricingDirector.d.ts.map +1 -0
  83. package/lib/directors/OrderPricingDirector.js +31 -0
  84. package/lib/directors/OrderPricingDirector.js.map +1 -0
  85. package/lib/directors/OrderPricingSheet.d.ts +37 -0
  86. package/lib/directors/OrderPricingSheet.d.ts.map +1 -0
  87. package/lib/directors/OrderPricingSheet.js +108 -0
  88. package/lib/directors/OrderPricingSheet.js.map +1 -0
  89. package/lib/directors/PaymentAdapter.d.ts +50 -0
  90. package/lib/directors/PaymentAdapter.d.ts.map +1 -0
  91. package/lib/directors/PaymentAdapter.js +55 -0
  92. package/lib/directors/PaymentAdapter.js.map +1 -0
  93. package/lib/directors/PaymentDirector.d.ts +21 -0
  94. package/lib/directors/PaymentDirector.d.ts.map +1 -0
  95. package/lib/directors/PaymentDirector.js +172 -0
  96. package/lib/directors/PaymentDirector.js.map +1 -0
  97. package/lib/directors/PaymentPricingAdapter.d.ts +48 -0
  98. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -0
  99. package/lib/directors/PaymentPricingAdapter.js +25 -0
  100. package/lib/directors/PaymentPricingAdapter.js.map +1 -0
  101. package/lib/directors/PaymentPricingDirector.d.ts +18 -0
  102. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -0
  103. package/lib/directors/PaymentPricingDirector.js +51 -0
  104. package/lib/directors/PaymentPricingDirector.js.map +1 -0
  105. package/lib/directors/PaymentPricingSheet.d.ts +9 -0
  106. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -0
  107. package/lib/directors/PaymentPricingSheet.js +75 -0
  108. package/lib/directors/PaymentPricingSheet.js.map +1 -0
  109. package/lib/directors/ProductDiscountAdapter.d.ts +3 -0
  110. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -0
  111. package/lib/directors/ProductDiscountAdapter.js +3 -0
  112. package/lib/directors/ProductDiscountAdapter.js.map +1 -0
  113. package/lib/directors/ProductDiscountConfiguration.d.ts +13 -0
  114. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -0
  115. package/lib/directors/ProductDiscountConfiguration.js +2 -0
  116. package/lib/directors/ProductDiscountConfiguration.js.map +1 -0
  117. package/lib/directors/ProductDiscountDirector.d.ts +3 -0
  118. package/lib/directors/ProductDiscountDirector.d.ts.map +1 -0
  119. package/lib/directors/ProductDiscountDirector.js +3 -0
  120. package/lib/directors/ProductDiscountDirector.js.map +1 -0
  121. package/lib/directors/ProductPricingAdapter.d.ts +19 -0
  122. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -0
  123. package/lib/directors/ProductPricingAdapter.js +24 -0
  124. package/lib/directors/ProductPricingAdapter.js.map +1 -0
  125. package/lib/directors/ProductPricingDirector.d.ts +21 -0
  126. package/lib/directors/ProductPricingDirector.d.ts.map +1 -0
  127. package/lib/directors/ProductPricingDirector.js +52 -0
  128. package/lib/directors/ProductPricingDirector.js.map +1 -0
  129. package/lib/directors/ProductPricingSheet.d.ts +35 -0
  130. package/lib/directors/ProductPricingSheet.d.ts.map +1 -0
  131. package/lib/directors/ProductPricingSheet.js +83 -0
  132. package/lib/directors/ProductPricingSheet.js.map +1 -0
  133. package/lib/directors/QuotationAdapter.d.ts +28 -0
  134. package/lib/directors/QuotationAdapter.d.ts.map +1 -0
  135. package/lib/directors/QuotationAdapter.js +46 -0
  136. package/lib/directors/QuotationAdapter.js.map +1 -0
  137. package/lib/directors/QuotationDirector.d.ts +7 -0
  138. package/lib/directors/QuotationDirector.d.ts.map +1 -0
  139. package/lib/directors/QuotationDirector.js +84 -0
  140. package/lib/directors/QuotationDirector.js.map +1 -0
  141. package/lib/directors/WarehousingAdapter.d.ts +40 -0
  142. package/lib/directors/WarehousingAdapter.d.ts.map +1 -0
  143. package/lib/directors/WarehousingAdapter.js +32 -0
  144. package/lib/directors/WarehousingAdapter.js.map +1 -0
  145. package/lib/directors/WarehousingDirector.d.ts +41 -0
  146. package/lib/directors/WarehousingDirector.d.ts.map +1 -0
  147. package/lib/directors/WarehousingDirector.js +169 -0
  148. package/lib/directors/WarehousingDirector.js.map +1 -0
  149. package/lib/directors/WorkerAdapter.d.ts +17 -0
  150. package/lib/directors/WorkerAdapter.d.ts.map +1 -0
  151. package/lib/directors/WorkerAdapter.js +11 -0
  152. package/lib/directors/WorkerAdapter.js.map +1 -0
  153. package/lib/directors/WorkerDirector.d.ts +26 -0
  154. package/lib/directors/WorkerDirector.d.ts.map +1 -0
  155. package/lib/directors/WorkerDirector.js +102 -0
  156. package/lib/directors/WorkerDirector.js.map +1 -0
  157. package/lib/directors/index.d.ts +39 -0
  158. package/lib/directors/index.d.ts.map +1 -0
  159. package/lib/directors/index.js +39 -0
  160. package/lib/directors/index.js.map +1 -0
  161. package/lib/modules.d.ts +59 -0
  162. package/lib/modules.d.ts.map +1 -0
  163. package/lib/modules.js +126 -0
  164. package/lib/modules.js.map +1 -0
  165. package/lib/services/activateEnrollment.d.ts +4 -0
  166. package/lib/services/activateEnrollment.d.ts.map +1 -0
  167. package/lib/services/activateEnrollment.js +25 -0
  168. package/lib/services/activateEnrollment.js.map +1 -0
  169. package/lib/services/calculateDiscountTotal.d.ts +7 -0
  170. package/lib/services/calculateDiscountTotal.d.ts.map +1 -0
  171. package/lib/services/calculateDiscountTotal.js +49 -0
  172. package/lib/services/calculateDiscountTotal.js.map +1 -0
  173. package/lib/services/checkoutOrder.d.ts +9 -0
  174. package/lib/services/checkoutOrder.d.ts.map +1 -0
  175. package/lib/services/checkoutOrder.js +28 -0
  176. package/lib/services/checkoutOrder.js.map +1 -0
  177. package/lib/services/confirmOrder.d.ts +9 -0
  178. package/lib/services/confirmOrder.d.ts.map +1 -0
  179. package/lib/services/confirmOrder.js +17 -0
  180. package/lib/services/confirmOrder.js.map +1 -0
  181. package/lib/services/createDownloadStream.d.ts +5 -0
  182. package/lib/services/createDownloadStream.d.ts.map +1 -0
  183. package/lib/services/createDownloadStream.js +8 -0
  184. package/lib/services/createDownloadStream.js.map +1 -0
  185. package/lib/services/createEnrollmentFromCheckout.d.ts +15 -0
  186. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -0
  187. package/lib/services/createEnrollmentFromCheckout.js +40 -0
  188. package/lib/services/createEnrollmentFromCheckout.js.map +1 -0
  189. package/lib/services/createManualOrderDiscount.d.ts +7 -0
  190. package/lib/services/createManualOrderDiscount.d.ts.map +1 -0
  191. package/lib/services/createManualOrderDiscount.js +47 -0
  192. package/lib/services/createManualOrderDiscount.js.map +1 -0
  193. package/lib/services/createSignedURL.d.ts +8 -0
  194. package/lib/services/createSignedURL.d.ts.map +1 -0
  195. package/lib/services/createSignedURL.js +15 -0
  196. package/lib/services/createSignedURL.js.map +1 -0
  197. package/lib/services/deleteUser.d.ts +5 -0
  198. package/lib/services/deleteUser.d.ts.map +1 -0
  199. package/lib/services/deleteUser.js +26 -0
  200. package/lib/services/deleteUser.js.map +1 -0
  201. package/lib/services/discountedEntities.d.ts +5 -0
  202. package/lib/services/discountedEntities.d.ts.map +1 -0
  203. package/lib/services/discountedEntities.js +61 -0
  204. package/lib/services/discountedEntities.js.map +1 -0
  205. package/lib/services/ercMetadata.d.ts +7 -0
  206. package/lib/services/ercMetadata.d.ts.map +1 -0
  207. package/lib/services/ercMetadata.js +22 -0
  208. package/lib/services/ercMetadata.js.map +1 -0
  209. package/lib/services/findOrInitCart.d.ts +9 -0
  210. package/lib/services/findOrInitCart.d.ts.map +1 -0
  211. package/lib/services/findOrInitCart.js +15 -0
  212. package/lib/services/findOrInitCart.js.map +1 -0
  213. package/lib/services/fullfillQuotation.d.ts +4 -0
  214. package/lib/services/fullfillQuotation.d.ts.map +1 -0
  215. package/lib/services/fullfillQuotation.js +12 -0
  216. package/lib/services/fullfillQuotation.js.map +1 -0
  217. package/lib/services/index.d.ts +118 -0
  218. package/lib/services/index.d.ts.map +1 -0
  219. package/lib/services/index.js +132 -0
  220. package/lib/services/index.js.map +1 -0
  221. package/lib/services/initCartProviders.d.ts +4 -0
  222. package/lib/services/initCartProviders.d.ts.map +1 -0
  223. package/lib/services/initCartProviders.js +55 -0
  224. package/lib/services/initCartProviders.js.map +1 -0
  225. package/lib/services/initializeEnrollment.d.ts +7 -0
  226. package/lib/services/initializeEnrollment.d.ts.map +1 -0
  227. package/lib/services/initializeEnrollment.js +28 -0
  228. package/lib/services/initializeEnrollment.js.map +1 -0
  229. package/lib/services/invalidateFilterCache.d.ts +3 -0
  230. package/lib/services/invalidateFilterCache.d.ts.map +1 -0
  231. package/lib/services/invalidateFilterCache.js +12 -0
  232. package/lib/services/invalidateFilterCache.js.map +1 -0
  233. package/lib/services/linkFileService.d.ts +7 -0
  234. package/lib/services/linkFileService.d.ts.map +1 -0
  235. package/lib/services/linkFileService.js +18 -0
  236. package/lib/services/linkFileService.js.map +1 -0
  237. package/lib/services/loadFilterOptions.d.ts +14 -0
  238. package/lib/services/loadFilterOptions.d.ts.map +1 -0
  239. package/lib/services/loadFilterOptions.js +29 -0
  240. package/lib/services/loadFilterOptions.js.map +1 -0
  241. package/lib/services/loadFilters.d.ts +14 -0
  242. package/lib/services/loadFilters.d.ts.map +1 -0
  243. package/lib/services/loadFilters.js +36 -0
  244. package/lib/services/loadFilters.js.map +1 -0
  245. package/lib/services/migrateBookmarks.d.ts +8 -0
  246. package/lib/services/migrateBookmarks.d.ts.map +1 -0
  247. package/lib/services/migrateBookmarks.js +26 -0
  248. package/lib/services/migrateBookmarks.js.map +1 -0
  249. package/lib/services/migrateOrderCart.d.ts +8 -0
  250. package/lib/services/migrateOrderCart.d.ts.map +1 -0
  251. package/lib/services/migrateOrderCart.js +32 -0
  252. package/lib/services/migrateOrderCart.js.map +1 -0
  253. package/lib/services/migrateUserData.d.ts +2 -0
  254. package/lib/services/migrateUserData.d.ts.map +1 -0
  255. package/lib/services/migrateUserData.js +20 -0
  256. package/lib/services/migrateUserData.js.map +1 -0
  257. package/lib/services/nextUserCart.d.ts +9 -0
  258. package/lib/services/nextUserCart.d.ts.map +1 -0
  259. package/lib/services/nextUserCart.js +34 -0
  260. package/lib/services/nextUserCart.js.map +1 -0
  261. package/lib/services/processEnrollment.d.ts +4 -0
  262. package/lib/services/processEnrollment.d.ts.map +1 -0
  263. package/lib/services/processEnrollment.js +33 -0
  264. package/lib/services/processEnrollment.js.map +1 -0
  265. package/lib/services/processOrder.d.ts +9 -0
  266. package/lib/services/processOrder.d.ts.map +1 -0
  267. package/lib/services/processOrder.js +161 -0
  268. package/lib/services/processOrder.js.map +1 -0
  269. package/lib/services/processQuotation.d.ts +6 -0
  270. package/lib/services/processQuotation.d.ts.map +1 -0
  271. package/lib/services/processQuotation.js +60 -0
  272. package/lib/services/processQuotation.js.map +1 -0
  273. package/lib/services/proposeQuotation.d.ts +6 -0
  274. package/lib/services/proposeQuotation.d.ts.map +1 -0
  275. package/lib/services/proposeQuotation.js +12 -0
  276. package/lib/services/proposeQuotation.js.map +1 -0
  277. package/lib/services/registerPaymentCredentials.d.ts +5 -0
  278. package/lib/services/registerPaymentCredentials.d.ts.map +1 -0
  279. package/lib/services/registerPaymentCredentials.js +21 -0
  280. package/lib/services/registerPaymentCredentials.js.map +1 -0
  281. package/lib/services/rejectOrder.d.ts +9 -0
  282. package/lib/services/rejectOrder.d.ts.map +1 -0
  283. package/lib/services/rejectOrder.js +17 -0
  284. package/lib/services/rejectOrder.js.map +1 -0
  285. package/lib/services/rejectQuotation.d.ts +6 -0
  286. package/lib/services/rejectQuotation.d.ts.map +1 -0
  287. package/lib/services/rejectQuotation.js +12 -0
  288. package/lib/services/rejectQuotation.js.map +1 -0
  289. package/lib/services/removeFiles.d.ts +5 -0
  290. package/lib/services/removeFiles.d.ts.map +1 -0
  291. package/lib/services/removeFiles.js +19 -0
  292. package/lib/services/removeFiles.js.map +1 -0
  293. package/lib/services/removeProduct.d.ts +5 -0
  294. package/lib/services/removeProduct.d.ts.map +1 -0
  295. package/lib/services/removeProduct.js +26 -0
  296. package/lib/services/removeProduct.js.map +1 -0
  297. package/lib/services/searchAssortments.d.ts +19 -0
  298. package/lib/services/searchAssortments.d.ts.map +1 -0
  299. package/lib/services/searchAssortments.js +33 -0
  300. package/lib/services/searchAssortments.js.map +1 -0
  301. package/lib/services/searchProducts.d.ts +16 -0
  302. package/lib/services/searchProducts.d.ts.map +1 -0
  303. package/lib/services/searchProducts.js +41 -0
  304. package/lib/services/searchProducts.js.map +1 -0
  305. package/lib/services/simulateProductDispatching.d.ts +15 -0
  306. package/lib/services/simulateProductDispatching.d.ts.map +1 -0
  307. package/lib/services/simulateProductDispatching.js +30 -0
  308. package/lib/services/simulateProductDispatching.js.map +1 -0
  309. package/lib/services/simulateProductInventory.d.ts +15 -0
  310. package/lib/services/simulateProductInventory.d.ts.map +1 -0
  311. package/lib/services/simulateProductInventory.js +29 -0
  312. package/lib/services/simulateProductInventory.js.map +1 -0
  313. package/lib/services/simulateProductPricing.d.ts +12 -0
  314. package/lib/services/simulateProductPricing.d.ts.map +1 -0
  315. package/lib/services/simulateProductPricing.js +8 -0
  316. package/lib/services/simulateProductPricing.js.map +1 -0
  317. package/lib/services/supportedDeliveryProviders.d.ts +5 -0
  318. package/lib/services/supportedDeliveryProviders.d.ts.map +1 -0
  319. package/lib/services/supportedDeliveryProviders.js +14 -0
  320. package/lib/services/supportedDeliveryProviders.js.map +1 -0
  321. package/lib/services/supportedPaymentProviders.d.ts +5 -0
  322. package/lib/services/supportedPaymentProviders.d.ts.map +1 -0
  323. package/lib/services/supportedPaymentProviders.js +14 -0
  324. package/lib/services/supportedPaymentProviders.js.map +1 -0
  325. package/lib/services/supportedWarehousingProviders.d.ts +5 -0
  326. package/lib/services/supportedWarehousingProviders.d.ts.map +1 -0
  327. package/lib/services/supportedWarehousingProviders.js +10 -0
  328. package/lib/services/supportedWarehousingProviders.js.map +1 -0
  329. package/lib/services/terminateEnrollment.d.ts +3 -0
  330. package/lib/services/terminateEnrollment.d.ts.map +1 -0
  331. package/lib/services/terminateEnrollment.js +25 -0
  332. package/lib/services/terminateEnrollment.js.map +1 -0
  333. package/lib/services/updateCalculation.d.ts +3 -0
  334. package/lib/services/updateCalculation.d.ts.map +1 -0
  335. package/lib/services/updateCalculation.js +101 -0
  336. package/lib/services/updateCalculation.js.map +1 -0
  337. package/lib/services/updateScheduling.d.ts +8 -0
  338. package/lib/services/updateScheduling.d.ts.map +1 -0
  339. package/lib/services/updateScheduling.js +42 -0
  340. package/lib/services/updateScheduling.js.map +1 -0
  341. package/lib/services/updateUserAvatarAfterUpload.d.ts +6 -0
  342. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -0
  343. package/lib/services/updateUserAvatarAfterUpload.js +25 -0
  344. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -0
  345. package/lib/services/uploadFileFromStream.d.ts +8 -0
  346. package/lib/services/uploadFileFromStream.d.ts.map +1 -0
  347. package/lib/services/uploadFileFromStream.js +11 -0
  348. package/lib/services/uploadFileFromStream.js.map +1 -0
  349. package/lib/services/uploadFileFromURL.d.ts +13 -0
  350. package/lib/services/uploadFileFromURL.d.ts.map +1 -0
  351. package/lib/services/uploadFileFromURL.js +11 -0
  352. package/lib/services/uploadFileFromURL.js.map +1 -0
  353. package/lib/services/validateOrder.d.ts +4 -0
  354. package/lib/services/validateOrder.d.ts.map +1 -0
  355. package/lib/services/validateOrder.js +45 -0
  356. package/lib/services/validateOrder.js.map +1 -0
  357. package/lib/services/verifyQuotation.d.ts +6 -0
  358. package/lib/services/verifyQuotation.d.ts.map +1 -0
  359. package/lib/services/verifyQuotation.js +12 -0
  360. package/lib/services/verifyQuotation.js.map +1 -0
  361. package/package.json +30 -29
  362. package/src/core-index.ts +14 -241
  363. package/src/directors/BaseDiscountAdapter.test.ts +49 -0
  364. package/src/directors/BaseDiscountAdapter.ts +90 -0
  365. package/src/directors/BaseDiscountDirector.ts +73 -0
  366. package/src/directors/BasePricingAdapter.ts +80 -0
  367. package/src/directors/BasePricingDirector.ts +137 -0
  368. package/src/directors/BasePricingSheet.test.ts +43 -0
  369. package/src/directors/BasePricingSheet.ts +140 -0
  370. package/src/directors/DeliveryAdapter.ts +110 -0
  371. package/src/directors/DeliveryDirector.ts +135 -0
  372. package/src/directors/DeliveryPricingAdapter.ts +87 -0
  373. package/src/directors/DeliveryPricingDirector.ts +92 -0
  374. package/src/directors/DeliveryPricingSheet.ts +86 -0
  375. package/src/directors/EnrollmentAdapter.ts +113 -0
  376. package/src/directors/EnrollmentDirector.ts +70 -0
  377. package/src/directors/FilterAdapter.ts +103 -0
  378. package/src/directors/FilterDirector.ts +309 -0
  379. package/src/directors/MessagingDirector.test.ts +5 -0
  380. package/src/directors/MessagingDirector.ts +59 -0
  381. package/src/directors/OrderDiscountAdapter.ts +10 -0
  382. package/src/directors/OrderDiscountConfiguration.ts +5 -0
  383. package/src/directors/OrderDiscountDirector.ts +5 -0
  384. package/src/directors/OrderPricingAdapter.ts +63 -0
  385. package/src/directors/OrderPricingDirector.ts +74 -0
  386. package/src/directors/OrderPricingSheet.ts +147 -0
  387. package/src/directors/PaymentAdapter.ts +118 -0
  388. package/src/directors/PaymentDirector.ts +275 -0
  389. package/src/directors/PaymentPricingAdapter.ts +86 -0
  390. package/src/directors/PaymentPricingDirector.ts +94 -0
  391. package/src/directors/PaymentPricingSheet.ts +91 -0
  392. package/src/directors/ProductDiscountAdapter.ts +10 -0
  393. package/src/directors/ProductDiscountConfiguration.ts +18 -0
  394. package/src/directors/ProductDiscountDirector.ts +4 -0
  395. package/src/directors/ProductPricingAdapter.ts +58 -0
  396. package/src/directors/ProductPricingDirector.ts +100 -0
  397. package/src/directors/ProductPricingSheet.test.ts +129 -0
  398. package/src/directors/ProductPricingSheet.ts +124 -0
  399. package/src/directors/QuotationAdapter.ts +86 -0
  400. package/src/directors/QuotationDirector.ts +105 -0
  401. package/src/directors/WarehousingAdapter.ts +83 -0
  402. package/src/directors/WarehousingDirector.ts +236 -0
  403. package/src/directors/WorkerAdapter.ts +30 -0
  404. package/src/directors/WorkerDirector.ts +154 -0
  405. package/src/directors/index.ts +49 -0
  406. package/src/directors/periodForReferenceDate.test.ts +23 -0
  407. package/src/modules.ts +208 -0
  408. package/src/services/activateEnrollment.ts +30 -0
  409. package/src/services/calculateDiscountTotal.ts +71 -0
  410. package/src/services/checkoutOrder.ts +43 -0
  411. package/src/services/confirmOrder.ts +26 -0
  412. package/src/services/createDownloadStream.ts +16 -0
  413. package/src/services/createEnrollmentFromCheckout.ts +66 -0
  414. package/src/services/createManualOrderDiscount.ts +56 -0
  415. package/src/services/createSignedURL.ts +20 -0
  416. package/src/services/deleteUser.ts +33 -0
  417. package/src/services/discountedEntities.ts +81 -0
  418. package/src/services/ercMetadata.ts +33 -0
  419. package/src/services/findOrInitCart.ts +29 -0
  420. package/src/services/fullfillQuotation.ts +14 -0
  421. package/src/services/index.ts +168 -0
  422. package/src/services/initCartProviders.ts +86 -0
  423. package/src/services/initializeEnrollment.ts +38 -0
  424. package/src/services/invalidateFilterCache.ts +16 -0
  425. package/src/services/linkFileService.ts +22 -0
  426. package/src/services/loadFilterOptions.ts +49 -0
  427. package/src/services/loadFilters.ts +52 -0
  428. package/src/services/migrateBookmarks.ts +39 -0
  429. package/src/services/migrateOrderCart.ts +52 -0
  430. package/src/services/migrateUserData.ts +22 -0
  431. package/src/services/nextUserCart.ts +52 -0
  432. package/src/services/processEnrollment.ts +37 -0
  433. package/src/services/processOrder.ts +241 -0
  434. package/src/services/processQuotation.ts +75 -0
  435. package/src/services/proposeQuotation.ts +18 -0
  436. package/src/services/registerPaymentCredentials.ts +30 -0
  437. package/src/services/rejectOrder.ts +26 -0
  438. package/src/services/rejectQuotation.ts +18 -0
  439. package/src/services/removeFiles.ts +25 -0
  440. package/src/services/removeProduct.ts +34 -0
  441. package/src/services/searchAssortments.ts +58 -0
  442. package/src/services/searchProducts.ts +73 -0
  443. package/src/services/simulateProductDispatching.ts +59 -0
  444. package/src/services/simulateProductInventory.ts +56 -0
  445. package/src/services/simulateProductPricing.ts +20 -0
  446. package/src/services/supportedDeliveryProviders.ts +24 -0
  447. package/src/services/supportedPaymentProviders.ts +25 -0
  448. package/src/services/supportedWarehousingProviders.ts +18 -0
  449. package/src/services/terminateEnrollment.ts +29 -0
  450. package/src/services/updateCalculation.ts +143 -0
  451. package/src/services/updateScheduling.ts +64 -0
  452. package/src/services/updateUserAvatarAfterUpload.ts +30 -0
  453. package/src/services/uploadFileFromStream.ts +15 -0
  454. package/src/services/uploadFileFromURL.ts +29 -0
  455. package/src/services/validateOrder.ts +53 -0
  456. package/src/services/verifyQuotation.ts +18 -0
  457. package/tsconfig.json +5 -7
  458. package/lib/types.d.ts +0 -4
  459. package/lib/types.d.ts.map +0 -1
  460. package/lib/types.js +0 -5
  461. package/lib/types.js.map +0 -1
  462. package/src/types.ts +0 -7
@@ -0,0 +1,137 @@
1
+ import { BaseDirector, IBaseDirector, PricingCalculation } from '@unchainedshop/utils';
2
+ import { BasePricingAdapterContext, BasePricingContext, IPricingAdapter } from './BasePricingAdapter.js';
3
+ import { IPricingSheet } from './BasePricingSheet.js';
4
+ import { OrderDiscountDirector } from './OrderDiscountDirector.js';
5
+ import { createLogger } from '@unchainedshop/logger';
6
+ import { Modules } from '../modules.js';
7
+
8
+ const logger = createLogger('unchained:core');
9
+
10
+ export interface Discount<DiscountConfiguration> {
11
+ discountId: string;
12
+ configuration: DiscountConfiguration;
13
+ }
14
+
15
+ export type IPricingDirector<
16
+ PricingContext extends BasePricingContext,
17
+ Calculation extends PricingCalculation,
18
+ PricingAdapterContext extends BasePricingAdapterContext,
19
+ PricingAdapterSheet extends IPricingSheet<Calculation>,
20
+ Adapter extends IPricingAdapter<PricingAdapterContext & Context, Calculation, PricingAdapterSheet>,
21
+ Context = { modules: Modules },
22
+ > = IBaseDirector<Adapter> & {
23
+ buildPricingContext: (
24
+ pricingContext: PricingContext,
25
+ unchainedAPI: Context,
26
+ ) => Promise<PricingAdapterContext>;
27
+
28
+ rebuildCalculation: (
29
+ pricingContext: PricingContext,
30
+ unchainedAPI: Context,
31
+ ) => Promise<Array<Calculation>>;
32
+
33
+ calculationSheet: (
34
+ pricingContext: PricingContext,
35
+ calculation: Array<Calculation>,
36
+ ) => PricingAdapterSheet;
37
+ };
38
+
39
+ export const BasePricingDirector = <
40
+ DirectorContext extends BasePricingContext,
41
+ AdapterContext extends BasePricingAdapterContext,
42
+ Calculation extends PricingCalculation,
43
+ PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>,
44
+ >(
45
+ directorName: string,
46
+ ): IPricingDirector<
47
+ DirectorContext,
48
+ Calculation,
49
+ AdapterContext,
50
+ IPricingSheet<Calculation>,
51
+ PricingAdapter,
52
+ any
53
+ > => {
54
+ const baseDirector = BaseDirector<PricingAdapter>(directorName, {
55
+ adapterSortKey: 'orderIndex',
56
+ });
57
+
58
+ const director: IPricingDirector<
59
+ DirectorContext,
60
+ Calculation,
61
+ AdapterContext,
62
+ IPricingSheet<Calculation>,
63
+ PricingAdapter,
64
+ any
65
+ > = {
66
+ ...baseDirector,
67
+
68
+ buildPricingContext: async () => {
69
+ throw new Error('Method not implemented');
70
+ },
71
+
72
+ calculationSheet() {
73
+ throw new Error('Method not implemented');
74
+ },
75
+
76
+ async rebuildCalculation(pricingContext, unchainedAPI) {
77
+ const context = await director.buildPricingContext(pricingContext, unchainedAPI);
78
+
79
+ let calculation: Array<Calculation> = [];
80
+
81
+ const Adapters = baseDirector.getAdapters({
82
+ adapterFilter: (Adapter) => {
83
+ return Adapter.isActivatedFor(context);
84
+ },
85
+ });
86
+
87
+ calculation = await Adapters.reduce(async (previousPromise, Adapter) => {
88
+ const resolvedCalculation = await previousPromise;
89
+ if (!resolvedCalculation) return null;
90
+
91
+ const discounts: Array<Discount<any>> = await Promise.all(
92
+ context.discounts.map(async (orderDiscount) => {
93
+ const order = await unchainedAPI.modules.orders.findOrder({
94
+ orderId: orderDiscount.orderId,
95
+ });
96
+ const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
97
+ if (!DiscountAdapter) return null;
98
+
99
+ const adapter = await DiscountAdapter.actions({
100
+ context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
101
+ });
102
+
103
+ const configuration = adapter.discountForPricingAdapterKey({
104
+ pricingAdapterKey: Adapter.key,
105
+ calculationSheet: this.calculationSheet(pricingContext, calculation),
106
+ });
107
+
108
+ return {
109
+ discountId: orderDiscount._id,
110
+ configuration,
111
+ };
112
+ }),
113
+ );
114
+
115
+ try {
116
+ const adapter = Adapter.actions({
117
+ context,
118
+ calculationSheet: this.calculationSheet(pricingContext, calculation),
119
+ discounts: discounts.filter((d) => d?.configuration !== null),
120
+ });
121
+
122
+ const nextCalculationResult = await adapter.calculate();
123
+ if (!nextCalculationResult) return null;
124
+ calculation = resolvedCalculation.concat(nextCalculationResult);
125
+ return calculation;
126
+ } catch (error) {
127
+ logger.error(error);
128
+ }
129
+ return resolvedCalculation;
130
+ }, Promise.resolve([]));
131
+
132
+ return calculation;
133
+ },
134
+ };
135
+
136
+ return director;
137
+ };
@@ -0,0 +1,43 @@
1
+ import { resolveRatioAndTaxDivisorForPricingSheet } from './BasePricingSheet';
2
+
3
+ describe('resolveRatioAndTaxDivisorForPricingSheet', () => {
4
+ it('total is 0 and pricing is provided', () => {
5
+ const pricing: any = {
6
+ taxSum: () => 10,
7
+ gross: () => 20,
8
+ net: () => 10,
9
+ };
10
+ const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 0);
11
+ expect(result).toEqual({ ratio: 1, taxDivisor: 1 });
12
+ });
13
+
14
+ it('gross - tax is 0', () => {
15
+ const pricing: any = {
16
+ taxSum: () => 10,
17
+ gross: () => 10,
18
+ net: () => 0,
19
+ };
20
+ const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
21
+ expect(result).toEqual({ ratio: 0, taxDivisor: 0 });
22
+ });
23
+
24
+ it('gross - tax is not 0', () => {
25
+ const pricing: any = {
26
+ taxSum: () => 10,
27
+ gross: () => 20,
28
+ net: () => 10,
29
+ };
30
+ const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
31
+ expect(result).toEqual({ ratio: 1, taxDivisor: 2 });
32
+ });
33
+
34
+ it('taxSum is 0', () => {
35
+ const pricing: any = {
36
+ taxSum: () => 0,
37
+ gross: () => 20,
38
+ net: () => 20,
39
+ };
40
+ const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
41
+ expect(result).toEqual({ ratio: 1, taxDivisor: 1 });
42
+ });
43
+ });
@@ -0,0 +1,140 @@
1
+ import { PricingCalculation } from '@unchainedshop/utils';
2
+ export interface PricingDiscount {
3
+ discountId: string;
4
+ amount: number;
5
+ currency: string;
6
+ }
7
+
8
+ export interface IPricingSheet<Calculation extends PricingCalculation>
9
+ extends IBasePricingSheet<Calculation> {
10
+ discountPrices: (discountId?: string) => Array<PricingDiscount>;
11
+ addDiscount: (params: { amount: number; discountId: string; meta?: any }) => void;
12
+ }
13
+
14
+ export interface IBasePricingSheet<Calculation extends PricingCalculation> {
15
+ calculation: Array<Calculation>;
16
+ currency?: string;
17
+ quantity?: number;
18
+
19
+ getRawPricingSheet: () => Array<Calculation>;
20
+ filterBy: (filter?: Partial<Calculation>) => Array<Calculation>;
21
+ isValid: () => boolean;
22
+
23
+ gross: () => number;
24
+ net: () => number;
25
+ sum: (filter?: Partial<Calculation>) => number;
26
+ total: (params?: { category?: string; discountId?: string; useNetPrice?: boolean }) => {
27
+ amount: number;
28
+ currency: string;
29
+ };
30
+
31
+ taxSum: (filter?: Partial<Calculation>) => number;
32
+
33
+ resetCalculation: (sheetToInvert: IBasePricingSheet<Calculation>) => Array<Calculation>;
34
+ }
35
+
36
+ export interface PricingSheetParams<Calculation extends PricingCalculation> {
37
+ calculation?: Array<Calculation>;
38
+ currency?: string;
39
+ quantity?: number;
40
+ }
41
+
42
+ export const BasePricingSheet = <Calculation extends PricingCalculation>(
43
+ params: PricingSheetParams<Calculation>,
44
+ ): IBasePricingSheet<Calculation> => {
45
+ const pricingSheet: IBasePricingSheet<Calculation> = {
46
+ calculation: params.calculation || [],
47
+ currency: params.currency,
48
+ quantity: params.quantity,
49
+
50
+ getRawPricingSheet() {
51
+ return this.calculation;
52
+ },
53
+
54
+ isValid() {
55
+ return this.calculation.length > 0;
56
+ },
57
+
58
+ sum(filter) {
59
+ return this.filterBy(filter)
60
+ .filter(Boolean)
61
+ .reduce((sum: number, calculationRow: Calculation) => sum + calculationRow.amount, 0);
62
+ },
63
+
64
+ taxSum() {
65
+ return 0;
66
+ },
67
+
68
+ gross() {
69
+ // Sum contains taxes, thus it's gross when just suming everything
70
+ return this.sum();
71
+ },
72
+
73
+ net() {
74
+ // Remove all taxes from gross to get net
75
+ return this.sum() - this.taxSum();
76
+ },
77
+
78
+ total({ category, useNetPrice, discountId } = { useNetPrice: false }) {
79
+ const amount = this.sum({ category, discountId });
80
+ const taxAmountForCategory = this.taxSum({ baseCategory: category, discountId });
81
+
82
+ // Sum does not contain taxes when filtering by category, it's net in that case and gross if there is no category
83
+ const netAmount = !category ? amount - taxAmountForCategory : amount;
84
+
85
+ return {
86
+ amount: Math.round(useNetPrice ? netAmount : netAmount + taxAmountForCategory),
87
+ currency: this.currency,
88
+ };
89
+ },
90
+
91
+ filterBy(filter) {
92
+ const filteredCalculation = Object.keys(filter || {}).reduce(
93
+ (oldCalculation, filterKey) =>
94
+ oldCalculation.filter(
95
+ (row: Calculation) =>
96
+ !!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey]),
97
+ ),
98
+ this.calculation,
99
+ );
100
+
101
+ return filteredCalculation;
102
+ },
103
+
104
+ resetCalculation(calculationSheet) {
105
+ calculationSheet.filterBy().forEach(({ amount, ...row }: Calculation) => {
106
+ this.calculation.push({
107
+ ...row,
108
+ amount: amount * -1,
109
+ } as Calculation);
110
+ });
111
+ return this.calculation;
112
+ },
113
+ };
114
+
115
+ return pricingSheet;
116
+ };
117
+
118
+ export const resolveRatioAndTaxDivisorForPricingSheet = (
119
+ pricing: IBasePricingSheet<PricingCalculation>,
120
+ total: number,
121
+ ) => {
122
+ if (total === 0 || !pricing) {
123
+ return {
124
+ ratio: 1,
125
+ taxDivisor: 1,
126
+ };
127
+ }
128
+ const tax = pricing.taxSum();
129
+ const gross = pricing.gross();
130
+ if (gross - tax === 0) {
131
+ return {
132
+ ratio: 0,
133
+ taxDivisor: 0,
134
+ };
135
+ }
136
+ return {
137
+ ratio: gross / total,
138
+ taxDivisor: gross / (gross - tax),
139
+ };
140
+ };
@@ -0,0 +1,110 @@
1
+ import { log, LogLevel } from '@unchainedshop/logger';
2
+ import { IBaseAdapter } from '@unchainedshop/utils';
3
+ import type { Order, OrderPosition, OrderDelivery } from '@unchainedshop/core-orders';
4
+ import type { Product } from '@unchainedshop/core-products';
5
+ import type { WarehousingProvider } from '@unchainedshop/core-warehousing';
6
+ import type { Work } from '@unchainedshop/core-worker';
7
+ import type { User } from '@unchainedshop/core-users';
8
+ import {
9
+ DeliveryConfiguration,
10
+ DeliveryLocation,
11
+ DeliveryProvider,
12
+ DeliveryProviderType,
13
+ } from '@unchainedshop/core-delivery';
14
+ import { Modules } from '../modules.js';
15
+
16
+ export enum DeliveryError {
17
+ ADAPTER_NOT_FOUND = 'ADAPTER_NOT_FOUND',
18
+ NOT_IMPLEMENTED = 'NOT_IMPLEMENTED',
19
+ INCOMPLETE_CONFIGURATION = 'INCOMPLETE_CONFIGURATION',
20
+ WRONG_CREDENTIALS = 'WRONG_CREDENTIALS',
21
+ }
22
+
23
+ export interface DeliveryAdapterActions {
24
+ configurationError: (transactionContext?: any) => DeliveryError;
25
+ estimatedDeliveryThroughput: (warehousingThroughputTime: number) => Promise<number>;
26
+ isActive: () => boolean;
27
+ isAutoReleaseAllowed: () => boolean;
28
+ pickUpLocationById: (locationId: string) => Promise<DeliveryLocation>;
29
+ pickUpLocations: () => Promise<Array<DeliveryLocation>>;
30
+ send: () => Promise<boolean | Work>;
31
+ }
32
+
33
+ export interface DeliveryContext {
34
+ country?: string;
35
+ deliveryProvider?: DeliveryProvider;
36
+ order?: Order;
37
+ orderDelivery?: OrderDelivery;
38
+ orderPosition?: OrderPosition;
39
+ product?: Product;
40
+ quantity?: number;
41
+ referenceDate?: Date;
42
+ transactionContext?: any;
43
+ user?: User;
44
+ warehousingProvider?: WarehousingProvider;
45
+ warehousingThroughputTime?: number;
46
+ }
47
+
48
+ export type IDeliveryAdapter = IBaseAdapter & {
49
+ initialConfiguration: DeliveryConfiguration;
50
+
51
+ typeSupported: (type: DeliveryProviderType) => boolean;
52
+
53
+ actions: (
54
+ config: DeliveryConfiguration,
55
+ context: DeliveryContext & { modules: Modules },
56
+ ) => DeliveryAdapterActions;
57
+ };
58
+
59
+ export const DeliveryAdapter: Omit<IDeliveryAdapter, 'key' | 'label' | 'version'> = {
60
+ initialConfiguration: [],
61
+
62
+ typeSupported: () => {
63
+ return false;
64
+ },
65
+
66
+ actions: () => {
67
+ return {
68
+ configurationError: () => {
69
+ return DeliveryError.NOT_IMPLEMENTED;
70
+ },
71
+
72
+ estimatedDeliveryThroughput: async () => {
73
+ return 0;
74
+ },
75
+
76
+ isActive: () => {
77
+ return false;
78
+ },
79
+
80
+ isAutoReleaseAllowed: () => {
81
+ // if you return false here,
82
+ // the order will need manual confirmation before
83
+ // unchained will try to invoke send()
84
+ return true;
85
+ },
86
+
87
+ send: async () => {
88
+ // if you return true, the status will be changed to DELIVERED
89
+
90
+ // if you return false, the order delivery status stays the
91
+ // same but the order status might change
92
+
93
+ // if you throw an error, you cancel the whole checkout process
94
+ return false;
95
+ },
96
+
97
+ pickUpLocationById: async () => {
98
+ return null;
99
+ },
100
+
101
+ pickUpLocations: async () => {
102
+ return [];
103
+ },
104
+ };
105
+ },
106
+
107
+ log: (message: string, { level = LogLevel.Debug, ...options } = {}) => {
108
+ return log(message, { level, ...options });
109
+ },
110
+ };
@@ -0,0 +1,135 @@
1
+ import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
2
+ import {
3
+ DeliveryAdapterActions,
4
+ DeliveryContext,
5
+ IDeliveryAdapter,
6
+ DeliveryError,
7
+ } from './DeliveryAdapter.js';
8
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
9
+ import { OrderDelivery, OrderDeliveryStatus } from '@unchainedshop/core-orders';
10
+ import { Modules } from '../modules.js';
11
+ import { createLogger } from '@unchainedshop/logger';
12
+
13
+ const logger = createLogger('unchained:core');
14
+
15
+ export type IDeliveryDirector = IBaseDirector<IDeliveryAdapter> & {
16
+ sendOrderDelivery: (
17
+ orderDelivery: OrderDelivery,
18
+ transactionContext: Record<string, any>,
19
+ unchainedAPI: { modules: Modules },
20
+ ) => Promise<OrderDelivery>;
21
+ actions: (
22
+ deliveryProvider: DeliveryProvider,
23
+ deliveryContext: DeliveryContext,
24
+ unchainedAPI: { modules: Modules },
25
+ ) => Promise<DeliveryAdapterActions>;
26
+ };
27
+
28
+ const baseDirector = BaseDirector<IDeliveryAdapter>('DeliveryDirector');
29
+
30
+ export const DeliveryDirector: IDeliveryDirector = {
31
+ ...baseDirector,
32
+
33
+ actions: async (deliveryProvider, deliveryContext, unchainedAPI) => {
34
+ const Adapter = baseDirector.getAdapter(deliveryProvider.adapterKey);
35
+
36
+ const context = { ...deliveryContext, ...unchainedAPI };
37
+ const adapter = Adapter?.actions(deliveryProvider.configuration, context);
38
+
39
+ return {
40
+ configurationError: () => {
41
+ try {
42
+ return adapter.configurationError();
43
+ } catch {
44
+ return DeliveryError.ADAPTER_NOT_FOUND;
45
+ }
46
+ },
47
+
48
+ estimatedDeliveryThroughput: async (warehousingThroughputTime) => {
49
+ try {
50
+ const throughput = await adapter.estimatedDeliveryThroughput(warehousingThroughputTime);
51
+ return throughput;
52
+ } catch (error) {
53
+ logger.warn('Delivery Director -> Error while estimating delivery throughput', {
54
+ ...error,
55
+ });
56
+ return null;
57
+ }
58
+ },
59
+
60
+ isActive: () => {
61
+ try {
62
+ return adapter.isActive();
63
+ } catch (error) {
64
+ logger.warn('Delivery Director -> Error while checking if is active', {
65
+ ...error,
66
+ });
67
+ return false;
68
+ }
69
+ },
70
+
71
+ isAutoReleaseAllowed: () => {
72
+ try {
73
+ return adapter.isAutoReleaseAllowed();
74
+ } catch (error) {
75
+ logger.warn('Delivery Director -> Error while checking if auto release is allowed', {
76
+ ...error,
77
+ });
78
+ return false;
79
+ }
80
+ },
81
+
82
+ send: async () => {
83
+ return adapter.send();
84
+ },
85
+
86
+ pickUpLocationById: async (locationId) => {
87
+ return adapter.pickUpLocationById(locationId);
88
+ },
89
+
90
+ pickUpLocations: async () => {
91
+ return adapter.pickUpLocations();
92
+ },
93
+ };
94
+ },
95
+
96
+ sendOrderDelivery: async (orderDelivery, transactionContext, unchainedAPI) => {
97
+ if (
98
+ unchainedAPI.modules.orders.deliveries.normalizedStatus(orderDelivery) !== OrderDeliveryStatus.OPEN
99
+ )
100
+ return orderDelivery;
101
+
102
+ const order = await unchainedAPI.modules.orders.findOrder({ orderId: orderDelivery.orderId });
103
+ const deliveryProvider = await unchainedAPI.modules.delivery.findProvider({
104
+ deliveryProviderId: orderDelivery.deliveryProviderId,
105
+ });
106
+ const deliveryProviderId = deliveryProvider._id;
107
+ const address = orderDelivery.context?.address || order || order.billingAddress;
108
+ const provider = await await unchainedAPI.modules.delivery.findProvider({ deliveryProviderId });
109
+
110
+ const adapter = await DeliveryDirector.actions(
111
+ provider,
112
+ {
113
+ order,
114
+ orderDelivery,
115
+ transactionContext: {
116
+ ...(transactionContext || {}),
117
+ ...(orderDelivery.context || {}),
118
+ ...(address || {}),
119
+ },
120
+ },
121
+ unchainedAPI,
122
+ );
123
+
124
+ const arbitraryResponseData = await adapter.send();
125
+
126
+ if (arbitraryResponseData) {
127
+ return await unchainedAPI.modules.orders.deliveries.updateStatus(orderDelivery._id, {
128
+ status: OrderDeliveryStatus.DELIVERED,
129
+ info: JSON.stringify(arbitraryResponseData),
130
+ });
131
+ }
132
+
133
+ return orderDelivery;
134
+ },
135
+ };
@@ -0,0 +1,87 @@
1
+ import { DeliveryPricingSheet } from './DeliveryPricingSheet.js';
2
+ import {
3
+ BasePricingAdapterContext,
4
+ IPricingAdapter,
5
+ IPricingSheet,
6
+ BasePricingAdapter,
7
+ } from '../directors/index.js';
8
+ import { DeliveryProvider } from '@unchainedshop/core-delivery';
9
+ import { PricingCalculation } from '@unchainedshop/utils';
10
+ import { OrderDelivery, OrderDiscount, Order } from '@unchainedshop/core-orders';
11
+ import { User } from '@unchainedshop/core-users';
12
+ import { Modules } from '../modules.js';
13
+
14
+ export interface DeliveryPricingCalculation extends PricingCalculation {
15
+ discountId?: string;
16
+ isNetPrice: boolean;
17
+ isTaxable: boolean;
18
+ rate?: number;
19
+ }
20
+
21
+ export type IDeliveryPricingSheet = IPricingSheet<DeliveryPricingCalculation> & {
22
+ addFee: (params: { amount: number; isTaxable: boolean; isNetPrice: boolean; meta?: any }) => void;
23
+ addTax: (params: {
24
+ amount: number;
25
+ rate: number;
26
+ baseCategory?: string;
27
+ discountId?: string;
28
+ meta?: any;
29
+ }) => void;
30
+ addDiscount: (params: {
31
+ amount: number;
32
+ isTaxable: boolean;
33
+ isNetPrice: boolean;
34
+ discountId: string;
35
+ meta?: any;
36
+ }) => void;
37
+ };
38
+
39
+ export interface DeliveryPricingAdapterContext extends BasePricingAdapterContext {
40
+ country?: string;
41
+ currency?: string;
42
+ provider: DeliveryProvider;
43
+ providerContext?: any;
44
+ order: Order;
45
+ orderDelivery: OrderDelivery;
46
+ user: User;
47
+ discounts: Array<OrderDiscount>;
48
+ }
49
+
50
+ export type IDeliveryPricingAdapter<DiscountConfiguration = unknown> = IPricingAdapter<
51
+ DeliveryPricingAdapterContext & { modules: Modules },
52
+ DeliveryPricingCalculation,
53
+ IDeliveryPricingSheet,
54
+ DiscountConfiguration
55
+ >;
56
+
57
+ const basePricingAdapter = BasePricingAdapter<
58
+ DeliveryPricingAdapterContext,
59
+ DeliveryPricingCalculation
60
+ >();
61
+
62
+ export const DeliveryPricingAdapter: IDeliveryPricingAdapter = {
63
+ ...basePricingAdapter,
64
+
65
+ isActivatedFor: () => {
66
+ return false;
67
+ },
68
+
69
+ actions: (params) => {
70
+ const { context } = params;
71
+ const { currency } = context;
72
+ const baseActions = basePricingAdapter.actions(params);
73
+ const resultSheet = DeliveryPricingSheet({ currency });
74
+
75
+ return {
76
+ ...baseActions,
77
+ calculate: async () => {
78
+ const resultRaw = resultSheet.getRawPricingSheet();
79
+ resultRaw.forEach(({ amount, category }) =>
80
+ basePricingAdapter.log(`Delivery Calculation -> ${category} ${amount}`),
81
+ );
82
+ return resultRaw;
83
+ },
84
+ resultSheet: () => resultSheet,
85
+ };
86
+ },
87
+ };