@unchainedshop/core 4.0.0-rc.9 → 4.0.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 (447) hide show
  1. package/lib/bulk-importer/createBulkImporter.d.ts +84 -0
  2. package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -0
  3. package/lib/bulk-importer/createBulkImporter.js +142 -0
  4. package/lib/bulk-importer/createBulkImporter.js.map +1 -0
  5. package/lib/bulk-importer/handlers/assortment/create.d.ts +565 -0
  6. package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -0
  7. package/lib/bulk-importer/handlers/assortment/create.js +89 -0
  8. package/lib/bulk-importer/handlers/assortment/create.js.map +1 -0
  9. package/lib/bulk-importer/handlers/assortment/index.d.ts +4 -0
  10. package/lib/bulk-importer/handlers/assortment/index.d.ts.map +1 -0
  11. package/lib/bulk-importer/handlers/assortment/index.js +4 -0
  12. package/lib/bulk-importer/handlers/assortment/index.js.map +1 -0
  13. package/lib/bulk-importer/handlers/assortment/remove.d.ts +30 -0
  14. package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -0
  15. package/lib/bulk-importer/handlers/assortment/remove.js +18 -0
  16. package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -0
  17. package/lib/bulk-importer/handlers/assortment/update.d.ts +566 -0
  18. package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -0
  19. package/lib/bulk-importer/handlers/assortment/update.js +98 -0
  20. package/lib/bulk-importer/handlers/assortment/update.js.map +1 -0
  21. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +29 -0
  22. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -0
  23. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +45 -0
  24. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -0
  25. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +29 -0
  26. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -0
  27. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +41 -0
  28. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -0
  29. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +29 -0
  30. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -0
  31. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +46 -0
  32. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -0
  33. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +76 -0
  34. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -0
  35. package/lib/bulk-importer/handlers/assortment/upsertMedia.js +53 -0
  36. package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -0
  37. package/lib/bulk-importer/handlers/filter/create.d.ts +138 -0
  38. package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -0
  39. package/lib/bulk-importer/handlers/filter/create.js +80 -0
  40. package/lib/bulk-importer/handlers/filter/create.js.map +1 -0
  41. package/lib/bulk-importer/handlers/filter/index.d.ts +4 -0
  42. package/lib/bulk-importer/handlers/filter/index.d.ts.map +1 -0
  43. package/lib/bulk-importer/handlers/filter/index.js +4 -0
  44. package/lib/bulk-importer/handlers/filter/index.js.map +1 -0
  45. package/lib/bulk-importer/handlers/filter/remove.d.ts +20 -0
  46. package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -0
  47. package/lib/bulk-importer/handlers/filter/remove.js +18 -0
  48. package/lib/bulk-importer/handlers/filter/remove.js.map +1 -0
  49. package/lib/bulk-importer/handlers/filter/update.d.ts +138 -0
  50. package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -0
  51. package/lib/bulk-importer/handlers/filter/update.js +70 -0
  52. package/lib/bulk-importer/handlers/filter/update.js.map +1 -0
  53. package/lib/bulk-importer/handlers/product/create.d.ts +1330 -0
  54. package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -0
  55. package/lib/bulk-importer/handlers/product/create.js +132 -0
  56. package/lib/bulk-importer/handlers/product/create.js.map +1 -0
  57. package/lib/bulk-importer/handlers/product/index.d.ts +4 -0
  58. package/lib/bulk-importer/handlers/product/index.d.ts.map +1 -0
  59. package/lib/bulk-importer/handlers/product/index.js +4 -0
  60. package/lib/bulk-importer/handlers/product/index.js.map +1 -0
  61. package/lib/bulk-importer/handlers/product/remove.d.ts +32 -0
  62. package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -0
  63. package/lib/bulk-importer/handlers/product/remove.js +18 -0
  64. package/lib/bulk-importer/handlers/product/remove.js.map +1 -0
  65. package/lib/bulk-importer/handlers/product/update.d.ts +1330 -0
  66. package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -0
  67. package/lib/bulk-importer/handlers/product/update.js +132 -0
  68. package/lib/bulk-importer/handlers/product/update.js.map +1 -0
  69. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +75 -0
  70. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -0
  71. package/lib/bulk-importer/handlers/product/upsertMedia.js +59 -0
  72. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -0
  73. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +79 -0
  74. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -0
  75. package/lib/bulk-importer/handlers/product/upsertVariations.js +72 -0
  76. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -0
  77. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +3 -0
  78. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -0
  79. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +6 -0
  80. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -0
  81. package/lib/bulk-importer/index.d.ts +4 -0
  82. package/lib/bulk-importer/index.d.ts.map +1 -0
  83. package/lib/bulk-importer/index.js +4 -0
  84. package/lib/bulk-importer/index.js.map +1 -0
  85. package/lib/bulk-importer/upsertAsset.d.ts +28 -0
  86. package/lib/bulk-importer/upsertAsset.d.ts.map +1 -0
  87. package/lib/bulk-importer/upsertAsset.js +41 -0
  88. package/lib/bulk-importer/upsertAsset.js.map +1 -0
  89. package/lib/core-index.d.ts +9 -6
  90. package/lib/core-index.d.ts.map +1 -1
  91. package/lib/core-index.js +5 -1
  92. package/lib/core-index.js.map +1 -1
  93. package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
  94. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
  95. package/lib/directors/BaseDiscountAdapter.js +1 -1
  96. package/lib/directors/BaseDiscountAdapter.js.map +1 -1
  97. package/lib/directors/BaseDiscountDirector.d.ts +1 -1
  98. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
  99. package/lib/directors/BaseDiscountDirector.js +1 -1
  100. package/lib/directors/BaseDiscountDirector.js.map +1 -1
  101. package/lib/directors/BasePricingAdapter.d.ts +2 -2
  102. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  103. package/lib/directors/BasePricingDirector.d.ts.map +1 -1
  104. package/lib/directors/BasePricingDirector.js +3 -3
  105. package/lib/directors/BasePricingDirector.js.map +1 -1
  106. package/lib/directors/BasePricingSheet.js.map +1 -1
  107. package/lib/directors/BaseWorker.js +1 -1
  108. package/lib/directors/BaseWorker.js.map +1 -1
  109. package/lib/directors/DeliveryAdapter.d.ts +3 -3
  110. package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
  111. package/lib/directors/DeliveryDirector.d.ts +3 -3
  112. package/lib/directors/DeliveryDirector.d.ts.map +1 -1
  113. package/lib/directors/DeliveryDirector.js +29 -16
  114. package/lib/directors/DeliveryDirector.js.map +1 -1
  115. package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
  116. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
  117. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
  118. package/lib/directors/DeliveryPricingDirector.js +3 -4
  119. package/lib/directors/DeliveryPricingDirector.js.map +1 -1
  120. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
  121. package/lib/directors/DeliveryPricingSheet.js +2 -1
  122. package/lib/directors/DeliveryPricingSheet.js.map +1 -1
  123. package/lib/directors/EnrollmentAdapter.d.ts +7 -4
  124. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
  125. package/lib/directors/EnrollmentAdapter.js +1 -4
  126. package/lib/directors/EnrollmentAdapter.js.map +1 -1
  127. package/lib/directors/EnrollmentDirector.d.ts +1 -1
  128. package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
  129. package/lib/directors/EnrollmentDirector.js +1 -5
  130. package/lib/directors/EnrollmentDirector.js.map +1 -1
  131. package/lib/directors/FilterAdapter.d.ts +3 -3
  132. package/lib/directors/FilterAdapter.d.ts.map +1 -1
  133. package/lib/directors/FilterDirector.d.ts +1 -1
  134. package/lib/directors/FilterDirector.d.ts.map +1 -1
  135. package/lib/directors/FilterDirector.js +7 -8
  136. package/lib/directors/FilterDirector.js.map +1 -1
  137. package/lib/directors/MessagingDirector.d.ts +2 -2
  138. package/lib/directors/MessagingDirector.d.ts.map +1 -1
  139. package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
  140. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
  141. package/lib/directors/OrderDiscountAdapter.js.map +1 -1
  142. package/lib/directors/OrderPricingAdapter.d.ts +2 -2
  143. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
  144. package/lib/directors/OrderPricingDirector.d.ts +2 -2
  145. package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
  146. package/lib/directors/OrderPricingDirector.js +1 -1
  147. package/lib/directors/OrderPricingDirector.js.map +1 -1
  148. package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
  149. package/lib/directors/OrderPricingSheet.js +2 -1
  150. package/lib/directors/OrderPricingSheet.js.map +1 -1
  151. package/lib/directors/PaymentAdapter.d.ts +2 -2
  152. package/lib/directors/PaymentAdapter.d.ts.map +1 -1
  153. package/lib/directors/PaymentDirector.d.ts +4 -4
  154. package/lib/directors/PaymentDirector.d.ts.map +1 -1
  155. package/lib/directors/PaymentDirector.js +24 -6
  156. package/lib/directors/PaymentDirector.js.map +1 -1
  157. package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
  158. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
  159. package/lib/directors/PaymentPricingDirector.d.ts +1 -1
  160. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
  161. package/lib/directors/PaymentPricingDirector.js +3 -5
  162. package/lib/directors/PaymentPricingDirector.js.map +1 -1
  163. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
  164. package/lib/directors/PaymentPricingSheet.js +2 -1
  165. package/lib/directors/PaymentPricingSheet.js.map +1 -1
  166. package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
  167. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
  168. package/lib/directors/ProductDiscountAdapter.js.map +1 -1
  169. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
  170. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
  171. package/lib/directors/ProductPricingAdapter.d.ts +1 -1
  172. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  173. package/lib/directors/ProductPricingDirector.d.ts +2 -2
  174. package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
  175. package/lib/directors/ProductPricingDirector.js +3 -3
  176. package/lib/directors/ProductPricingDirector.js.map +1 -1
  177. package/lib/directors/ProductPricingSheet.d.ts +2 -2
  178. package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
  179. package/lib/directors/ProductPricingSheet.js +2 -1
  180. package/lib/directors/ProductPricingSheet.js.map +1 -1
  181. package/lib/directors/QuotationAdapter.d.ts +2 -2
  182. package/lib/directors/QuotationAdapter.d.ts.map +1 -1
  183. package/lib/directors/QuotationDirector.js +2 -2
  184. package/lib/directors/WarehousingAdapter.d.ts +3 -4
  185. package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
  186. package/lib/directors/WarehousingAdapter.js.map +1 -1
  187. package/lib/directors/WarehousingDirector.d.ts +5 -5
  188. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  189. package/lib/directors/WarehousingDirector.js +10 -13
  190. package/lib/directors/WarehousingDirector.js.map +1 -1
  191. package/lib/directors/WorkerAdapter.d.ts +3 -2
  192. package/lib/directors/WorkerAdapter.d.ts.map +1 -1
  193. package/lib/directors/WorkerAdapter.js +1 -1
  194. package/lib/directors/WorkerAdapter.js.map +1 -1
  195. package/lib/directors/WorkerDirector.d.ts +2 -2
  196. package/lib/directors/WorkerDirector.d.ts.map +1 -1
  197. package/lib/directors/WorkerDirector.js +2 -3
  198. package/lib/directors/WorkerDirector.js.map +1 -1
  199. package/lib/factory/index.d.ts +3 -0
  200. package/lib/factory/index.d.ts.map +1 -0
  201. package/lib/factory/index.js +3 -0
  202. package/lib/factory/index.js.map +1 -0
  203. package/lib/factory/registerProductDiscoverabilityFilter.d.ts +5 -0
  204. package/lib/factory/registerProductDiscoverabilityFilter.d.ts.map +1 -0
  205. package/lib/factory/registerProductDiscoverabilityFilter.js +27 -0
  206. package/lib/factory/registerProductDiscoverabilityFilter.js.map +1 -0
  207. package/lib/modules.d.ts +4 -5
  208. package/lib/modules.d.ts.map +1 -1
  209. package/lib/modules.js +3 -3
  210. package/lib/modules.js.map +1 -1
  211. package/lib/services/activateEnrollment.d.ts.map +1 -1
  212. package/lib/services/activateEnrollment.js +8 -12
  213. package/lib/services/activateEnrollment.js.map +1 -1
  214. package/lib/services/addMessage.d.ts +4 -0
  215. package/lib/services/addMessage.d.ts.map +1 -0
  216. package/lib/services/addMessage.js +15 -0
  217. package/lib/services/addMessage.js.map +1 -0
  218. package/lib/services/calculateDiscountTotal.js +2 -2
  219. package/lib/services/calculateDiscountTotal.js.map +1 -1
  220. package/lib/services/checkoutOrder.d.ts +1 -1
  221. package/lib/services/checkoutOrder.d.ts.map +1 -1
  222. package/lib/services/checkoutOrder.js +10 -4
  223. package/lib/services/checkoutOrder.js.map +1 -1
  224. package/lib/services/confirmOrder.d.ts +1 -1
  225. package/lib/services/confirmOrder.d.ts.map +1 -1
  226. package/lib/services/createDownloadStream.d.ts +1 -1
  227. package/lib/services/createDownloadStream.d.ts.map +1 -1
  228. package/lib/services/createDownloadStream.js +2 -0
  229. package/lib/services/createDownloadStream.js.map +1 -1
  230. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
  231. package/lib/services/createEnrollmentFromCheckout.js +2 -2
  232. package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
  233. package/lib/services/createManualOrderDiscount.d.ts +2 -2
  234. package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
  235. package/lib/services/createSignedURL.d.ts.map +1 -1
  236. package/lib/services/createSignedURL.js +2 -0
  237. package/lib/services/createSignedURL.js.map +1 -1
  238. package/lib/services/deleteUser.d.ts +1 -1
  239. package/lib/services/deleteUser.d.ts.map +1 -1
  240. package/lib/services/deleteUser.js +4 -2
  241. package/lib/services/deleteUser.js.map +1 -1
  242. package/lib/services/discountedEntities.js.map +1 -1
  243. package/lib/services/findOrInitCart.d.ts +1 -2
  244. package/lib/services/findOrInitCart.d.ts.map +1 -1
  245. package/lib/services/findOrInitCart.js.map +1 -1
  246. package/lib/services/fullfillQuotation.d.ts +1 -1
  247. package/lib/services/fullfillQuotation.d.ts.map +1 -1
  248. package/lib/services/fullfillQuotation.js.map +1 -1
  249. package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
  250. package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
  251. package/lib/services/generateOrderFromEnrollment.js +34 -0
  252. package/lib/services/generateOrderFromEnrollment.js.map +1 -0
  253. package/lib/services/index.d.ts +6 -0
  254. package/lib/services/index.d.ts.map +1 -1
  255. package/lib/services/index.js +6 -0
  256. package/lib/services/index.js.map +1 -1
  257. package/lib/services/initCartProviders.d.ts.map +1 -1
  258. package/lib/services/initCartProviders.js +6 -2
  259. package/lib/services/initCartProviders.js.map +1 -1
  260. package/lib/services/initializeEnrollment.d.ts +1 -1
  261. package/lib/services/initializeEnrollment.d.ts.map +1 -1
  262. package/lib/services/initializeEnrollment.js +11 -12
  263. package/lib/services/initializeEnrollment.js.map +1 -1
  264. package/lib/services/linkFileService.d.ts +1 -1
  265. package/lib/services/linkFileService.d.ts.map +1 -1
  266. package/lib/services/linkFileService.js +3 -1
  267. package/lib/services/linkFileService.js.map +1 -1
  268. package/lib/services/loadFilterOptions.d.ts +2 -2
  269. package/lib/services/loadFilterOptions.d.ts.map +1 -1
  270. package/lib/services/migrateOrderCart.d.ts +1 -1
  271. package/lib/services/migrateOrderCart.d.ts.map +1 -1
  272. package/lib/services/nextUserCart.d.ts +1 -1
  273. package/lib/services/nextUserCart.d.ts.map +1 -1
  274. package/lib/services/nextUserCart.js +1 -1
  275. package/lib/services/nextUserCart.js.map +1 -1
  276. package/lib/services/processEnrollment.d.ts.map +1 -1
  277. package/lib/services/processEnrollment.js +13 -5
  278. package/lib/services/processEnrollment.js.map +1 -1
  279. package/lib/services/processOrder.d.ts.map +1 -1
  280. package/lib/services/processOrder.js +30 -30
  281. package/lib/services/processOrder.js.map +1 -1
  282. package/lib/services/processQuotation.d.ts.map +1 -1
  283. package/lib/services/processQuotation.js +10 -14
  284. package/lib/services/processQuotation.js.map +1 -1
  285. package/lib/services/proposeQuotation.d.ts +1 -1
  286. package/lib/services/proposeQuotation.d.ts.map +1 -1
  287. package/lib/services/proposeQuotation.js +2 -2
  288. package/lib/services/proposeQuotation.js.map +1 -1
  289. package/lib/services/registerPaymentCredentials.d.ts +1 -2
  290. package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
  291. package/lib/services/registerPaymentCredentials.js +4 -6
  292. package/lib/services/registerPaymentCredentials.js.map +1 -1
  293. package/lib/services/rejectOrder.d.ts +1 -1
  294. package/lib/services/rejectOrder.d.ts.map +1 -1
  295. package/lib/services/rejectQuotation.d.ts +1 -1
  296. package/lib/services/rejectQuotation.d.ts.map +1 -1
  297. package/lib/services/rejectQuotation.js +2 -2
  298. package/lib/services/rejectQuotation.js.map +1 -1
  299. package/lib/services/removeFiles.js +2 -2
  300. package/lib/services/removeFiles.js.map +1 -1
  301. package/lib/services/removeProduct.js +3 -3
  302. package/lib/services/removeProduct.js.map +1 -1
  303. package/lib/services/searchAssortments.d.ts.map +1 -1
  304. package/lib/services/searchAssortments.js +3 -2
  305. package/lib/services/searchAssortments.js.map +1 -1
  306. package/lib/services/searchProducts.d.ts.map +1 -1
  307. package/lib/services/searchProducts.js +3 -2
  308. package/lib/services/searchProducts.js.map +1 -1
  309. package/lib/services/simulateProductDispatching.d.ts +1 -1
  310. package/lib/services/simulateProductDispatching.d.ts.map +1 -1
  311. package/lib/services/simulateProductInventory.d.ts +1 -1
  312. package/lib/services/simulateProductInventory.d.ts.map +1 -1
  313. package/lib/services/simulateProductInventory.js.map +1 -1
  314. package/lib/services/simulateProductPricing.d.ts +7 -4
  315. package/lib/services/simulateProductPricing.d.ts.map +1 -1
  316. package/lib/services/simulateProductPricing.js.map +1 -1
  317. package/lib/services/terminateEnrollment.d.ts.map +1 -1
  318. package/lib/services/terminateEnrollment.js +5 -9
  319. package/lib/services/terminateEnrollment.js.map +1 -1
  320. package/lib/services/updateCalculation.d.ts +2 -1
  321. package/lib/services/updateCalculation.d.ts.map +1 -1
  322. package/lib/services/updateCalculation.js +20 -12
  323. package/lib/services/updateCalculation.js.map +1 -1
  324. package/lib/services/updateScheduling.d.ts +1 -1
  325. package/lib/services/updateScheduling.d.ts.map +1 -1
  326. package/lib/services/updateScheduling.js +7 -11
  327. package/lib/services/updateScheduling.js.map +1 -1
  328. package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
  329. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
  330. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
  331. package/lib/services/uploadFileFromStream.d.ts.map +1 -1
  332. package/lib/services/uploadFileFromStream.js +4 -1
  333. package/lib/services/uploadFileFromStream.js.map +1 -1
  334. package/lib/services/uploadFileFromURL.d.ts +1 -2
  335. package/lib/services/uploadFileFromURL.d.ts.map +1 -1
  336. package/lib/services/uploadFileFromURL.js.map +1 -1
  337. package/lib/services/validateOrder.d.ts +1 -1
  338. package/lib/services/validateOrder.d.ts.map +1 -1
  339. package/lib/services/validateOrder.js +17 -24
  340. package/lib/services/validateOrder.js.map +1 -1
  341. package/lib/services/verifyQuotation.d.ts +1 -1
  342. package/lib/services/verifyQuotation.d.ts.map +1 -1
  343. package/lib/services/verifyQuotation.js +2 -2
  344. package/lib/services/verifyQuotation.js.map +1 -1
  345. package/package.json +21 -20
  346. package/src/bulk-importer/createBulkImporter.ts +205 -0
  347. package/src/bulk-importer/handlers/assortment/create.ts +118 -0
  348. package/src/bulk-importer/handlers/assortment/index.ts +3 -0
  349. package/src/bulk-importer/handlers/assortment/remove.ts +26 -0
  350. package/src/bulk-importer/handlers/assortment/update.ts +133 -0
  351. package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +77 -0
  352. package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +70 -0
  353. package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +76 -0
  354. package/src/bulk-importer/handlers/assortment/upsertMedia.ts +76 -0
  355. package/src/bulk-importer/handlers/filter/create.ts +104 -0
  356. package/src/bulk-importer/handlers/filter/index.ts +3 -0
  357. package/src/bulk-importer/handlers/filter/remove.ts +25 -0
  358. package/src/bulk-importer/handlers/filter/update.ts +94 -0
  359. package/src/bulk-importer/handlers/product/create.ts +170 -0
  360. package/src/bulk-importer/handlers/product/index.ts +3 -0
  361. package/src/bulk-importer/handlers/product/remove.ts +27 -0
  362. package/src/bulk-importer/handlers/product/update.ts +175 -0
  363. package/src/bulk-importer/handlers/product/upsertMedia.ts +81 -0
  364. package/src/bulk-importer/handlers/product/upsertVariations.ts +110 -0
  365. package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +4 -0
  366. package/src/bulk-importer/index.ts +3 -0
  367. package/src/bulk-importer/upsertAsset.ts +50 -0
  368. package/src/core-index.ts +10 -7
  369. package/src/directors/BaseDiscountAdapter.test.ts +1 -1
  370. package/src/directors/BaseDiscountAdapter.ts +5 -5
  371. package/src/directors/BaseDiscountDirector.ts +2 -2
  372. package/src/directors/BasePricingAdapter.ts +2 -2
  373. package/src/directors/BasePricingDirector.ts +47 -44
  374. package/src/directors/BasePricingSheet.ts +1 -1
  375. package/src/directors/BaseWorker.ts +1 -1
  376. package/src/directors/DeliveryAdapter.ts +3 -3
  377. package/src/directors/DeliveryDirector.ts +33 -23
  378. package/src/directors/DeliveryPricingAdapter.ts +1 -1
  379. package/src/directors/DeliveryPricingDirector.ts +5 -6
  380. package/src/directors/DeliveryPricingSheet.ts +3 -2
  381. package/src/directors/EnrollmentAdapter.ts +9 -6
  382. package/src/directors/EnrollmentDirector.ts +9 -8
  383. package/src/directors/FilterAdapter.ts +3 -3
  384. package/src/directors/FilterDirector.ts +11 -12
  385. package/src/directors/MessagingDirector.ts +1 -1
  386. package/src/directors/OrderDiscountAdapter.ts +2 -2
  387. package/src/directors/OrderPricingAdapter.ts +2 -2
  388. package/src/directors/OrderPricingDirector.ts +3 -3
  389. package/src/directors/OrderPricingSheet.ts +3 -2
  390. package/src/directors/PaymentAdapter.ts +2 -2
  391. package/src/directors/PaymentDirector.ts +34 -10
  392. package/src/directors/PaymentPricingAdapter.ts +2 -2
  393. package/src/directors/PaymentPricingDirector.ts +6 -8
  394. package/src/directors/PaymentPricingSheet.ts +3 -2
  395. package/src/directors/ProductDiscountAdapter.ts +2 -2
  396. package/src/directors/ProductDiscountConfiguration.ts +1 -1
  397. package/src/directors/ProductPricingAdapter.ts +1 -1
  398. package/src/directors/ProductPricingDirector.ts +7 -7
  399. package/src/directors/ProductPricingSheet.ts +4 -3
  400. package/src/directors/QuotationAdapter.ts +2 -2
  401. package/src/directors/QuotationDirector.ts +2 -2
  402. package/src/directors/WarehousingAdapter.ts +3 -4
  403. package/src/directors/WarehousingDirector.ts +20 -23
  404. package/src/directors/WorkerAdapter.ts +9 -4
  405. package/src/directors/WorkerDirector.ts +5 -6
  406. package/src/factory/index.ts +3 -0
  407. package/src/factory/registerProductDiscoverabilityFilter.ts +36 -0
  408. package/src/modules.ts +6 -7
  409. package/src/services/activateEnrollment.ts +9 -13
  410. package/src/services/addMessage.ts +20 -0
  411. package/src/services/calculateDiscountTotal.ts +4 -4
  412. package/src/services/checkoutOrder.ts +10 -5
  413. package/src/services/createDownloadStream.ts +1 -0
  414. package/src/services/createEnrollmentFromCheckout.ts +22 -20
  415. package/src/services/createManualOrderDiscount.ts +2 -2
  416. package/src/services/createSignedURL.ts +1 -0
  417. package/src/services/deleteUser.ts +7 -2
  418. package/src/services/discountedEntities.ts +6 -6
  419. package/src/services/findOrInitCart.ts +1 -2
  420. package/src/services/fullfillQuotation.ts +1 -1
  421. package/src/services/generateOrderFromEnrollment.ts +54 -0
  422. package/src/services/index.ts +8 -0
  423. package/src/services/initCartProviders.ts +8 -10
  424. package/src/services/initializeEnrollment.ts +16 -13
  425. package/src/services/linkFileService.ts +3 -1
  426. package/src/services/nextUserCart.ts +1 -1
  427. package/src/services/processEnrollment.ts +18 -6
  428. package/src/services/processOrder.ts +37 -36
  429. package/src/services/processQuotation.ts +10 -14
  430. package/src/services/proposeQuotation.ts +2 -2
  431. package/src/services/registerPaymentCredentials.ts +6 -8
  432. package/src/services/rejectQuotation.ts +2 -2
  433. package/src/services/removeFiles.ts +2 -2
  434. package/src/services/removeProduct.ts +3 -3
  435. package/src/services/searchAssortments.ts +3 -2
  436. package/src/services/searchProducts.ts +4 -2
  437. package/src/services/simulateProductDispatching.ts +1 -1
  438. package/src/services/simulateProductInventory.ts +7 -3
  439. package/src/services/simulateProductPricing.ts +6 -3
  440. package/src/services/terminateEnrollment.ts +5 -9
  441. package/src/services/updateCalculation.ts +37 -20
  442. package/src/services/updateScheduling.ts +19 -20
  443. package/src/services/updateUserAvatarAfterUpload.ts +4 -1
  444. package/src/services/uploadFileFromStream.ts +3 -1
  445. package/src/services/uploadFileFromURL.ts +2 -2
  446. package/src/services/validateOrder.ts +34 -38
  447. package/src/services/verifyQuotation.ts +2 -2
@@ -4,11 +4,12 @@ import {
4
4
  OrderDeliveryStatus,
5
5
  OrderPayment,
6
6
  OrderPaymentStatus,
7
+ OrderPosition,
7
8
  OrderStatus,
8
9
  } from '@unchainedshop/core-orders';
9
10
  import { Modules } from '../modules.js';
10
11
  import { createEnrollmentFromCheckoutService } from './createEnrollmentFromCheckout.js';
11
- import { ProductTypes } from '@unchainedshop/core-products';
12
+ import { Product, ProductTypes } from '@unchainedshop/core-products';
12
13
  import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
13
14
  import { WarehousingDirector, DeliveryDirector, PaymentDirector } from '../directors/index.js';
14
15
  import { fullfillQuotationService } from './fullfillQuotation.js';
@@ -24,10 +25,12 @@ const isAutoConfirmationEnabled = async (
24
25
  modules: Modules,
25
26
  ) => {
26
27
  if (orderPayment.status !== OrderPaymentStatus.PAID) {
27
- const provider = await modules.payment.paymentProviders.findProvider({
28
+ const paymentProvider = await modules.payment.paymentProviders.findProvider({
28
29
  paymentProviderId: orderPayment.paymentProviderId,
29
30
  });
30
- const actions = await PaymentDirector.actions(provider, {}, { modules });
31
+ if (!paymentProvider)
32
+ throw new Error('Payment provider not found: ' + orderPayment.paymentProviderId);
33
+ const actions = await PaymentDirector.actions(paymentProvider, {}, { modules });
31
34
  if (!actions.isPayLaterAllowed()) return false;
32
35
  }
33
36
 
@@ -35,6 +38,8 @@ const isAutoConfirmationEnabled = async (
35
38
  const deliveryProvider = await modules.delivery.findProvider({
36
39
  deliveryProviderId: orderDelivery.deliveryProviderId,
37
40
  });
41
+ if (!deliveryProvider)
42
+ throw new Error('Delivery provider not found: ' + orderDelivery.deliveryProviderId);
38
43
  const director = await DeliveryDirector.actions(deliveryProvider, {}, { modules });
39
44
  if (!director.isAutoReleaseAllowed()) return false;
40
45
  }
@@ -56,14 +61,18 @@ const findNextStatus = async (
56
61
  return status;
57
62
  }
58
63
 
59
- const orderPayment = await modules.orders.payments.findOrderPayment({
60
- orderPaymentId: order.paymentId,
61
- });
64
+ const orderPayment =
65
+ order.paymentId &&
66
+ (await modules.orders.payments.findOrderPayment({
67
+ orderPaymentId: order.paymentId,
68
+ }));
62
69
  if (!orderPayment) return status;
63
70
 
64
- const orderDelivery = await modules.orders.deliveries.findDelivery({
65
- orderDeliveryId: order.deliveryId,
66
- });
71
+ const orderDelivery =
72
+ order.deliveryId &&
73
+ (await modules.orders.deliveries.findDelivery({
74
+ orderDeliveryId: order.deliveryId,
75
+ }));
67
76
  if (!orderDelivery) return status;
68
77
 
69
78
  // Ok, we have a payment and a delivery and the correct status,
@@ -108,26 +117,18 @@ export async function processOrderService(
108
117
 
109
118
  if (nextStatus === OrderStatus.PENDING) {
110
119
  // auto charge during transition to pending
111
- const orderPayment = await this.orders.payments.findOrderPayment({
112
- orderPaymentId: order.paymentId,
113
- });
114
-
115
120
  await PaymentDirector.chargeOrderPayment(
116
- orderPayment,
121
+ order,
117
122
  { userId: order.userId, transactionContext: paymentContext },
118
123
  { modules: this },
119
124
  );
120
-
121
125
  nextStatus = await findNextStatus(nextStatus, order, this);
122
126
  }
123
127
 
124
128
  if (nextStatus === OrderStatus.REJECTED) {
125
129
  // auto cancel during transition to rejected
126
- const orderPayment = await this.orders.payments.findOrderPayment({
127
- orderPaymentId: order.paymentId,
128
- });
129
130
  await PaymentDirector.cancelOrderPayment(
130
- orderPayment,
131
+ order,
131
132
  { userId: order.userId, transactionContext: paymentContext },
132
133
  { modules: this },
133
134
  );
@@ -135,11 +136,8 @@ export async function processOrderService(
135
136
 
136
137
  if (nextStatus === OrderStatus.CONFIRMED) {
137
138
  // confirm pre-authorized payments
138
- const orderPayment = await this.orders.payments.findOrderPayment({
139
- orderPaymentId: order.paymentId,
140
- });
141
139
  await PaymentDirector.confirmOrderPayment(
142
- orderPayment,
140
+ order,
143
141
  { userId: order.userId, transactionContext: paymentContext },
144
142
  { modules: this },
145
143
  );
@@ -147,23 +145,23 @@ export async function processOrderService(
147
145
  // we have to stop here shortly to complete the confirmation
148
146
  // before auto delivery is started, else we have no chance to create
149
147
  // numbers that are needed for delivery
150
- order = await this.orders.updateStatus(orderId, {
148
+ order = (await this.orders.updateStatus(orderId, {
151
149
  status: OrderStatus.CONFIRMED,
152
150
  info: comment,
153
- });
154
-
155
- const orderDelivery = await this.orders.deliveries.findDelivery({
156
- orderDeliveryId: order.deliveryId,
157
- });
151
+ })) as Order;
158
152
 
159
- await DeliveryDirector.sendOrderDelivery(orderDelivery, deliveryContext, { modules: this });
153
+ // TODO: What happens if this THROWS?
154
+ // Tokenization would be skipped?
155
+ // Enrollments will not be there?
156
+ // Quotations would not fulfil?
157
+ await DeliveryDirector.sendOrderDelivery(order, deliveryContext, { modules: this });
160
158
 
161
159
  const orderPositions = await this.orders.positions.findOrderPositions({ orderId });
162
160
  const mappedProductOrderPositions = await Promise.all(
163
161
  orderPositions.map(async (orderPosition) => {
164
- const product = await this.products.findProduct({
162
+ const product = (await this.products.findProduct({
165
163
  productId: orderPosition.productId,
166
- });
164
+ })) as Product;
167
165
  return {
168
166
  orderPosition,
169
167
  product,
@@ -172,7 +170,8 @@ export async function processOrderService(
172
170
  );
173
171
  const tokenizedItems = mappedProductOrderPositions.filter(
174
172
  (item) => item.product?.type === ProductTypes.TokenizedProduct,
175
- );
173
+ ) as { orderPosition: OrderPosition; product: Product }[];
174
+
176
175
  if (tokenizedItems.length > 0) {
177
176
  // Give virtual warehouse a chance to instantiate new virtual objects
178
177
  const virtualProviders = (await this.warehousing.allProviders()).filter(
@@ -180,7 +179,7 @@ export async function processOrderService(
180
179
  );
181
180
 
182
181
  // It's very important to do this in a series and not in Promise.all
183
- // TODO: Actually, only createTokens should decide on the unique chainTokenId
182
+ // TODO: Actually, only createTokens should decide on the unique tokenSerialNumber
184
183
  // and the tokens should be created with a distributed Lock to not assign the same id multiple times!
185
184
  for (const { orderPosition, product } of tokenizedItems) {
186
185
  for (const virtualProvider of virtualProviders) {
@@ -221,12 +220,14 @@ export async function processOrderService(
221
220
  // Quotations: If we came here, the checkout succeeded, so we can fullfill underlying quotations
222
221
  const quotationItems = mappedProductOrderPositions.filter(
223
222
  (item) => item.orderPosition.quotationId,
224
- );
223
+ ) as { orderPosition: OrderPosition & { quotationId: string }; product: Product }[];
224
+
225
225
  await Promise.all(
226
226
  quotationItems.map(async ({ orderPosition }) => {
227
227
  const quotation = await this.quotations.findQuotation({
228
228
  quotationId: orderPosition.quotationId,
229
229
  });
230
+ if (!quotation) return; // TODO: What happens then?
230
231
  await fullfillQuotationService.bind(this)(quotation, {
231
232
  orderId,
232
233
  orderPositionId: orderPosition._id,
@@ -238,5 +239,5 @@ export async function processOrderService(
238
239
  nextStatus = await findNextStatus(nextStatus, order, this);
239
240
  }
240
241
 
241
- return this.orders.updateStatus(order._id, { status: nextStatus, info: comment });
242
+ return (await this.orders.updateStatus(order._id, { status: nextStatus, info: comment })) as Order;
242
243
  }
@@ -1,6 +1,7 @@
1
1
  import { Quotation, QuotationStatus } from '@unchainedshop/core-quotations';
2
2
  import { Modules } from '../modules.js';
3
3
  import { QuotationDirector } from '../core-index.js';
4
+ import { addMessageService } from './addMessage.js';
4
5
 
5
6
  const findNextStatus = async (quotation: Quotation, modules: Modules): Promise<QuotationStatus> => {
6
7
  let status = quotation.status as QuotationStatus;
@@ -33,42 +34,37 @@ export async function processQuotationService(
33
34
  await director.submitRequest(params.quotationContext);
34
35
  }
35
36
 
36
- quotation = await this.quotations.findQuotation({ quotationId });
37
+ quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
37
38
  nextStatus = await findNextStatus(quotation, this);
38
39
  if (nextStatus !== QuotationStatus.PROCESSING) {
39
40
  await director.verifyRequest(params.quotationContext);
40
41
  }
41
42
 
42
- quotation = await this.quotations.findQuotation({ quotationId });
43
+ quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
43
44
  nextStatus = await findNextStatus(quotation, this);
44
45
  if (nextStatus === QuotationStatus.REJECTED) {
45
46
  await director.rejectRequest(params.quotationContext);
46
47
  }
47
48
 
48
- quotation = await this.quotations.findQuotation({ quotationId });
49
+ quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
49
50
  nextStatus = await findNextStatus(quotation, this);
50
51
  if (nextStatus === QuotationStatus.PROPOSED) {
51
52
  const proposal = await director.quote();
52
- quotation = await this.quotations.updateProposal(quotation._id, proposal);
53
+ quotation = (await this.quotations.updateProposal(quotation._id, proposal)) as Quotation;
53
54
  nextStatus = await findNextStatus(quotation, this);
54
55
  }
55
56
 
56
- const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
57
+ const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
57
58
  status: nextStatus,
58
59
  info: 'quotation processed',
59
- });
60
+ })) as Quotation;
60
61
 
61
62
  const user = await this.users.findUserById(updatedQuotation.userId);
62
63
  const locale = this.users.userLocale(user);
63
64
 
64
- await this.worker.addWork({
65
- type: 'MESSAGE',
66
- retries: 0,
67
- input: {
68
- locale: locale.baseName,
69
- template: 'QUOTATION_STATUS',
70
- quotationId: updatedQuotation._id,
71
- },
65
+ await addMessageService.bind(this)('QUOTATION_STATUS', {
66
+ locale: locale.baseName,
67
+ quotationId: updatedQuotation._id,
72
68
  });
73
69
 
74
70
  return updatedQuotation;
@@ -9,10 +9,10 @@ export async function proposeQuotationService(
9
9
  ) {
10
10
  if (quotation.status !== QuotationStatus.PROCESSING) return quotation;
11
11
 
12
- const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
12
+ const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
13
13
  status: QuotationStatus.PROPOSED,
14
14
  info: 'proposed manually',
15
- });
15
+ })) as Quotation;
16
16
 
17
17
  return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
18
18
  }
@@ -1,4 +1,3 @@
1
- import { PaymentCredentials } from '@unchainedshop/core-payment';
2
1
  import { PaymentContext } from '../directors/PaymentAdapter.js';
3
2
  import { PaymentDirector } from '../directors/PaymentDirector.js';
4
3
  import { Modules } from '../modules.js';
@@ -7,24 +6,23 @@ export async function registerPaymentCredentialsService(
7
6
  this: Modules,
8
7
  paymentProviderId: string,
9
8
  paymentContext: PaymentContext,
10
- ): Promise<PaymentCredentials> {
9
+ ) {
11
10
  const paymentProvider = await this.payment.paymentProviders.findProvider({
12
11
  paymentProviderId,
13
12
  });
13
+
14
+ if (!paymentProvider) return null;
15
+
14
16
  const actions = await PaymentDirector.actions(paymentProvider, paymentContext, { modules: this });
15
17
  const registration = await actions.register();
16
18
 
17
19
  if (!registration) return null;
18
20
 
19
- const paymentCredentialsId = await this.payment.paymentCredentials.upsertCredentials({
21
+ const paymentCredentials = await this.payment.paymentCredentials.upsertCredentials({
20
22
  userId: paymentContext.userId,
21
23
  paymentProviderId,
22
24
  ...registration,
23
25
  });
24
26
 
25
- return this.payment.paymentCredentials.findPaymentCredential({
26
- paymentCredentialsId,
27
- userId: paymentContext.userId,
28
- paymentProviderId,
29
- });
27
+ return paymentCredentials;
30
28
  }
@@ -9,10 +9,10 @@ export async function rejectQuotationService(
9
9
  ) {
10
10
  if (quotation.status === QuotationStatus.FULLFILLED) return quotation;
11
11
 
12
- const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
12
+ const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
13
13
  status: QuotationStatus.REJECTED,
14
14
  info: 'rejected manually',
15
- });
15
+ })) as Quotation;
16
16
 
17
17
  return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
18
18
  }
@@ -13,8 +13,8 @@ export async function removeFilesService(this: Modules, { fileIds }: { fileIds:
13
13
 
14
14
  try {
15
15
  await fileUploadAdapter.removeFiles(fileObjects, { modules: this });
16
- } catch (e) {
17
- console.warn(e);
16
+ } catch {
17
+ /**/
18
18
  }
19
19
 
20
20
  const fileIdsToDelete = fileObjects.map((f) => f._id).filter(Boolean);
@@ -8,7 +8,7 @@ export async function removeProductService(
8
8
  ): Promise<boolean> {
9
9
  const product = await this.products.findProduct({ productId });
10
10
 
11
- switch (product.status) {
11
+ switch (product?.status) {
12
12
  case ProductStatus.ACTIVE:
13
13
  await this.products.unpublish(product);
14
14
  // falls through
@@ -16,7 +16,7 @@ export async function removeProductService(
16
16
  case ProductStatus.DRAFT:
17
17
  {
18
18
  await this.bookmarks.deleteByProductId(productId);
19
- await this.assortments.products.delete(productId);
19
+ await this.assortments.products.deleteMany({ productId });
20
20
  await this.products.removeAllAssignmentsAndBundleItems(productId);
21
21
  const orderIdsToRecalculate =
22
22
  await this.orders.positions.removeProductByIdFromAllOpenPositions(productId);
@@ -29,7 +29,7 @@ export async function removeProductService(
29
29
  }
30
30
  break;
31
31
  default:
32
- throw new Error(`Invalid status', ${product.status}`);
32
+ throw new Error(`Invalid status: ${product?.status}`);
33
33
  }
34
34
 
35
35
  return true;
@@ -29,14 +29,15 @@ export async function searchAssortmentsService(
29
29
  filterSelector,
30
30
  assortmentSelector,
31
31
  sortStage,
32
- forceLiveCollection,
32
+ forceLiveCollection: !!forceLiveCollection,
33
33
  locale,
34
34
  };
35
35
 
36
36
  const assortmentIds = await searchQuery.assortmentIds;
37
37
 
38
38
  const totalAssortmentIds =
39
- (await filterActions.searchAssortments({ assortmentIds }, searchConfiguration)) || [];
39
+ (await filterActions.searchAssortments({ assortmentIds }, searchConfiguration)) ||
40
+ (await this.assortments.findAssortmentIds({ includeInactive: searchQuery.includeInactive }));
40
41
 
41
42
  return {
42
43
  searchConfiguration,
@@ -32,7 +32,7 @@ export async function searchProductsService(
32
32
  filterSelector,
33
33
  productSelector,
34
34
  sortStage,
35
- forceLiveCollection,
35
+ forceLiveCollection: !!forceLiveCollection,
36
36
  locale,
37
37
  };
38
38
 
@@ -47,7 +47,9 @@ export async function searchProductsService(
47
47
  };
48
48
  }
49
49
 
50
- const totalProductIds = (await filterActions.searchProducts(searchQuery, searchConfiguration)) || [];
50
+ const totalProductIds =
51
+ (await filterActions.searchProducts(searchQuery, searchConfiguration)) ||
52
+ (await this.products.findProductIds({ includeDrafts: searchQuery.includeInactive }));
51
53
 
52
54
  const filteredProductIds = await FilterDirector.productFacetedSearch(
53
55
  totalProductIds,
@@ -13,7 +13,7 @@ export async function simulateProductDispatchingService(
13
13
  referenceDate,
14
14
  }: {
15
15
  product: Product;
16
- quantity?: number;
16
+ quantity: number;
17
17
  referenceDate?: Date;
18
18
  },
19
19
  ) {
@@ -1,7 +1,7 @@
1
1
  import { Modules } from '../modules.js';
2
2
  import { supportedWarehousingProvidersService } from './supportedWarehousingProviders.js';
3
3
  import { Product } from '@unchainedshop/core-products';
4
- import { EstimatedStock, WarehousingDirector } from '../directors/WarehousingDirector.js';
4
+ import { WarehousingDirector } from '../directors/WarehousingDirector.js';
5
5
  import { WarehousingContext } from '../directors/WarehousingAdapter.js';
6
6
  import { WarehousingProvider } from '@unchainedshop/core-warehousing';
7
7
 
@@ -18,7 +18,11 @@ export async function simulateProductInventoryService(
18
18
  const deliveryProviders = await this.delivery.allProviders();
19
19
 
20
20
  return deliveryProviders.reduce<
21
- Promise<(WarehousingContext & EstimatedStock & { warehousingProvider: WarehousingProvider })[]>
21
+ Promise<
22
+ (WarehousingContext & { quantity?: number } & {
23
+ warehousingProvider: WarehousingProvider;
24
+ })[]
25
+ >
22
26
  >(async (oldResult, deliveryProvider) => {
23
27
  const result = await oldResult;
24
28
 
@@ -31,7 +35,7 @@ export async function simulateProductInventoryService(
31
35
 
32
36
  const mappedWarehousingProviders = await Promise.all(
33
37
  warehousingProviders.map(async (warehousingProvider) => {
34
- const warehousingContext: WarehousingContext = {
38
+ const warehousingContext = {
35
39
  deliveryProvider,
36
40
  product,
37
41
  referenceDate,
@@ -2,16 +2,19 @@ import { Product, ProductConfiguration } from '@unchainedshop/core-products';
2
2
  import { ProductPricingDirector } from '../core-index.js';
3
3
  import { User } from '@unchainedshop/core-users';
4
4
  import { Modules } from '../modules.js';
5
+ import { Order, OrderDiscount } from '@unchainedshop/core-orders';
5
6
 
6
7
  export async function simulateProductPricingService(
7
8
  this: Modules,
8
9
  pricingContext: {
9
- product: Product;
10
- user: User;
11
- countryCode: string;
12
10
  currencyCode: string;
11
+ countryCode: string;
13
12
  quantity: number;
13
+ discounts: OrderDiscount[];
14
+ order?: Order;
15
+ product: Product;
14
16
  configuration?: ProductConfiguration[];
17
+ user?: User;
15
18
  },
16
19
  ) {
17
20
  const calculated = await ProductPricingDirector.rebuildCalculation(pricingContext, { modules: this });
@@ -1,5 +1,6 @@
1
1
  import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
2
2
  import { processEnrollmentService } from './processEnrollment.js';
3
+ import { addMessageService } from './addMessage.js';
3
4
 
4
5
  export async function terminateEnrollmentService(enrollment: Enrollment) {
5
6
  if (enrollment.status === EnrollmentStatus.TERMINATED) return enrollment;
@@ -14,15 +15,10 @@ export async function terminateEnrollmentService(enrollment: Enrollment) {
14
15
  const user = await this.users.findUserById(enrollment.userId);
15
16
  const locale = this.users.userLocale(user);
16
17
 
17
- await this.worker.addWork({
18
- type: 'MESSAGE',
19
- retries: 0,
20
- input: {
21
- reason: 'status_change',
22
- locale: locale.baseName,
23
- template: 'ENROLLMENT_STATUS',
24
- enrollmentId: updatedEnrollment._id,
25
- },
18
+ await addMessageService.bind(this)('ENROLLMENT_STATUS', {
19
+ reason: 'status_change',
20
+ locale: locale.baseName,
21
+ enrollmentId: updatedEnrollment._id,
26
22
  });
27
23
 
28
24
  return updatedEnrollment;
@@ -1,4 +1,10 @@
1
- import { OrderDiscountTrigger } from '@unchainedshop/core-orders';
1
+ import {
2
+ OrderDelivery,
3
+ OrderDiscountTrigger,
4
+ OrderPayment,
5
+ Order,
6
+ OrderPosition,
7
+ } from '@unchainedshop/core-orders';
2
8
  import { initCartProvidersService } from './initCartProviders.js';
3
9
  import { Modules } from '../modules.js';
4
10
  import { updateSchedulingService } from './updateScheduling.js';
@@ -11,7 +17,8 @@ import {
11
17
  } from '../directors/index.js';
12
18
 
13
19
  export async function updateCalculationService(this: Modules, orderId: string) {
14
- const order = await this.orders.findOrder({ orderId });
20
+ let order = await this.orders.findOrder({ orderId });
21
+ if (!order) throw new Error('Order not found');
15
22
 
16
23
  // Don't recalculate orders, only carts
17
24
  if (order.status !== null) return order;
@@ -27,15 +34,17 @@ export async function updateCalculationService(this: Modules, orderId: string) {
27
34
  const Adapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
28
35
  if (!Adapter) return null;
29
36
  const adapter = await Adapter.actions({
30
- context: { order, orderDiscount, code: orderDiscount.code, modules: this },
37
+ context: { order: order!, orderDiscount, code: orderDiscount.code, modules: this },
31
38
  });
32
39
 
33
- const isValid =
34
- orderDiscount.trigger === OrderDiscountTrigger.SYSTEM
35
- ? await adapter.isValidForSystemTriggering()
36
- : await adapter.isValidForCodeTriggering({
37
- code: orderDiscount.code,
38
- });
40
+ let isValid = false;
41
+ if (orderDiscount.trigger === OrderDiscountTrigger.SYSTEM) {
42
+ isValid = await adapter.isValidForSystemTriggering();
43
+ } else if (orderDiscount.trigger === OrderDiscountTrigger.USER && orderDiscount.code) {
44
+ isValid = await adapter.isValidForCodeTriggering({
45
+ code: orderDiscount.code,
46
+ });
47
+ }
39
48
 
40
49
  if (!isValid) {
41
50
  if (orderDiscount.trigger === OrderDiscountTrigger.USER) {
@@ -52,14 +61,14 @@ export async function updateCalculationService(this: Modules, orderId: string) {
52
61
  });
53
62
 
54
63
  const currentDiscountKeys = cleanedDiscounts.map(({ discountKey }) => discountKey);
55
- const director = await OrderDiscountDirector.actions({ order, code: null }, { modules: this });
64
+ const director = await OrderDiscountDirector.actions({ order }, { modules: this });
56
65
  const systemDiscounts = await director.findSystemDiscounts();
57
66
  await Promise.all(
58
67
  systemDiscounts
59
68
  .filter((key) => currentDiscountKeys.indexOf(key) === -1)
60
69
  .map(async (discountKey) =>
61
70
  this.orders.discounts.create({
62
- orderId: order._id,
71
+ orderId: order!._id,
63
72
  discountKey,
64
73
  trigger: OrderDiscountTrigger.SYSTEM,
65
74
  }),
@@ -73,18 +82,21 @@ export async function updateCalculationService(this: Modules, orderId: string) {
73
82
  orderPositions.map(async (orderPosition) => {
74
83
  const positionCalculation = await ProductPricingDirector.rebuildCalculation(
75
84
  {
76
- currencyCode: order.currencyCode,
85
+ currencyCode: order!.currencyCode,
77
86
  quantity: orderPosition.quantity,
78
87
  item: orderPosition,
79
88
  },
80
89
  { modules: this },
81
90
  );
82
- return this.orders.positions.updateCalculation(orderPosition._id, positionCalculation);
91
+ return (await this.orders.positions.updateCalculation(
92
+ orderPosition._id,
93
+ positionCalculation,
94
+ )) as OrderPosition;
83
95
  }),
84
96
  );
85
97
 
86
98
  let orderDelivery = await this.orders.deliveries.findDelivery({
87
- orderDeliveryId: order.deliveryId,
99
+ orderDeliveryId: order.deliveryId!,
88
100
  });
89
101
  if (orderDelivery) {
90
102
  const deliveryCalculation = await DeliveryPricingDirector.rebuildCalculation(
@@ -94,13 +106,13 @@ export async function updateCalculationService(this: Modules, orderId: string) {
94
106
  },
95
107
  { modules: this },
96
108
  );
97
- orderDelivery = await this.orders.deliveries.updateCalculation(
109
+ orderDelivery = (await this.orders.deliveries.updateCalculation(
98
110
  orderDelivery._id,
99
111
  deliveryCalculation,
100
- );
112
+ )) as OrderDelivery;
101
113
  }
102
114
  let orderPayment = await this.orders.payments.findOrderPayment({
103
- orderPaymentId: order.paymentId,
115
+ orderPaymentId: order.paymentId!,
104
116
  });
105
117
  if (orderPayment) {
106
118
  const paymentCalculation = await PaymentPricingDirector.rebuildCalculation(
@@ -110,7 +122,10 @@ export async function updateCalculationService(this: Modules, orderId: string) {
110
122
  },
111
123
  { modules: this },
112
124
  );
113
- orderPayment = await this.orders.payments.updateCalculation(orderPayment._id, paymentCalculation);
125
+ orderPayment = (await this.orders.payments.updateCalculation(
126
+ orderPayment._id,
127
+ paymentCalculation,
128
+ )) as OrderPayment;
114
129
  }
115
130
 
116
131
  orderPositions = await updateSchedulingService.bind(this)({
@@ -124,7 +139,9 @@ export async function updateCalculationService(this: Modules, orderId: string) {
124
139
  { modules: this },
125
140
  );
126
141
 
127
- const updatedOrder = await this.orders.updateCalculationSheet(orderId, calculation);
142
+ if (JSON.stringify(order.calculation) !== JSON.stringify(calculation)) {
143
+ order = (await this.orders.updateCalculationSheet(orderId, calculation)) as Order;
144
+ }
128
145
 
129
146
  /*
130
147
  // We have to do initCartProviders after calculation, only then filterSupportedProviders will work correctly and has access to recent pricing
@@ -138,5 +155,5 @@ export async function updateCalculationService(this: Modules, orderId: string) {
138
155
  // 6. update calculation -> order pricing updated to items 0, delivery 0, payment 0
139
156
  // 7. initCartProviders with updated order -> all providers are valid -> return order
140
157
  */
141
- return initCartProvidersService.bind(this)(updatedOrder);
158
+ return initCartProvidersService.bind(this)(order);
142
159
  }