@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
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const _models_1 = require("../models");
17
- class OrderChangeService extends utils_1.ModulesSdkUtils.internalModuleServiceFactory(_models_1.OrderChange) {
18
- constructor(container) {
19
- // @ts-ignore
20
- super(...arguments);
21
- this.orderChangeRepository_ = container.orderChangeRepository;
22
- }
23
- async listCurrentOrderChange(orderId, config = {}, sharedContext = {}) {
24
- const allChanges = await super.list({ order_id: orderId }, config ?? {
25
- select: ["order_id", "status", "version"],
26
- order: {
27
- order_id: "ASC",
28
- version: "DESC",
29
- },
30
- });
31
- if (!allChanges.length) {
32
- return [];
33
- }
34
- const lastChanges = [];
35
- const seen = new Set();
36
- for (let i = 0; i < allChanges.length; i++) {
37
- if (seen.has(allChanges[i].order_id)) {
38
- continue;
39
- }
40
- seen.add(allChanges[i].order_id);
41
- if (this.isActive(allChanges[i])) {
42
- lastChanges.push(allChanges[i].id);
43
- }
44
- }
45
- let orderChange;
46
- if (allChanges?.length > 0) {
47
- if (this.isActive(allChanges[0])) {
48
- orderChange = allChanges[0];
49
- }
50
- }
51
- if (!orderChange) {
52
- return [];
53
- }
54
- const relations = (0, utils_1.deduplicate)([...(config.relations ?? []), "actions"]);
55
- config.relations = relations;
56
- const queryConfig = utils_1.ModulesSdkUtils.buildQuery({
57
- id: lastChanges,
58
- order: {
59
- items: {
60
- version: orderChange.version,
61
- },
62
- },
63
- }, config);
64
- return await this.orderChangeRepository_.find(queryConfig, sharedContext);
65
- }
66
- isActive(orderChange) {
67
- return (orderChange.status === utils_1.OrderChangeStatus.PENDING ||
68
- orderChange.status === utils_1.OrderChangeStatus.REQUESTED);
69
- }
70
- async create(data, sharedContext = {}) {
71
- const dataArr = Array.isArray(data) ? data : [data];
72
- const activeOrderEdit = await this.listCurrentOrderChange(dataArr.map((d) => d.order_id), {}, sharedContext);
73
- if (activeOrderEdit.length > 0) {
74
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `An active order change already exists for the order(s) ${activeOrderEdit
75
- .map((a) => a.order_id)
76
- .join(",")}`);
77
- }
78
- return await super.create(dataArr, sharedContext);
79
- }
80
- }
81
- exports.default = OrderChangeService;
82
- __decorate([
83
- (0, utils_1.InjectManager)("orderChangeRepository_"),
84
- __param(2, (0, utils_1.MedusaContext)()),
85
- __metadata("design:type", Function),
86
- __metadata("design:paramtypes", [Object, Object, Object]),
87
- __metadata("design:returntype", Promise)
88
- ], OrderChangeService.prototype, "listCurrentOrderChange", null);
89
- __decorate([
90
- (0, utils_1.InjectTransactionManager)("orderChangeRepository_"),
91
- __param(1, (0, utils_1.MedusaContext)()),
92
- __metadata("design:type", Function),
93
- __metadata("design:paramtypes", [Object, Object]),
94
- __metadata("design:returntype", Promise)
95
- ], OrderChangeService.prototype, "create", null);
96
- //# sourceMappingURL=order-change-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-change-service.js","sourceRoot":"","sources":["../../src/services/order-change-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,2CAQwB;AACxB,qCAAqC;AAMrC,MAAqB,kBAEnB,SAAQ,uBAAe,CAAC,4BAA4B,CACpD,qBAAW,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BACtE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;iBACtB,IAAI,CAAC,GAAG,CAAC,EAAE,CACf,CAAA;SACF;QAED,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IACnD,CAAC;CACF;AApHD,qCAoHC;AAtGO;IADL,IAAA,qBAAa,EAAC,wBAAwB,CAAC;IAIrC,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;gEAyDjB;AAoBK;IADL,IAAA,gCAAwB,EAAC,wBAAwB,CAAC;IAGhD,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;gDAmBjB"}
@@ -1,13 +0,0 @@
1
- export declare enum ChangeActionType {
2
- CANCEL = "CANCEL",
3
- CANCEL_RETURN = "CANCEL_RETURN",
4
- FULFILL_ITEM = "FULFILL_ITEM",
5
- ITEM_ADD = "ITEM_ADD",
6
- ITEM_REMOVE = "ITEM_REMOVE",
7
- RECEIVE_DAMAGED_RETURN_ITEM = "RECEIVE_DAMAGED_RETURN_ITEM",
8
- RECEIVE_RETURN_ITEM = "RECEIVE_RETURN_ITEM",
9
- RETURN_ITEM = "RETURN_ITEM",
10
- SHIPPING_ADD = "SHIPPING_ADD",
11
- SHIP_ITEM = "SHIP_ITEM",
12
- WRITE_OFF_ITEM = "WRITE_OFF_ITEM"
13
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChangeActionType = void 0;
4
- var ChangeActionType;
5
- (function (ChangeActionType) {
6
- ChangeActionType["CANCEL"] = "CANCEL";
7
- ChangeActionType["CANCEL_RETURN"] = "CANCEL_RETURN";
8
- ChangeActionType["FULFILL_ITEM"] = "FULFILL_ITEM";
9
- ChangeActionType["ITEM_ADD"] = "ITEM_ADD";
10
- ChangeActionType["ITEM_REMOVE"] = "ITEM_REMOVE";
11
- ChangeActionType["RECEIVE_DAMAGED_RETURN_ITEM"] = "RECEIVE_DAMAGED_RETURN_ITEM";
12
- ChangeActionType["RECEIVE_RETURN_ITEM"] = "RECEIVE_RETURN_ITEM";
13
- ChangeActionType["RETURN_ITEM"] = "RETURN_ITEM";
14
- ChangeActionType["SHIPPING_ADD"] = "SHIPPING_ADD";
15
- ChangeActionType["SHIP_ITEM"] = "SHIP_ITEM";
16
- ChangeActionType["WRITE_OFF_ITEM"] = "WRITE_OFF_ITEM";
17
- })(ChangeActionType || (exports.ChangeActionType = ChangeActionType = {}));
18
- //# sourceMappingURL=action-key.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-key.js","sourceRoot":"","sources":["../../src/utils/action-key.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAYX;AAZD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,mDAA+B,CAAA;IAC/B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;IACrB,+CAA2B,CAAA;IAC3B,+EAA2D,CAAA;IAC3D,+DAA2C,CAAA;IAC3C,+CAA2B,CAAA;IAC3B,iDAA6B,CAAA;IAC7B,2CAAuB,CAAA;IACvB,qDAAiC,CAAA;AACnC,CAAC,EAZW,gBAAgB,gCAAhB,gBAAgB,QAY3B"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const action_key_1 = require("../action-key");
4
- const calculate_order_change_1 = require("../calculate-order-change");
5
- calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.CANCEL, {
6
- void: true,
7
- });
8
- //# sourceMappingURL=cancel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel.ts"],"names":[],"mappings":";;AAAA,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,MAAM,EAAE;IAChE,IAAI,EAAE,IAAI;CACX,CAAC,CAAA"}