@unchainedshop/core 3.0.0-alpha7 → 3.0.0-rc2

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 (530) 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/core-index_BACKUP_57582.d.ts +26 -0
  6. package/lib/core-index_BACKUP_57582.d.ts.map +1 -0
  7. package/lib/core-index_BACKUP_57582.js +30 -0
  8. package/lib/core-index_BACKUP_57582.js.map +1 -0
  9. package/lib/core-index_BASE_57582.d.ts +74 -0
  10. package/lib/core-index_BASE_57582.d.ts.map +1 -0
  11. package/lib/core-index_BASE_57582.js +145 -0
  12. package/lib/core-index_BASE_57582.js.map +1 -0
  13. package/lib/core-index_LOCAL_57582.d.ts +26 -0
  14. package/lib/core-index_LOCAL_57582.d.ts.map +1 -0
  15. package/lib/core-index_LOCAL_57582.js +31 -0
  16. package/lib/core-index_LOCAL_57582.js.map +1 -0
  17. package/lib/core-index_REMOTE_57582.d.ts +74 -0
  18. package/lib/core-index_REMOTE_57582.d.ts.map +1 -0
  19. package/lib/core-index_REMOTE_57582.js +146 -0
  20. package/lib/core-index_REMOTE_57582.js.map +1 -0
  21. package/lib/directors/BaseDiscountAdapter.d.ts +38 -0
  22. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -0
  23. package/lib/directors/BaseDiscountAdapter.js +48 -0
  24. package/lib/directors/BaseDiscountAdapter.js.map +1 -0
  25. package/lib/directors/BaseDiscountDirector.d.ts +12 -0
  26. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -0
  27. package/lib/directors/BaseDiscountDirector.js +45 -0
  28. package/lib/directors/BaseDiscountDirector.js.map +1 -0
  29. package/lib/directors/BasePricingAdapter.d.ts +39 -0
  30. package/lib/directors/BasePricingAdapter.d.ts.map +1 -0
  31. package/lib/directors/BasePricingAdapter.js +25 -0
  32. package/lib/directors/BasePricingAdapter.js.map +1 -0
  33. package/lib/directors/BasePricingDirector.d.ts +17 -0
  34. package/lib/directors/BasePricingDirector.d.ts.map +1 -0
  35. package/lib/directors/BasePricingDirector.js +70 -0
  36. package/lib/directors/BasePricingDirector.js.map +1 -0
  37. package/lib/directors/BasePricingSheet.d.ts +46 -0
  38. package/lib/directors/BasePricingSheet.d.ts.map +1 -0
  39. package/lib/directors/BasePricingSheet.js +74 -0
  40. package/lib/directors/BasePricingSheet.js.map +1 -0
  41. package/lib/directors/DeliveryAdapter.d.ts +46 -0
  42. package/lib/directors/DeliveryAdapter.d.ts.map +1 -0
  43. package/lib/directors/DeliveryAdapter.js +50 -0
  44. package/lib/directors/DeliveryAdapter.js.map +1 -0
  45. package/lib/directors/DeliveryDirector.d.ts +15 -0
  46. package/lib/directors/DeliveryDirector.d.ts.map +1 -0
  47. package/lib/directors/DeliveryDirector.js +96 -0
  48. package/lib/directors/DeliveryDirector.js.map +1 -0
  49. package/lib/directors/DeliveryPricingAdapter.d.ts +49 -0
  50. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -0
  51. package/lib/directors/DeliveryPricingAdapter.js +25 -0
  52. package/lib/directors/DeliveryPricingAdapter.js.map +1 -0
  53. package/lib/directors/DeliveryPricingDirector.d.ts +20 -0
  54. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -0
  55. package/lib/directors/DeliveryPricingDirector.js +50 -0
  56. package/lib/directors/DeliveryPricingDirector.js.map +1 -0
  57. package/lib/directors/DeliveryPricingSheet.d.ts +10 -0
  58. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -0
  59. package/lib/directors/DeliveryPricingSheet.js +75 -0
  60. package/lib/directors/DeliveryPricingSheet.js.map +1 -0
  61. package/lib/directors/EnrollmentAdapter.d.ts +27 -0
  62. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -0
  63. package/lib/directors/EnrollmentAdapter.js +73 -0
  64. package/lib/directors/EnrollmentAdapter.js.map +1 -0
  65. package/lib/directors/EnrollmentDirector.d.ts +14 -0
  66. package/lib/directors/EnrollmentDirector.d.ts.map +1 -0
  67. package/lib/directors/EnrollmentDirector.js +44 -0
  68. package/lib/directors/EnrollmentDirector.js.map +1 -0
  69. package/lib/directors/FilterAdapter.d.ts +54 -0
  70. package/lib/directors/FilterAdapter.d.ts.map +1 -0
  71. package/lib/directors/FilterAdapter.js +38 -0
  72. package/lib/directors/FilterAdapter.js.map +1 -0
  73. package/lib/directors/FilterDirector.d.ts +40 -0
  74. package/lib/directors/FilterDirector.d.ts.map +1 -0
  75. package/lib/directors/FilterDirector.js +173 -0
  76. package/lib/directors/FilterDirector.js.map +1 -0
  77. package/lib/directors/MessagingDirector.d.ts +46 -0
  78. package/lib/directors/MessagingDirector.d.ts.map +1 -0
  79. package/lib/directors/MessagingDirector.js +10 -0
  80. package/lib/directors/MessagingDirector.js.map +1 -0
  81. package/lib/directors/OrderDiscountAdapter.d.ts +3 -0
  82. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -0
  83. package/lib/directors/OrderDiscountAdapter.js +3 -0
  84. package/lib/directors/OrderDiscountAdapter.js.map +1 -0
  85. package/lib/directors/OrderDiscountConfiguration.d.ts +6 -0
  86. package/lib/directors/OrderDiscountConfiguration.d.ts.map +1 -0
  87. package/lib/directors/OrderDiscountConfiguration.js +2 -0
  88. package/lib/directors/OrderDiscountConfiguration.js.map +1 -0
  89. package/lib/directors/OrderDiscountDirector.d.ts +3 -0
  90. package/lib/directors/OrderDiscountDirector.d.ts.map +1 -0
  91. package/lib/directors/OrderDiscountDirector.js +3 -0
  92. package/lib/directors/OrderDiscountDirector.js.map +1 -0
  93. package/lib/directors/OrderPricingAdapter.d.ts +18 -0
  94. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -0
  95. package/lib/directors/OrderPricingAdapter.js +24 -0
  96. package/lib/directors/OrderPricingAdapter.js.map +1 -0
  97. package/lib/directors/OrderPricingDirector.d.ts +18 -0
  98. package/lib/directors/OrderPricingDirector.d.ts.map +1 -0
  99. package/lib/directors/OrderPricingDirector.js +31 -0
  100. package/lib/directors/OrderPricingDirector.js.map +1 -0
  101. package/lib/directors/OrderPricingSheet.d.ts +37 -0
  102. package/lib/directors/OrderPricingSheet.d.ts.map +1 -0
  103. package/lib/directors/OrderPricingSheet.js +108 -0
  104. package/lib/directors/OrderPricingSheet.js.map +1 -0
  105. package/lib/directors/PaymentAdapter.d.ts +50 -0
  106. package/lib/directors/PaymentAdapter.d.ts.map +1 -0
  107. package/lib/directors/PaymentAdapter.js +55 -0
  108. package/lib/directors/PaymentAdapter.js.map +1 -0
  109. package/lib/directors/PaymentDirector.d.ts +21 -0
  110. package/lib/directors/PaymentDirector.d.ts.map +1 -0
  111. package/lib/directors/PaymentDirector.js +172 -0
  112. package/lib/directors/PaymentDirector.js.map +1 -0
  113. package/lib/directors/PaymentPricingAdapter.d.ts +48 -0
  114. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -0
  115. package/lib/directors/PaymentPricingAdapter.js +25 -0
  116. package/lib/directors/PaymentPricingAdapter.js.map +1 -0
  117. package/lib/directors/PaymentPricingDirector.d.ts +18 -0
  118. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -0
  119. package/lib/directors/PaymentPricingDirector.js +51 -0
  120. package/lib/directors/PaymentPricingDirector.js.map +1 -0
  121. package/lib/directors/PaymentPricingSheet.d.ts +9 -0
  122. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -0
  123. package/lib/directors/PaymentPricingSheet.js +75 -0
  124. package/lib/directors/PaymentPricingSheet.js.map +1 -0
  125. package/lib/directors/ProductDiscountAdapter.d.ts +3 -0
  126. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -0
  127. package/lib/directors/ProductDiscountAdapter.js +3 -0
  128. package/lib/directors/ProductDiscountAdapter.js.map +1 -0
  129. package/lib/directors/ProductDiscountConfiguration.d.ts +13 -0
  130. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -0
  131. package/lib/directors/ProductDiscountConfiguration.js +2 -0
  132. package/lib/directors/ProductDiscountConfiguration.js.map +1 -0
  133. package/lib/directors/ProductDiscountDirector.d.ts +3 -0
  134. package/lib/directors/ProductDiscountDirector.d.ts.map +1 -0
  135. package/lib/directors/ProductDiscountDirector.js +3 -0
  136. package/lib/directors/ProductDiscountDirector.js.map +1 -0
  137. package/lib/directors/ProductPricingAdapter.d.ts +17 -0
  138. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -0
  139. package/lib/directors/ProductPricingAdapter.js +24 -0
  140. package/lib/directors/ProductPricingAdapter.js.map +1 -0
  141. package/lib/directors/ProductPricingDirector.d.ts +21 -0
  142. package/lib/directors/ProductPricingDirector.d.ts.map +1 -0
  143. package/lib/directors/ProductPricingDirector.js +52 -0
  144. package/lib/directors/ProductPricingDirector.js.map +1 -0
  145. package/lib/directors/ProductPricingSheet.d.ts +38 -0
  146. package/lib/directors/ProductPricingSheet.d.ts.map +1 -0
  147. package/lib/directors/ProductPricingSheet.js +83 -0
  148. package/lib/directors/ProductPricingSheet.js.map +1 -0
  149. package/lib/directors/QuotationAdapter.d.ts +28 -0
  150. package/lib/directors/QuotationAdapter.d.ts.map +1 -0
  151. package/lib/directors/QuotationAdapter.js +46 -0
  152. package/lib/directors/QuotationAdapter.js.map +1 -0
  153. package/lib/directors/QuotationDirector.d.ts +7 -0
  154. package/lib/directors/QuotationDirector.d.ts.map +1 -0
  155. package/lib/directors/QuotationDirector.js +84 -0
  156. package/lib/directors/QuotationDirector.js.map +1 -0
  157. package/lib/directors/WarehousingAdapter.d.ts +40 -0
  158. package/lib/directors/WarehousingAdapter.d.ts.map +1 -0
  159. package/lib/directors/WarehousingAdapter.js +32 -0
  160. package/lib/directors/WarehousingAdapter.js.map +1 -0
  161. package/lib/directors/WarehousingDirector.d.ts +38 -0
  162. package/lib/directors/WarehousingDirector.d.ts.map +1 -0
  163. package/lib/directors/WarehousingDirector.js +169 -0
  164. package/lib/directors/WarehousingDirector.js.map +1 -0
  165. package/lib/directors/WorkerAdapter.d.ts +17 -0
  166. package/lib/directors/WorkerAdapter.d.ts.map +1 -0
  167. package/lib/directors/WorkerAdapter.js +11 -0
  168. package/lib/directors/WorkerAdapter.js.map +1 -0
  169. package/lib/directors/WorkerDirector.d.ts +26 -0
  170. package/lib/directors/WorkerDirector.d.ts.map +1 -0
  171. package/lib/directors/WorkerDirector.js +102 -0
  172. package/lib/directors/WorkerDirector.js.map +1 -0
  173. package/lib/directors/index.d.ts +39 -0
  174. package/lib/directors/index.d.ts.map +1 -0
  175. package/lib/directors/index.js +39 -0
  176. package/lib/directors/index.js.map +1 -0
  177. package/lib/modules.d.ts +61 -0
  178. package/lib/modules.d.ts.map +1 -0
  179. package/lib/modules.js +132 -0
  180. package/lib/modules.js.map +1 -0
  181. package/lib/services/activateEnrollment.d.ts +4 -0
  182. package/lib/services/activateEnrollment.d.ts.map +1 -0
  183. package/lib/services/activateEnrollment.js +25 -0
  184. package/lib/services/activateEnrollment.js.map +1 -0
  185. package/lib/services/calculateDiscountTotal.d.ts +7 -0
  186. package/lib/services/calculateDiscountTotal.d.ts.map +1 -0
  187. package/lib/services/calculateDiscountTotal.js +49 -0
  188. package/lib/services/calculateDiscountTotal.js.map +1 -0
  189. package/lib/services/checkoutOrder.d.ts +9 -0
  190. package/lib/services/checkoutOrder.d.ts.map +1 -0
  191. package/lib/services/checkoutOrder.js +28 -0
  192. package/lib/services/checkoutOrder.js.map +1 -0
  193. package/lib/services/confirmOrder.d.ts +9 -0
  194. package/lib/services/confirmOrder.d.ts.map +1 -0
  195. package/lib/services/confirmOrder.js +17 -0
  196. package/lib/services/confirmOrder.js.map +1 -0
  197. package/lib/services/createDownloadStream.d.ts +5 -0
  198. package/lib/services/createDownloadStream.d.ts.map +1 -0
  199. package/lib/services/createDownloadStream.js +8 -0
  200. package/lib/services/createDownloadStream.js.map +1 -0
  201. package/lib/services/createDownloadStreamService.d.ts +11 -0
  202. package/lib/services/createDownloadStreamService.d.ts.map +1 -0
  203. package/lib/services/createDownloadStreamService.js +9 -0
  204. package/lib/services/createDownloadStreamService.js.map +1 -0
  205. package/lib/services/createEnrollmentFromCheckout.d.ts +15 -0
  206. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -0
  207. package/lib/services/createEnrollmentFromCheckout.js +40 -0
  208. package/lib/services/createEnrollmentFromCheckout.js.map +1 -0
  209. package/lib/services/createManualOrderDiscount.d.ts +7 -0
  210. package/lib/services/createManualOrderDiscount.d.ts.map +1 -0
  211. package/lib/services/createManualOrderDiscount.js +47 -0
  212. package/lib/services/createManualOrderDiscount.js.map +1 -0
  213. package/lib/services/createSignedURL.d.ts +8 -0
  214. package/lib/services/createSignedURL.d.ts.map +1 -0
  215. package/lib/services/createSignedURL.js +15 -0
  216. package/lib/services/createSignedURL.js.map +1 -0
  217. package/lib/services/createSignedURLService.d.ts +13 -0
  218. package/lib/services/createSignedURLService.d.ts.map +1 -0
  219. package/lib/services/createSignedURLService.js +14 -0
  220. package/lib/services/createSignedURLService.js.map +1 -0
  221. package/lib/services/deleteUser.d.ts +5 -0
  222. package/lib/services/deleteUser.d.ts.map +1 -0
  223. package/lib/services/deleteUser.js +26 -0
  224. package/lib/services/deleteUser.js.map +1 -0
  225. package/lib/services/deleteUserCartService.d.ts +6 -0
  226. package/lib/services/deleteUserCartService.d.ts.map +1 -0
  227. package/lib/services/deleteUserCartService.js +20 -0
  228. package/lib/services/deleteUserCartService.js.map +1 -0
  229. package/lib/services/deleteUserCarts.d.ts +5 -0
  230. package/lib/services/deleteUserCarts.d.ts.map +1 -0
  231. package/lib/services/deleteUserCarts.js +18 -0
  232. package/lib/services/deleteUserCarts.js.map +1 -0
  233. package/lib/services/deleteUserCartsService.d.ts +5 -0
  234. package/lib/services/deleteUserCartsService.d.ts.map +1 -0
  235. package/lib/services/deleteUserCartsService.js +18 -0
  236. package/lib/services/deleteUserCartsService.js.map +1 -0
  237. package/lib/services/discountedEntities.d.ts +5 -0
  238. package/lib/services/discountedEntities.d.ts.map +1 -0
  239. package/lib/services/discountedEntities.js +61 -0
  240. package/lib/services/discountedEntities.js.map +1 -0
  241. package/lib/services/ercMetadata.d.ts +7 -0
  242. package/lib/services/ercMetadata.d.ts.map +1 -0
  243. package/lib/services/ercMetadata.js +22 -0
  244. package/lib/services/ercMetadata.js.map +1 -0
  245. package/lib/services/fullfillQuotation.d.ts +4 -0
  246. package/lib/services/fullfillQuotation.d.ts.map +1 -0
  247. package/lib/services/fullfillQuotation.js +12 -0
  248. package/lib/services/fullfillQuotation.js.map +1 -0
  249. package/lib/services/index.d.ts +110 -0
  250. package/lib/services/index.d.ts.map +1 -0
  251. package/lib/services/index.js +124 -0
  252. package/lib/services/index.js.map +1 -0
  253. package/lib/services/index_BACKUP_58089.d.ts +246 -0
  254. package/lib/services/index_BACKUP_58089.d.ts.map +1 -0
  255. package/lib/services/index_BACKUP_58089.js +103 -0
  256. package/lib/services/index_BACKUP_58089.js.map +1 -0
  257. package/lib/services/index_BASE_58089.d.ts +31 -0
  258. package/lib/services/index_BASE_58089.d.ts.map +1 -0
  259. package/lib/services/index_BASE_58089.js +42 -0
  260. package/lib/services/index_BASE_58089.js.map +1 -0
  261. package/lib/services/index_LOCAL_58089.d.ts +246 -0
  262. package/lib/services/index_LOCAL_58089.d.ts.map +1 -0
  263. package/lib/services/index_LOCAL_58089.js +103 -0
  264. package/lib/services/index_LOCAL_58089.js.map +1 -0
  265. package/lib/services/index_REMOTE_58089.d.ts +34 -0
  266. package/lib/services/index_REMOTE_58089.d.ts.map +1 -0
  267. package/lib/services/index_REMOTE_58089.js +44 -0
  268. package/lib/services/index_REMOTE_58089.js.map +1 -0
  269. package/lib/services/initCartProviders.d.ts +4 -0
  270. package/lib/services/initCartProviders.d.ts.map +1 -0
  271. package/lib/services/initCartProviders.js +55 -0
  272. package/lib/services/initCartProviders.js.map +1 -0
  273. package/lib/services/initializeEnrollment.d.ts +7 -0
  274. package/lib/services/initializeEnrollment.d.ts.map +1 -0
  275. package/lib/services/initializeEnrollment.js +28 -0
  276. package/lib/services/initializeEnrollment.js.map +1 -0
  277. package/lib/services/invalidateFilterCache.d.ts +3 -0
  278. package/lib/services/invalidateFilterCache.d.ts.map +1 -0
  279. package/lib/services/invalidateFilterCache.js +12 -0
  280. package/lib/services/invalidateFilterCache.js.map +1 -0
  281. package/lib/services/linkFileService.d.ts +7 -0
  282. package/lib/services/linkFileService.d.ts.map +1 -0
  283. package/lib/services/linkFileService.js +18 -0
  284. package/lib/services/linkFileService.js.map +1 -0
  285. package/lib/services/loadFilterOptions.d.ts +14 -0
  286. package/lib/services/loadFilterOptions.d.ts.map +1 -0
  287. package/lib/services/loadFilterOptions.js +30 -0
  288. package/lib/services/loadFilterOptions.js.map +1 -0
  289. package/lib/services/loadFilters.d.ts +14 -0
  290. package/lib/services/loadFilters.d.ts.map +1 -0
  291. package/lib/services/loadFilters.js +36 -0
  292. package/lib/services/loadFilters.js.map +1 -0
  293. package/lib/services/migrateBookmarks.d.ts +8 -0
  294. package/lib/services/migrateBookmarks.d.ts.map +1 -0
  295. package/lib/services/migrateBookmarks.js +26 -0
  296. package/lib/services/migrateBookmarks.js.map +1 -0
  297. package/lib/services/migrateBookmarksService.d.ts +13 -0
  298. package/lib/services/migrateBookmarksService.d.ts.map +1 -0
  299. package/lib/services/migrateBookmarksService.js +26 -0
  300. package/lib/services/migrateBookmarksService.js.map +1 -0
  301. package/lib/services/migrateOrderCart.d.ts +8 -0
  302. package/lib/services/migrateOrderCart.d.ts.map +1 -0
  303. package/lib/services/migrateOrderCart.js +32 -0
  304. package/lib/services/migrateOrderCart.js.map +1 -0
  305. package/lib/services/migrateOrderCartService.d.ts +23 -0
  306. package/lib/services/migrateOrderCartService.d.ts.map +1 -0
  307. package/lib/services/migrateOrderCartService.js +32 -0
  308. package/lib/services/migrateOrderCartService.js.map +1 -0
  309. package/lib/services/migrateUserData.d.ts +2 -0
  310. package/lib/services/migrateUserData.d.ts.map +1 -0
  311. package/lib/services/migrateUserData.js +20 -0
  312. package/lib/services/migrateUserData.js.map +1 -0
  313. package/lib/services/migrateUserDataService.d.ts +19 -0
  314. package/lib/services/migrateUserDataService.d.ts.map +1 -0
  315. package/lib/services/migrateUserDataService.js +18 -0
  316. package/lib/services/migrateUserDataService.js.map +1 -0
  317. package/lib/services/nextUserCart.d.ts +9 -0
  318. package/lib/services/nextUserCart.d.ts.map +1 -0
  319. package/lib/services/nextUserCart.js +34 -0
  320. package/lib/services/nextUserCart.js.map +1 -0
  321. package/lib/services/nextUserCartService.d.ts +22 -0
  322. package/lib/services/nextUserCartService.d.ts.map +1 -0
  323. package/lib/services/nextUserCartService.js +35 -0
  324. package/lib/services/nextUserCartService.js.map +1 -0
  325. package/lib/services/processEnrollment.d.ts +4 -0
  326. package/lib/services/processEnrollment.d.ts.map +1 -0
  327. package/lib/services/processEnrollment.js +33 -0
  328. package/lib/services/processEnrollment.js.map +1 -0
  329. package/lib/services/processOrder.d.ts +9 -0
  330. package/lib/services/processOrder.d.ts.map +1 -0
  331. package/lib/services/processOrder.js +161 -0
  332. package/lib/services/processOrder.js.map +1 -0
  333. package/lib/services/processQuotation.d.ts +6 -0
  334. package/lib/services/processQuotation.d.ts.map +1 -0
  335. package/lib/services/processQuotation.js +60 -0
  336. package/lib/services/processQuotation.js.map +1 -0
  337. package/lib/services/proposeQuotation.d.ts +6 -0
  338. package/lib/services/proposeQuotation.d.ts.map +1 -0
  339. package/lib/services/proposeQuotation.js +12 -0
  340. package/lib/services/proposeQuotation.js.map +1 -0
  341. package/lib/services/registerPaymentCredentials.d.ts +5 -0
  342. package/lib/services/registerPaymentCredentials.d.ts.map +1 -0
  343. package/lib/services/registerPaymentCredentials.js +21 -0
  344. package/lib/services/registerPaymentCredentials.js.map +1 -0
  345. package/lib/services/rejectOrder.d.ts +9 -0
  346. package/lib/services/rejectOrder.d.ts.map +1 -0
  347. package/lib/services/rejectOrder.js +17 -0
  348. package/lib/services/rejectOrder.js.map +1 -0
  349. package/lib/services/rejectQuotation.d.ts +6 -0
  350. package/lib/services/rejectQuotation.d.ts.map +1 -0
  351. package/lib/services/rejectQuotation.js +12 -0
  352. package/lib/services/rejectQuotation.js.map +1 -0
  353. package/lib/services/removeFiles.d.ts +5 -0
  354. package/lib/services/removeFiles.d.ts.map +1 -0
  355. package/lib/services/removeFiles.js +19 -0
  356. package/lib/services/removeFiles.js.map +1 -0
  357. package/lib/services/removeFilesService.d.ts +10 -0
  358. package/lib/services/removeFilesService.d.ts.map +1 -0
  359. package/lib/services/removeFilesService.js +20 -0
  360. package/lib/services/removeFilesService.js.map +1 -0
  361. package/lib/services/removeProduct.d.ts +5 -0
  362. package/lib/services/removeProduct.d.ts.map +1 -0
  363. package/lib/services/removeProduct.js +26 -0
  364. package/lib/services/removeProduct.js.map +1 -0
  365. package/lib/services/removeProductService.d.ts +20 -0
  366. package/lib/services/removeProductService.d.ts.map +1 -0
  367. package/lib/services/removeProductService.js +27 -0
  368. package/lib/services/removeProductService.js.map +1 -0
  369. package/lib/services/searchAssortments.d.ts +19 -0
  370. package/lib/services/searchAssortments.d.ts.map +1 -0
  371. package/lib/services/searchAssortments.js +33 -0
  372. package/lib/services/searchAssortments.js.map +1 -0
  373. package/lib/services/searchProducts.d.ts +16 -0
  374. package/lib/services/searchProducts.d.ts.map +1 -0
  375. package/lib/services/searchProducts.js +41 -0
  376. package/lib/services/searchProducts.js.map +1 -0
  377. package/lib/services/supportedDeliveryProviders.d.ts +5 -0
  378. package/lib/services/supportedDeliveryProviders.d.ts.map +1 -0
  379. package/lib/services/supportedDeliveryProviders.js +14 -0
  380. package/lib/services/supportedDeliveryProviders.js.map +1 -0
  381. package/lib/services/supportedPaymentProviders.d.ts +5 -0
  382. package/lib/services/supportedPaymentProviders.d.ts.map +1 -0
  383. package/lib/services/supportedPaymentProviders.js +14 -0
  384. package/lib/services/supportedPaymentProviders.js.map +1 -0
  385. package/lib/services/supportedWarehousingProviders.d.ts +5 -0
  386. package/lib/services/supportedWarehousingProviders.d.ts.map +1 -0
  387. package/lib/services/supportedWarehousingProviders.js +10 -0
  388. package/lib/services/supportedWarehousingProviders.js.map +1 -0
  389. package/lib/services/terminateEnrollment.d.ts +3 -0
  390. package/lib/services/terminateEnrollment.d.ts.map +1 -0
  391. package/lib/services/terminateEnrollment.js +25 -0
  392. package/lib/services/terminateEnrollment.js.map +1 -0
  393. package/lib/services/updateCalculation.d.ts +3 -0
  394. package/lib/services/updateCalculation.d.ts.map +1 -0
  395. package/lib/services/updateCalculation.js +101 -0
  396. package/lib/services/updateCalculation.js.map +1 -0
  397. package/lib/services/updateCalculationService.d.ts +17 -0
  398. package/lib/services/updateCalculationService.d.ts.map +1 -0
  399. package/lib/services/updateCalculationService.js +68 -0
  400. package/lib/services/updateCalculationService.js.map +1 -0
  401. package/lib/services/updateScheduling.d.ts +8 -0
  402. package/lib/services/updateScheduling.d.ts.map +1 -0
  403. package/lib/services/updateScheduling.js +42 -0
  404. package/lib/services/updateScheduling.js.map +1 -0
  405. package/lib/services/updateUserAvatarAfterUpload.d.ts +6 -0
  406. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -0
  407. package/lib/services/updateUserAvatarAfterUpload.js +25 -0
  408. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -0
  409. package/lib/services/updateUserAvatarAfterUploadService.d.ts +18 -0
  410. package/lib/services/updateUserAvatarAfterUploadService.d.ts.map +1 -0
  411. package/lib/services/updateUserAvatarAfterUploadService.js +25 -0
  412. package/lib/services/updateUserAvatarAfterUploadService.js.map +1 -0
  413. package/lib/services/uploadFileFromStream.d.ts +8 -0
  414. package/lib/services/uploadFileFromStream.d.ts.map +1 -0
  415. package/lib/services/uploadFileFromStream.js +11 -0
  416. package/lib/services/uploadFileFromStream.js.map +1 -0
  417. package/lib/services/uploadFileFromStreamService.d.ts +12 -0
  418. package/lib/services/uploadFileFromStreamService.d.ts.map +1 -0
  419. package/lib/services/uploadFileFromStreamService.js +10 -0
  420. package/lib/services/uploadFileFromStreamService.js.map +1 -0
  421. package/lib/services/uploadFileFromURL.d.ts +13 -0
  422. package/lib/services/uploadFileFromURL.d.ts.map +1 -0
  423. package/lib/services/uploadFileFromURL.js +11 -0
  424. package/lib/services/uploadFileFromURL.js.map +1 -0
  425. package/lib/services/uploadFileFromURLService.d.ts +17 -0
  426. package/lib/services/uploadFileFromURLService.d.ts.map +1 -0
  427. package/lib/services/uploadFileFromURLService.js +10 -0
  428. package/lib/services/uploadFileFromURLService.js.map +1 -0
  429. package/lib/services/validateOrder.d.ts +4 -0
  430. package/lib/services/validateOrder.d.ts.map +1 -0
  431. package/lib/services/validateOrder.js +45 -0
  432. package/lib/services/validateOrder.js.map +1 -0
  433. package/lib/services/verifyQuotation.d.ts +6 -0
  434. package/lib/services/verifyQuotation.d.ts.map +1 -0
  435. package/lib/services/verifyQuotation.js +12 -0
  436. package/lib/services/verifyQuotation.js.map +1 -0
  437. package/package.json +28 -28
  438. package/src/core-index.ts +14 -241
  439. package/src/directors/BaseDiscountAdapter.test.ts +49 -0
  440. package/src/directors/BaseDiscountAdapter.ts +91 -0
  441. package/src/directors/BaseDiscountDirector.ts +72 -0
  442. package/src/directors/BasePricingAdapter.ts +82 -0
  443. package/src/directors/BasePricingDirector.ts +136 -0
  444. package/src/directors/BasePricingSheet.test.ts +43 -0
  445. package/src/directors/BasePricingSheet.ts +140 -0
  446. package/src/directors/DeliveryAdapter.ts +110 -0
  447. package/src/directors/DeliveryDirector.ts +135 -0
  448. package/src/directors/DeliveryPricingAdapter.ts +87 -0
  449. package/src/directors/DeliveryPricingDirector.ts +92 -0
  450. package/src/directors/DeliveryPricingSheet.ts +86 -0
  451. package/src/directors/EnrollmentAdapter.ts +109 -0
  452. package/src/directors/EnrollmentDirector.ts +70 -0
  453. package/src/directors/FilterAdapter.ts +103 -0
  454. package/src/directors/FilterDirector.ts +309 -0
  455. package/src/directors/MessagingDirector.test.ts +5 -0
  456. package/src/directors/MessagingDirector.ts +59 -0
  457. package/src/directors/OrderDiscountAdapter.ts +10 -0
  458. package/src/directors/OrderDiscountConfiguration.ts +5 -0
  459. package/src/directors/OrderDiscountDirector.ts +6 -0
  460. package/src/directors/OrderPricingAdapter.ts +63 -0
  461. package/src/directors/OrderPricingDirector.ts +74 -0
  462. package/src/directors/OrderPricingSheet.ts +147 -0
  463. package/src/directors/PaymentAdapter.ts +118 -0
  464. package/src/directors/PaymentDirector.ts +275 -0
  465. package/src/directors/PaymentPricingAdapter.ts +86 -0
  466. package/src/directors/PaymentPricingDirector.ts +94 -0
  467. package/src/directors/PaymentPricingSheet.ts +91 -0
  468. package/src/directors/ProductDiscountAdapter.ts +10 -0
  469. package/src/directors/ProductDiscountConfiguration.ts +18 -0
  470. package/src/directors/ProductDiscountDirector.ts +5 -0
  471. package/src/directors/ProductPricingAdapter.ts +56 -0
  472. package/src/directors/ProductPricingDirector.ts +100 -0
  473. package/src/directors/ProductPricingSheet.test.ts +129 -0
  474. package/src/directors/ProductPricingSheet.ts +127 -0
  475. package/src/directors/QuotationAdapter.ts +86 -0
  476. package/src/directors/QuotationDirector.ts +105 -0
  477. package/src/directors/WarehousingAdapter.ts +83 -0
  478. package/src/directors/WarehousingDirector.ts +235 -0
  479. package/src/directors/WorkerAdapter.ts +30 -0
  480. package/src/directors/WorkerDirector.ts +154 -0
  481. package/src/directors/index.ts +49 -0
  482. package/src/directors/periodForReferenceDate.test.ts +23 -0
  483. package/src/modules.ts +215 -0
  484. package/src/services/activateEnrollment.ts +30 -0
  485. package/src/services/calculateDiscountTotal.ts +71 -0
  486. package/src/services/checkoutOrder.ts +43 -0
  487. package/src/services/confirmOrder.ts +26 -0
  488. package/src/services/createDownloadStream.ts +16 -0
  489. package/src/services/createEnrollmentFromCheckout.ts +66 -0
  490. package/src/services/createManualOrderDiscount.ts +56 -0
  491. package/src/services/createSignedURL.ts +20 -0
  492. package/src/services/deleteUser.ts +33 -0
  493. package/src/services/discountedEntities.ts +81 -0
  494. package/src/services/ercMetadata.ts +33 -0
  495. package/src/services/fullfillQuotation.ts +14 -0
  496. package/src/services/index.ts +154 -0
  497. package/src/services/initCartProviders.ts +86 -0
  498. package/src/services/initializeEnrollment.ts +38 -0
  499. package/src/services/invalidateFilterCache.ts +16 -0
  500. package/src/services/linkFileService.ts +22 -0
  501. package/src/services/loadFilterOptions.ts +50 -0
  502. package/src/services/loadFilters.ts +52 -0
  503. package/src/services/migrateBookmarks.ts +39 -0
  504. package/src/services/migrateOrderCart.ts +52 -0
  505. package/src/services/migrateUserData.ts +22 -0
  506. package/src/services/nextUserCart.ts +52 -0
  507. package/src/services/processEnrollment.ts +37 -0
  508. package/src/services/processOrder.ts +241 -0
  509. package/src/services/processQuotation.ts +75 -0
  510. package/src/services/proposeQuotation.ts +18 -0
  511. package/src/services/registerPaymentCredentials.ts +30 -0
  512. package/src/services/rejectOrder.ts +26 -0
  513. package/src/services/rejectQuotation.ts +18 -0
  514. package/src/services/removeFiles.ts +25 -0
  515. package/src/services/removeProduct.ts +34 -0
  516. package/src/services/searchAssortments.ts +58 -0
  517. package/src/services/searchProducts.ts +73 -0
  518. package/src/services/supportedDeliveryProviders.ts +24 -0
  519. package/src/services/supportedPaymentProviders.ts +25 -0
  520. package/src/services/supportedWarehousingProviders.ts +18 -0
  521. package/src/services/terminateEnrollment.ts +29 -0
  522. package/src/services/updateCalculation.ts +143 -0
  523. package/src/services/updateScheduling.ts +64 -0
  524. package/src/services/updateUserAvatarAfterUpload.ts +30 -0
  525. package/src/services/uploadFileFromStream.ts +15 -0
  526. package/src/services/uploadFileFromURL.ts +29 -0
  527. package/src/services/validateOrder.ts +53 -0
  528. package/src/services/verifyQuotation.ts +18 -0
  529. package/tsconfig.json +5 -7
  530. package/src/types.ts +0 -7
@@ -0,0 +1,91 @@
1
+ import { log, LogLevel } from '@unchainedshop/logger';
2
+ import { IBaseAdapter } from '@unchainedshop/utils';
3
+ import { IPricingSheet } from './BasePricingSheet.js';
4
+ import { PricingCalculation } from '@unchainedshop/utils';
5
+ export interface DiscountContext {
6
+ code?: string;
7
+ orderDiscount?: { _id?: string; orderId: string };
8
+ order?: { _id?: string; userId: string };
9
+ }
10
+
11
+ export type IDiscountAdapter<DiscountConfiguration, Context> = IBaseAdapter & {
12
+ orderIndex: number;
13
+
14
+ isManualAdditionAllowed: (code: string) => Promise<boolean>;
15
+ isManualRemovalAllowed: () => Promise<boolean>;
16
+
17
+ actions: (params: {
18
+ context: DiscountContext & Context;
19
+ }) => Promise<DiscountAdapterActions<DiscountConfiguration>>;
20
+ };
21
+
22
+ export interface DiscountAdapterActions<DiscountConfiguration> {
23
+ isValidForSystemTriggering: () => Promise<boolean>;
24
+ isValidForCodeTriggering: (params: { code: string }) => Promise<boolean>;
25
+
26
+ discountForPricingAdapterKey: (params: {
27
+ pricingAdapterKey: string;
28
+ calculationSheet: IPricingSheet<PricingCalculation>;
29
+ }) => DiscountConfiguration;
30
+
31
+ reserve: (params: { code: string }) => Promise<any>;
32
+ release: () => Promise<void>;
33
+ }
34
+
35
+ export const BaseDiscountAdapter: Omit<
36
+ IDiscountAdapter<unknown, unknown>,
37
+ 'key' | 'label' | 'version'
38
+ > = {
39
+ orderIndex: 0,
40
+
41
+ isManualAdditionAllowed: async () => {
42
+ return false;
43
+ },
44
+
45
+ // return true if a discount is allowed to get removed manually by a user
46
+ isManualRemovalAllowed: async () => {
47
+ return false;
48
+ },
49
+
50
+ actions: async () => ({
51
+ // return true if a discount is valid to be part of the order
52
+ // without input of a user. that could be a time based global discount
53
+ // like a 10% discount day
54
+ // if you return false, this discount will
55
+ // get removed from the order before any price calculation
56
+ // takes place.
57
+ // eslint-disable-next-line
58
+ isValidForSystemTriggering: async () => {
59
+ return false;
60
+ },
61
+
62
+ // return an arbitrary JSON serializable object with reservation data
63
+ // this method is called when a discount is added through a manual code and let's
64
+ // you manually deduct expendable discounts (coupon balances for ex.) before checkout
65
+ reserve: async () => {
66
+ return {};
67
+ },
68
+
69
+ // return void, allows you to free up any reservations in backend systems
70
+ release: async () => {
71
+ return null;
72
+ },
73
+
74
+ // return true if a discount is valid to be part of the order.
75
+ // if you return false, this discount will
76
+ // get removed from the order before any price calculation
77
+ // takes place.
78
+ isValidForCodeTriggering: async () => {
79
+ return false;
80
+ },
81
+
82
+ // returns the appropriate discount context for a calculation adapter
83
+ discountForPricingAdapterKey() {
84
+ return null;
85
+ },
86
+ }),
87
+
88
+ log(message: string, { level = LogLevel.Debug, ...options } = {}) {
89
+ return log(message, { level, ...options });
90
+ },
91
+ };
@@ -0,0 +1,72 @@
1
+ import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
2
+ import { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.js';
3
+
4
+ export type IDiscountDirector<DiscountConfiguration, Context> = IBaseDirector<
5
+ IDiscountAdapter<DiscountConfiguration, Context>
6
+ > & {
7
+ actions: (
8
+ discountContext: DiscountContext,
9
+ unchainedAPI: Context,
10
+ ) => Promise<{
11
+ resolveDiscountAdapterFromStaticCode: (params: {
12
+ code: string;
13
+ }) => Promise<IDiscountAdapter<DiscountConfiguration, Context>>;
14
+ findSystemDiscounts: () => Promise<Array<string>>;
15
+ }>;
16
+ };
17
+
18
+ export const BaseDiscountDirector = <DiscountConfigurationType, Context>(
19
+ directorName: string,
20
+ ): IDiscountDirector<DiscountConfigurationType, Context> => {
21
+ const baseDirector = BaseDirector<IDiscountAdapter<DiscountConfigurationType, Context>>(directorName, {
22
+ adapterSortKey: 'orderIndex',
23
+ });
24
+
25
+ return {
26
+ ...baseDirector,
27
+
28
+ actions: async (discountContext, unchainedAPI) => {
29
+ const context = { ...discountContext, ...unchainedAPI };
30
+
31
+ return {
32
+ resolveDiscountAdapterFromStaticCode: async (options) => {
33
+ if (!context.order) return null;
34
+
35
+ const discounts = await Promise.all(
36
+ baseDirector
37
+ .getAdapters()
38
+ .filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
39
+ .map(async (Adapter) => {
40
+ const adapter = await Adapter.actions({ context });
41
+ return {
42
+ Adapter,
43
+ isValid: await adapter.isValidForCodeTriggering(options),
44
+ };
45
+ }),
46
+ );
47
+
48
+ return discounts.find(({ isValid }) => isValid === true)?.Adapter;
49
+ },
50
+
51
+ async findSystemDiscounts() {
52
+ if (!context.order) return [];
53
+ const discounts = await Promise.all(
54
+ baseDirector.getAdapters().map(async (Adapter) => {
55
+ const adapter = await Adapter.actions({ context });
56
+ return {
57
+ key: Adapter.key,
58
+ isValid: await adapter.isValidForSystemTriggering(),
59
+ };
60
+ }),
61
+ );
62
+
63
+ const validDiscounts = discounts
64
+ .filter(({ isValid }) => isValid === true)
65
+ .map(({ key }) => key);
66
+
67
+ return validDiscounts;
68
+ },
69
+ };
70
+ },
71
+ };
72
+ };
@@ -0,0 +1,82 @@
1
+ import { createLogger } from '@unchainedshop/logger';
2
+ import { IPricingSheet } from './BasePricingSheet.js';
3
+ import { IBaseAdapter, PricingCalculation } from '@unchainedshop/utils';
4
+ import { Discount } from './BasePricingDirector.js';
5
+
6
+ const logger = createLogger('unchained:core');
7
+
8
+ type Order = { _id?: string };
9
+ type OrderDiscount = { _id?: string };
10
+
11
+ interface IDiscountableItem {
12
+ _id?: string;
13
+ orderId?: string;
14
+ }
15
+
16
+ export interface BasePricingAdapterContext {
17
+ order?: Order;
18
+ discounts: Array<OrderDiscount>;
19
+ }
20
+
21
+ export type BasePricingContext =
22
+ | {
23
+ order?: Order;
24
+ discounts?: Array<OrderDiscount>;
25
+ }
26
+ | {
27
+ item: IDiscountableItem;
28
+ };
29
+
30
+ export interface IPricingAdapterActions<
31
+ Calculation extends PricingCalculation,
32
+ Sheet extends IPricingSheet<Calculation>,
33
+ > {
34
+ calculate: () => Promise<Array<Calculation>>;
35
+ resultSheet: () => Sheet;
36
+ }
37
+
38
+ export type IPricingAdapter<
39
+ PricingAdapterContext extends BasePricingAdapterContext,
40
+ Calculation extends PricingCalculation,
41
+ Sheet extends IPricingSheet<Calculation>,
42
+ DiscountConfiguration = unknown,
43
+ > = IBaseAdapter & {
44
+ orderIndex: number;
45
+
46
+ isActivatedFor: (context: PricingAdapterContext) => boolean;
47
+
48
+ actions: (params: {
49
+ context: PricingAdapterContext;
50
+ calculationSheet: Sheet;
51
+ discounts: Array<Discount<DiscountConfiguration>>;
52
+ }) => IPricingAdapterActions<Calculation, Sheet>;
53
+ };
54
+
55
+ export const BasePricingAdapter = <
56
+ PricingAdapterContext extends BasePricingAdapterContext,
57
+ Calculation extends PricingCalculation,
58
+ >(): IPricingAdapter<PricingAdapterContext, Calculation, IPricingSheet<Calculation>> => ({
59
+ key: '',
60
+ label: '',
61
+ version: '',
62
+ orderIndex: 0,
63
+
64
+ isActivatedFor: () => {
65
+ return false;
66
+ },
67
+
68
+ actions: () => {
69
+ return {
70
+ calculate: async () => {
71
+ throw new Error('Method not implemented.');
72
+ },
73
+ resultSheet: () => {
74
+ throw new Error('Method not implemented.');
75
+ }, // abstract
76
+ };
77
+ },
78
+
79
+ log(message: string, options) {
80
+ return logger.debug(message, options);
81
+ },
82
+ });
@@ -0,0 +1,136 @@
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 this.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
+ const adapter = await DiscountAdapter.actions({
99
+ context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
100
+ });
101
+
102
+ const configuration = adapter.discountForPricingAdapterKey({
103
+ pricingAdapterKey: Adapter.key,
104
+ calculationSheet: this.calculationSheet(pricingContext, calculation),
105
+ });
106
+
107
+ return {
108
+ discountId: orderDiscount._id,
109
+ configuration,
110
+ };
111
+ }),
112
+ );
113
+
114
+ try {
115
+ const adapter = Adapter.actions({
116
+ context,
117
+ calculationSheet: this.calculationSheet(pricingContext, calculation),
118
+ discounts: discounts.filter(({ configuration }) => configuration !== null),
119
+ });
120
+
121
+ const nextCalculationResult = await adapter.calculate();
122
+ if (!nextCalculationResult) return null;
123
+ calculation = resolvedCalculation.concat(nextCalculationResult);
124
+ return calculation;
125
+ } catch (error) {
126
+ logger.error(error);
127
+ }
128
+ return resolvedCalculation;
129
+ }, Promise.resolve([]));
130
+
131
+ return calculation;
132
+ },
133
+ };
134
+
135
+ return director;
136
+ };
@@ -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
+ };