@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,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("@medusajs/utils");
4
+ const action_key_1 = require("../action-key");
4
5
  const calculate_order_change_1 = require("../calculate-order-change");
5
- const set_action_reference_1 = require("../set-action-reference");
6
- calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.ChangeActionType.WRITE_OFF_ITEM, {
7
- operation({ action, currentOrder, options }) {
6
+ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.WRITE_OFF_ITEM, {
7
+ operation({ action, currentOrder }) {
8
+ var _a;
8
9
  const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
9
- existing.detail.written_off_quantity ??= 0;
10
+ (_a = existing.detail).written_off_quantity ?? (_a.written_off_quantity = 0);
10
11
  existing.detail.written_off_quantity = utils_1.MathBN.add(existing.detail.written_off_quantity, action.details.quantity);
11
- (0, set_action_reference_1.setActionReference)(existing, action, options);
12
12
  },
13
13
  revert({ action, currentOrder }) {
14
14
  const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
15
15
  existing.detail.written_off_quantity = utils_1.MathBN.sub(existing.detail.written_off_quantity, action.details.quantity);
16
- (0, set_action_reference_1.unsetActionReference)(existing, action);
17
16
  },
18
17
  validate({ action, currentOrder }) {
19
18
  const refId = action.details?.reference_id;
@@ -22,7 +21,7 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(utils_1.Change
22
21
  }
23
22
  const existing = currentOrder.items.find((item) => item.id === refId);
24
23
  if (!existing) {
25
- throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
24
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Reference ID "${refId}" not found.`);
26
25
  }
27
26
  if (!action.details?.quantity) {
28
27
  throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to write-off item ${refId} is required.`);
@@ -1 +1 @@
1
- {"version":3,"file":"write-off-item.js","sourceRoot":"","sources":["../../../src/utils/actions/write-off-item.ts"],"names":[],"mappings":";;AAAA,2CAKwB;AACxB,sEAAiE;AACjE,kEAGgC;AAEhC,8CAAqB,CAAC,kBAAkB,CAAC,wBAAgB,CAAC,cAAc,EAAE;IACxE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE;QACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,CAAC,YAAY,CACjD,CAAA;QAEF,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B,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,gDAAgD,CACjD,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -1,25 +1,19 @@
1
1
  import { OrderSummaryDTO } from "@medusajs/types";
2
2
  import { ActionTypeDefinition, InternalOrderChangeEvent, OrderChangeEvent, OrderTransaction, VirtualOrder } from "../types";
3
- interface ProcessOptions {
4
- addActionReferenceToObject?: boolean;
5
- [key: string]: any;
6
- }
7
3
  export declare class OrderChangeProcessing {
8
4
  private static typeDefinition;
9
5
  private static defaultConfig;
10
6
  private order;
11
7
  private transactions;
12
8
  private actions;
13
- private options;
14
9
  private actionsProcessed;
15
10
  private groupTotal;
16
11
  private summary;
17
12
  static registerActionType(key: string, type: ActionTypeDefinition): void;
18
- constructor({ order, transactions, actions, options, }: {
13
+ constructor({ order, transactions, actions, }: {
19
14
  order: VirtualOrder;
20
15
  transactions: OrderTransaction[];
21
16
  actions: InternalOrderChangeEvent[];
22
- options: ProcessOptions;
23
17
  });
24
18
  private isEventActive;
25
19
  private isEventDone;
@@ -31,14 +25,11 @@ export declare class OrderChangeProcessing {
31
25
  getSummary(): OrderSummaryDTO;
32
26
  getCurrentOrder(): VirtualOrder;
33
27
  }
34
- export declare function calculateOrderChange({ order, transactions, actions, options, }: {
28
+ export declare function calculateOrderChange({ order, transactions, actions, }: {
35
29
  order: VirtualOrder;
36
30
  transactions?: OrderTransaction[];
37
31
  actions?: OrderChangeEvent[];
38
- options?: ProcessOptions;
39
32
  }): {
40
33
  summary: OrderSummaryDTO;
41
34
  order: VirtualOrder;
42
35
  };
43
- export {};
44
- //# sourceMappingURL=calculate-order-change.d.ts.map
@@ -7,39 +7,24 @@ class OrderChangeProcessing {
7
7
  static registerActionType(key, type) {
8
8
  OrderChangeProcessing.typeDefinition[key] = type;
9
9
  }
10
- constructor({ order, transactions, actions, options, }) {
11
- this.options = {};
10
+ constructor({ order, transactions, actions, }) {
12
11
  this.actionsProcessed = {};
13
12
  this.groupTotal = {};
14
13
  this.order = JSON.parse(JSON.stringify(order));
15
14
  this.transactions = JSON.parse(JSON.stringify(transactions ?? []));
16
15
  this.actions = JSON.parse(JSON.stringify(actions ?? []));
17
- this.options = options;
18
- let paid = utils_1.MathBN.convert(0);
19
- let refunded = utils_1.MathBN.convert(0);
20
- let transactionTotal = utils_1.MathBN.convert(0);
21
- for (const tr of transactions) {
22
- if (utils_1.MathBN.lt(tr.amount, 0)) {
23
- refunded = utils_1.MathBN.add(refunded, utils_1.MathBN.abs(tr.amount));
24
- }
25
- else {
26
- paid = utils_1.MathBN.add(paid, tr.amount);
27
- }
28
- transactionTotal = utils_1.MathBN.add(transactionTotal, tr.amount);
29
- }
16
+ const transactionTotal = utils_1.MathBN.add(...transactions.map((tr) => tr.amount));
30
17
  (0, utils_1.transformPropertiesToBigNumber)(this.order.metadata);
31
18
  this.summary = {
32
- future_difference: 0,
33
- future_temporary_difference: 0,
34
- temporary_difference: 0,
35
- pending_difference: 0,
36
- future_temporary_sum: 0,
37
- difference_sum: 0,
38
- current_order_total: this.order.total ?? 0,
39
- original_order_total: this.order.total ?? 0,
40
- transaction_total: transactionTotal,
41
- paid_total: paid,
42
- refunded_total: refunded,
19
+ futureDifference: 0,
20
+ futureTemporaryDifference: 0,
21
+ temporaryDifference: 0,
22
+ pendingDifference: 0,
23
+ futureTemporarySum: 0,
24
+ differenceSum: 0,
25
+ currentOrderTotal: this.order.total ?? 0,
26
+ originalOrderTotal: this.order.total ?? 0,
27
+ transactionTotal,
43
28
  };
44
29
  }
45
30
  isEventActive(action) {
@@ -57,6 +42,7 @@ class OrderChangeProcessing {
57
42
  return status === undefined || status === _types_1.EVENT_STATUS.PENDING;
58
43
  }
59
44
  processActions() {
45
+ var _a, _b;
60
46
  for (const action of this.actions) {
61
47
  this.processAction_(action);
62
48
  }
@@ -70,45 +56,42 @@ class OrderChangeProcessing {
70
56
  ...OrderChangeProcessing.typeDefinition[action.action],
71
57
  };
72
58
  const amount = utils_1.MathBN.mult(action.amount, type.isDeduction ? -1 : 1);
73
- if (action.change_id && !action.evaluationOnly) {
74
- this.groupTotal[action.change_id] ??= 0;
75
- this.groupTotal[action.change_id] = utils_1.MathBN.add(this.groupTotal[action.change_id], amount);
59
+ if (action.group_id && !action.evaluationOnly) {
60
+ (_a = this.groupTotal)[_b = action.group_id] ?? (_a[_b] = 0);
61
+ this.groupTotal[action.group_id] = utils_1.MathBN.add(this.groupTotal[action.group_id], amount);
76
62
  }
77
63
  if (type.awaitRequired && !this.isEventDone(action)) {
78
64
  if (action.evaluationOnly) {
79
- summary.future_temporary_sum = utils_1.MathBN.add(summary.future_temporary_sum, amount);
65
+ summary.futureTemporarySum = utils_1.MathBN.add(summary.futureTemporarySum, amount);
80
66
  }
81
67
  else {
82
- summary.temporary_difference = utils_1.MathBN.add(summary.temporary_difference, amount);
68
+ summary.temporaryDifference = utils_1.MathBN.add(summary.temporaryDifference, amount);
83
69
  }
84
70
  }
85
71
  if (action.evaluationOnly) {
86
- summary.future_difference = utils_1.MathBN.add(summary.future_difference, amount);
72
+ summary.futureDifference = utils_1.MathBN.add(summary.futureDifference, amount);
87
73
  }
88
74
  else {
89
- if (!this.isEventDone(action) && !action.change_id) {
90
- summary.difference_sum = utils_1.MathBN.add(summary.difference_sum, amount);
75
+ if (!this.isEventDone(action) && !action.group_id) {
76
+ summary.differenceSum = utils_1.MathBN.add(summary.differenceSum, amount);
91
77
  }
92
- summary.current_order_total = utils_1.MathBN.add(summary.current_order_total, amount);
78
+ summary.currentOrderTotal = utils_1.MathBN.add(summary.currentOrderTotal, amount);
93
79
  }
94
80
  }
95
81
  const groupSum = utils_1.MathBN.add(...Object.values(this.groupTotal));
96
- summary.difference_sum = utils_1.MathBN.add(summary.difference_sum, groupSum);
97
- summary.transaction_total = utils_1.MathBN.sum(...this.transactions.map((tr) => tr.amount));
98
- summary.future_temporary_difference = utils_1.MathBN.sub(summary.future_difference, summary.future_temporary_sum);
99
- summary.temporary_difference = utils_1.MathBN.sub(summary.difference_sum, summary.temporary_difference);
100
- summary.pending_difference = utils_1.MathBN.sub(summary.current_order_total, summary.transaction_total);
82
+ summary.differenceSum = utils_1.MathBN.add(summary.differenceSum, groupSum);
83
+ summary.transactionTotal = utils_1.MathBN.sum(...this.transactions.map((tr) => tr.amount));
84
+ summary.futureTemporaryDifference = utils_1.MathBN.sub(summary.futureDifference, summary.futureTemporarySum);
85
+ summary.temporaryDifference = utils_1.MathBN.sub(summary.differenceSum, summary.temporaryDifference);
86
+ summary.pendingDifference = utils_1.MathBN.sub(summary.currentOrderTotal, summary.transactionTotal);
101
87
  }
102
88
  processAction_(action, isReplay = false) {
103
- const definedType = OrderChangeProcessing.typeDefinition[action.action];
104
- if (!(0, utils_1.isPresent)(definedType)) {
105
- throw new Error(`Action type ${action.action} is not defined`);
106
- }
89
+ var _a, _b, _c;
107
90
  const type = {
108
91
  ...OrderChangeProcessing.defaultConfig,
109
- ...definedType,
92
+ ...OrderChangeProcessing.typeDefinition[action.action],
110
93
  };
111
- this.actionsProcessed[action.action] ??= [];
94
+ (_a = this.actionsProcessed)[_b = action.action] ?? (_a[_b] = []);
112
95
  if (!isReplay) {
113
96
  this.actionsProcessed[action.action].push(action);
114
97
  }
@@ -126,7 +109,6 @@ class OrderChangeProcessing {
126
109
  summary: this.summary,
127
110
  transactions: this.transactions,
128
111
  type,
129
- options: this.options,
130
112
  };
131
113
  if (typeof type.validate === "function") {
132
114
  type.validate(params);
@@ -148,13 +130,13 @@ class OrderChangeProcessing {
148
130
  if (action.resolve.reference_id) {
149
131
  this.resolveReferences(action);
150
132
  }
151
- const groupId = action.resolve.change_id ?? "__default";
152
- if (action.resolve.change_id) {
133
+ const groupId = action.resolve.group_id ?? "__default";
134
+ if (action.resolve.group_id) {
153
135
  // resolve all actions in the same group
154
136
  this.resolveGroup(action);
155
137
  }
156
138
  if (action.resolve.amount && !action.evaluationOnly) {
157
- this.groupTotal[groupId] ??= 0;
139
+ (_c = this.groupTotal)[groupId] ?? (_c[groupId] = 0);
158
140
  this.groupTotal[groupId] = utils_1.MathBN.sub(this.groupTotal[groupId], action.resolve.amount);
159
141
  }
160
142
  }
@@ -204,7 +186,7 @@ class OrderChangeProcessing {
204
186
  const type = OrderChangeProcessing.typeDefinition[actionKey];
205
187
  const actions = this.actionsProcessed[actionKey];
206
188
  for (const action of actions) {
207
- if (!resolve?.change_id || action?.change_id !== resolve.change_id) {
189
+ if (!resolve?.group_id || action?.group_id !== resolve.group_id) {
208
190
  continue;
209
191
  }
210
192
  if (type.revert &&
@@ -239,17 +221,42 @@ class OrderChangeProcessing {
239
221
  getSummary() {
240
222
  const summary = this.summary;
241
223
  const orderSummary = {
242
- transaction_total: new utils_1.BigNumber(summary.transaction_total),
243
- original_order_total: new utils_1.BigNumber(summary.original_order_total),
244
- current_order_total: new utils_1.BigNumber(summary.current_order_total),
245
- temporary_difference: new utils_1.BigNumber(summary.temporary_difference),
246
- future_difference: new utils_1.BigNumber(summary.future_difference),
247
- future_temporary_difference: new utils_1.BigNumber(summary.future_temporary_difference),
248
- pending_difference: new utils_1.BigNumber(summary.pending_difference),
249
- difference_sum: new utils_1.BigNumber(summary.difference_sum),
250
- paid_total: new utils_1.BigNumber(summary.paid_total),
251
- refunded_total: new utils_1.BigNumber(summary.refunded_total),
224
+ transactionTotal: new utils_1.BigNumber(summary.transactionTotal),
225
+ originalOrderTotal: new utils_1.BigNumber(summary.originalOrderTotal),
226
+ currentOrderTotal: new utils_1.BigNumber(summary.currentOrderTotal),
227
+ temporaryDifference: new utils_1.BigNumber(summary.temporaryDifference),
228
+ futureDifference: new utils_1.BigNumber(summary.futureDifference),
229
+ futureTemporaryDifference: new utils_1.BigNumber(summary.futureTemporaryDifference),
230
+ pendingDifference: new utils_1.BigNumber(summary.pendingDifference),
231
+ differenceSum: new utils_1.BigNumber(summary.differenceSum),
252
232
  };
233
+ /*
234
+ {
235
+ total: summary.currentOrderTotal
236
+
237
+ subtotal: number
238
+ total_tax: number
239
+
240
+ ordered_total: summary.originalOrderTotal
241
+ fulfilled_total: number
242
+ returned_total: number
243
+ return_request_total: number
244
+ write_off_total: number
245
+ projected_total: number
246
+
247
+ net_total: number
248
+ net_subtotal: number
249
+ net_total_tax: number
250
+
251
+ future_total: number
252
+ future_subtotal: number
253
+ future_total_tax: number
254
+ future_projected_total: number
255
+
256
+ balance: summary.pendingDifference
257
+ future_balance: number
258
+ }
259
+ */
253
260
  return orderSummary;
254
261
  }
255
262
  getCurrentOrder() {
@@ -262,13 +269,8 @@ OrderChangeProcessing.defaultConfig = {
262
269
  awaitRequired: false,
263
270
  isDeduction: false,
264
271
  };
265
- function calculateOrderChange({ order, transactions = [], actions = [], options = {}, }) {
266
- const calc = new OrderChangeProcessing({
267
- order,
268
- transactions,
269
- actions,
270
- options,
271
- });
272
+ function calculateOrderChange({ order, transactions = [], actions = [], }) {
273
+ const calc = new OrderChangeProcessing({ order, transactions, actions });
272
274
  calc.processActions();
273
275
  return {
274
276
  summary: calc.getSummary(),
@@ -1 +1 @@
1
- {"version":3,"file":"calculate-order-change.js","sourceRoot":"","sources":["../../src/utils/calculate-order-change.ts"],"names":[],"mappings":";;;AACA,2CAMwB;AACxB,mCAQe;AAUf,MAAa,qBAAqB;IAgBzB,MAAM,CAAC,kBAAkB,CAAC,GAAW,EAAE,IAA0B;QACtE,qBAAqB,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAClD,CAAC;IAED,YAAY,EACV,KAAK,EACL,YAAY,EACZ,OAAO,EACP,OAAO,GAMR;QApBO,YAAO,GAAmB,EAAE,CAAA;QAE5B,qBAAgB,GAAkD,EAAE,CAAA;QACpE,eAAU,GAAmC,EAAE,CAAA;QAkBrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,EAAE,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,CAAC;;AAnXH,sDAoXC;AAnXgB,oCAAc,GAA4C,EAAE,AAA9C,CAA8C;AAC5D,mCAAa,GAAG;IAC7B,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;CACnB,AAH2B,CAG3B;AAiXH,SAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,OAAO,GAAG,EAAE,EACZ,OAAO,GAAG,EAAE,GAMb;IACC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CAAC;QACrC,KAAK;QACL,YAAY;QACZ,OAAO;QACP,OAAO;KACR,CAAC,CAAA;IACF,IAAI,CAAC,cAAc,EAAE,CAAA;IAErB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;QAC1B,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE;KAC9B,CAAA;AACH,CAAC;AAvBD,oDAuBC"}
1
+ {"version":3,"file":"calculate-order-change.js","sourceRoot":"","sources":["../../src/utils/calculate-order-change.ts"],"names":[],"mappings":";;;AACA,2CAKwB;AACxB,mCAQe;AAMf,MAAa,qBAAqB;IAezB,MAAM,CAAC,kBAAkB,CAAC,GAAW,EAAE,IAA0B;QACtE,qBAAqB,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAClD,CAAC;IAED,YAAY,EACV,KAAK,EACL,YAAY,EACZ,OAAO,GAKR;QAhBO,qBAAgB,GAAkD,EAAE,CAAA;QACpE,eAAU,GAAmC,EAAE,CAAA;QAgBrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,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AAiXH,SAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,OAAO,GAAG,EAAE,GAKb;IACC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAA;IACxE,IAAI,CAAC,cAAc,EAAE,CAAA;IAErB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;QAC1B,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE;KAC9B,CAAA;AACH,CAAC;AAhBD,oDAgBC"}
@@ -1,6 +1,3 @@
1
+ export * from "./action-key";
1
2
  export * from "./actions";
2
- export * from "./apply-order-changes";
3
3
  export * from "./calculate-order-change";
4
- export * from "./set-action-reference";
5
- export * from "./transform-order";
6
- //# sourceMappingURL=index.d.ts.map
@@ -14,9 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./action-key"), exports);
17
18
  __exportStar(require("./actions"), exports);
18
- __exportStar(require("./apply-order-changes"), exports);
19
19
  __exportStar(require("./calculate-order-change"), exports);
20
- __exportStar(require("./set-action-reference"), exports);
21
- __exportStar(require("./transform-order"), exports);
22
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,wDAAqC;AACrC,2DAAwC;AACxC,yDAAsC;AACtC,oDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,4CAAyB;AACzB,2DAAwC"}
@@ -1,7 +1,5 @@
1
1
  import { OrderTypes } from "@medusajs/types";
2
2
  export declare function formatOrder(order: any, options: {
3
- entity: any;
4
3
  includeTotals?: boolean;
5
- }): Partial<OrderTypes.OrderDTO> | Partial<OrderTypes.OrderDTO>[];
6
- export declare function mapRepositoryToOrderModel(config: any, isRelatedEntity?: boolean): any;
7
- //# sourceMappingURL=transform-order.d.ts.map
4
+ }): OrderTypes.OrderDTO | OrderTypes.OrderDTO[];
5
+ export declare function mapRepositoryToOrderModel(config: any): any;
@@ -2,26 +2,11 @@
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
7
5
  function formatOrder(order, options) {
8
6
  const isArray = Array.isArray(order);
9
7
  const orders = [...(isArray ? order : [order])];
10
8
  orders.map((order) => {
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
- }
9
+ order.items = order.items?.map((orderItem) => {
25
10
  const detail = { ...orderItem };
26
11
  delete detail.order;
27
12
  delete detail.item;
@@ -32,105 +17,26 @@ function formatOrder(order, options) {
32
17
  detail,
33
18
  };
34
19
  });
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);
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;
71
35
  });
72
36
  return isArray ? orders : orders[0];
73
37
  }
74
38
  exports.formatOrder = formatOrder;
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
- }
39
+ function mapRepositoryToOrderModel(config) {
134
40
  const conf = { ...config };
135
41
  function replace(obj, type) {
136
42
  if (!(0, utils_1.isDefined)(obj[type])) {
@@ -188,24 +94,4 @@ function mapRepositoryToOrderModel(config, isRelatedEntity = false) {
188
94
  return conf;
189
95
  }
190
96
  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
- }
211
97
  //# 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,iDAAiD;AACjD,+FAA+F;AAC/F,SAAgB,WAAW,CACzB,KAAK,EACL,OAGC;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,EAAE,EAAE;QACnB,IAAI,SAAS,GAAG,KAAK,CAAA;QAErB,MAAM,eAAe,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,KAAK,OAAO,CAAA;QAEzD,yFAAyF;QACzF,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACjB,OAAO,KAAK,CAAA;YACd,CAAC;YAED,SAAS,GAAG,KAAK,CAAC,KAAK,CAAA;QACzB,CAAC;QAED,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YACnD,MAAM,WAAW,GAAG,IAAA,iBAAS,EAAC,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;YACnE,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,SAAS,CAAA;YAClB,CAAC;YAED,MAAM,MAAM,GAAG,EAAE,GAAG,SAAS,EAAE,CAAA;YAC/B,OAAO,MAAM,CAAC,KAAK,CAAA;YACnB,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