@unchainedshop/core 4.0.0-rc.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/lib/bulk-importer/createBulkImporter.d.ts +84 -0
  2. package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -0
  3. package/lib/bulk-importer/createBulkImporter.js +142 -0
  4. package/lib/bulk-importer/createBulkImporter.js.map +1 -0
  5. package/lib/bulk-importer/handlers/assortment/create.d.ts +565 -0
  6. package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -0
  7. package/lib/bulk-importer/handlers/assortment/create.js +89 -0
  8. package/lib/bulk-importer/handlers/assortment/create.js.map +1 -0
  9. package/lib/bulk-importer/handlers/assortment/index.d.ts +4 -0
  10. package/lib/bulk-importer/handlers/assortment/index.d.ts.map +1 -0
  11. package/lib/bulk-importer/handlers/assortment/index.js +4 -0
  12. package/lib/bulk-importer/handlers/assortment/index.js.map +1 -0
  13. package/lib/bulk-importer/handlers/assortment/remove.d.ts +30 -0
  14. package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -0
  15. package/lib/bulk-importer/handlers/assortment/remove.js +18 -0
  16. package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -0
  17. package/lib/bulk-importer/handlers/assortment/update.d.ts +566 -0
  18. package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -0
  19. package/lib/bulk-importer/handlers/assortment/update.js +98 -0
  20. package/lib/bulk-importer/handlers/assortment/update.js.map +1 -0
  21. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +29 -0
  22. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -0
  23. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +45 -0
  24. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -0
  25. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +29 -0
  26. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -0
  27. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +41 -0
  28. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -0
  29. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +29 -0
  30. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -0
  31. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +46 -0
  32. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -0
  33. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +76 -0
  34. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -0
  35. package/lib/bulk-importer/handlers/assortment/upsertMedia.js +53 -0
  36. package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -0
  37. package/lib/bulk-importer/handlers/filter/create.d.ts +138 -0
  38. package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -0
  39. package/lib/bulk-importer/handlers/filter/create.js +80 -0
  40. package/lib/bulk-importer/handlers/filter/create.js.map +1 -0
  41. package/lib/bulk-importer/handlers/filter/index.d.ts +4 -0
  42. package/lib/bulk-importer/handlers/filter/index.d.ts.map +1 -0
  43. package/lib/bulk-importer/handlers/filter/index.js +4 -0
  44. package/lib/bulk-importer/handlers/filter/index.js.map +1 -0
  45. package/lib/bulk-importer/handlers/filter/remove.d.ts +20 -0
  46. package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -0
  47. package/lib/bulk-importer/handlers/filter/remove.js +18 -0
  48. package/lib/bulk-importer/handlers/filter/remove.js.map +1 -0
  49. package/lib/bulk-importer/handlers/filter/update.d.ts +138 -0
  50. package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -0
  51. package/lib/bulk-importer/handlers/filter/update.js +70 -0
  52. package/lib/bulk-importer/handlers/filter/update.js.map +1 -0
  53. package/lib/bulk-importer/handlers/product/create.d.ts +1330 -0
  54. package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -0
  55. package/lib/bulk-importer/handlers/product/create.js +132 -0
  56. package/lib/bulk-importer/handlers/product/create.js.map +1 -0
  57. package/lib/bulk-importer/handlers/product/index.d.ts +4 -0
  58. package/lib/bulk-importer/handlers/product/index.d.ts.map +1 -0
  59. package/lib/bulk-importer/handlers/product/index.js +4 -0
  60. package/lib/bulk-importer/handlers/product/index.js.map +1 -0
  61. package/lib/bulk-importer/handlers/product/remove.d.ts +32 -0
  62. package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -0
  63. package/lib/bulk-importer/handlers/product/remove.js +18 -0
  64. package/lib/bulk-importer/handlers/product/remove.js.map +1 -0
  65. package/lib/bulk-importer/handlers/product/update.d.ts +1330 -0
  66. package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -0
  67. package/lib/bulk-importer/handlers/product/update.js +132 -0
  68. package/lib/bulk-importer/handlers/product/update.js.map +1 -0
  69. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +75 -0
  70. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -0
  71. package/lib/bulk-importer/handlers/product/upsertMedia.js +59 -0
  72. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -0
  73. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +79 -0
  74. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -0
  75. package/lib/bulk-importer/handlers/product/upsertVariations.js +72 -0
  76. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -0
  77. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +3 -0
  78. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -0
  79. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +6 -0
  80. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -0
  81. package/lib/bulk-importer/index.d.ts +4 -0
  82. package/lib/bulk-importer/index.d.ts.map +1 -0
  83. package/lib/bulk-importer/index.js +4 -0
  84. package/lib/bulk-importer/index.js.map +1 -0
  85. package/lib/bulk-importer/upsertAsset.d.ts +28 -0
  86. package/lib/bulk-importer/upsertAsset.d.ts.map +1 -0
  87. package/lib/bulk-importer/upsertAsset.js +41 -0
  88. package/lib/bulk-importer/upsertAsset.js.map +1 -0
  89. package/lib/core-index.d.ts +9 -6
  90. package/lib/core-index.d.ts.map +1 -1
  91. package/lib/core-index.js +5 -1
  92. package/lib/core-index.js.map +1 -1
  93. package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
  94. package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
  95. package/lib/directors/BaseDiscountAdapter.js +1 -1
  96. package/lib/directors/BaseDiscountAdapter.js.map +1 -1
  97. package/lib/directors/BaseDiscountDirector.d.ts +1 -1
  98. package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
  99. package/lib/directors/BaseDiscountDirector.js +1 -1
  100. package/lib/directors/BaseDiscountDirector.js.map +1 -1
  101. package/lib/directors/BasePricingAdapter.d.ts +2 -2
  102. package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
  103. package/lib/directors/BasePricingDirector.d.ts.map +1 -1
  104. package/lib/directors/BasePricingDirector.js +3 -3
  105. package/lib/directors/BasePricingDirector.js.map +1 -1
  106. package/lib/directors/BasePricingSheet.js.map +1 -1
  107. package/lib/directors/BaseWorker.js +1 -1
  108. package/lib/directors/BaseWorker.js.map +1 -1
  109. package/lib/directors/DeliveryAdapter.d.ts +3 -3
  110. package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
  111. package/lib/directors/DeliveryDirector.d.ts +3 -3
  112. package/lib/directors/DeliveryDirector.d.ts.map +1 -1
  113. package/lib/directors/DeliveryDirector.js +29 -16
  114. package/lib/directors/DeliveryDirector.js.map +1 -1
  115. package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
  116. package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
  117. package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
  118. package/lib/directors/DeliveryPricingDirector.js +3 -4
  119. package/lib/directors/DeliveryPricingDirector.js.map +1 -1
  120. package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
  121. package/lib/directors/DeliveryPricingSheet.js +2 -1
  122. package/lib/directors/DeliveryPricingSheet.js.map +1 -1
  123. package/lib/directors/EnrollmentAdapter.d.ts +7 -4
  124. package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
  125. package/lib/directors/EnrollmentAdapter.js +1 -4
  126. package/lib/directors/EnrollmentAdapter.js.map +1 -1
  127. package/lib/directors/EnrollmentDirector.d.ts +1 -1
  128. package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
  129. package/lib/directors/EnrollmentDirector.js +1 -5
  130. package/lib/directors/EnrollmentDirector.js.map +1 -1
  131. package/lib/directors/FilterAdapter.d.ts +3 -3
  132. package/lib/directors/FilterAdapter.d.ts.map +1 -1
  133. package/lib/directors/FilterDirector.d.ts +1 -1
  134. package/lib/directors/FilterDirector.d.ts.map +1 -1
  135. package/lib/directors/FilterDirector.js +7 -8
  136. package/lib/directors/FilterDirector.js.map +1 -1
  137. package/lib/directors/MessagingDirector.d.ts +2 -2
  138. package/lib/directors/MessagingDirector.d.ts.map +1 -1
  139. package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
  140. package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
  141. package/lib/directors/OrderDiscountAdapter.js.map +1 -1
  142. package/lib/directors/OrderPricingAdapter.d.ts +2 -2
  143. package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
  144. package/lib/directors/OrderPricingDirector.d.ts +2 -2
  145. package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
  146. package/lib/directors/OrderPricingDirector.js +1 -1
  147. package/lib/directors/OrderPricingDirector.js.map +1 -1
  148. package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
  149. package/lib/directors/OrderPricingSheet.js +2 -1
  150. package/lib/directors/OrderPricingSheet.js.map +1 -1
  151. package/lib/directors/PaymentAdapter.d.ts +2 -2
  152. package/lib/directors/PaymentAdapter.d.ts.map +1 -1
  153. package/lib/directors/PaymentDirector.d.ts +4 -4
  154. package/lib/directors/PaymentDirector.d.ts.map +1 -1
  155. package/lib/directors/PaymentDirector.js +24 -6
  156. package/lib/directors/PaymentDirector.js.map +1 -1
  157. package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
  158. package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
  159. package/lib/directors/PaymentPricingDirector.d.ts +1 -1
  160. package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
  161. package/lib/directors/PaymentPricingDirector.js +3 -5
  162. package/lib/directors/PaymentPricingDirector.js.map +1 -1
  163. package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
  164. package/lib/directors/PaymentPricingSheet.js +2 -1
  165. package/lib/directors/PaymentPricingSheet.js.map +1 -1
  166. package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
  167. package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
  168. package/lib/directors/ProductDiscountAdapter.js.map +1 -1
  169. package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
  170. package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
  171. package/lib/directors/ProductPricingAdapter.d.ts +1 -1
  172. package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
  173. package/lib/directors/ProductPricingDirector.d.ts +2 -2
  174. package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
  175. package/lib/directors/ProductPricingDirector.js +3 -3
  176. package/lib/directors/ProductPricingDirector.js.map +1 -1
  177. package/lib/directors/ProductPricingSheet.d.ts +2 -2
  178. package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
  179. package/lib/directors/ProductPricingSheet.js +2 -1
  180. package/lib/directors/ProductPricingSheet.js.map +1 -1
  181. package/lib/directors/QuotationAdapter.d.ts +2 -2
  182. package/lib/directors/QuotationAdapter.d.ts.map +1 -1
  183. package/lib/directors/QuotationDirector.js +2 -2
  184. package/lib/directors/WarehousingAdapter.d.ts +3 -4
  185. package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
  186. package/lib/directors/WarehousingAdapter.js.map +1 -1
  187. package/lib/directors/WarehousingDirector.d.ts +5 -5
  188. package/lib/directors/WarehousingDirector.d.ts.map +1 -1
  189. package/lib/directors/WarehousingDirector.js +10 -13
  190. package/lib/directors/WarehousingDirector.js.map +1 -1
  191. package/lib/directors/WorkerAdapter.d.ts +3 -2
  192. package/lib/directors/WorkerAdapter.d.ts.map +1 -1
  193. package/lib/directors/WorkerAdapter.js +1 -1
  194. package/lib/directors/WorkerAdapter.js.map +1 -1
  195. package/lib/directors/WorkerDirector.d.ts +2 -2
  196. package/lib/directors/WorkerDirector.d.ts.map +1 -1
  197. package/lib/directors/WorkerDirector.js +2 -3
  198. package/lib/directors/WorkerDirector.js.map +1 -1
  199. package/lib/factory/index.d.ts +3 -0
  200. package/lib/factory/index.d.ts.map +1 -0
  201. package/lib/factory/index.js +3 -0
  202. package/lib/factory/index.js.map +1 -0
  203. package/lib/factory/registerProductDiscoverabilityFilter.d.ts +5 -0
  204. package/lib/factory/registerProductDiscoverabilityFilter.d.ts.map +1 -0
  205. package/lib/factory/registerProductDiscoverabilityFilter.js +27 -0
  206. package/lib/factory/registerProductDiscoverabilityFilter.js.map +1 -0
  207. package/lib/modules.d.ts +4 -5
  208. package/lib/modules.d.ts.map +1 -1
  209. package/lib/modules.js +3 -3
  210. package/lib/modules.js.map +1 -1
  211. package/lib/services/activateEnrollment.d.ts.map +1 -1
  212. package/lib/services/activateEnrollment.js +8 -12
  213. package/lib/services/activateEnrollment.js.map +1 -1
  214. package/lib/services/addMessage.d.ts +4 -0
  215. package/lib/services/addMessage.d.ts.map +1 -0
  216. package/lib/services/addMessage.js +15 -0
  217. package/lib/services/addMessage.js.map +1 -0
  218. package/lib/services/calculateDiscountTotal.js +2 -2
  219. package/lib/services/calculateDiscountTotal.js.map +1 -1
  220. package/lib/services/checkoutOrder.d.ts +1 -1
  221. package/lib/services/checkoutOrder.d.ts.map +1 -1
  222. package/lib/services/checkoutOrder.js +10 -4
  223. package/lib/services/checkoutOrder.js.map +1 -1
  224. package/lib/services/confirmOrder.d.ts +1 -1
  225. package/lib/services/confirmOrder.d.ts.map +1 -1
  226. package/lib/services/createDownloadStream.d.ts +1 -1
  227. package/lib/services/createDownloadStream.d.ts.map +1 -1
  228. package/lib/services/createDownloadStream.js +2 -0
  229. package/lib/services/createDownloadStream.js.map +1 -1
  230. package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
  231. package/lib/services/createEnrollmentFromCheckout.js +2 -2
  232. package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
  233. package/lib/services/createManualOrderDiscount.d.ts +2 -2
  234. package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
  235. package/lib/services/createSignedURL.d.ts.map +1 -1
  236. package/lib/services/createSignedURL.js +2 -0
  237. package/lib/services/createSignedURL.js.map +1 -1
  238. package/lib/services/deleteUser.d.ts +1 -1
  239. package/lib/services/deleteUser.d.ts.map +1 -1
  240. package/lib/services/deleteUser.js +4 -2
  241. package/lib/services/deleteUser.js.map +1 -1
  242. package/lib/services/discountedEntities.js.map +1 -1
  243. package/lib/services/findOrInitCart.d.ts +1 -2
  244. package/lib/services/findOrInitCart.d.ts.map +1 -1
  245. package/lib/services/findOrInitCart.js.map +1 -1
  246. package/lib/services/fullfillQuotation.d.ts +1 -1
  247. package/lib/services/fullfillQuotation.d.ts.map +1 -1
  248. package/lib/services/fullfillQuotation.js.map +1 -1
  249. package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
  250. package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
  251. package/lib/services/generateOrderFromEnrollment.js +34 -0
  252. package/lib/services/generateOrderFromEnrollment.js.map +1 -0
  253. package/lib/services/index.d.ts +6 -0
  254. package/lib/services/index.d.ts.map +1 -1
  255. package/lib/services/index.js +6 -0
  256. package/lib/services/index.js.map +1 -1
  257. package/lib/services/initCartProviders.d.ts.map +1 -1
  258. package/lib/services/initCartProviders.js +6 -2
  259. package/lib/services/initCartProviders.js.map +1 -1
  260. package/lib/services/initializeEnrollment.d.ts +1 -1
  261. package/lib/services/initializeEnrollment.d.ts.map +1 -1
  262. package/lib/services/initializeEnrollment.js +11 -12
  263. package/lib/services/initializeEnrollment.js.map +1 -1
  264. package/lib/services/linkFileService.d.ts +1 -1
  265. package/lib/services/linkFileService.d.ts.map +1 -1
  266. package/lib/services/linkFileService.js +3 -1
  267. package/lib/services/linkFileService.js.map +1 -1
  268. package/lib/services/loadFilterOptions.d.ts +2 -2
  269. package/lib/services/loadFilterOptions.d.ts.map +1 -1
  270. package/lib/services/migrateOrderCart.d.ts +1 -1
  271. package/lib/services/migrateOrderCart.d.ts.map +1 -1
  272. package/lib/services/nextUserCart.d.ts +1 -1
  273. package/lib/services/nextUserCart.d.ts.map +1 -1
  274. package/lib/services/nextUserCart.js +1 -1
  275. package/lib/services/nextUserCart.js.map +1 -1
  276. package/lib/services/processEnrollment.d.ts.map +1 -1
  277. package/lib/services/processEnrollment.js +13 -5
  278. package/lib/services/processEnrollment.js.map +1 -1
  279. package/lib/services/processOrder.d.ts.map +1 -1
  280. package/lib/services/processOrder.js +30 -30
  281. package/lib/services/processOrder.js.map +1 -1
  282. package/lib/services/processQuotation.d.ts.map +1 -1
  283. package/lib/services/processQuotation.js +10 -14
  284. package/lib/services/processQuotation.js.map +1 -1
  285. package/lib/services/proposeQuotation.d.ts +1 -1
  286. package/lib/services/proposeQuotation.d.ts.map +1 -1
  287. package/lib/services/proposeQuotation.js +2 -2
  288. package/lib/services/proposeQuotation.js.map +1 -1
  289. package/lib/services/registerPaymentCredentials.d.ts +1 -2
  290. package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
  291. package/lib/services/registerPaymentCredentials.js +4 -6
  292. package/lib/services/registerPaymentCredentials.js.map +1 -1
  293. package/lib/services/rejectOrder.d.ts +1 -1
  294. package/lib/services/rejectOrder.d.ts.map +1 -1
  295. package/lib/services/rejectQuotation.d.ts +1 -1
  296. package/lib/services/rejectQuotation.d.ts.map +1 -1
  297. package/lib/services/rejectQuotation.js +2 -2
  298. package/lib/services/rejectQuotation.js.map +1 -1
  299. package/lib/services/removeFiles.js +2 -2
  300. package/lib/services/removeFiles.js.map +1 -1
  301. package/lib/services/removeProduct.js +3 -3
  302. package/lib/services/removeProduct.js.map +1 -1
  303. package/lib/services/searchAssortments.d.ts.map +1 -1
  304. package/lib/services/searchAssortments.js +3 -2
  305. package/lib/services/searchAssortments.js.map +1 -1
  306. package/lib/services/searchProducts.d.ts.map +1 -1
  307. package/lib/services/searchProducts.js +3 -2
  308. package/lib/services/searchProducts.js.map +1 -1
  309. package/lib/services/simulateProductDispatching.d.ts +1 -1
  310. package/lib/services/simulateProductDispatching.d.ts.map +1 -1
  311. package/lib/services/simulateProductInventory.d.ts +1 -1
  312. package/lib/services/simulateProductInventory.d.ts.map +1 -1
  313. package/lib/services/simulateProductInventory.js.map +1 -1
  314. package/lib/services/simulateProductPricing.d.ts +7 -4
  315. package/lib/services/simulateProductPricing.d.ts.map +1 -1
  316. package/lib/services/simulateProductPricing.js.map +1 -1
  317. package/lib/services/terminateEnrollment.d.ts.map +1 -1
  318. package/lib/services/terminateEnrollment.js +5 -9
  319. package/lib/services/terminateEnrollment.js.map +1 -1
  320. package/lib/services/updateCalculation.d.ts +2 -1
  321. package/lib/services/updateCalculation.d.ts.map +1 -1
  322. package/lib/services/updateCalculation.js +20 -12
  323. package/lib/services/updateCalculation.js.map +1 -1
  324. package/lib/services/updateScheduling.d.ts +1 -1
  325. package/lib/services/updateScheduling.d.ts.map +1 -1
  326. package/lib/services/updateScheduling.js +7 -11
  327. package/lib/services/updateScheduling.js.map +1 -1
  328. package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
  329. package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
  330. package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
  331. package/lib/services/uploadFileFromStream.d.ts.map +1 -1
  332. package/lib/services/uploadFileFromStream.js +4 -1
  333. package/lib/services/uploadFileFromStream.js.map +1 -1
  334. package/lib/services/uploadFileFromURL.d.ts +1 -2
  335. package/lib/services/uploadFileFromURL.d.ts.map +1 -1
  336. package/lib/services/uploadFileFromURL.js.map +1 -1
  337. package/lib/services/validateOrder.d.ts +1 -1
  338. package/lib/services/validateOrder.d.ts.map +1 -1
  339. package/lib/services/validateOrder.js +17 -24
  340. package/lib/services/validateOrder.js.map +1 -1
  341. package/lib/services/verifyQuotation.d.ts +1 -1
  342. package/lib/services/verifyQuotation.d.ts.map +1 -1
  343. package/lib/services/verifyQuotation.js +2 -2
  344. package/lib/services/verifyQuotation.js.map +1 -1
  345. package/package.json +21 -20
  346. package/src/bulk-importer/createBulkImporter.ts +205 -0
  347. package/src/bulk-importer/handlers/assortment/create.ts +118 -0
  348. package/src/bulk-importer/handlers/assortment/index.ts +3 -0
  349. package/src/bulk-importer/handlers/assortment/remove.ts +26 -0
  350. package/src/bulk-importer/handlers/assortment/update.ts +133 -0
  351. package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +77 -0
  352. package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +70 -0
  353. package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +76 -0
  354. package/src/bulk-importer/handlers/assortment/upsertMedia.ts +76 -0
  355. package/src/bulk-importer/handlers/filter/create.ts +104 -0
  356. package/src/bulk-importer/handlers/filter/index.ts +3 -0
  357. package/src/bulk-importer/handlers/filter/remove.ts +25 -0
  358. package/src/bulk-importer/handlers/filter/update.ts +94 -0
  359. package/src/bulk-importer/handlers/product/create.ts +170 -0
  360. package/src/bulk-importer/handlers/product/index.ts +3 -0
  361. package/src/bulk-importer/handlers/product/remove.ts +27 -0
  362. package/src/bulk-importer/handlers/product/update.ts +175 -0
  363. package/src/bulk-importer/handlers/product/upsertMedia.ts +81 -0
  364. package/src/bulk-importer/handlers/product/upsertVariations.ts +110 -0
  365. package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +4 -0
  366. package/src/bulk-importer/index.ts +3 -0
  367. package/src/bulk-importer/upsertAsset.ts +50 -0
  368. package/src/core-index.ts +10 -7
  369. package/src/directors/BaseDiscountAdapter.test.ts +1 -1
  370. package/src/directors/BaseDiscountAdapter.ts +5 -5
  371. package/src/directors/BaseDiscountDirector.ts +2 -2
  372. package/src/directors/BasePricingAdapter.ts +2 -2
  373. package/src/directors/BasePricingDirector.ts +47 -44
  374. package/src/directors/BasePricingSheet.ts +1 -1
  375. package/src/directors/BaseWorker.ts +1 -1
  376. package/src/directors/DeliveryAdapter.ts +3 -3
  377. package/src/directors/DeliveryDirector.ts +33 -23
  378. package/src/directors/DeliveryPricingAdapter.ts +1 -1
  379. package/src/directors/DeliveryPricingDirector.ts +5 -6
  380. package/src/directors/DeliveryPricingSheet.ts +3 -2
  381. package/src/directors/EnrollmentAdapter.ts +9 -6
  382. package/src/directors/EnrollmentDirector.ts +9 -8
  383. package/src/directors/FilterAdapter.ts +3 -3
  384. package/src/directors/FilterDirector.ts +11 -12
  385. package/src/directors/MessagingDirector.ts +1 -1
  386. package/src/directors/OrderDiscountAdapter.ts +2 -2
  387. package/src/directors/OrderPricingAdapter.ts +2 -2
  388. package/src/directors/OrderPricingDirector.ts +3 -3
  389. package/src/directors/OrderPricingSheet.ts +3 -2
  390. package/src/directors/PaymentAdapter.ts +2 -2
  391. package/src/directors/PaymentDirector.ts +34 -10
  392. package/src/directors/PaymentPricingAdapter.ts +2 -2
  393. package/src/directors/PaymentPricingDirector.ts +6 -8
  394. package/src/directors/PaymentPricingSheet.ts +3 -2
  395. package/src/directors/ProductDiscountAdapter.ts +2 -2
  396. package/src/directors/ProductDiscountConfiguration.ts +1 -1
  397. package/src/directors/ProductPricingAdapter.ts +1 -1
  398. package/src/directors/ProductPricingDirector.ts +7 -7
  399. package/src/directors/ProductPricingSheet.ts +4 -3
  400. package/src/directors/QuotationAdapter.ts +2 -2
  401. package/src/directors/QuotationDirector.ts +2 -2
  402. package/src/directors/WarehousingAdapter.ts +3 -4
  403. package/src/directors/WarehousingDirector.ts +20 -23
  404. package/src/directors/WorkerAdapter.ts +9 -4
  405. package/src/directors/WorkerDirector.ts +5 -6
  406. package/src/factory/index.ts +3 -0
  407. package/src/factory/registerProductDiscoverabilityFilter.ts +36 -0
  408. package/src/modules.ts +6 -7
  409. package/src/services/activateEnrollment.ts +9 -13
  410. package/src/services/addMessage.ts +20 -0
  411. package/src/services/calculateDiscountTotal.ts +4 -4
  412. package/src/services/checkoutOrder.ts +10 -5
  413. package/src/services/createDownloadStream.ts +1 -0
  414. package/src/services/createEnrollmentFromCheckout.ts +22 -20
  415. package/src/services/createManualOrderDiscount.ts +2 -2
  416. package/src/services/createSignedURL.ts +1 -0
  417. package/src/services/deleteUser.ts +7 -2
  418. package/src/services/discountedEntities.ts +6 -6
  419. package/src/services/findOrInitCart.ts +1 -2
  420. package/src/services/fullfillQuotation.ts +1 -1
  421. package/src/services/generateOrderFromEnrollment.ts +54 -0
  422. package/src/services/index.ts +8 -0
  423. package/src/services/initCartProviders.ts +8 -10
  424. package/src/services/initializeEnrollment.ts +16 -13
  425. package/src/services/linkFileService.ts +3 -1
  426. package/src/services/nextUserCart.ts +1 -1
  427. package/src/services/processEnrollment.ts +18 -6
  428. package/src/services/processOrder.ts +37 -36
  429. package/src/services/processQuotation.ts +10 -14
  430. package/src/services/proposeQuotation.ts +2 -2
  431. package/src/services/registerPaymentCredentials.ts +6 -8
  432. package/src/services/rejectQuotation.ts +2 -2
  433. package/src/services/removeFiles.ts +2 -2
  434. package/src/services/removeProduct.ts +3 -3
  435. package/src/services/searchAssortments.ts +3 -2
  436. package/src/services/searchProducts.ts +4 -2
  437. package/src/services/simulateProductDispatching.ts +1 -1
  438. package/src/services/simulateProductInventory.ts +7 -3
  439. package/src/services/simulateProductPricing.ts +6 -3
  440. package/src/services/terminateEnrollment.ts +5 -9
  441. package/src/services/updateCalculation.ts +37 -20
  442. package/src/services/updateScheduling.ts +19 -20
  443. package/src/services/updateUserAvatarAfterUpload.ts +4 -1
  444. package/src/services/uploadFileFromStream.ts +3 -1
  445. package/src/services/uploadFileFromURL.ts +2 -2
  446. package/src/services/validateOrder.ts +34 -38
  447. package/src/services/verifyQuotation.ts +2 -2
@@ -1,45 +1,38 @@
1
1
  import { ordersSettings } from '@unchainedshop/core-orders';
2
2
  export async function validateOrderService(order) {
3
- const errors = [];
4
3
  if (!order.contact)
5
- errors.push(new Error('Contact data not provided'));
4
+ throw new Error('Contact data not provided');
6
5
  if (!order.billingAddress)
7
- errors.push(new Error('Billing address not provided'));
8
- if (!(await this.orders.deliveries.findDelivery({ orderDeliveryId: order.deliveryId })))
9
- errors.push('No delivery provider selected');
10
- if (!(await this.orders.payments.findOrderPayment({ orderPaymentId: order.paymentId })))
11
- errors.push('No payment provider selected');
6
+ throw new Error('Billing address not provided');
7
+ if (!order.deliveryId ||
8
+ !(await this.orders.deliveries.findDelivery({ orderDeliveryId: order.deliveryId })))
9
+ throw new Error('No delivery provider selected');
10
+ if (!order.paymentId ||
11
+ !(await this.orders.payments.findOrderPayment({ orderPaymentId: order.paymentId })))
12
+ throw new Error('No payment provider selected');
12
13
  const orderPositions = await this.orders.positions.findOrderPositions({ orderId: order._id });
13
14
  if (orderPositions.length === 0) {
14
15
  const NoItemsError = new Error('No items to checkout');
15
16
  NoItemsError.name = 'NoItemsError';
16
- return [NoItemsError];
17
+ throw NoItemsError;
17
18
  }
18
- await Promise.all(orderPositions.map(async (orderPosition) => {
19
+ for (const orderPosition of orderPositions) {
19
20
  const product = await this.products.findProduct({
20
21
  productId: orderPosition.productId,
21
22
  });
22
- try {
23
- await ordersSettings.validateOrderPosition({
24
- order,
25
- product,
26
- configuration: orderPosition.configuration,
27
- quantityDiff: 0,
28
- }, { modules: this });
29
- }
30
- catch (e) {
31
- errors.push(e);
32
- }
23
+ await ordersSettings.validateOrderPosition({
24
+ order,
25
+ product,
26
+ configuration: orderPosition.configuration,
27
+ quantityDiff: 0,
28
+ }, { modules: this });
33
29
  const quotation = orderPosition.quotationId &&
34
30
  (await this.quotations.findQuotation({
35
31
  quotationId: orderPosition.quotationId,
36
32
  }));
37
33
  if (quotation && !this.quotations.isProposalValid(quotation)) {
38
- errors.push(new Error('Quotation expired or fullfiled, please request a new offer'));
34
+ throw new Error('Quotation expired or fullfiled, please request a new offer');
39
35
  }
40
- }));
41
- if (errors.length > 0) {
42
- throw new Error(errors[0]);
43
36
  }
44
37
  }
45
38
  //# sourceMappingURL=validateOrder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateOrder.js","sourceRoot":"","sources":["../../src/services/validateOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAgB,KAAY;IACpE,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,KAAK,CAAC,cAAc;QAAE,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAClF,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;QACrF,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IAC/C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QACrF,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;IAE9C,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9F,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACvD,YAAY,CAAC,IAAI,GAAG,cAAc,CAAC;QACnC,OAAO,CAAC,YAAY,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CACf,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QACzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC9C,SAAS,EAAE,aAAa,CAAC,SAAS;SACnC,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,cAAc,CAAC,qBAAqB,CACxC;gBACE,KAAK;gBACL,OAAO;gBACP,aAAa,EAAE,aAAa,CAAC,aAAa;gBAC1C,YAAY,EAAE,CAAC;aAChB,EACD,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QAED,MAAM,SAAS,GACb,aAAa,CAAC,WAAW;YACzB,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;gBACnC,WAAW,EAAE,aAAa,CAAC,WAAW;aACvC,CAAC,CAAC,CAAC;QACN,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"validateOrder.js","sourceRoot":"","sources":["../../src/services/validateOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGnE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAgB,KAAY;IACpE,IAAI,CAAC,KAAK,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,cAAc;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAC3E,IACE,CAAC,KAAK,CAAC,UAAU;QACjB,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;QAEnF,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,IACE,CAAC,KAAK,CAAC,SAAS;QAChB,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;QAEnF,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAElD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9F,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACvD,YAAY,CAAC,IAAI,GAAG,cAAc,CAAC;QACnC,MAAM,YAAY,CAAC;IACrB,CAAC;IAED,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC9C,SAAS,EAAE,aAAa,CAAC,SAAS;SACnC,CAAC,CAAC;QAEH,MAAM,cAAc,CAAC,qBAAqB,CACxC;YACE,KAAK;YACL,OAAO;YACP,aAAa,EAAE,aAAa,CAAC,aAAa;YAC1C,YAAY,EAAE,CAAC;SAChB,EACD,EAAE,OAAO,EAAE,IAAI,EAAE,CAClB,CAAC;QAEF,MAAM,SAAS,GACb,aAAa,CAAC,WAAW;YACzB,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC;gBACnC,WAAW,EAAE,aAAa,CAAC,WAAW;aACvC,CAAC,CAAC,CAAC;QACN,IAAI,SAAS,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -2,5 +2,5 @@ import { Quotation } from '@unchainedshop/core-quotations';
2
2
  import { Modules } from '../modules.js';
3
3
  export declare function verifyQuotationService(this: Modules, quotation: Quotation, { quotationContext }: {
4
4
  quotationContext?: any;
5
- }): Promise<any>;
5
+ }): Promise<Quotation>;
6
6
  //# sourceMappingURL=verifyQuotation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verifyQuotation.d.ts","sourceRoot":"","sources":["../../src/services/verifyQuotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,gCAAgC,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,SAAS,EACpB,EAAE,gBAAgB,EAAE,EAAE;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAA;CAAE,gBAUjD"}
1
+ {"version":3,"file":"verifyQuotation.d.ts","sourceRoot":"","sources":["../../src/services/verifyQuotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,gCAAgC,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,SAAS,EACpB,EAAE,gBAAgB,EAAE,EAAE;IAAE,gBAAgB,CAAC,EAAE,GAAG,CAAA;CAAE,sBAUjD"}
@@ -3,10 +3,10 @@ import { processQuotationService } from './processQuotation.js';
3
3
  export async function verifyQuotationService(quotation, { quotationContext }) {
4
4
  if (quotation.status !== QuotationStatus.REQUESTED)
5
5
  return quotation;
6
- const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
6
+ const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
7
7
  status: QuotationStatus.PROCESSING,
8
8
  info: 'verified elligibility manually',
9
- });
9
+ }));
10
10
  return await processQuotationService.bind(this)(updatedQuotation, { quotationContext });
11
11
  }
12
12
  //# sourceMappingURL=verifyQuotation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verifyQuotation.js","sourceRoot":"","sources":["../../src/services/verifyQuotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAE1C,SAAoB,EACpB,EAAE,gBAAgB,EAA8B;IAEhD,IAAI,SAAS,CAAC,MAAM,KAAK,eAAe,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IAErE,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,EAAE;QACzE,MAAM,EAAE,eAAe,CAAC,UAAU;QAClC,IAAI,EAAE,gCAAgC;KACvC,CAAC,CAAC;IAEH,OAAO,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC1F,CAAC"}
1
+ {"version":3,"file":"verifyQuotation.js","sourceRoot":"","sources":["../../src/services/verifyQuotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAE1C,SAAoB,EACpB,EAAE,gBAAgB,EAA8B;IAEhD,IAAI,SAAS,CAAC,MAAM,KAAK,eAAe,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IAErE,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,EAAE;QAC1E,MAAM,EAAE,eAAe,CAAC,UAAU;QAClC,IAAI,EAAE,gCAAgC;KACvC,CAAC,CAAc,CAAC;IAEjB,OAAO,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAC1F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/core",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.0",
4
4
  "main": "lib/core-index.js",
5
5
  "types": "lib/core-index.d.ts",
6
6
  "type": "module",
@@ -32,25 +32,26 @@
32
32
  "homepage": "https://github.com/unchainedshop/unchained#readme",
33
33
  "dependencies": {
34
34
  "@breejs/later": "^4.2.0",
35
- "@unchainedshop/core-assortments": "^4.0.0-rc.4",
36
- "@unchainedshop/core-bookmarks": "^4.0.0-rc.4",
37
- "@unchainedshop/core-countries": "^4.0.0-rc.4",
38
- "@unchainedshop/core-currencies": "^4.0.0-rc.4",
39
- "@unchainedshop/core-delivery": "^4.0.0-rc.4",
40
- "@unchainedshop/core-enrollments": "^4.0.0-rc.4",
41
- "@unchainedshop/core-events": "^4.0.0-rc.4",
42
- "@unchainedshop/core-files": "^4.0.0-rc.4",
43
- "@unchainedshop/core-filters": "^4.0.0-rc.4",
44
- "@unchainedshop/core-languages": "^4.0.0-rc.4",
45
- "@unchainedshop/core-orders": "^4.0.0-rc.4",
46
- "@unchainedshop/core-payment": "^4.0.0-rc.4",
47
- "@unchainedshop/core-products": "^4.0.0-rc.4",
48
- "@unchainedshop/core-quotations": "^4.0.0-rc.4",
49
- "@unchainedshop/core-users": "^4.0.0-rc.4",
50
- "@unchainedshop/core-warehousing": "^4.0.0-rc.4",
51
- "@unchainedshop/core-worker": "^4.0.0-rc.4",
52
- "@unchainedshop/logger": "^4.0.0-rc.4",
53
- "@unchainedshop/utils": "^4.0.0-rc.4"
35
+ "@unchainedshop/core-assortments": "^4.0.0",
36
+ "@unchainedshop/core-bookmarks": "^4.0.0",
37
+ "@unchainedshop/core-countries": "^4.0.0",
38
+ "@unchainedshop/core-currencies": "^4.0.0",
39
+ "@unchainedshop/core-delivery": "^4.0.0",
40
+ "@unchainedshop/core-enrollments": "^4.0.0",
41
+ "@unchainedshop/core-events": "^4.0.0",
42
+ "@unchainedshop/core-files": "^4.0.0",
43
+ "@unchainedshop/core-filters": "^4.0.0",
44
+ "@unchainedshop/core-languages": "^4.0.0",
45
+ "@unchainedshop/core-orders": "^4.0.0",
46
+ "@unchainedshop/core-payment": "^4.0.0",
47
+ "@unchainedshop/core-products": "^4.0.0",
48
+ "@unchainedshop/core-quotations": "^4.0.0",
49
+ "@unchainedshop/core-users": "^4.0.0",
50
+ "@unchainedshop/core-warehousing": "^4.0.0",
51
+ "@unchainedshop/core-worker": "^4.0.0",
52
+ "@unchainedshop/logger": "^4.0.0",
53
+ "@unchainedshop/utils": "^4.0.0",
54
+ "minipass-json-stream": "^1.0.2"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@types/breejs__later": "^4.1.5",
@@ -0,0 +1,205 @@
1
+ import { z } from 'zod';
2
+ import JSONStream from 'minipass-json-stream';
3
+ import { PassThrough, Readable } from 'node:stream';
4
+ import { pipeline } from 'node:stream/promises';
5
+ import { mongodb } from '@unchainedshop/mongodb';
6
+ import * as AssortmentHandlers from './handlers/assortment/index.js';
7
+ import * as FilterHandlers from './handlers/filter/index.js';
8
+ import * as ProductHandlers from './handlers/product/index.js';
9
+ import { createLogger } from '@unchainedshop/logger';
10
+ import { Modules } from '../modules.js';
11
+ import { Services } from '../services/index.js';
12
+
13
+ const logger = createLogger('unchained:bulk-import');
14
+
15
+ export interface BulkImportOperationResult {
16
+ entity: string;
17
+ operation: string;
18
+ success: boolean;
19
+ }
20
+ export type BulkImportOperation<T> = { payloadSchema?: z.AnyZodObject } & ((
21
+ payload: any,
22
+ options: {
23
+ bulk: (collection: string) => typeof mongodb.BulkOperationBase;
24
+ createShouldUpsertIfIDExists?: boolean;
25
+ updateShouldUpsertIfIDNotExists?: boolean;
26
+ skipCacheInvalidation?: boolean;
27
+ },
28
+ unchainedAPI: T,
29
+ ) => Promise<BulkImportOperationResult>);
30
+
31
+ export type BulkImportHandler<T> = Record<string, BulkImportOperation<T>>;
32
+
33
+ let bulkOperationHandlers: Record<string, BulkImportHandler<any>> = {};
34
+
35
+ export const getOperation = (entity: string, operation: string): BulkImportOperation<any> => {
36
+ if (
37
+ entity === '__PROTO__' ||
38
+ entity === 'CONSTRUCTOR' ||
39
+ entity === 'PROTOTYPE' ||
40
+ operation === '__PROTO__' ||
41
+ operation === 'CONSTRUCTOR' ||
42
+ operation === 'PROTOTYPE'
43
+ ) {
44
+ throw new Error(`Dude!`);
45
+ }
46
+ const handlers = bulkOperationHandlers[entity];
47
+ if (!handlers) {
48
+ throw new Error(`Entity unknown`);
49
+ }
50
+
51
+ const entityOperation = handlers[operation] as BulkImportOperation<any>;
52
+
53
+ if (!entityOperation || typeof entityOperation !== 'function') {
54
+ throw new Error(`Operation unknown/invalid`);
55
+ }
56
+
57
+ return entityOperation;
58
+ };
59
+
60
+ export default function createBulkImporterFactory(db, bulkImporterOptions: any) {
61
+ bulkOperationHandlers = {
62
+ ASSORTMENT: AssortmentHandlers,
63
+ PRODUCT: ProductHandlers,
64
+ FILTER: FilterHandlers,
65
+ ...(bulkImporterOptions?.handlers || {}),
66
+ };
67
+
68
+ const createBulkImporter = (options) => {
69
+ const bulkOperations = {};
70
+ const preparationIssues: {
71
+ operation: string;
72
+ entity: string;
73
+ payloadId: string;
74
+ errorCode: string;
75
+ errorMessage: string;
76
+ }[] = [];
77
+ const processedOperations = {};
78
+ const { createShouldUpsertIfIDExists, skipCacheInvalidation, updateShouldUpsertIfIDNotExists } =
79
+ options;
80
+
81
+ const bulk = (collectionName: string) => {
82
+ const Collection = db.collection(collectionName);
83
+ if (!bulkOperations[collectionName])
84
+ bulkOperations[collectionName] = Collection.initializeOrderedBulkOp();
85
+ return bulkOperations[collectionName];
86
+ };
87
+
88
+ logger.debug(
89
+ `Configure event import with options: createShouldUpsertIfIDExists=${createShouldUpsertIfIDExists} updateShouldUpsertIfIDNotExists=${updateShouldUpsertIfIDNotExists} skipCacheInvalidation=${skipCacheInvalidation}`,
90
+ );
91
+
92
+ return {
93
+ validate: async (event) => {
94
+ const entity = event.entity.toUpperCase();
95
+ const operation = event.operation.toLowerCase();
96
+ logger.debug(`🩺 ${entity}.${operation}.${event.payload?._id || '*'}`);
97
+ try {
98
+ const fn = getOperation(entity, operation);
99
+ if (fn.payloadSchema) {
100
+ fn.payloadSchema.parse(event.payload);
101
+ }
102
+ } catch (e) {
103
+ throw new Error(`🤧 ${entity}.${operation}.${event.payload?._id || '*'} (${e.message})`);
104
+ }
105
+ },
106
+ prepare: async (event, unchainedAPI: { modules: Modules; services: Services }) => {
107
+ const entity = event.entity.toUpperCase();
108
+ const operation = event.operation.toLowerCase();
109
+
110
+ const handler = getOperation(entity, operation);
111
+
112
+ const payloadId = event.payload?._id || 'global';
113
+
114
+ logger.debug(`🏃‍♂️ ${entity}.${operation}.${payloadId}`);
115
+
116
+ try {
117
+ await handler(event.payload, { bulk, logger, ...options }, unchainedAPI);
118
+ if (!processedOperations[entity]) processedOperations[entity] = {};
119
+ if (!processedOperations[entity][operation]) processedOperations[entity][operation] = [];
120
+ processedOperations[entity][operation].push(payloadId);
121
+ logger.debug(`👍 ${entity}.${operation}.${payloadId}`);
122
+ } catch (e) {
123
+ logger.debug(`💥 ${entity}.${operation}.${payloadId} (${e.message})`);
124
+ preparationIssues.push({
125
+ operation,
126
+ entity,
127
+ payloadId,
128
+ errorCode: e.name,
129
+ errorMessage: e.message,
130
+ });
131
+ } finally {
132
+ logger.debug(`🏁 ${entity}.${operation}.${payloadId}`);
133
+ }
134
+ },
135
+ execute: async () => {
136
+ logger.debug(`🍔 ${Object.keys(bulkOperations).join(', ')}`);
137
+ const processedBulkOperations = await Promise.allSettled(
138
+ Object.values(bulkOperations).map(async (o: any) => o.execute()),
139
+ );
140
+ const operationResults = {
141
+ processedOperations,
142
+ processedBulkOperations,
143
+ };
144
+ if (preparationIssues?.length) {
145
+ logger.warn(
146
+ `${preparationIssues.length} issues occured while preparing events, import finished with errors`,
147
+ );
148
+ const errors = { preparationIssues };
149
+ return [operationResults, errors];
150
+ }
151
+ return [operationResults, null];
152
+ },
153
+ invalidateCaches: async (unchainedAPI: { modules: Modules; services: Services }) => {
154
+ if (skipCacheInvalidation) return;
155
+ await unchainedAPI.modules.assortments.invalidateCache({}, { skipUpstreamTraversal: true });
156
+ await unchainedAPI.services.filters.invalidateFilterCache();
157
+ },
158
+ };
159
+ };
160
+
161
+ const validateEventStream = async (readStream: Readable) => {
162
+ const bulkImporter = createBulkImporter({});
163
+ await pipeline(
164
+ readStream,
165
+ JSONStream.parse('events.*'),
166
+ async function* (source: AsyncIterable<any>, { signal }) {
167
+ for await (const event of source) {
168
+ if (signal.aborted) break;
169
+ await bulkImporter.validate(event);
170
+ }
171
+ yield true;
172
+ },
173
+ );
174
+ };
175
+
176
+ const pipeEventStream = async (
177
+ readStream: Readable,
178
+ bulkImporter: ReturnType<typeof createBulkImporter>,
179
+ unchainedAPI: { modules: Modules; services: Services },
180
+ ) => {
181
+ await pipeline(
182
+ readStream,
183
+ new PassThrough({
184
+ highWaterMark: 100,
185
+ }),
186
+ JSONStream.parse('events.*'),
187
+ async function* (source) {
188
+ for await (const event of source) {
189
+ await bulkImporter.prepare(event, unchainedAPI);
190
+ }
191
+ yield true;
192
+ },
193
+ );
194
+ };
195
+
196
+ return {
197
+ createBulkImporter,
198
+ validateEventStream,
199
+ pipeEventStream,
200
+ };
201
+ }
202
+
203
+ export type BulkImporter = ReturnType<typeof createBulkImporterFactory>;
204
+
205
+ export { AssortmentHandlers, ProductHandlers, FilterHandlers };
@@ -0,0 +1,118 @@
1
+ import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
2
+ import upsertAssortmentChildren, { AssortmentLinkSchema } from './upsertAssortmentChildren.js';
3
+ import upsertAssortmentFilters, { AssortmentFilterSchema } from './upsertAssortmentFilters.js';
4
+ import upsertAssortmentProducts, { AssortmentProductSchema } from './upsertAssortmentProducts.js';
5
+ import upsertMedia, { MediaSchema } from './upsertMedia.js';
6
+ import { Modules } from '../../../modules.js';
7
+ import { Services } from '../../../services/index.js';
8
+ import { z } from 'zod';
9
+
10
+ export const AssortmentCreatePayloadSchema = z.object({
11
+ _id: z.string(),
12
+ specification: z.object({
13
+ isActive: z.boolean(),
14
+ isBase: z.boolean().optional(),
15
+ isRoot: z.boolean().optional(),
16
+ sequence: z.number(),
17
+ tags: z.array(z.string()).optional(),
18
+ meta: z.record(z.unknown()).optional(),
19
+ content: z
20
+ .record(
21
+ z.string(), // locale
22
+ z.object({
23
+ title: z.string().optional(),
24
+ subtitle: z.string().optional(),
25
+ slug: z.string().optional(),
26
+ }),
27
+ )
28
+ .optional(),
29
+ }),
30
+ media: z.array(MediaSchema).optional(),
31
+ products: z.array(AssortmentProductSchema).optional(),
32
+ children: z.array(AssortmentLinkSchema).optional(),
33
+ filters: z.array(AssortmentFilterSchema).optional(),
34
+ });
35
+
36
+ export default async function createAssortment(
37
+ payload: z.infer<typeof AssortmentCreatePayloadSchema>,
38
+ { logger, createShouldUpsertIfIDExists },
39
+ unchainedAPI: { modules: Modules; services: Services },
40
+ ) {
41
+ const { modules } = unchainedAPI;
42
+ const { media, specification, products, children, filters, _id } = payload;
43
+ if (!specification) throw new Error(`Specification is required when creating new assortment ${_id}`);
44
+
45
+ if (!specification.content)
46
+ throw new Error(`Assortment content is required when creating new assortment${_id}`);
47
+
48
+ if (specification.tags) {
49
+ specification.tags = convertTagsToLowerCase(specification.tags)!;
50
+ }
51
+
52
+ logger.debug('create assortment object', specification);
53
+ try {
54
+ await modules.assortments.create({ ...specification, _id } as any);
55
+ } catch (e) {
56
+ if (!createShouldUpsertIfIDExists) throw e;
57
+ logger.debug('entity already exists, falling back to update', specification);
58
+ await modules.assortments.update(_id, {
59
+ ...specification,
60
+ });
61
+ }
62
+
63
+ if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
64
+ throw new Error(`Can't create assortment ${_id}, fields missing?`);
65
+ }
66
+
67
+ if (specification.content) {
68
+ logger.debug('create localized content for assortment', specification.content);
69
+ await modules.assortments.texts.updateTexts(
70
+ _id,
71
+ Object.entries(specification.content).map(([locale, localizedData]: [string, any]) => {
72
+ return {
73
+ locale,
74
+ ...localizedData,
75
+ };
76
+ }),
77
+ );
78
+ }
79
+
80
+ logger.debug('create assortment products', products);
81
+ await upsertAssortmentProducts(
82
+ {
83
+ products: products || [],
84
+ assortmentId: _id,
85
+ },
86
+ unchainedAPI,
87
+ );
88
+
89
+ logger.debug('create assortment children', children);
90
+ await upsertAssortmentChildren(
91
+ {
92
+ children: children || [],
93
+ assortmentId: _id,
94
+ },
95
+ unchainedAPI,
96
+ );
97
+
98
+ logger.debug('create assortment filters', filters);
99
+ await upsertAssortmentFilters(
100
+ {
101
+ filters: filters || [],
102
+ assortmentId: _id,
103
+ },
104
+ unchainedAPI,
105
+ );
106
+
107
+ logger.debug('create assortment media', media);
108
+ await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
109
+
110
+ return {
111
+ entity: 'ASSORTMENT',
112
+ operation: 'create',
113
+ _id,
114
+ success: true,
115
+ };
116
+ }
117
+
118
+ createAssortment.payloadSchema = AssortmentCreatePayloadSchema;
@@ -0,0 +1,3 @@
1
+ export { default as create } from './create.js';
2
+ export { default as update } from './update.js';
3
+ export { default as remove } from './remove.js';
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { Modules } from '../../../modules.js';
3
+
4
+ export const AssortmentRemovePayloadSchema = z.object({
5
+ _id: z.string(),
6
+ });
7
+
8
+ export default async function removeAssortment(
9
+ payload: z.infer<typeof AssortmentRemovePayloadSchema>,
10
+ { logger },
11
+ unchainedAPI: { modules: Modules },
12
+ ) {
13
+ const { modules } = unchainedAPI;
14
+ const { _id } = payload;
15
+ logger.debug('remove assortment');
16
+ const deletedAssortment = await modules.assortments.delete(_id, { skipInvalidation: true });
17
+
18
+ return {
19
+ entity: 'ASSORTMENT',
20
+ operation: 'remove',
21
+ _id,
22
+ success: Boolean(deletedAssortment),
23
+ };
24
+ }
25
+
26
+ removeAssortment.payloadSchema = AssortmentRemovePayloadSchema;
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ import upsertAssortmentProducts, { AssortmentProductSchema } from './upsertAssortmentProducts.js';
3
+ import upsertAssortmentChildren, { AssortmentLinkSchema } from './upsertAssortmentChildren.js';
4
+ import upsertAssortmentFilters, { AssortmentFilterSchema } from './upsertAssortmentFilters.js';
5
+ import upsertMedia, { MediaSchema } from './upsertMedia.js';
6
+ import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
7
+ import createAssortment, { AssortmentCreatePayloadSchema } from './create.js';
8
+ import { Modules } from '../../../modules.js';
9
+ import { Services } from '../../../services/index.js';
10
+
11
+ export const AssortmentUpdatePayloadSchema = z.object({
12
+ _id: z.string(),
13
+ specification: z
14
+ .object({
15
+ isActive: z.boolean().optional(),
16
+ isBase: z.boolean().optional(),
17
+ isRoot: z.boolean().optional(),
18
+ sequence: z.number().optional(),
19
+ tags: z.array(z.string()).optional(),
20
+ meta: z.record(z.unknown()).optional(),
21
+ content: z
22
+ .record(
23
+ z.string(), // locale
24
+ z.object({
25
+ title: z.string().optional(),
26
+ subtitle: z.string().optional(),
27
+ slug: z.string().optional(),
28
+ }),
29
+ )
30
+ .optional(),
31
+ })
32
+ .optional(),
33
+ media: z.array(MediaSchema).optional(),
34
+ products: z.array(AssortmentProductSchema).optional(),
35
+ children: z.array(AssortmentLinkSchema).optional(),
36
+ filters: z.array(AssortmentFilterSchema).optional(),
37
+ });
38
+
39
+ export default async function updateAssortment(
40
+ payload: z.infer<typeof AssortmentUpdatePayloadSchema>,
41
+ { logger, createShouldUpsertIfIDExists, updateShouldUpsertIfIDNotExists },
42
+ unchainedAPI: { modules: Modules; services: Services },
43
+ ) {
44
+ const { modules } = unchainedAPI;
45
+ const { media, specification, products, children, filters, _id } = payload;
46
+
47
+ if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
48
+ if (updateShouldUpsertIfIDNotExists && specification) {
49
+ return createAssortment(
50
+ {
51
+ _id,
52
+ specification,
53
+ media,
54
+ products,
55
+ children,
56
+ filters,
57
+ } as z.infer<typeof AssortmentCreatePayloadSchema>,
58
+ { logger, createShouldUpsertIfIDExists },
59
+ unchainedAPI,
60
+ );
61
+ }
62
+ throw new Error(`Can't update non-existing assortment ${_id}`);
63
+ }
64
+
65
+ if (specification) {
66
+ logger.debug('update assortment object', specification);
67
+
68
+ if (specification.tags) {
69
+ specification.tags = convertTagsToLowerCase(specification.tags!)!;
70
+ }
71
+
72
+ await unchainedAPI.modules.assortments.update(_id, { ...specification });
73
+
74
+ if (specification.content) {
75
+ logger.debug('replace localized content for assortment', specification.content);
76
+ await modules.assortments.texts.updateTexts(
77
+ _id,
78
+ Object.entries(specification.content).map(([locale, localizedData]: [string, any]) => {
79
+ return {
80
+ locale,
81
+ ...localizedData,
82
+ };
83
+ }),
84
+ );
85
+ }
86
+ }
87
+
88
+ if (products) {
89
+ logger.debug('update product products', products);
90
+ await upsertAssortmentProducts(
91
+ {
92
+ products: products || [],
93
+ assortmentId: _id,
94
+ },
95
+ unchainedAPI,
96
+ );
97
+ }
98
+
99
+ if (children) {
100
+ logger.debug('update assortment children', children);
101
+ await upsertAssortmentChildren(
102
+ {
103
+ children: children || [],
104
+ assortmentId: _id,
105
+ },
106
+ unchainedAPI,
107
+ );
108
+ }
109
+
110
+ if (filters) {
111
+ logger.debug('update assortment filters', filters);
112
+ await upsertAssortmentFilters(
113
+ {
114
+ filters: filters || [],
115
+ assortmentId: _id,
116
+ },
117
+ unchainedAPI,
118
+ );
119
+ }
120
+ if (media) {
121
+ logger.debug('update assortment media', media);
122
+ await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
123
+ }
124
+
125
+ return {
126
+ entity: 'ASSORTMENT',
127
+ operation: 'update',
128
+ _id,
129
+ success: true,
130
+ };
131
+ }
132
+
133
+ updateAssortment.payloadSchema = AssortmentUpdatePayloadSchema;