@medusajs/order 0.1.3-snapshot-20240718083016 → 0.1.3-snapshot-20240719133408

Sign up to get free protection for your applications and to get access to all the features.
Files changed (331) 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/migrations/Migration20240219102530.d.ts +1 -0
  6. package/dist/migrations/Migration20240219102530.d.ts.map +1 -0
  7. package/dist/migrations/Migration20240219102530.js +38 -4
  8. package/dist/migrations/Migration20240219102530.js.map +1 -1
  9. package/dist/migrations/Migration20240604100512.d.ts +5 -0
  10. package/dist/migrations/Migration20240604100512.d.ts.map +1 -0
  11. package/dist/migrations/Migration20240604100512.js +364 -0
  12. package/dist/migrations/Migration20240604100512.js.map +1 -0
  13. package/dist/migrations/Migration20240715102100.d.ts +5 -0
  14. package/dist/migrations/Migration20240715102100.d.ts.map +1 -0
  15. package/dist/migrations/Migration20240715102100.js +15 -0
  16. package/dist/migrations/Migration20240715102100.js.map +1 -0
  17. package/dist/migrations/Migration20240715174100.d.ts +5 -0
  18. package/dist/migrations/Migration20240715174100.d.ts.map +1 -0
  19. package/dist/migrations/Migration20240715174100.js +21 -0
  20. package/dist/migrations/Migration20240715174100.js.map +1 -0
  21. package/dist/migrations/Migration20240716081800.d.ts +5 -0
  22. package/dist/migrations/Migration20240716081800.d.ts.map +1 -0
  23. package/dist/migrations/Migration20240716081800.js +67 -0
  24. package/dist/migrations/Migration20240716081800.js.map +1 -0
  25. package/dist/models/address.d.ts +2 -1
  26. package/dist/models/address.d.ts.map +1 -0
  27. package/dist/models/adjustment-line.d.ts +3 -1
  28. package/dist/models/adjustment-line.d.ts.map +1 -0
  29. package/dist/models/adjustment-line.js +5 -0
  30. package/dist/models/adjustment-line.js.map +1 -1
  31. package/dist/models/claim-item-image.d.ts +19 -0
  32. package/dist/models/claim-item-image.d.ts.map +1 -0
  33. package/dist/models/claim-item-image.js +109 -0
  34. package/dist/models/claim-item-image.js.map +1 -0
  35. package/dist/models/claim-item.d.ts +29 -0
  36. package/dist/models/claim-item.d.ts.map +1 -0
  37. package/dist/models/claim-item.js +156 -0
  38. package/dist/models/claim-item.js.map +1 -0
  39. package/dist/models/claim.d.ts +36 -0
  40. package/dist/models/claim.d.ts.map +1 -0
  41. package/dist/models/claim.js +195 -0
  42. package/dist/models/claim.js.map +1 -0
  43. package/dist/models/exchange-item.d.ts +24 -0
  44. package/dist/models/exchange-item.d.ts.map +1 -0
  45. package/dist/models/exchange-item.js +138 -0
  46. package/dist/models/exchange-item.js.map +1 -0
  47. package/dist/models/exchange.d.ts +34 -0
  48. package/dist/models/exchange.d.ts.map +1 -0
  49. package/dist/models/exchange.js +188 -0
  50. package/dist/models/exchange.js.map +1 -0
  51. package/dist/models/index.d.ts +9 -0
  52. package/dist/models/index.d.ts.map +1 -0
  53. package/dist/models/index.js +17 -1
  54. package/dist/models/index.js.map +1 -1
  55. package/dist/models/line-item-adjustment.d.ts +3 -1
  56. package/dist/models/line-item-adjustment.d.ts.map +1 -0
  57. package/dist/models/line-item-adjustment.js +3 -3
  58. package/dist/models/line-item-adjustment.js.map +1 -1
  59. package/dist/models/line-item-tax-line.d.ts +3 -1
  60. package/dist/models/line-item-tax-line.d.ts.map +1 -0
  61. package/dist/models/line-item-tax-line.js +3 -3
  62. package/dist/models/line-item-tax-line.js.map +1 -1
  63. package/dist/models/line-item.d.ts +3 -1
  64. package/dist/models/line-item.d.ts.map +1 -0
  65. package/dist/models/line-item.js +18 -4
  66. package/dist/models/line-item.js.map +1 -1
  67. package/dist/models/order-change-action.d.ts +15 -4
  68. package/dist/models/order-change-action.d.ts.map +1 -0
  69. package/dist/models/order-change-action.js +102 -7
  70. package/dist/models/order-change-action.js.map +1 -1
  71. package/dist/models/order-change.d.ts +17 -5
  72. package/dist/models/order-change.d.ts.map +1 -0
  73. package/dist/models/order-change.js +109 -4
  74. package/dist/models/order-change.js.map +1 -1
  75. package/dist/models/order-item.d.ts +5 -4
  76. package/dist/models/order-item.d.ts.map +1 -0
  77. package/dist/models/order-item.js +13 -13
  78. package/dist/models/order-item.js.map +1 -1
  79. package/dist/models/order-shipping-method.d.ts +14 -4
  80. package/dist/models/order-shipping-method.d.ts.map +1 -0
  81. package/dist/models/order-shipping-method.js +89 -13
  82. package/dist/models/order-shipping-method.js.map +1 -1
  83. package/dist/models/order-summary.d.ts +6 -7
  84. package/dist/models/order-summary.d.ts.map +1 -0
  85. package/dist/models/order-summary.js +9 -6
  86. package/dist/models/order-summary.js.map +1 -1
  87. package/dist/models/order.d.ts +6 -4
  88. package/dist/models/order.d.ts.map +1 -0
  89. package/dist/models/order.js +11 -1
  90. package/dist/models/order.js.map +1 -1
  91. package/dist/models/return-item.d.ts +29 -0
  92. package/dist/models/return-item.d.ts.map +1 -0
  93. package/dist/models/return-item.js +170 -0
  94. package/dist/models/return-item.js.map +1 -0
  95. package/dist/models/return-reason.d.ts +21 -0
  96. package/dist/models/return-reason.d.ts.map +1 -0
  97. package/dist/models/return-reason.js +120 -0
  98. package/dist/models/return-reason.js.map +1 -0
  99. package/dist/models/return.d.ts +39 -0
  100. package/dist/models/return.d.ts.map +1 -0
  101. package/dist/models/return.js +216 -0
  102. package/dist/models/return.js.map +1 -0
  103. package/dist/models/shipping-method-adjustment.d.ts +3 -1
  104. package/dist/models/shipping-method-adjustment.d.ts.map +1 -0
  105. package/dist/models/shipping-method-adjustment.js +3 -3
  106. package/dist/models/shipping-method-adjustment.js.map +1 -1
  107. package/dist/models/shipping-method-tax-line.d.ts +3 -1
  108. package/dist/models/shipping-method-tax-line.d.ts.map +1 -0
  109. package/dist/models/shipping-method-tax-line.js +3 -3
  110. package/dist/models/shipping-method-tax-line.js.map +1 -1
  111. package/dist/models/shipping-method.d.ts +2 -0
  112. package/dist/models/shipping-method.d.ts.map +1 -0
  113. package/dist/models/shipping-method.js +17 -4
  114. package/dist/models/shipping-method.js.map +1 -1
  115. package/dist/models/tax-line.d.ts +2 -0
  116. package/dist/models/tax-line.d.ts.map +1 -0
  117. package/dist/models/tax-line.js +7 -0
  118. package/dist/models/tax-line.js.map +1 -1
  119. package/dist/models/transaction.d.ts +15 -3
  120. package/dist/models/transaction.d.ts.map +1 -0
  121. package/dist/models/transaction.js +109 -4
  122. package/dist/models/transaction.js.map +1 -1
  123. package/dist/repositories/claim.d.ts +9 -0
  124. package/dist/repositories/claim.d.ts.map +1 -0
  125. package/dist/repositories/claim.js +11 -0
  126. package/dist/repositories/claim.js.map +1 -0
  127. package/dist/repositories/exchange.d.ts +9 -0
  128. package/dist/repositories/exchange.d.ts.map +1 -0
  129. package/dist/repositories/exchange.js +11 -0
  130. package/dist/repositories/exchange.js.map +1 -0
  131. package/dist/repositories/index.d.ts +4 -1
  132. package/dist/repositories/index.d.ts.map +1 -0
  133. package/dist/repositories/index.js +7 -16
  134. package/dist/repositories/index.js.map +1 -1
  135. package/dist/repositories/order.d.ts +1 -3
  136. package/dist/repositories/order.d.ts.map +1 -0
  137. package/dist/repositories/order.js +2 -85
  138. package/dist/repositories/order.js.map +1 -1
  139. package/dist/repositories/return.d.ts +9 -0
  140. package/dist/repositories/return.d.ts.map +1 -0
  141. package/dist/repositories/return.js +11 -0
  142. package/dist/repositories/return.js.map +1 -0
  143. package/dist/services/actions/cancel-claim.d.ts +3 -0
  144. package/dist/services/actions/cancel-claim.d.ts.map +1 -0
  145. package/dist/services/actions/cancel-claim.js +107 -0
  146. package/dist/services/actions/cancel-claim.js.map +1 -0
  147. package/dist/services/actions/cancel-exchange.d.ts +3 -0
  148. package/dist/services/actions/cancel-exchange.d.ts.map +1 -0
  149. package/dist/services/actions/cancel-exchange.js +92 -0
  150. package/dist/services/actions/cancel-exchange.js.map +1 -0
  151. package/dist/services/actions/cancel-fulfillment.d.ts +3 -0
  152. package/dist/services/actions/cancel-fulfillment.d.ts.map +1 -0
  153. package/dist/services/actions/cancel-fulfillment.js +32 -0
  154. package/dist/services/actions/cancel-fulfillment.js.map +1 -0
  155. package/dist/services/actions/cancel-return.d.ts +3 -0
  156. package/dist/services/actions/cancel-return.d.ts.map +1 -0
  157. package/dist/services/actions/cancel-return.js +72 -0
  158. package/dist/services/actions/cancel-return.js.map +1 -0
  159. package/dist/services/actions/create-claim.d.ts +3 -0
  160. package/dist/services/actions/create-claim.d.ts.map +1 -0
  161. package/dist/services/actions/create-claim.js +228 -0
  162. package/dist/services/actions/create-claim.js.map +1 -0
  163. package/dist/services/actions/create-exchange.d.ts +3 -0
  164. package/dist/services/actions/create-exchange.d.ts.map +1 -0
  165. package/dist/services/actions/create-exchange.js +193 -0
  166. package/dist/services/actions/create-exchange.js.map +1 -0
  167. package/dist/services/actions/create-return.d.ts +3 -0
  168. package/dist/services/actions/create-return.d.ts.map +1 -0
  169. package/dist/services/actions/create-return.js +102 -0
  170. package/dist/services/actions/create-return.js.map +1 -0
  171. package/dist/services/actions/index.d.ts +11 -0
  172. package/dist/services/actions/index.d.ts.map +1 -0
  173. package/dist/services/actions/index.js +27 -0
  174. package/dist/services/actions/index.js.map +1 -0
  175. package/dist/services/actions/receive-return.d.ts +3 -0
  176. package/dist/services/actions/receive-return.d.ts.map +1 -0
  177. package/dist/services/actions/receive-return.js +72 -0
  178. package/dist/services/actions/receive-return.js.map +1 -0
  179. package/dist/services/actions/register-fulfillment.d.ts +3 -0
  180. package/dist/services/actions/register-fulfillment.d.ts.map +1 -0
  181. package/dist/services/actions/register-fulfillment.js +30 -0
  182. package/dist/services/actions/register-fulfillment.js.map +1 -0
  183. package/dist/services/actions/register-shipment.d.ts +3 -0
  184. package/dist/services/actions/register-shipment.d.ts.map +1 -0
  185. package/dist/services/actions/register-shipment.js +38 -0
  186. package/dist/services/actions/register-shipment.js.map +1 -0
  187. package/dist/services/index.d.ts +1 -1
  188. package/dist/services/index.d.ts.map +1 -0
  189. package/dist/services/index.js +1 -3
  190. package/dist/services/index.js.map +1 -1
  191. package/dist/services/order-module-service.d.ts +138 -67
  192. package/dist/services/order-module-service.d.ts.map +1 -0
  193. package/dist/services/order-module-service.js +993 -241
  194. package/dist/services/order-module-service.js.map +1 -1
  195. package/dist/services/order-service.d.ts +5 -4
  196. package/dist/services/order-service.d.ts.map +1 -0
  197. package/dist/services/order-service.js +1 -1
  198. package/dist/services/order-service.js.map +1 -1
  199. package/dist/types/address.d.ts +1 -0
  200. package/dist/types/address.d.ts.map +1 -0
  201. package/dist/types/index.d.ts +3 -1
  202. package/dist/types/index.d.ts.map +1 -0
  203. package/dist/types/index.js +1 -0
  204. package/dist/types/index.js.map +1 -1
  205. package/dist/types/line-item-adjustment.d.ts +1 -0
  206. package/dist/types/line-item-adjustment.d.ts.map +1 -0
  207. package/dist/types/line-item-tax-line.d.ts +1 -0
  208. package/dist/types/line-item-tax-line.d.ts.map +1 -0
  209. package/dist/types/line-item.d.ts +1 -0
  210. package/dist/types/line-item.d.ts.map +1 -0
  211. package/dist/types/order-change.d.ts +6 -0
  212. package/dist/types/order-change.d.ts.map +1 -0
  213. package/dist/types/order-change.js +3 -0
  214. package/dist/types/order-change.js.map +1 -0
  215. package/dist/types/order-detail.d.ts +2 -1
  216. package/dist/types/order-detail.d.ts.map +1 -0
  217. package/dist/types/order.d.ts +3 -2
  218. package/dist/types/order.d.ts.map +1 -0
  219. package/dist/types/shipping-method-adjustment.d.ts +1 -0
  220. package/dist/types/shipping-method-adjustment.d.ts.map +1 -0
  221. package/dist/types/shipping-method-tax-line.d.ts +1 -0
  222. package/dist/types/shipping-method-tax-line.d.ts.map +1 -0
  223. package/dist/types/shipping-method.d.ts +4 -0
  224. package/dist/types/shipping-method.d.ts.map +1 -0
  225. package/dist/types/tax-line.d.ts +1 -0
  226. package/dist/types/tax-line.d.ts.map +1 -0
  227. package/dist/types/transaction.d.ts +1 -0
  228. package/dist/types/transaction.d.ts.map +1 -0
  229. package/dist/types/utils/index.d.ts +40 -21
  230. package/dist/types/utils/index.d.ts.map +1 -0
  231. package/dist/types/utils/index.js +0 -1
  232. package/dist/types/utils/index.js.map +1 -1
  233. package/dist/utils/actions/cancel-item-fulfillment.d.ts +2 -0
  234. package/dist/utils/actions/cancel-item-fulfillment.d.ts.map +1 -0
  235. package/dist/utils/actions/cancel-item-fulfillment.js +34 -0
  236. package/dist/utils/actions/cancel-item-fulfillment.js.map +1 -0
  237. package/dist/utils/actions/cancel-return.d.ts +1 -0
  238. package/dist/utils/actions/cancel-return.d.ts.map +1 -0
  239. package/dist/utils/actions/cancel-return.js +6 -10
  240. package/dist/utils/actions/cancel-return.js.map +1 -1
  241. package/dist/utils/actions/fulfill-item.d.ts +1 -0
  242. package/dist/utils/actions/fulfill-item.d.ts.map +1 -0
  243. package/dist/utils/actions/fulfill-item.js +6 -10
  244. package/dist/utils/actions/fulfill-item.js.map +1 -1
  245. package/dist/utils/actions/index.d.ts +4 -1
  246. package/dist/utils/actions/index.d.ts.map +1 -0
  247. package/dist/utils/actions/index.js +3 -1
  248. package/dist/utils/actions/index.js.map +1 -1
  249. package/dist/utils/actions/item-add.d.ts +1 -0
  250. package/dist/utils/actions/item-add.d.ts.map +1 -0
  251. package/dist/utils/actions/item-add.js +15 -24
  252. package/dist/utils/actions/item-add.js.map +1 -1
  253. package/dist/utils/actions/item-remove.d.ts +1 -0
  254. package/dist/utils/actions/item-remove.d.ts.map +1 -0
  255. package/dist/utils/actions/item-remove.js +8 -22
  256. package/dist/utils/actions/item-remove.js.map +1 -1
  257. package/dist/utils/actions/receive-damaged-return-item.d.ts +1 -0
  258. package/dist/utils/actions/receive-damaged-return-item.d.ts.map +1 -0
  259. package/dist/utils/actions/receive-damaged-return-item.js +9 -35
  260. package/dist/utils/actions/receive-damaged-return-item.js.map +1 -1
  261. package/dist/utils/actions/receive-return-item.d.ts +1 -0
  262. package/dist/utils/actions/receive-return-item.d.ts.map +1 -0
  263. package/dist/utils/actions/receive-return-item.js +7 -36
  264. package/dist/utils/actions/receive-return-item.js.map +1 -1
  265. package/dist/utils/actions/reinstate-item.d.ts +2 -0
  266. package/dist/utils/actions/reinstate-item.d.ts.map +1 -0
  267. package/dist/utils/actions/reinstate-item.js +32 -0
  268. package/dist/utils/actions/reinstate-item.js.map +1 -0
  269. package/dist/utils/actions/return-item.d.ts +1 -0
  270. package/dist/utils/actions/return-item.d.ts.map +1 -0
  271. package/dist/utils/actions/return-item.js +8 -12
  272. package/dist/utils/actions/return-item.js.map +1 -1
  273. package/dist/utils/actions/ship-item.d.ts +1 -0
  274. package/dist/utils/actions/ship-item.d.ts.map +1 -0
  275. package/dist/utils/actions/ship-item.js +6 -10
  276. package/dist/utils/actions/ship-item.js.map +1 -1
  277. package/dist/utils/actions/shipping-add.d.ts +1 -0
  278. package/dist/utils/actions/shipping-add.d.ts.map +1 -0
  279. package/dist/utils/actions/shipping-add.js +16 -16
  280. package/dist/utils/actions/shipping-add.js.map +1 -1
  281. package/dist/utils/actions/shipping-remove.d.ts +2 -0
  282. package/dist/utils/actions/shipping-remove.d.ts.map +1 -0
  283. package/dist/utils/actions/shipping-remove.js +25 -0
  284. package/dist/utils/actions/shipping-remove.js.map +1 -0
  285. package/dist/utils/actions/write-off-item.d.ts +1 -0
  286. package/dist/utils/actions/write-off-item.d.ts.map +1 -0
  287. package/dist/utils/actions/write-off-item.js +6 -10
  288. package/dist/utils/actions/write-off-item.js.map +1 -1
  289. package/dist/utils/apply-order-changes.d.ts +18 -0
  290. package/dist/utils/apply-order-changes.d.ts.map +1 -0
  291. package/dist/utils/apply-order-changes.js +95 -0
  292. package/dist/utils/apply-order-changes.js.map +1 -0
  293. package/dist/utils/base-repository-find.d.ts +3 -0
  294. package/dist/utils/base-repository-find.d.ts.map +1 -0
  295. package/dist/utils/base-repository-find.js +142 -0
  296. package/dist/utils/base-repository-find.js.map +1 -0
  297. package/dist/utils/calculate-order-change.d.ts +11 -5
  298. package/dist/utils/calculate-order-change.d.ts.map +1 -0
  299. package/dist/utils/calculate-order-change.js +58 -183
  300. package/dist/utils/calculate-order-change.js.map +1 -1
  301. package/dist/utils/index.d.ts +4 -1
  302. package/dist/utils/index.d.ts.map +1 -0
  303. package/dist/utils/index.js +3 -1
  304. package/dist/utils/index.js.map +1 -1
  305. package/dist/utils/set-action-reference.d.ts +2 -0
  306. package/dist/utils/set-action-reference.d.ts.map +1 -0
  307. package/dist/utils/set-action-reference.js +11 -0
  308. package/dist/utils/set-action-reference.js.map +1 -0
  309. package/dist/utils/transform-order.d.ts +4 -2
  310. package/dist/utils/transform-order.d.ts.map +1 -0
  311. package/dist/utils/transform-order.js +131 -17
  312. package/dist/utils/transform-order.js.map +1 -1
  313. package/package.json +8 -14
  314. package/dist/joiner-config.d.ts +0 -5
  315. package/dist/joiner-config.js +0 -36
  316. package/dist/joiner-config.js.map +0 -1
  317. package/dist/module-definition.d.ts +0 -2
  318. package/dist/module-definition.js +0 -59
  319. package/dist/module-definition.js.map +0 -1
  320. package/dist/scripts/bin/run-seed.d.ts +0 -3
  321. package/dist/scripts/bin/run-seed.js +0 -49
  322. package/dist/scripts/bin/run-seed.js.map +0 -1
  323. package/dist/services/order-change-service.d.ts +0 -15
  324. package/dist/services/order-change-service.js +0 -96
  325. package/dist/services/order-change-service.js.map +0 -1
  326. package/dist/utils/action-key.d.ts +0 -13
  327. package/dist/utils/action-key.js +0 -18
  328. package/dist/utils/action-key.js.map +0 -1
  329. package/dist/utils/actions/cancel.d.ts +0 -1
  330. package/dist/utils/actions/cancel.js +0 -8
  331. package/dist/utils/actions/cancel.js.map +0 -1
@@ -1,10 +1,33 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
19
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
20
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
21
  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
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
23
  };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
8
31
  var __metadata = (this && this.__metadata) || function (k, v) {
9
32
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
33
  };
@@ -15,26 +38,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
38
  const types_1 = require("@medusajs/types");
16
39
  const utils_1 = require("@medusajs/utils");
17
40
  const _models_1 = require("../models");
18
- const joiner_config_1 = require("../joiner-config");
19
41
  const utils_2 = require("../utils");
20
- const transform_order_1 = require("../utils/transform-order");
21
- const generateMethodForModels = [
22
- _models_1.Address,
23
- _models_1.LineItem,
24
- _models_1.LineItemAdjustment,
25
- _models_1.LineItemTaxLine,
26
- _models_1.ShippingMethod,
27
- _models_1.ShippingMethodAdjustment,
28
- _models_1.ShippingMethodTaxLine,
29
- _models_1.Transaction,
30
- _models_1.OrderChange,
31
- _models_1.OrderChangeAction,
32
- _models_1.OrderItem,
33
- _models_1.OrderSummary,
34
- _models_1.OrderShippingMethod,
35
- ];
36
- class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.Order, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
37
- constructor({ baseRepository, orderService, addressService, lineItemService, shippingMethodAdjustmentService, shippingMethodService, lineItemAdjustmentService, shippingMethodTaxLineService, lineItemTaxLineService, transactionService, orderChangeService, orderChangeActionService, orderItemService, orderSummaryService, orderShippingMethodService, }, moduleDeclaration) {
42
+ const BundledActions = __importStar(require("./actions"));
43
+ const generateMethodForModels = {
44
+ Order: _models_1.Order,
45
+ Address: _models_1.Address,
46
+ LineItem: _models_1.LineItem,
47
+ LineItemAdjustment: _models_1.LineItemAdjustment,
48
+ LineItemTaxLine: _models_1.LineItemTaxLine,
49
+ ShippingMethod: _models_1.ShippingMethod,
50
+ ShippingMethodAdjustment: _models_1.ShippingMethodAdjustment,
51
+ ShippingMethodTaxLine: _models_1.ShippingMethodTaxLine,
52
+ Transaction: _models_1.Transaction,
53
+ OrderChange: _models_1.OrderChange,
54
+ OrderChangeAction: _models_1.OrderChangeAction,
55
+ OrderItem: _models_1.OrderItem,
56
+ OrderSummary: _models_1.OrderSummary,
57
+ OrderShippingMethod: _models_1.OrderShippingMethod,
58
+ ReturnReason: _models_1.ReturnReason,
59
+ Return: _models_1.Return,
60
+ ReturnItem: _models_1.ReturnItem,
61
+ OrderClaim: _models_1.OrderClaim,
62
+ OrderExchange: _models_1.OrderExchange,
63
+ };
64
+ // TODO: rm template args here, keep it for later to not collide with carlos work at least as little as possible
65
+ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateMethodForModels) {
66
+ constructor({ baseRepository, orderService, addressService, lineItemService, shippingMethodAdjustmentService, shippingMethodService, lineItemAdjustmentService, shippingMethodTaxLineService, lineItemTaxLineService, transactionService, orderChangeService, orderChangeActionService, orderItemService, orderSummaryService, orderShippingMethodService, returnReasonService, returnService, returnItemService, orderClaimService, orderExchangeService, }, moduleDeclaration) {
38
67
  // @ts-ignore
39
68
  super(...arguments);
40
69
  this.moduleDeclaration = moduleDeclaration;
@@ -53,9 +82,11 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
53
82
  this.orderItemService_ = orderItemService;
54
83
  this.orderSummaryService_ = orderSummaryService;
55
84
  this.orderShippingMethodService_ = orderShippingMethodService;
56
- }
57
- __joinerConfig() {
58
- return joiner_config_1.joinerConfig;
85
+ this.returnReasonService_ = returnReasonService;
86
+ this.returnService_ = returnService;
87
+ this.returnItemService_ = returnItemService;
88
+ this.orderClaimService_ = orderClaimService;
89
+ this.orderExchangeService_ = orderExchangeService;
59
90
  }
60
91
  shouldIncludeTotals(config) {
61
92
  const totalFields = [
@@ -76,7 +107,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
76
107
  "shipping_subtotal",
77
108
  "shipping_tax_total",
78
109
  "original_shipping_tax_total",
79
- "original_shipping_tax_subtotal",
110
+ "original_shipping_subtotal",
80
111
  "original_shipping_total",
81
112
  ];
82
113
  const includeTotals = (config?.select ?? []).some((field) => totalFields.includes(field));
@@ -86,8 +117,8 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
86
117
  return includeTotals;
87
118
  }
88
119
  addRelationsToCalculateTotals(config, totalFields) {
89
- config.relations ?? (config.relations = []);
90
- config.select ?? (config.select = []);
120
+ config.relations ??= [];
121
+ config.select ??= [];
91
122
  const requiredFieldsForTotals = [
92
123
  "items",
93
124
  "items.tax_lines",
@@ -104,33 +135,144 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
104
135
  return (!requiredFieldsForTotals.some((val) => val.startsWith(field)) && !totalFields.includes(field));
105
136
  });
106
137
  }
107
- async retrieve(id, config, sharedContext) {
108
- config ?? (config = {});
138
+ // @ts-expect-error
139
+ async retrieveOrder(id, config, sharedContext) {
140
+ config ??= {};
141
+ const includeTotals = this.shouldIncludeTotals(config);
142
+ const order = await super.retrieveOrder(id, config, sharedContext);
143
+ const orderChange = await this.getActiveOrderChange_(order.id, false, sharedContext);
144
+ order.order_change = orderChange;
145
+ return (0, utils_2.formatOrder)(order, {
146
+ entity: _models_1.Order,
147
+ includeTotals,
148
+ });
149
+ }
150
+ // @ts-expect-error
151
+ async listOrders(filters, config, sharedContext) {
152
+ config ??= {};
153
+ const includeTotals = this.shouldIncludeTotals(config);
154
+ const orders = await super.listOrders(filters, config, sharedContext);
155
+ return (0, utils_2.formatOrder)(orders, {
156
+ entity: _models_1.Order,
157
+ includeTotals,
158
+ });
159
+ }
160
+ // @ts-expect-error
161
+ async listAndCountOrders(filters, config, sharedContext) {
162
+ config ??= {};
163
+ const includeTotals = this.shouldIncludeTotals(config);
164
+ const [orders, count] = await super.listAndCountOrders(filters, config, sharedContext);
165
+ return [
166
+ (0, utils_2.formatOrder)(orders, {
167
+ entity: _models_1.Order,
168
+ includeTotals,
169
+ }),
170
+ count,
171
+ ];
172
+ }
173
+ // @ts-ignore
174
+ async retrieveReturn(id, config, sharedContext) {
175
+ config ??= {};
176
+ const includeTotals = this.shouldIncludeTotals(config);
177
+ const returnOrder = await super.retrieveReturn(id, config, sharedContext);
178
+ return (0, utils_2.formatOrder)(returnOrder, {
179
+ entity: _models_1.Return,
180
+ includeTotals,
181
+ });
182
+ }
183
+ // @ts-ignore
184
+ async listReturns(filters, config, sharedContext) {
185
+ config ??= {};
186
+ const includeTotals = this.shouldIncludeTotals(config);
187
+ const returnOrders = await super.listReturns(filters, config, sharedContext);
188
+ return (0, utils_2.formatOrder)(returnOrders, {
189
+ entity: _models_1.Return,
190
+ includeTotals,
191
+ });
192
+ }
193
+ // @ts-ignore
194
+ async listAndCountReturns(filters, config, sharedContext) {
195
+ config ??= {};
196
+ const includeTotals = this.shouldIncludeTotals(config);
197
+ const [returnOrders, count] = await super.listAndCountReturns(filters, config, sharedContext);
198
+ return [
199
+ (0, utils_2.formatOrder)(returnOrders, {
200
+ entity: _models_1.Return,
201
+ includeTotals,
202
+ }),
203
+ count,
204
+ ];
205
+ }
206
+ // @ts-ignore
207
+ async retrieveOrderClaim(id, config, sharedContext) {
208
+ config ??= {};
209
+ const includeTotals = this.shouldIncludeTotals(config);
210
+ const returnOrder = await super.retrieveOrderClaim(id, config, sharedContext);
211
+ return (0, utils_2.formatOrder)(returnOrder, {
212
+ entity: _models_1.OrderClaim,
213
+ includeTotals,
214
+ });
215
+ }
216
+ // @ts-ignore
217
+ async listOrderClaims(filters, config, sharedContext) {
218
+ config ??= {};
219
+ const includeTotals = this.shouldIncludeTotals(config);
220
+ const returnOrders = await super.listOrderClaims(filters, config, sharedContext);
221
+ return (0, utils_2.formatOrder)(returnOrders, {
222
+ entity: _models_1.OrderClaim,
223
+ includeTotals,
224
+ });
225
+ }
226
+ // @ts-ignore
227
+ async listAndCountOrderClaims(filters, config, sharedContext) {
228
+ config ??= {};
229
+ const includeTotals = this.shouldIncludeTotals(config);
230
+ const [returnOrders, count] = await super.listAndCountOrderClaims(filters, config, sharedContext);
231
+ return [
232
+ (0, utils_2.formatOrder)(returnOrders, {
233
+ entity: _models_1.OrderClaim,
234
+ includeTotals,
235
+ }),
236
+ count,
237
+ ];
238
+ }
239
+ // @ts-ignore
240
+ async retrieveOrderExchange(id, config, sharedContext) {
241
+ config ??= {};
109
242
  const includeTotals = this.shouldIncludeTotals(config);
110
- const order = await super.retrieve(id, config, sharedContext);
111
- return (0, transform_order_1.formatOrder)(order, { includeTotals });
243
+ const returnOrder = await super.retrieveOrderExchange(id, config, sharedContext);
244
+ return (0, utils_2.formatOrder)(returnOrder, {
245
+ entity: _models_1.OrderExchange,
246
+ includeTotals,
247
+ });
112
248
  }
113
- async list(filters, config, sharedContext) {
114
- config ?? (config = {});
249
+ // @ts-ignore
250
+ async listOrderExchanges(filters, config, sharedContext) {
251
+ config ??= {};
115
252
  const includeTotals = this.shouldIncludeTotals(config);
116
- const orders = await super.list(filters, config, sharedContext);
117
- return (0, transform_order_1.formatOrder)(orders, {
253
+ const returnOrders = await super.listOrderExchanges(filters, config, sharedContext);
254
+ return (0, utils_2.formatOrder)(returnOrders, {
255
+ entity: _models_1.OrderExchange,
118
256
  includeTotals,
119
257
  });
120
258
  }
121
- async listAndCount(filters, config, sharedContext) {
122
- config ?? (config = {});
259
+ // @ts-ignore
260
+ async listAndCountOrderExchanges(filters, config, sharedContext) {
261
+ config ??= {};
123
262
  const includeTotals = this.shouldIncludeTotals(config);
124
- const [orders, count] = await super.listAndCount(filters, config, sharedContext);
263
+ const [returnOrders, count] = await super.listAndCountOrderExchanges(filters, config, sharedContext);
125
264
  return [
126
- (0, transform_order_1.formatOrder)(orders, { includeTotals }),
265
+ (0, utils_2.formatOrder)(returnOrders, {
266
+ entity: _models_1.OrderExchange,
267
+ includeTotals,
268
+ }),
127
269
  count,
128
270
  ];
129
271
  }
130
- async create(data, sharedContext = {}) {
272
+ async createOrders(data, sharedContext = {}) {
131
273
  const input = Array.isArray(data) ? data : [data];
132
- const orders = await this.create_(input, sharedContext);
133
- const result = await this.list({
274
+ const orders = await this.createOrders_(input, sharedContext);
275
+ const result = await this.listOrders({
134
276
  id: orders.map((p) => p.id),
135
277
  }, {
136
278
  relations: [
@@ -148,7 +290,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
148
290
  }, sharedContext);
149
291
  return (Array.isArray(data) ? result : result[0]);
150
292
  }
151
- async create_(data, sharedContext = {}) {
293
+ async createOrders_(data, sharedContext = {}) {
152
294
  const lineItemsToCreate = [];
153
295
  const createdOrders = [];
154
296
  for (const { items, shipping_methods, ...order } of data) {
@@ -189,14 +331,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
189
331
  }
190
332
  return createdOrders;
191
333
  }
192
- async update(dataOrIdOrSelector, data, sharedContext = {}) {
193
- const result = await this.update_(dataOrIdOrSelector, data, sharedContext);
334
+ async updateOrders(dataOrIdOrSelector, data, sharedContext = {}) {
335
+ const result = await this.updateOrders_(dataOrIdOrSelector, data, sharedContext);
194
336
  const serializedResult = await this.baseRepository_.serialize(result, {
195
337
  populate: true,
196
338
  });
197
339
  return (0, utils_1.isString)(dataOrIdOrSelector) ? serializedResult[0] : serializedResult;
198
340
  }
199
- async update_(dataOrIdOrSelector, data, sharedContext = {}) {
341
+ async updateOrders_(dataOrIdOrSelector, data, sharedContext = {}) {
200
342
  let toUpdate = [];
201
343
  if ((0, utils_1.isString)(dataOrIdOrSelector)) {
202
344
  toUpdate = [
@@ -231,7 +373,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
231
373
  ? orderIdOrData
232
374
  : [orderIdOrData];
233
375
  const allOrderIds = data.map((dt) => dt.order_id);
234
- const order = await this.list({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
376
+ const order = await this.listOrders({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
235
377
  const mapOrderVersion = order.reduce((acc, curr) => {
236
378
  acc[curr.id] = curr.version;
237
379
  return acc;
@@ -249,7 +391,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
249
391
  });
250
392
  }
251
393
  async createLineItems_(orderId, items, sharedContext = {}) {
252
- const order = await this.retrieve(orderId, { select: ["id", "version"] }, sharedContext);
394
+ const order = await this.retrieveOrder(orderId, { select: ["id", "version"] }, sharedContext);
253
395
  const toUpdate = items.map((item) => {
254
396
  return {
255
397
  ...item,
@@ -401,7 +543,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
401
543
  ? orderIdOrData
402
544
  : [orderIdOrData];
403
545
  const allOrderIds = data.map((dt) => dt.order_id);
404
- const order = await this.list({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
546
+ const order = await this.listOrders({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
405
547
  const mapOrderVersion = order.reduce((acc, curr) => {
406
548
  acc[curr.id] = curr.version;
407
549
  return acc;
@@ -410,7 +552,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
410
552
  return {
411
553
  shipping_method: dt,
412
554
  order_id: dt.order_id,
413
- version: mapOrderVersion[dt.order_id],
555
+ return_id: dt.return_id,
556
+ claim_id: dt.claim_id,
557
+ exchange_id: dt.exchange_id,
558
+ version: dt.version ?? mapOrderVersion[dt.order_id],
414
559
  };
415
560
  });
416
561
  methods = await this.createShippingMethodsBulk_(orderShippingMethodData, sharedContext);
@@ -418,12 +563,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
418
563
  return await this.baseRepository_.serialize(methods, { populate: true });
419
564
  }
420
565
  async createShippingMethods_(orderId, data, sharedContext = {}) {
421
- const order = await this.retrieve(orderId, { select: ["id", "version"] }, sharedContext);
422
- const methods = data.map((method) => {
566
+ const order = await this.retrieveOrder(orderId, { select: ["id", "version"] }, sharedContext);
567
+ const methods = data.map((methodData) => {
423
568
  return {
424
- shipping_method: method,
569
+ shipping_method: methodData,
425
570
  order_id: order.id,
426
- version: method.version ?? order.version ?? 1,
571
+ return_id: methodData.return_id,
572
+ claim_id: methodData.claim_id,
573
+ exchange_id: methodData.exchange_id,
574
+ version: methodData.version ?? order.version ?? 1,
427
575
  };
428
576
  });
429
577
  return await this.createShippingMethodsBulk_(methods, sharedContext);
@@ -432,10 +580,38 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
432
580
  const sm = await this.orderShippingMethodService_.create(data, sharedContext);
433
581
  return sm.map((s) => s.shipping_method);
434
582
  }
583
+ // @ts-ignore
584
+ async softDeleteShippingMethods(ids, config, sharedContext) {
585
+ const rel = await super.listOrderShippingMethods({
586
+ shipping_method_id: ids,
587
+ }, {
588
+ select: ["id"],
589
+ }, sharedContext);
590
+ const orderShippingMethodIds = rel.map((r) => r.id);
591
+ const [returned] = await (0, utils_1.promiseAll)([
592
+ super.softDeleteShippingMethods(ids, config, sharedContext),
593
+ super.softDeleteOrderShippingMethods(orderShippingMethodIds, config, sharedContext),
594
+ ]);
595
+ return returned;
596
+ }
597
+ // @ts-ignore
598
+ async restoreShippingMethods(transactionIds, config, sharedContext) {
599
+ const rel = await super.listOrderShippingMethods({
600
+ shipping_method_id: transactionIds,
601
+ }, {
602
+ select: ["id"],
603
+ }, sharedContext);
604
+ const orderShippingMethodIds = rel.map((r) => r.id);
605
+ const [returned] = await (0, utils_1.promiseAll)([
606
+ super.restoreShippingMethods(transactionIds, config, sharedContext),
607
+ super.restoreOrderShippingMethods(orderShippingMethodIds, config, sharedContext),
608
+ ]);
609
+ return returned;
610
+ }
435
611
  async createLineItemAdjustments(orderIdOrData, adjustments, sharedContext = {}) {
436
612
  let addedAdjustments = [];
437
613
  if ((0, utils_1.isString)(orderIdOrData)) {
438
- const order = await this.retrieve(orderIdOrData, { select: ["id"], relations: ["items.item"] }, sharedContext);
614
+ const order = await this.retrieveOrder(orderIdOrData, { select: ["id"], relations: ["items.item"] }, sharedContext);
439
615
  const lineIds = order.items?.map((item) => item.id);
440
616
  for (const adj of adjustments || []) {
441
617
  if (!lineIds?.includes(adj.item_id)) {
@@ -455,7 +631,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
455
631
  });
456
632
  }
457
633
  async setLineItemAdjustments(orderId, adjustments, sharedContext = {}) {
458
- const order = await this.retrieve(orderId, { select: ["id"], relations: ["items.item.adjustments"] }, sharedContext);
634
+ const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["items.item.adjustments"] }, sharedContext);
459
635
  const existingAdjustments = (order.items ?? [])
460
636
  .map((item) => item.adjustments ?? [])
461
637
  .flat()
@@ -479,7 +655,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
479
655
  });
480
656
  }
481
657
  async setShippingMethodAdjustments(orderId, adjustments, sharedContext = {}) {
482
- const order = await this.retrieve(orderId, { select: ["id"], relations: ["shipping_methods.adjustments"] }, sharedContext);
658
+ const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["shipping_methods.adjustments"] }, sharedContext);
483
659
  const existingAdjustments = (order.shipping_methods ?? [])
484
660
  .map((shippingMethod) => shippingMethod.adjustments ?? [])
485
661
  .flat()
@@ -505,7 +681,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
505
681
  async createShippingMethodAdjustments(orderIdOrData, adjustments, sharedContext = {}) {
506
682
  let addedAdjustments = [];
507
683
  if ((0, utils_1.isString)(orderIdOrData)) {
508
- const order = await this.retrieve(orderIdOrData, { select: ["id"], relations: ["shipping_methods"] }, sharedContext);
684
+ const order = await this.retrieveOrder(orderIdOrData, { select: ["id"], relations: ["shipping_methods"] }, sharedContext);
509
685
  const methodIds = order.shipping_methods?.map((method) => method.id);
510
686
  for (const adj of adjustments || []) {
511
687
  if (!methodIds?.includes(adj.shipping_method_id)) {
@@ -550,7 +726,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
550
726
  return serialized;
551
727
  }
552
728
  async setLineItemTaxLines(orderId, taxLines, sharedContext = {}) {
553
- const order = await this.retrieve(orderId, { select: ["id"], relations: ["items.item.tax_lines"] }, sharedContext);
729
+ const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["items.item.tax_lines"] }, sharedContext);
554
730
  const existingTaxLines = (order.items ?? [])
555
731
  .map((item) => item.tax_lines ?? [])
556
732
  .flat()
@@ -590,7 +766,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
590
766
  return serialized;
591
767
  }
592
768
  async setShippingMethodTaxLines(orderId, taxLines, sharedContext = {}) {
593
- const order = await this.retrieve(orderId, { select: ["id"], relations: ["shipping_methods.tax_lines"] }, sharedContext);
769
+ const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["shipping_methods.tax_lines"] }, sharedContext);
594
770
  const existingTaxLines = (order.shipping_methods ?? [])
595
771
  .map((shippingMethod) => shippingMethod.tax_lines ?? [])
596
772
  .flat()
@@ -612,6 +788,42 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
612
788
  populate: true,
613
789
  });
614
790
  }
791
+ async createReturns(data, sharedContext) {
792
+ const created = await this.createOrderRelatedEntity_(data, this.returnService_, sharedContext);
793
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
794
+ populate: true,
795
+ });
796
+ }
797
+ async createOrderClaims(data, sharedContext) {
798
+ const created = await this.createOrderRelatedEntity_(data, this.orderClaimService_, sharedContext);
799
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
800
+ populate: true,
801
+ });
802
+ }
803
+ async createOrderExchanges(data, sharedContext) {
804
+ const created = await this.createOrderRelatedEntity_(data, this.orderExchangeService_, sharedContext);
805
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
806
+ populate: true,
807
+ });
808
+ }
809
+ async createOrderRelatedEntity_(data, service, sharedContext) {
810
+ const data_ = Array.isArray(data) ? data : [data];
811
+ const inputDataMap = data_.reduce((acc, curr) => {
812
+ acc[curr.order_id] = curr;
813
+ return acc;
814
+ }, {});
815
+ const orderIds = data_.map((d) => d.order_id);
816
+ const orders = await this.orderService_.list({ id: orderIds }, { select: ["id", "version"] }, sharedContext);
817
+ if (orders.length !== orderIds.length) {
818
+ const foundOrders = orders.map((o) => o.id);
819
+ const missing = orderIds.filter((id) => !foundOrders.includes(id));
820
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Order could not be found: ${missing.join(", ")}`);
821
+ }
822
+ for (const order of orders) {
823
+ inputDataMap[order.id].order_version = order.version;
824
+ }
825
+ return await service.create(data_, sharedContext);
826
+ }
615
827
  async createOrderChange(data, sharedContext) {
616
828
  const changes = await this.createOrderChange_(data, sharedContext);
617
829
  return await this.baseRepository_.serialize(Array.isArray(data) ? changes : changes[0], {
@@ -622,21 +834,26 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
622
834
  const dataArr = Array.isArray(data) ? data : [data];
623
835
  const orderIds = [];
624
836
  const dataMap = {};
837
+ const orderChanges = await this.listOrderChanges({
838
+ order_id: dataArr.map((data) => data.order_id),
839
+ status: [utils_1.OrderChangeStatus.PENDING, utils_1.OrderChangeStatus.REQUESTED],
840
+ }, {}, sharedContext);
841
+ const orderChangesMap = new Map(orderChanges.map((item) => [item.order_id, item]));
625
842
  for (const change of dataArr) {
626
843
  orderIds.push(change.order_id);
627
844
  dataMap[change.order_id] = change;
628
845
  }
629
- const orders = await this.list({
630
- id: orderIds,
631
- }, {
632
- select: ["id", "version"],
633
- }, sharedContext);
846
+ const orders = await this.orderService_.list({ id: orderIds }, { select: ["id", "version"] }, sharedContext);
634
847
  if (orders.length !== orderIds.length) {
635
848
  const foundOrders = orders.map((o) => o.id);
636
849
  const missing = orderIds.filter((id) => !foundOrders.includes(id));
637
850
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Order could not be found: ${missing.join(", ")}`);
638
851
  }
639
852
  const input = orders.map((order) => {
853
+ const existingOrderChange = orderChangesMap.get(order.id);
854
+ if (existingOrderChange) {
855
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Order (${order.id}) already has an existing active order change`);
856
+ }
640
857
  return {
641
858
  ...dataMap[order.id],
642
859
  version: order.version + 1,
@@ -644,6 +861,98 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
644
861
  });
645
862
  return await this.orderChangeService_.create(input, sharedContext);
646
863
  }
864
+ async previewOrderChange(orderId, sharedContext) {
865
+ const order = await this.retrieveOrder(orderId, {
866
+ select: ["id", "version", "items.detail", "summary", "total"],
867
+ relations: [
868
+ "transactions",
869
+ "items",
870
+ "items.detail",
871
+ "shipping_methods",
872
+ ],
873
+ }, sharedContext);
874
+ if (!order.order_change) {
875
+ return order;
876
+ }
877
+ const orderChange = await super.retrieveOrderChange(order.order_change.id, { relations: ["actions"] }, sharedContext);
878
+ orderChange.actions = orderChange.actions.map((action) => {
879
+ return {
880
+ ...action,
881
+ version: orderChange.version,
882
+ order_id: orderChange.order_id,
883
+ return_id: orderChange.return_id,
884
+ claim_id: orderChange.claim_id,
885
+ exchange_id: orderChange.exchange_id,
886
+ };
887
+ });
888
+ const { itemsToUpsert, shippingMethodsToUpsert, calculatedOrders } = (0, utils_2.applyChangesToOrder)([order], { [order.id]: orderChange.actions }, { addActionReferenceToObject: true });
889
+ const calculated = calculatedOrders[order.id];
890
+ const addedItems = {};
891
+ const addedShippingMethods = {};
892
+ for (const item of calculated.order.items) {
893
+ const isExistingItem = item.id === item.detail?.item_id;
894
+ if (!isExistingItem) {
895
+ addedItems[item.id] = item;
896
+ }
897
+ }
898
+ for (const sm of calculated.order.shipping_methods) {
899
+ if (!(0, utils_1.isDefined)(sm.shipping_option_id)) {
900
+ addedShippingMethods[sm.id] = sm;
901
+ }
902
+ }
903
+ if (Object.keys(addedItems).length > 0) {
904
+ const addedItemDetails = await this.listLineItems({ id: Object.keys(addedItems) }, {
905
+ relations: ["adjustments", "tax_lines"],
906
+ }, sharedContext);
907
+ calculated.order.items.forEach((item, idx) => {
908
+ if (!addedItems[item.id]) {
909
+ return;
910
+ }
911
+ const lineItem = addedItemDetails.find((d) => d.id === item.id);
912
+ const actions = item.actions;
913
+ delete item.actions;
914
+ const newItem = itemsToUpsert.find((d) => d.item_id === item.id);
915
+ calculated.order.items[idx] = {
916
+ ...lineItem,
917
+ actions,
918
+ quantity: newItem.quantity,
919
+ detail: {
920
+ ...newItem,
921
+ ...item,
922
+ },
923
+ };
924
+ });
925
+ }
926
+ if (Object.keys(addedShippingMethods).length > 0) {
927
+ const addedShippingDetails = await this.listShippingMethods({ id: Object.keys(addedShippingMethods) }, {
928
+ relations: ["adjustments", "tax_lines"],
929
+ }, sharedContext);
930
+ calculated.order.shipping_methods.forEach((sm, idx) => {
931
+ if (!addedShippingMethods[sm.id]) {
932
+ return;
933
+ }
934
+ const shippingMethod = addedShippingDetails.find((d) => d.id === sm.id);
935
+ const actions = sm.actions;
936
+ delete sm.actions;
937
+ const newItem = shippingMethodsToUpsert.find((d) => d.id === sm.id);
938
+ sm.shipping_method_id = sm.id;
939
+ delete sm.id;
940
+ calculated.order.shipping_methods[idx] = {
941
+ ...shippingMethod,
942
+ actions,
943
+ detail: {
944
+ ...sm,
945
+ ...newItem,
946
+ },
947
+ };
948
+ });
949
+ }
950
+ const calcOrder = calculated.order;
951
+ (0, utils_1.decorateCartTotals)(calcOrder);
952
+ calcOrder.summary = calculated.summary;
953
+ (0, utils_1.createRawPropertiesFromBigNumber)(calcOrder);
954
+ return calcOrder;
955
+ }
647
956
  async cancelOrderChange(orderChangeIdOrData, sharedContext) {
648
957
  const data = Array.isArray(orderChangeIdOrData)
649
958
  ? orderChangeIdOrData
@@ -683,11 +992,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
683
992
  ...action,
684
993
  version: change.version,
685
994
  order_id: change.order_id,
995
+ return_id: change.return_id,
996
+ claim_id: change.claim_id,
997
+ exchange_id: change.exchange_id,
686
998
  };
687
999
  });
688
1000
  return change.actions;
689
1001
  });
690
- await this.applyOrderChanges_(orderChanges.flat(), sharedContext);
1002
+ return await this.applyOrderChanges_(orderChanges.flat(), sharedContext);
691
1003
  }
692
1004
  async declineOrderChange(orderChangeIdOrData, sharedContext) {
693
1005
  const data = Array.isArray(orderChangeIdOrData)
@@ -708,7 +1020,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
708
1020
  }
709
1021
  async applyPendingOrderActions(orderId, sharedContext) {
710
1022
  const orderIds = Array.isArray(orderId) ? orderId : [orderId];
711
- const orders = await this.list({ id: orderIds }, {
1023
+ const orders = await this.orderService_.list({ id: orderIds }, {
712
1024
  select: ["id", "version"],
713
1025
  }, sharedContext);
714
1026
  const changes = await this.orderChangeActionService_.list({
@@ -719,6 +1031,9 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
719
1031
  select: [
720
1032
  "id",
721
1033
  "order_id",
1034
+ "return_id",
1035
+ "exchange_id",
1036
+ "claim_id",
722
1037
  "ordering",
723
1038
  "version",
724
1039
  "applied",
@@ -734,10 +1049,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
734
1049
  ordering: "ASC",
735
1050
  },
736
1051
  }, sharedContext);
737
- await this.applyOrderChanges_(changes, sharedContext);
1052
+ return await this.applyOrderChanges_(changes, sharedContext);
738
1053
  }
739
1054
  async revertLastVersion(orderId, sharedContext) {
740
- const order = await super.retrieve(orderId, {
1055
+ const order = await super.retrieveOrder(orderId, {
741
1056
  select: ["id", "version"],
742
1057
  }, sharedContext);
743
1058
  if (order.version < 2) {
@@ -791,10 +1106,58 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
791
1106
  version: order.version - 1,
792
1107
  },
793
1108
  }, sharedContext);
1109
+ // Returns
1110
+ await this.returnService_.delete({
1111
+ order_id: order.id,
1112
+ order_version: currentVersion,
1113
+ }, sharedContext);
1114
+ }
1115
+ async getActiveOrderChange_(orderId, includeActions, sharedContext) {
1116
+ const options = {
1117
+ select: [
1118
+ "id",
1119
+ "change_type",
1120
+ "order_id",
1121
+ "return_id",
1122
+ "claim_id",
1123
+ "exchange_id",
1124
+ "version",
1125
+ "requested_at",
1126
+ "requested_by",
1127
+ "status",
1128
+ "description",
1129
+ "internal_note",
1130
+ ],
1131
+ relations: [],
1132
+ order: {},
1133
+ };
1134
+ if (includeActions) {
1135
+ options.select.push("actions");
1136
+ options.relations.push("actions");
1137
+ options.order = {
1138
+ actions: {
1139
+ ordering: "ASC",
1140
+ },
1141
+ };
1142
+ }
1143
+ const [orderChange] = await this.listOrderChanges({
1144
+ order_id: orderId,
1145
+ status: [utils_1.OrderChangeStatus.PENDING, utils_1.OrderChangeStatus.REQUESTED],
1146
+ }, options, sharedContext);
1147
+ return orderChange;
794
1148
  }
795
1149
  async getAndValidateOrderChange_(orderChangeIds, includeActions, sharedContext) {
1150
+ orderChangeIds = (0, utils_1.deduplicate)(orderChangeIds);
796
1151
  const options = {
797
- select: ["id", "order_id", "version", "status"],
1152
+ select: [
1153
+ "id",
1154
+ "order_id",
1155
+ "return_id",
1156
+ "claim_id",
1157
+ "exchange_id",
1158
+ "version",
1159
+ "status",
1160
+ ],
798
1161
  relations: [],
799
1162
  order: {},
800
1163
  };
@@ -832,9 +1195,8 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
832
1195
  const orderChangeMap = {};
833
1196
  const orderChangeIds = dataArr
834
1197
  .map((data, idx) => {
835
- var _a;
836
1198
  if (data.order_change_id) {
837
- orderChangeMap[_a = data.order_change_id] ?? (orderChangeMap[_a] = []);
1199
+ orderChangeMap[data.order_change_id] ??= [];
838
1200
  orderChangeMap[data.order_change_id].push(dataArr[idx]);
839
1201
  }
840
1202
  return data.order_change_id;
@@ -855,7 +1217,6 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
855
1217
  return Array.isArray(data) ? actions : actions[0];
856
1218
  }
857
1219
  async applyOrderChanges_(changeActions, sharedContext) {
858
- var _a;
859
1220
  const actionsMap = {};
860
1221
  const ordersIds = [];
861
1222
  const usedActions = [];
@@ -864,7 +1225,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
864
1225
  continue;
865
1226
  }
866
1227
  ordersIds.push(action.order_id);
867
- actionsMap[_a = action.order_id] ?? (actionsMap[_a] = []);
1228
+ actionsMap[action.order_id] ??= [];
868
1229
  actionsMap[action.order_id].push(action);
869
1230
  usedActions.push({
870
1231
  selector: {
@@ -876,74 +1237,26 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
876
1237
  });
877
1238
  }
878
1239
  if (!ordersIds.length) {
879
- return;
1240
+ return {
1241
+ items: [],
1242
+ shippingMethods: [],
1243
+ };
880
1244
  }
881
- const orders = await this.list({ id: (0, utils_1.deduplicate)(ordersIds) }, {
882
- select: [
883
- "id",
884
- "version",
885
- "items.detail",
1245
+ let orders = await super.listOrders({ id: (0, utils_1.deduplicate)(ordersIds) }, {
1246
+ select: ["id", "version", "items.detail", "summary", "total"],
1247
+ relations: [
886
1248
  "transactions",
887
- "summary",
888
- "total",
1249
+ "items",
1250
+ "items.detail",
1251
+ "shipping_methods",
889
1252
  ],
890
- relations: ["transactions", "items", "items.detail"],
891
1253
  }, sharedContext);
892
- const itemsToUpsert = [];
893
- const shippingMethodsToInsert = [];
894
- const summariesToUpsert = [];
895
- const orderToUpdate = [];
896
- for (const order of orders) {
897
- const calculated = (0, utils_2.calculateOrderChange)({
898
- order: order,
899
- actions: actionsMap[order.id],
900
- transactions: order.transactions,
901
- });
902
- (0, utils_1.createRawPropertiesFromBigNumber)(calculated);
903
- const version = actionsMap[order.id][0].version;
904
- for (const item of calculated.order.items) {
905
- const orderItem = item.detail;
906
- itemsToUpsert.push({
907
- id: orderItem.version === version ? orderItem.id : undefined,
908
- item_id: item.id,
909
- order_id: order.id,
910
- version,
911
- quantity: item.detail.quantity,
912
- fulfilled_quantity: item.detail.fulfilled_quantity,
913
- shipped_quantity: item.detail.shipped_quantity,
914
- return_requested_quantity: item.detail.return_requested_quantity,
915
- return_received_quantity: item.detail.return_received_quantity,
916
- return_dismissed_quantity: item.detail.return_dismissed_quantity,
917
- written_off_quantity: item.detail.written_off_quantity,
918
- metadata: item.detail.metadata,
919
- });
920
- }
921
- const orderSummary = order.summary;
922
- summariesToUpsert.push({
923
- id: orderSummary.version === version ? orderSummary.id : undefined,
924
- order_id: order.id,
925
- version,
926
- totals: calculated.summary,
927
- });
928
- if (version > order.version) {
929
- for (const shippingMethod of order.shipping_methods ?? []) {
930
- const sm = {
931
- ...shippingMethod.detail,
932
- version,
933
- };
934
- delete sm.id;
935
- shippingMethodsToInsert.push(sm);
936
- }
937
- orderToUpdate.push({
938
- selector: {
939
- id: order.id,
940
- },
941
- data: {
942
- version,
943
- },
944
- });
945
- }
946
- }
1254
+ orders = (0, utils_2.formatOrder)(orders, {
1255
+ entity: _models_1.Order,
1256
+ });
1257
+ const { itemsToUpsert, shippingMethodsToUpsert, summariesToUpsert, orderToUpdate, } = (0, utils_2.applyChangesToOrder)(orders, actionsMap, {
1258
+ addActionReferenceToObject: true,
1259
+ });
947
1260
  await (0, utils_1.promiseAll)([
948
1261
  orderToUpdate.length
949
1262
  ? this.orderService_.update(orderToUpdate, sharedContext)
@@ -957,153 +1270,378 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFa
957
1270
  summariesToUpsert.length
958
1271
  ? this.orderSummaryService_.upsert(summariesToUpsert, sharedContext)
959
1272
  : null,
960
- shippingMethodsToInsert.length
961
- ? this.orderShippingMethodService_.create(shippingMethodsToInsert, sharedContext)
1273
+ shippingMethodsToUpsert.length
1274
+ ? this.orderShippingMethodService_.upsert(shippingMethodsToUpsert, sharedContext)
962
1275
  : null,
963
1276
  ]);
1277
+ return {
1278
+ items: itemsToUpsert,
1279
+ shippingMethods: shippingMethodsToUpsert,
1280
+ };
964
1281
  }
965
- async registerFulfillment(data, sharedContext) {
966
- const items = data.items.map((item) => {
967
- return {
968
- action: utils_2.ChangeActionType.FULFILL_ITEM,
969
- internal_note: item.internal_note,
970
- reference: data.reference,
971
- reference_id: data.reference_id,
972
- details: {
973
- reference_id: item.id,
974
- quantity: item.quantity,
975
- metadata: item.metadata,
976
- },
977
- };
1282
+ async addTransactions(transactionData, sharedContext) {
1283
+ const orders = await this.orderService_.list({
1284
+ id: Array.isArray(transactionData)
1285
+ ? transactionData.map((t) => t.order_id)
1286
+ : transactionData.order_id,
1287
+ }, {
1288
+ select: ["id", "version"],
1289
+ }, sharedContext);
1290
+ const data = Array.isArray(transactionData)
1291
+ ? transactionData
1292
+ : [transactionData];
1293
+ for (const order of orders) {
1294
+ const trxs = data.filter((t) => t.order_id === order.id);
1295
+ for (const trx of trxs) {
1296
+ ;
1297
+ trx.version = order.version;
1298
+ }
1299
+ }
1300
+ const created = await this.transactionService_.create(data, sharedContext);
1301
+ await this.updateOrderPaidRefundableAmount_(created, false, sharedContext);
1302
+ return await this.baseRepository_.serialize(!Array.isArray(transactionData) ? created[0] : created, {
1303
+ populate: true,
978
1304
  });
979
- const change = await this.createOrderChange_({
980
- order_id: data.order_id,
981
- description: data.description,
982
- internal_note: data.internal_note,
983
- created_by: data.created_by,
984
- metadata: data.metadata,
985
- actions: items,
1305
+ }
1306
+ // @ts-ignore
1307
+ async deleteTransactions(transactionIds, sharedContext) {
1308
+ const data = Array.isArray(transactionIds)
1309
+ ? transactionIds
1310
+ : [transactionIds];
1311
+ const transactions = await super.listTransactions({
1312
+ id: data,
1313
+ }, {
1314
+ select: ["order_id", "version", "amount"],
986
1315
  }, sharedContext);
987
- await this.confirmOrderChange(change[0].id, sharedContext);
1316
+ await this.transactionService_.delete(data, sharedContext);
1317
+ await this.updateOrderPaidRefundableAmount_(transactions, true, sharedContext);
988
1318
  }
989
- async registerShipment(data, sharedContext) {
990
- let shippingMethodId;
991
- if (!(0, utils_1.isString)(data.shipping_method)) {
992
- const methods = await this.createShippingMethods(data.order_id, data.shipping_method, sharedContext);
993
- shippingMethodId = methods[0].id;
994
- }
995
- else {
996
- shippingMethodId = data.shipping_method;
997
- }
998
- const method = await this.shippingMethodService_.retrieve(shippingMethodId, {
999
- relations: ["tax_lines", "adjustments"],
1319
+ // @ts-ignore
1320
+ async softDeleteTransactions(transactionIds, config, sharedContext) {
1321
+ const transactions = await super.listTransactions({
1322
+ id: transactionIds,
1323
+ }, {
1324
+ select: ["order_id", "amount"],
1000
1325
  }, sharedContext);
1001
- const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
1002
- const actions = data.items.map((item) => {
1003
- return {
1004
- action: utils_2.ChangeActionType.SHIP_ITEM,
1005
- internal_note: item.internal_note,
1006
- reference: data.reference,
1007
- reference_id: shippingMethodId,
1008
- details: {
1009
- reference_id: item.id,
1010
- quantity: item.quantity,
1011
- metadata: item.metadata,
1012
- },
1013
- };
1326
+ const returned = await super.softDeleteTransactions(transactionIds, config, sharedContext);
1327
+ await this.updateOrderPaidRefundableAmount_(transactions, true, sharedContext);
1328
+ return returned;
1329
+ }
1330
+ // @ts-ignore
1331
+ async restoreTransactions(transactionIds, config, sharedContext) {
1332
+ const transactions = await super.listTransactions({
1333
+ id: transactionIds,
1334
+ }, {
1335
+ select: ["order_id", "amount"],
1336
+ withDeleted: true,
1337
+ }, sharedContext);
1338
+ const returned = await super.restoreTransactions(transactionIds, config, sharedContext);
1339
+ await this.updateOrderPaidRefundableAmount_(transactions, false, sharedContext);
1340
+ return returned;
1341
+ }
1342
+ async updateOrderPaidRefundableAmount_(transactionData, isRemoved, sharedContext) {
1343
+ const summaries = await super.listOrderSummaries({
1344
+ order_id: transactionData.map((trx) => trx.order_id),
1345
+ }, {}, sharedContext);
1346
+ summaries.forEach((summary) => {
1347
+ let trxs = transactionData.filter((trx) => trx.order_id === summary.order_id);
1348
+ if (!trxs.length) {
1349
+ return;
1350
+ }
1351
+ (0, utils_1.transformPropertiesToBigNumber)(trxs);
1352
+ const op = isRemoved ? utils_1.MathBN.sub : utils_1.MathBN.add;
1353
+ for (const trx of trxs) {
1354
+ if (utils_1.MathBN.gt(trx.amount, 0)) {
1355
+ summary.totals.paid_total = new utils_1.BigNumber(op(summary.totals.paid_total, trx.amount));
1356
+ }
1357
+ else {
1358
+ summary.totals.refunded_total = new utils_1.BigNumber(op(summary.totals.refunded_total, utils_1.MathBN.abs(trx.amount)));
1359
+ }
1360
+ }
1014
1361
  });
1015
- if (shippingMethodId) {
1016
- actions.push({
1017
- action: utils_2.ChangeActionType.SHIPPING_ADD,
1018
- reference: data.reference,
1019
- reference_id: shippingMethodId,
1020
- amount: calculatedAmount.total,
1021
- });
1362
+ (0, utils_1.createRawPropertiesFromBigNumber)(summaries);
1363
+ await this.orderSummaryService_.update(summaries, sharedContext);
1364
+ }
1365
+ async archive(orderId, sharedContext) {
1366
+ const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1367
+ const orders = await this.listOrders({
1368
+ id: orderIds,
1369
+ }, {}, sharedContext);
1370
+ const notAllowed = [];
1371
+ for (const order of orders) {
1372
+ if (![
1373
+ utils_1.OrderStatus.COMPLETED,
1374
+ utils_1.OrderStatus.CANCELED,
1375
+ utils_1.OrderStatus.DRAFT,
1376
+ ].includes(order.status)) {
1377
+ notAllowed.push(order.id);
1378
+ }
1379
+ order.status = utils_1.OrderStatus.ARCHIVED;
1380
+ }
1381
+ if (notAllowed.length) {
1382
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Orders ${notAllowed.join(", ")} are completed, canceled, or in draft and cannot be archived`);
1022
1383
  }
1023
- const change = await this.createOrderChange_({
1024
- order_id: data.order_id,
1025
- description: data.description,
1026
- internal_note: data.internal_note,
1027
- created_by: data.created_by,
1028
- metadata: data.metadata,
1029
- actions,
1384
+ await this.orderService_.update({
1385
+ id: orderIds,
1386
+ status: utils_1.OrderStatus.ARCHIVED,
1030
1387
  }, sharedContext);
1031
- await this.confirmOrderChange(change[0].id, sharedContext);
1388
+ return Array.isArray(orderId) ? orders : orders[0];
1032
1389
  }
1033
- async createReturn(data, sharedContext) {
1034
- let shippingMethodId;
1035
- if (!(0, utils_1.isString)(data.shipping_method)) {
1036
- const methods = await this.createShippingMethods(data.order_id, data.shipping_method, sharedContext);
1037
- shippingMethodId = methods[0].id;
1390
+ async completeOrder(orderId, sharedContext) {
1391
+ const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1392
+ const orders = await this.listOrders({
1393
+ id: orderIds,
1394
+ }, {}, sharedContext);
1395
+ const notAllowed = [];
1396
+ for (const order of orders) {
1397
+ if ([utils_1.OrderStatus.CANCELED].includes(order.status)) {
1398
+ notAllowed.push(order.id);
1399
+ }
1400
+ order.status = utils_1.OrderStatus.COMPLETED;
1038
1401
  }
1039
- else {
1040
- shippingMethodId = data.shipping_method;
1402
+ if (notAllowed.length) {
1403
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Orders ${notAllowed.join(", ")} are canceled and cannot be completed`);
1041
1404
  }
1042
- const method = await this.shippingMethodService_.retrieve(shippingMethodId, {
1043
- relations: ["tax_lines", "adjustments"],
1044
- }, sharedContext);
1045
- const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
1046
- const actions = data.items.map((item) => {
1405
+ await this.orderService_.update(orderIds.map((id) => {
1047
1406
  return {
1048
- action: utils_2.ChangeActionType.RETURN_ITEM,
1049
- internal_note: item.internal_note,
1050
- reference: data.reference,
1051
- reference_id: shippingMethodId,
1052
- details: {
1053
- reference_id: item.id,
1054
- quantity: item.quantity,
1055
- metadata: item.metadata,
1056
- },
1407
+ id,
1408
+ status: utils_1.OrderStatus.COMPLETED,
1057
1409
  };
1058
- });
1059
- if (shippingMethodId) {
1060
- actions.push({
1061
- action: utils_2.ChangeActionType.SHIPPING_ADD,
1062
- reference: data.reference,
1063
- reference_id: shippingMethodId,
1064
- amount: calculatedAmount.total,
1065
- });
1410
+ }), sharedContext);
1411
+ return Array.isArray(orderId) ? orders : orders[0];
1412
+ }
1413
+ async cancel(orderId, sharedContext) {
1414
+ const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1415
+ const orders = await this.listOrders({
1416
+ id: orderIds,
1417
+ }, {}, sharedContext);
1418
+ const canceled_at = new Date();
1419
+ for (const order of orders) {
1420
+ order.status = utils_1.OrderStatus.CANCELED;
1421
+ order.canceled_at = canceled_at;
1066
1422
  }
1067
- const change = await this.createOrderChange_({
1068
- order_id: data.order_id,
1069
- description: data.description,
1070
- internal_note: data.internal_note,
1071
- created_by: data.created_by,
1072
- metadata: data.metadata,
1073
- actions,
1423
+ await this.orderService_.update(orderIds.map((id) => {
1424
+ return {
1425
+ id,
1426
+ status: utils_1.OrderStatus.CANCELED,
1427
+ canceled_at,
1428
+ };
1429
+ }), sharedContext);
1430
+ return Array.isArray(orderId) ? orders : orders[0];
1431
+ }
1432
+ // ------------------- Bundled Order Actions
1433
+ async createReturn(data, sharedContext) {
1434
+ const ret = await BundledActions.createReturn.bind(this)(data, sharedContext);
1435
+ return await this.retrieveReturn(ret.id, {
1436
+ relations: [
1437
+ "items",
1438
+ "shipping_methods",
1439
+ "shipping_methods.tax_lines",
1440
+ "shipping_methods.adjustments",
1441
+ ],
1442
+ }, sharedContext);
1443
+ }
1444
+ async receiveReturn(data, sharedContext) {
1445
+ const ret = await this.receiveReturn_(data, sharedContext);
1446
+ return await this.retrieveReturn(ret.id, {
1447
+ relations: [
1448
+ "items",
1449
+ "shipping_methods",
1450
+ "shipping_methods.tax_lines",
1451
+ "shipping_methods.adjustments",
1452
+ ],
1453
+ });
1454
+ }
1455
+ async receiveReturn_(data, sharedContext) {
1456
+ return await BundledActions.receiveReturn.bind(this)(data, sharedContext);
1457
+ }
1458
+ async cancelReturn(data, sharedContext) {
1459
+ const ret = await this.cancelReturn_(data, sharedContext);
1460
+ return await this.retrieveReturn(ret.id, {
1461
+ relations: [
1462
+ "items",
1463
+ "shipping_methods",
1464
+ "shipping_methods.tax_lines",
1465
+ "shipping_methods.adjustments",
1466
+ ],
1467
+ });
1468
+ }
1469
+ async cancelReturn_(data, sharedContext) {
1470
+ return await BundledActions.cancelReturn.bind(this)(data, sharedContext);
1471
+ }
1472
+ async createClaim(data, sharedContext) {
1473
+ const ret = await this.createClaim_(data, sharedContext);
1474
+ const claim = await this.retrieveOrderClaim(ret.id, {
1475
+ relations: [
1476
+ "additional_items",
1477
+ "additional_items.item",
1478
+ "claim_items",
1479
+ "claim_items.item",
1480
+ "return",
1481
+ "return.items",
1482
+ "shipping_methods",
1483
+ "shipping_methods.tax_lines",
1484
+ "shipping_methods.adjustments",
1485
+ "transactions",
1486
+ ],
1074
1487
  }, sharedContext);
1075
- await this.confirmOrderChange(change[0].id, sharedContext);
1488
+ return await this.baseRepository_.serialize(claim, {
1489
+ populate: true,
1490
+ });
1491
+ }
1492
+ async createClaim_(data, sharedContext) {
1493
+ return await BundledActions.createClaim.bind(this)(data, sharedContext);
1494
+ }
1495
+ async cancelClaim(data, sharedContext) {
1496
+ const ret = await this.cancelClaim_(data, sharedContext);
1497
+ return await this.retrieveOrderClaim(ret.id, {
1498
+ relations: ["items"],
1499
+ });
1500
+ }
1501
+ async cancelClaim_(data, sharedContext) {
1502
+ return await BundledActions.cancelClaim.bind(this)(data, sharedContext);
1503
+ }
1504
+ async createExchange(data, sharedContext) {
1505
+ const ret = await this.createExchange_(data, sharedContext);
1506
+ const claim = await this.retrieveOrderExchange(ret.id, {
1507
+ relations: [
1508
+ "additional_items",
1509
+ "additional_items.item",
1510
+ "return",
1511
+ "return.items",
1512
+ "shipping_methods",
1513
+ "shipping_methods.tax_lines",
1514
+ "shipping_methods.adjustments",
1515
+ "transactions",
1516
+ ],
1517
+ }, sharedContext);
1518
+ return await this.baseRepository_.serialize(claim, {
1519
+ populate: true,
1520
+ });
1521
+ }
1522
+ async createExchange_(data, sharedContext) {
1523
+ return await BundledActions.createExchange.bind(this)(data, sharedContext);
1524
+ }
1525
+ async cancelExchange(data, sharedContext) {
1526
+ const ret = await this.cancelExchange_(data, sharedContext);
1527
+ return await this.retrieveOrderExchange(ret.id, {
1528
+ relations: ["items"],
1529
+ });
1530
+ }
1531
+ async cancelExchange_(data, sharedContext) {
1532
+ return await BundledActions.cancelExchange.bind(this)(data, sharedContext);
1533
+ }
1534
+ async registerFulfillment(data, sharedContext) {
1535
+ return await BundledActions.registerFulfillment.bind(this)(data, sharedContext);
1536
+ }
1537
+ async cancelFulfillment(data, sharedContext) {
1538
+ return await BundledActions.cancelFulfillment.bind(this)(data, sharedContext);
1539
+ }
1540
+ async registerShipment(data, sharedContext) {
1541
+ return await BundledActions.registerShipment.bind(this)(data, sharedContext);
1076
1542
  }
1077
1543
  }
1078
1544
  exports.default = OrderModuleService;
1545
+ __decorate([
1546
+ __param(2, (0, utils_1.MedusaContext)()),
1547
+ __metadata("design:type", Function),
1548
+ __metadata("design:paramtypes", [String, Object, Object]),
1549
+ __metadata("design:returntype", Promise)
1550
+ ], OrderModuleService.prototype, "retrieveOrder", null);
1551
+ __decorate([
1552
+ __param(2, (0, utils_1.MedusaContext)()),
1553
+ __metadata("design:type", Function),
1554
+ __metadata("design:paramtypes", [Object, Object, Object]),
1555
+ __metadata("design:returntype", Promise)
1556
+ ], OrderModuleService.prototype, "listOrders", null);
1557
+ __decorate([
1558
+ __param(2, (0, utils_1.MedusaContext)()),
1559
+ __metadata("design:type", Function),
1560
+ __metadata("design:paramtypes", [Object, Object, Object]),
1561
+ __metadata("design:returntype", Promise)
1562
+ ], OrderModuleService.prototype, "listAndCountOrders", null);
1563
+ __decorate([
1564
+ __param(2, (0, utils_1.MedusaContext)()),
1565
+ __metadata("design:type", Function),
1566
+ __metadata("design:paramtypes", [String, Object, Object]),
1567
+ __metadata("design:returntype", Promise)
1568
+ ], OrderModuleService.prototype, "retrieveReturn", null);
1569
+ __decorate([
1570
+ __param(2, (0, utils_1.MedusaContext)()),
1571
+ __metadata("design:type", Function),
1572
+ __metadata("design:paramtypes", [Object, Object, Object]),
1573
+ __metadata("design:returntype", Promise)
1574
+ ], OrderModuleService.prototype, "listReturns", null);
1575
+ __decorate([
1576
+ __param(2, (0, utils_1.MedusaContext)()),
1577
+ __metadata("design:type", Function),
1578
+ __metadata("design:paramtypes", [Object, Object, Object]),
1579
+ __metadata("design:returntype", Promise)
1580
+ ], OrderModuleService.prototype, "listAndCountReturns", null);
1581
+ __decorate([
1582
+ __param(2, (0, utils_1.MedusaContext)()),
1583
+ __metadata("design:type", Function),
1584
+ __metadata("design:paramtypes", [String, Object, Object]),
1585
+ __metadata("design:returntype", Promise)
1586
+ ], OrderModuleService.prototype, "retrieveOrderClaim", null);
1587
+ __decorate([
1588
+ __param(2, (0, utils_1.MedusaContext)()),
1589
+ __metadata("design:type", Function),
1590
+ __metadata("design:paramtypes", [Object, Object, Object]),
1591
+ __metadata("design:returntype", Promise)
1592
+ ], OrderModuleService.prototype, "listOrderClaims", null);
1593
+ __decorate([
1594
+ __param(2, (0, utils_1.MedusaContext)()),
1595
+ __metadata("design:type", Function),
1596
+ __metadata("design:paramtypes", [Object, Object, Object]),
1597
+ __metadata("design:returntype", Promise)
1598
+ ], OrderModuleService.prototype, "listAndCountOrderClaims", null);
1599
+ __decorate([
1600
+ __param(2, (0, utils_1.MedusaContext)()),
1601
+ __metadata("design:type", Function),
1602
+ __metadata("design:paramtypes", [String, Object, Object]),
1603
+ __metadata("design:returntype", Promise)
1604
+ ], OrderModuleService.prototype, "retrieveOrderExchange", null);
1605
+ __decorate([
1606
+ __param(2, (0, utils_1.MedusaContext)()),
1607
+ __metadata("design:type", Function),
1608
+ __metadata("design:paramtypes", [Object, Object, Object]),
1609
+ __metadata("design:returntype", Promise)
1610
+ ], OrderModuleService.prototype, "listOrderExchanges", null);
1611
+ __decorate([
1612
+ __param(2, (0, utils_1.MedusaContext)()),
1613
+ __metadata("design:type", Function),
1614
+ __metadata("design:paramtypes", [Object, Object, Object]),
1615
+ __metadata("design:returntype", Promise)
1616
+ ], OrderModuleService.prototype, "listAndCountOrderExchanges", null);
1079
1617
  __decorate([
1080
1618
  (0, utils_1.InjectManager)("baseRepository_"),
1081
1619
  __param(1, (0, utils_1.MedusaContext)()),
1082
1620
  __metadata("design:type", Function),
1083
1621
  __metadata("design:paramtypes", [Object, Object]),
1084
1622
  __metadata("design:returntype", Promise)
1085
- ], OrderModuleService.prototype, "create", null);
1623
+ ], OrderModuleService.prototype, "createOrders", null);
1086
1624
  __decorate([
1087
1625
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1088
1626
  __param(1, (0, utils_1.MedusaContext)()),
1089
1627
  __metadata("design:type", Function),
1090
1628
  __metadata("design:paramtypes", [Array, Object]),
1091
1629
  __metadata("design:returntype", Promise)
1092
- ], OrderModuleService.prototype, "create_", null);
1630
+ ], OrderModuleService.prototype, "createOrders_", null);
1093
1631
  __decorate([
1094
1632
  (0, utils_1.InjectManager)("baseRepository_"),
1095
1633
  __param(2, (0, utils_1.MedusaContext)()),
1096
1634
  __metadata("design:type", Function),
1097
1635
  __metadata("design:paramtypes", [Object, Object, Object]),
1098
1636
  __metadata("design:returntype", Promise)
1099
- ], OrderModuleService.prototype, "update", null);
1637
+ ], OrderModuleService.prototype, "updateOrders", null);
1100
1638
  __decorate([
1101
1639
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1102
1640
  __param(2, (0, utils_1.MedusaContext)()),
1103
1641
  __metadata("design:type", Function),
1104
1642
  __metadata("design:paramtypes", [Object, Object, Object]),
1105
1643
  __metadata("design:returntype", Promise)
1106
- ], OrderModuleService.prototype, "update_", null);
1644
+ ], OrderModuleService.prototype, "updateOrders_", null);
1107
1645
  __decorate([
1108
1646
  (0, utils_1.InjectManager)("baseRepository_"),
1109
1647
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1216,6 +1754,24 @@ __decorate([
1216
1754
  __metadata("design:paramtypes", [Array, Object]),
1217
1755
  __metadata("design:returntype", Promise)
1218
1756
  ], OrderModuleService.prototype, "createShippingMethodsBulk_", null);
1757
+ __decorate([
1758
+ (0, utils_1.InjectManager)("baseRepository_")
1759
+ // @ts-ignore
1760
+ ,
1761
+ __param(2, (0, utils_1.MedusaContext)()),
1762
+ __metadata("design:type", Function),
1763
+ __metadata("design:paramtypes", [Object, Object, Object]),
1764
+ __metadata("design:returntype", Promise)
1765
+ ], OrderModuleService.prototype, "softDeleteShippingMethods", null);
1766
+ __decorate([
1767
+ (0, utils_1.InjectManager)("baseRepository_")
1768
+ // @ts-ignore
1769
+ ,
1770
+ __param(2, (0, utils_1.MedusaContext)()),
1771
+ __metadata("design:type", Function),
1772
+ __metadata("design:paramtypes", [Object, Object, Object]),
1773
+ __metadata("design:returntype", Promise)
1774
+ ], OrderModuleService.prototype, "restoreShippingMethods", null);
1219
1775
  __decorate([
1220
1776
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1221
1777
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1272,44 +1828,84 @@ __decorate([
1272
1828
  __metadata("design:paramtypes", [String, Array, Object]),
1273
1829
  __metadata("design:returntype", Promise)
1274
1830
  ], OrderModuleService.prototype, "setShippingMethodTaxLines", null);
1831
+ __decorate([
1832
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1833
+ __param(1, (0, utils_1.MedusaContext)()),
1834
+ __metadata("design:type", Function),
1835
+ __metadata("design:paramtypes", [Object, Object]),
1836
+ __metadata("design:returntype", Promise)
1837
+ ], OrderModuleService.prototype, "createReturns", null);
1838
+ __decorate([
1839
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1840
+ __param(1, (0, utils_1.MedusaContext)()),
1841
+ __metadata("design:type", Function),
1842
+ __metadata("design:paramtypes", [Object, Object]),
1843
+ __metadata("design:returntype", Promise)
1844
+ ], OrderModuleService.prototype, "createOrderClaims", null);
1845
+ __decorate([
1846
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1847
+ __param(1, (0, utils_1.MedusaContext)()),
1848
+ __metadata("design:type", Function),
1849
+ __metadata("design:paramtypes", [Object, Object]),
1850
+ __metadata("design:returntype", Promise)
1851
+ ], OrderModuleService.prototype, "createOrderExchanges", null);
1852
+ __decorate([
1853
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1854
+ __metadata("design:type", Function),
1855
+ __metadata("design:paramtypes", [Object, Object, Object]),
1856
+ __metadata("design:returntype", Promise)
1857
+ ], OrderModuleService.prototype, "createOrderRelatedEntity_", null);
1275
1858
  __decorate([
1276
1859
  (0, utils_1.InjectManager)("baseRepository_"),
1860
+ __param(1, (0, utils_1.MedusaContext)()),
1277
1861
  __metadata("design:type", Function),
1278
1862
  __metadata("design:paramtypes", [Object, Object]),
1279
1863
  __metadata("design:returntype", Promise)
1280
1864
  ], OrderModuleService.prototype, "createOrderChange", null);
1281
1865
  __decorate([
1282
1866
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1867
+ __param(1, (0, utils_1.MedusaContext)()),
1283
1868
  __metadata("design:type", Function),
1284
1869
  __metadata("design:paramtypes", [Object, Object]),
1285
1870
  __metadata("design:returntype", Promise)
1286
1871
  ], OrderModuleService.prototype, "createOrderChange_", null);
1872
+ __decorate([
1873
+ (0, utils_1.InjectManager)("baseRepository_"),
1874
+ __metadata("design:type", Function),
1875
+ __metadata("design:paramtypes", [String, Object]),
1876
+ __metadata("design:returntype", Promise)
1877
+ ], OrderModuleService.prototype, "previewOrderChange", null);
1287
1878
  __decorate([
1288
1879
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1880
+ __param(1, (0, utils_1.MedusaContext)()),
1289
1881
  __metadata("design:type", Function),
1290
1882
  __metadata("design:paramtypes", [Object, Object]),
1291
1883
  __metadata("design:returntype", Promise)
1292
1884
  ], OrderModuleService.prototype, "cancelOrderChange", null);
1293
1885
  __decorate([
1294
1886
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1887
+ __param(1, (0, utils_1.MedusaContext)()),
1295
1888
  __metadata("design:type", Function),
1296
1889
  __metadata("design:paramtypes", [Object, Object]),
1297
1890
  __metadata("design:returntype", Promise)
1298
1891
  ], OrderModuleService.prototype, "confirmOrderChange", null);
1299
1892
  __decorate([
1300
1893
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1894
+ __param(1, (0, utils_1.MedusaContext)()),
1301
1895
  __metadata("design:type", Function),
1302
1896
  __metadata("design:paramtypes", [Object, Object]),
1303
1897
  __metadata("design:returntype", Promise)
1304
1898
  ], OrderModuleService.prototype, "declineOrderChange", null);
1305
1899
  __decorate([
1306
1900
  (0, utils_1.InjectManager)("baseRepository_"),
1901
+ __param(1, (0, utils_1.MedusaContext)()),
1307
1902
  __metadata("design:type", Function),
1308
1903
  __metadata("design:paramtypes", [Object, Object]),
1309
1904
  __metadata("design:returntype", Promise)
1310
1905
  ], OrderModuleService.prototype, "applyPendingOrderActions", null);
1311
1906
  __decorate([
1312
1907
  (0, utils_1.InjectManager)("baseRepository_"),
1908
+ __param(1, (0, utils_1.MedusaContext)()),
1313
1909
  __metadata("design:type", Function),
1314
1910
  __metadata("design:paramtypes", [String, Object]),
1315
1911
  __metadata("design:returntype", Promise)
@@ -1322,26 +1918,182 @@ __decorate([
1322
1918
  ], OrderModuleService.prototype, "revertLastChange_", null);
1323
1919
  __decorate([
1324
1920
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1921
+ __param(1, (0, utils_1.MedusaContext)()),
1325
1922
  __metadata("design:type", Function),
1326
1923
  __metadata("design:paramtypes", [Object, Object]),
1327
1924
  __metadata("design:returntype", Promise)
1328
1925
  ], OrderModuleService.prototype, "addOrderAction", null);
1926
+ __decorate([
1927
+ (0, utils_1.InjectManager)("baseRepository_"),
1928
+ __param(1, (0, utils_1.MedusaContext)()),
1929
+ __metadata("design:type", Function),
1930
+ __metadata("design:paramtypes", [Object, Object]),
1931
+ __metadata("design:returntype", Promise)
1932
+ ], OrderModuleService.prototype, "addTransactions", null);
1933
+ __decorate([
1934
+ (0, utils_1.InjectManager)("baseRepository_")
1935
+ // @ts-ignore
1936
+ ,
1937
+ __param(1, (0, utils_1.MedusaContext)()),
1938
+ __metadata("design:type", Function),
1939
+ __metadata("design:paramtypes", [Object, Object]),
1940
+ __metadata("design:returntype", Promise)
1941
+ ], OrderModuleService.prototype, "deleteTransactions", null);
1942
+ __decorate([
1943
+ (0, utils_1.InjectManager)("baseRepository_")
1944
+ // @ts-ignore
1945
+ ,
1946
+ __param(2, (0, utils_1.MedusaContext)()),
1947
+ __metadata("design:type", Function),
1948
+ __metadata("design:paramtypes", [Object, Object, Object]),
1949
+ __metadata("design:returntype", Promise)
1950
+ ], OrderModuleService.prototype, "softDeleteTransactions", null);
1951
+ __decorate([
1952
+ (0, utils_1.InjectManager)("baseRepository_")
1953
+ // @ts-ignore
1954
+ ,
1955
+ __param(2, (0, utils_1.MedusaContext)()),
1956
+ __metadata("design:type", Function),
1957
+ __metadata("design:paramtypes", [Object, Object, Object]),
1958
+ __metadata("design:returntype", Promise)
1959
+ ], OrderModuleService.prototype, "restoreTransactions", null);
1960
+ __decorate([
1961
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1962
+ __metadata("design:type", Function),
1963
+ __metadata("design:paramtypes", [Array, Boolean, Object]),
1964
+ __metadata("design:returntype", Promise)
1965
+ ], OrderModuleService.prototype, "updateOrderPaidRefundableAmount_", null);
1329
1966
  __decorate([
1330
1967
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1968
+ __param(1, (0, utils_1.MedusaContext)()),
1331
1969
  __metadata("design:type", Function),
1332
1970
  __metadata("design:paramtypes", [Object, Object]),
1333
1971
  __metadata("design:returntype", Promise)
1334
- ], OrderModuleService.prototype, "registerFulfillment", null);
1972
+ ], OrderModuleService.prototype, "archive", null);
1335
1973
  __decorate([
1336
1974
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1975
+ __param(1, (0, utils_1.MedusaContext)()),
1337
1976
  __metadata("design:type", Function),
1338
1977
  __metadata("design:paramtypes", [Object, Object]),
1339
1978
  __metadata("design:returntype", Promise)
1340
- ], OrderModuleService.prototype, "registerShipment", null);
1979
+ ], OrderModuleService.prototype, "completeOrder", null);
1980
+ __decorate([
1981
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
1982
+ __param(1, (0, utils_1.MedusaContext)()),
1983
+ __metadata("design:type", Function),
1984
+ __metadata("design:paramtypes", [Object, Object]),
1985
+ __metadata("design:returntype", Promise)
1986
+ ], OrderModuleService.prototype, "cancel", null);
1341
1987
  __decorate([
1342
1988
  (0, utils_1.InjectTransactionManager)("baseRepository_"),
1989
+ __param(1, (0, utils_1.MedusaContext)()),
1343
1990
  __metadata("design:type", Function),
1344
1991
  __metadata("design:paramtypes", [Object, Object]),
1345
1992
  __metadata("design:returntype", Promise)
1346
1993
  ], OrderModuleService.prototype, "createReturn", null);
1994
+ __decorate([
1995
+ (0, utils_1.InjectManager)("baseRepository_"),
1996
+ __param(1, (0, utils_1.MedusaContext)()),
1997
+ __metadata("design:type", Function),
1998
+ __metadata("design:paramtypes", [Object, Object]),
1999
+ __metadata("design:returntype", Promise)
2000
+ ], OrderModuleService.prototype, "receiveReturn", null);
2001
+ __decorate([
2002
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2003
+ __param(1, (0, utils_1.MedusaContext)()),
2004
+ __metadata("design:type", Function),
2005
+ __metadata("design:paramtypes", [Object, Object]),
2006
+ __metadata("design:returntype", Promise)
2007
+ ], OrderModuleService.prototype, "receiveReturn_", null);
2008
+ __decorate([
2009
+ (0, utils_1.InjectManager)("baseRepository_"),
2010
+ __param(1, (0, utils_1.MedusaContext)()),
2011
+ __metadata("design:type", Function),
2012
+ __metadata("design:paramtypes", [Object, Object]),
2013
+ __metadata("design:returntype", Promise)
2014
+ ], OrderModuleService.prototype, "cancelReturn", null);
2015
+ __decorate([
2016
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2017
+ __param(1, (0, utils_1.MedusaContext)()),
2018
+ __metadata("design:type", Function),
2019
+ __metadata("design:paramtypes", [Object, Object]),
2020
+ __metadata("design:returntype", Promise)
2021
+ ], OrderModuleService.prototype, "cancelReturn_", null);
2022
+ __decorate([
2023
+ (0, utils_1.InjectManager)("baseRepository_"),
2024
+ __param(1, (0, utils_1.MedusaContext)()),
2025
+ __metadata("design:type", Function),
2026
+ __metadata("design:paramtypes", [Object, Object]),
2027
+ __metadata("design:returntype", Promise)
2028
+ ], OrderModuleService.prototype, "createClaim", null);
2029
+ __decorate([
2030
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2031
+ __param(1, (0, utils_1.MedusaContext)()),
2032
+ __metadata("design:type", Function),
2033
+ __metadata("design:paramtypes", [Object, Object]),
2034
+ __metadata("design:returntype", Promise)
2035
+ ], OrderModuleService.prototype, "createClaim_", null);
2036
+ __decorate([
2037
+ (0, utils_1.InjectManager)("baseRepository_"),
2038
+ __param(1, (0, utils_1.MedusaContext)()),
2039
+ __metadata("design:type", Function),
2040
+ __metadata("design:paramtypes", [Object, Object]),
2041
+ __metadata("design:returntype", Promise)
2042
+ ], OrderModuleService.prototype, "cancelClaim", null);
2043
+ __decorate([
2044
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2045
+ __param(1, (0, utils_1.MedusaContext)()),
2046
+ __metadata("design:type", Function),
2047
+ __metadata("design:paramtypes", [Object, Object]),
2048
+ __metadata("design:returntype", Promise)
2049
+ ], OrderModuleService.prototype, "cancelClaim_", null);
2050
+ __decorate([
2051
+ (0, utils_1.InjectManager)("baseRepository_"),
2052
+ __param(1, (0, utils_1.MedusaContext)()),
2053
+ __metadata("design:type", Function),
2054
+ __metadata("design:paramtypes", [Object, Object]),
2055
+ __metadata("design:returntype", Promise)
2056
+ ], OrderModuleService.prototype, "createExchange", null);
2057
+ __decorate([
2058
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2059
+ __param(1, (0, utils_1.MedusaContext)()),
2060
+ __metadata("design:type", Function),
2061
+ __metadata("design:paramtypes", [Object, Object]),
2062
+ __metadata("design:returntype", Promise)
2063
+ ], OrderModuleService.prototype, "createExchange_", null);
2064
+ __decorate([
2065
+ (0, utils_1.InjectManager)("baseRepository_"),
2066
+ __param(1, (0, utils_1.MedusaContext)()),
2067
+ __metadata("design:type", Function),
2068
+ __metadata("design:paramtypes", [Object, Object]),
2069
+ __metadata("design:returntype", Promise)
2070
+ ], OrderModuleService.prototype, "cancelExchange", null);
2071
+ __decorate([
2072
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2073
+ __param(1, (0, utils_1.MedusaContext)()),
2074
+ __metadata("design:type", Function),
2075
+ __metadata("design:paramtypes", [Object, Object]),
2076
+ __metadata("design:returntype", Promise)
2077
+ ], OrderModuleService.prototype, "cancelExchange_", null);
2078
+ __decorate([
2079
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2080
+ __param(1, (0, utils_1.MedusaContext)()),
2081
+ __metadata("design:type", Function),
2082
+ __metadata("design:paramtypes", [Object, Object]),
2083
+ __metadata("design:returntype", Promise)
2084
+ ], OrderModuleService.prototype, "registerFulfillment", null);
2085
+ __decorate([
2086
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2087
+ __param(1, (0, utils_1.MedusaContext)()),
2088
+ __metadata("design:type", Function),
2089
+ __metadata("design:paramtypes", [Object, Object]),
2090
+ __metadata("design:returntype", Promise)
2091
+ ], OrderModuleService.prototype, "cancelFulfillment", null);
2092
+ __decorate([
2093
+ (0, utils_1.InjectTransactionManager)("baseRepository_"),
2094
+ __param(1, (0, utils_1.MedusaContext)()),
2095
+ __metadata("design:type", Function),
2096
+ __metadata("design:paramtypes", [Object, Object]),
2097
+ __metadata("design:returntype", Promise)
2098
+ ], OrderModuleService.prototype, "registerShipment", null);
1347
2099
  //# sourceMappingURL=order-module-service.js.map