@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
@@ -1,8 +1,49 @@
1
- export default OrderService;
2
- declare const OrderService_base: any;
3
- declare class OrderService extends OrderService_base {
4
- [x: string]: any;
5
- static Events: {
1
+ import { EntityManager } from "typeorm";
2
+ import CustomerService from "./customer";
3
+ import { OrderRepository } from "../repositories/order";
4
+ import PaymentProviderService from "./payment-provider";
5
+ import ShippingOptionService from "./shipping-option";
6
+ import ShippingProfileService from "./shipping-profile";
7
+ import DiscountService from "./discount";
8
+ import FulfillmentProviderService from "./fulfillment-provider";
9
+ import FulfillmentService from "./fulfillment";
10
+ import LineItemService from "./line-item";
11
+ import TotalsService from "./totals";
12
+ import RegionService from "./region";
13
+ import CartService from "./cart";
14
+ import { AddressRepository } from "../repositories/address";
15
+ import GiftCardService from "./gift-card";
16
+ import DraftOrderService from "./draft-order";
17
+ import InventoryService from "./inventory";
18
+ import EventBusService from "./event-bus";
19
+ import { TransactionBaseService } from "../interfaces";
20
+ import { FindConfig, QuerySelector, Selector } from "../types/common";
21
+ import { Address, LineItem, Order, Return, TrackingLink } from "../models";
22
+ import { UpdateOrderInput } from "../types/orders";
23
+ import { CreateShippingMethodDto } from "../types/shipping-options";
24
+ import { FulFillmentItemType } from "../types/fulfillment";
25
+ declare type InjectedDependencies = {
26
+ manager: EntityManager;
27
+ orderRepository: typeof OrderRepository;
28
+ customerService: CustomerService;
29
+ paymentProviderService: PaymentProviderService;
30
+ shippingOptionService: ShippingOptionService;
31
+ shippingProfileService: ShippingProfileService;
32
+ discountService: DiscountService;
33
+ fulfillmentProviderService: FulfillmentProviderService;
34
+ fulfillmentService: FulfillmentService;
35
+ lineItemService: LineItemService;
36
+ totalsService: TotalsService;
37
+ regionService: RegionService;
38
+ cartService: CartService;
39
+ addressRepository: typeof AddressRepository;
40
+ giftCardService: GiftCardService;
41
+ draftOrderService: DraftOrderService;
42
+ inventoryService: InventoryService;
43
+ eventBusService: EventBusService;
44
+ };
45
+ declare class OrderService extends TransactionBaseService<OrderService> {
46
+ static readonly Events: {
6
47
  GIFT_CARD_CREATED: string;
7
48
  PAYMENT_CAPTURED: string;
8
49
  PAYMENT_CAPTURE_FAILED: string;
@@ -20,249 +61,193 @@ declare class OrderService extends OrderService_base {
20
61
  CANCELED: string;
21
62
  COMPLETED: string;
22
63
  };
23
- constructor({ manager, orderRepository, customerService, paymentProviderService, shippingOptionService, shippingProfileService, discountService, fulfillmentProviderService, fulfillmentService, lineItemService, totalsService, regionService, cartService, addressRepository, giftCardService, draftOrderService, inventoryService, eventBusService, }: {
24
- manager: any;
25
- orderRepository: any;
26
- customerService: any;
27
- paymentProviderService: any;
28
- shippingOptionService: any;
29
- shippingProfileService: any;
30
- discountService: any;
31
- fulfillmentProviderService: any;
32
- fulfillmentService: any;
33
- lineItemService: any;
34
- totalsService: any;
35
- regionService: any;
36
- cartService: any;
37
- addressRepository: any;
38
- giftCardService: any;
39
- draftOrderService: any;
40
- inventoryService: any;
41
- eventBusService: any;
42
- });
43
- /** @private @constant {EntityManager} */
44
- private manager_;
45
- /** @private @constant {OrderRepository} */
46
- private orderRepository_;
47
- /** @private @constant {CustomerService} */
48
- private customerService_;
49
- /** @private @constant {PaymentProviderService} */
50
- private paymentProviderService_;
51
- /** @private @constant {ShippingProvileService} */
52
- private shippingProfileService_;
53
- /** @private @constant {FulfillmentProviderService} */
54
- private fulfillmentProviderService_;
55
- /** @private @constant {LineItemService} */
56
- private lineItemService_;
57
- /** @private @constant {TotalsService} */
58
- private totalsService_;
59
- /** @private @constant {RegionService} */
60
- private regionService_;
61
- /** @private @constant {FulfillmentService} */
62
- private fulfillmentService_;
63
- /** @private @constant {DiscountService} */
64
- private discountService_;
65
- /** @private @constant {DiscountService} */
66
- private giftCardService_;
67
- /** @private @constant {EventBus} */
68
- private eventBus_;
69
- /** @private @constant {ShippingOptionService} */
70
- private shippingOptionService_;
71
- /** @private @constant {CartService} */
72
- private cartService_;
73
- /** @private @constant {AddressRepository} */
74
- private addressRepository_;
75
- /** @private @constant {DraftOrderService} */
76
- private draftOrderService_;
77
- /** @private @constant {InventoryService} */
78
- private inventoryService_;
79
- withTransaction(manager: any): OrderService;
80
- /**
81
- * Used to validate order ids. Throws an error if the cast fails
82
- * @param {string} rawId - the raw order id to validate.
83
- * @return {string} the validated id
84
- */
85
- validateId_(rawId: string): string;
64
+ protected manager_: EntityManager;
65
+ protected transactionManager_: EntityManager;
66
+ protected readonly orderRepository_: typeof OrderRepository;
67
+ protected readonly customerService_: CustomerService;
68
+ protected readonly paymentProviderService_: PaymentProviderService;
69
+ protected readonly shippingOptionService_: ShippingOptionService;
70
+ protected readonly shippingProfileService_: ShippingProfileService;
71
+ protected readonly discountService_: DiscountService;
72
+ protected readonly fulfillmentProviderService_: FulfillmentProviderService;
73
+ protected readonly fulfillmentService_: FulfillmentService;
74
+ protected readonly lineItemService_: LineItemService;
75
+ protected readonly totalsService_: TotalsService;
76
+ protected readonly regionService_: RegionService;
77
+ protected readonly cartService_: CartService;
78
+ protected readonly addressRepository_: typeof AddressRepository;
79
+ protected readonly giftCardService_: GiftCardService;
80
+ protected readonly draftOrderService_: DraftOrderService;
81
+ protected readonly inventoryService_: InventoryService;
82
+ protected readonly eventBus_: EventBusService;
83
+ constructor({ manager, orderRepository, customerService, paymentProviderService, shippingOptionService, shippingProfileService, discountService, fulfillmentProviderService, fulfillmentService, lineItemService, totalsService, regionService, cartService, addressRepository, giftCardService, draftOrderService, inventoryService, eventBusService, }: InjectedDependencies);
86
84
  /**
87
- * @param {Object} selector - the query object for find
88
- * @param {Object} config - the config to be used for find
89
- * @return {Promise} the result of the find operation
85
+ * @param selector the query object for find
86
+ * @param config the config to be used for find
87
+ * @return the result of the find operation
90
88
  */
91
- list(selector: any, config?: any): Promise<any>;
92
- listAndCount(selector: any, config?: {
93
- skip: number;
94
- take: number;
95
- order: {
96
- created_at: string;
97
- };
98
- }): Promise<any[]>;
99
- transformQueryForTotals_(config: any): {
100
- select: any;
101
- relations: any;
102
- totalsToSelect: never[];
103
- } | {
104
- relations: any;
105
- select: any[];
106
- totalsToSelect: any;
89
+ list(selector: Selector<Order>, config?: FindConfig<Order>): Promise<Order[]>;
90
+ listAndCount(selector: QuerySelector<Order>, config?: FindConfig<Order>): Promise<[Order[], number]>;
91
+ protected transformQueryForTotals(config: FindConfig<Order>): {
92
+ relations: string[] | undefined;
93
+ select: FindConfig<Order>["select"];
94
+ totalsToSelect: FindConfig<Order>["select"];
107
95
  };
108
96
  /**
109
97
  * Gets an order by id.
110
- * @param {string} orderId - id of order to retrieve
111
- * @param {Object} config - config of order to retrieve
112
- * @return {Promise<Order>} the order document
98
+ * @param orderId - id of order to retrieve
99
+ * @param config - config of order to retrieve
100
+ * @return the order document
113
101
  */
114
- retrieve(orderId: string, config?: any): Promise<Order>;
102
+ retrieve(orderId: string, config?: FindConfig<Order>): Promise<Order>;
115
103
  /**
116
104
  * Gets an order by cart id.
117
- * @param {string} cartId - cart id to find order
118
- * @param {Object} config - the config to be used to find order
119
- * @return {Promise<Order>} the order document
105
+ * @param cartId - cart id to find order
106
+ * @param config - the config to be used to find order
107
+ * @return the order document
120
108
  */
121
- retrieveByCartId(cartId: string, config?: any): Promise<Order>;
109
+ retrieveByCartId(cartId: string, config?: FindConfig<Order>): Promise<Order>;
122
110
  /**
123
111
  * Gets an order by id.
124
- * @param {string} externalId - id of order to retrieve
125
- * @param {object} config - query config to get order by
126
- * @return {Promise<Order>} the order document
112
+ * @param externalId - id of order to retrieve
113
+ * @param config - query config to get order by
114
+ * @return the order document
127
115
  */
128
- retrieveByExternalId(externalId: string, config?: object): Promise<Order>;
116
+ retrieveByExternalId(externalId: string, config?: FindConfig<Order>): Promise<Order>;
129
117
  /**
130
118
  * Checks the existence of an order by cart id.
131
- * @param {string} cartId - cart id to find order
132
- * @return {Promise<Order>} the order document
119
+ * @param cartId - cart id to find order
120
+ * @return the order document
133
121
  */
134
- existsByCartId(cartId: string): Promise<Order>;
122
+ existsByCartId(cartId: string): Promise<boolean>;
135
123
  /**
136
- * @param {string} orderId - id of the order to complete
137
- * @return {Promise} the result of the find operation
124
+ * @param orderId - id of the order to complete
125
+ * @return the result of the find operation
138
126
  */
139
- completeOrder(orderId: string): Promise<any>;
127
+ completeOrder(orderId: string): Promise<Order>;
140
128
  /**
141
129
  * Creates an order from a cart
142
- * @param {string} cartId - id of the cart to create an order from
143
- * @return {Promise} resolves to the creation result.
130
+ * @param cartId - id of the cart to create an order from
131
+ * @return resolves to the creation result.
144
132
  */
145
- createFromCart(cartId: string): Promise<any>;
133
+ createFromCart(cartId: string): Promise<Order | never>;
146
134
  /**
147
135
  * Adds a shipment to the order to indicate that an order has left the
148
136
  * warehouse. Will ask the fulfillment provider for any documents that may
149
137
  * have been created in regards to the shipment.
150
- * @param {string} orderId - the id of the order that has been shipped
151
- * @param {string} fulfillmentId - the fulfillment that has now been shipped
152
- * @param {TrackingLink[] | undefined} trackingLinks - array of tracking numebers
138
+ * @param orderId - the id of the order that has been shipped
139
+ * @param fulfillmentId - the fulfillment that has now been shipped
140
+ * @param trackingLinks - array of tracking numebers
153
141
  * associated with the shipment
154
- * @param {Object} config - the config of the order that has been shipped
155
- * @param {Dictionary<String, String>} metadata - optional metadata to add to
156
- * the fulfillment
157
- * @return {order} the resulting order following the update.
158
- */
159
- createShipment(orderId: string, fulfillmentId: string, trackingLinks: TrackingLink[] | undefined, config?: any): order;
160
- /**
161
- * Creates an order
162
- * @param {object} data - the data to create an order
163
- * @return {Promise} resolves to the creation result.
142
+ * @param config - the config of the order that has been shipped
143
+ * @return the resulting order following the update.
164
144
  */
165
- create(data: object): Promise<any>;
145
+ createShipment(orderId: string, fulfillmentId: string, trackingLinks?: TrackingLink[], config?: {
146
+ no_notification?: boolean;
147
+ metadata: Record<string, unknown>;
148
+ }): Promise<Order>;
166
149
  /**
167
150
  * Updates the order's billing address.
168
- * @param {object} order - the order to update
169
- * @param {object} address - the value to set the billing address to
170
- * @return {Promise} the result of the update operation
151
+ * @param order - the order to update
152
+ * @param address - the value to set the billing address to
153
+ * @return the result of the update operation
171
154
  */
172
- updateBillingAddress_(order: object, address: object): Promise<any>;
155
+ protected updateBillingAddress(order: Order, address: Address): Promise<void>;
173
156
  /**
174
157
  * Updates the order's shipping address.
175
- * @param {object} order - the order to update
176
- * @param {object} address - the value to set the shipping address to
177
- * @return {Promise} the result of the update operation
158
+ * @param order - the order to update
159
+ * @param address - the value to set the shipping address to
160
+ * @return the result of the update operation
178
161
  */
179
- updateShippingAddress_(order: object, address: object): Promise<any>;
180
- addShippingMethod(orderId: any, optionId: any, data: any, config?: {}): Promise<any>;
162
+ protected updateShippingAddress(order: Order, address: Address): Promise<void>;
163
+ addShippingMethod(orderId: string, optionId: string, data?: Record<string, unknown>, config?: CreateShippingMethodDto): Promise<Order>;
181
164
  /**
182
165
  * Updates an order. Metadata updates should
183
166
  * use dedicated method, e.g. `setMetadata` etc. The function
184
167
  * will throw errors if metadata updates are attempted.
185
- * @param {string} orderId - the id of the order. Must be a string that
168
+ * @param orderId - the id of the order. Must be a string that
186
169
  * can be casted to an ObjectId
187
- * @param {object} update - an object with the update values.
188
- * @return {Promise} resolves to the update result.
170
+ * @param update - an object with the update values.
171
+ * @return resolves to the update result.
189
172
  */
190
- update(orderId: string, update: object): Promise<any>;
173
+ update(orderId: string, update: UpdateOrderInput): Promise<Order>;
191
174
  /**
192
175
  * Cancels an order.
193
176
  * Throws if fulfillment process has been initiated.
194
177
  * Throws if payment process has been initiated.
195
- * @param {string} orderId - id of order to cancel.
196
- * @return {Promise} result of the update operation.
178
+ * @param orderId - id of order to cancel.
179
+ * @return result of the update operation.
197
180
  */
198
- cancel(orderId: string): Promise<any>;
181
+ cancel(orderId: string): Promise<Order>;
199
182
  /**
200
183
  * Captures payment for an order.
201
- * @param {string} orderId - id of order to capture payment for.
202
- * @return {Promise} result of the update operation.
184
+ * @param orderId - id of order to capture payment for.
185
+ * @return result of the update operation.
203
186
  */
204
- capturePayment(orderId: string): Promise<any>;
187
+ capturePayment(orderId: string): Promise<Order>;
205
188
  /**
206
189
  * Checks that a given quantity of a line item can be fulfilled. Fails if the
207
190
  * fulfillable quantity is lower than the requested fulfillment quantity.
208
191
  * Fulfillable quantity is calculated by subtracting the already fulfilled
209
192
  * quantity from the quantity that was originally purchased.
210
- * @param {LineItem} item - the line item to check has sufficient fulfillable
193
+ * @param item - the line item to check has sufficient fulfillable
211
194
  * quantity.
212
- * @param {number} quantity - the quantity that is requested to be fulfilled.
213
- * @return {LineItem} a line item that has the requested fulfillment quantity
195
+ * @param quantity - the quantity that is requested to be fulfilled.
196
+ * @return a line item that has the requested fulfillment quantity
214
197
  * set.
215
198
  */
216
- validateFulfillmentLineItem_(item: LineItem, quantity: number): LineItem;
199
+ protected validateFulfillmentLineItem(item: LineItem, quantity: number): LineItem | null;
217
200
  /**
218
201
  * Creates fulfillments for an order.
219
202
  * In a situation where the order has more than one shipping method,
220
203
  * we need to partition the order items, such that they can be sent
221
204
  * to their respective fulfillment provider.
222
- * @param {string} orderId - id of order to cancel.
223
- * @param {Object} itemsToFulfill - items to fulfil.
224
- * @param {Object} config - the config to cancel.
225
- * @return {Promise} result of the update operation.
205
+ * @param orderId - id of order to cancel.
206
+ * @param itemsToFulfill - items to fulfil.
207
+ * @param config - the config to cancel.
208
+ * @return result of the update operation.
226
209
  */
227
- createFulfillment(orderId: string, itemsToFulfill: any, config?: any): Promise<any>;
210
+ createFulfillment(orderId: string, itemsToFulfill: FulFillmentItemType[], config?: {
211
+ no_notification?: boolean;
212
+ metadata?: Record<string, unknown>;
213
+ }): Promise<Order>;
228
214
  /**
229
215
  * Cancels a fulfillment (if related to an order)
230
- * @param {string} fulfillmentId - the ID of the fulfillment to cancel
231
- * @return {Promise} updated order
216
+ * @param fulfillmentId - the ID of the fulfillment to cancel
217
+ * @return updated order
232
218
  */
233
- cancelFulfillment(fulfillmentId: string): Promise<any>;
219
+ cancelFulfillment(fulfillmentId: string): Promise<Order>;
234
220
  /**
235
221
  * Retrieves the order line items, given an array of items.
236
- * @param {Order} order - the order to get line items from
237
- * @param {{ item_id: string, quantity: number }} items - the items to get
238
- * @param {function} transformer - a function to apply to each of the items
222
+ * @param order - the order to get line items from
223
+ * @param items - the items to get
224
+ * @param transformer - a function to apply to each of the items
239
225
  * retrieved from the order, should return a line item. If the transformer
240
226
  * returns an undefined value the line item will be filtered from the
241
227
  * returned array.
242
- * @return {Promise<Array<LineItem>>} the line items generated by the transformer.
228
+ * @return the line items generated by the transformer.
243
229
  */
244
- getFulfillmentItems_(order: Order, items: {
245
- item_id: string;
246
- quantity: number;
247
- }, transformer: Function): Promise<Array<LineItem>>;
230
+ protected getFulfillmentItems(order: Order, items: FulFillmentItemType[], transformer: (item: LineItem | undefined, quantity: number) => unknown): Promise<LineItem[]>;
248
231
  /**
249
232
  * Archives an order. It only alloved, if the order has been fulfilled
250
233
  * and payment has been captured.
251
- * @param {string} orderId - the order to archive
252
- * @return {Promise} the result of the update operation
234
+ * @param orderId - the order to archive
235
+ * @return the result of the update operation
253
236
  */
254
- archive(orderId: string): Promise<any>;
237
+ archive(orderId: string): Promise<Order>;
255
238
  /**
256
239
  * Refunds a given amount back to the customer.
257
- * @param {string} orderId - id of the order to refund.
258
- * @param {float} refundAmount - the amount to refund.
259
- * @param {string} reason - the reason to refund.
260
- * @param {string | undefined} note - note for refund.
261
- * @param {Object} config - the config for refund.
262
- * @return {Promise} the result of the refund operation.
240
+ * @param orderId - id of the order to refund.
241
+ * @param refundAmount - the amount to refund.
242
+ * @param reason - the reason to refund.
243
+ * @param note - note for refund.
244
+ * @param config - the config for refund.
245
+ * @return the result of the refund operation.
263
246
  */
264
- createRefund(orderId: string, refundAmount: float, reason: string, note: string | undefined, config?: any): Promise<any>;
265
- decorateTotals_(order: any, totalsFields?: any[]): Promise<any>;
247
+ createRefund(orderId: string, refundAmount: number, reason: string, note?: string, config?: {
248
+ no_notification?: boolean;
249
+ }): Promise<Order>;
250
+ protected decorateTotals(order: Order, totalsFields?: string[]): Promise<Order>;
266
251
  /**
267
252
  * Handles receiving a return. This will create a
268
253
  * refund to the customer. If the returned items don't match the requested
@@ -271,17 +256,11 @@ declare class OrderService extends OrderService_base {
271
256
  * retuned items are not matching the requested items. Setting the
272
257
  * allowMismatch argument to true, will process the return, ignoring any
273
258
  * mismatches.
274
- * @param {string} orderId - the order to return.
275
- * @param {object} receivedReturn - the received return
276
- * @param {float} customRefundAmount - the custom refund amount return
277
- * @return {Promise} the result of the update operation
278
- */
279
- registerReturnReceived(orderId: string, receivedReturn: object, customRefundAmount: float): Promise<any>;
280
- /**
281
- * Dedicated method to delete metadata for an order.
282
- * @param {string} orderId - the order to delete metadata from.
283
- * @param {string} key - key for metadata field
284
- * @return {Promise} resolves to the updated result.
259
+ * @param orderId - the order to return.
260
+ * @param receivedReturn - the received return
261
+ * @param customRefundAmount - the custom refund amount return
262
+ * @return the result of the update operation
285
263
  */
286
- deleteMetadata(orderId: string, key: string): Promise<any>;
264
+ registerReturnReceived(orderId: string, receivedReturn: Return, customRefundAmount?: number): Promise<Order>;
287
265
  }
266
+ export default OrderService;