@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
@@ -2,11 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mapRepositoryToOrderModel = exports.formatOrder = void 0;
4
4
  const utils_1 = require("@medusajs/utils");
5
+ // Reshape the order object to match the OrderDTO
6
+ // This function is used to format the order object before returning to the main module methods
5
7
  function formatOrder(order, options) {
6
8
  const isArray = Array.isArray(order);
7
9
  const orders = [...(isArray ? order : [order])];
8
10
  orders.map((order) => {
9
- order.items = order.items?.map((orderItem) => {
11
+ let mainOrder = order;
12
+ const isRelatedEntity = options?.entity?.name !== "Order";
13
+ // If the entity is a related entity, the original order is located in the order property
14
+ if (isRelatedEntity) {
15
+ if (!order.order) {
16
+ return order;
17
+ }
18
+ mainOrder = order.order;
19
+ }
20
+ mainOrder.items = mainOrder.items?.map((orderItem) => {
21
+ const isFormatted = (0, utils_1.isDefined)(orderItem.detail?.fulfilled_quantity);
22
+ if (isFormatted) {
23
+ return orderItem;
24
+ }
10
25
  const detail = { ...orderItem };
11
26
  delete detail.order;
12
27
  delete detail.item;
@@ -17,26 +32,105 @@ function formatOrder(order, options) {
17
32
  detail,
18
33
  };
19
34
  });
20
- order.shipping_methods = order.shipping_methods?.map((shippingMethod) => {
21
- const sm = { ...shippingMethod.shipping_method };
22
- delete shippingMethod.shipping_method;
23
- return {
24
- ...sm,
25
- order_id: shippingMethod.order_id,
26
- detail: {
27
- ...shippingMethod,
28
- },
29
- };
30
- });
31
- order.summary = order.summary?.[0]?.totals;
32
- return options?.includeTotals
33
- ? (0, utils_1.createRawPropertiesFromBigNumber)((0, utils_1.decorateCartTotals)(order))
34
- : order;
35
+ if (isRelatedEntity) {
36
+ if (order.return) {
37
+ formatOrderReturn(order.return, mainOrder);
38
+ }
39
+ const entityName = options.entity.name;
40
+ if (entityName === "OrderClaim") {
41
+ formatClaim(order);
42
+ }
43
+ else if (entityName === "OrderExchange") {
44
+ formatExchange(order);
45
+ }
46
+ else if (entityName === "Return") {
47
+ formatReturn(order);
48
+ }
49
+ }
50
+ if (order.shipping_methods) {
51
+ order.shipping_methods = order.shipping_methods?.map((shippingMethod) => {
52
+ if (shippingMethod.detail) {
53
+ return shippingMethod;
54
+ }
55
+ const sm = { ...shippingMethod.shipping_method };
56
+ delete shippingMethod.shipping_method;
57
+ cleanNestedRelations(shippingMethod);
58
+ return {
59
+ ...sm,
60
+ order_id: shippingMethod.order_id,
61
+ detail: {
62
+ ...shippingMethod,
63
+ },
64
+ };
65
+ });
66
+ }
67
+ if (mainOrder.summary) {
68
+ mainOrder.summary = mainOrder.summary?.[0]?.totals;
69
+ }
70
+ return (0, utils_1.createRawPropertiesFromBigNumber)(options?.includeTotals ? (0, utils_1.decorateCartTotals)(order) : order);
35
71
  });
36
72
  return isArray ? orders : orders[0];
37
73
  }
38
74
  exports.formatOrder = formatOrder;
39
- function mapRepositoryToOrderModel(config) {
75
+ function cleanNestedRelations(obj) {
76
+ delete obj.order;
77
+ delete obj.return;
78
+ delete obj.claim;
79
+ delete obj.exchange;
80
+ }
81
+ function formatOrderReturn(orderReturn, mainOrder) {
82
+ orderReturn.items?.forEach((orderItem) => {
83
+ const item = mainOrder.items?.find((item) => item.id === orderItem.item_id);
84
+ orderItem.detail = item?.detail;
85
+ });
86
+ }
87
+ function formatClaim(claim) {
88
+ if (claim.additional_items) {
89
+ claim.additional_items = claim.additional_items.filter((item) => item.is_additional_item);
90
+ claim.additional_items.forEach((orderItem) => {
91
+ const item = claim.order.items?.find((item) => item.id === orderItem.item_id);
92
+ cleanNestedRelations(item);
93
+ orderItem.detail = item?.detail;
94
+ });
95
+ }
96
+ if (!claim.claim_items) {
97
+ return;
98
+ }
99
+ claim.claim_items = claim.claim_items.filter((item) => !item.is_additional_item);
100
+ claim.claim_items.forEach((orderItem) => {
101
+ const item = claim.order.items?.find((item) => item.id === orderItem.item_id);
102
+ cleanNestedRelations(item);
103
+ orderItem.detail = item?.detail;
104
+ });
105
+ }
106
+ function formatExchange(exchange) {
107
+ if (!exchange.additional_items) {
108
+ return;
109
+ }
110
+ exchange.additional_items.forEach((orderItem) => {
111
+ const item = exchange.order.items?.find((item) => item.id === orderItem.item_id);
112
+ cleanNestedRelations(item);
113
+ orderItem.detail = item?.detail;
114
+ });
115
+ }
116
+ function formatReturn(returnOrder) {
117
+ if (!returnOrder.items) {
118
+ return;
119
+ }
120
+ returnOrder.items.forEach((orderItem) => {
121
+ const item = returnOrder.order.items?.find((item) => item.id === orderItem.item_id);
122
+ cleanNestedRelations(item);
123
+ orderItem.detail = item?.detail;
124
+ });
125
+ }
126
+ // Map the public order model to the repository model format
127
+ // As the public responses have a different shape than the repository responses, this function is used to map the public properties to the internal db entities
128
+ // e.g "items" is the relation between "line-item" and "order" + "version", The line item itself is in "items.item"
129
+ // This helper maps to the correct repository to query the DB, and the function "formatOrder" remap the response to the public shape
130
+ function mapRepositoryToOrderModel(config, isRelatedEntity = false) {
131
+ if (isRelatedEntity) {
132
+ return mapRepositoryToRelatedEntity(config);
133
+ }
40
134
  const conf = { ...config };
41
135
  function replace(obj, type) {
42
136
  if (!(0, utils_1.isDefined)(obj[type])) {
@@ -94,4 +188,24 @@ function mapRepositoryToOrderModel(config) {
94
188
  return conf;
95
189
  }
96
190
  exports.mapRepositoryToOrderModel = mapRepositoryToOrderModel;
191
+ // This function has the same purpose as "mapRepositoryToOrderModel" but for returns, claims and exchanges
192
+ function mapRepositoryToRelatedEntity(config) {
193
+ const conf = { ...config };
194
+ function replace(obj, type) {
195
+ if (!(0, utils_1.isDefined)(obj[type])) {
196
+ return;
197
+ }
198
+ return (0, utils_1.deduplicate)(obj[type].sort().map((rel) => {
199
+ if (rel.includes("shipping_methods") &&
200
+ !rel.includes("shipping_methods.shipping_method")) {
201
+ obj.populate.push("shipping_methods.shipping_method");
202
+ return rel.replace("shipping_methods", "shipping_methods.shipping_method");
203
+ }
204
+ return rel;
205
+ }));
206
+ }
207
+ conf.options.fields = replace(config.options, "fields");
208
+ conf.options.populate = replace(config.options, "populate");
209
+ return conf;
210
+ }
97
211
  //# sourceMappingURL=transform-order.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-order.js","sourceRoot":"","sources":["../../src/utils/transform-order.ts"],"names":[],"mappings":";;;AACA,2CAKwB;AAExB,SAAgB,WAAW,CACzB,KAAK,EACL,OAEC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAE/C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EA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": "0.1.3-snapshot-20240718083016",
3
+ "version": "0.1.3-snapshot-20240719133408",
4
4
  "description": "Medusa Order module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,10 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "engines": {
11
- "node": ">=16"
12
- },
13
- "bin": {
14
- "medusa-order-seed": "dist/scripts/bin/run-seed.js"
11
+ "node": ">=20"
15
12
  },
16
13
  "repository": {
17
14
  "type": "git",
@@ -37,25 +34,22 @@
37
34
  "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
38
35
  },
39
36
  "devDependencies": {
37
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240719133408",
38
+ "@medusajs/types": "1.12.0-snapshot-20240719133408",
40
39
  "@mikro-orm/cli": "5.9.7",
41
40
  "cross-env": "^5.2.1",
42
- "jest": "^29.6.3",
43
- "medusa-test-utils": "1.1.45-snapshot-20240718083016",
41
+ "jest": "^29.7.0",
42
+ "medusa-test-utils": "1.1.45-snapshot-20240719133408",
44
43
  "rimraf": "^3.0.2",
45
- "ts-jest": "^29.1.1",
46
44
  "ts-node": "^10.9.1",
47
45
  "tsc-alias": "^1.8.6",
48
46
  "typescript": "^5.1.6"
49
47
  },
50
48
  "dependencies": {
51
- "@medusajs/modules-sdk": "1.12.12-snapshot-20240718083016",
52
- "@medusajs/types": "1.11.17-snapshot-20240718083016",
53
- "@medusajs/utils": "1.11.10-snapshot-20240718083016",
49
+ "@medusajs/utils": "1.12.0-snapshot-20240719133408",
54
50
  "@mikro-orm/core": "5.9.7",
55
51
  "@mikro-orm/migrations": "5.9.7",
56
52
  "@mikro-orm/postgresql": "5.9.7",
57
- "awilix": "^8.0.0",
58
- "dotenv": "^16.4.5",
59
- "knex": "2.4.2"
53
+ "awilix": "^8.0.0"
60
54
  }
61
55
  }
@@ -1,5 +0,0 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- import { MapToConfig } from "@medusajs/utils";
3
- export declare const LinkableKeys: Record<string, string>;
4
- export declare const entityNameToLinkableKeysMap: MapToConfig;
5
- export declare const joinerConfig: ModuleJoinerConfig;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
7
- const modules_sdk_1 = require("@medusajs/modules-sdk");
8
- const _models_1 = require("./models");
9
- const order_1 = __importDefault(require("./models/order"));
10
- exports.LinkableKeys = {
11
- order_id: order_1.default.name,
12
- order_item_id: _models_1.LineItem.name,
13
- };
14
- const entityLinkableKeysMap = {};
15
- Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
16
- entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
17
- entityLinkableKeysMap[value].push({
18
- mapTo: key,
19
- valueFrom: key.split("_").pop(),
20
- });
21
- });
22
- exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
23
- exports.joinerConfig = {
24
- serviceName: modules_sdk_1.Modules.ORDER,
25
- primaryKeys: ["id"],
26
- linkableKeys: exports.LinkableKeys,
27
- alias: [
28
- {
29
- name: ["order", "orders"],
30
- args: {
31
- entity: order_1.default.name,
32
- },
33
- },
34
- ],
35
- };
36
- //# sourceMappingURL=joiner-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"joiner-config.js","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+C;AAG/C,qCAAkC;AAClC,2DAAkC;AAErB,QAAA,YAAY,GAA2B;IAClD,QAAQ,EAAE,eAAK,CAAC,IAAI;IACpB,aAAa,EAAE,kBAAQ,CAAC,IAAI;CAC7B,CAAA;AAED,MAAM,qBAAqB,GAAgB,EAAE,CAAA;AAC7C,MAAM,CAAC,OAAO,CAAC,oBAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;IACpD,qBAAqB,CAAC,KAAK,MAA3B,qBAAqB,CAAC,KAAK,IAAM,EAAE,EAAA;IACnC,qBAAqB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;QAChC,KAAK,EAAE,GAAG;QACV,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAG;KACjC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEW,QAAA,2BAA2B,GAAgB,qBAAqB,CAAA;AAEhE,QAAA,YAAY,GAAuB;IAC9C,WAAW,EAAE,qBAAO,CAAC,KAAK;IAC1B,WAAW,EAAE,CAAC,IAAI,CAAC;IACnB,YAAY,EAAE,oBAAY;IAC1B,KAAK,EAAE;QACL;YACE,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;YACzB,IAAI,EAAE;gBACJ,MAAM,EAAE,eAAK,CAAC,IAAI;aACnB;SACF;KACF;CACoB,CAAA"}
@@ -1,2 +0,0 @@
1
- import { ModuleExports } from "@medusajs/types";
2
- export declare const moduleDefinition: ModuleExports;
@@ -1,59 +0,0 @@
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
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.moduleDefinition = void 0;
27
- const modules_sdk_1 = require("@medusajs/modules-sdk");
28
- const utils_1 = require("@medusajs/utils");
29
- const Models = __importStar(require("./models"));
30
- const ModuleModels = __importStar(require("./models"));
31
- const ModuleRepositories = __importStar(require("./repositories"));
32
- const ModuleServices = __importStar(require("./services"));
33
- const _services_1 = require("./services");
34
- const migrationScriptOptions = {
35
- moduleName: modules_sdk_1.Modules.ORDER,
36
- models: Models,
37
- pathToMigrations: __dirname + "/migrations",
38
- };
39
- const runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
40
- const revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
41
- const containerLoader = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
42
- moduleModels: ModuleModels,
43
- moduleRepositories: ModuleRepositories,
44
- moduleServices: ModuleServices,
45
- });
46
- const connectionLoader = utils_1.ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
47
- moduleName: modules_sdk_1.Modules.ORDER,
48
- moduleModels: Object.values(Models),
49
- migrationsPath: __dirname + "/migrations",
50
- });
51
- const service = _services_1.OrderModuleService;
52
- const loaders = [containerLoader, connectionLoader];
53
- exports.moduleDefinition = {
54
- service,
55
- loaders,
56
- revertMigration,
57
- runMigrations,
58
- };
59
- //# sourceMappingURL=module-definition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"module-definition.js","sourceRoot":"","sources":["../src/module-definition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAE/C,2CAAiD;AACjD,gDAAiC;AACjC,sDAAuC;AACvC,kEAAmD;AACnD,0DAA2C;AAC3C,yCAA8C;AAE9C,MAAM,sBAAsB,GAAG;IAC7B,UAAU,EAAE,qBAAO,CAAC,KAAK;IACzB,MAAM,EAAE,MAAM;IACd,gBAAgB,EAAE,SAAS,GAAG,aAAa;CAC5C,CAAA;AAED,MAAM,aAAa,GAAG,uBAAe,CAAC,oBAAoB,CACxD,sBAAsB,CACvB,CAAA;AAED,MAAM,eAAe,GAAG,uBAAe,CAAC,0BAA0B,CAChE,sBAAsB,CACvB,CAAA;AAED,MAAM,eAAe,GAAG,uBAAe,CAAC,4BAA4B,CAAC;IACnE,YAAY,EAAE,YAAY;IAC1B,kBAAkB,EAAE,kBAAkB;IACtC,cAAc,EAAE,cAAc;CAC/B,CAAC,CAAA;AAEF,MAAM,gBAAgB,GAAG,uBAAe,CAAC,+BAA+B,CAAC;IACvE,UAAU,EAAE,qBAAO,CAAC,KAAK;IACzB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IACnC,cAAc,EAAE,SAAS,GAAG,aAAa;CAC1C,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,8BAAkB,CAAA;AAClC,MAAM,OAAO,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAQ,CAAA;AAE7C,QAAA,gBAAgB,GAAkB;IAC7C,OAAO;IACP,OAAO;IACP,eAAe;IACf,aAAa;CACd,CAAA"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- declare const _default: Promise<void>;
3
- export default _default;
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- const modules_sdk_1 = require("@medusajs/modules-sdk");
28
- const utils_1 = require("@medusajs/utils");
29
- const Models = __importStar(require("../../models"));
30
- const os_1 = require("os");
31
- const args = process.argv;
32
- const path = args.pop();
33
- exports.default = (async () => {
34
- const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
35
- config();
36
- if (!path) {
37
- throw new Error(`filePath is required.${os_1.EOL}Example: medusa-order-seed <filePath>`);
38
- }
39
- const run = utils_1.ModulesSdkUtils.buildSeedScript({
40
- moduleName: modules_sdk_1.Modules.ORDER,
41
- models: Models,
42
- pathToMigrations: __dirname + "/../../migrations",
43
- seedHandler: async ({ manager, data }) => {
44
- // TODO: Add seed logic
45
- },
46
- });
47
- await run({ path });
48
- })();
49
- //# sourceMappingURL=run-seed.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-seed.js","sourceRoot":"","sources":["../../../src/scripts/bin/run-seed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uDAA+C;AAC/C,2CAAiD;AACjD,gDAAiC;AACjC,2BAAwB;AAExB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;AACzB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAY,CAAA;AAEjC,kBAAe,CAAC,KAAK,IAAI,EAAE;IACzB,MAAM,EAAE,MAAM,EAAE,GAAG,wDAAa,QAAQ,GAAC,CAAA;IACzC,MAAM,EAAE,CAAA;IACR,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAG,uCAAuC,CACnE,CAAA;KACF;IAED,MAAM,GAAG,GAAG,uBAAe,CAAC,eAAe,CAAC;QAC1C,UAAU,EAAE,qBAAO,CAAC,KAAK;QACzB,MAAM,EAAE,MAAM;QACd,gBAAgB,EAAE,SAAS,GAAG,mBAAmB;QACjD,WAAW,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YACvC,uBAAuB;QACzB,CAAC;KACF,CAAC,CAAA;IACF,MAAM,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AACrB,CAAC,CAAC,EAAE,CAAA"}
@@ -1,15 +0,0 @@
1
- import { Context, DAL, FindConfig, OrderTypes, RepositoryService } from "@medusajs/types";
2
- import { OrderChange } from "../models";
3
- type InjectedDependencies = {
4
- orderChangeRepository: DAL.RepositoryService;
5
- };
6
- declare const OrderChangeService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => import("@medusajs/types").InternalModuleService<TEntity_1, InjectedDependencies>;
7
- export default class OrderChangeService<TEntity extends OrderChange = OrderChange> extends OrderChangeService_base<TEntity> {
8
- protected readonly orderChangeRepository_: RepositoryService<TEntity>;
9
- constructor(container: InjectedDependencies);
10
- listCurrentOrderChange<TEntityMethod = OrderTypes.OrderDTO>(orderId: string | string[], config?: FindConfig<TEntityMethod>, sharedContext?: Context): Promise<TEntity[]>;
11
- isActive(orderChange: OrderChange): boolean;
12
- create(data: Partial<TEntity>[], sharedContext?: Context): Promise<TEntity[]>;
13
- create(data: Partial<TEntity>, sharedContext?: Context): Promise<TEntity>;
14
- }
15
- export {};
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const utils_1 = require("@medusajs/utils");
16
- const _models_1 = require("../models");
17
- class OrderChangeService extends utils_1.ModulesSdkUtils.internalModuleServiceFactory(_models_1.OrderChange) {
18
- constructor(container) {
19
- // @ts-ignore
20
- super(...arguments);
21
- this.orderChangeRepository_ = container.orderChangeRepository;
22
- }
23
- async listCurrentOrderChange(orderId, config = {}, sharedContext = {}) {
24
- const allChanges = await super.list({ order_id: orderId }, config ?? {
25
- select: ["order_id", "status", "version"],
26
- order: {
27
- order_id: "ASC",
28
- version: "DESC",
29
- },
30
- });
31
- if (!allChanges.length) {
32
- return [];
33
- }
34
- const lastChanges = [];
35
- const seen = new Set();
36
- for (let i = 0; i < allChanges.length; i++) {
37
- if (seen.has(allChanges[i].order_id)) {
38
- continue;
39
- }
40
- seen.add(allChanges[i].order_id);
41
- if (this.isActive(allChanges[i])) {
42
- lastChanges.push(allChanges[i].id);
43
- }
44
- }
45
- let orderChange;
46
- if (allChanges?.length > 0) {
47
- if (this.isActive(allChanges[0])) {
48
- orderChange = allChanges[0];
49
- }
50
- }
51
- if (!orderChange) {
52
- return [];
53
- }
54
- const relations = (0, utils_1.deduplicate)([...(config.relations ?? []), "actions"]);
55
- config.relations = relations;
56
- const queryConfig = utils_1.ModulesSdkUtils.buildQuery({
57
- id: lastChanges,
58
- order: {
59
- items: {
60
- version: orderChange.version,
61
- },
62
- },
63
- }, config);
64
- return await this.orderChangeRepository_.find(queryConfig, sharedContext);
65
- }
66
- isActive(orderChange) {
67
- return (orderChange.status === utils_1.OrderChangeStatus.PENDING ||
68
- orderChange.status === utils_1.OrderChangeStatus.REQUESTED);
69
- }
70
- async create(data, sharedContext = {}) {
71
- const dataArr = Array.isArray(data) ? data : [data];
72
- const activeOrderEdit = await this.listCurrentOrderChange(dataArr.map((d) => d.order_id), {}, sharedContext);
73
- if (activeOrderEdit.length > 0) {
74
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `An active order change already exists for the order(s) ${activeOrderEdit
75
- .map((a) => a.order_id)
76
- .join(",")}`);
77
- }
78
- return await super.create(dataArr, sharedContext);
79
- }
80
- }
81
- exports.default = OrderChangeService;
82
- __decorate([
83
- (0, utils_1.InjectManager)("orderChangeRepository_"),
84
- __param(2, (0, utils_1.MedusaContext)()),
85
- __metadata("design:type", Function),
86
- __metadata("design:paramtypes", [Object, Object, Object]),
87
- __metadata("design:returntype", Promise)
88
- ], OrderChangeService.prototype, "listCurrentOrderChange", null);
89
- __decorate([
90
- (0, utils_1.InjectTransactionManager)("orderChangeRepository_"),
91
- __param(1, (0, utils_1.MedusaContext)()),
92
- __metadata("design:type", Function),
93
- __metadata("design:paramtypes", [Object, Object]),
94
- __metadata("design:returntype", Promise)
95
- ], OrderChangeService.prototype, "create", null);
96
- //# sourceMappingURL=order-change-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-change-service.js","sourceRoot":"","sources":["../../src/services/order-change-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAOA,2CAQwB;AACxB,qCAAqC;AAMrC,MAAqB,kBAEnB,SAAQ,uBAAe,CAAC,4BAA4B,CACpD,qBAAW,CACH;IAGR,YAAY,SAA+B;QACzC,aAAa;QACb,KAAK,CAAC,GAAG,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC,qBAAqB,CAAA;IAC/D,CAAC;IAGK,AAAN,KAAK,CAAC,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EAAE,aAAa,CAAC,CAAA;IACnD,CAAC;CACF;AApHD,qCAoHC;AAtGO;IADL,IAAA,qBAAa,EAAC,wBAAwB,CAAC;IAIrC,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;gEAyDjB;AAoBK;IADL,IAAA,gCAAwB,EAAC,wBAAwB,CAAC;IAGhD,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;gDAmBjB"}
@@ -1,13 +0,0 @@
1
- export declare enum ChangeActionType {
2
- CANCEL = "CANCEL",
3
- CANCEL_RETURN = "CANCEL_RETURN",
4
- FULFILL_ITEM = "FULFILL_ITEM",
5
- ITEM_ADD = "ITEM_ADD",
6
- ITEM_REMOVE = "ITEM_REMOVE",
7
- RECEIVE_DAMAGED_RETURN_ITEM = "RECEIVE_DAMAGED_RETURN_ITEM",
8
- RECEIVE_RETURN_ITEM = "RECEIVE_RETURN_ITEM",
9
- RETURN_ITEM = "RETURN_ITEM",
10
- SHIPPING_ADD = "SHIPPING_ADD",
11
- SHIP_ITEM = "SHIP_ITEM",
12
- WRITE_OFF_ITEM = "WRITE_OFF_ITEM"
13
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChangeActionType = void 0;
4
- var ChangeActionType;
5
- (function (ChangeActionType) {
6
- ChangeActionType["CANCEL"] = "CANCEL";
7
- ChangeActionType["CANCEL_RETURN"] = "CANCEL_RETURN";
8
- ChangeActionType["FULFILL_ITEM"] = "FULFILL_ITEM";
9
- ChangeActionType["ITEM_ADD"] = "ITEM_ADD";
10
- ChangeActionType["ITEM_REMOVE"] = "ITEM_REMOVE";
11
- ChangeActionType["RECEIVE_DAMAGED_RETURN_ITEM"] = "RECEIVE_DAMAGED_RETURN_ITEM";
12
- ChangeActionType["RECEIVE_RETURN_ITEM"] = "RECEIVE_RETURN_ITEM";
13
- ChangeActionType["RETURN_ITEM"] = "RETURN_ITEM";
14
- ChangeActionType["SHIPPING_ADD"] = "SHIPPING_ADD";
15
- ChangeActionType["SHIP_ITEM"] = "SHIP_ITEM";
16
- ChangeActionType["WRITE_OFF_ITEM"] = "WRITE_OFF_ITEM";
17
- })(ChangeActionType || (exports.ChangeActionType = ChangeActionType = {}));
18
- //# sourceMappingURL=action-key.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action-key.js","sourceRoot":"","sources":["../../src/utils/action-key.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAYX;AAZD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,mDAA+B,CAAA;IAC/B,iDAA6B,CAAA;IAC7B,yCAAqB,CAAA;IACrB,+CAA2B,CAAA;IAC3B,+EAA2D,CAAA;IAC3D,+DAA2C,CAAA;IAC3C,+CAA2B,CAAA;IAC3B,iDAA6B,CAAA;IAC7B,2CAAuB,CAAA;IACvB,qDAAiC,CAAA;AACnC,CAAC,EAZW,gBAAgB,gCAAhB,gBAAgB,QAY3B"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const action_key_1 = require("../action-key");
4
- const calculate_order_change_1 = require("../calculate-order-change");
5
- calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.CANCEL, {
6
- void: true,
7
- });
8
- //# sourceMappingURL=cancel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cancel.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel.ts"],"names":[],"mappings":";;AAAA,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,MAAM,EAAE;IAChE,IAAI,EAAE,IAAI;CACX,CAAC,CAAA"}