@medusajs/order 0.1.3-snapshot-20240718073308 → 0.1.3

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