@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
@@ -2,7 +2,7 @@ import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
2
2
  import { createLogger } from '@unchainedshop/logger';
3
3
  import { PaymentError, IPaymentActions, IPaymentAdapter, PaymentContext } from './PaymentAdapter.js';
4
4
  import { PaymentProvider } from '@unchainedshop/core-payment';
5
- import { OrderPayment, OrderPaymentStatus } from '@unchainedshop/core-orders';
5
+ import { Order, OrderPayment, OrderPaymentStatus } from '@unchainedshop/core-orders';
6
6
 
7
7
  const buildPaymentProviderActionsContext = (
8
8
  orderPayment: OrderPayment,
@@ -19,7 +19,7 @@ const buildPaymentProviderActionsContext = (
19
19
 
20
20
  export type IPaymentDirector = IBaseDirector<IPaymentAdapter> & {
21
21
  confirmOrderPayment: (
22
- orderPayment: OrderPayment,
22
+ order: Order,
23
23
  paymentContext: {
24
24
  transactionContext: any;
25
25
  userId: string;
@@ -28,7 +28,7 @@ export type IPaymentDirector = IBaseDirector<IPaymentAdapter> & {
28
28
  ) => Promise<OrderPayment>;
29
29
 
30
30
  cancelOrderPayment: (
31
- orderPayment: OrderPayment,
31
+ order: Order,
32
32
  paymentContext: {
33
33
  transactionContext: any;
34
34
  userId: string;
@@ -37,7 +37,7 @@ export type IPaymentDirector = IBaseDirector<IPaymentAdapter> & {
37
37
  ) => Promise<OrderPayment>;
38
38
 
39
39
  chargeOrderPayment: (
40
- orderPayment: OrderPayment,
40
+ order: Order,
41
41
  context: {
42
42
  transactionContext: any;
43
43
  userId: string;
@@ -51,7 +51,7 @@ export type IPaymentDirector = IBaseDirector<IPaymentAdapter> & {
51
51
  unchainedAPI,
52
52
  ) => Promise<IPaymentActions>;
53
53
  };
54
- const logger = createLogger('unchained:core-payment');
54
+ const logger = createLogger('unchained:core:payment');
55
55
  const baseDirector = BaseDirector<IPaymentAdapter>('PaymentDirector');
56
56
 
57
57
  export const PaymentDirector: IPaymentDirector = {
@@ -101,7 +101,7 @@ export const PaymentDirector: IPaymentDirector = {
101
101
  try {
102
102
  return adapter.isActive(paymentContext.transactionContext);
103
103
  } catch (error) {
104
- logger.error(error.message);
104
+ logger.error(error);
105
105
  return false;
106
106
  }
107
107
  },
@@ -110,7 +110,7 @@ export const PaymentDirector: IPaymentDirector = {
110
110
  try {
111
111
  return adapter.isPayLaterAllowed(paymentContext.transactionContext);
112
112
  } catch (error) {
113
- logger.error(error.message);
113
+ logger.error(error);
114
114
  return false;
115
115
  }
116
116
  },
@@ -143,7 +143,7 @@ export const PaymentDirector: IPaymentDirector = {
143
143
  },
144
144
 
145
145
  confirmOrderPayment: async (
146
- orderPayment: OrderPayment,
146
+ order: Order,
147
147
  paymentContext: {
148
148
  transactionContext: any;
149
149
  userId: string;
@@ -152,6 +152,14 @@ export const PaymentDirector: IPaymentDirector = {
152
152
  ): Promise<OrderPayment> => {
153
153
  const { modules } = unchainedAPI;
154
154
 
155
+ const orderPayment =
156
+ order.paymentId &&
157
+ (await modules.orders.payments.findOrderPayment({
158
+ orderPaymentId: order.paymentId,
159
+ }));
160
+
161
+ if (!orderPayment) throw new Error('Order payment not set');
162
+
155
163
  if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.PAID) {
156
164
  return orderPayment;
157
165
  }
@@ -178,7 +186,7 @@ export const PaymentDirector: IPaymentDirector = {
178
186
  },
179
187
 
180
188
  cancelOrderPayment: async (
181
- orderPayment: OrderPayment,
189
+ order: Order,
182
190
  paymentContext: {
183
191
  transactionContext: any;
184
192
  userId: string;
@@ -187,6 +195,14 @@ export const PaymentDirector: IPaymentDirector = {
187
195
  ): Promise<OrderPayment> => {
188
196
  const { modules } = unchainedAPI;
189
197
 
198
+ const orderPayment =
199
+ order.paymentId &&
200
+ (await modules.orders.payments.findOrderPayment({
201
+ orderPaymentId: order.paymentId,
202
+ }));
203
+
204
+ if (!orderPayment) throw new Error('Order payment not set');
205
+
190
206
  if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.PAID) {
191
207
  return orderPayment;
192
208
  }
@@ -212,7 +228,7 @@ export const PaymentDirector: IPaymentDirector = {
212
228
  },
213
229
 
214
230
  chargeOrderPayment: async (
215
- orderPayment: OrderPayment,
231
+ order: Order,
216
232
  context: {
217
233
  transactionContext: any;
218
234
  userId: string;
@@ -221,6 +237,14 @@ export const PaymentDirector: IPaymentDirector = {
221
237
  ): Promise<OrderPayment> => {
222
238
  const { modules } = unchainedAPI;
223
239
 
240
+ const orderPayment =
241
+ order.paymentId &&
242
+ (await modules.orders.payments.findOrderPayment({
243
+ orderPaymentId: order.paymentId,
244
+ }));
245
+
246
+ if (!orderPayment) throw new Error('Order payment not set');
247
+
224
248
  if (modules.orders.payments.normalizedStatus(orderPayment) !== OrderPaymentStatus.OPEN) {
225
249
  return orderPayment;
226
250
  }
@@ -20,8 +20,8 @@ export interface PaymentPricingCalculation extends PricingCalculation {
20
20
  export interface PaymentPricingAdapterContext extends BasePricingAdapterContext {
21
21
  countryCode?: string;
22
22
  currency?: string;
23
- user: User;
24
- orderPayment: OrderPayment;
23
+ user: User | null;
24
+ orderPayment?: OrderPayment;
25
25
  order: Order;
26
26
  provider: PaymentProvider;
27
27
  discounts: OrderDiscount[];
@@ -15,7 +15,7 @@ export type PaymentPricingContext =
15
15
  | {
16
16
  countryCode?: string;
17
17
  currencyCode?: string;
18
- user: User;
18
+ user?: User;
19
19
  order: Order;
20
20
  provider: PaymentProvider;
21
21
  providerContext?: any;
@@ -54,21 +54,20 @@ export const PaymentPricingDirector: IPaymentPricingDirector<any> = {
54
54
  const provider = await modules.payment.paymentProviders.findProvider({
55
55
  paymentProviderId: item.paymentProviderId,
56
56
  });
57
- const user = await modules.users.findUserById(order.userId);
57
+ const user = await modules.users.findUserById(order!.userId);
58
58
  const discounts = await modules.orders.discounts.findOrderDiscounts({
59
59
  orderId: item.orderId,
60
60
  });
61
61
 
62
62
  return {
63
63
  ...unchainedAPI,
64
- countryCode: order.countryCode,
64
+ countryCode: order!.countryCode,
65
65
  currencyCode,
66
- order,
67
- provider,
66
+ order: order!,
67
+ provider: provider!,
68
68
  user,
69
69
  discounts,
70
70
  orderPayment: item,
71
- providerContext: null,
72
71
  };
73
72
  }
74
73
 
@@ -78,9 +77,8 @@ export const PaymentPricingDirector: IPaymentPricingDirector<any> = {
78
77
  currencyCode: context.currencyCode,
79
78
  order: context.order,
80
79
  provider: context.provider,
81
- user: context.user,
80
+ user: context.user || null,
82
81
  discounts: [],
83
- orderPayment: null,
84
82
  providerContext: context.providerContext,
85
83
  };
86
84
  },
@@ -66,7 +66,8 @@ export const PaymentPricingSheet = (
66
66
  category: PaymentPricingRowCategory.Discount,
67
67
  discountId: explicitDiscountId,
68
68
  })
69
- .map(({ discountId }) => discountId);
69
+ .map(({ discountId }) => discountId)
70
+ .filter(Boolean) as string[];
70
71
 
71
72
  return [...new Set(discountIds)]
72
73
  .map((discountId) => {
@@ -83,7 +84,7 @@ export const PaymentPricingSheet = (
83
84
  currencyCode: basePricingSheet.currencyCode,
84
85
  };
85
86
  })
86
- .filter(Boolean);
87
+ .filter(Boolean) as { discountId: string; amount: number; currencyCode: string }[];
87
88
  },
88
89
  };
89
90
 
@@ -4,7 +4,7 @@ import {
4
4
  ProductDiscountConfiguration,
5
5
  } from '../directors/index.js';
6
6
 
7
- export const ProductDiscountAdapter: Omit<
7
+ export const ProductDiscountAdapter = BaseDiscountAdapter as Omit<
8
8
  IDiscountAdapter<ProductDiscountConfiguration>,
9
9
  'key' | 'label' | 'version'
10
- > = BaseDiscountAdapter;
10
+ >;
@@ -10,7 +10,7 @@ type ResolvedConfiguration = {
10
10
  export type PriceConfigurationResolver = (
11
11
  product: Product,
12
12
  quantity: number,
13
- configuration: ProductConfiguration[],
13
+ configuration?: ProductConfiguration[],
14
14
  ) => ResolvedConfiguration | null;
15
15
 
16
16
  export interface ProductDiscountConfiguration extends ResolvedConfiguration {
@@ -16,7 +16,7 @@ export interface ProductPricingAdapterContext extends BasePricingAdapterContext
16
16
  currencyCode: string;
17
17
  product: Product;
18
18
  quantity: number;
19
- configuration: ProductConfiguration[];
19
+ configuration?: ProductConfiguration[];
20
20
  order?: Order;
21
21
  user?: User;
22
22
  }
@@ -16,9 +16,9 @@ export type ProductPricingContext =
16
16
  currencyCode: string;
17
17
  countryCode: string;
18
18
  quantity: number;
19
- discounts?: OrderDiscount[];
19
+ discounts: OrderDiscount[];
20
20
  order?: Order;
21
- product?: Product;
21
+ product: Product;
22
22
  configuration?: ProductConfiguration[];
23
23
  user?: User;
24
24
  }
@@ -59,21 +59,21 @@ export const ProductPricingDirector: IProductPricingDirector<any> = {
59
59
  const order = await modules.orders.findOrder({
60
60
  orderId: item.orderId,
61
61
  });
62
- const user = await modules.users.findUserById(order.userId);
62
+ const user = await modules.users.findUserById(order!.userId);
63
63
  const discounts = await modules.orders.discounts.findOrderDiscounts({
64
64
  orderId: item.orderId,
65
65
  });
66
66
 
67
67
  return {
68
68
  ...unchainedAPI,
69
- countryCode: order.countryCode,
69
+ countryCode: order!.countryCode,
70
70
  currencyCode,
71
71
  discounts,
72
- order,
73
- product,
72
+ order: order!,
73
+ product: product!,
74
74
  quantity,
75
75
  configuration: item.configuration,
76
- user,
76
+ user: user!,
77
77
  };
78
78
  }
79
79
 
@@ -33,7 +33,7 @@ export interface IProductPricingSheet extends IPricingSheet<ProductPricingCalcul
33
33
  meta?: any;
34
34
  }) => void;
35
35
 
36
- unitPrice: (params?: { useNetPrice: boolean }) => Price;
36
+ unitPrice: (params: { useNetPrice?: boolean }) => Price;
37
37
  }
38
38
 
39
39
  export const ProductPricingSheet = (
@@ -99,7 +99,8 @@ export const ProductPricingSheet = (
99
99
  category: ProductPricingRowCategory.Discount,
100
100
  discountId: explicitDiscountId,
101
101
  })
102
- .map(({ discountId }) => discountId);
102
+ .map(({ discountId }) => discountId)
103
+ .filter(Boolean) as string[];
103
104
 
104
105
  return [...new Set(discountIds)]
105
106
  .map((discountId) => {
@@ -116,7 +117,7 @@ export const ProductPricingSheet = (
116
117
  currencyCode: basePricingSheet.currencyCode,
117
118
  };
118
119
  })
119
- .filter(Boolean);
120
+ .filter(Boolean) as { discountId: string; amount: number; currencyCode: string }[];
120
121
  },
121
122
  };
122
123
 
@@ -10,7 +10,7 @@ export interface QuotationContext {
10
10
  }
11
11
 
12
12
  export interface QuotationAdapterActions {
13
- configurationError: () => QuotationError;
13
+ configurationError: () => QuotationError | null;
14
14
  isManualProposalRequired: () => Promise<boolean>;
15
15
  isManualRequestVerificationRequired: () => Promise<boolean>;
16
16
  quote: () => Promise<QuotationProposal>;
@@ -20,7 +20,7 @@ export interface QuotationAdapterActions {
20
20
 
21
21
  transformItemConfiguration: (
22
22
  params: QuotationItemConfiguration,
23
- ) => Promise<QuotationItemConfiguration>;
23
+ ) => Promise<QuotationItemConfiguration | null>;
24
24
  }
25
25
 
26
26
  export type IQuotationAdapter = IBaseAdapter & {
@@ -65,7 +65,7 @@ export const QuotationDirector: IQuotationDirector = {
65
65
  ...error,
66
66
  },
67
67
  );
68
- return null;
68
+ return true;
69
69
  }
70
70
  },
71
71
 
@@ -77,7 +77,7 @@ export const QuotationDirector: IQuotationDirector = {
77
77
  logger.error('QuotationDirector -> Error while checking if is manual proposal required', {
78
78
  ...error,
79
79
  });
80
- return null;
80
+ return true;
81
81
  }
82
82
  },
83
83
 
@@ -16,14 +16,14 @@ export enum WarehousingError {
16
16
  }
17
17
 
18
18
  export interface WarehousingAdapterActions {
19
- configurationError: () => WarehousingError;
19
+ configurationError: () => WarehousingError | null;
20
20
  isActive: () => boolean;
21
21
  stock: (referenceDate: Date) => Promise<number>;
22
22
  productionTime: (quantityToProduce: number) => Promise<number>;
23
23
  commissioningTime: (quantity: number) => Promise<number>;
24
24
  tokenize: () => Promise<Omit<TokenSurrogate, 'userId' | 'productId' | 'orderPositionId'>[]>;
25
- tokenMetadata: (chainTokenId: string, referenceDate: Date) => Promise<any>;
26
- isInvalidateable: (chainTokenId: string, referenceDate: Date) => Promise<boolean>;
25
+ tokenMetadata: (tokenSerialNumber: string, referenceDate: Date) => Promise<any>;
26
+ isInvalidateable: (tokenSerialNumber: string, referenceDate: Date) => Promise<boolean>;
27
27
  }
28
28
 
29
29
  export interface WarehousingContext {
@@ -34,7 +34,6 @@ export interface WarehousingContext {
34
34
  referenceDate?: Date;
35
35
  locale?: Intl.Locale;
36
36
  order?: Order;
37
- warehousingProviderId?: string;
38
37
  orderPosition?: OrderPosition;
39
38
  }
40
39
 
@@ -28,13 +28,13 @@ export interface WarehousingInterface {
28
28
  export type IWarehousingDirector = IBaseDirector<IWarehousingAdapter> & {
29
29
  tokenMetadata: (
30
30
  virtualProviders: WarehousingProvider[],
31
- warehousingContext: WarehousingContext & { token: { chainTokenId: string } },
31
+ warehousingContext: WarehousingContext & { token: { tokenSerialNumber: string } },
32
32
  unchainedAPI,
33
33
  ) => Promise<any>;
34
34
 
35
35
  isInvalidateable: (
36
36
  virtualProviders: WarehousingProvider[],
37
- warehousingContext: WarehousingContext & { token: { chainTokenId: string } },
37
+ warehousingContext: WarehousingContext & { token: { tokenSerialNumber: string } },
38
38
  unchainedAPI,
39
39
  ) => Promise<any>;
40
40
 
@@ -43,13 +43,13 @@ export type IWarehousingDirector = IBaseDirector<IWarehousingAdapter> & {
43
43
  warehousingContext: WarehousingContext,
44
44
  unchainedAPI: { modules: Modules },
45
45
  ) => Promise<{
46
- configurationError: () => WarehousingError;
46
+ configurationError: () => WarehousingError | null;
47
47
  isActive: () => boolean;
48
48
  estimatedStock: () => Promise<EstimatedStock>;
49
49
  estimatedDispatch: () => Promise<EstimatedDispatch>;
50
50
  tokenize: () => Promise<TokenSurrogate[]>;
51
- tokenMetadata: (chainTokenId: string) => Promise<any>;
52
- isInvalidateable: (chainTokenId: string) => Promise<boolean>;
51
+ tokenMetadata: (tokenSerialNumber: string) => Promise<any>;
52
+ isInvalidateable: (tokenSerialNumber: string) => Promise<boolean>;
53
53
  }>;
54
54
  };
55
55
 
@@ -81,9 +81,9 @@ export const WarehousingDirector: IWarehousingDirector = {
81
81
  try {
82
82
  const { quantity } = context;
83
83
  const stock = await adapter.stock(referenceDate);
84
- const notInStockQuantity = Math.max(quantity - stock, 0);
84
+ const notInStockQuantity = Math.max((quantity || 1) - stock, 0);
85
85
  const productionTime = await adapter.productionTime(notInStockQuantity);
86
- const commissioningTime = await adapter.commissioningTime(quantity);
86
+ const commissioningTime = await adapter.commissioningTime(quantity || 1);
87
87
  return Math.max(commissioningTime + productionTime, 0);
88
88
  } catch (error) {
89
89
  logger.error(error);
@@ -130,10 +130,7 @@ export const WarehousingDirector: IWarehousingDirector = {
130
130
 
131
131
  const warehousingThroughputTime = await throughputTime(referenceDate);
132
132
  if (!Number.isFinite(warehousingThroughputTime)) {
133
- return {
134
- shipping: null,
135
- earliestDelivery: null,
136
- };
133
+ return {};
137
134
  }
138
135
 
139
136
  // Calculate shipping date
@@ -141,12 +138,12 @@ export const WarehousingDirector: IWarehousingDirector = {
141
138
  const shipping = new Date(shippingTimestamp);
142
139
 
143
140
  // Calculate earliest delivery date
144
- const actions = await DeliveryDirector.actions(deliveryProvider, context, unchainedAPI);
141
+ const actions = await DeliveryDirector.actions(deliveryProvider!, context, unchainedAPI);
145
142
  const deliveryThroughputTime =
146
143
  await actions.estimatedDeliveryThroughput(warehousingThroughputTime);
147
144
  const earliestDelivery = Number.isFinite(deliveryThroughputTime)
148
- ? new Date(shippingTimestamp + deliveryThroughputTime)
149
- : null;
145
+ ? new Date(shippingTimestamp + deliveryThroughputTime!)
146
+ : undefined;
150
147
 
151
148
  return {
152
149
  shipping,
@@ -158,10 +155,10 @@ export const WarehousingDirector: IWarehousingDirector = {
158
155
  }
159
156
  },
160
157
 
161
- tokenMetadata: async (chainTokenId) => {
158
+ tokenMetadata: async (tokenSerialNumber) => {
162
159
  try {
163
160
  const referenceDate = getReferenceDate(context);
164
- const tokenMetadata = await adapter.tokenMetadata(chainTokenId, referenceDate);
161
+ const tokenMetadata = await adapter.tokenMetadata(tokenSerialNumber, referenceDate);
165
162
  return tokenMetadata;
166
163
  } catch (error) {
167
164
  logger.error(error);
@@ -169,10 +166,10 @@ export const WarehousingDirector: IWarehousingDirector = {
169
166
  }
170
167
  },
171
168
 
172
- isInvalidateable: async (chainTokenId) => {
169
+ isInvalidateable: async (tokenSerialNumber) => {
173
170
  try {
174
171
  const referenceDate = getReferenceDate(context);
175
- const isInvalidateable = await adapter.isInvalidateable(chainTokenId, referenceDate);
172
+ const isInvalidateable = await adapter.isInvalidateable(tokenSerialNumber, referenceDate);
176
173
  return isInvalidateable;
177
174
  } catch (error) {
178
175
  logger.error(error);
@@ -187,9 +184,9 @@ export const WarehousingDirector: IWarehousingDirector = {
187
184
  return tokens.map((token) => {
188
185
  return {
189
186
  ...token,
190
- userId: order.userId,
191
- productId: orderPosition.productId,
192
- orderPositionId: orderPosition._id,
187
+ userId: order!.userId,
188
+ productId: orderPosition!.productId,
189
+ orderPositionId: orderPosition!._id,
193
190
  };
194
191
  });
195
192
  } catch (error) {
@@ -211,7 +208,7 @@ export const WarehousingDirector: IWarehousingDirector = {
211
208
  );
212
209
  const isActive = await currentDirector.isActive();
213
210
  if (isActive) {
214
- return currentDirector.tokenMetadata(warehousingContext.token.chainTokenId);
211
+ return currentDirector.tokenMetadata(warehousingContext.token.tokenSerialNumber);
215
212
  }
216
213
  return null;
217
214
  }, Promise.resolve(null));
@@ -228,7 +225,7 @@ export const WarehousingDirector: IWarehousingDirector = {
228
225
  );
229
226
  const isActive = await currentDirector.isActive();
230
227
  if (isActive) {
231
- return currentDirector.isInvalidateable(warehousingContext.token.chainTokenId);
228
+ return currentDirector.isInvalidateable(warehousingContext.token.tokenSerialNumber);
232
229
  }
233
230
  return null;
234
231
  }, Promise.resolve(null));
@@ -1,8 +1,8 @@
1
1
  import { BaseAdapter, IBaseAdapter } from '@unchainedshop/utils';
2
2
  import { WorkResult } from '@unchainedshop/core-worker';
3
- import { Modules } from '../modules.js';
3
+ import { ModuleOptions, Modules } from '../modules.js';
4
4
  import { Services } from '../services/index.js';
5
- import { BulkImporter } from '../core-index.js';
5
+ import { BulkImporter } from '../bulk-importer/index.js';
6
6
 
7
7
  export type IWorkerAdapter<Input, Output> = IBaseAdapter & {
8
8
  type: string;
@@ -11,7 +11,12 @@ export type IWorkerAdapter<Input, Output> = IBaseAdapter & {
11
11
 
12
12
  doWork: (
13
13
  input: Input,
14
- unchainedAPI: { modules: Modules; services: Services; bulkImporter: BulkImporter },
14
+ unchainedAPI: {
15
+ modules: Modules;
16
+ services: Services;
17
+ bulkImporter: BulkImporter;
18
+ options: ModuleOptions;
19
+ },
15
20
  workId: string,
16
21
  ) => Promise<WorkResult<Output>>;
17
22
  };
@@ -21,6 +26,6 @@ export const WorkerAdapter: Omit<IWorkerAdapter<any, void>, 'key' | 'label' | 't
21
26
  external: false,
22
27
 
23
28
  async doWork() {
24
- return { success: false, result: null };
29
+ return { success: false };
25
30
  },
26
31
  };
@@ -13,7 +13,7 @@ export type WorkScheduleConfiguration = Pick<
13
13
  > & {
14
14
  type: string;
15
15
  input?: (workData: Omit<WorkData, 'input'>) => Promise<Record<string, any> | null>;
16
- schedule: ScheduleData;
16
+ schedule?: ScheduleData;
17
17
  scheduleId?: string;
18
18
  };
19
19
 
@@ -24,7 +24,7 @@ export type IWorkerDirector = IBaseDirector<IWorkerAdapter<any, any>> & {
24
24
  configureAutoscheduling: (workScheduleConfiguration: WorkScheduleConfiguration) => void;
25
25
  getAutoSchedules: () => [string, WorkScheduleConfiguration][];
26
26
  doWork: (work: Work, unchainedAPI) => Promise<WorkResult>;
27
- processNextWork: (unchainedAPI: { modules: Modules }, workerId?: string) => Promise<Work>;
27
+ processNextWork: (unchainedAPI: { modules: Modules }, workerId?: string) => Promise<Work | null>;
28
28
  };
29
29
 
30
30
  const AutoScheduleMap = new Map<string, WorkScheduleConfiguration>();
@@ -36,7 +36,7 @@ const baseDirector = BaseDirector<IWorkerAdapter<any, any>>('WorkerDirector', {
36
36
  export const WorkerDirector: IWorkerDirector = {
37
37
  ...baseDirector,
38
38
 
39
- getActivePluginTypes: ({ external } = { external: null }) => {
39
+ getActivePluginTypes: ({ external } = {}) => {
40
40
  return WorkerDirector.getAdapters()
41
41
  .filter((adapter) => {
42
42
  if (external === null || external === undefined) return true;
@@ -55,8 +55,7 @@ export const WorkerDirector: IWorkerDirector = {
55
55
  },
56
56
 
57
57
  disableAutoscheduling: (type) => {
58
- const config = AutoScheduleMap.get(type);
59
- AutoScheduleMap.set(type, { ...config, schedule: null });
58
+ AutoScheduleMap.delete(type);
60
59
  },
61
60
 
62
61
  unregisterAdapter: (key) => {
@@ -110,7 +109,7 @@ export const WorkerDirector: IWorkerDirector = {
110
109
  }
111
110
  },
112
111
 
113
- processNextWork: async (unchainedAPI: { modules: Modules }, workerId?: string): Promise<Work> => {
112
+ processNextWork: async (unchainedAPI: { modules: Modules }, workerId?: string) => {
114
113
  const adapters = WorkerDirector.getAdapters();
115
114
 
116
115
  const allocationMap = await unchainedAPI.modules.worker.allocationMap();
@@ -0,0 +1,3 @@
1
+ import registerProductDiscoverabilityFilter from './registerProductDiscoverabilityFilter.js';
2
+
3
+ export { registerProductDiscoverabilityFilter };
@@ -0,0 +1,36 @@
1
+ import { FilterAdapter, FilterDirector } from '../core-index.js';
2
+
3
+ export default function registerProductDiscoverabilityFilter({
4
+ orderIndex = 0,
5
+ hiddenTagValue = 'hidden',
6
+ }: {
7
+ orderIndex?: number;
8
+ hiddenTagValue?: string;
9
+ }) {
10
+ FilterDirector.registerAdapter({
11
+ ...FilterAdapter,
12
+
13
+ key: `shop.unchained.filters.product-discoverability-${crypto.randomUUID()}`,
14
+ label: 'Product Discoverability Filter',
15
+ version: '1.0.0',
16
+ orderIndex,
17
+
18
+ actions: (params) => {
19
+ return {
20
+ ...FilterAdapter.actions(params),
21
+
22
+ transformProductSelector: async (lastSelector, options) => {
23
+ const { key } = options || {};
24
+
25
+ if (!key) {
26
+ const newSelector = { ...lastSelector };
27
+ if (!newSelector.$and) newSelector.$and = [];
28
+ newSelector.$and.push({ tags: { $ne: hiddenTagValue } });
29
+ return newSelector;
30
+ }
31
+ return lastSelector;
32
+ },
33
+ };
34
+ },
35
+ });
36
+ }
package/src/modules.ts CHANGED
@@ -69,17 +69,17 @@ export interface ModuleOptions {
69
69
  assortments?: AssortmentsSettingsOptions;
70
70
  products?: ProductsSettingsOptions;
71
71
  delivery?: DeliverySettingsOptions;
72
+ payment?: PaymentSettingsOptions;
72
73
  filters?: FiltersSettingsOptions;
73
74
  enrollments?: EnrollmentsSettingsOptions;
74
75
  orders?: OrdersSettingsOptions;
75
76
  quotations?: QuotationsSettingsOptions;
76
77
  files?: FilesSettingsOptions;
77
- payment?: PaymentSettingsOptions;
78
78
  worker?: WorkerSettingsOptions;
79
79
  users?: UserSettingsOptions;
80
80
  }
81
81
 
82
- const initModules = async (
82
+ export default async function initModules(
83
83
  {
84
84
  db,
85
85
  migrationRepository,
@@ -87,7 +87,7 @@ const initModules = async (
87
87
  }: {
88
88
  db: mongodb.Db;
89
89
  migrationRepository: MigrationRepository<unknown>;
90
- options?: ModuleOptions;
90
+ options: ModuleOptions;
91
91
  },
92
92
  customModules: Record<
93
93
  string,
@@ -95,7 +95,7 @@ const initModules = async (
95
95
  configure: (params: ModuleInput<any>) => any;
96
96
  }
97
97
  >,
98
- ): Promise<Modules> => {
98
+ ): Promise<Modules> {
99
99
  const assortments = await configureAssortmentsModule({
100
100
  db,
101
101
  options: options.assortments,
@@ -154,6 +154,7 @@ const initModules = async (
154
154
  const products = await configureProductsModule({
155
155
  db,
156
156
  migrationRepository,
157
+ options: options.products,
157
158
  });
158
159
  const quotations = await configureQuotationsModule({
159
160
  db,
@@ -203,6 +204,4 @@ const initModules = async (
203
204
  }
204
205
 
205
206
  return modules;
206
- };
207
-
208
- export default initModules;
207
+ }