@unchainedshop/core 4.0.0-rc.16 → 4.0.0-rc.18

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 (412) hide show
  1. package/lib/bulk-importer/createBulkImporter.d.ts +29 -6
  2. package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -1
  3. package/lib/bulk-importer/createBulkImporter.js +26 -19
  4. package/lib/bulk-importer/createBulkImporter.js.map +1 -1
  5. package/lib/bulk-importer/handlers/assortment/create.d.ts +552 -2
  6. package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -1
  7. package/lib/bulk-importer/handlers/assortment/create.js +32 -5
  8. package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
  9. package/lib/bulk-importer/handlers/assortment/remove.d.ts +20 -2
  10. package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -1
  11. package/lib/bulk-importer/handlers/assortment/remove.js +7 -2
  12. package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
  13. package/lib/bulk-importer/handlers/assortment/update.d.ts +552 -2
  14. package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -1
  15. package/lib/bulk-importer/handlers/assortment/update.js +43 -7
  16. package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
  17. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +23 -3
  18. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -1
  19. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +14 -6
  20. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
  21. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +23 -3
  22. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -1
  23. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +15 -6
  24. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -1
  25. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +23 -3
  26. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -1
  27. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +17 -8
  28. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
  29. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +67 -2
  30. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -1
  31. package/lib/bulk-importer/handlers/assortment/upsertMedia.js +18 -4
  32. package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
  33. package/lib/bulk-importer/handlers/filter/create.d.ts +125 -0
  34. package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -1
  35. package/lib/bulk-importer/handlers/filter/create.js +22 -0
  36. package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
  37. package/lib/bulk-importer/handlers/filter/remove.d.ts +10 -2
  38. package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -1
  39. package/lib/bulk-importer/handlers/filter/remove.js +4 -0
  40. package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
  41. package/lib/bulk-importer/handlers/filter/update.d.ts +125 -0
  42. package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -1
  43. package/lib/bulk-importer/handlers/filter/update.js +22 -0
  44. package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
  45. package/lib/bulk-importer/handlers/product/create.d.ts +1317 -2
  46. package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -1
  47. package/lib/bulk-importer/handlers/product/create.js +87 -8
  48. package/lib/bulk-importer/handlers/product/create.js.map +1 -1
  49. package/lib/bulk-importer/handlers/product/remove.d.ts +20 -2
  50. package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -1
  51. package/lib/bulk-importer/handlers/product/remove.js +5 -0
  52. package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
  53. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +278 -1
  54. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -1
  55. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +64 -3
  56. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -1
  57. package/lib/bulk-importer/handlers/product/update.d.ts +1317 -2
  58. package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -1
  59. package/lib/bulk-importer/handlers/product/update.js +89 -5
  60. package/lib/bulk-importer/handlers/product/update.js.map +1 -1
  61. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +67 -2
  62. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -1
  63. package/lib/bulk-importer/handlers/product/upsertMedia.js +16 -2
  64. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
  65. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +73 -2
  66. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -1
  67. package/lib/bulk-importer/handlers/product/upsertVariations.js +26 -2
  68. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
  69. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +1 -1
  70. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -1
  71. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -1
  72. package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
  73. package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
  74. package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
  75. package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
  76. package/lib/bulk-importer/index.d.ts +4 -0
  77. package/lib/bulk-importer/index.d.ts.map +1 -0
  78. package/lib/bulk-importer/index.js +4 -0
  79. package/lib/bulk-importer/index.js.map +1 -0
  80. package/lib/bulk-importer/upsertAsset.d.ts +21 -5
  81. package/lib/bulk-importer/upsertAsset.d.ts.map +1 -1
  82. package/lib/bulk-importer/upsertAsset.js +8 -0
  83. package/lib/bulk-importer/upsertAsset.js.map +1 -1
  84. package/lib/core-index.d.ts +4 -3
  85. package/lib/core-index.d.ts.map +1 -1
  86. package/lib/core-index.js +2 -2
  87. package/lib/core-index.js.map +1 -1
  88. package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
  89. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
  90. package/lib/directors/BaseDiscountAdapter.js +1 -1
  91. package/lib/directors/BaseDiscountAdapter.js.map +1 -1
  92. package/lib/directors/BaseDiscountDirector.d.ts +1 -1
  93. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
  94. package/lib/directors/BaseDiscountDirector.js +1 -1
  95. package/lib/directors/BaseDiscountDirector.js.map +1 -1
  96. package/lib/directors/BasePricingAdapter.d.ts +2 -2
  97. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  98. package/lib/directors/BasePricingDirector.d.ts.map +1 -1
  99. package/lib/directors/BasePricingDirector.js +3 -3
  100. package/lib/directors/BasePricingDirector.js.map +1 -1
  101. package/lib/directors/BasePricingSheet.js.map +1 -1
  102. package/lib/directors/BaseWorker.js +1 -1
  103. package/lib/directors/BaseWorker.js.map +1 -1
  104. package/lib/directors/DeliveryAdapter.d.ts +3 -3
  105. package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
  106. package/lib/directors/DeliveryDirector.d.ts +3 -3
  107. package/lib/directors/DeliveryDirector.d.ts.map +1 -1
  108. package/lib/directors/DeliveryDirector.js +29 -16
  109. package/lib/directors/DeliveryDirector.js.map +1 -1
  110. package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
  111. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
  112. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
  113. package/lib/directors/DeliveryPricingDirector.js +3 -4
  114. package/lib/directors/DeliveryPricingDirector.js.map +1 -1
  115. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
  116. package/lib/directors/DeliveryPricingSheet.js +2 -1
  117. package/lib/directors/DeliveryPricingSheet.js.map +1 -1
  118. package/lib/directors/EnrollmentAdapter.d.ts +7 -4
  119. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
  120. package/lib/directors/EnrollmentAdapter.js +1 -4
  121. package/lib/directors/EnrollmentAdapter.js.map +1 -1
  122. package/lib/directors/EnrollmentDirector.d.ts +1 -1
  123. package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
  124. package/lib/directors/EnrollmentDirector.js +1 -5
  125. package/lib/directors/EnrollmentDirector.js.map +1 -1
  126. package/lib/directors/FilterAdapter.d.ts +3 -3
  127. package/lib/directors/FilterAdapter.d.ts.map +1 -1
  128. package/lib/directors/FilterDirector.d.ts +1 -1
  129. package/lib/directors/FilterDirector.d.ts.map +1 -1
  130. package/lib/directors/FilterDirector.js +1 -1
  131. package/lib/directors/FilterDirector.js.map +1 -1
  132. package/lib/directors/MessagingDirector.d.ts +1 -1
  133. package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
  134. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
  135. package/lib/directors/OrderDiscountAdapter.js.map +1 -1
  136. package/lib/directors/OrderPricingAdapter.d.ts +2 -2
  137. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
  138. package/lib/directors/OrderPricingDirector.d.ts +2 -2
  139. package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
  140. package/lib/directors/OrderPricingDirector.js +1 -1
  141. package/lib/directors/OrderPricingDirector.js.map +1 -1
  142. package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
  143. package/lib/directors/OrderPricingSheet.js +2 -1
  144. package/lib/directors/OrderPricingSheet.js.map +1 -1
  145. package/lib/directors/PaymentAdapter.d.ts +2 -2
  146. package/lib/directors/PaymentAdapter.d.ts.map +1 -1
  147. package/lib/directors/PaymentDirector.d.ts +4 -4
  148. package/lib/directors/PaymentDirector.d.ts.map +1 -1
  149. package/lib/directors/PaymentDirector.js +22 -4
  150. package/lib/directors/PaymentDirector.js.map +1 -1
  151. package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
  152. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
  153. package/lib/directors/PaymentPricingDirector.d.ts +1 -1
  154. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
  155. package/lib/directors/PaymentPricingDirector.js +3 -5
  156. package/lib/directors/PaymentPricingDirector.js.map +1 -1
  157. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
  158. package/lib/directors/PaymentPricingSheet.js +2 -1
  159. package/lib/directors/PaymentPricingSheet.js.map +1 -1
  160. package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
  161. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
  162. package/lib/directors/ProductDiscountAdapter.js.map +1 -1
  163. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
  164. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
  165. package/lib/directors/ProductPricingAdapter.d.ts +1 -1
  166. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  167. package/lib/directors/ProductPricingDirector.d.ts +2 -2
  168. package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
  169. package/lib/directors/ProductPricingDirector.js +3 -3
  170. package/lib/directors/ProductPricingDirector.js.map +1 -1
  171. package/lib/directors/ProductPricingSheet.d.ts +2 -2
  172. package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
  173. package/lib/directors/ProductPricingSheet.js +2 -1
  174. package/lib/directors/ProductPricingSheet.js.map +1 -1
  175. package/lib/directors/QuotationAdapter.d.ts +2 -2
  176. package/lib/directors/QuotationAdapter.d.ts.map +1 -1
  177. package/lib/directors/QuotationDirector.js +2 -2
  178. package/lib/directors/WarehousingAdapter.d.ts +3 -4
  179. package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
  180. package/lib/directors/WarehousingAdapter.js.map +1 -1
  181. package/lib/directors/WarehousingDirector.d.ts +5 -5
  182. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  183. package/lib/directors/WarehousingDirector.js +10 -13
  184. package/lib/directors/WarehousingDirector.js.map +1 -1
  185. package/lib/directors/WorkerAdapter.d.ts +1 -1
  186. package/lib/directors/WorkerAdapter.d.ts.map +1 -1
  187. package/lib/directors/WorkerAdapter.js +1 -1
  188. package/lib/directors/WorkerAdapter.js.map +1 -1
  189. package/lib/directors/WorkerDirector.d.ts +2 -2
  190. package/lib/directors/WorkerDirector.d.ts.map +1 -1
  191. package/lib/directors/WorkerDirector.js +2 -3
  192. package/lib/directors/WorkerDirector.js.map +1 -1
  193. package/lib/modules.d.ts +1 -1
  194. package/lib/modules.d.ts.map +1 -1
  195. package/lib/services/activateEnrollment.js +3 -3
  196. package/lib/services/activateEnrollment.js.map +1 -1
  197. package/lib/services/calculateDiscountTotal.js +2 -2
  198. package/lib/services/calculateDiscountTotal.js.map +1 -1
  199. package/lib/services/checkoutOrder.d.ts +1 -1
  200. package/lib/services/checkoutOrder.d.ts.map +1 -1
  201. package/lib/services/checkoutOrder.js +9 -3
  202. package/lib/services/checkoutOrder.js.map +1 -1
  203. package/lib/services/confirmOrder.d.ts +1 -1
  204. package/lib/services/confirmOrder.d.ts.map +1 -1
  205. package/lib/services/createDownloadStream.d.ts +1 -1
  206. package/lib/services/createDownloadStream.d.ts.map +1 -1
  207. package/lib/services/createDownloadStream.js +2 -0
  208. package/lib/services/createDownloadStream.js.map +1 -1
  209. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
  210. package/lib/services/createEnrollmentFromCheckout.js +2 -2
  211. package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
  212. package/lib/services/createManualOrderDiscount.d.ts +2 -2
  213. package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
  214. package/lib/services/createSignedURL.d.ts.map +1 -1
  215. package/lib/services/createSignedURL.js +2 -0
  216. package/lib/services/createSignedURL.js.map +1 -1
  217. package/lib/services/deleteUser.d.ts +1 -1
  218. package/lib/services/deleteUser.d.ts.map +1 -1
  219. package/lib/services/deleteUser.js +4 -2
  220. package/lib/services/deleteUser.js.map +1 -1
  221. package/lib/services/discountedEntities.js.map +1 -1
  222. package/lib/services/findOrInitCart.d.ts +1 -2
  223. package/lib/services/findOrInitCart.d.ts.map +1 -1
  224. package/lib/services/findOrInitCart.js.map +1 -1
  225. package/lib/services/fullfillQuotation.d.ts +1 -1
  226. package/lib/services/fullfillQuotation.d.ts.map +1 -1
  227. package/lib/services/fullfillQuotation.js.map +1 -1
  228. package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
  229. package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
  230. package/lib/services/generateOrderFromEnrollment.js +34 -0
  231. package/lib/services/generateOrderFromEnrollment.js.map +1 -0
  232. package/lib/services/index.d.ts +2 -0
  233. package/lib/services/index.d.ts.map +1 -1
  234. package/lib/services/index.js +2 -0
  235. package/lib/services/index.js.map +1 -1
  236. package/lib/services/initCartProviders.js.map +1 -1
  237. package/lib/services/initializeEnrollment.d.ts +1 -1
  238. package/lib/services/initializeEnrollment.d.ts.map +1 -1
  239. package/lib/services/initializeEnrollment.js +6 -3
  240. package/lib/services/initializeEnrollment.js.map +1 -1
  241. package/lib/services/linkFileService.d.ts +1 -1
  242. package/lib/services/linkFileService.d.ts.map +1 -1
  243. package/lib/services/linkFileService.js +3 -1
  244. package/lib/services/linkFileService.js.map +1 -1
  245. package/lib/services/loadFilterOptions.d.ts +2 -2
  246. package/lib/services/loadFilterOptions.d.ts.map +1 -1
  247. package/lib/services/migrateOrderCart.d.ts +1 -1
  248. package/lib/services/migrateOrderCart.d.ts.map +1 -1
  249. package/lib/services/nextUserCart.d.ts +1 -1
  250. package/lib/services/nextUserCart.d.ts.map +1 -1
  251. package/lib/services/nextUserCart.js +1 -1
  252. package/lib/services/nextUserCart.js.map +1 -1
  253. package/lib/services/processEnrollment.d.ts.map +1 -1
  254. package/lib/services/processEnrollment.js +13 -5
  255. package/lib/services/processEnrollment.js.map +1 -1
  256. package/lib/services/processOrder.d.ts.map +1 -1
  257. package/lib/services/processOrder.js +26 -30
  258. package/lib/services/processOrder.js.map +1 -1
  259. package/lib/services/processQuotation.js +6 -6
  260. package/lib/services/processQuotation.js.map +1 -1
  261. package/lib/services/proposeQuotation.d.ts +1 -1
  262. package/lib/services/proposeQuotation.d.ts.map +1 -1
  263. package/lib/services/proposeQuotation.js +2 -2
  264. package/lib/services/proposeQuotation.js.map +1 -1
  265. package/lib/services/registerPaymentCredentials.d.ts +1 -2
  266. package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
  267. package/lib/services/registerPaymentCredentials.js +4 -6
  268. package/lib/services/registerPaymentCredentials.js.map +1 -1
  269. package/lib/services/rejectOrder.d.ts +1 -1
  270. package/lib/services/rejectOrder.d.ts.map +1 -1
  271. package/lib/services/rejectQuotation.d.ts +1 -1
  272. package/lib/services/rejectQuotation.d.ts.map +1 -1
  273. package/lib/services/rejectQuotation.js +2 -2
  274. package/lib/services/rejectQuotation.js.map +1 -1
  275. package/lib/services/removeProduct.js +3 -3
  276. package/lib/services/removeProduct.js.map +1 -1
  277. package/lib/services/searchAssortments.js +1 -1
  278. package/lib/services/searchAssortments.js.map +1 -1
  279. package/lib/services/searchProducts.js +1 -1
  280. package/lib/services/searchProducts.js.map +1 -1
  281. package/lib/services/simulateProductDispatching.d.ts +1 -1
  282. package/lib/services/simulateProductDispatching.d.ts.map +1 -1
  283. package/lib/services/simulateProductInventory.d.ts +1 -1
  284. package/lib/services/simulateProductInventory.d.ts.map +1 -1
  285. package/lib/services/simulateProductInventory.js.map +1 -1
  286. package/lib/services/simulateProductPricing.d.ts +7 -4
  287. package/lib/services/simulateProductPricing.d.ts.map +1 -1
  288. package/lib/services/simulateProductPricing.js.map +1 -1
  289. package/lib/services/updateCalculation.d.ts +2 -1
  290. package/lib/services/updateCalculation.d.ts.map +1 -1
  291. package/lib/services/updateCalculation.js +16 -10
  292. package/lib/services/updateCalculation.js.map +1 -1
  293. package/lib/services/updateScheduling.d.ts +1 -1
  294. package/lib/services/updateScheduling.d.ts.map +1 -1
  295. package/lib/services/updateScheduling.js +7 -11
  296. package/lib/services/updateScheduling.js.map +1 -1
  297. package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
  298. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
  299. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
  300. package/lib/services/uploadFileFromStream.d.ts.map +1 -1
  301. package/lib/services/uploadFileFromStream.js +4 -1
  302. package/lib/services/uploadFileFromStream.js.map +1 -1
  303. package/lib/services/uploadFileFromURL.d.ts +1 -2
  304. package/lib/services/uploadFileFromURL.d.ts.map +1 -1
  305. package/lib/services/uploadFileFromURL.js.map +1 -1
  306. package/lib/services/validateOrder.d.ts +1 -1
  307. package/lib/services/validateOrder.d.ts.map +1 -1
  308. package/lib/services/validateOrder.js +17 -24
  309. package/lib/services/validateOrder.js.map +1 -1
  310. package/lib/services/verifyQuotation.d.ts +1 -1
  311. package/lib/services/verifyQuotation.d.ts.map +1 -1
  312. package/lib/services/verifyQuotation.js +2 -2
  313. package/lib/services/verifyQuotation.js.map +1 -1
  314. package/package.json +20 -20
  315. package/src/bulk-importer/createBulkImporter.ts +34 -22
  316. package/src/bulk-importer/handlers/assortment/create.ts +38 -7
  317. package/src/bulk-importer/handlers/assortment/remove.ts +14 -3
  318. package/src/bulk-importer/handlers/assortment/update.ts +53 -9
  319. package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +44 -19
  320. package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +37 -9
  321. package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +35 -9
  322. package/src/bulk-importer/handlers/assortment/upsertMedia.ts +23 -5
  323. package/src/bulk-importer/handlers/filter/create.ts +28 -0
  324. package/src/bulk-importer/handlers/filter/remove.ts +6 -1
  325. package/src/bulk-importer/handlers/filter/update.ts +28 -1
  326. package/src/bulk-importer/handlers/product/create.ts +109 -9
  327. package/src/bulk-importer/handlers/product/remove.ts +7 -1
  328. package/src/bulk-importer/handlers/product/update.ts +117 -8
  329. package/src/bulk-importer/handlers/product/upsertMedia.ts +20 -3
  330. package/src/bulk-importer/handlers/product/upsertVariations.ts +43 -4
  331. package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +1 -1
  332. package/src/bulk-importer/index.ts +3 -0
  333. package/src/bulk-importer/upsertAsset.ts +10 -2
  334. package/src/core-index.ts +4 -6
  335. package/src/directors/BaseDiscountAdapter.test.ts +1 -1
  336. package/src/directors/BaseDiscountAdapter.ts +5 -5
  337. package/src/directors/BaseDiscountDirector.ts +2 -2
  338. package/src/directors/BasePricingAdapter.ts +2 -2
  339. package/src/directors/BasePricingDirector.ts +47 -44
  340. package/src/directors/BasePricingSheet.ts +1 -1
  341. package/src/directors/BaseWorker.ts +1 -1
  342. package/src/directors/DeliveryAdapter.ts +3 -3
  343. package/src/directors/DeliveryDirector.ts +33 -23
  344. package/src/directors/DeliveryPricingAdapter.ts +1 -1
  345. package/src/directors/DeliveryPricingDirector.ts +5 -6
  346. package/src/directors/DeliveryPricingSheet.ts +3 -2
  347. package/src/directors/EnrollmentAdapter.ts +9 -6
  348. package/src/directors/EnrollmentDirector.ts +9 -8
  349. package/src/directors/FilterAdapter.ts +3 -3
  350. package/src/directors/FilterDirector.ts +5 -5
  351. package/src/directors/OrderDiscountAdapter.ts +2 -2
  352. package/src/directors/OrderPricingAdapter.ts +2 -2
  353. package/src/directors/OrderPricingDirector.ts +3 -3
  354. package/src/directors/OrderPricingSheet.ts +3 -2
  355. package/src/directors/PaymentAdapter.ts +2 -2
  356. package/src/directors/PaymentDirector.ts +32 -8
  357. package/src/directors/PaymentPricingAdapter.ts +2 -2
  358. package/src/directors/PaymentPricingDirector.ts +6 -8
  359. package/src/directors/PaymentPricingSheet.ts +3 -2
  360. package/src/directors/ProductDiscountAdapter.ts +2 -2
  361. package/src/directors/ProductDiscountConfiguration.ts +1 -1
  362. package/src/directors/ProductPricingAdapter.ts +1 -1
  363. package/src/directors/ProductPricingDirector.ts +7 -7
  364. package/src/directors/ProductPricingSheet.ts +4 -3
  365. package/src/directors/QuotationAdapter.ts +2 -2
  366. package/src/directors/QuotationDirector.ts +2 -2
  367. package/src/directors/WarehousingAdapter.ts +3 -4
  368. package/src/directors/WarehousingDirector.ts +20 -23
  369. package/src/directors/WorkerAdapter.ts +2 -2
  370. package/src/directors/WorkerDirector.ts +5 -6
  371. package/src/modules.ts +1 -1
  372. package/src/services/activateEnrollment.ts +5 -5
  373. package/src/services/calculateDiscountTotal.ts +4 -4
  374. package/src/services/checkoutOrder.ts +9 -4
  375. package/src/services/createDownloadStream.ts +1 -0
  376. package/src/services/createEnrollmentFromCheckout.ts +22 -20
  377. package/src/services/createManualOrderDiscount.ts +2 -2
  378. package/src/services/createSignedURL.ts +1 -0
  379. package/src/services/deleteUser.ts +7 -2
  380. package/src/services/discountedEntities.ts +6 -6
  381. package/src/services/findOrInitCart.ts +1 -2
  382. package/src/services/fullfillQuotation.ts +1 -1
  383. package/src/services/generateOrderFromEnrollment.ts +54 -0
  384. package/src/services/index.ts +4 -0
  385. package/src/services/initCartProviders.ts +2 -2
  386. package/src/services/initializeEnrollment.ts +11 -4
  387. package/src/services/linkFileService.ts +3 -1
  388. package/src/services/nextUserCart.ts +1 -1
  389. package/src/services/processEnrollment.ts +18 -6
  390. package/src/services/processOrder.ts +33 -36
  391. package/src/services/processQuotation.ts +6 -6
  392. package/src/services/proposeQuotation.ts +2 -2
  393. package/src/services/registerPaymentCredentials.ts +6 -8
  394. package/src/services/rejectQuotation.ts +2 -2
  395. package/src/services/removeProduct.ts +3 -3
  396. package/src/services/searchAssortments.ts +1 -1
  397. package/src/services/searchProducts.ts +1 -1
  398. package/src/services/simulateProductDispatching.ts +1 -1
  399. package/src/services/simulateProductInventory.ts +7 -3
  400. package/src/services/simulateProductPricing.ts +6 -3
  401. package/src/services/updateCalculation.ts +33 -18
  402. package/src/services/updateScheduling.ts +19 -20
  403. package/src/services/updateUserAvatarAfterUpload.ts +4 -1
  404. package/src/services/uploadFileFromStream.ts +3 -1
  405. package/src/services/uploadFileFromURL.ts +2 -2
  406. package/src/services/validateOrder.ts +34 -38
  407. package/src/services/verifyQuotation.ts +2 -2
  408. package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts +0 -5
  409. package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts.map +0 -1
  410. package/lib/factory/registerProductDiscoverabilityFilter copy.js +0 -28
  411. package/lib/factory/registerProductDiscoverabilityFilter copy.js.map +0 -1
  412. package/src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts +0 -22
@@ -16,9 +16,9 @@ export type ProductPricingContext =
16
16
  currencyCode: string;
17
17
  countryCode: string;
18
18
  quantity: number;
19
- discounts?: OrderDiscount[];
19
+ discounts: OrderDiscount[];
20
20
  order?: Order;
21
- product?: Product;
21
+ product: Product;
22
22
  configuration?: ProductConfiguration[];
23
23
  user?: User;
24
24
  }
@@ -59,21 +59,21 @@ export const ProductPricingDirector: IProductPricingDirector<any> = {
59
59
  const order = await modules.orders.findOrder({
60
60
  orderId: item.orderId,
61
61
  });
62
- const user = await modules.users.findUserById(order.userId);
62
+ const user = await modules.users.findUserById(order!.userId);
63
63
  const discounts = await modules.orders.discounts.findOrderDiscounts({
64
64
  orderId: item.orderId,
65
65
  });
66
66
 
67
67
  return {
68
68
  ...unchainedAPI,
69
- countryCode: order.countryCode,
69
+ countryCode: order!.countryCode,
70
70
  currencyCode,
71
71
  discounts,
72
- order,
73
- product,
72
+ order: order!,
73
+ product: product!,
74
74
  quantity,
75
75
  configuration: item.configuration,
76
- user,
76
+ user: user!,
77
77
  };
78
78
  }
79
79
 
@@ -33,7 +33,7 @@ export interface IProductPricingSheet extends IPricingSheet<ProductPricingCalcul
33
33
  meta?: any;
34
34
  }) => void;
35
35
 
36
- unitPrice: (params?: { useNetPrice: boolean }) => Price;
36
+ unitPrice: (params: { useNetPrice?: boolean }) => Price;
37
37
  }
38
38
 
39
39
  export const ProductPricingSheet = (
@@ -99,7 +99,8 @@ export const ProductPricingSheet = (
99
99
  category: ProductPricingRowCategory.Discount,
100
100
  discountId: explicitDiscountId,
101
101
  })
102
- .map(({ discountId }) => discountId);
102
+ .map(({ discountId }) => discountId)
103
+ .filter(Boolean) as string[];
103
104
 
104
105
  return [...new Set(discountIds)]
105
106
  .map((discountId) => {
@@ -116,7 +117,7 @@ export const ProductPricingSheet = (
116
117
  currencyCode: basePricingSheet.currencyCode,
117
118
  };
118
119
  })
119
- .filter(Boolean);
120
+ .filter(Boolean) as { discountId: string; amount: number; currencyCode: string }[];
120
121
  },
121
122
  };
122
123
 
@@ -10,7 +10,7 @@ export interface QuotationContext {
10
10
  }
11
11
 
12
12
  export interface QuotationAdapterActions {
13
- configurationError: () => QuotationError;
13
+ configurationError: () => QuotationError | null;
14
14
  isManualProposalRequired: () => Promise<boolean>;
15
15
  isManualRequestVerificationRequired: () => Promise<boolean>;
16
16
  quote: () => Promise<QuotationProposal>;
@@ -20,7 +20,7 @@ export interface QuotationAdapterActions {
20
20
 
21
21
  transformItemConfiguration: (
22
22
  params: QuotationItemConfiguration,
23
- ) => Promise<QuotationItemConfiguration>;
23
+ ) => Promise<QuotationItemConfiguration | null>;
24
24
  }
25
25
 
26
26
  export type IQuotationAdapter = IBaseAdapter & {
@@ -65,7 +65,7 @@ export const QuotationDirector: IQuotationDirector = {
65
65
  ...error,
66
66
  },
67
67
  );
68
- return null;
68
+ return true;
69
69
  }
70
70
  },
71
71
 
@@ -77,7 +77,7 @@ export const QuotationDirector: IQuotationDirector = {
77
77
  logger.error('QuotationDirector -> Error while checking if is manual proposal required', {
78
78
  ...error,
79
79
  });
80
- return null;
80
+ return true;
81
81
  }
82
82
  },
83
83
 
@@ -16,14 +16,14 @@ export enum WarehousingError {
16
16
  }
17
17
 
18
18
  export interface WarehousingAdapterActions {
19
- configurationError: () => WarehousingError;
19
+ configurationError: () => WarehousingError | null;
20
20
  isActive: () => boolean;
21
21
  stock: (referenceDate: Date) => Promise<number>;
22
22
  productionTime: (quantityToProduce: number) => Promise<number>;
23
23
  commissioningTime: (quantity: number) => Promise<number>;
24
24
  tokenize: () => Promise<Omit<TokenSurrogate, 'userId' | 'productId' | 'orderPositionId'>[]>;
25
- tokenMetadata: (chainTokenId: string, referenceDate: Date) => Promise<any>;
26
- isInvalidateable: (chainTokenId: string, referenceDate: Date) => Promise<boolean>;
25
+ tokenMetadata: (tokenSerialNumber: string, referenceDate: Date) => Promise<any>;
26
+ isInvalidateable: (tokenSerialNumber: string, referenceDate: Date) => Promise<boolean>;
27
27
  }
28
28
 
29
29
  export interface WarehousingContext {
@@ -34,7 +34,6 @@ export interface WarehousingContext {
34
34
  referenceDate?: Date;
35
35
  locale?: Intl.Locale;
36
36
  order?: Order;
37
- warehousingProviderId?: string;
38
37
  orderPosition?: OrderPosition;
39
38
  }
40
39
 
@@ -28,13 +28,13 @@ export interface WarehousingInterface {
28
28
  export type IWarehousingDirector = IBaseDirector<IWarehousingAdapter> & {
29
29
  tokenMetadata: (
30
30
  virtualProviders: WarehousingProvider[],
31
- warehousingContext: WarehousingContext & { token: { chainTokenId: string } },
31
+ warehousingContext: WarehousingContext & { token: { tokenSerialNumber: string } },
32
32
  unchainedAPI,
33
33
  ) => Promise<any>;
34
34
 
35
35
  isInvalidateable: (
36
36
  virtualProviders: WarehousingProvider[],
37
- warehousingContext: WarehousingContext & { token: { chainTokenId: string } },
37
+ warehousingContext: WarehousingContext & { token: { tokenSerialNumber: string } },
38
38
  unchainedAPI,
39
39
  ) => Promise<any>;
40
40
 
@@ -43,13 +43,13 @@ export type IWarehousingDirector = IBaseDirector<IWarehousingAdapter> & {
43
43
  warehousingContext: WarehousingContext,
44
44
  unchainedAPI: { modules: Modules },
45
45
  ) => Promise<{
46
- configurationError: () => WarehousingError;
46
+ configurationError: () => WarehousingError | null;
47
47
  isActive: () => boolean;
48
48
  estimatedStock: () => Promise<EstimatedStock>;
49
49
  estimatedDispatch: () => Promise<EstimatedDispatch>;
50
50
  tokenize: () => Promise<TokenSurrogate[]>;
51
- tokenMetadata: (chainTokenId: string) => Promise<any>;
52
- isInvalidateable: (chainTokenId: string) => Promise<boolean>;
51
+ tokenMetadata: (tokenSerialNumber: string) => Promise<any>;
52
+ isInvalidateable: (tokenSerialNumber: string) => Promise<boolean>;
53
53
  }>;
54
54
  };
55
55
 
@@ -81,9 +81,9 @@ export const WarehousingDirector: IWarehousingDirector = {
81
81
  try {
82
82
  const { quantity } = context;
83
83
  const stock = await adapter.stock(referenceDate);
84
- const notInStockQuantity = Math.max(quantity - stock, 0);
84
+ const notInStockQuantity = Math.max((quantity || 1) - stock, 0);
85
85
  const productionTime = await adapter.productionTime(notInStockQuantity);
86
- const commissioningTime = await adapter.commissioningTime(quantity);
86
+ const commissioningTime = await adapter.commissioningTime(quantity || 1);
87
87
  return Math.max(commissioningTime + productionTime, 0);
88
88
  } catch (error) {
89
89
  logger.error(error);
@@ -130,10 +130,7 @@ export const WarehousingDirector: IWarehousingDirector = {
130
130
 
131
131
  const warehousingThroughputTime = await throughputTime(referenceDate);
132
132
  if (!Number.isFinite(warehousingThroughputTime)) {
133
- return {
134
- shipping: null,
135
- earliestDelivery: null,
136
- };
133
+ return {};
137
134
  }
138
135
 
139
136
  // Calculate shipping date
@@ -141,12 +138,12 @@ export const WarehousingDirector: IWarehousingDirector = {
141
138
  const shipping = new Date(shippingTimestamp);
142
139
 
143
140
  // Calculate earliest delivery date
144
- const actions = await DeliveryDirector.actions(deliveryProvider, context, unchainedAPI);
141
+ const actions = await DeliveryDirector.actions(deliveryProvider!, context, unchainedAPI);
145
142
  const deliveryThroughputTime =
146
143
  await actions.estimatedDeliveryThroughput(warehousingThroughputTime);
147
144
  const earliestDelivery = Number.isFinite(deliveryThroughputTime)
148
- ? new Date(shippingTimestamp + deliveryThroughputTime)
149
- : null;
145
+ ? new Date(shippingTimestamp + deliveryThroughputTime!)
146
+ : undefined;
150
147
 
151
148
  return {
152
149
  shipping,
@@ -158,10 +155,10 @@ export const WarehousingDirector: IWarehousingDirector = {
158
155
  }
159
156
  },
160
157
 
161
- tokenMetadata: async (chainTokenId) => {
158
+ tokenMetadata: async (tokenSerialNumber) => {
162
159
  try {
163
160
  const referenceDate = getReferenceDate(context);
164
- const tokenMetadata = await adapter.tokenMetadata(chainTokenId, referenceDate);
161
+ const tokenMetadata = await adapter.tokenMetadata(tokenSerialNumber, referenceDate);
165
162
  return tokenMetadata;
166
163
  } catch (error) {
167
164
  logger.error(error);
@@ -169,10 +166,10 @@ export const WarehousingDirector: IWarehousingDirector = {
169
166
  }
170
167
  },
171
168
 
172
- isInvalidateable: async (chainTokenId) => {
169
+ isInvalidateable: async (tokenSerialNumber) => {
173
170
  try {
174
171
  const referenceDate = getReferenceDate(context);
175
- const isInvalidateable = await adapter.isInvalidateable(chainTokenId, referenceDate);
172
+ const isInvalidateable = await adapter.isInvalidateable(tokenSerialNumber, referenceDate);
176
173
  return isInvalidateable;
177
174
  } catch (error) {
178
175
  logger.error(error);
@@ -187,9 +184,9 @@ export const WarehousingDirector: IWarehousingDirector = {
187
184
  return tokens.map((token) => {
188
185
  return {
189
186
  ...token,
190
- userId: order.userId,
191
- productId: orderPosition.productId,
192
- orderPositionId: orderPosition._id,
187
+ userId: order!.userId,
188
+ productId: orderPosition!.productId,
189
+ orderPositionId: orderPosition!._id,
193
190
  };
194
191
  });
195
192
  } catch (error) {
@@ -211,7 +208,7 @@ export const WarehousingDirector: IWarehousingDirector = {
211
208
  );
212
209
  const isActive = await currentDirector.isActive();
213
210
  if (isActive) {
214
- return currentDirector.tokenMetadata(warehousingContext.token.chainTokenId);
211
+ return currentDirector.tokenMetadata(warehousingContext.token.tokenSerialNumber);
215
212
  }
216
213
  return null;
217
214
  }, Promise.resolve(null));
@@ -228,7 +225,7 @@ export const WarehousingDirector: IWarehousingDirector = {
228
225
  );
229
226
  const isActive = await currentDirector.isActive();
230
227
  if (isActive) {
231
- return currentDirector.isInvalidateable(warehousingContext.token.chainTokenId);
228
+ return currentDirector.isInvalidateable(warehousingContext.token.tokenSerialNumber);
232
229
  }
233
230
  return null;
234
231
  }, Promise.resolve(null));
@@ -2,7 +2,7 @@ import { BaseAdapter, IBaseAdapter } from '@unchainedshop/utils';
2
2
  import { WorkResult } from '@unchainedshop/core-worker';
3
3
  import { ModuleOptions, Modules } from '../modules.js';
4
4
  import { Services } from '../services/index.js';
5
- import { BulkImporter } from '../bulk-importer/createBulkImporter.js';
5
+ import { BulkImporter } from '../bulk-importer/index.js';
6
6
 
7
7
  export type IWorkerAdapter<Input, Output> = IBaseAdapter & {
8
8
  type: string;
@@ -26,6 +26,6 @@ export const WorkerAdapter: Omit<IWorkerAdapter<any, void>, 'key' | 'label' | 't
26
26
  external: false,
27
27
 
28
28
  async doWork() {
29
- return { success: false, result: null };
29
+ return { success: false };
30
30
  },
31
31
  };
@@ -13,7 +13,7 @@ export type WorkScheduleConfiguration = Pick<
13
13
  > & {
14
14
  type: string;
15
15
  input?: (workData: Omit<WorkData, 'input'>) => Promise<Record<string, any> | null>;
16
- schedule: ScheduleData;
16
+ schedule?: ScheduleData;
17
17
  scheduleId?: string;
18
18
  };
19
19
 
@@ -24,7 +24,7 @@ export type IWorkerDirector = IBaseDirector<IWorkerAdapter<any, any>> & {
24
24
  configureAutoscheduling: (workScheduleConfiguration: WorkScheduleConfiguration) => void;
25
25
  getAutoSchedules: () => [string, WorkScheduleConfiguration][];
26
26
  doWork: (work: Work, unchainedAPI) => Promise<WorkResult>;
27
- processNextWork: (unchainedAPI: { modules: Modules }, workerId?: string) => Promise<Work>;
27
+ processNextWork: (unchainedAPI: { modules: Modules }, workerId?: string) => Promise<Work | null>;
28
28
  };
29
29
 
30
30
  const AutoScheduleMap = new Map<string, WorkScheduleConfiguration>();
@@ -36,7 +36,7 @@ const baseDirector = BaseDirector<IWorkerAdapter<any, any>>('WorkerDirector', {
36
36
  export const WorkerDirector: IWorkerDirector = {
37
37
  ...baseDirector,
38
38
 
39
- getActivePluginTypes: ({ external } = { external: null }) => {
39
+ getActivePluginTypes: ({ external } = {}) => {
40
40
  return WorkerDirector.getAdapters()
41
41
  .filter((adapter) => {
42
42
  if (external === null || external === undefined) return true;
@@ -55,8 +55,7 @@ export const WorkerDirector: IWorkerDirector = {
55
55
  },
56
56
 
57
57
  disableAutoscheduling: (type) => {
58
- const config = AutoScheduleMap.get(type);
59
- AutoScheduleMap.set(type, { ...config, schedule: null });
58
+ AutoScheduleMap.delete(type);
60
59
  },
61
60
 
62
61
  unregisterAdapter: (key) => {
@@ -110,7 +109,7 @@ export const WorkerDirector: IWorkerDirector = {
110
109
  }
111
110
  },
112
111
 
113
- processNextWork: async (unchainedAPI: { modules: Modules }, workerId?: string): Promise<Work> => {
112
+ processNextWork: async (unchainedAPI: { modules: Modules }, workerId?: string) => {
114
113
  const adapters = WorkerDirector.getAdapters();
115
114
 
116
115
  const allocationMap = await unchainedAPI.modules.worker.allocationMap();
package/src/modules.ts CHANGED
@@ -87,7 +87,7 @@ const initModules = async (
87
87
  }: {
88
88
  db: mongodb.Db;
89
89
  migrationRepository: MigrationRepository<unknown>;
90
- options?: ModuleOptions;
90
+ options: ModuleOptions;
91
91
  },
92
92
  customModules: Record<
93
93
  string,
@@ -6,12 +6,12 @@ import { addMessageService } from './addMessage.js';
6
6
  export async function activateEnrollmentService(this: Modules, enrollment: Enrollment) {
7
7
  if (enrollment.status === EnrollmentStatus.TERMINATED) return enrollment;
8
8
 
9
- let updatedEnrollment = await this.enrollments.updateStatus(enrollment._id, {
9
+ let updatedEnrollment = (await this.enrollments.updateStatus(enrollment._id, {
10
10
  status: EnrollmentStatus.ACTIVE,
11
11
  info: 'activated manually',
12
- });
12
+ })) as Enrollment;
13
13
 
14
- updatedEnrollment = await processEnrollmentService.bind(this)(updatedEnrollment);
14
+ updatedEnrollment = (await processEnrollmentService.bind(this)(updatedEnrollment)) as Enrollment;
15
15
 
16
16
  const user = await this.users.findUserById(enrollment.userId);
17
17
  const locale = this.users.userLocale(user);
@@ -19,8 +19,8 @@ export async function activateEnrollmentService(this: Modules, enrollment: Enrol
19
19
  await addMessageService.bind(this)('ENROLLMENT_STATUS', {
20
20
  reason: 'status_change',
21
21
  locale: locale.baseName,
22
- enrollmentId: updatedEnrollment._id,
22
+ enrollmentId: updatedEnrollment!._id,
23
23
  });
24
24
 
25
- return updatedEnrollment;
25
+ return updatedEnrollment!;
26
26
  }
@@ -20,19 +20,19 @@ export async function calculateDiscountTotalService(
20
20
 
21
21
  // Delivery discounts
22
22
  const orderDelivery = await this.orders.deliveries.findDelivery({
23
- orderDeliveryId: order.deliveryId,
23
+ orderDeliveryId: order.deliveryId!,
24
24
  });
25
25
  const orderDeliveryDiscountSum = DeliveryPricingSheet({
26
- calculation: orderDelivery.calculation || [],
26
+ calculation: orderDelivery?.calculation || [],
27
27
  currencyCode: order.currencyCode,
28
28
  }).total({ category: DeliveryPricingRowCategory.Discount, discountId: orderDiscountId });
29
29
 
30
30
  // Payment discounts
31
31
  const orderPayment = await this.orders.payments.findOrderPayment({
32
- orderPaymentId: order.paymentId,
32
+ orderPaymentId: order.paymentId!,
33
33
  });
34
34
  const orderPaymentDiscountSum = PaymentPricingSheet({
35
- calculation: orderPayment.calculation || [],
35
+ calculation: orderPayment?.calculation || [],
36
36
  currencyCode: order.currencyCode,
37
37
  }).total({ category: PaymentPricingRowCategory.Discount, discountId: orderDiscountId });
38
38
 
@@ -3,6 +3,7 @@ import { Modules } from '../modules.js';
3
3
  import { nextUserCartService } from './nextUserCart.js';
4
4
  import { validateOrderService } from './validateOrder.js';
5
5
  import { processOrderService } from './processOrder.js';
6
+ import { User } from '@unchainedshop/core-users';
6
7
 
7
8
  export async function checkoutOrderService(
8
9
  this: Modules,
@@ -15,6 +16,7 @@ export async function checkoutOrderService(
15
16
  },
16
17
  ) {
17
18
  const order = await this.orders.findOrder({ orderId });
19
+ if (!order) return null;
18
20
  if (order.status !== null) return order;
19
21
 
20
22
  await validateOrderService.bind(this)(order);
@@ -25,11 +27,14 @@ export async function checkoutOrderService(
25
27
  const processedOrder = await processOrderService.bind(this)(order, transactionContext);
26
28
 
27
29
  // After checkout, store last checkout information on user
28
- await this.users.updateLastBillingAddress(processedOrder.userId, processedOrder.billingAddress);
29
- await this.users.updateLastContact(processedOrder.userId, processedOrder.contact);
30
-
30
+ if (processedOrder.billingAddress) {
31
+ await this.users.updateLastBillingAddress(processedOrder.userId, processedOrder.billingAddress);
32
+ }
33
+ if (processedOrder.contact) {
34
+ await this.users.updateLastContact(processedOrder.userId, processedOrder.contact);
35
+ }
31
36
  // Then eventually build next cart
32
- const user = await this.users.findUserById(processedOrder.userId);
37
+ const user = (await this.users.findUserById(processedOrder.userId)) as User;
33
38
  const locale = this.users.userLocale(user);
34
39
  await nextUserCartService.bind(this)({
35
40
  user,
@@ -11,6 +11,7 @@ export async function createDownloadStreamService(
11
11
  ) {
12
12
  const fileAdapter = getFileAdapter();
13
13
  const file = await this.files.findFile({ fileId });
14
+ if (!file) return null;
14
15
  const stream = fileAdapter.createDownloadStream(file, { modules: this });
15
16
  return stream;
16
17
  }
@@ -25,42 +25,44 @@ export async function createEnrollmentFromCheckoutService(
25
25
  const orderId = order._id;
26
26
 
27
27
  const payment = await this.orders.payments.findOrderPayment({
28
- orderPaymentId: order.paymentId,
28
+ orderPaymentId: order.paymentId!,
29
29
  });
30
30
  const delivery = await this.orders.deliveries.findDelivery({
31
- orderDeliveryId: order.deliveryId,
31
+ orderDeliveryId: order.deliveryId!,
32
32
  });
33
33
 
34
34
  const template = {
35
- billingAddress: order.billingAddress,
36
- contact: order.contact,
35
+ billingAddress: order.billingAddress!,
36
+ contact: order.contact!,
37
37
  countryCode: order.countryCode,
38
38
  currencyCode: order.currencyCode,
39
39
  delivery: {
40
- deliveryProviderId: delivery.deliveryProviderId,
41
- context: delivery.context,
40
+ deliveryProviderId: delivery!.deliveryProviderId,
41
+ context: delivery!.context,
42
42
  },
43
43
  orderIdForFirstPeriod: orderId,
44
44
  payment: {
45
- paymentProviderId: payment.paymentProviderId,
46
- context: payment.context,
45
+ paymentProviderId: payment!.paymentProviderId,
46
+ context: payment!.context,
47
47
  },
48
48
  userId: order.userId,
49
49
  meta: order.context,
50
50
  ...context,
51
51
  };
52
52
 
53
- return Promise.all(
54
- items.map(async (item) => {
55
- const enrollmentData = await EnrollmentDirector.transformOrderItemToEnrollment(item, template, {
56
- modules: this,
57
- });
53
+ return (
54
+ await Promise.all(
55
+ items.map(async (item) => {
56
+ const enrollmentData = await EnrollmentDirector.transformOrderItemToEnrollment(item, template, {
57
+ modules: this,
58
+ });
58
59
 
59
- const enrollment = await this.enrollments.create(enrollmentData);
60
- return await initializeEnrollmentService.bind(this)(enrollment, {
61
- orderIdForFirstPeriod: enrollment.orderIdForFirstPeriod,
62
- reason: 'new_enrollment',
63
- });
64
- }),
65
- );
60
+ const enrollment = await this.enrollments.create(enrollmentData);
61
+ return await initializeEnrollmentService.bind(this)(enrollment, {
62
+ orderIdForFirstPeriod: enrollment.orderIdForFirstPeriod,
63
+ reason: 'new_enrollment',
64
+ });
65
+ }),
66
+ )
67
+ ).filter(Boolean) as Enrollment[];
66
68
  }
@@ -1,11 +1,11 @@
1
- import { Order, OrderDiscount } from '@unchainedshop/core-orders';
1
+ import { Order } from '@unchainedshop/core-orders';
2
2
  import { OrderDiscountDirector } from '../directors/OrderDiscountDirector.js';
3
3
  import { Modules } from '../modules.js';
4
4
 
5
5
  export async function createManualOrderDiscountService(
6
6
  this: Modules,
7
7
  { order, code }: { code: string; order: Order },
8
- ): Promise<OrderDiscount> {
8
+ ) {
9
9
  // Use an already existing discount if available!
10
10
  const spareDiscount = await this.orders.discounts.findSpareDiscount({ code });
11
11
  if (spareDiscount) {
@@ -9,6 +9,7 @@ export async function createSignedURLService(
9
9
  const preparedFileData = await fileUploadAdapter.createSignedURL(directoryName, fileName, {
10
10
  modules: this,
11
11
  });
12
+ if (!preparedFileData) throw new Error('Could not prepare signed URL');
12
13
  const fileData = getFileFromFileData(preparedFileData, meta);
13
14
  const fileId = await this.files.create(fileData);
14
15
  const file = await this.files.findFile({ fileId });
@@ -9,9 +9,14 @@ export async function deleteUserService(this: Modules, { userId }: { userId: str
9
9
  await this.quotations.deleteRequestedUserQuotations(userId);
10
10
  await this.enrollments.deleteInactiveUserEnrollments(userId);
11
11
  await this.payment.paymentCredentials.deleteUserPaymentCredentials(userId);
12
- await this.users.webAuthn.deleteUserWebAuthnCredentials(user.username);
13
12
 
14
- const carts = await this.orders.findOrders({ userId, status: null });
13
+ if (user.username) {
14
+ await this.users.webAuthn.deleteUserWebAuthnCredentials(user.username);
15
+ }
16
+
17
+ const carts = (await this.orders.findOrders({ userId, includeCarts: true })).filter(
18
+ (c) => c.status === null,
19
+ );
15
20
 
16
21
  await Array.fromAsync(carts, async (userCart) => {
17
22
  await this.orders.positions.deleteOrderPositions(userCart?._id);
@@ -15,32 +15,32 @@ export async function discountedEntitiesService(
15
15
  ): Promise<OrderPricingDiscount[]> {
16
16
  // Delivery discounts
17
17
  const orderDelivery = await this.orders.deliveries.findDelivery({
18
- orderDeliveryId: order.deliveryId,
18
+ orderDeliveryId: order.deliveryId!,
19
19
  });
20
20
 
21
21
  const deliveryPricingSheet = DeliveryPricingSheet({
22
- calculation: orderDelivery.calculation || [],
22
+ calculation: orderDelivery!.calculation || [],
23
23
  currencyCode: order.currencyCode,
24
24
  });
25
25
  const orderDeliveryDiscounts = deliveryPricingSheet
26
26
  .discountPrices(orderDiscount._id)
27
27
  .map((discount) => ({
28
- delivery: orderDelivery,
28
+ delivery: orderDelivery!,
29
29
  ...discount,
30
30
  }));
31
31
 
32
32
  // Payment discounts
33
33
  const orderPayment = await this.orders.payments.findOrderPayment({
34
- orderPaymentId: order.paymentId,
34
+ orderPaymentId: order.paymentId!,
35
35
  });
36
36
  const paymentPricingSheet = PaymentPricingSheet({
37
- calculation: orderPayment.calculation || [],
37
+ calculation: orderPayment!.calculation || [],
38
38
  currencyCode: order.currencyCode,
39
39
  });
40
40
  const orderPaymentDiscounts = paymentPricingSheet
41
41
  .discountPrices(orderDiscount._id)
42
42
  .map((discount) => ({
43
- payment: orderPayment,
43
+ payment: orderPayment!,
44
44
  ...discount,
45
45
  }));
46
46
 
@@ -1,5 +1,4 @@
1
1
  import { User } from '@unchainedshop/core-users';
2
- import { Order } from '@unchainedshop/core-orders';
3
2
  import { Modules } from '../modules.js';
4
3
  import { nextUserCartService } from './nextUserCart.js';
5
4
 
@@ -25,5 +24,5 @@ export async function findOrInitCartService(
25
24
  user,
26
25
  countryCode,
27
26
  forceCartCreation: true,
28
- }) as Order;
27
+ });
29
28
  }
@@ -10,5 +10,5 @@ export async function fullfillQuotationService(this: Modules, quotation: Quotati
10
10
  info: JSON.stringify(info),
11
11
  });
12
12
 
13
- return processQuotationService.bind(this)(updatedQuotation, {});
13
+ return processQuotationService.bind(this)(updatedQuotation!, {});
14
14
  }
@@ -0,0 +1,54 @@
1
+ import { Modules } from '../modules.js';
2
+ import { Enrollment, EnrollmentOrderPositionTemplate } from '@unchainedshop/core-enrollments';
3
+ import { updateCalculationService } from './updateCalculation.js';
4
+ import { checkoutOrderService } from './checkoutOrder.js';
5
+
6
+ export async function generateOrderFromEnrollmentService(
7
+ this: Modules,
8
+ enrollment: Enrollment,
9
+ {
10
+ orderPositionTemplates,
11
+ orderContext,
12
+ }: {
13
+ orderPositionTemplates: EnrollmentOrderPositionTemplate[];
14
+ orderContext?: any;
15
+ },
16
+ ) {
17
+ if (!enrollment.payment || !enrollment.delivery) return null;
18
+
19
+ const order = await this.orders.create({
20
+ userId: enrollment.userId,
21
+ currencyCode: enrollment.currencyCode,
22
+ countryCode: enrollment.countryCode,
23
+ contact: enrollment.contact,
24
+ billingAddress: enrollment.billingAddress,
25
+ originEnrollmentId: enrollment._id,
26
+ context: orderContext,
27
+ });
28
+ const orderId = order._id;
29
+
30
+ await Promise.all(
31
+ orderPositionTemplates.map((orderPositionTemplate) =>
32
+ this.orders.positions.addProductItem({
33
+ ...orderPositionTemplate,
34
+ orderId: order._id,
35
+ }),
36
+ ),
37
+ );
38
+
39
+ const { paymentProviderId, context: paymentContext } = enrollment.payment;
40
+ if (paymentProviderId) {
41
+ await this.orders.setPaymentProvider(orderId, paymentProviderId);
42
+ }
43
+
44
+ const { deliveryProviderId, context: deliveryContext } = enrollment.delivery;
45
+ if (deliveryProviderId) {
46
+ await this.orders.setDeliveryProvider(orderId, deliveryProviderId);
47
+ }
48
+
49
+ await updateCalculationService.bind(this)(orderId);
50
+ return checkoutOrderService.bind(this)(order._id, {
51
+ deliveryContext,
52
+ paymentContext,
53
+ });
54
+ }