@unchainedshop/core 4.0.0-rc.15 → 4.0.0-rc.17

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 (443) 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/transformSpecificationToProductStructure.d.ts +280 -0
  66. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -0
  67. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +77 -0
  68. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -0
  69. package/lib/bulk-importer/handlers/product/update.d.ts +1330 -0
  70. package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -0
  71. package/lib/bulk-importer/handlers/product/update.js +132 -0
  72. package/lib/bulk-importer/handlers/product/update.js.map +1 -0
  73. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +75 -0
  74. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -0
  75. package/lib/bulk-importer/handlers/product/upsertMedia.js +59 -0
  76. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -0
  77. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +79 -0
  78. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -0
  79. package/lib/bulk-importer/handlers/product/upsertVariations.js +72 -0
  80. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -0
  81. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +3 -0
  82. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -0
  83. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +6 -0
  84. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -0
  85. package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
  86. package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
  87. package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
  88. package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
  89. package/lib/bulk-importer/index.d.ts +4 -0
  90. package/lib/bulk-importer/index.d.ts.map +1 -0
  91. package/lib/bulk-importer/index.js +4 -0
  92. package/lib/bulk-importer/index.js.map +1 -0
  93. package/lib/bulk-importer/upsertAsset.d.ts +28 -0
  94. package/lib/bulk-importer/upsertAsset.d.ts.map +1 -0
  95. package/lib/bulk-importer/upsertAsset.js +41 -0
  96. package/lib/bulk-importer/upsertAsset.js.map +1 -0
  97. package/lib/core-index.d.ts +8 -6
  98. package/lib/core-index.d.ts.map +1 -1
  99. package/lib/core-index.js +4 -1
  100. package/lib/core-index.js.map +1 -1
  101. package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
  102. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
  103. package/lib/directors/BaseDiscountAdapter.js +1 -1
  104. package/lib/directors/BaseDiscountAdapter.js.map +1 -1
  105. package/lib/directors/BaseDiscountDirector.d.ts +1 -1
  106. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
  107. package/lib/directors/BaseDiscountDirector.js +1 -1
  108. package/lib/directors/BaseDiscountDirector.js.map +1 -1
  109. package/lib/directors/BasePricingAdapter.d.ts +2 -2
  110. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  111. package/lib/directors/BasePricingDirector.d.ts.map +1 -1
  112. package/lib/directors/BasePricingDirector.js +3 -3
  113. package/lib/directors/BasePricingDirector.js.map +1 -1
  114. package/lib/directors/BasePricingSheet.js.map +1 -1
  115. package/lib/directors/BaseWorker.js +1 -1
  116. package/lib/directors/BaseWorker.js.map +1 -1
  117. package/lib/directors/DeliveryAdapter.d.ts +3 -3
  118. package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
  119. package/lib/directors/DeliveryDirector.d.ts +3 -3
  120. package/lib/directors/DeliveryDirector.d.ts.map +1 -1
  121. package/lib/directors/DeliveryDirector.js +29 -16
  122. package/lib/directors/DeliveryDirector.js.map +1 -1
  123. package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
  124. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
  125. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
  126. package/lib/directors/DeliveryPricingDirector.js +3 -4
  127. package/lib/directors/DeliveryPricingDirector.js.map +1 -1
  128. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
  129. package/lib/directors/DeliveryPricingSheet.js +2 -1
  130. package/lib/directors/DeliveryPricingSheet.js.map +1 -1
  131. package/lib/directors/EnrollmentAdapter.d.ts +7 -4
  132. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
  133. package/lib/directors/EnrollmentAdapter.js +1 -4
  134. package/lib/directors/EnrollmentAdapter.js.map +1 -1
  135. package/lib/directors/EnrollmentDirector.d.ts +1 -1
  136. package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
  137. package/lib/directors/EnrollmentDirector.js +1 -5
  138. package/lib/directors/EnrollmentDirector.js.map +1 -1
  139. package/lib/directors/FilterAdapter.d.ts +3 -3
  140. package/lib/directors/FilterAdapter.d.ts.map +1 -1
  141. package/lib/directors/FilterDirector.d.ts +1 -1
  142. package/lib/directors/FilterDirector.d.ts.map +1 -1
  143. package/lib/directors/FilterDirector.js +1 -1
  144. package/lib/directors/FilterDirector.js.map +1 -1
  145. package/lib/directors/MessagingDirector.d.ts +1 -1
  146. package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
  147. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
  148. package/lib/directors/OrderDiscountAdapter.js.map +1 -1
  149. package/lib/directors/OrderPricingAdapter.d.ts +2 -2
  150. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
  151. package/lib/directors/OrderPricingDirector.d.ts +2 -2
  152. package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
  153. package/lib/directors/OrderPricingDirector.js +1 -1
  154. package/lib/directors/OrderPricingDirector.js.map +1 -1
  155. package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
  156. package/lib/directors/OrderPricingSheet.js +2 -1
  157. package/lib/directors/OrderPricingSheet.js.map +1 -1
  158. package/lib/directors/PaymentAdapter.d.ts +2 -2
  159. package/lib/directors/PaymentAdapter.d.ts.map +1 -1
  160. package/lib/directors/PaymentDirector.d.ts +4 -4
  161. package/lib/directors/PaymentDirector.d.ts.map +1 -1
  162. package/lib/directors/PaymentDirector.js +24 -6
  163. package/lib/directors/PaymentDirector.js.map +1 -1
  164. package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
  165. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
  166. package/lib/directors/PaymentPricingDirector.d.ts +1 -1
  167. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
  168. package/lib/directors/PaymentPricingDirector.js +3 -5
  169. package/lib/directors/PaymentPricingDirector.js.map +1 -1
  170. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
  171. package/lib/directors/PaymentPricingSheet.js +2 -1
  172. package/lib/directors/PaymentPricingSheet.js.map +1 -1
  173. package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
  174. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
  175. package/lib/directors/ProductDiscountAdapter.js.map +1 -1
  176. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
  177. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
  178. package/lib/directors/ProductPricingAdapter.d.ts +1 -1
  179. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  180. package/lib/directors/ProductPricingDirector.d.ts +2 -2
  181. package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
  182. package/lib/directors/ProductPricingDirector.js +3 -3
  183. package/lib/directors/ProductPricingDirector.js.map +1 -1
  184. package/lib/directors/ProductPricingSheet.d.ts +2 -2
  185. package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
  186. package/lib/directors/ProductPricingSheet.js +2 -1
  187. package/lib/directors/ProductPricingSheet.js.map +1 -1
  188. package/lib/directors/QuotationAdapter.d.ts +2 -2
  189. package/lib/directors/QuotationAdapter.d.ts.map +1 -1
  190. package/lib/directors/QuotationDirector.js +2 -2
  191. package/lib/directors/WarehousingAdapter.d.ts +3 -4
  192. package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
  193. package/lib/directors/WarehousingAdapter.js.map +1 -1
  194. package/lib/directors/WarehousingDirector.d.ts +5 -5
  195. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  196. package/lib/directors/WarehousingDirector.js +10 -13
  197. package/lib/directors/WarehousingDirector.js.map +1 -1
  198. package/lib/directors/WorkerAdapter.d.ts +3 -2
  199. package/lib/directors/WorkerAdapter.d.ts.map +1 -1
  200. package/lib/directors/WorkerAdapter.js +1 -1
  201. package/lib/directors/WorkerAdapter.js.map +1 -1
  202. package/lib/directors/WorkerDirector.d.ts +2 -2
  203. package/lib/directors/WorkerDirector.d.ts.map +1 -1
  204. package/lib/directors/WorkerDirector.js +2 -3
  205. package/lib/directors/WorkerDirector.js.map +1 -1
  206. package/lib/modules.d.ts +1 -1
  207. package/lib/modules.d.ts.map +1 -1
  208. package/lib/modules.js +1 -0
  209. package/lib/modules.js.map +1 -1
  210. package/lib/services/activateEnrollment.d.ts.map +1 -1
  211. package/lib/services/activateEnrollment.js +8 -12
  212. package/lib/services/activateEnrollment.js.map +1 -1
  213. package/lib/services/addMessage.d.ts +4 -0
  214. package/lib/services/addMessage.d.ts.map +1 -0
  215. package/lib/services/addMessage.js +15 -0
  216. package/lib/services/addMessage.js.map +1 -0
  217. package/lib/services/calculateDiscountTotal.js +2 -2
  218. package/lib/services/calculateDiscountTotal.js.map +1 -1
  219. package/lib/services/checkoutOrder.d.ts +1 -1
  220. package/lib/services/checkoutOrder.d.ts.map +1 -1
  221. package/lib/services/checkoutOrder.js +9 -3
  222. package/lib/services/checkoutOrder.js.map +1 -1
  223. package/lib/services/confirmOrder.d.ts +1 -1
  224. package/lib/services/confirmOrder.d.ts.map +1 -1
  225. package/lib/services/createDownloadStream.d.ts +1 -1
  226. package/lib/services/createDownloadStream.d.ts.map +1 -1
  227. package/lib/services/createDownloadStream.js +2 -0
  228. package/lib/services/createDownloadStream.js.map +1 -1
  229. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
  230. package/lib/services/createEnrollmentFromCheckout.js +2 -2
  231. package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
  232. package/lib/services/createManualOrderDiscount.d.ts +2 -2
  233. package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
  234. package/lib/services/createSignedURL.d.ts.map +1 -1
  235. package/lib/services/createSignedURL.js +2 -0
  236. package/lib/services/createSignedURL.js.map +1 -1
  237. package/lib/services/deleteUser.d.ts +1 -1
  238. package/lib/services/deleteUser.d.ts.map +1 -1
  239. package/lib/services/deleteUser.js +4 -2
  240. package/lib/services/deleteUser.js.map +1 -1
  241. package/lib/services/discountedEntities.js.map +1 -1
  242. package/lib/services/findOrInitCart.d.ts +1 -2
  243. package/lib/services/findOrInitCart.d.ts.map +1 -1
  244. package/lib/services/findOrInitCart.js.map +1 -1
  245. package/lib/services/fullfillQuotation.d.ts +1 -1
  246. package/lib/services/fullfillQuotation.d.ts.map +1 -1
  247. package/lib/services/fullfillQuotation.js.map +1 -1
  248. package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
  249. package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
  250. package/lib/services/generateOrderFromEnrollment.js +34 -0
  251. package/lib/services/generateOrderFromEnrollment.js.map +1 -0
  252. package/lib/services/index.d.ts +6 -0
  253. package/lib/services/index.d.ts.map +1 -1
  254. package/lib/services/index.js +6 -0
  255. package/lib/services/index.js.map +1 -1
  256. package/lib/services/initCartProviders.js.map +1 -1
  257. package/lib/services/initializeEnrollment.d.ts +1 -1
  258. package/lib/services/initializeEnrollment.d.ts.map +1 -1
  259. package/lib/services/initializeEnrollment.js +11 -12
  260. package/lib/services/initializeEnrollment.js.map +1 -1
  261. package/lib/services/linkFileService.d.ts +1 -1
  262. package/lib/services/linkFileService.d.ts.map +1 -1
  263. package/lib/services/linkFileService.js +3 -1
  264. package/lib/services/linkFileService.js.map +1 -1
  265. package/lib/services/loadFilterOptions.d.ts +2 -2
  266. package/lib/services/loadFilterOptions.d.ts.map +1 -1
  267. package/lib/services/migrateOrderCart.d.ts +1 -1
  268. package/lib/services/migrateOrderCart.d.ts.map +1 -1
  269. package/lib/services/nextUserCart.d.ts +1 -1
  270. package/lib/services/nextUserCart.d.ts.map +1 -1
  271. package/lib/services/nextUserCart.js +1 -1
  272. package/lib/services/nextUserCart.js.map +1 -1
  273. package/lib/services/processEnrollment.d.ts.map +1 -1
  274. package/lib/services/processEnrollment.js +13 -5
  275. package/lib/services/processEnrollment.js.map +1 -1
  276. package/lib/services/processOrder.d.ts.map +1 -1
  277. package/lib/services/processOrder.js +26 -30
  278. package/lib/services/processOrder.js.map +1 -1
  279. package/lib/services/processQuotation.d.ts.map +1 -1
  280. package/lib/services/processQuotation.js +10 -14
  281. package/lib/services/processQuotation.js.map +1 -1
  282. package/lib/services/proposeQuotation.d.ts +1 -1
  283. package/lib/services/proposeQuotation.d.ts.map +1 -1
  284. package/lib/services/proposeQuotation.js +2 -2
  285. package/lib/services/proposeQuotation.js.map +1 -1
  286. package/lib/services/registerPaymentCredentials.d.ts +1 -2
  287. package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
  288. package/lib/services/registerPaymentCredentials.js +4 -6
  289. package/lib/services/registerPaymentCredentials.js.map +1 -1
  290. package/lib/services/rejectOrder.d.ts +1 -1
  291. package/lib/services/rejectOrder.d.ts.map +1 -1
  292. package/lib/services/rejectQuotation.d.ts +1 -1
  293. package/lib/services/rejectQuotation.d.ts.map +1 -1
  294. package/lib/services/rejectQuotation.js +2 -2
  295. package/lib/services/rejectQuotation.js.map +1 -1
  296. package/lib/services/removeFiles.js +2 -2
  297. package/lib/services/removeFiles.js.map +1 -1
  298. package/lib/services/removeProduct.js +3 -3
  299. package/lib/services/removeProduct.js.map +1 -1
  300. package/lib/services/searchAssortments.js +1 -1
  301. package/lib/services/searchAssortments.js.map +1 -1
  302. package/lib/services/searchProducts.js +1 -1
  303. package/lib/services/searchProducts.js.map +1 -1
  304. package/lib/services/simulateProductDispatching.d.ts +1 -1
  305. package/lib/services/simulateProductDispatching.d.ts.map +1 -1
  306. package/lib/services/simulateProductInventory.d.ts +1 -1
  307. package/lib/services/simulateProductInventory.d.ts.map +1 -1
  308. package/lib/services/simulateProductInventory.js.map +1 -1
  309. package/lib/services/simulateProductPricing.d.ts +7 -4
  310. package/lib/services/simulateProductPricing.d.ts.map +1 -1
  311. package/lib/services/simulateProductPricing.js.map +1 -1
  312. package/lib/services/terminateEnrollment.d.ts.map +1 -1
  313. package/lib/services/terminateEnrollment.js +5 -9
  314. package/lib/services/terminateEnrollment.js.map +1 -1
  315. package/lib/services/updateCalculation.d.ts +2 -1
  316. package/lib/services/updateCalculation.d.ts.map +1 -1
  317. package/lib/services/updateCalculation.js +16 -10
  318. package/lib/services/updateCalculation.js.map +1 -1
  319. package/lib/services/updateScheduling.d.ts +1 -1
  320. package/lib/services/updateScheduling.d.ts.map +1 -1
  321. package/lib/services/updateScheduling.js +7 -11
  322. package/lib/services/updateScheduling.js.map +1 -1
  323. package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
  324. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
  325. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
  326. package/lib/services/uploadFileFromStream.d.ts.map +1 -1
  327. package/lib/services/uploadFileFromStream.js +4 -1
  328. package/lib/services/uploadFileFromStream.js.map +1 -1
  329. package/lib/services/uploadFileFromURL.d.ts +1 -2
  330. package/lib/services/uploadFileFromURL.d.ts.map +1 -1
  331. package/lib/services/uploadFileFromURL.js.map +1 -1
  332. package/lib/services/validateOrder.d.ts +1 -1
  333. package/lib/services/validateOrder.d.ts.map +1 -1
  334. package/lib/services/validateOrder.js +17 -24
  335. package/lib/services/validateOrder.js.map +1 -1
  336. package/lib/services/verifyQuotation.d.ts +1 -1
  337. package/lib/services/verifyQuotation.d.ts.map +1 -1
  338. package/lib/services/verifyQuotation.js +2 -2
  339. package/lib/services/verifyQuotation.js.map +1 -1
  340. package/package.json +21 -20
  341. package/src/bulk-importer/createBulkImporter.ts +205 -0
  342. package/src/bulk-importer/handlers/assortment/create.ts +118 -0
  343. package/src/bulk-importer/handlers/assortment/index.ts +3 -0
  344. package/src/bulk-importer/handlers/assortment/remove.ts +26 -0
  345. package/src/bulk-importer/handlers/assortment/update.ts +133 -0
  346. package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +77 -0
  347. package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +70 -0
  348. package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +76 -0
  349. package/src/bulk-importer/handlers/assortment/upsertMedia.ts +76 -0
  350. package/src/bulk-importer/handlers/filter/create.ts +104 -0
  351. package/src/bulk-importer/handlers/filter/index.ts +3 -0
  352. package/src/bulk-importer/handlers/filter/remove.ts +25 -0
  353. package/src/bulk-importer/handlers/filter/update.ts +94 -0
  354. package/src/bulk-importer/handlers/product/create.ts +170 -0
  355. package/src/bulk-importer/handlers/product/index.ts +3 -0
  356. package/src/bulk-importer/handlers/product/remove.ts +27 -0
  357. package/src/bulk-importer/handlers/product/update.ts +175 -0
  358. package/src/bulk-importer/handlers/product/upsertMedia.ts +81 -0
  359. package/src/bulk-importer/handlers/product/upsertVariations.ts +110 -0
  360. package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +4 -0
  361. package/src/bulk-importer/index.ts +3 -0
  362. package/src/bulk-importer/upsertAsset.ts +50 -0
  363. package/src/core-index.ts +9 -6
  364. package/src/directors/BaseDiscountAdapter.test.ts +1 -1
  365. package/src/directors/BaseDiscountAdapter.ts +5 -5
  366. package/src/directors/BaseDiscountDirector.ts +2 -2
  367. package/src/directors/BasePricingAdapter.ts +2 -2
  368. package/src/directors/BasePricingDirector.ts +47 -44
  369. package/src/directors/BasePricingSheet.ts +1 -1
  370. package/src/directors/BaseWorker.ts +1 -1
  371. package/src/directors/DeliveryAdapter.ts +3 -3
  372. package/src/directors/DeliveryDirector.ts +33 -23
  373. package/src/directors/DeliveryPricingAdapter.ts +1 -1
  374. package/src/directors/DeliveryPricingDirector.ts +5 -6
  375. package/src/directors/DeliveryPricingSheet.ts +3 -2
  376. package/src/directors/EnrollmentAdapter.ts +9 -6
  377. package/src/directors/EnrollmentDirector.ts +9 -8
  378. package/src/directors/FilterAdapter.ts +3 -3
  379. package/src/directors/FilterDirector.ts +5 -5
  380. package/src/directors/OrderDiscountAdapter.ts +2 -2
  381. package/src/directors/OrderPricingAdapter.ts +2 -2
  382. package/src/directors/OrderPricingDirector.ts +3 -3
  383. package/src/directors/OrderPricingSheet.ts +3 -2
  384. package/src/directors/PaymentAdapter.ts +2 -2
  385. package/src/directors/PaymentDirector.ts +34 -10
  386. package/src/directors/PaymentPricingAdapter.ts +2 -2
  387. package/src/directors/PaymentPricingDirector.ts +6 -8
  388. package/src/directors/PaymentPricingSheet.ts +3 -2
  389. package/src/directors/ProductDiscountAdapter.ts +2 -2
  390. package/src/directors/ProductDiscountConfiguration.ts +1 -1
  391. package/src/directors/ProductPricingAdapter.ts +1 -1
  392. package/src/directors/ProductPricingDirector.ts +7 -7
  393. package/src/directors/ProductPricingSheet.ts +4 -3
  394. package/src/directors/QuotationAdapter.ts +2 -2
  395. package/src/directors/QuotationDirector.ts +2 -2
  396. package/src/directors/WarehousingAdapter.ts +3 -4
  397. package/src/directors/WarehousingDirector.ts +20 -23
  398. package/src/directors/WorkerAdapter.ts +9 -4
  399. package/src/directors/WorkerDirector.ts +5 -6
  400. package/src/modules.ts +2 -1
  401. package/src/services/activateEnrollment.ts +9 -13
  402. package/src/services/addMessage.ts +20 -0
  403. package/src/services/calculateDiscountTotal.ts +4 -4
  404. package/src/services/checkoutOrder.ts +9 -4
  405. package/src/services/createDownloadStream.ts +1 -0
  406. package/src/services/createEnrollmentFromCheckout.ts +22 -20
  407. package/src/services/createManualOrderDiscount.ts +2 -2
  408. package/src/services/createSignedURL.ts +1 -0
  409. package/src/services/deleteUser.ts +7 -2
  410. package/src/services/discountedEntities.ts +6 -6
  411. package/src/services/findOrInitCart.ts +1 -2
  412. package/src/services/fullfillQuotation.ts +1 -1
  413. package/src/services/generateOrderFromEnrollment.ts +54 -0
  414. package/src/services/index.ts +8 -0
  415. package/src/services/initCartProviders.ts +2 -2
  416. package/src/services/initializeEnrollment.ts +16 -13
  417. package/src/services/linkFileService.ts +3 -1
  418. package/src/services/nextUserCart.ts +1 -1
  419. package/src/services/processEnrollment.ts +18 -6
  420. package/src/services/processOrder.ts +33 -36
  421. package/src/services/processQuotation.ts +10 -14
  422. package/src/services/proposeQuotation.ts +2 -2
  423. package/src/services/registerPaymentCredentials.ts +6 -8
  424. package/src/services/rejectQuotation.ts +2 -2
  425. package/src/services/removeFiles.ts +2 -2
  426. package/src/services/removeProduct.ts +3 -3
  427. package/src/services/searchAssortments.ts +1 -1
  428. package/src/services/searchProducts.ts +1 -1
  429. package/src/services/simulateProductDispatching.ts +1 -1
  430. package/src/services/simulateProductInventory.ts +7 -3
  431. package/src/services/simulateProductPricing.ts +6 -3
  432. package/src/services/terminateEnrollment.ts +5 -9
  433. package/src/services/updateCalculation.ts +33 -18
  434. package/src/services/updateScheduling.ts +19 -20
  435. package/src/services/updateUserAvatarAfterUpload.ts +4 -1
  436. package/src/services/uploadFileFromStream.ts +3 -1
  437. package/src/services/uploadFileFromURL.ts +2 -2
  438. package/src/services/validateOrder.ts +34 -38
  439. package/src/services/verifyQuotation.ts +2 -2
  440. package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts +0 -5
  441. package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts.map +0 -1
  442. package/lib/factory/registerProductDiscoverabilityFilter copy.js +0 -28
  443. package/lib/factory/registerProductDiscoverabilityFilter copy.js.map +0 -1
@@ -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
+ }
@@ -44,6 +44,8 @@ import { simulateProductPricingService } from './simulateProductPricing.js';
44
44
  import { simulateProductDispatchingService } from './simulateProductDispatching.js';
45
45
  import { simulateProductInventoryService } from './simulateProductInventory.js';
46
46
  import { findOrInitCartService } from './findOrInitCart.js';
47
+ import { addMessageService } from './addMessage.js';
48
+ import { generateOrderFromEnrollmentService } from './generateOrderFromEnrollment.js';
47
49
 
48
50
  // Auto-Inject Unchained API as last parameter
49
51
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
@@ -134,6 +136,9 @@ export default function initServices(modules: Modules, customServices: CustomSer
134
136
  createEnrollmentFromCheckout: createEnrollmentFromCheckoutService as Bound<
135
137
  typeof createEnrollmentFromCheckoutService
136
138
  >,
139
+ generateOrderFromEnrollment: generateOrderFromEnrollmentService as Bound<
140
+ typeof generateOrderFromEnrollmentService
141
+ >,
137
142
  processEnrollment: processOrderService as Bound<typeof processOrderService>,
138
143
  initializeEnrollment: initializeEnrollmentService as Bound<typeof initializeEnrollmentService>,
139
144
  activateEnrollment: activateEnrollmentService as Bound<typeof activateEnrollmentService>,
@@ -156,6 +161,9 @@ export default function initServices(modules: Modules, customServices: CustomSer
156
161
  warehousing: {
157
162
  ercMetadata: ercMetadataService as Bound<typeof ercMetadataService>,
158
163
  },
164
+ worker: {
165
+ addMessage: addMessageService as Bound<typeof addMessageService>,
166
+ },
159
167
  };
160
168
 
161
169
  // This Proxy Binds all services to the Modules Object
@@ -14,7 +14,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
14
14
  });
15
15
 
16
16
  const orderDelivery = await this.orders.deliveries.findDelivery({
17
- orderDeliveryId: updatedOrder.deliveryId,
17
+ orderDeliveryId: updatedOrder.deliveryId!,
18
18
  });
19
19
  const deliveryProviderId = orderDelivery?.deliveryProviderId;
20
20
 
@@ -45,7 +45,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
45
45
  });
46
46
 
47
47
  const orderPayment = await this.orders.payments.findOrderPayment({
48
- orderPaymentId: updatedOrder.paymentId,
48
+ orderPaymentId: updatedOrder.paymentId!,
49
49
  });
50
50
  const paymentProviderId = orderPayment?.paymentProviderId;
51
51
 
@@ -2,36 +2,39 @@ import { Enrollment } from '@unchainedshop/core-enrollments';
2
2
  import { EnrollmentDirector } from '../core-index.js';
3
3
  import { processEnrollmentService } from './processEnrollment.js';
4
4
  import { Modules } from '../modules.js';
5
+ import { addMessageService } from './addMessage.js';
5
6
 
6
7
  export async function initializeEnrollmentService(
7
8
  this: Modules,
8
9
  enrollment: Enrollment,
9
10
  params: { orderIdForFirstPeriod?: string; reason: string },
10
11
  ) {
11
- const director = await EnrollmentDirector.actions({ enrollment }, { modules: this });
12
+ const product = await this.products.findProduct({
13
+ productId: enrollment.productId,
14
+ });
15
+
16
+ const director = await EnrollmentDirector.actions(
17
+ { enrollment, product: product! },
18
+ { modules: this },
19
+ );
12
20
  const period = await director.nextPeriod();
13
21
 
14
22
  let updatedEnrollment = enrollment;
15
23
  if (period && (params.orderIdForFirstPeriod || period.isTrial)) {
16
- updatedEnrollment = await this.enrollments.addEnrollmentPeriod(enrollment._id, {
24
+ updatedEnrollment = (await this.enrollments.addEnrollmentPeriod(enrollment._id, {
17
25
  ...period,
18
26
  orderId: params.orderIdForFirstPeriod,
19
- });
27
+ })) as Enrollment;
20
28
  }
21
29
 
22
30
  const processedEnrollment = await processEnrollmentService.bind(this)(updatedEnrollment);
23
31
  const user = await this.users.findUserById(enrollment.userId);
24
- const locale = this.users.userLocale(user);
32
+ const locale = this.users.userLocale(user!);
25
33
 
26
- await this.worker.addWork({
27
- type: 'MESSAGE',
28
- retries: 0,
29
- input: {
30
- reason: params.reason || 'status_change',
31
- locale: locale.baseName,
32
- template: 'ENROLLMENT_STATUS',
33
- enrollmentId: processedEnrollment._id,
34
- },
34
+ await addMessageService.bind(this)('ENROLLMENT_STATUS', {
35
+ reason: 'status_change',
36
+ locale: locale.baseName,
37
+ enrollmentId: processedEnrollment._id,
35
38
  });
36
39
 
37
40
  return processedEnrollment;
@@ -6,11 +6,13 @@ export async function linkFileService(
6
6
  { fileId, size, type }: { fileId: string; size?: number; type?: string },
7
7
  ) {
8
8
  const file = await this.files.findFile({ fileId });
9
+ if (!file) return null;
10
+
9
11
  await this.files.update(file._id, {
10
12
  size: size || file.size,
11
13
  type: type || file.type,
12
- expires: null,
13
14
  });
15
+ await this.files.unexpire(file._id);
14
16
  if (file?.expires) {
15
17
  const callback = FileDirector.getFileUploadCallback(file.path);
16
18
  if (callback) {
@@ -30,7 +30,7 @@ export async function nextUserCartService(
30
30
 
31
31
  const countryObject = await this.countries.findCountry({ isoCode: countryCode });
32
32
  const currencies = await this.currencies.findCurrencies({ includeInactive: false });
33
- const currencyCode = resolveBestCurrency(countryObject.defaultCurrencyCode, currencies);
33
+ const currencyCode = resolveBestCurrency(countryObject?.defaultCurrencyCode || null, currencies);
34
34
 
35
35
  const order = await this.orders.create({
36
36
  userId: user._id,
@@ -2,9 +2,18 @@ import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
2
2
  import { Modules } from '../modules.js';
3
3
  import { EnrollmentDirector } from '../core-index.js';
4
4
 
5
- const findNextStatus = async (enrollment: Enrollment, modules: Modules): Promise<EnrollmentStatus> => {
5
+ const findNextStatus = async (
6
+ enrollment: Enrollment,
7
+ modules: Modules,
8
+ ): Promise<EnrollmentStatus | null> => {
6
9
  let status = enrollment.status;
7
- const director = await EnrollmentDirector.actions({ enrollment }, { modules });
10
+ const product = await modules.products.findProduct({
11
+ productId: enrollment.productId,
12
+ });
13
+
14
+ if (!product) throw new Error('Product not found for enrollment');
15
+
16
+ const director = await EnrollmentDirector.actions({ enrollment, product }, { modules });
8
17
 
9
18
  if (status === EnrollmentStatus.INITIAL || status === EnrollmentStatus.PAUSED) {
10
19
  if (await director.isValidForActivation()) {
@@ -30,8 +39,11 @@ export async function processEnrollmentService(this: Modules, enrollment: Enroll
30
39
  // status = await findNextStatus(nextEnrollment, unchainedAPI);
31
40
  }
32
41
 
33
- return this.enrollments.updateStatus(enrollment._id, {
34
- status,
35
- info: 'enrollment processed',
36
- });
42
+ if (status) {
43
+ return this.enrollments.updateStatus(enrollment._id, {
44
+ status,
45
+ info: 'enrollment processed',
46
+ }) as Promise<Enrollment>;
47
+ }
48
+ return enrollment;
37
49
  }
@@ -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,27 +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
153
  // TODO: What happens if this THROWS?
160
154
  // Tokenization would be skipped?
161
155
  // Enrollments will not be there?
162
156
  // Quotations would not fulfil?
163
- await DeliveryDirector.sendOrderDelivery(orderDelivery, deliveryContext, { modules: this });
157
+ await DeliveryDirector.sendOrderDelivery(order, deliveryContext, { modules: this });
164
158
 
165
159
  const orderPositions = await this.orders.positions.findOrderPositions({ orderId });
166
160
  const mappedProductOrderPositions = await Promise.all(
167
161
  orderPositions.map(async (orderPosition) => {
168
- const product = await this.products.findProduct({
162
+ const product = (await this.products.findProduct({
169
163
  productId: orderPosition.productId,
170
- });
164
+ })) as Product;
171
165
  return {
172
166
  orderPosition,
173
167
  product,
@@ -176,7 +170,8 @@ export async function processOrderService(
176
170
  );
177
171
  const tokenizedItems = mappedProductOrderPositions.filter(
178
172
  (item) => item.product?.type === ProductTypes.TokenizedProduct,
179
- );
173
+ ) as { orderPosition: OrderPosition; product: Product }[];
174
+
180
175
  if (tokenizedItems.length > 0) {
181
176
  // Give virtual warehouse a chance to instantiate new virtual objects
182
177
  const virtualProviders = (await this.warehousing.allProviders()).filter(
@@ -184,7 +179,7 @@ export async function processOrderService(
184
179
  );
185
180
 
186
181
  // It's very important to do this in a series and not in Promise.all
187
- // TODO: Actually, only createTokens should decide on the unique chainTokenId
182
+ // TODO: Actually, only createTokens should decide on the unique tokenSerialNumber
188
183
  // and the tokens should be created with a distributed Lock to not assign the same id multiple times!
189
184
  for (const { orderPosition, product } of tokenizedItems) {
190
185
  for (const virtualProvider of virtualProviders) {
@@ -225,12 +220,14 @@ export async function processOrderService(
225
220
  // Quotations: If we came here, the checkout succeeded, so we can fullfill underlying quotations
226
221
  const quotationItems = mappedProductOrderPositions.filter(
227
222
  (item) => item.orderPosition.quotationId,
228
- );
223
+ ) as { orderPosition: OrderPosition & { quotationId: string }; product: Product }[];
224
+
229
225
  await Promise.all(
230
226
  quotationItems.map(async ({ orderPosition }) => {
231
227
  const quotation = await this.quotations.findQuotation({
232
228
  quotationId: orderPosition.quotationId,
233
229
  });
230
+ if (!quotation) return; // TODO: What happens then?
234
231
  await fullfillQuotationService.bind(this)(quotation, {
235
232
  orderId,
236
233
  orderPositionId: orderPosition._id,
@@ -242,5 +239,5 @@ export async function processOrderService(
242
239
  nextStatus = await findNextStatus(nextStatus, order, this);
243
240
  }
244
241
 
245
- return this.orders.updateStatus(order._id, { status: nextStatus, info: comment });
242
+ return (await this.orders.updateStatus(order._id, { status: nextStatus, info: comment })) as Order;
246
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,7 +29,7 @@ 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
 
@@ -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
 
@@ -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
  ) {