@unchainedshop/core 4.3.6 → 4.4.0

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 (648) hide show
  1. package/README.md +614 -2
  2. package/lib/bulk-importer/createBulkImporter.d.ts +5 -6
  3. package/lib/bulk-importer/createBulkImporter.js +6 -5
  4. package/lib/bulk-importer/handlers/assortment/create.d.ts +2 -3
  5. package/lib/bulk-importer/handlers/assortment/create.js +6 -8
  6. package/lib/bulk-importer/handlers/assortment/index.d.ts +3 -4
  7. package/lib/bulk-importer/handlers/assortment/index.js +3 -4
  8. package/lib/bulk-importer/handlers/assortment/remove.d.ts +1 -2
  9. package/lib/bulk-importer/handlers/assortment/remove.js +0 -1
  10. package/lib/bulk-importer/handlers/assortment/update.d.ts +2 -3
  11. package/lib/bulk-importer/handlers/assortment/update.js +7 -9
  12. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +1 -2
  13. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +1 -2
  14. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +1 -2
  15. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +1 -2
  16. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +1 -2
  17. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +1 -2
  18. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +2 -3
  19. package/lib/bulk-importer/handlers/assortment/upsertMedia.js +2 -4
  20. package/lib/bulk-importer/handlers/filter/create.d.ts +7 -3
  21. package/lib/bulk-importer/handlers/filter/create.js +3 -4
  22. package/lib/bulk-importer/handlers/filter/index.d.ts +3 -4
  23. package/lib/bulk-importer/handlers/filter/index.js +3 -4
  24. package/lib/bulk-importer/handlers/filter/remove.d.ts +1 -2
  25. package/lib/bulk-importer/handlers/filter/remove.js +0 -1
  26. package/lib/bulk-importer/handlers/filter/update.d.ts +1 -2
  27. package/lib/bulk-importer/handlers/filter/update.js +2 -4
  28. package/lib/bulk-importer/handlers/product/create.d.ts +23 -6
  29. package/lib/bulk-importer/handlers/product/create.js +10 -12
  30. package/lib/bulk-importer/handlers/product/index.d.ts +3 -4
  31. package/lib/bulk-importer/handlers/product/index.js +3 -4
  32. package/lib/bulk-importer/handlers/product/remove.d.ts +2 -3
  33. package/lib/bulk-importer/handlers/product/remove.js +0 -1
  34. package/lib/bulk-importer/handlers/product/update.d.ts +2 -3
  35. package/lib/bulk-importer/handlers/product/update.js +8 -11
  36. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +2 -3
  37. package/lib/bulk-importer/handlers/product/upsertMedia.js +3 -5
  38. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +1 -2
  39. package/lib/bulk-importer/handlers/product/upsertVariations.js +2 -5
  40. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +0 -1
  41. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +0 -1
  42. package/lib/bulk-importer/index.d.ts +2 -3
  43. package/lib/bulk-importer/index.js +2 -3
  44. package/lib/bulk-importer/upsertAsset.d.ts +3 -4
  45. package/lib/bulk-importer/upsertAsset.js +1 -3
  46. package/lib/core-index.d.ts +9 -10
  47. package/lib/core-index.js +9 -10
  48. package/lib/directors/BaseDiscountAdapter.d.ts +5 -6
  49. package/lib/directors/BaseDiscountAdapter.js +0 -17
  50. package/lib/directors/BaseDiscountDirector.d.ts +3 -4
  51. package/lib/directors/BaseDiscountDirector.js +0 -1
  52. package/lib/directors/BasePricingAdapter.d.ts +4 -5
  53. package/lib/directors/BasePricingAdapter.js +1 -2
  54. package/lib/directors/BasePricingDirector.d.ts +4 -5
  55. package/lib/directors/BasePricingDirector.js +1 -6
  56. package/lib/directors/BasePricingSheet.d.ts +1 -2
  57. package/lib/directors/BasePricingSheet.js +0 -4
  58. package/lib/directors/BaseWorker.d.ts +1 -2
  59. package/lib/directors/BaseWorker.js +2 -5
  60. package/lib/directors/DeliveryAdapter.d.ts +8 -8
  61. package/lib/directors/DeliveryAdapter.js +6 -15
  62. package/lib/directors/DeliveryDirector.d.ts +5 -6
  63. package/lib/directors/DeliveryDirector.js +1 -2
  64. package/lib/directors/DeliveryPricingAdapter.d.ts +6 -7
  65. package/lib/directors/DeliveryPricingAdapter.js +2 -3
  66. package/lib/directors/DeliveryPricingDirector.d.ts +3 -4
  67. package/lib/directors/DeliveryPricingDirector.js +2 -2
  68. package/lib/directors/DeliveryPricingSheet.d.ts +9 -9
  69. package/lib/directors/DeliveryPricingSheet.js +7 -9
  70. package/lib/directors/EnrollmentAdapter.d.ts +2 -3
  71. package/lib/directors/EnrollmentAdapter.js +0 -1
  72. package/lib/directors/EnrollmentDirector.d.ts +3 -4
  73. package/lib/directors/EnrollmentDirector.js +0 -1
  74. package/lib/directors/EventListenerWorker.d.ts +1 -2
  75. package/lib/directors/EventListenerWorker.js +2 -11
  76. package/lib/directors/FailedRescheduler.d.ts +1 -2
  77. package/lib/directors/FailedRescheduler.js +0 -3
  78. package/lib/directors/FilterAdapter.d.ts +5 -6
  79. package/lib/directors/FilterAdapter.js +1 -5
  80. package/lib/directors/FilterDirector.d.ts +4 -5
  81. package/lib/directors/FilterDirector.js +1 -10
  82. package/lib/directors/IntervalWorker.d.ts +2 -3
  83. package/lib/directors/IntervalWorker.js +3 -5
  84. package/lib/directors/MessagingDirector.d.ts +0 -1
  85. package/lib/directors/MessagingDirector.js +0 -1
  86. package/lib/directors/OrderDiscountAdapter.d.ts +1 -2
  87. package/lib/directors/OrderDiscountAdapter.js +1 -2
  88. package/lib/directors/OrderDiscountConfiguration.d.ts +0 -1
  89. package/lib/directors/OrderDiscountConfiguration.js +0 -1
  90. package/lib/directors/OrderDiscountDirector.d.ts +2 -3
  91. package/lib/directors/OrderDiscountDirector.js +1 -2
  92. package/lib/directors/OrderPricingAdapter.d.ts +4 -5
  93. package/lib/directors/OrderPricingAdapter.js +1 -2
  94. package/lib/directors/OrderPricingDirector.d.ts +2 -3
  95. package/lib/directors/OrderPricingDirector.js +1 -2
  96. package/lib/directors/OrderPricingSheet.d.ts +10 -10
  97. package/lib/directors/OrderPricingSheet.js +8 -12
  98. package/lib/directors/PaymentAdapter.d.ts +8 -8
  99. package/lib/directors/PaymentAdapter.js +6 -12
  100. package/lib/directors/PaymentDirector.d.ts +4 -5
  101. package/lib/directors/PaymentDirector.js +1 -2
  102. package/lib/directors/PaymentPricingAdapter.d.ts +6 -7
  103. package/lib/directors/PaymentPricingAdapter.js +2 -3
  104. package/lib/directors/PaymentPricingDirector.d.ts +4 -5
  105. package/lib/directors/PaymentPricingDirector.js +2 -3
  106. package/lib/directors/PaymentPricingSheet.d.ts +8 -8
  107. package/lib/directors/PaymentPricingSheet.js +7 -9
  108. package/lib/directors/ProductDiscountAdapter.d.ts +1 -2
  109. package/lib/directors/ProductDiscountAdapter.js +1 -2
  110. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -2
  111. package/lib/directors/ProductDiscountConfiguration.js +0 -1
  112. package/lib/directors/ProductDiscountDirector.d.ts +2 -3
  113. package/lib/directors/ProductDiscountDirector.js +1 -2
  114. package/lib/directors/ProductPricingAdapter.d.ts +5 -6
  115. package/lib/directors/ProductPricingAdapter.js +1 -2
  116. package/lib/directors/ProductPricingDirector.d.ts +4 -5
  117. package/lib/directors/ProductPricingDirector.js +1 -2
  118. package/lib/directors/ProductPricingSheet.d.ts +8 -8
  119. package/lib/directors/ProductPricingSheet.js +6 -8
  120. package/lib/directors/QuotationAdapter.d.ts +9 -9
  121. package/lib/directors/QuotationAdapter.js +6 -8
  122. package/lib/directors/QuotationDirector.d.ts +2 -3
  123. package/lib/directors/QuotationDirector.js +1 -2
  124. package/lib/directors/WarehousingAdapter.d.ts +12 -12
  125. package/lib/directors/WarehousingAdapter.js +6 -8
  126. package/lib/directors/WarehousingDirector.d.ts +4 -5
  127. package/lib/directors/WarehousingDirector.js +1 -4
  128. package/lib/directors/WorkerAdapter.d.ts +5 -6
  129. package/lib/directors/WorkerAdapter.js +0 -1
  130. package/lib/directors/WorkerDirector.d.ts +5 -6
  131. package/lib/directors/WorkerDirector.js +0 -3
  132. package/lib/directors/index.d.ts +42 -43
  133. package/lib/directors/index.js +42 -43
  134. package/lib/factory/index.d.ts +9 -10
  135. package/lib/factory/index.js +9 -10
  136. package/lib/factory/registerAssortmentSearchFilter.d.ts +1 -2
  137. package/lib/factory/registerAssortmentSearchFilter.js +1 -2
  138. package/lib/factory/registerInvoicePayment.d.ts +2 -3
  139. package/lib/factory/registerInvoicePayment.js +1 -2
  140. package/lib/factory/registerPhysicalWarehousing.d.ts +2 -3
  141. package/lib/factory/registerPhysicalWarehousing.js +1 -2
  142. package/lib/factory/registerPickUpDelivery.d.ts +3 -4
  143. package/lib/factory/registerPickUpDelivery.js +1 -2
  144. package/lib/factory/registerProductDiscoverabilityFilter.d.ts +0 -1
  145. package/lib/factory/registerProductDiscoverabilityFilter.js +1 -2
  146. package/lib/factory/registerProductSearchFilter.d.ts +1 -2
  147. package/lib/factory/registerProductSearchFilter.js +1 -2
  148. package/lib/factory/registerShippingDelivery.d.ts +3 -4
  149. package/lib/factory/registerShippingDelivery.js +1 -2
  150. package/lib/factory/registerVirtualWarehousing.d.ts +2 -3
  151. package/lib/factory/registerVirtualWarehousing.js +1 -2
  152. package/lib/factory/registerWorker.d.ts +0 -1
  153. package/lib/factory/registerWorker.js +1 -2
  154. package/lib/modules.d.ts +18 -19
  155. package/lib/modules.js +5 -5
  156. package/lib/services/activateEnrollment.d.ts +2 -3
  157. package/lib/services/activateEnrollment.js +2 -3
  158. package/lib/services/addMessage.d.ts +2 -3
  159. package/lib/services/addMessage.js +2 -3
  160. package/lib/services/calculateDiscountTotal.d.ts +2 -3
  161. package/lib/services/calculateDiscountTotal.js +1 -6
  162. package/lib/services/checkoutOrder.d.ts +1 -2
  163. package/lib/services/checkoutOrder.js +4 -6
  164. package/lib/services/confirmOrder.d.ts +2 -3
  165. package/lib/services/confirmOrder.js +1 -2
  166. package/lib/services/createDownloadStream.d.ts +2 -3
  167. package/lib/services/createDownloadStream.js +0 -1
  168. package/lib/services/createEnrollmentFromCheckout.d.ts +4 -5
  169. package/lib/services/createEnrollmentFromCheckout.js +2 -3
  170. package/lib/services/createManualOrderDiscount.d.ts +2 -3
  171. package/lib/services/createManualOrderDiscount.js +1 -3
  172. package/lib/services/createSignedURL.d.ts +2 -3
  173. package/lib/services/createSignedURL.js +0 -1
  174. package/lib/services/deleteUser.d.ts +1 -2
  175. package/lib/services/deleteUser.js +0 -1
  176. package/lib/services/discountedEntities.d.ts +3 -4
  177. package/lib/services/discountedEntities.js +1 -7
  178. package/lib/services/ercMetadata.d.ts +3 -4
  179. package/lib/services/ercMetadata.js +1 -2
  180. package/lib/services/findOrInitCart.d.ts +2 -3
  181. package/lib/services/findOrInitCart.js +1 -2
  182. package/lib/services/fullfillQuotation.d.ts +2 -3
  183. package/lib/services/fullfillQuotation.js +1 -2
  184. package/lib/services/generateOrderFromEnrollment.d.ts +2 -3
  185. package/lib/services/generateOrderFromEnrollment.js +2 -3
  186. package/lib/services/index.d.ts +48 -49
  187. package/lib/services/index.js +47 -51
  188. package/lib/services/initCartProviders.d.ts +2 -3
  189. package/lib/services/initCartProviders.js +2 -5
  190. package/lib/services/initializeEnrollment.d.ts +2 -3
  191. package/lib/services/initializeEnrollment.js +3 -4
  192. package/lib/services/invalidateFilterCache.d.ts +1 -2
  193. package/lib/services/invalidateFilterCache.js +1 -2
  194. package/lib/services/linkFileService.d.ts +1 -2
  195. package/lib/services/linkFileService.js +0 -1
  196. package/lib/services/loadFilterOptions.d.ts +2 -3
  197. package/lib/services/loadFilterOptions.js +1 -2
  198. package/lib/services/loadFilters.d.ts +2 -3
  199. package/lib/services/loadFilters.js +1 -2
  200. package/lib/services/migrateBookmarks.d.ts +1 -2
  201. package/lib/services/migrateBookmarks.js +0 -2
  202. package/lib/services/migrateOrderCart.d.ts +1 -2
  203. package/lib/services/migrateOrderCart.js +1 -7
  204. package/lib/services/migrateUserData.d.ts +0 -1
  205. package/lib/services/migrateUserData.js +2 -3
  206. package/lib/services/nextUserCart.d.ts +2 -3
  207. package/lib/services/nextUserCart.js +1 -2
  208. package/lib/services/processEnrollment.d.ts +2 -3
  209. package/lib/services/processEnrollment.js +1 -5
  210. package/lib/services/processOrder.d.ts +2 -3
  211. package/lib/services/processOrder.js +7 -27
  212. package/lib/services/processQuotation.d.ts +2 -3
  213. package/lib/services/processQuotation.js +2 -3
  214. package/lib/services/proposeQuotation.d.ts +2 -3
  215. package/lib/services/proposeQuotation.js +1 -2
  216. package/lib/services/registerPaymentCredentials.d.ts +2 -3
  217. package/lib/services/registerPaymentCredentials.js +1 -2
  218. package/lib/services/rejectOrder.d.ts +2 -3
  219. package/lib/services/rejectOrder.js +1 -2
  220. package/lib/services/rejectQuotation.d.ts +2 -3
  221. package/lib/services/rejectQuotation.js +1 -2
  222. package/lib/services/removeFiles.d.ts +1 -2
  223. package/lib/services/removeFiles.js +0 -2
  224. package/lib/services/removeProduct.d.ts +1 -2
  225. package/lib/services/removeProduct.js +1 -4
  226. package/lib/services/searchAssortments.d.ts +3 -4
  227. package/lib/services/searchAssortments.js +1 -2
  228. package/lib/services/searchProducts.d.ts +3 -4
  229. package/lib/services/searchProducts.js +1 -4
  230. package/lib/services/simulateProductDispatching.d.ts +5 -6
  231. package/lib/services/simulateProductDispatching.js +2 -3
  232. package/lib/services/simulateProductInventory.d.ts +4 -5
  233. package/lib/services/simulateProductInventory.js +2 -3
  234. package/lib/services/simulateProductPricing.d.ts +5 -6
  235. package/lib/services/simulateProductPricing.js +1 -2
  236. package/lib/services/supportedDeliveryProviders.d.ts +3 -4
  237. package/lib/services/supportedDeliveryProviders.js +1 -2
  238. package/lib/services/supportedPaymentProviders.d.ts +3 -4
  239. package/lib/services/supportedPaymentProviders.js +1 -2
  240. package/lib/services/supportedWarehousingProviders.d.ts +3 -4
  241. package/lib/services/supportedWarehousingProviders.js +1 -2
  242. package/lib/services/terminateEnrollment.d.ts +1 -2
  243. package/lib/services/terminateEnrollment.js +2 -3
  244. package/lib/services/updateCalculation.d.ts +2 -3
  245. package/lib/services/updateCalculation.js +3 -20
  246. package/lib/services/updateScheduling.d.ts +2 -3
  247. package/lib/services/updateScheduling.js +2 -4
  248. package/lib/services/updateUserAvatarAfterUpload.d.ts +2 -3
  249. package/lib/services/updateUserAvatarAfterUpload.js +1 -3
  250. package/lib/services/uploadFileFromStream.d.ts +2 -3
  251. package/lib/services/uploadFileFromStream.js +0 -1
  252. package/lib/services/uploadFileFromURL.d.ts +1 -2
  253. package/lib/services/uploadFileFromURL.js +0 -1
  254. package/lib/services/validateOrder.d.ts +2 -3
  255. package/lib/services/validateOrder.js +0 -1
  256. package/lib/services/verifyQuotation.d.ts +2 -3
  257. package/lib/services/verifyQuotation.js +1 -2
  258. package/package.json +27 -26
  259. package/lib/bulk-importer/createBulkImporter.d.ts.map +0 -1
  260. package/lib/bulk-importer/createBulkImporter.js.map +0 -1
  261. package/lib/bulk-importer/handlers/assortment/create.d.ts.map +0 -1
  262. package/lib/bulk-importer/handlers/assortment/create.js.map +0 -1
  263. package/lib/bulk-importer/handlers/assortment/index.d.ts.map +0 -1
  264. package/lib/bulk-importer/handlers/assortment/index.js.map +0 -1
  265. package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +0 -1
  266. package/lib/bulk-importer/handlers/assortment/remove.js.map +0 -1
  267. package/lib/bulk-importer/handlers/assortment/update.d.ts.map +0 -1
  268. package/lib/bulk-importer/handlers/assortment/update.js.map +0 -1
  269. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +0 -1
  270. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +0 -1
  271. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +0 -1
  272. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +0 -1
  273. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +0 -1
  274. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +0 -1
  275. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +0 -1
  276. package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +0 -1
  277. package/lib/bulk-importer/handlers/filter/create.d.ts.map +0 -1
  278. package/lib/bulk-importer/handlers/filter/create.js.map +0 -1
  279. package/lib/bulk-importer/handlers/filter/index.d.ts.map +0 -1
  280. package/lib/bulk-importer/handlers/filter/index.js.map +0 -1
  281. package/lib/bulk-importer/handlers/filter/remove.d.ts.map +0 -1
  282. package/lib/bulk-importer/handlers/filter/remove.js.map +0 -1
  283. package/lib/bulk-importer/handlers/filter/update.d.ts.map +0 -1
  284. package/lib/bulk-importer/handlers/filter/update.js.map +0 -1
  285. package/lib/bulk-importer/handlers/product/create.d.ts.map +0 -1
  286. package/lib/bulk-importer/handlers/product/create.js.map +0 -1
  287. package/lib/bulk-importer/handlers/product/index.d.ts.map +0 -1
  288. package/lib/bulk-importer/handlers/product/index.js.map +0 -1
  289. package/lib/bulk-importer/handlers/product/remove.d.ts.map +0 -1
  290. package/lib/bulk-importer/handlers/product/remove.js.map +0 -1
  291. package/lib/bulk-importer/handlers/product/update.d.ts.map +0 -1
  292. package/lib/bulk-importer/handlers/product/update.js.map +0 -1
  293. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +0 -1
  294. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +0 -1
  295. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +0 -1
  296. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +0 -1
  297. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +0 -1
  298. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +0 -1
  299. package/lib/bulk-importer/index.d.ts.map +0 -1
  300. package/lib/bulk-importer/index.js.map +0 -1
  301. package/lib/bulk-importer/upsertAsset.d.ts.map +0 -1
  302. package/lib/bulk-importer/upsertAsset.js.map +0 -1
  303. package/lib/core-index.d.ts.map +0 -1
  304. package/lib/core-index.js.map +0 -1
  305. package/lib/directors/BaseDiscountAdapter.d.ts.map +0 -1
  306. package/lib/directors/BaseDiscountAdapter.js.map +0 -1
  307. package/lib/directors/BaseDiscountDirector.d.ts.map +0 -1
  308. package/lib/directors/BaseDiscountDirector.js.map +0 -1
  309. package/lib/directors/BasePricingAdapter.d.ts.map +0 -1
  310. package/lib/directors/BasePricingAdapter.js.map +0 -1
  311. package/lib/directors/BasePricingDirector.d.ts.map +0 -1
  312. package/lib/directors/BasePricingDirector.js.map +0 -1
  313. package/lib/directors/BasePricingSheet.d.ts.map +0 -1
  314. package/lib/directors/BasePricingSheet.js.map +0 -1
  315. package/lib/directors/BaseWorker.d.ts.map +0 -1
  316. package/lib/directors/BaseWorker.js.map +0 -1
  317. package/lib/directors/DeliveryAdapter.d.ts.map +0 -1
  318. package/lib/directors/DeliveryAdapter.js.map +0 -1
  319. package/lib/directors/DeliveryDirector.d.ts.map +0 -1
  320. package/lib/directors/DeliveryDirector.js.map +0 -1
  321. package/lib/directors/DeliveryPricingAdapter.d.ts.map +0 -1
  322. package/lib/directors/DeliveryPricingAdapter.js.map +0 -1
  323. package/lib/directors/DeliveryPricingDirector.d.ts.map +0 -1
  324. package/lib/directors/DeliveryPricingDirector.js.map +0 -1
  325. package/lib/directors/DeliveryPricingSheet.d.ts.map +0 -1
  326. package/lib/directors/DeliveryPricingSheet.js.map +0 -1
  327. package/lib/directors/EnrollmentAdapter.d.ts.map +0 -1
  328. package/lib/directors/EnrollmentAdapter.js.map +0 -1
  329. package/lib/directors/EnrollmentDirector.d.ts.map +0 -1
  330. package/lib/directors/EnrollmentDirector.js.map +0 -1
  331. package/lib/directors/EventListenerWorker.d.ts.map +0 -1
  332. package/lib/directors/EventListenerWorker.js.map +0 -1
  333. package/lib/directors/FailedRescheduler.d.ts.map +0 -1
  334. package/lib/directors/FailedRescheduler.js.map +0 -1
  335. package/lib/directors/FilterAdapter.d.ts.map +0 -1
  336. package/lib/directors/FilterAdapter.js.map +0 -1
  337. package/lib/directors/FilterDirector.d.ts.map +0 -1
  338. package/lib/directors/FilterDirector.js.map +0 -1
  339. package/lib/directors/IntervalWorker.d.ts.map +0 -1
  340. package/lib/directors/IntervalWorker.js.map +0 -1
  341. package/lib/directors/MessagingDirector.d.ts.map +0 -1
  342. package/lib/directors/MessagingDirector.js.map +0 -1
  343. package/lib/directors/OrderDiscountAdapter.d.ts.map +0 -1
  344. package/lib/directors/OrderDiscountAdapter.js.map +0 -1
  345. package/lib/directors/OrderDiscountConfiguration.d.ts.map +0 -1
  346. package/lib/directors/OrderDiscountConfiguration.js.map +0 -1
  347. package/lib/directors/OrderDiscountDirector.d.ts.map +0 -1
  348. package/lib/directors/OrderDiscountDirector.js.map +0 -1
  349. package/lib/directors/OrderPricingAdapter.d.ts.map +0 -1
  350. package/lib/directors/OrderPricingAdapter.js.map +0 -1
  351. package/lib/directors/OrderPricingDirector.d.ts.map +0 -1
  352. package/lib/directors/OrderPricingDirector.js.map +0 -1
  353. package/lib/directors/OrderPricingSheet.d.ts.map +0 -1
  354. package/lib/directors/OrderPricingSheet.js.map +0 -1
  355. package/lib/directors/PaymentAdapter.d.ts.map +0 -1
  356. package/lib/directors/PaymentAdapter.js.map +0 -1
  357. package/lib/directors/PaymentDirector.d.ts.map +0 -1
  358. package/lib/directors/PaymentDirector.js.map +0 -1
  359. package/lib/directors/PaymentPricingAdapter.d.ts.map +0 -1
  360. package/lib/directors/PaymentPricingAdapter.js.map +0 -1
  361. package/lib/directors/PaymentPricingDirector.d.ts.map +0 -1
  362. package/lib/directors/PaymentPricingDirector.js.map +0 -1
  363. package/lib/directors/PaymentPricingSheet.d.ts.map +0 -1
  364. package/lib/directors/PaymentPricingSheet.js.map +0 -1
  365. package/lib/directors/ProductDiscountAdapter.d.ts.map +0 -1
  366. package/lib/directors/ProductDiscountAdapter.js.map +0 -1
  367. package/lib/directors/ProductDiscountConfiguration.d.ts.map +0 -1
  368. package/lib/directors/ProductDiscountConfiguration.js.map +0 -1
  369. package/lib/directors/ProductDiscountDirector.d.ts.map +0 -1
  370. package/lib/directors/ProductDiscountDirector.js.map +0 -1
  371. package/lib/directors/ProductPricingAdapter.d.ts.map +0 -1
  372. package/lib/directors/ProductPricingAdapter.js.map +0 -1
  373. package/lib/directors/ProductPricingDirector.d.ts.map +0 -1
  374. package/lib/directors/ProductPricingDirector.js.map +0 -1
  375. package/lib/directors/ProductPricingSheet.d.ts.map +0 -1
  376. package/lib/directors/ProductPricingSheet.js.map +0 -1
  377. package/lib/directors/QuotationAdapter.d.ts.map +0 -1
  378. package/lib/directors/QuotationAdapter.js.map +0 -1
  379. package/lib/directors/QuotationDirector.d.ts.map +0 -1
  380. package/lib/directors/QuotationDirector.js.map +0 -1
  381. package/lib/directors/WarehousingAdapter.d.ts.map +0 -1
  382. package/lib/directors/WarehousingAdapter.js.map +0 -1
  383. package/lib/directors/WarehousingDirector.d.ts.map +0 -1
  384. package/lib/directors/WarehousingDirector.js.map +0 -1
  385. package/lib/directors/WorkerAdapter.d.ts.map +0 -1
  386. package/lib/directors/WorkerAdapter.js.map +0 -1
  387. package/lib/directors/WorkerDirector.d.ts.map +0 -1
  388. package/lib/directors/WorkerDirector.js.map +0 -1
  389. package/lib/directors/index.d.ts.map +0 -1
  390. package/lib/directors/index.js.map +0 -1
  391. package/lib/factory/index.d.ts.map +0 -1
  392. package/lib/factory/index.js.map +0 -1
  393. package/lib/factory/registerAssortmentSearchFilter.d.ts.map +0 -1
  394. package/lib/factory/registerAssortmentSearchFilter.js.map +0 -1
  395. package/lib/factory/registerInvoicePayment.d.ts.map +0 -1
  396. package/lib/factory/registerInvoicePayment.js.map +0 -1
  397. package/lib/factory/registerPhysicalWarehousing.d.ts.map +0 -1
  398. package/lib/factory/registerPhysicalWarehousing.js.map +0 -1
  399. package/lib/factory/registerPickUpDelivery.d.ts.map +0 -1
  400. package/lib/factory/registerPickUpDelivery.js.map +0 -1
  401. package/lib/factory/registerProductDiscoverabilityFilter.d.ts.map +0 -1
  402. package/lib/factory/registerProductDiscoverabilityFilter.js.map +0 -1
  403. package/lib/factory/registerProductSearchFilter.d.ts.map +0 -1
  404. package/lib/factory/registerProductSearchFilter.js.map +0 -1
  405. package/lib/factory/registerShippingDelivery.d.ts.map +0 -1
  406. package/lib/factory/registerShippingDelivery.js.map +0 -1
  407. package/lib/factory/registerVirtualWarehousing.d.ts.map +0 -1
  408. package/lib/factory/registerVirtualWarehousing.js.map +0 -1
  409. package/lib/factory/registerWorker.d.ts.map +0 -1
  410. package/lib/factory/registerWorker.js.map +0 -1
  411. package/lib/modules.d.ts.map +0 -1
  412. package/lib/modules.js.map +0 -1
  413. package/lib/services/activateEnrollment.d.ts.map +0 -1
  414. package/lib/services/activateEnrollment.js.map +0 -1
  415. package/lib/services/addMessage.d.ts.map +0 -1
  416. package/lib/services/addMessage.js.map +0 -1
  417. package/lib/services/calculateDiscountTotal.d.ts.map +0 -1
  418. package/lib/services/calculateDiscountTotal.js.map +0 -1
  419. package/lib/services/checkoutOrder.d.ts.map +0 -1
  420. package/lib/services/checkoutOrder.js.map +0 -1
  421. package/lib/services/confirmOrder.d.ts.map +0 -1
  422. package/lib/services/confirmOrder.js.map +0 -1
  423. package/lib/services/createDownloadStream.d.ts.map +0 -1
  424. package/lib/services/createDownloadStream.js.map +0 -1
  425. package/lib/services/createEnrollmentFromCheckout.d.ts.map +0 -1
  426. package/lib/services/createEnrollmentFromCheckout.js.map +0 -1
  427. package/lib/services/createManualOrderDiscount.d.ts.map +0 -1
  428. package/lib/services/createManualOrderDiscount.js.map +0 -1
  429. package/lib/services/createSignedURL.d.ts.map +0 -1
  430. package/lib/services/createSignedURL.js.map +0 -1
  431. package/lib/services/deleteUser.d.ts.map +0 -1
  432. package/lib/services/deleteUser.js.map +0 -1
  433. package/lib/services/discountedEntities.d.ts.map +0 -1
  434. package/lib/services/discountedEntities.js.map +0 -1
  435. package/lib/services/ercMetadata.d.ts.map +0 -1
  436. package/lib/services/ercMetadata.js.map +0 -1
  437. package/lib/services/findOrInitCart.d.ts.map +0 -1
  438. package/lib/services/findOrInitCart.js.map +0 -1
  439. package/lib/services/fullfillQuotation.d.ts.map +0 -1
  440. package/lib/services/fullfillQuotation.js.map +0 -1
  441. package/lib/services/generateOrderFromEnrollment.d.ts.map +0 -1
  442. package/lib/services/generateOrderFromEnrollment.js.map +0 -1
  443. package/lib/services/index.d.ts.map +0 -1
  444. package/lib/services/index.js.map +0 -1
  445. package/lib/services/initCartProviders.d.ts.map +0 -1
  446. package/lib/services/initCartProviders.js.map +0 -1
  447. package/lib/services/initializeEnrollment.d.ts.map +0 -1
  448. package/lib/services/initializeEnrollment.js.map +0 -1
  449. package/lib/services/invalidateFilterCache.d.ts.map +0 -1
  450. package/lib/services/invalidateFilterCache.js.map +0 -1
  451. package/lib/services/linkFileService.d.ts.map +0 -1
  452. package/lib/services/linkFileService.js.map +0 -1
  453. package/lib/services/loadFilterOptions.d.ts.map +0 -1
  454. package/lib/services/loadFilterOptions.js.map +0 -1
  455. package/lib/services/loadFilters.d.ts.map +0 -1
  456. package/lib/services/loadFilters.js.map +0 -1
  457. package/lib/services/migrateBookmarks.d.ts.map +0 -1
  458. package/lib/services/migrateBookmarks.js.map +0 -1
  459. package/lib/services/migrateOrderCart.d.ts.map +0 -1
  460. package/lib/services/migrateOrderCart.js.map +0 -1
  461. package/lib/services/migrateUserData.d.ts.map +0 -1
  462. package/lib/services/migrateUserData.js.map +0 -1
  463. package/lib/services/nextUserCart.d.ts.map +0 -1
  464. package/lib/services/nextUserCart.js.map +0 -1
  465. package/lib/services/processEnrollment.d.ts.map +0 -1
  466. package/lib/services/processEnrollment.js.map +0 -1
  467. package/lib/services/processOrder.d.ts.map +0 -1
  468. package/lib/services/processOrder.js.map +0 -1
  469. package/lib/services/processQuotation.d.ts.map +0 -1
  470. package/lib/services/processQuotation.js.map +0 -1
  471. package/lib/services/proposeQuotation.d.ts.map +0 -1
  472. package/lib/services/proposeQuotation.js.map +0 -1
  473. package/lib/services/registerPaymentCredentials.d.ts.map +0 -1
  474. package/lib/services/registerPaymentCredentials.js.map +0 -1
  475. package/lib/services/rejectOrder.d.ts.map +0 -1
  476. package/lib/services/rejectOrder.js.map +0 -1
  477. package/lib/services/rejectQuotation.d.ts.map +0 -1
  478. package/lib/services/rejectQuotation.js.map +0 -1
  479. package/lib/services/removeFiles.d.ts.map +0 -1
  480. package/lib/services/removeFiles.js.map +0 -1
  481. package/lib/services/removeProduct.d.ts.map +0 -1
  482. package/lib/services/removeProduct.js.map +0 -1
  483. package/lib/services/searchAssortments.d.ts.map +0 -1
  484. package/lib/services/searchAssortments.js.map +0 -1
  485. package/lib/services/searchProducts.d.ts.map +0 -1
  486. package/lib/services/searchProducts.js.map +0 -1
  487. package/lib/services/simulateProductDispatching.d.ts.map +0 -1
  488. package/lib/services/simulateProductDispatching.js.map +0 -1
  489. package/lib/services/simulateProductInventory.d.ts.map +0 -1
  490. package/lib/services/simulateProductInventory.js.map +0 -1
  491. package/lib/services/simulateProductPricing.d.ts.map +0 -1
  492. package/lib/services/simulateProductPricing.js.map +0 -1
  493. package/lib/services/supportedDeliveryProviders.d.ts.map +0 -1
  494. package/lib/services/supportedDeliveryProviders.js.map +0 -1
  495. package/lib/services/supportedPaymentProviders.d.ts.map +0 -1
  496. package/lib/services/supportedPaymentProviders.js.map +0 -1
  497. package/lib/services/supportedWarehousingProviders.d.ts.map +0 -1
  498. package/lib/services/supportedWarehousingProviders.js.map +0 -1
  499. package/lib/services/terminateEnrollment.d.ts.map +0 -1
  500. package/lib/services/terminateEnrollment.js.map +0 -1
  501. package/lib/services/updateCalculation.d.ts.map +0 -1
  502. package/lib/services/updateCalculation.js.map +0 -1
  503. package/lib/services/updateScheduling.d.ts.map +0 -1
  504. package/lib/services/updateScheduling.js.map +0 -1
  505. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +0 -1
  506. package/lib/services/updateUserAvatarAfterUpload.js.map +0 -1
  507. package/lib/services/uploadFileFromStream.d.ts.map +0 -1
  508. package/lib/services/uploadFileFromStream.js.map +0 -1
  509. package/lib/services/uploadFileFromURL.d.ts.map +0 -1
  510. package/lib/services/uploadFileFromURL.js.map +0 -1
  511. package/lib/services/validateOrder.d.ts.map +0 -1
  512. package/lib/services/validateOrder.js.map +0 -1
  513. package/lib/services/verifyQuotation.d.ts.map +0 -1
  514. package/lib/services/verifyQuotation.js.map +0 -1
  515. package/src/bulk-importer/createBulkImporter.ts +0 -205
  516. package/src/bulk-importer/handlers/assortment/create.ts +0 -118
  517. package/src/bulk-importer/handlers/assortment/index.ts +0 -3
  518. package/src/bulk-importer/handlers/assortment/remove.ts +0 -26
  519. package/src/bulk-importer/handlers/assortment/update.ts +0 -133
  520. package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +0 -77
  521. package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +0 -70
  522. package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +0 -76
  523. package/src/bulk-importer/handlers/assortment/upsertMedia.ts +0 -76
  524. package/src/bulk-importer/handlers/filter/create.ts +0 -104
  525. package/src/bulk-importer/handlers/filter/index.ts +0 -3
  526. package/src/bulk-importer/handlers/filter/remove.ts +0 -25
  527. package/src/bulk-importer/handlers/filter/update.ts +0 -94
  528. package/src/bulk-importer/handlers/product/create.ts +0 -170
  529. package/src/bulk-importer/handlers/product/index.ts +0 -3
  530. package/src/bulk-importer/handlers/product/remove.ts +0 -27
  531. package/src/bulk-importer/handlers/product/update.ts +0 -175
  532. package/src/bulk-importer/handlers/product/upsertMedia.ts +0 -81
  533. package/src/bulk-importer/handlers/product/upsertVariations.ts +0 -110
  534. package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +0 -4
  535. package/src/bulk-importer/index.ts +0 -3
  536. package/src/bulk-importer/upsertAsset.ts +0 -53
  537. package/src/core-index.ts +0 -103
  538. package/src/directors/BaseDiscountAdapter.test.ts +0 -52
  539. package/src/directors/BaseDiscountAdapter.ts +0 -86
  540. package/src/directors/BaseDiscountDirector.ts +0 -73
  541. package/src/directors/BasePricingAdapter.ts +0 -74
  542. package/src/directors/BasePricingDirector.ts +0 -136
  543. package/src/directors/BasePricingSheet.test.ts +0 -45
  544. package/src/directors/BasePricingSheet.ts +0 -141
  545. package/src/directors/BaseWorker.ts +0 -117
  546. package/src/directors/DeliveryAdapter.ts +0 -106
  547. package/src/directors/DeliveryDirector.ts +0 -143
  548. package/src/directors/DeliveryPricingAdapter.ts +0 -87
  549. package/src/directors/DeliveryPricingDirector.ts +0 -91
  550. package/src/directors/DeliveryPricingSheet.ts +0 -87
  551. package/src/directors/EnrollmentAdapter.ts +0 -108
  552. package/src/directors/EnrollmentDirector.ts +0 -71
  553. package/src/directors/EventListenerWorker.ts +0 -101
  554. package/src/directors/FailedRescheduler.ts +0 -73
  555. package/src/directors/FilterAdapter.ts +0 -106
  556. package/src/directors/FilterDirector.ts +0 -314
  557. package/src/directors/IntervalWorker.ts +0 -75
  558. package/src/directors/MessagingDirector.test.ts +0 -8
  559. package/src/directors/MessagingDirector.ts +0 -52
  560. package/src/directors/OrderDiscountAdapter.ts +0 -10
  561. package/src/directors/OrderDiscountConfiguration.ts +0 -5
  562. package/src/directors/OrderDiscountDirector.ts +0 -5
  563. package/src/directors/OrderPricingAdapter.ts +0 -63
  564. package/src/directors/OrderPricingDirector.ts +0 -74
  565. package/src/directors/OrderPricingSheet.ts +0 -148
  566. package/src/directors/PaymentAdapter.ts +0 -118
  567. package/src/directors/PaymentDirector.ts +0 -297
  568. package/src/directors/PaymentPricingAdapter.ts +0 -86
  569. package/src/directors/PaymentPricingDirector.ts +0 -92
  570. package/src/directors/PaymentPricingSheet.ts +0 -92
  571. package/src/directors/ProductDiscountAdapter.ts +0 -10
  572. package/src/directors/ProductDiscountConfiguration.ts +0 -18
  573. package/src/directors/ProductDiscountDirector.ts +0 -4
  574. package/src/directors/ProductPricingAdapter.ts +0 -58
  575. package/src/directors/ProductPricingDirector.ts +0 -100
  576. package/src/directors/ProductPricingSheet.test.ts +0 -140
  577. package/src/directors/ProductPricingSheet.ts +0 -125
  578. package/src/directors/QuotationAdapter.ts +0 -82
  579. package/src/directors/QuotationDirector.ts +0 -105
  580. package/src/directors/WarehousingAdapter.ts +0 -77
  581. package/src/directors/WarehousingDirector.ts +0 -233
  582. package/src/directors/WorkerAdapter.ts +0 -31
  583. package/src/directors/WorkerDirector.ts +0 -149
  584. package/src/directors/index.ts +0 -53
  585. package/src/directors/periodForReferenceDate.test.ts +0 -25
  586. package/src/factory/index.ts +0 -21
  587. package/src/factory/registerAssortmentSearchFilter.ts +0 -36
  588. package/src/factory/registerInvoicePayment.ts +0 -61
  589. package/src/factory/registerPhysicalWarehousing.ts +0 -92
  590. package/src/factory/registerPickUpDelivery.ts +0 -81
  591. package/src/factory/registerProductDiscoverabilityFilter.ts +0 -36
  592. package/src/factory/registerProductSearchFilter.ts +0 -36
  593. package/src/factory/registerShippingDelivery.ts +0 -65
  594. package/src/factory/registerVirtualWarehousing.ts +0 -100
  595. package/src/factory/registerWorker.ts +0 -46
  596. package/src/modules.ts +0 -207
  597. package/src/services/activateEnrollment.ts +0 -26
  598. package/src/services/addMessage.ts +0 -20
  599. package/src/services/calculateDiscountTotal.ts +0 -71
  600. package/src/services/checkoutOrder.ts +0 -48
  601. package/src/services/confirmOrder.ts +0 -26
  602. package/src/services/createDownloadStream.ts +0 -17
  603. package/src/services/createEnrollmentFromCheckout.ts +0 -68
  604. package/src/services/createManualOrderDiscount.ts +0 -56
  605. package/src/services/createSignedURL.ts +0 -21
  606. package/src/services/deleteUser.ts +0 -48
  607. package/src/services/discountedEntities.ts +0 -81
  608. package/src/services/ercMetadata.ts +0 -25
  609. package/src/services/findOrInitCart.ts +0 -28
  610. package/src/services/fullfillQuotation.ts +0 -14
  611. package/src/services/generateOrderFromEnrollment.ts +0 -54
  612. package/src/services/index.ts +0 -173
  613. package/src/services/initCartProviders.ts +0 -84
  614. package/src/services/initializeEnrollment.ts +0 -41
  615. package/src/services/invalidateFilterCache.ts +0 -16
  616. package/src/services/linkFileService.ts +0 -24
  617. package/src/services/loadFilterOptions.ts +0 -49
  618. package/src/services/loadFilters.ts +0 -62
  619. package/src/services/migrateBookmarks.ts +0 -39
  620. package/src/services/migrateOrderCart.ts +0 -52
  621. package/src/services/migrateUserData.ts +0 -22
  622. package/src/services/nextUserCart.ts +0 -52
  623. package/src/services/processEnrollment.ts +0 -49
  624. package/src/services/processOrder.ts +0 -243
  625. package/src/services/processQuotation.ts +0 -71
  626. package/src/services/proposeQuotation.ts +0 -18
  627. package/src/services/registerPaymentCredentials.ts +0 -28
  628. package/src/services/rejectOrder.ts +0 -26
  629. package/src/services/rejectQuotation.ts +0 -18
  630. package/src/services/removeFiles.ts +0 -25
  631. package/src/services/removeProduct.ts +0 -39
  632. package/src/services/searchAssortments.ts +0 -57
  633. package/src/services/searchProducts.ts +0 -71
  634. package/src/services/simulateProductDispatching.ts +0 -58
  635. package/src/services/simulateProductInventory.ts +0 -59
  636. package/src/services/simulateProductPricing.ts +0 -23
  637. package/src/services/supportedDeliveryProviders.ts +0 -24
  638. package/src/services/supportedPaymentProviders.ts +0 -25
  639. package/src/services/supportedWarehousingProviders.ts +0 -18
  640. package/src/services/terminateEnrollment.ts +0 -25
  641. package/src/services/updateCalculation.ts +0 -159
  642. package/src/services/updateScheduling.ts +0 -63
  643. package/src/services/updateUserAvatarAfterUpload.ts +0 -33
  644. package/src/services/uploadFileFromStream.ts +0 -27
  645. package/src/services/uploadFileFromURL.ts +0 -29
  646. package/src/services/validateOrder.ts +0 -49
  647. package/src/services/verifyQuotation.ts +0 -18
  648. package/tsconfig.json +0 -9
@@ -1,73 +0,0 @@
1
- import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
2
- import { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.js';
3
- import { Modules } from '../modules.js';
4
-
5
- export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<
6
- IDiscountAdapter<DiscountConfiguration>
7
- > & {
8
- actions: (
9
- discountContext: DiscountContext,
10
- unchainedAPI: { modules: Modules },
11
- ) => Promise<{
12
- resolveDiscountAdapterFromStaticCode: (params: {
13
- code: string;
14
- }) => Promise<IDiscountAdapter<DiscountConfiguration> | null>;
15
- findSystemDiscounts: () => Promise<string[]>;
16
- }>;
17
- };
18
-
19
- export const BaseDiscountDirector = <DiscountConfigurationType>(
20
- directorName: string,
21
- ): IDiscountDirector<DiscountConfigurationType> => {
22
- const baseDirector = BaseDirector<IDiscountAdapter<DiscountConfigurationType>>(directorName, {
23
- adapterSortKey: 'orderIndex',
24
- });
25
-
26
- return {
27
- ...baseDirector,
28
-
29
- actions: async (discountContext, unchainedAPI) => {
30
- const context = { ...discountContext, ...unchainedAPI };
31
-
32
- return {
33
- resolveDiscountAdapterFromStaticCode: async (options) => {
34
- if (!context.order) return null;
35
-
36
- const discounts = await Promise.all(
37
- baseDirector
38
- .getAdapters()
39
- .filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
40
- .map(async (Adapter) => {
41
- const adapter = await Adapter.actions({ context });
42
- return {
43
- Adapter,
44
- isValid: await adapter.isValidForCodeTriggering(options),
45
- };
46
- }),
47
- );
48
-
49
- return discounts.find(({ isValid }) => isValid === true)?.Adapter || null;
50
- },
51
-
52
- async findSystemDiscounts() {
53
- if (!context.order) return [];
54
- const discounts = await Promise.all(
55
- baseDirector.getAdapters().map(async (Adapter) => {
56
- const adapter = await Adapter.actions({ context });
57
- return {
58
- key: Adapter.key,
59
- isValid: await adapter.isValidForSystemTriggering(),
60
- };
61
- }),
62
- );
63
-
64
- const validDiscounts = discounts
65
- .filter(({ isValid }) => isValid === true)
66
- .map(({ key }) => key);
67
-
68
- return validDiscounts;
69
- },
70
- };
71
- },
72
- };
73
- };
@@ -1,74 +0,0 @@
1
- import { IPricingSheet } from './BasePricingSheet.js';
2
- import { BaseAdapter, IBaseAdapter, PricingCalculation } from '@unchainedshop/utils';
3
- import { Discount } from './BasePricingDirector.js';
4
- import { Order, OrderDiscount } from '@unchainedshop/core-orders';
5
-
6
- interface IDiscountableItem {
7
- _id: string;
8
- orderId?: string;
9
- }
10
-
11
- export interface BasePricingAdapterContext {
12
- order?: Order;
13
- discounts: OrderDiscount[];
14
- }
15
-
16
- export type BasePricingContext =
17
- | {
18
- order?: Order;
19
- discounts?: OrderDiscount[];
20
- }
21
- | {
22
- item: IDiscountableItem;
23
- };
24
-
25
- export interface IPricingAdapterActions<
26
- Calculation extends PricingCalculation,
27
- Sheet extends IPricingSheet<Calculation>,
28
- > {
29
- calculate: () => Promise<Calculation[] | null>;
30
- resultSheet: () => Sheet;
31
- }
32
-
33
- export type IPricingAdapter<
34
- PricingAdapterContext extends BasePricingAdapterContext,
35
- Calculation extends PricingCalculation,
36
- Sheet extends IPricingSheet<Calculation>,
37
- DiscountConfiguration = unknown,
38
- > = IBaseAdapter & {
39
- orderIndex: number;
40
-
41
- isActivatedFor: (context: PricingAdapterContext) => boolean;
42
-
43
- actions: (params: {
44
- context: PricingAdapterContext;
45
- calculationSheet: Sheet;
46
- discounts: Discount<DiscountConfiguration>[];
47
- }) => IPricingAdapterActions<Calculation, Sheet>;
48
- };
49
-
50
- export const BasePricingAdapter = <
51
- PricingAdapterContext extends BasePricingAdapterContext,
52
- Calculation extends PricingCalculation,
53
- >(): IPricingAdapter<PricingAdapterContext, Calculation, IPricingSheet<Calculation>> => ({
54
- ...BaseAdapter,
55
- key: '',
56
- label: '',
57
- version: '',
58
- orderIndex: 0,
59
-
60
- isActivatedFor: () => {
61
- return false;
62
- },
63
-
64
- actions: () => {
65
- return {
66
- calculate: async () => {
67
- throw new Error('Method not implemented.');
68
- },
69
- resultSheet: () => {
70
- throw new Error('Method not implemented.');
71
- }, // abstract
72
- };
73
- },
74
- });
@@ -1,136 +0,0 @@
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: (pricingContext: PricingContext, unchainedAPI: Context) => Promise<Calculation[]>;
29
-
30
- calculationSheet: (pricingContext: PricingContext, calculation: Calculation[]) => PricingAdapterSheet;
31
- };
32
-
33
- export const BasePricingDirector = <
34
- DirectorContext extends BasePricingContext,
35
- AdapterContext extends BasePricingAdapterContext,
36
- Calculation extends PricingCalculation,
37
- PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>,
38
- >(
39
- directorName: string,
40
- ): IPricingDirector<
41
- DirectorContext,
42
- Calculation,
43
- AdapterContext,
44
- IPricingSheet<Calculation>,
45
- PricingAdapter
46
- > => {
47
- const baseDirector = BaseDirector<PricingAdapter>(directorName, {
48
- adapterSortKey: 'orderIndex',
49
- });
50
-
51
- const director: IPricingDirector<
52
- DirectorContext,
53
- Calculation,
54
- AdapterContext,
55
- IPricingSheet<Calculation>,
56
- PricingAdapter
57
- > = {
58
- ...baseDirector,
59
-
60
- buildPricingContext: async () => {
61
- throw new Error('Method not implemented');
62
- },
63
-
64
- calculationSheet() {
65
- throw new Error('Method not implemented');
66
- },
67
-
68
- async rebuildCalculation(this: typeof director, pricingContext, unchainedAPI) {
69
- const context = await this.buildPricingContext(pricingContext, unchainedAPI);
70
-
71
- let calculation: Calculation[] | null = [];
72
-
73
- const Adapters = baseDirector.getAdapters({
74
- adapterFilter: (Adapter) => {
75
- return Adapter.isActivatedFor(context);
76
- },
77
- });
78
-
79
- calculation = await Adapters.reduce(
80
- async (previousPromise, Adapter) => {
81
- const resolvedCalculation = await previousPromise;
82
- if (!resolvedCalculation) return null;
83
-
84
- const discounts: (Discount<any> | null)[] = await Promise.all(
85
- context.discounts.map(async (orderDiscount) => {
86
- // TODO: We shouldn't need to fetch this here, most probably we already have an order in context
87
- // 1. it should propably be required to pass an order
88
- // 2. we should pass the order in the pricing context or pricing adapter context
89
- // 3. it can't be different orders for different discounts in the same calculation rebuild
90
- const order = await unchainedAPI.modules.orders.findOrder({
91
- orderId: orderDiscount.orderId,
92
- });
93
- const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
94
- if (!DiscountAdapter) return null;
95
-
96
- const adapter = await DiscountAdapter.actions({
97
- context: { order: order!, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
98
- });
99
-
100
- const configuration = adapter.discountForPricingAdapterKey({
101
- pricingAdapterKey: Adapter.key,
102
- calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
103
- });
104
-
105
- return {
106
- discountId: orderDiscount._id,
107
- configuration,
108
- };
109
- }),
110
- );
111
-
112
- try {
113
- const adapter = Adapter.actions({
114
- context,
115
- calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
116
- discounts: discounts.filter((d) => d?.configuration !== null) as Discount<any>[],
117
- });
118
-
119
- const nextCalculationResult = await adapter.calculate();
120
- if (!nextCalculationResult) return null;
121
- calculation = resolvedCalculation.concat(nextCalculationResult);
122
- return calculation;
123
- } catch (error) {
124
- logger.error(error);
125
- }
126
- return resolvedCalculation;
127
- },
128
- Promise.resolve([] as Calculation[]),
129
- );
130
-
131
- return calculation || ([] as Calculation[]);
132
- },
133
- };
134
-
135
- return director;
136
- };
@@ -1,45 +0,0 @@
1
- import { describe, it } from 'node:test';
2
- import { resolveRatioAndTaxDivisorForPricingSheet } from './BasePricingSheet';
3
- import assert from 'node:assert';
4
-
5
- describe('resolveRatioAndTaxDivisorForPricingSheet', () => {
6
- it('total is 0 and pricing is provided', () => {
7
- const pricing: any = {
8
- taxSum: () => 10,
9
- gross: () => 20,
10
- net: () => 10,
11
- };
12
- const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 0);
13
- assert.deepStrictEqual(result, { ratio: 1, taxDivisor: 1 });
14
- });
15
-
16
- it('gross - tax is 0', () => {
17
- const pricing: any = {
18
- taxSum: () => 10,
19
- gross: () => 10,
20
- net: () => 0,
21
- };
22
- const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
23
- assert.deepStrictEqual(result, { ratio: 0, taxDivisor: 0 });
24
- });
25
-
26
- it('gross - tax is not 0', () => {
27
- const pricing: any = {
28
- taxSum: () => 10,
29
- gross: () => 20,
30
- net: () => 10,
31
- };
32
- const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
33
- assert.deepStrictEqual(result, { ratio: 1, taxDivisor: 2 });
34
- });
35
-
36
- it('taxSum is 0', () => {
37
- const pricing: any = {
38
- taxSum: () => 0,
39
- gross: () => 20,
40
- net: () => 20,
41
- };
42
- const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
43
- assert.deepStrictEqual(result, { ratio: 1, taxDivisor: 1 });
44
- });
45
- });
@@ -1,141 +0,0 @@
1
- import { PricingCalculation } from '@unchainedshop/utils';
2
- export interface PricingDiscount {
3
- discountId: string;
4
- amount: number;
5
- currencyCode: string;
6
- }
7
-
8
- export interface IPricingSheet<
9
- Calculation extends PricingCalculation,
10
- > extends IBasePricingSheet<Calculation> {
11
- discountPrices: (discountId?: string) => PricingDiscount[];
12
- addDiscount: (params: { amount: number; discountId: string; meta?: any }) => void;
13
- }
14
-
15
- export interface IBasePricingSheet<Calculation extends PricingCalculation> {
16
- calculation: Calculation[];
17
- currencyCode?: string;
18
- quantity?: number;
19
-
20
- getRawPricingSheet: () => Calculation[];
21
- filterBy: (filter?: Partial<Calculation>) => Calculation[];
22
- isValid: () => boolean;
23
-
24
- gross: () => number;
25
- net: () => number;
26
- sum: (filter?: Partial<Calculation>) => number;
27
- total: (params?: { category?: string; discountId?: string; useNetPrice?: boolean }) => {
28
- amount: number;
29
- currencyCode: string;
30
- };
31
-
32
- taxSum: (filter?: Partial<Calculation>) => number;
33
-
34
- resetCalculation: (sheetToInvert: IBasePricingSheet<Calculation>) => Calculation[];
35
- }
36
-
37
- export interface PricingSheetParams<Calculation extends PricingCalculation> {
38
- calculation?: Calculation[];
39
- currencyCode?: string;
40
- quantity?: number;
41
- }
42
-
43
- export const BasePricingSheet = <Calculation extends PricingCalculation>(
44
- params: PricingSheetParams<Calculation>,
45
- ): IBasePricingSheet<Calculation> => {
46
- const pricingSheet: IBasePricingSheet<Calculation> = {
47
- calculation: params.calculation || [],
48
- currencyCode: params.currencyCode,
49
- quantity: params.quantity,
50
-
51
- getRawPricingSheet() {
52
- return this.calculation;
53
- },
54
-
55
- isValid() {
56
- return this.calculation.length > 0;
57
- },
58
-
59
- sum(filter) {
60
- return this.filterBy(filter)
61
- .filter(Boolean)
62
- .reduce((sum: number, calculationRow: Calculation) => sum + calculationRow.amount, 0);
63
- },
64
-
65
- taxSum() {
66
- return 0;
67
- },
68
-
69
- gross() {
70
- // Sum contains taxes, thus it's gross when just suming everything
71
- return this.sum();
72
- },
73
-
74
- net() {
75
- // Remove all taxes from gross to get net
76
- return this.sum() - this.taxSum();
77
- },
78
-
79
- total({ category, useNetPrice, discountId } = { useNetPrice: false }) {
80
- const amount = this.sum({ category, discountId });
81
- const taxAmountForCategory = this.taxSum({ baseCategory: category, discountId });
82
-
83
- // Sum does not contain taxes when filtering by category, it's net in that case and gross if there is no category
84
- const netAmount = !category ? amount - taxAmountForCategory : amount;
85
-
86
- return {
87
- amount: Math.round(useNetPrice ? netAmount : netAmount + taxAmountForCategory),
88
- currencyCode: this.currencyCode,
89
- };
90
- },
91
-
92
- filterBy(filter) {
93
- const filteredCalculation = Object.keys(filter || {}).reduce(
94
- (oldCalculation, filterKey) =>
95
- oldCalculation.filter(
96
- (row: Calculation) =>
97
- !!row && (filter![filterKey] === undefined || row[filterKey] === filter![filterKey]),
98
- ),
99
- this.calculation,
100
- );
101
-
102
- return filteredCalculation;
103
- },
104
-
105
- resetCalculation(calculationSheet) {
106
- calculationSheet.filterBy().forEach(({ amount, ...row }: Calculation) => {
107
- this.calculation.push({
108
- ...row,
109
- amount: amount * -1,
110
- } as Calculation);
111
- });
112
- return this.calculation;
113
- },
114
- };
115
-
116
- return pricingSheet;
117
- };
118
-
119
- export const resolveRatioAndTaxDivisorForPricingSheet = (
120
- pricing: IBasePricingSheet<PricingCalculation>,
121
- total: number,
122
- ) => {
123
- if (total === 0 || !pricing) {
124
- return {
125
- ratio: 1,
126
- taxDivisor: 1,
127
- };
128
- }
129
- const tax = pricing.taxSum();
130
- const gross = pricing.gross();
131
- if (gross - tax === 0) {
132
- return {
133
- ratio: 0,
134
- taxDivisor: 0,
135
- };
136
- }
137
- return {
138
- ratio: gross / total,
139
- taxDivisor: gross / (gross - tax),
140
- };
141
- };
@@ -1,117 +0,0 @@
1
- import later from '@breejs/later';
2
- import { Work, WorkData } from '@unchainedshop/core-worker';
3
- import { WorkerDirector } from './WorkerDirector.js';
4
-
5
- export interface IWorker<P extends { workerId?: string }> {
6
- key: string;
7
- label: string;
8
- version: string;
9
- type: string;
10
- external: boolean;
11
-
12
- getFloorDate: (date?: Date) => Date;
13
-
14
- actions: (
15
- params: P,
16
- unchainedAPI,
17
- ) => {
18
- autorescheduleTypes: (options: { referenceDate: Date }) => Promise<(Work | null)[]>;
19
- process: (options: { maxWorkItemCount?: number; referenceDate?: Date }) => Promise<void>;
20
- reset: () => Promise<void> | void;
21
- start: () => Promise<void> | void;
22
- stop: () => Promise<void> | void;
23
- };
24
- }
25
-
26
- interface WorkerParams {
27
- workerId?: string;
28
- worker: IWorker<any>;
29
- }
30
-
31
- export const BaseWorker: IWorker<WorkerParams> = {
32
- key: 'shop.unchained.worker.base',
33
- label: 'Base worker. Do not use this directly.',
34
- version: '1.0.0',
35
- type: 'BASE',
36
- external: false,
37
-
38
- getFloorDate: (date = new Date()) => {
39
- const floored = new Date(Math.floor(date.getTime() / 1000) * 1000);
40
- return floored;
41
- },
42
-
43
- actions: ({ workerId }: WorkerParams, unchainedAPI) => {
44
- const workerActions = {
45
- async start() {
46
- throw new Error(`Not implemented on ${this.constructor.key}`);
47
- },
48
-
49
- async stop() {
50
- throw new Error(`Not implemented on ${this.constructor.key}`);
51
- },
52
-
53
- reset: async (referenceDate = new Date()) => {
54
- await unchainedAPI.modules.worker.markOldWorkAsFailed({
55
- types: WorkerDirector.getActivePluginTypes({ external: false }),
56
- worker: workerId,
57
- referenceDate,
58
- });
59
- },
60
-
61
- autorescheduleTypes: async ({ referenceDate }) => {
62
- return Promise.all(
63
- WorkerDirector.getAutoSchedules().map(async ([scheduleId, workConfig]) => {
64
- if (!workConfig.schedule) {
65
- await unchainedAPI.modules.worker.ensureNoWork({
66
- type: workConfig.type,
67
- priority: workConfig.priority || 0,
68
- scheduleId,
69
- });
70
- return null;
71
- }
72
-
73
- const fixedSchedule = { ...workConfig.schedule };
74
- fixedSchedule.schedules[0].s = [0]; // ignore seconds, always run on second 0
75
- const nextDate = later.schedule(fixedSchedule).next(1, referenceDate) as Date;
76
- nextDate.setMilliseconds(0);
77
- const workData: WorkData = {
78
- type: workConfig.type,
79
- scheduleId,
80
- scheduled: nextDate,
81
- timeout: workConfig.timeout,
82
- priority: workConfig.priority || 0,
83
- retries: workConfig.retries || 0,
84
- };
85
- if (workConfig.input) {
86
- workData.input = (await workConfig.input(workData)) || {};
87
- // A work input fn can skip auto scheduling a new record
88
- // when it explicitly returns a falsish input instead of a dictionary
89
- if (!workData.input) return null;
90
- }
91
- return unchainedAPI.modules.worker.ensureOneWork(workData);
92
- }),
93
- );
94
- },
95
-
96
- process: async ({ maxWorkItemCount = 10, referenceDate }) => {
97
- await workerActions.autorescheduleTypes({
98
- referenceDate,
99
- });
100
-
101
- let processedCount = 0;
102
- while (true) {
103
- if (maxWorkItemCount && maxWorkItemCount <= processedCount) break;
104
-
105
- const doneWork = await WorkerDirector.processNextWork(unchainedAPI, workerId);
106
- if (!doneWork) break;
107
-
108
- processedCount++;
109
- }
110
- },
111
- };
112
-
113
- workerActions.reset();
114
-
115
- return workerActions;
116
- },
117
- };
@@ -1,106 +0,0 @@
1
- import { BaseAdapter } from '@unchainedshop/utils';
2
- import type { 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 type {
9
- DeliveryConfiguration,
10
- DeliveryLocation,
11
- DeliveryProvider,
12
- DeliveryProviderType,
13
- } from '@unchainedshop/core-delivery';
14
- import type { 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 | null;
25
- estimatedDeliveryThroughput: (warehousingThroughputTime: number) => Promise<number | null>;
26
- isActive: () => boolean;
27
- isAutoReleaseAllowed: () => boolean;
28
- pickUpLocationById: (locationId: string) => Promise<DeliveryLocation | null>;
29
- pickUpLocations: () => Promise<DeliveryLocation[]>;
30
- send: () => Promise<boolean | Work>;
31
- }
32
-
33
- export interface DeliveryContext {
34
- countryCode?: string;
35
- order?: Order;
36
- orderDelivery?: OrderDelivery;
37
- orderPosition?: OrderPosition;
38
- product?: Product;
39
- quantity?: number;
40
- referenceDate?: Date;
41
- transactionContext?: any;
42
- user?: User;
43
- warehousingProvider?: WarehousingProvider;
44
- warehousingThroughputTime?: number;
45
- }
46
-
47
- export type IDeliveryAdapter = IBaseAdapter & {
48
- initialConfiguration: DeliveryConfiguration;
49
-
50
- typeSupported: (type: DeliveryProviderType) => boolean;
51
-
52
- actions: (
53
- config: DeliveryConfiguration,
54
- context: DeliveryContext & { modules: Modules; deliveryProvider: DeliveryProvider },
55
- ) => DeliveryAdapterActions;
56
- };
57
-
58
- export const DeliveryAdapter: Omit<IDeliveryAdapter, 'key' | 'label' | 'version'> = {
59
- ...BaseAdapter,
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
- };