@medusajs/medusa 1.3.4 → 2.0.0-next.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 (502) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +27 -0
  3. package/dist/api/middlewares/await-middleware.js +7 -0
  4. package/dist/api/middlewares/await-middleware.js.map +1 -1
  5. package/dist/api/middlewares/error-handler.d.ts +1 -1
  6. package/dist/api/middlewares/error-handler.js.map +1 -1
  7. package/dist/api/middlewares/transform-query.d.ts +1 -1
  8. package/dist/api/middlewares/transform-query.js +2 -0
  9. package/dist/api/middlewares/transform-query.js.map +1 -1
  10. package/dist/api/middlewares/validators/product-existence.d.ts +3 -0
  11. package/dist/api/middlewares/validators/product-existence.js +86 -0
  12. package/dist/api/middlewares/validators/product-existence.js.map +1 -0
  13. package/dist/api/middlewares/validators/sales-channel-existence.d.ts +3 -0
  14. package/dist/api/middlewares/validators/sales-channel-existence.js +86 -0
  15. package/dist/api/middlewares/validators/sales-channel-existence.js.map +1 -0
  16. package/dist/api/routes/admin/auth/create-session.js +10 -2
  17. package/dist/api/routes/admin/auth/create-session.js.map +1 -1
  18. package/dist/api/routes/admin/batch/cancel-batch-job.js +12 -2
  19. package/dist/api/routes/admin/batch/cancel-batch-job.js.map +1 -1
  20. package/dist/api/routes/admin/batch/confirm-batch-job.js +12 -2
  21. package/dist/api/routes/admin/batch/confirm-batch-job.js.map +1 -1
  22. package/dist/api/routes/admin/batch/create-batch-job.js +10 -2
  23. package/dist/api/routes/admin/batch/create-batch-job.js.map +1 -1
  24. package/dist/api/routes/admin/collections/add-products.js +10 -2
  25. package/dist/api/routes/admin/collections/add-products.js.map +1 -1
  26. package/dist/api/routes/admin/collections/create-collection.js +10 -2
  27. package/dist/api/routes/admin/collections/create-collection.js.map +1 -1
  28. package/dist/api/routes/admin/collections/delete-collection.js +10 -2
  29. package/dist/api/routes/admin/collections/delete-collection.js.map +1 -1
  30. package/dist/api/routes/admin/collections/remove-products.js +10 -2
  31. package/dist/api/routes/admin/collections/remove-products.js.map +1 -1
  32. package/dist/api/routes/admin/collections/update-collection.js +10 -2
  33. package/dist/api/routes/admin/collections/update-collection.js.map +1 -1
  34. package/dist/api/routes/admin/customer-groups/add-customers-batch.js +15 -5
  35. package/dist/api/routes/admin/customer-groups/add-customers-batch.js.map +1 -1
  36. package/dist/api/routes/admin/customer-groups/create-customer-group.js +12 -2
  37. package/dist/api/routes/admin/customer-groups/create-customer-group.js.map +1 -1
  38. package/dist/api/routes/admin/customer-groups/delete-customer-group.js +12 -2
  39. package/dist/api/routes/admin/customer-groups/delete-customer-group.js.map +1 -1
  40. package/dist/api/routes/admin/customer-groups/delete-customers-batch.js +15 -5
  41. package/dist/api/routes/admin/customer-groups/delete-customers-batch.js.map +1 -1
  42. package/dist/api/routes/admin/customer-groups/update-customer-group.js +12 -2
  43. package/dist/api/routes/admin/customer-groups/update-customer-group.js.map +1 -1
  44. package/dist/api/routes/admin/customers/create-customer.js +12 -2
  45. package/dist/api/routes/admin/customers/create-customer.js.map +1 -1
  46. package/dist/api/routes/admin/customers/update-customer.js +12 -2
  47. package/dist/api/routes/admin/customers/update-customer.js.map +1 -1
  48. package/dist/api/routes/admin/discounts/add-region.js +12 -2
  49. package/dist/api/routes/admin/discounts/add-region.js.map +1 -1
  50. package/dist/api/routes/admin/discounts/create-condition.d.ts +1 -1
  51. package/dist/api/routes/admin/discounts/create-condition.js +13 -3
  52. package/dist/api/routes/admin/discounts/create-condition.js.map +1 -1
  53. package/dist/api/routes/admin/discounts/create-discount.d.ts +1 -2
  54. package/dist/api/routes/admin/discounts/create-discount.js +12 -3
  55. package/dist/api/routes/admin/discounts/create-discount.js.map +1 -1
  56. package/dist/api/routes/admin/discounts/create-dynamic-code.js +12 -2
  57. package/dist/api/routes/admin/discounts/create-dynamic-code.js.map +1 -1
  58. package/dist/api/routes/admin/discounts/delete-condition.js +12 -2
  59. package/dist/api/routes/admin/discounts/delete-condition.js.map +1 -1
  60. package/dist/api/routes/admin/discounts/delete-discount.js +12 -2
  61. package/dist/api/routes/admin/discounts/delete-discount.js.map +1 -1
  62. package/dist/api/routes/admin/discounts/delete-dynamic-code.js +12 -2
  63. package/dist/api/routes/admin/discounts/delete-dynamic-code.js.map +1 -1
  64. package/dist/api/routes/admin/discounts/remove-region.js +12 -2
  65. package/dist/api/routes/admin/discounts/remove-region.js.map +1 -1
  66. package/dist/api/routes/admin/discounts/update-condition.js +12 -2
  67. package/dist/api/routes/admin/discounts/update-condition.js.map +1 -1
  68. package/dist/api/routes/admin/discounts/update-discount.d.ts +1 -1
  69. package/dist/api/routes/admin/discounts/update-discount.js +13 -3
  70. package/dist/api/routes/admin/discounts/update-discount.js.map +1 -1
  71. package/dist/api/routes/admin/draft-orders/create-draft-order.js +12 -2
  72. package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
  73. package/dist/api/routes/admin/draft-orders/create-line-item.js +4 -2
  74. package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
  75. package/dist/api/routes/admin/draft-orders/delete-draft-order.js +12 -2
  76. package/dist/api/routes/admin/draft-orders/delete-draft-order.js.map +1 -1
  77. package/dist/api/routes/admin/draft-orders/register-payment.js +6 -3
  78. package/dist/api/routes/admin/draft-orders/register-payment.js.map +1 -1
  79. package/dist/api/routes/admin/draft-orders/update-draft-order.js +28 -12
  80. package/dist/api/routes/admin/draft-orders/update-draft-order.js.map +1 -1
  81. package/dist/api/routes/admin/gift-cards/create-gift-card.js +10 -2
  82. package/dist/api/routes/admin/gift-cards/create-gift-card.js.map +1 -1
  83. package/dist/api/routes/admin/gift-cards/delete-gift-card.js +10 -2
  84. package/dist/api/routes/admin/gift-cards/delete-gift-card.js.map +1 -1
  85. package/dist/api/routes/admin/gift-cards/update-gift-card.js +12 -2
  86. package/dist/api/routes/admin/gift-cards/update-gift-card.js.map +1 -1
  87. package/dist/api/routes/admin/invites/accept-invite.js +12 -2
  88. package/dist/api/routes/admin/invites/accept-invite.js.map +1 -1
  89. package/dist/api/routes/admin/invites/create-invite.js +12 -2
  90. package/dist/api/routes/admin/invites/create-invite.js.map +1 -1
  91. package/dist/api/routes/admin/invites/delete-invite.js +12 -2
  92. package/dist/api/routes/admin/invites/delete-invite.js.map +1 -1
  93. package/dist/api/routes/admin/invites/resend-invite.js +12 -2
  94. package/dist/api/routes/admin/invites/resend-invite.js.map +1 -1
  95. package/dist/api/routes/admin/notes/create-note.js +15 -7
  96. package/dist/api/routes/admin/notes/create-note.js.map +1 -1
  97. package/dist/api/routes/admin/notes/delete-note.js +10 -2
  98. package/dist/api/routes/admin/notes/delete-note.js.map +1 -1
  99. package/dist/api/routes/admin/notes/update-note.js +12 -2
  100. package/dist/api/routes/admin/notes/update-note.js.map +1 -1
  101. package/dist/api/routes/admin/notifications/list-notifications.js +8 -7
  102. package/dist/api/routes/admin/notifications/list-notifications.js.map +1 -1
  103. package/dist/api/routes/admin/notifications/resend-notification.js +12 -2
  104. package/dist/api/routes/admin/notifications/resend-notification.js.map +1 -1
  105. package/dist/api/routes/admin/orders/add-shipping-method.js +14 -4
  106. package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
  107. package/dist/api/routes/admin/orders/archive-order.js +10 -2
  108. package/dist/api/routes/admin/orders/archive-order.js.map +1 -1
  109. package/dist/api/routes/admin/orders/cancel-claim.js +12 -2
  110. package/dist/api/routes/admin/orders/cancel-claim.js.map +1 -1
  111. package/dist/api/routes/admin/orders/cancel-fulfillment-claim.js +12 -2
  112. package/dist/api/routes/admin/orders/cancel-fulfillment-claim.js.map +1 -1
  113. package/dist/api/routes/admin/orders/cancel-fulfillment-swap.js +12 -2
  114. package/dist/api/routes/admin/orders/cancel-fulfillment-swap.js.map +1 -1
  115. package/dist/api/routes/admin/orders/cancel-fulfillment.js +12 -2
  116. package/dist/api/routes/admin/orders/cancel-fulfillment.js.map +1 -1
  117. package/dist/api/routes/admin/orders/cancel-order.js +10 -2
  118. package/dist/api/routes/admin/orders/cancel-order.js.map +1 -1
  119. package/dist/api/routes/admin/orders/cancel-swap.js +10 -2
  120. package/dist/api/routes/admin/orders/cancel-swap.js.map +1 -1
  121. package/dist/api/routes/admin/orders/capture-payment.js +12 -2
  122. package/dist/api/routes/admin/orders/capture-payment.js.map +1 -1
  123. package/dist/api/routes/admin/orders/complete-order.js +12 -2
  124. package/dist/api/routes/admin/orders/complete-order.js.map +1 -1
  125. package/dist/api/routes/admin/orders/create-claim-shipment.js +18 -8
  126. package/dist/api/routes/admin/orders/create-claim-shipment.js.map +1 -1
  127. package/dist/api/routes/admin/orders/create-claim.js +199 -140
  128. package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
  129. package/dist/api/routes/admin/orders/create-fulfillment.d.ts +1 -1
  130. package/dist/api/routes/admin/orders/create-fulfillment.js +15 -5
  131. package/dist/api/routes/admin/orders/create-fulfillment.js.map +1 -1
  132. package/dist/api/routes/admin/orders/create-shipment.js +23 -8
  133. package/dist/api/routes/admin/orders/create-shipment.js.map +1 -1
  134. package/dist/api/routes/admin/orders/create-swap-shipment.js +16 -8
  135. package/dist/api/routes/admin/orders/create-swap-shipment.js.map +1 -1
  136. package/dist/api/routes/admin/orders/create-swap.js +150 -101
  137. package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
  138. package/dist/api/routes/admin/orders/fulfill-swap.js +8 -9
  139. package/dist/api/routes/admin/orders/fulfill-swap.js.map +1 -1
  140. package/dist/api/routes/admin/orders/index.d.ts +1 -3
  141. package/dist/api/routes/admin/orders/index.js +0 -10
  142. package/dist/api/routes/admin/orders/index.js.map +1 -1
  143. package/dist/api/routes/admin/orders/list-orders.d.ts +1 -0
  144. package/dist/api/routes/admin/orders/list-orders.js +1 -0
  145. package/dist/api/routes/admin/orders/list-orders.js.map +1 -1
  146. package/dist/api/routes/admin/orders/refund-payment.js +14 -4
  147. package/dist/api/routes/admin/orders/refund-payment.js.map +1 -1
  148. package/dist/api/routes/admin/orders/request-return.js +180 -131
  149. package/dist/api/routes/admin/orders/request-return.js.map +1 -1
  150. package/dist/api/routes/admin/orders/update-claim.js +12 -2
  151. package/dist/api/routes/admin/orders/update-claim.js.map +1 -1
  152. package/dist/api/routes/admin/orders/update-order.d.ts +9 -9
  153. package/dist/api/routes/admin/orders/update-order.js +16 -6
  154. package/dist/api/routes/admin/orders/update-order.js.map +1 -1
  155. package/dist/api/routes/admin/price-lists/add-prices-batch.js +12 -2
  156. package/dist/api/routes/admin/price-lists/add-prices-batch.js.map +1 -1
  157. package/dist/api/routes/admin/price-lists/create-price-list.js +12 -2
  158. package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -1
  159. package/dist/api/routes/admin/price-lists/delete-price-list.js +10 -2
  160. package/dist/api/routes/admin/price-lists/delete-price-list.js.map +1 -1
  161. package/dist/api/routes/admin/price-lists/delete-prices-batch.js +12 -2
  162. package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -1
  163. package/dist/api/routes/admin/price-lists/delete-product-prices.js +12 -4
  164. package/dist/api/routes/admin/price-lists/delete-product-prices.js.map +1 -1
  165. package/dist/api/routes/admin/price-lists/delete-variant-prices.js +12 -4
  166. package/dist/api/routes/admin/price-lists/delete-variant-prices.js.map +1 -1
  167. package/dist/api/routes/admin/price-lists/list-price-list-products.d.ts +2 -2
  168. package/dist/api/routes/admin/price-lists/list-price-list-products.js +1 -2
  169. package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -1
  170. package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -1
  171. package/dist/api/routes/admin/price-lists/update-price-list.js +12 -2
  172. package/dist/api/routes/admin/price-lists/update-price-list.js.map +1 -1
  173. package/dist/api/routes/admin/products/add-option.js +12 -2
  174. package/dist/api/routes/admin/products/add-option.js.map +1 -1
  175. package/dist/api/routes/admin/products/create-product.d.ts +10 -8
  176. package/dist/api/routes/admin/products/create-product.js +36 -37
  177. package/dist/api/routes/admin/products/create-product.js.map +1 -1
  178. package/dist/api/routes/admin/products/create-variant.js +12 -2
  179. package/dist/api/routes/admin/products/create-variant.js.map +1 -1
  180. package/dist/api/routes/admin/products/delete-option.js +12 -2
  181. package/dist/api/routes/admin/products/delete-option.js.map +1 -1
  182. package/dist/api/routes/admin/products/delete-product.js +10 -2
  183. package/dist/api/routes/admin/products/delete-product.js.map +1 -1
  184. package/dist/api/routes/admin/products/delete-variant.js +14 -2
  185. package/dist/api/routes/admin/products/delete-variant.js.map +1 -1
  186. package/dist/api/routes/admin/products/index.d.ts +2 -2
  187. package/dist/api/routes/admin/products/index.js +6 -31
  188. package/dist/api/routes/admin/products/index.js.map +1 -1
  189. package/dist/api/routes/admin/products/list-products.d.ts +3 -20
  190. package/dist/api/routes/admin/products/list-products.js +15 -103
  191. package/dist/api/routes/admin/products/list-products.js.map +1 -1
  192. package/dist/api/routes/admin/products/set-metadata.js +18 -10
  193. package/dist/api/routes/admin/products/set-metadata.js.map +1 -1
  194. package/dist/api/routes/admin/products/update-option.js +12 -2
  195. package/dist/api/routes/admin/products/update-option.js.map +1 -1
  196. package/dist/api/routes/admin/products/update-product.d.ts +10 -8
  197. package/dist/api/routes/admin/products/update-product.js +40 -33
  198. package/dist/api/routes/admin/products/update-product.js.map +1 -1
  199. package/dist/api/routes/admin/products/update-variant.js +14 -2
  200. package/dist/api/routes/admin/products/update-variant.js.map +1 -1
  201. package/dist/api/routes/admin/regions/add-country.js +12 -2
  202. package/dist/api/routes/admin/regions/add-country.js.map +1 -1
  203. package/dist/api/routes/admin/regions/add-fulfillment-provider.js +12 -2
  204. package/dist/api/routes/admin/regions/add-fulfillment-provider.js.map +1 -1
  205. package/dist/api/routes/admin/regions/add-payment-provider.js +12 -2
  206. package/dist/api/routes/admin/regions/add-payment-provider.js.map +1 -1
  207. package/dist/api/routes/admin/regions/create-region.js +12 -2
  208. package/dist/api/routes/admin/regions/create-region.js.map +1 -1
  209. package/dist/api/routes/admin/regions/delete-region.js +12 -2
  210. package/dist/api/routes/admin/regions/delete-region.js.map +1 -1
  211. package/dist/api/routes/admin/regions/index.d.ts +0 -1
  212. package/dist/api/routes/admin/regions/index.js +0 -9
  213. package/dist/api/routes/admin/regions/index.js.map +1 -1
  214. package/dist/api/routes/admin/regions/remove-country.js +12 -2
  215. package/dist/api/routes/admin/regions/remove-country.js.map +1 -1
  216. package/dist/api/routes/admin/regions/remove-fulfillment-provider.js +12 -2
  217. package/dist/api/routes/admin/regions/remove-fulfillment-provider.js.map +1 -1
  218. package/dist/api/routes/admin/regions/remove-payment-provider.js +12 -2
  219. package/dist/api/routes/admin/regions/remove-payment-provider.js.map +1 -1
  220. package/dist/api/routes/admin/regions/update-region.js +12 -2
  221. package/dist/api/routes/admin/regions/update-region.js.map +1 -1
  222. package/dist/api/routes/admin/return-reasons/create-reason.js +12 -2
  223. package/dist/api/routes/admin/return-reasons/create-reason.js.map +1 -1
  224. package/dist/api/routes/admin/return-reasons/delete-reason.js +12 -2
  225. package/dist/api/routes/admin/return-reasons/delete-reason.js.map +1 -1
  226. package/dist/api/routes/admin/return-reasons/update-reason.js +12 -2
  227. package/dist/api/routes/admin/return-reasons/update-reason.js.map +1 -1
  228. package/dist/api/routes/admin/returns/cancel-return.js +10 -2
  229. package/dist/api/routes/admin/returns/cancel-return.js.map +1 -1
  230. package/dist/api/routes/admin/sales-channels/add-product-batch.d.ts +28 -0
  231. package/dist/api/routes/admin/sales-channels/add-product-batch.js +111 -0
  232. package/dist/api/routes/admin/sales-channels/add-product-batch.js.map +1 -0
  233. package/dist/api/routes/admin/sales-channels/create-sales-channel.d.ts +2 -1
  234. package/dist/api/routes/admin/sales-channels/create-sales-channel.js +19 -3
  235. package/dist/api/routes/admin/sales-channels/create-sales-channel.js.map +1 -1
  236. package/dist/api/routes/admin/sales-channels/delete-products-batch.d.ts +28 -0
  237. package/dist/api/routes/admin/sales-channels/delete-products-batch.js +111 -0
  238. package/dist/api/routes/admin/sales-channels/delete-products-batch.js.map +1 -0
  239. package/dist/api/routes/admin/sales-channels/delete-sales-channel.js +12 -2
  240. package/dist/api/routes/admin/sales-channels/delete-sales-channel.js.map +1 -1
  241. package/dist/api/routes/admin/sales-channels/index.d.ts +7 -3
  242. package/dist/api/routes/admin/sales-channels/index.js +18 -8
  243. package/dist/api/routes/admin/sales-channels/index.js.map +1 -1
  244. package/dist/api/routes/admin/sales-channels/list-sales-channels.d.ts +57 -0
  245. package/dist/api/routes/admin/sales-channels/list-sales-channels.js +197 -0
  246. package/dist/api/routes/admin/sales-channels/list-sales-channels.js.map +1 -0
  247. package/dist/api/routes/admin/sales-channels/update-sales-channel.js +12 -2
  248. package/dist/api/routes/admin/sales-channels/update-sales-channel.js.map +1 -1
  249. package/dist/api/routes/admin/shipping-options/create-shipping-option.js +13 -2
  250. package/dist/api/routes/admin/shipping-options/create-shipping-option.js.map +1 -1
  251. package/dist/api/routes/admin/shipping-options/delete-shipping-option.js +12 -2
  252. package/dist/api/routes/admin/shipping-options/delete-shipping-option.js.map +1 -1
  253. package/dist/api/routes/admin/shipping-options/update-shipping-option.js +12 -2
  254. package/dist/api/routes/admin/shipping-options/update-shipping-option.js.map +1 -1
  255. package/dist/api/routes/admin/shipping-profiles/create-shipping-profile.js +12 -2
  256. package/dist/api/routes/admin/shipping-profiles/create-shipping-profile.js.map +1 -1
  257. package/dist/api/routes/admin/shipping-profiles/delete-shipping-profile.js +12 -2
  258. package/dist/api/routes/admin/shipping-profiles/delete-shipping-profile.js.map +1 -1
  259. package/dist/api/routes/admin/shipping-profiles/update-shipping-profile.js +12 -2
  260. package/dist/api/routes/admin/shipping-profiles/update-shipping-profile.js.map +1 -1
  261. package/dist/api/routes/admin/store/add-currency.js +12 -2
  262. package/dist/api/routes/admin/store/add-currency.js.map +1 -1
  263. package/dist/api/routes/admin/store/get-store.js +6 -2
  264. package/dist/api/routes/admin/store/get-store.js.map +1 -1
  265. package/dist/api/routes/admin/store/remove-currency.js +12 -2
  266. package/dist/api/routes/admin/store/remove-currency.js.map +1 -1
  267. package/dist/api/routes/admin/store/update-store.js +12 -2
  268. package/dist/api/routes/admin/store/update-store.js.map +1 -1
  269. package/dist/api/routes/admin/tax-rates/add-to-product-types.js +12 -2
  270. package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +1 -1
  271. package/dist/api/routes/admin/tax-rates/add-to-products.js +12 -2
  272. package/dist/api/routes/admin/tax-rates/add-to-products.js.map +1 -1
  273. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +12 -2
  274. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +1 -1
  275. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js +10 -2
  276. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js.map +1 -1
  277. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js +12 -2
  278. package/dist/api/routes/admin/tax-rates/remove-from-product-types.js.map +1 -1
  279. package/dist/api/routes/admin/tax-rates/remove-from-products.js +12 -2
  280. package/dist/api/routes/admin/tax-rates/remove-from-products.js.map +1 -1
  281. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js +12 -2
  282. package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js.map +1 -1
  283. package/dist/api/routes/admin/users/create-user.js +12 -2
  284. package/dist/api/routes/admin/users/create-user.js.map +1 -1
  285. package/dist/api/routes/admin/users/delete-user.js +10 -2
  286. package/dist/api/routes/admin/users/delete-user.js.map +1 -1
  287. package/dist/api/routes/admin/users/reset-password-token.js +12 -4
  288. package/dist/api/routes/admin/users/reset-password-token.js.map +1 -1
  289. package/dist/api/routes/admin/users/reset-password.js +17 -8
  290. package/dist/api/routes/admin/users/reset-password.js.map +1 -1
  291. package/dist/api/routes/admin/users/update-user.js +12 -2
  292. package/dist/api/routes/admin/users/update-user.js.map +1 -1
  293. package/dist/api/routes/store/auth/create-session.js +12 -2
  294. package/dist/api/routes/store/auth/create-session.js.map +1 -1
  295. package/dist/api/routes/store/carts/calculate-taxes.js +84 -49
  296. package/dist/api/routes/store/carts/calculate-taxes.js.map +1 -1
  297. package/dist/api/routes/store/carts/complete-cart.js +10 -2
  298. package/dist/api/routes/store/carts/complete-cart.js.map +1 -1
  299. package/dist/api/routes/store/carts/create-cart.d.ts +4 -0
  300. package/dist/api/routes/store/carts/create-cart.js +72 -85
  301. package/dist/api/routes/store/carts/create-cart.js.map +1 -1
  302. package/dist/api/routes/store/carts/create-line-item.js +6 -3
  303. package/dist/api/routes/store/carts/create-line-item.js.map +1 -1
  304. package/dist/api/routes/store/carts/create-payment-sessions.js +10 -2
  305. package/dist/api/routes/store/carts/create-payment-sessions.js.map +1 -1
  306. package/dist/api/routes/store/carts/decorate-line-items-with-totals.js +20 -10
  307. package/dist/api/routes/store/carts/decorate-line-items-with-totals.js.map +1 -1
  308. package/dist/api/routes/store/carts/delete-payment-session.js +10 -2
  309. package/dist/api/routes/store/carts/delete-payment-session.js.map +1 -1
  310. package/dist/api/routes/store/carts/index.js +6 -30
  311. package/dist/api/routes/store/carts/index.js.map +1 -1
  312. package/dist/api/routes/store/carts/refresh-payment-session.js +10 -2
  313. package/dist/api/routes/store/carts/refresh-payment-session.js.map +1 -1
  314. package/dist/api/routes/store/carts/set-payment-session.js +11 -3
  315. package/dist/api/routes/store/carts/set-payment-session.js.map +1 -1
  316. package/dist/api/routes/store/carts/update-cart.d.ts +4 -0
  317. package/dist/api/routes/store/carts/update-cart.js +49 -64
  318. package/dist/api/routes/store/carts/update-cart.js.map +1 -1
  319. package/dist/api/routes/store/carts/update-line-item.js +1 -1
  320. package/dist/api/routes/store/carts/update-line-item.js.map +1 -1
  321. package/dist/api/routes/store/carts/update-payment-session.js +17 -7
  322. package/dist/api/routes/store/carts/update-payment-session.js.map +1 -1
  323. package/dist/api/routes/store/customers/create-address.js +13 -3
  324. package/dist/api/routes/store/customers/create-address.js.map +1 -1
  325. package/dist/api/routes/store/customers/create-customer.js +12 -2
  326. package/dist/api/routes/store/customers/create-customer.js.map +1 -1
  327. package/dist/api/routes/store/customers/delete-address.js +12 -2
  328. package/dist/api/routes/store/customers/delete-address.js.map +1 -1
  329. package/dist/api/routes/store/customers/list-orders.js.map +1 -1
  330. package/dist/api/routes/store/customers/reset-password-token.js +12 -4
  331. package/dist/api/routes/store/customers/reset-password-token.js.map +1 -1
  332. package/dist/api/routes/store/customers/reset-password.js +14 -4
  333. package/dist/api/routes/store/customers/reset-password.js.map +1 -1
  334. package/dist/api/routes/store/customers/update-address.js +12 -2
  335. package/dist/api/routes/store/customers/update-address.js.map +1 -1
  336. package/dist/api/routes/store/customers/update-customer.js +12 -2
  337. package/dist/api/routes/store/customers/update-customer.js.map +1 -1
  338. package/dist/api/routes/store/orders/index.d.ts +1 -1
  339. package/dist/api/routes/store/orders/index.js.map +1 -1
  340. package/dist/api/routes/store/returns/create-return.js +145 -100
  341. package/dist/api/routes/store/returns/create-return.js.map +1 -1
  342. package/dist/api/routes/store/shipping-options/list-shipping-options.js +7 -1
  343. package/dist/api/routes/store/shipping-options/list-shipping-options.js.map +1 -1
  344. package/dist/api/routes/store/swaps/create-swap.js +148 -99
  345. package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
  346. package/dist/interfaces/base-repository.d.ts +3 -0
  347. package/dist/interfaces/base-repository.js +28 -0
  348. package/dist/interfaces/base-repository.js.map +1 -0
  349. package/dist/interfaces/index.d.ts +3 -0
  350. package/dist/interfaces/index.js +3 -0
  351. package/dist/interfaces/index.js.map +1 -1
  352. package/dist/interfaces/notification-service.d.ts +18 -0
  353. package/dist/interfaces/notification-service.js +40 -0
  354. package/dist/interfaces/notification-service.js.map +1 -0
  355. package/dist/interfaces/search-service.d.ts +78 -0
  356. package/dist/interfaces/search-service.js +42 -0
  357. package/dist/interfaces/search-service.js.map +1 -0
  358. package/dist/loaders/index.js +1 -1
  359. package/dist/loaders/index.js.map +1 -1
  360. package/dist/loaders/plugins.js +10 -12
  361. package/dist/loaders/plugins.js.map +1 -1
  362. package/dist/loaders/search-index.d.ts +1 -0
  363. package/dist/loaders/search-index.js +7 -64
  364. package/dist/loaders/search-index.js.map +1 -1
  365. package/dist/models/index.d.ts +1 -0
  366. package/dist/models/index.js +1 -0
  367. package/dist/models/index.js.map +1 -1
  368. package/dist/models/notification.d.ts +1 -1
  369. package/dist/models/notification.js +1 -1
  370. package/dist/models/notification.js.map +1 -1
  371. package/dist/models/order.d.ts +1 -1
  372. package/dist/models/payment-session.d.ts +1 -1
  373. package/dist/models/payment-session.js +4 -4
  374. package/dist/models/payment-session.js.map +1 -1
  375. package/dist/models/product.js +1 -1
  376. package/dist/models/product.js.map +1 -1
  377. package/dist/repositories/claim.js.map +1 -1
  378. package/dist/repositories/order.d.ts +3 -3
  379. package/dist/repositories/order.js +2 -2
  380. package/dist/repositories/order.js.map +1 -1
  381. package/dist/repositories/price-list.js.map +1 -1
  382. package/dist/repositories/product.d.ts +2 -2
  383. package/dist/repositories/product.js +19 -11
  384. package/dist/repositories/product.js.map +1 -1
  385. package/dist/repositories/sales-channel.d.ts +5 -1
  386. package/dist/repositories/sales-channel.js +116 -0
  387. package/dist/repositories/sales-channel.js.map +1 -1
  388. package/dist/services/batch-job.js +18 -32
  389. package/dist/services/batch-job.js.map +1 -1
  390. package/dist/services/cart.d.ts +37 -10
  391. package/dist/services/cart.js +293 -161
  392. package/dist/services/cart.js.map +1 -1
  393. package/dist/services/claim.js +18 -32
  394. package/dist/services/claim.js.map +1 -1
  395. package/dist/services/custom-shipping-option.js +28 -53
  396. package/dist/services/custom-shipping-option.js.map +1 -1
  397. package/dist/services/customer.js +33 -78
  398. package/dist/services/customer.js.map +1 -1
  399. package/dist/services/discount-condition.js +12 -19
  400. package/dist/services/discount-condition.js.map +1 -1
  401. package/dist/services/discount.js +67 -91
  402. package/dist/services/discount.js.map +1 -1
  403. package/dist/services/draft-order.js +57 -85
  404. package/dist/services/draft-order.js.map +1 -1
  405. package/dist/services/fulfillment.d.ts +1 -1
  406. package/dist/services/fulfillment.js +12 -19
  407. package/dist/services/fulfillment.js.map +1 -1
  408. package/dist/services/gift-card.js +67 -116
  409. package/dist/services/gift-card.js.map +1 -1
  410. package/dist/services/idempotency-key.d.ts +2 -3
  411. package/dist/services/idempotency-key.js +3 -3
  412. package/dist/services/idempotency-key.js.map +1 -1
  413. package/dist/services/inventory.d.ts +22 -21
  414. package/dist/services/inventory.js +57 -55
  415. package/dist/services/inventory.js.map +1 -1
  416. package/dist/services/line-item.js +19 -33
  417. package/dist/services/line-item.js.map +1 -1
  418. package/dist/services/note.d.ts +43 -48
  419. package/dist/services/note.js +106 -118
  420. package/dist/services/note.js.map +1 -1
  421. package/dist/services/notification.d.ts +54 -51
  422. package/dist/services/notification.js +118 -113
  423. package/dist/services/notification.js.map +1 -1
  424. package/dist/services/order.d.ts +163 -184
  425. package/dist/services/order.js +1248 -1319
  426. package/dist/services/order.js.map +1 -1
  427. package/dist/services/price-list.js +35 -45
  428. package/dist/services/price-list.js.map +1 -1
  429. package/dist/services/pricing.js +32 -35
  430. package/dist/services/pricing.js.map +1 -1
  431. package/dist/services/product.d.ts +7 -4
  432. package/dist/services/product.js +151 -170
  433. package/dist/services/product.js.map +1 -1
  434. package/dist/services/sales-channel.d.ts +22 -1
  435. package/dist/services/sales-channel.js +130 -28
  436. package/dist/services/sales-channel.js.map +1 -1
  437. package/dist/services/search.d.ts +23 -19
  438. package/dist/services/search.js +10 -9
  439. package/dist/services/search.js.map +1 -1
  440. package/dist/services/shipping-option.d.ts +1 -1
  441. package/dist/services/shipping-option.js +77 -84
  442. package/dist/services/shipping-option.js.map +1 -1
  443. package/dist/services/shipping-profile.js +37 -30
  444. package/dist/services/shipping-profile.js.map +1 -1
  445. package/dist/services/store.d.ts +5 -5
  446. package/dist/services/store.js +13 -20
  447. package/dist/services/store.js.map +1 -1
  448. package/dist/services/swap.js +3 -1
  449. package/dist/services/swap.js.map +1 -1
  450. package/dist/services/tax-provider.d.ts +18 -19
  451. package/dist/services/tax-provider.js +81 -61
  452. package/dist/services/tax-provider.js.map +1 -1
  453. package/dist/services/tax-rate.js +23 -46
  454. package/dist/services/tax-rate.js.map +1 -1
  455. package/dist/services/totals.d.ts +7 -4
  456. package/dist/services/totals.js +19 -7
  457. package/dist/services/totals.js.map +1 -1
  458. package/dist/services/user.d.ts +3 -0
  459. package/dist/services/user.js +70 -76
  460. package/dist/services/user.js.map +1 -1
  461. package/dist/strategies/__fixtures__/order-export-data.js +11 -0
  462. package/dist/strategies/__fixtures__/order-export-data.js.map +1 -1
  463. package/dist/strategies/__fixtures__/product-export-data.d.ts +10 -0
  464. package/dist/strategies/__fixtures__/product-export-data.js +7 -0
  465. package/dist/strategies/__fixtures__/product-export-data.js.map +1 -1
  466. package/dist/strategies/batch-jobs/order/export.d.ts +10 -4
  467. package/dist/strategies/batch-jobs/order/export.js +29 -11
  468. package/dist/strategies/batch-jobs/order/export.js.map +1 -1
  469. package/dist/strategies/batch-jobs/order/index.js +1 -1
  470. package/dist/strategies/batch-jobs/order/index.js.map +1 -1
  471. package/dist/strategies/batch-jobs/product/export.d.ts +13 -1
  472. package/dist/strategies/batch-jobs/product/export.js +137 -80
  473. package/dist/strategies/batch-jobs/product/export.js.map +1 -1
  474. package/dist/strategies/batch-jobs/product/index.d.ts +1 -0
  475. package/dist/strategies/batch-jobs/product/index.js.map +1 -1
  476. package/dist/subscribers/search-indexing.d.ts +18 -0
  477. package/dist/subscribers/search-indexing.js +126 -0
  478. package/dist/subscribers/search-indexing.js.map +1 -0
  479. package/dist/types/cart.d.ts +7 -4
  480. package/dist/types/common.d.ts +10 -1
  481. package/dist/types/common.js +63 -1
  482. package/dist/types/common.js.map +1 -1
  483. package/dist/types/gift-card.d.ts +3 -1
  484. package/dist/types/global.d.ts +3 -2
  485. package/dist/types/orders.d.ts +80 -3
  486. package/dist/types/orders.js +8 -2
  487. package/dist/types/orders.js.map +1 -1
  488. package/dist/types/product.d.ts +16 -0
  489. package/dist/types/product.js +46 -1
  490. package/dist/types/product.js.map +1 -1
  491. package/dist/types/sales-channels.d.ts +3 -0
  492. package/dist/types/sales-channels.js +21 -0
  493. package/dist/types/sales-channels.js.map +1 -1
  494. package/dist/utils/index.d.ts +5 -4
  495. package/dist/utils/index.js +1 -0
  496. package/dist/utils/index.js.map +1 -1
  497. package/dist/utils/remove-undefined-properties.d.ts +1 -0
  498. package/dist/utils/remove-undefined-properties.js +46 -0
  499. package/dist/utils/remove-undefined-properties.js.map +1 -0
  500. package/jest.config.js +6 -6
  501. package/package.json +4 -5
  502. package/yarn-error.log +29038 -0
@@ -52,54 +52,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  var medusa_core_utils_1 = require("medusa-core-utils");
55
- var medusa_interfaces_1 = require("medusa-interfaces");
56
- var typeorm_1 = require("typeorm");
55
+ var interfaces_1 = require("../interfaces");
56
+ var utils_1 = require("../utils");
57
57
  var NoteService = /** @class */ (function (_super) {
58
58
  __extends(NoteService, _super);
59
59
  function NoteService(_a) {
60
60
  var manager = _a.manager, noteRepository = _a.noteRepository, eventBusService = _a.eventBusService;
61
- var _this = _super.call(this) || this;
62
- /** @private @const {EntityManager} */
61
+ var _this = _super.call(this, { manager: manager, noteRepository: noteRepository, eventBusService: eventBusService }) || this;
63
62
  _this.manager_ = manager;
64
- /** @private @const {NoteRepository} */
65
63
  _this.noteRepository_ = noteRepository;
66
- /** @private @const {EventBus} */
67
64
  _this.eventBus_ = eventBusService;
68
65
  return _this;
69
66
  }
70
- /**
71
- * Sets the service's manager to a given transaction manager
72
- * @param {EntityManager} transactionManager - the manager to use
73
- * @return {NoteService} a cloned note service
74
- */
75
- NoteService.prototype.withTransaction = function (transactionManager) {
76
- if (!typeorm_1.TransactionManager) {
77
- return this;
78
- }
79
- var cloned = new NoteService({
80
- manager: transactionManager,
81
- noteRepository: this.noteRepository_,
82
- eventBusService: this.eventBus_,
83
- });
84
- cloned.transactionManager_ = transactionManager;
85
- return cloned;
86
- };
87
67
  /**
88
68
  * Retrieves a specific note.
89
- * @param {string} id - the id of the note to retrieve.
90
- * @param {object} config - any options needed to query for the result.
91
- * @return {Promise<Note>} which resolves to the requested note.
69
+ * @param id - the id of the note to retrieve.
70
+ * @param config - any options needed to query for the result.
71
+ * @return which resolves to the requested note.
92
72
  */
93
73
  NoteService.prototype.retrieve = function (id, config) {
94
74
  if (config === void 0) { config = {}; }
95
75
  return __awaiter(this, void 0, void 0, function () {
96
- var noteRepo, validatedId, query, note;
76
+ var noteRepo, query, note;
97
77
  return __generator(this, function (_a) {
98
78
  switch (_a.label) {
99
79
  case 0:
100
80
  noteRepo = this.manager_.getCustomRepository(this.noteRepository_);
101
- validatedId = this.validateId_(id);
102
- query = this.buildQuery_({ id: validatedId }, config);
81
+ query = (0, utils_1.buildQuery)({ id: id }, config);
103
82
  return [4 /*yield*/, noteRepo.findOne(query)];
104
83
  case 1:
105
84
  note = _a.sent();
@@ -112,12 +91,12 @@ var NoteService = /** @class */ (function (_super) {
112
91
  });
113
92
  };
114
93
  /** Fetches all notes related to the given selector
115
- * @param {Object} selector - the query object for find
116
- * @param {Object} config - the configuration used to find the objects. contains relations, skip, and take.
117
- * @param {string[]} config.relations - Which relations to include in the resulting list of Notes.
118
- * @param {number} config.take - How many Notes to take in the resulting list of Notes.
119
- * @param {number} config.skip - How many Notes to skip in the resulting list of Notes.
120
- * @return {Promise<Note[]>} notes related to the given search.
94
+ * @param selector - the query object for find
95
+ * @param config - the configuration used to find the objects. contains relations, skip, and take.
96
+ * @param config.relations - Which relations to include in the resulting list of Notes.
97
+ * @param config.take - How many Notes to take in the resulting list of Notes.
98
+ * @param config.skip - How many Notes to skip in the resulting list of Notes.
99
+ * @return notes related to the given search.
121
100
  */
122
101
  NoteService.prototype.list = function (selector, config) {
123
102
  if (config === void 0) { config = {
@@ -129,16 +108,16 @@ var NoteService = /** @class */ (function (_super) {
129
108
  var noteRepo, query;
130
109
  return __generator(this, function (_a) {
131
110
  noteRepo = this.manager_.getCustomRepository(this.noteRepository_);
132
- query = this.buildQuery_(selector, config);
111
+ query = (0, utils_1.buildQuery)(selector, config);
133
112
  return [2 /*return*/, noteRepo.find(query)];
134
113
  });
135
114
  });
136
115
  };
137
116
  /**
138
117
  * Creates a note associated with a given author
139
- * @param {CreateNoteInput} data - the note to create
140
- * @param {*} config - any configurations if needed, including meta data
141
- * @return {Promise} resolves to the creation result
118
+ * @param data - the note to create
119
+ * @param config - any configurations if needed, including meta data
120
+ * @return resolves to the creation result
142
121
  */
143
122
  NoteService.prototype.create = function (data, config) {
144
123
  if (config === void 0) { config = { metadata: {} }; }
@@ -146,104 +125,113 @@ var NoteService = /** @class */ (function (_super) {
146
125
  var metadata, resource_id, resource_type, value, author_id;
147
126
  var _this = this;
148
127
  return __generator(this, function (_a) {
149
- metadata = config.metadata;
150
- resource_id = data.resource_id, resource_type = data.resource_type, value = data.value, author_id = data.author_id;
151
- return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
152
- var noteRepo, toCreate, note, result;
153
- return __generator(this, function (_a) {
154
- switch (_a.label) {
155
- case 0:
156
- noteRepo = manager.getCustomRepository(this.noteRepository_);
157
- toCreate = {
158
- resource_id: resource_id,
159
- resource_type: resource_type,
160
- value: value,
161
- author_id: author_id,
162
- metadata: metadata,
163
- };
164
- return [4 /*yield*/, noteRepo.create(toCreate)];
165
- case 1:
166
- note = _a.sent();
167
- return [4 /*yield*/, noteRepo.save(note)];
168
- case 2:
169
- result = _a.sent();
170
- return [4 /*yield*/, this.eventBus_
171
- .withTransaction(manager)
172
- .emit(NoteService.Events.CREATED, { id: result.id })];
173
- case 3:
174
- _a.sent();
175
- return [2 /*return*/, result];
176
- }
177
- });
178
- }); })];
128
+ switch (_a.label) {
129
+ case 0:
130
+ metadata = config.metadata;
131
+ resource_id = data.resource_id, resource_type = data.resource_type, value = data.value, author_id = data.author_id;
132
+ return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
133
+ var noteRepo, toCreate, note, result;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ noteRepo = manager.getCustomRepository(this.noteRepository_);
138
+ toCreate = {
139
+ resource_id: resource_id,
140
+ resource_type: resource_type,
141
+ value: value,
142
+ author_id: author_id,
143
+ metadata: metadata,
144
+ };
145
+ return [4 /*yield*/, noteRepo.create(toCreate)];
146
+ case 1:
147
+ note = _a.sent();
148
+ return [4 /*yield*/, noteRepo.save(note)];
149
+ case 2:
150
+ result = _a.sent();
151
+ return [4 /*yield*/, this.eventBus_
152
+ .withTransaction(manager)
153
+ .emit(NoteService.Events.CREATED, { id: result.id })];
154
+ case 3:
155
+ _a.sent();
156
+ return [2 /*return*/, result];
157
+ }
158
+ });
159
+ }); })];
160
+ case 1: return [2 /*return*/, _a.sent()];
161
+ }
179
162
  });
180
163
  });
181
164
  };
182
165
  /**
183
166
  * Updates a given note with a new value
184
- * @param {*} noteId - the id of the note to update
185
- * @param {*} value - the new value
186
- * @return {Promise} resolves to the updated element
167
+ * @param noteId - the id of the note to update
168
+ * @param value - the new value
169
+ * @return resolves to the updated element
187
170
  */
188
171
  NoteService.prototype.update = function (noteId, value) {
189
172
  return __awaiter(this, void 0, void 0, function () {
190
173
  var _this = this;
191
174
  return __generator(this, function (_a) {
192
- return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
193
- var noteRepo, note, result;
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0:
197
- noteRepo = manager.getCustomRepository(this.noteRepository_);
198
- return [4 /*yield*/, this.retrieve(noteId, { relations: ["author"] })];
199
- case 1:
200
- note = _a.sent();
201
- note.value = value;
202
- return [4 /*yield*/, noteRepo.save(note)];
203
- case 2:
204
- result = _a.sent();
205
- return [4 /*yield*/, this.eventBus_
206
- .withTransaction(manager)
207
- .emit(NoteService.Events.UPDATED, { id: result.id })];
208
- case 3:
209
- _a.sent();
210
- return [2 /*return*/, result];
211
- }
212
- });
213
- }); })];
175
+ switch (_a.label) {
176
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
177
+ var noteRepo, note, result;
178
+ return __generator(this, function (_a) {
179
+ switch (_a.label) {
180
+ case 0:
181
+ noteRepo = manager.getCustomRepository(this.noteRepository_);
182
+ return [4 /*yield*/, this.retrieve(noteId, { relations: ["author"] })];
183
+ case 1:
184
+ note = _a.sent();
185
+ note.value = value;
186
+ return [4 /*yield*/, noteRepo.save(note)];
187
+ case 2:
188
+ result = _a.sent();
189
+ return [4 /*yield*/, this.eventBus_
190
+ .withTransaction(manager)
191
+ .emit(NoteService.Events.UPDATED, { id: result.id })];
192
+ case 3:
193
+ _a.sent();
194
+ return [2 /*return*/, result];
195
+ }
196
+ });
197
+ }); })];
198
+ case 1: return [2 /*return*/, _a.sent()];
199
+ }
214
200
  });
215
201
  });
216
202
  };
217
203
  /**
218
204
  * Deletes a given note
219
- * @param {*} noteId - id of the note to delete
220
- * @return {Promise}
205
+ * @param noteId - id of the note to delete
221
206
  */
222
207
  NoteService.prototype.delete = function (noteId) {
223
208
  return __awaiter(this, void 0, void 0, function () {
224
209
  var _this = this;
225
210
  return __generator(this, function (_a) {
226
- return [2 /*return*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
227
- var noteRepo, note;
228
- return __generator(this, function (_a) {
229
- switch (_a.label) {
230
- case 0:
231
- noteRepo = manager.getCustomRepository(this.noteRepository_);
232
- return [4 /*yield*/, this.retrieve(noteId)];
233
- case 1:
234
- note = _a.sent();
235
- return [4 /*yield*/, noteRepo.softRemove(note)];
236
- case 2:
237
- _a.sent();
238
- return [4 /*yield*/, this.eventBus_
239
- .withTransaction(manager)
240
- .emit(NoteService.Events.DELETED, { id: noteId })];
241
- case 3:
242
- _a.sent();
243
- return [2 /*return*/, Promise.resolve()];
244
- }
245
- });
246
- }); })];
211
+ switch (_a.label) {
212
+ case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
213
+ var noteRepo, note;
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0:
217
+ noteRepo = manager.getCustomRepository(this.noteRepository_);
218
+ return [4 /*yield*/, this.retrieve(noteId)];
219
+ case 1:
220
+ note = _a.sent();
221
+ return [4 /*yield*/, noteRepo.softRemove(note)];
222
+ case 2:
223
+ _a.sent();
224
+ return [4 /*yield*/, this.eventBus_
225
+ .withTransaction(manager)
226
+ .emit(NoteService.Events.DELETED, { id: noteId })];
227
+ case 3:
228
+ _a.sent();
229
+ return [2 /*return*/];
230
+ }
231
+ });
232
+ }); })];
233
+ case 1: return [2 /*return*/, _a.sent()];
234
+ }
247
235
  });
248
236
  });
249
237
  };
@@ -253,6 +241,6 @@ var NoteService = /** @class */ (function (_super) {
253
241
  DELETED: "note.deleted",
254
242
  };
255
243
  return NoteService;
256
- }(medusa_interfaces_1.BaseService));
244
+ }(interfaces_1.TransactionBaseService));
257
245
  exports.default = NoteService;
258
246
  //# sourceMappingURL=note.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"note.js","sourceRoot":"","sources":["../../src/services/note.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAC/C,mCAA4C;AAE5C;IAA0B,+BAAW;IAOnC,qBAAY,EAA4C;YAA1C,OAAO,aAAA,EAAE,cAAc,oBAAA,EAAE,eAAe,qBAAA;QAAtD,YACE,iBAAO,SAUR;QARC,sCAAsC;QACtC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QAEvB,uCAAuC;QACvC,KAAI,CAAC,eAAe,GAAG,cAAc,CAAA;QAErC,iCAAiC;QACjC,KAAI,CAAC,SAAS,GAAG,eAAe,CAAA;;IAClC,CAAC;IAED;;;;OAIG;IACH,qCAAe,GAAf,UAAgB,kBAAkB;QAChC,IAAI,CAAC,4BAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,WAAW,CAAC;YAC7B,OAAO,EAAE,k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BAVF,sBAAO,SAUL,EAAA;;;;KACH;IApJe,kBAAM,GAAG;QACvB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,cAAc;KACxB,CAAA;IAiJH,kBAAC;CAAA,AAtJD,CAA0B,mCAAsB,GAsJ/C;AAED,kBAAe,WAAW,CAAA"}
@@ -1,83 +1,85 @@
1
- export default NotificationService;
2
- declare const NotificationService_base: any;
3
- /**
4
- * Provides layer to manipulate orchestrate notifications.
5
- * @extends BaseService
6
- */
7
- declare class NotificationService extends NotificationService_base {
8
- [x: string]: any;
9
- constructor(container: any);
10
- container_: any;
11
- /** @private @const {EntityManager} */
12
- private manager_;
13
- logger_: any;
14
- /** @private @const {NotificationRepository} */
15
- private notificationRepository_;
16
- notificationProviderRepository_: any;
17
- subscribers_: {};
18
- attachmentGenerator_: any;
1
+ import { AbstractNotificationService, TransactionBaseService } from "../interfaces";
2
+ import { EntityManager } from "typeorm";
3
+ import { Logger } from "../types/global";
4
+ import { NotificationRepository } from "../repositories/notification";
5
+ import { NotificationProviderRepository } from "../repositories/notification-provider";
6
+ import { FindConfig, Selector } from "../types/common";
7
+ import { Notification } from "../models";
8
+ declare type InjectedDependencies = {
9
+ manager: EntityManager;
10
+ logger: Logger;
11
+ notificationRepository: typeof NotificationRepository;
12
+ notificationProviderRepository: typeof NotificationProviderRepository;
13
+ };
14
+ declare type NotificationProviderKey = `noti_${string}`;
15
+ declare class NotificationService extends TransactionBaseService<NotificationService> {
16
+ protected manager_: EntityManager;
17
+ protected transactionManager_: EntityManager | undefined;
18
+ protected subscribers_: {};
19
+ protected attachmentGenerator_: unknown;
20
+ protected readonly container_: InjectedDependencies & {
21
+ [key in `${NotificationProviderKey}`]: AbstractNotificationService<never>;
22
+ };
23
+ protected readonly logger_: Logger;
24
+ protected readonly notificationRepository_: typeof NotificationRepository;
25
+ protected readonly notificationProviderRepository_: typeof NotificationProviderRepository;
26
+ constructor(container: InjectedDependencies);
19
27
  /**
20
28
  * Registers an attachment generator to the service. The generator can be
21
29
  * used to generate on demand invoices or other documents.
22
- * @param {object} service
23
- */
24
- registerAttachmentGenerator(service: object): void;
25
- /**
26
- * Sets the service's manager to a given transaction manager.
27
- * @param {EntityManager} transactionManager - the manager to use
28
- * @return {NotificationService} a cloned notification service
30
+ * @param service the service to assign to the attachmentGenerator
29
31
  */
30
- withTransaction(transactionManager: EntityManager): NotificationService;
32
+ registerAttachmentGenerator(service: unknown): void;
31
33
  /**
32
34
  * Takes a list of notification provider ids and persists them in the database.
33
- * @param {Array<string>} providers - a list of provider ids
35
+ * @param providerIds - a list of provider ids
34
36
  */
35
- registerInstalledProviders(providers: Array<string>): Promise<void>;
37
+ registerInstalledProviders(providerIds: string[]): Promise<void>;
36
38
  /**
37
39
  * Retrieves a list of notifications.
38
- * @param {object} selector - the params to select the notifications by.
39
- * @param {object} config - the configuration to apply to the query
40
- * @return {Array<Notification>} the notifications that satisfy the query.
40
+ * @param selector - the params to select the notifications by.
41
+ * @param config - the configuration to apply to the query
42
+ * @return the notifications that satisfy the query.
41
43
  */
42
- list(selector: object, config?: object): Array<Notification>;
44
+ list(selector: Selector<Notification>, config?: FindConfig<Notification>): Promise<Notification[]>;
43
45
  /**
44
46
  * Retrieves a notification with a given id
45
- * @param {string} id - the id of the notification
46
- * @param {object} config - the configuration to apply to the query
47
- * @return {Notification} the notification
47
+ * @param id - the id of the notification
48
+ * @param config - the configuration to apply to the query
49
+ * @return the notification
48
50
  */
49
- retrieve(id: string, config?: object): Notification;
51
+ retrieve(id: string, config?: FindConfig<Notification>): Promise<Notification | never>;
50
52
  /**
51
53
  * Subscribes a given provider to an event.
52
- * @param {string} eventName - the event to subscribe to
53
- * @param {string} providerId - the provider that the event will be sent to
54
+ * @param eventName - the event to subscribe to
55
+ * @param providerId - the provider that the event will be sent to
54
56
  */
55
57
  subscribe(eventName: string, providerId: string): void;
56
58
  /**
57
59
  * Finds a provider with a given id. Will throw a NOT_FOUND error if the
58
60
  * resolution fails.
59
- * @param {string} id - the id of the provider
60
- * @return {NotificationProvider} the notification provider
61
+ * @param id - the id of the provider
62
+ * @return the notification provider
61
63
  */
62
- retrieveProvider_(id: string): NotificationProvider;
64
+ protected retrieveProvider_(id: string): AbstractNotificationService<never>;
63
65
  /**
64
66
  * Handles an event by relaying the event data to the subscribing providers.
65
67
  * The result of the notification send will be persisted in the database in
66
68
  * order to allow for resends. Will log any errors that are encountered.
67
- * @param {string} eventName - the event to handle
68
- * @param {object} data - the data the event was sent with
69
- * @return {Promise} - the result of notification subscribed
69
+ * @param eventName - the event to handle
70
+ * @param data - the data the event was sent with
71
+ * @return the result of notification subscribed
70
72
  */
71
- handleEvent(eventName: string, data: object): Promise<any>;
73
+ handleEvent(eventName: string, data: Record<string, unknown>): Promise<void | undefined | Notification[]>;
72
74
  /**
73
75
  * Sends a notification, by calling the given provider's sendNotification
74
76
  * method. Persists the Notification in the database.
75
- * @param {string} event - the name of the event
76
- * @param {object} eventData - the data the event was sent with
77
- * @param {string} providerId - the provider that should hande the event.
78
- * @return {Notification} the created notification
77
+ * @param event - the name of the event
78
+ * @param eventData - the data the event was sent with
79
+ * @param providerId - the provider that should hande the event.
80
+ * @return the created notification
79
81
  */
80
- send(event: string, eventData: object, providerId: string): Notification;
82
+ send(event: string, eventData: Record<string, unknown>, providerId: string): Promise<Notification | undefined>;
81
83
  /**
82
84
  * Resends a notification by retrieving a prior notification and calling the
83
85
  * underlying provider's resendNotification method.
@@ -86,5 +88,6 @@ declare class NotificationService extends NotificationService_base {
86
88
  * send
87
89
  * @return {Notification} the newly created notification
88
90
  */
89
- resend(id: string, config?: object): Notification;
91
+ resend(id: string, config?: FindConfig<Notification>): Promise<Notification>;
90
92
  }
93
+ export default NotificationService;