@medusajs/order 0.1.3 → 1.0.0-rc-20241001083650

Sign up to get free protection for your applications and to get access to all the features.
Files changed (379) hide show
  1. package/dist/index.d.ts +6 -8
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +4 -26
  4. package/dist/index.js.map +1 -1
  5. package/dist/joiner-config.d.ts +2 -5
  6. package/dist/joiner-config.d.ts.map +1 -0
  7. package/dist/joiner-config.js +21 -28
  8. package/dist/joiner-config.js.map +1 -1
  9. package/dist/migrations/Migration20240219102530.d.ts +1 -0
  10. package/dist/migrations/Migration20240219102530.d.ts.map +1 -0
  11. package/dist/migrations/Migration20240219102530.js +53 -19
  12. package/dist/migrations/Migration20240219102530.js.map +1 -1
  13. package/dist/migrations/Migration20240604100512.d.ts +5 -0
  14. package/dist/migrations/Migration20240604100512.d.ts.map +1 -0
  15. package/dist/migrations/Migration20240604100512.js +371 -0
  16. package/dist/migrations/Migration20240604100512.js.map +1 -0
  17. package/dist/migrations/Migration20240715102100.d.ts +5 -0
  18. package/dist/migrations/Migration20240715102100.d.ts.map +1 -0
  19. package/dist/migrations/Migration20240715102100.js +15 -0
  20. package/dist/migrations/Migration20240715102100.js.map +1 -0
  21. package/dist/migrations/Migration20240715174100.d.ts +5 -0
  22. package/dist/migrations/Migration20240715174100.d.ts.map +1 -0
  23. package/dist/migrations/Migration20240715174100.js +21 -0
  24. package/dist/migrations/Migration20240715174100.js.map +1 -0
  25. package/dist/migrations/Migration20240716081800.d.ts +5 -0
  26. package/dist/migrations/Migration20240716081800.d.ts.map +1 -0
  27. package/dist/migrations/Migration20240716081800.js +67 -0
  28. package/dist/migrations/Migration20240716081800.js.map +1 -0
  29. package/dist/migrations/Migration20240801085921.d.ts +5 -0
  30. package/dist/migrations/Migration20240801085921.d.ts.map +1 -0
  31. package/dist/migrations/Migration20240801085921.js +30 -0
  32. package/dist/migrations/Migration20240801085921.js.map +1 -0
  33. package/dist/migrations/Migration20240821164505.d.ts +6 -0
  34. package/dist/migrations/Migration20240821164505.d.ts.map +1 -0
  35. package/dist/migrations/Migration20240821164505.js +26 -0
  36. package/dist/migrations/Migration20240821164505.js.map +1 -0
  37. package/dist/migrations/Migration20240821170920.d.ts +6 -0
  38. package/dist/migrations/Migration20240821170920.d.ts.map +1 -0
  39. package/dist/migrations/Migration20240821170920.js +18 -0
  40. package/dist/migrations/Migration20240821170920.js.map +1 -0
  41. package/dist/migrations/Migration20240827133639.d.ts +6 -0
  42. package/dist/migrations/Migration20240827133639.d.ts.map +1 -0
  43. package/dist/migrations/Migration20240827133639.js +17 -0
  44. package/dist/migrations/Migration20240827133639.js.map +1 -0
  45. package/dist/migrations/Migration20240902195921.d.ts +6 -0
  46. package/dist/migrations/Migration20240902195921.d.ts.map +1 -0
  47. package/dist/migrations/Migration20240902195921.js +16 -0
  48. package/dist/migrations/Migration20240902195921.js.map +1 -0
  49. package/dist/migrations/Migration20240913092514.d.ts +6 -0
  50. package/dist/migrations/Migration20240913092514.d.ts.map +1 -0
  51. package/dist/migrations/Migration20240913092514.js +17 -0
  52. package/dist/migrations/Migration20240913092514.js.map +1 -0
  53. package/dist/models/address.d.ts +4 -3
  54. package/dist/models/address.d.ts.map +1 -0
  55. package/dist/models/address.js +22 -22
  56. package/dist/models/address.js.map +1 -1
  57. package/dist/models/adjustment-line.d.ts +5 -3
  58. package/dist/models/adjustment-line.d.ts.map +1 -0
  59. package/dist/models/adjustment-line.js +6 -1
  60. package/dist/models/adjustment-line.js.map +1 -1
  61. package/dist/models/claim-item-image.d.ts +19 -0
  62. package/dist/models/claim-item-image.d.ts.map +1 -0
  63. package/dist/models/claim-item-image.js +109 -0
  64. package/dist/models/claim-item-image.js.map +1 -0
  65. package/dist/models/claim-item.d.ts +29 -0
  66. package/dist/models/claim-item.d.ts.map +1 -0
  67. package/dist/models/claim-item.js +157 -0
  68. package/dist/models/claim-item.js.map +1 -0
  69. package/dist/models/claim.d.ts +37 -0
  70. package/dist/models/claim.d.ts.map +1 -0
  71. package/dist/models/claim.js +201 -0
  72. package/dist/models/claim.js.map +1 -0
  73. package/dist/models/exchange-item.d.ts +24 -0
  74. package/dist/models/exchange-item.d.ts.map +1 -0
  75. package/dist/models/exchange-item.js +138 -0
  76. package/dist/models/exchange-item.js.map +1 -0
  77. package/dist/models/exchange.d.ts +35 -0
  78. package/dist/models/exchange.d.ts.map +1 -0
  79. package/dist/models/exchange.js +194 -0
  80. package/dist/models/exchange.js.map +1 -0
  81. package/dist/models/index.d.ts +18 -9
  82. package/dist/models/index.d.ts.map +1 -0
  83. package/dist/models/index.js +26 -10
  84. package/dist/models/index.js.map +1 -1
  85. package/dist/models/line-item-adjustment.d.ts +5 -3
  86. package/dist/models/line-item-adjustment.d.ts.map +1 -0
  87. package/dist/models/line-item-adjustment.js +12 -12
  88. package/dist/models/line-item-adjustment.js.map +1 -1
  89. package/dist/models/line-item-tax-line.d.ts +5 -3
  90. package/dist/models/line-item-tax-line.d.ts.map +1 -0
  91. package/dist/models/line-item-tax-line.js +12 -12
  92. package/dist/models/line-item-tax-line.js.map +1 -1
  93. package/dist/models/line-item.d.ts +11 -8
  94. package/dist/models/line-item.d.ts.map +1 -0
  95. package/dist/models/line-item.js +58 -39
  96. package/dist/models/line-item.js.map +1 -1
  97. package/dist/models/order-change-action.d.ts +17 -6
  98. package/dist/models/order-change-action.d.ts.map +1 -0
  99. package/dist/models/order-change-action.js +110 -8
  100. package/dist/models/order-change-action.js.map +1 -1
  101. package/dist/models/order-change.d.ts +18 -6
  102. package/dist/models/order-change.d.ts.map +1 -0
  103. package/dist/models/order-change.js +108 -6
  104. package/dist/models/order-change.js.map +1 -1
  105. package/dist/models/order-item.d.ts +10 -7
  106. package/dist/models/order-item.d.ts.map +1 -0
  107. package/dist/models/order-item.js +29 -19
  108. package/dist/models/order-item.js.map +1 -1
  109. package/dist/models/order-shipping-method.d.ts +17 -7
  110. package/dist/models/order-shipping-method.d.ts.map +1 -0
  111. package/dist/models/order-shipping-method.js +113 -33
  112. package/dist/models/order-shipping-method.js.map +1 -1
  113. package/dist/models/order-summary.d.ts +7 -8
  114. package/dist/models/order-summary.d.ts.map +1 -0
  115. package/dist/models/order-summary.js +14 -10
  116. package/dist/models/order-summary.js.map +1 -1
  117. package/dist/models/order.d.ts +13 -11
  118. package/dist/models/order.d.ts.map +1 -0
  119. package/dist/models/order.js +12 -2
  120. package/dist/models/order.js.map +1 -1
  121. package/dist/models/return-item.d.ts +31 -0
  122. package/dist/models/return-item.d.ts.map +1 -0
  123. package/dist/models/return-item.js +180 -0
  124. package/dist/models/return-item.js.map +1 -0
  125. package/dist/models/return-reason.d.ts +22 -0
  126. package/dist/models/return-reason.d.ts.map +1 -0
  127. package/dist/models/return-reason.js +122 -0
  128. package/dist/models/return-reason.js.map +1 -0
  129. package/dist/models/return.d.ts +41 -0
  130. package/dist/models/return.d.ts.map +1 -0
  131. package/dist/models/return.js +227 -0
  132. package/dist/models/return.js.map +1 -0
  133. package/dist/models/shipping-method-adjustment.d.ts +5 -3
  134. package/dist/models/shipping-method-adjustment.d.ts.map +1 -0
  135. package/dist/models/shipping-method-adjustment.js +12 -12
  136. package/dist/models/shipping-method-adjustment.js.map +1 -1
  137. package/dist/models/shipping-method-tax-line.d.ts +5 -3
  138. package/dist/models/shipping-method-tax-line.d.ts.map +1 -0
  139. package/dist/models/shipping-method-tax-line.js +12 -12
  140. package/dist/models/shipping-method-tax-line.js.map +1 -1
  141. package/dist/models/shipping-method.d.ts +10 -7
  142. package/dist/models/shipping-method.d.ts.map +1 -0
  143. package/dist/models/shipping-method.js +42 -24
  144. package/dist/models/shipping-method.js.map +1 -1
  145. package/dist/models/tax-line.d.ts +4 -2
  146. package/dist/models/tax-line.d.ts.map +1 -0
  147. package/dist/models/tax-line.js +8 -1
  148. package/dist/models/tax-line.js.map +1 -1
  149. package/dist/models/transaction.d.ts +18 -6
  150. package/dist/models/transaction.d.ts.map +1 -0
  151. package/dist/models/transaction.js +133 -24
  152. package/dist/models/transaction.js.map +1 -1
  153. package/dist/repositories/claim.d.ts +9 -0
  154. package/dist/repositories/claim.d.ts.map +1 -0
  155. package/dist/repositories/claim.js +11 -0
  156. package/dist/repositories/claim.js.map +1 -0
  157. package/dist/repositories/exchange.d.ts +9 -0
  158. package/dist/repositories/exchange.d.ts.map +1 -0
  159. package/dist/repositories/exchange.js +11 -0
  160. package/dist/repositories/exchange.js.map +1 -0
  161. package/dist/repositories/index.d.ts +5 -2
  162. package/dist/repositories/index.d.ts.map +1 -0
  163. package/dist/repositories/index.js +8 -17
  164. package/dist/repositories/index.js.map +1 -1
  165. package/dist/repositories/order.d.ts +2 -4
  166. package/dist/repositories/order.d.ts.map +1 -0
  167. package/dist/repositories/order.js +3 -86
  168. package/dist/repositories/order.js.map +1 -1
  169. package/dist/repositories/return.d.ts +9 -0
  170. package/dist/repositories/return.d.ts.map +1 -0
  171. package/dist/repositories/return.js +11 -0
  172. package/dist/repositories/return.js.map +1 -0
  173. package/dist/schema/index.d.ts +3 -0
  174. package/dist/schema/index.d.ts.map +1 -0
  175. package/dist/schema/index.js +556 -0
  176. package/dist/schema/index.js.map +1 -0
  177. package/dist/services/actions/cancel-claim.d.ts +3 -0
  178. package/dist/services/actions/cancel-claim.d.ts.map +1 -0
  179. package/dist/services/actions/cancel-claim.js +85 -0
  180. package/dist/services/actions/cancel-claim.js.map +1 -0
  181. package/dist/services/actions/cancel-exchange.d.ts +3 -0
  182. package/dist/services/actions/cancel-exchange.d.ts.map +1 -0
  183. package/dist/services/actions/cancel-exchange.js +71 -0
  184. package/dist/services/actions/cancel-exchange.js.map +1 -0
  185. package/dist/services/actions/cancel-fulfillment.d.ts +3 -0
  186. package/dist/services/actions/cancel-fulfillment.d.ts.map +1 -0
  187. package/dist/services/actions/cancel-fulfillment.js +31 -0
  188. package/dist/services/actions/cancel-fulfillment.js.map +1 -0
  189. package/dist/services/actions/cancel-return.d.ts +3 -0
  190. package/dist/services/actions/cancel-return.d.ts.map +1 -0
  191. package/dist/services/actions/cancel-return.js +69 -0
  192. package/dist/services/actions/cancel-return.js.map +1 -0
  193. package/dist/services/actions/create-claim.d.ts +3 -0
  194. package/dist/services/actions/create-claim.d.ts.map +1 -0
  195. package/dist/services/actions/create-claim.js +225 -0
  196. package/dist/services/actions/create-claim.js.map +1 -0
  197. package/dist/services/actions/create-exchange.d.ts +3 -0
  198. package/dist/services/actions/create-exchange.d.ts.map +1 -0
  199. package/dist/services/actions/create-exchange.js +191 -0
  200. package/dist/services/actions/create-exchange.js.map +1 -0
  201. package/dist/services/actions/create-return.d.ts +3 -0
  202. package/dist/services/actions/create-return.d.ts.map +1 -0
  203. package/dist/services/actions/create-return.js +100 -0
  204. package/dist/services/actions/create-return.js.map +1 -0
  205. package/dist/services/actions/index.d.ts +12 -0
  206. package/dist/services/actions/index.d.ts.map +1 -0
  207. package/dist/services/actions/index.js +28 -0
  208. package/dist/services/actions/index.js.map +1 -0
  209. package/dist/services/actions/receive-return.d.ts +3 -0
  210. package/dist/services/actions/receive-return.d.ts.map +1 -0
  211. package/dist/services/actions/receive-return.js +71 -0
  212. package/dist/services/actions/receive-return.js.map +1 -0
  213. package/dist/services/actions/register-delivery.d.ts +3 -0
  214. package/dist/services/actions/register-delivery.d.ts.map +1 -0
  215. package/dist/services/actions/register-delivery.js +29 -0
  216. package/dist/services/actions/register-delivery.js.map +1 -0
  217. package/dist/services/actions/register-fulfillment.d.ts +3 -0
  218. package/dist/services/actions/register-fulfillment.d.ts.map +1 -0
  219. package/dist/services/actions/register-fulfillment.js +29 -0
  220. package/dist/services/actions/register-fulfillment.js.map +1 -0
  221. package/dist/services/actions/register-shipment.d.ts +3 -0
  222. package/dist/services/actions/register-shipment.d.ts.map +1 -0
  223. package/dist/services/actions/register-shipment.js +37 -0
  224. package/dist/services/actions/register-shipment.js.map +1 -0
  225. package/dist/services/index.d.ts +1 -1
  226. package/dist/services/index.d.ts.map +1 -0
  227. package/dist/services/index.js +1 -3
  228. package/dist/services/index.js.map +1 -1
  229. package/dist/services/order-module-service.d.ts +191 -109
  230. package/dist/services/order-module-service.d.ts.map +1 -0
  231. package/dist/services/order-module-service.js +1165 -425
  232. package/dist/services/order-module-service.js.map +1 -1
  233. package/dist/services/order-service.d.ts +6 -5
  234. package/dist/services/order-service.d.ts.map +1 -0
  235. package/dist/services/order-service.js +2 -2
  236. package/dist/services/order-service.js.map +1 -1
  237. package/dist/tsconfig.tsbuildinfo +1 -0
  238. package/dist/types/address.d.ts +2 -1
  239. package/dist/types/address.d.ts.map +1 -0
  240. package/dist/types/index.d.ts +5 -2
  241. package/dist/types/index.d.ts.map +1 -0
  242. package/dist/types/index.js +2 -0
  243. package/dist/types/index.js.map +1 -1
  244. package/dist/types/line-item-adjustment.d.ts +2 -1
  245. package/dist/types/line-item-adjustment.d.ts.map +1 -0
  246. package/dist/types/line-item-tax-line.d.ts +1 -0
  247. package/dist/types/line-item-tax-line.d.ts.map +1 -0
  248. package/dist/types/line-item.d.ts +2 -1
  249. package/dist/types/line-item.d.ts.map +1 -0
  250. package/dist/types/order-change.d.ts +4 -0
  251. package/dist/types/order-change.d.ts.map +1 -0
  252. package/dist/types/order-change.js +3 -0
  253. package/dist/types/order-change.js.map +1 -0
  254. package/dist/types/order-detail.d.ts +3 -2
  255. package/dist/types/order-detail.d.ts.map +1 -0
  256. package/dist/types/order.d.ts +4 -3
  257. package/dist/types/order.d.ts.map +1 -0
  258. package/dist/types/return-reason.d.ts +5 -0
  259. package/dist/types/return-reason.d.ts.map +1 -0
  260. package/dist/types/return-reason.js +3 -0
  261. package/dist/types/return-reason.js.map +1 -0
  262. package/dist/types/shipping-method-adjustment.d.ts +2 -1
  263. package/dist/types/shipping-method-adjustment.d.ts.map +1 -0
  264. package/dist/types/shipping-method-tax-line.d.ts +1 -0
  265. package/dist/types/shipping-method-tax-line.d.ts.map +1 -0
  266. package/dist/types/shipping-method.d.ts +5 -1
  267. package/dist/types/shipping-method.d.ts.map +1 -0
  268. package/dist/types/tax-line.d.ts +2 -1
  269. package/dist/types/tax-line.d.ts.map +1 -0
  270. package/dist/types/transaction.d.ts +2 -1
  271. package/dist/types/transaction.d.ts.map +1 -0
  272. package/dist/types/utils/index.d.ts +41 -23
  273. package/dist/types/utils/index.d.ts.map +1 -0
  274. package/dist/types/utils/index.js +0 -1
  275. package/dist/types/utils/index.js.map +1 -1
  276. package/dist/utils/actions/cancel-item-fulfillment.d.ts +2 -0
  277. package/dist/utils/actions/cancel-item-fulfillment.d.ts.map +1 -0
  278. package/dist/utils/actions/cancel-item-fulfillment.js +34 -0
  279. package/dist/utils/actions/cancel-item-fulfillment.js.map +1 -0
  280. package/dist/utils/actions/cancel-return.d.ts +1 -0
  281. package/dist/utils/actions/cancel-return.d.ts.map +1 -0
  282. package/dist/utils/actions/cancel-return.js +9 -16
  283. package/dist/utils/actions/cancel-return.js.map +1 -1
  284. package/dist/utils/actions/deliver-item.d.ts +2 -0
  285. package/dist/utils/actions/deliver-item.d.ts.map +1 -0
  286. package/dist/utils/actions/deliver-item.js +38 -0
  287. package/dist/utils/actions/deliver-item.js.map +1 -0
  288. package/dist/utils/actions/fulfill-item.d.ts +1 -0
  289. package/dist/utils/actions/fulfill-item.d.ts.map +1 -0
  290. package/dist/utils/actions/fulfill-item.js +8 -12
  291. package/dist/utils/actions/fulfill-item.js.map +1 -1
  292. package/dist/utils/actions/index.d.ts +7 -1
  293. package/dist/utils/actions/index.d.ts.map +1 -0
  294. package/dist/utils/actions/index.js +6 -1
  295. package/dist/utils/actions/index.js.map +1 -1
  296. package/dist/utils/actions/item-add.d.ts +1 -0
  297. package/dist/utils/actions/item-add.d.ts.map +1 -0
  298. package/dist/utils/actions/item-add.js +17 -26
  299. package/dist/utils/actions/item-add.js.map +1 -1
  300. package/dist/utils/actions/item-remove.d.ts +1 -0
  301. package/dist/utils/actions/item-remove.d.ts.map +1 -0
  302. package/dist/utils/actions/item-remove.js +10 -30
  303. package/dist/utils/actions/item-remove.js.map +1 -1
  304. package/dist/utils/actions/item-update.d.ts +2 -0
  305. package/dist/utils/actions/item-update.d.ts.map +1 -0
  306. package/dist/utils/actions/item-update.js +37 -0
  307. package/dist/utils/actions/item-update.js.map +1 -0
  308. package/dist/utils/actions/receive-damaged-return-item.d.ts +1 -0
  309. package/dist/utils/actions/receive-damaged-return-item.d.ts.map +1 -0
  310. package/dist/utils/actions/receive-damaged-return-item.js +11 -37
  311. package/dist/utils/actions/receive-damaged-return-item.js.map +1 -1
  312. package/dist/utils/actions/receive-return-item.d.ts +1 -0
  313. package/dist/utils/actions/receive-return-item.d.ts.map +1 -0
  314. package/dist/utils/actions/receive-return-item.js +9 -38
  315. package/dist/utils/actions/receive-return-item.js.map +1 -1
  316. package/dist/utils/actions/reinstate-item.d.ts +2 -0
  317. package/dist/utils/actions/reinstate-item.d.ts.map +1 -0
  318. package/dist/utils/actions/reinstate-item.js +32 -0
  319. package/dist/utils/actions/reinstate-item.js.map +1 -0
  320. package/dist/utils/actions/return-item.d.ts +1 -0
  321. package/dist/utils/actions/return-item.d.ts.map +1 -0
  322. package/dist/utils/actions/return-item.js +10 -15
  323. package/dist/utils/actions/return-item.js.map +1 -1
  324. package/dist/utils/actions/ship-item.d.ts +1 -0
  325. package/dist/utils/actions/ship-item.d.ts.map +1 -0
  326. package/dist/utils/actions/ship-item.js +8 -12
  327. package/dist/utils/actions/ship-item.js.map +1 -1
  328. package/dist/utils/actions/shipping-add.d.ts +1 -0
  329. package/dist/utils/actions/shipping-add.d.ts.map +1 -0
  330. package/dist/utils/actions/shipping-add.js +18 -18
  331. package/dist/utils/actions/shipping-add.js.map +1 -1
  332. package/dist/utils/actions/shipping-remove.d.ts +2 -0
  333. package/dist/utils/actions/shipping-remove.d.ts.map +1 -0
  334. package/dist/utils/actions/shipping-remove.js +22 -0
  335. package/dist/utils/actions/shipping-remove.js.map +1 -0
  336. package/dist/utils/actions/write-off-item.d.ts +1 -0
  337. package/dist/utils/actions/write-off-item.d.ts.map +1 -0
  338. package/dist/utils/actions/write-off-item.js +8 -12
  339. package/dist/utils/actions/write-off-item.js.map +1 -1
  340. package/dist/utils/apply-order-changes.d.ts +18 -0
  341. package/dist/utils/apply-order-changes.d.ts.map +1 -0
  342. package/dist/utils/apply-order-changes.js +98 -0
  343. package/dist/utils/apply-order-changes.js.map +1 -0
  344. package/dist/utils/base-repository-find.d.ts +3 -0
  345. package/dist/utils/base-repository-find.d.ts.map +1 -0
  346. package/dist/utils/base-repository-find.js +154 -0
  347. package/dist/utils/base-repository-find.js.map +1 -0
  348. package/dist/utils/calculate-order-change.d.ts +12 -6
  349. package/dist/utils/calculate-order-change.d.ts.map +1 -0
  350. package/dist/utils/calculate-order-change.js +56 -187
  351. package/dist/utils/calculate-order-change.js.map +1 -1
  352. package/dist/utils/index.d.ts +4 -1
  353. package/dist/utils/index.d.ts.map +1 -0
  354. package/dist/utils/index.js +3 -1
  355. package/dist/utils/index.js.map +1 -1
  356. package/dist/utils/set-action-reference.d.ts +2 -0
  357. package/dist/utils/set-action-reference.d.ts.map +1 -0
  358. package/dist/utils/set-action-reference.js +10 -0
  359. package/dist/utils/set-action-reference.js.map +1 -0
  360. package/dist/utils/transform-order.d.ts +5 -4
  361. package/dist/utils/transform-order.d.ts.map +1 -0
  362. package/dist/utils/transform-order.js +138 -21
  363. package/dist/utils/transform-order.js.map +1 -1
  364. package/package.json +20 -21
  365. package/dist/module-definition.d.ts +0 -2
  366. package/dist/module-definition.js +0 -59
  367. package/dist/module-definition.js.map +0 -1
  368. package/dist/scripts/bin/run-seed.d.ts +0 -3
  369. package/dist/scripts/bin/run-seed.js +0 -49
  370. package/dist/scripts/bin/run-seed.js.map +0 -1
  371. package/dist/services/order-change-service.d.ts +0 -15
  372. package/dist/services/order-change-service.js +0 -96
  373. package/dist/services/order-change-service.js.map +0 -1
  374. package/dist/utils/action-key.d.ts +0 -13
  375. package/dist/utils/action-key.js +0 -18
  376. package/dist/utils/action-key.js.map +0 -1
  377. package/dist/utils/actions/cancel.d.ts +0 -1
  378. package/dist/utils/actions/cancel.js +0 -8
  379. package/dist/utils/actions/cancel.js.map +0 -1
@@ -0,0 +1 @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;QAClC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO;KACR,EACD,aAAa,CACd,CAAA;IAED,MAAM,IAAA,kBAAU,EAAC;QACf,IAAI,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;QACpD,IAAI,CAAC,oBAAoB,CAAC,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;QAC7D,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC;KACrD,CAAC,CAAA;IAEF,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Context, OrderTypes } from "@medusajs/framework/types";
2
+ export declare function createReturn(this: any, data: OrderTypes.CreateOrderReturnDTO, sharedContext?: Context): Promise<any>;
3
+ //# sourceMappingURL=create-return.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-return.d.ts","sourceRoot":"","sources":["../../../src/services/actions/create-return.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,UAAU,EACX,MAAM,2BAA2B,CAAA;AA6HlC,wBAAsB,YAAY,CAChC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,UAAU,CAAC,oBAAoB,EACrC,aAAa,CAAC,EAAE,OAAO,gBA8BxB"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReturn = createReturn;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ const _models_1 = require("../../models");
6
+ function createReturnReference(em, data, order) {
7
+ return em.create(_models_1.Return, {
8
+ order_id: data.order_id,
9
+ order_version: order.version,
10
+ status: utils_1.ReturnStatus.REQUESTED,
11
+ no_notification: data.no_notification,
12
+ refund_amount: data.refund_amount ?? null,
13
+ });
14
+ }
15
+ function createReturnItems(em, data, returnRef, actions) {
16
+ return data.items.map((item) => {
17
+ actions.push({
18
+ action: utils_1.ChangeActionType.RETURN_ITEM,
19
+ return_id: returnRef.id,
20
+ internal_note: item.internal_note,
21
+ reference: "return",
22
+ reference_id: returnRef.id,
23
+ details: {
24
+ reference_id: item.id,
25
+ quantity: item.quantity,
26
+ metadata: item.metadata,
27
+ },
28
+ });
29
+ return em.create(_models_1.ReturnItem, {
30
+ reason_id: item.reason_id,
31
+ return_id: returnRef.id,
32
+ item_id: item.id,
33
+ quantity: item.quantity,
34
+ note: item.note,
35
+ metadata: item.metadata,
36
+ });
37
+ });
38
+ }
39
+ async function processShippingMethod(service, data, returnRef, actions, sharedContext) {
40
+ let shippingMethodId;
41
+ if (!(0, utils_1.isDefined)(data.shipping_method)) {
42
+ return;
43
+ }
44
+ if (!(0, utils_1.isString)(data.shipping_method)) {
45
+ const methods = await service.createOrderShippingMethods([
46
+ {
47
+ ...data.shipping_method,
48
+ order_id: data.order_id,
49
+ return_id: returnRef.id,
50
+ },
51
+ ], sharedContext);
52
+ shippingMethodId = methods[0].id;
53
+ }
54
+ else {
55
+ shippingMethodId = data.shipping_method;
56
+ }
57
+ const method = await service.retrieveOrderShippingMethod(shippingMethodId, { relations: ["tax_lines", "adjustments"] }, sharedContext);
58
+ const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
59
+ if (shippingMethodId) {
60
+ actions.push({
61
+ action: utils_1.ChangeActionType.SHIPPING_ADD,
62
+ reference: "order_shipping_method",
63
+ reference_id: shippingMethodId,
64
+ amount: calculatedAmount.total,
65
+ details: {
66
+ order_id: returnRef.order_id,
67
+ return_id: returnRef.id,
68
+ },
69
+ });
70
+ }
71
+ }
72
+ async function createOrderChange(service, data, returnRef, actions, sharedContext) {
73
+ return await service.createOrderChange_({
74
+ order_id: data.order_id,
75
+ return_id: returnRef.id,
76
+ change_type: utils_1.OrderChangeType.RETURN_REQUEST,
77
+ reference: "return",
78
+ reference_id: returnRef.id,
79
+ description: data.description,
80
+ internal_note: data.internal_note,
81
+ created_by: data.created_by,
82
+ metadata: data.metadata,
83
+ actions,
84
+ }, sharedContext);
85
+ }
86
+ async function createReturn(data, sharedContext) {
87
+ const order = await this.orderService_.retrieve(data.order_id, { relations: ["items"] }, sharedContext);
88
+ const em = sharedContext.transactionManager;
89
+ const returnRef = createReturnReference(em, data, order);
90
+ const actions = [];
91
+ returnRef.items = createReturnItems(em, data, returnRef, actions);
92
+ await processShippingMethod(this, data, returnRef, actions, sharedContext);
93
+ const change = await createOrderChange(this, data, returnRef, actions, sharedContext);
94
+ await (0, utils_1.promiseAll)([
95
+ this.createReturns([returnRef], sharedContext),
96
+ this.confirmOrderChange(change[0].id, sharedContext),
97
+ ]);
98
+ return returnRef;
99
+ }
100
+ //# sourceMappingURL=create-return.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-return.js","sourceRoot":"","sources":["../../../src/services/actions/create-return.ts"],"names":[],"mappings":";;AAiIA,oCAiCC;AA7JD,qDAQkC;AAClC,qCAA4C;AAE5C,SAAS,qBAAqB,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK;IAC5C,OAAO,EAAE,CAAC,MAAM,CAAC,gBAAM,EAAE;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,aAAa,EAAE,KAAK,CAAC,OAAO;QAC5B,MAAM,EAAE,oBAAY,CAAC,SAAS;QAC9B,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,aAAa,EAAG,IAAI,CAAC,aAAyB,IAAI,IAAI;KACvD,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO;IACrD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7B,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,wBAAgB,CAAC,WAAW;YACpC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QAAQ,EACb,EAAE,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,EACxB,aAAa,CACd,CAAA;IAED,MAAM,EAAE,GAAG,aAAc,CAAC,kBAAyB,CAAA;IACnD,MAAM,SAAS,GAAG,qBAAqB,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;IACxD,MAAM,OAAO,GAAiC,EAAE,CAAA;IAEhD,SAAS,CAAC,KAAK,GAAG,iBAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAEjE,MAAM,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;IAE1E,MAAM,MAAM,GAAG,MAAM,iBAAiB,CACpC,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,OAAO,EACP,aAAa,CACd,CAAA;IAED,MAAM,IAAA,kBAAU,EAAC;QACf,IAAI,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;QAC9C,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC;KACrD,CAAC,CAAA;IAEF,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./cancel-claim";
2
+ export * from "./cancel-exchange";
3
+ export * from "./cancel-fulfillment";
4
+ export * from "./cancel-return";
5
+ export * from "./create-claim";
6
+ export * from "./create-exchange";
7
+ export * from "./create-return";
8
+ export * from "./receive-return";
9
+ export * from "./register-delivery";
10
+ export * from "./register-fulfillment";
11
+ export * from "./register-shipment";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/actions/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cancel-claim"), exports);
18
+ __exportStar(require("./cancel-exchange"), exports);
19
+ __exportStar(require("./cancel-fulfillment"), exports);
20
+ __exportStar(require("./cancel-return"), exports);
21
+ __exportStar(require("./create-claim"), exports);
22
+ __exportStar(require("./create-exchange"), exports);
23
+ __exportStar(require("./create-return"), exports);
24
+ __exportStar(require("./receive-return"), exports);
25
+ __exportStar(require("./register-delivery"), exports);
26
+ __exportStar(require("./register-fulfillment"), exports);
27
+ __exportStar(require("./register-shipment"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,oDAAiC;AACjC,uDAAoC;AACpC,kDAA+B;AAC/B,iDAA8B;AAC9B,oDAAiC;AACjC,kDAA+B;AAC/B,mDAAgC;AAChC,sDAAmC;AACnC,yDAAsC;AACtC,sDAAmC"}
@@ -0,0 +1,3 @@
1
+ import { Context, OrderTypes } from "@medusajs/framework/types";
2
+ export declare function receiveReturn(this: any, data: OrderTypes.ReceiveOrderReturnDTO, sharedContext?: Context): Promise<any>;
3
+ //# sourceMappingURL=receive-return.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive-return.d.ts","sourceRoot":"","sources":["../../../src/services/actions/receive-return.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AA8E/D,wBAAsB,aAAa,CACjC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,UAAU,CAAC,qBAAqB,EACtC,aAAa,CAAC,EAAE,OAAO,gBAmCxB"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.receiveReturn = receiveReturn;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ function createReturnItems(data) {
6
+ return data.items.map((item) => ({
7
+ action: utils_1.ChangeActionType.RECEIVE_RETURN_ITEM,
8
+ internal_note: item.internal_note,
9
+ reference: data.reference,
10
+ reference_id: data.reference_id,
11
+ details: {
12
+ reference_id: item.id,
13
+ quantity: item.quantity,
14
+ },
15
+ }));
16
+ }
17
+ async function createOrderChange(service, data, returnEntry, items, sharedContext) {
18
+ return await service.createOrderChange_({
19
+ order_id: returnEntry.order_id,
20
+ return_id: returnEntry.id,
21
+ reference: "return",
22
+ reference_id: returnEntry.id,
23
+ change_type: utils_1.OrderChangeType.RETURN_RECEIVE,
24
+ description: data.description,
25
+ internal_note: data.internal_note,
26
+ created_by: data.created_by,
27
+ metadata: data.metadata,
28
+ actions: items,
29
+ }, sharedContext);
30
+ }
31
+ function updateReturnItems(returnEntry, items) {
32
+ return returnEntry.items
33
+ .map((item) => {
34
+ const data = items.find((i) => i.details.reference_id === item.item_id);
35
+ if (!data)
36
+ return;
37
+ const receivedQuantity = utils_1.MathBN.add(item.received_quantity || 0, data.details.quantity);
38
+ item.received_quantity = receivedQuantity;
39
+ return {
40
+ id: item.id,
41
+ received_quantity: receivedQuantity,
42
+ };
43
+ })
44
+ .filter(Boolean);
45
+ }
46
+ function checkAllItemsReceived(returnEntry) {
47
+ return returnEntry.items.every((item) => utils_1.MathBN.eq(item.received_quantity, item.quantity));
48
+ }
49
+ function getReturnUpdateData(hasReceivedAllItems) {
50
+ return hasReceivedAllItems
51
+ ? { status: utils_1.ReturnStatus.RECEIVED, received_at: new Date() }
52
+ : { status: utils_1.ReturnStatus.PARTIALLY_RECEIVED };
53
+ }
54
+ async function receiveReturn(data, sharedContext) {
55
+ const returnEntry = await this.retrieveReturn(data.return_id, {
56
+ select: ["id", "order_id"],
57
+ relations: ["items"],
58
+ }, sharedContext);
59
+ const items = createReturnItems(data);
60
+ const change = await createOrderChange(this, data, returnEntry, items, sharedContext);
61
+ await this.confirmOrderChange(change[0].id, sharedContext);
62
+ const retItemsToUpdate = updateReturnItems(returnEntry, items);
63
+ const hasReceivedAllItems = checkAllItemsReceived(returnEntry);
64
+ const retData = getReturnUpdateData(hasReceivedAllItems);
65
+ const [returnRef] = await (0, utils_1.promiseAll)([
66
+ this.updateReturns({ selector: { id: returnEntry.id }, data: retData }, sharedContext),
67
+ this.updateReturnItems(retItemsToUpdate, sharedContext),
68
+ ]);
69
+ return returnRef;
70
+ }
71
+ //# sourceMappingURL=receive-return.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receive-return.js","sourceRoot":"","sources":["../../../src/services/actions/receive-return.ts"],"names":[],"mappings":";;AA8EA,sCAsCC;AAnHD,qDAMkC;AAElC,SAAS,iBAAiB,CAAC,IAAI;IAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/B,MAAM,EAAE,wBAAgB,CAAC,mBAAmB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A;IAC9D,MAAM,OAAO,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAAA;IAExD,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,IAAA,kBAAU,EAAC;QACnC,IAAI,CAAC,aAAa,CAChB,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,WAAW,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EACnD,aAAa,CACd;QACD,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,EAAE,aAAa,CAAC;KACxD,CAAC,CAAA;IAEF,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Context, OrderTypes } from "@medusajs/framework/types";
2
+ export declare function registerDelivery(this: any, data: OrderTypes.RegisterOrderDeliveryDTO, sharedContext?: Context): Promise<void>;
3
+ //# sourceMappingURL=register-delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-delivery.d.ts","sourceRoot":"","sources":["../../../src/services/actions/register-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG/D,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,UAAU,CAAC,wBAAwB,EACzC,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerDelivery = registerDelivery;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ async function registerDelivery(data, sharedContext) {
6
+ const items = data.items?.map((item) => {
7
+ return {
8
+ action: utils_1.ChangeActionType.DELIVER_ITEM,
9
+ internal_note: item.internal_note,
10
+ reference: data.reference,
11
+ reference_id: data.reference_id,
12
+ details: {
13
+ reference_id: item.id,
14
+ quantity: item.quantity,
15
+ metadata: item.metadata,
16
+ },
17
+ };
18
+ });
19
+ const change = await this.createOrderChange_({
20
+ order_id: data.order_id,
21
+ description: data.description,
22
+ internal_note: data.internal_note,
23
+ created_by: data.created_by,
24
+ metadata: data.metadata,
25
+ actions: items,
26
+ }, sharedContext);
27
+ await this.confirmOrderChange(change[0].id, sharedContext);
28
+ }
29
+ //# sourceMappingURL=register-delivery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-delivery.js","sourceRoot":"","sources":["../../../src/services/actions/register-delivery.ts"],"names":[],"mappings":";;AAGA,4CAgCC;AAlCD,qDAA4D;AAErD,KAAK,UAAU,gBAAgB,CAEpC,IAAyC,EACzC,aAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,OAAO;YACL,MAAM,EAAE,wBAAgB,CAAC,YAAY;YACrC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,EAAE;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAC1C;QACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,KAAK;KACf,EACD,aAAa,CACd,CAAA;IAED,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Context, OrderTypes } from "@medusajs/framework/types";
2
+ export declare function registerFulfillment(this: any, data: OrderTypes.RegisterOrderFulfillmentDTO, sharedContext?: Context): Promise<void>;
3
+ //# sourceMappingURL=register-fulfillment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-fulfillment.d.ts","sourceRoot":"","sources":["../../../src/services/actions/register-fulfillment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAG/D,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,UAAU,CAAC,2BAA2B,EAC5C,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerFulfillment = registerFulfillment;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ async function registerFulfillment(data, sharedContext) {
6
+ const items = data.items.map((item) => {
7
+ return {
8
+ action: utils_1.ChangeActionType.FULFILL_ITEM,
9
+ internal_note: item.internal_note,
10
+ reference: data.reference,
11
+ reference_id: data.reference_id,
12
+ details: {
13
+ reference_id: item.id,
14
+ quantity: item.quantity,
15
+ metadata: item.metadata,
16
+ },
17
+ };
18
+ });
19
+ const change = await this.createOrderChange_({
20
+ order_id: data.order_id,
21
+ description: data.description,
22
+ internal_note: data.internal_note,
23
+ created_by: data.created_by,
24
+ metadata: data.metadata,
25
+ actions: items,
26
+ }, sharedContext);
27
+ await this.confirmOrderChange(change[0].id, sharedContext);
28
+ }
29
+ //# sourceMappingURL=register-fulfillment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-fulfillment.js","sourceRoot":"","sources":["../../../src/services/actions/register-fulfillment.ts"],"names":[],"mappings":";;AAGA,kDAgCC;AAlCD,qDAA4D;AAErD,KAAK,UAAU,mBAAmB,CAEvC,IAA4C,EAC5C,aAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,OAAO;YACL,MAAM,EAAE,wBAAgB,CAAC,YAAY;YACrC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,EAAE;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAC1C;QACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,KAAK;KACf,EACD,aAAa,CACd,CAAA;IAED,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Context, OrderTypes } from "@medusajs/framework/types";
2
+ export declare function registerShipment(this: any, data: OrderTypes.RegisterOrderShipmentDTO, sharedContext?: Context): Promise<void>;
3
+ //# sourceMappingURL=register-shipment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-shipment.d.ts","sourceRoot":"","sources":["../../../src/services/actions/register-shipment.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,UAAU,EACX,MAAM,2BAA2B,CAAA;AAGlC,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE,UAAU,CAAC,wBAAwB,EACzC,aAAa,CAAC,EAAE,OAAO,GACtB,OAAO,CAAC,IAAI,CAAC,CAsCf"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerShipment = registerShipment;
4
+ const utils_1 = require("@medusajs/framework/utils");
5
+ async function registerShipment(data, sharedContext) {
6
+ let shippingMethodId;
7
+ const actions = data.items.map((item) => {
8
+ return {
9
+ action: utils_1.ChangeActionType.SHIP_ITEM,
10
+ internal_note: item.internal_note,
11
+ reference: data.reference,
12
+ reference_id: data.reference_id,
13
+ details: {
14
+ reference_id: item.id,
15
+ quantity: item.quantity,
16
+ metadata: item.metadata,
17
+ },
18
+ };
19
+ });
20
+ if (shippingMethodId) {
21
+ actions.push({
22
+ action: utils_1.ChangeActionType.SHIPPING_ADD,
23
+ reference: data.reference,
24
+ reference_id: shippingMethodId,
25
+ });
26
+ }
27
+ const change = await this.createOrderChange_({
28
+ order_id: data.order_id,
29
+ description: data.description,
30
+ internal_note: data.internal_note,
31
+ created_by: data.created_by,
32
+ metadata: data.metadata,
33
+ actions,
34
+ }, sharedContext);
35
+ await this.confirmOrderChange(change[0].id, sharedContext);
36
+ }
37
+ //# sourceMappingURL=register-shipment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-shipment.js","sourceRoot":"","sources":["../../../src/services/actions/register-shipment.ts"],"names":[],"mappings":";;AAOA,4CA0CC;AA5CD,qDAA4D;AAErD,KAAK,UAAU,gBAAgB,CAEpC,IAAyC,EACzC,aAAuB;IAEvB,IAAI,gBAAgB,CAAA;IAEpB,MAAM,OAAO,GAAiC,IAAI,CAAC,KAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrE,OAAO;YACL,MAAM,EAAE,wBAAgB,CAAC,SAAS;YAClC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,EAAE;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC;YACX,MAAM,EAAE,wBAAgB,CAAC,YAAY;YACrC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,gBAAgB;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAC1C;QACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO;KACR,EACD,aAAa,CACd,CAAA;IAED,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC"}
@@ -1,3 +1,3 @@
1
- export { default as OrderChangeService } from "./order-change-service";
2
1
  export { default as OrderModuleService } from "./order-module-service";
3
2
  export { default as OrderService } from "./order-service";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
@@ -3,9 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OrderService = exports.OrderModuleService = exports.OrderChangeService = void 0;
7
- var order_change_service_1 = require("./order-change-service");
8
- Object.defineProperty(exports, "OrderChangeService", { enumerable: true, get: function () { return __importDefault(order_change_service_1).default; } });
6
+ exports.OrderService = exports.OrderModuleService = void 0;
9
7
  var order_module_service_1 = require("./order-module-service");
10
8
  Object.defineProperty(exports, "OrderModuleService", { enumerable: true, get: function () { return __importDefault(order_module_service_1).default; } });
11
9
  var order_service_1 = require("./order-service");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,iDAAyD;AAAhD,8HAAA,OAAO,OAAgB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,iDAAyD;AAAhD,8HAAA,OAAO,OAAgB"}