@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
@@ -14,71 +14,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const utils_1 = require("@medusajs/utils");
16
16
  const core_1 = require("@mikro-orm/core");
17
- const claim_1 = __importDefault(require("./claim"));
18
- const exchange_1 = __importDefault(require("./exchange"));
19
17
  const order_1 = __importDefault(require("./order"));
20
- const return_1 = __importDefault(require("./return"));
21
18
  const ReferenceIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
22
19
  tableName: "order_transaction",
23
20
  columns: "reference_id",
24
- where: "deleted_at IS NOT NULL",
25
21
  });
26
22
  const OrderIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
27
23
  tableName: "order_transaction",
28
24
  columns: "order_id",
29
- where: "deleted_at IS NOT NULL",
30
- });
31
- const ReturnIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
32
- tableName: "order_transaction",
33
- columns: "return_id",
34
- where: "return_id IS NOT NULL AND deleted_at IS NOT NULL",
35
- });
36
- const ExchangeIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
37
- tableName: "order_item",
38
- columns: ["exchange_id"],
39
- where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL",
40
- });
41
- const ClaimIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
42
- tableName: "order_item",
43
- columns: ["claim_id"],
44
- where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL",
45
25
  });
46
26
  const CurrencyCodeIndex = (0, utils_1.createPsqlIndexStatementHelper)({
47
27
  tableName: "order_transaction",
48
28
  columns: "currency_code",
49
- where: "deleted_at IS NOT NULL",
50
- });
51
- const DeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
52
- tableName: "order_transaction",
53
- columns: "deleted_at",
54
- where: "deleted_at IS NOT NULL",
55
- });
56
- const OrderIdVersionIndex = (0, utils_1.createPsqlIndexStatementHelper)({
57
- tableName: "order_transaction",
58
- columns: ["order_id", "version"],
59
- where: "deleted_at IS NOT NULL",
60
29
  });
61
30
  let Transaction = class Transaction {
62
31
  constructor() {
63
- this.return_id = null;
64
- this.version = 1;
65
32
  this.reference = null;
66
33
  this.reference_id = null;
67
- this.deleted_at = null;
68
34
  }
69
35
  onCreate() {
70
36
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
71
- this.order_id ??= this.order?.id;
72
- this.return_id ??= this.return?.id;
73
- this.claim_id ??= this.claim?.id;
74
- this.exchange_id ??= this.exchange?.id;
37
+ this.order_id ?? (this.order_id = this.order?.id);
75
38
  }
76
39
  onInit() {
77
40
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
78
- this.order_id ??= this.order?.id;
79
- this.return_id ??= this.return?.id;
80
- this.claim_id ??= this.claim?.id;
81
- this.exchange_id ??= this.exchange?.id;
41
+ this.order_id ?? (this.order_id = this.order?.id);
82
42
  }
83
43
  };
84
44
  __decorate([
@@ -100,66 +60,8 @@ __decorate([
100
60
  (0, core_1.ManyToOne)(() => order_1.default, {
101
61
  persist: false,
102
62
  }),
103
- __metadata("design:type", Object)
63
+ __metadata("design:type", order_1.default)
104
64
  ], Transaction.prototype, "order", void 0);
105
- __decorate([
106
- (0, core_1.ManyToOne)({
107
- entity: () => return_1.default,
108
- mapToPk: true,
109
- fieldName: "return_id",
110
- columnType: "text",
111
- nullable: true,
112
- }),
113
- ReturnIdIndex.MikroORMIndex(),
114
- __metadata("design:type", Object)
115
- ], Transaction.prototype, "return_id", void 0);
116
- __decorate([
117
- (0, core_1.ManyToOne)(() => return_1.default, {
118
- persist: false,
119
- }),
120
- __metadata("design:type", Object)
121
- ], Transaction.prototype, "return", void 0);
122
- __decorate([
123
- (0, core_1.ManyToOne)({
124
- entity: () => exchange_1.default,
125
- mapToPk: true,
126
- fieldName: "exchange_id",
127
- columnType: "text",
128
- nullable: true,
129
- }),
130
- ExchangeIdIndex.MikroORMIndex(),
131
- __metadata("design:type", Object)
132
- ], Transaction.prototype, "exchange_id", void 0);
133
- __decorate([
134
- (0, core_1.ManyToOne)(() => exchange_1.default, {
135
- persist: false,
136
- }),
137
- __metadata("design:type", Object)
138
- ], Transaction.prototype, "exchange", void 0);
139
- __decorate([
140
- (0, core_1.ManyToOne)({
141
- entity: () => claim_1.default,
142
- mapToPk: true,
143
- fieldName: "claim_id",
144
- columnType: "text",
145
- nullable: true,
146
- }),
147
- ClaimIdIndex.MikroORMIndex(),
148
- __metadata("design:type", Object)
149
- ], Transaction.prototype, "claim_id", void 0);
150
- __decorate([
151
- (0, core_1.ManyToOne)(() => claim_1.default, {
152
- persist: false,
153
- }),
154
- __metadata("design:type", Object)
155
- ], Transaction.prototype, "claim", void 0);
156
- __decorate([
157
- (0, core_1.Property)({
158
- columnType: "integer",
159
- defaultRaw: "1",
160
- }),
161
- __metadata("design:type", Number)
162
- ], Transaction.prototype, "version", void 0);
163
65
  __decorate([
164
66
  (0, utils_1.MikroOrmBigNumberProperty)(),
165
67
  __metadata("design:type", Object)
@@ -205,11 +107,6 @@ __decorate([
205
107
  }),
206
108
  __metadata("design:type", Date)
207
109
  ], Transaction.prototype, "updated_at", void 0);
208
- __decorate([
209
- (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
210
- DeletedAtIndex.MikroORMIndex(),
211
- __metadata("design:type", Object)
212
- ], Transaction.prototype, "deleted_at", void 0);
213
110
  __decorate([
214
111
  (0, core_1.BeforeCreate)(),
215
112
  __metadata("design:type", Function),
@@ -223,9 +120,7 @@ __decorate([
223
120
  __metadata("design:returntype", void 0)
224
121
  ], Transaction.prototype, "onInit", null);
225
122
  Transaction = __decorate([
226
- (0, core_1.Entity)({ tableName: "order_transaction" }),
227
- (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions),
228
- OrderIdVersionIndex.MikroORMIndex()
123
+ (0, core_1.Entity)({ tableName: "order_transaction" })
229
124
  ], Transaction);
230
125
  exports.default = Transaction;
231
126
  //# sourceMappingURL=transaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAMwB;AACxB,0CAUwB;AACxB,oDAA2B;AAC3B,0DAAiC;AACjC,oDAA2B;AAC3B,sDAA6B;AAI7B,MAAM,gBAAgB,GAAG,IAAA,sCAA8B,EAAC;IACtD,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,cAAc;IACvB,KAAK,EAAE,wBAAwB;CAChC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,IAAA,sCAA8B,EAAC;IAClD,SAAS,EAAE,mBAAmB;IAC9B,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,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,EAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;+CACL;AAI7B;IAFC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAChC,iBAAiB,CAAC,aAAa,EAAE;;kDACb;AAMrB;IAJC,IAAA,eAAQ,EAAC;QACR,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC;;8CAC6B;AAO/B;IALC,IAAA,eAAQ,EAAC;QACR,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,gBAAgB,CAAC,aAAa,EAAE;;iDACC;AAOlC;IALC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;+CAAA;AAQhB;IANC,IAAA,eAAQ,EAAC;QACR,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;QAC1B,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,OAAO;KACpB,CAAC;8BACU,IAAI;+CAAA;AAGhB;IADC,IAAA,mBAAY,GAAE;;;;2CAId;AAGD;IADC,IAAA,aAAM,GAAE;;;;yCAIR;AArEkB,WAAW;IAD/B,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;GACtB,WAAW,CAsE/B;kBAtEoB,WAAW"}
@@ -0,0 +1,2 @@
1
+ import { ModuleExports } from "@medusajs/types";
2
+ export declare const moduleDefinition: ModuleExports;
@@ -0,0 +1,59 @@
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
@@ -0,0 +1 @@
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,5 +1,2 @@
1
1
  export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
- export { OrderClaimRepository } from "./claim";
3
- export { OrderRepository } from "./order";
4
- export { ReturnRepository } from "./return";
5
- //# sourceMappingURL=index.d.ts.map
2
+ export * from "./order";
@@ -1,12 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReturnRepository = exports.OrderRepository = exports.OrderClaimRepository = exports.BaseRepository = void 0;
17
+ exports.BaseRepository = void 0;
4
18
  var utils_1 = require("@medusajs/utils");
5
19
  Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
6
- var claim_1 = require("./claim");
7
- Object.defineProperty(exports, "OrderClaimRepository", { enumerable: true, get: function () { return claim_1.OrderClaimRepository; } });
8
- var order_1 = require("./order");
9
- Object.defineProperty(exports, "OrderRepository", { enumerable: true, get: function () { return order_1.OrderRepository; } });
10
- var return_1 = require("./return");
11
- Object.defineProperty(exports, "ReturnRepository", { enumerable: true, get: function () { return return_1.ReturnRepository; } });
20
+ __exportStar(require("./order"), exports);
12
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAAjE,uGAAA,sBAAsB,OAAkB;AACjD,iCAA8C;AAArC,6GAAA,oBAAoB,OAAA;AAC7B,iCAAyC;AAAhC,wGAAA,eAAe,OAAA;AACxB,mCAA2C;AAAlC,0GAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAA0E;AAAjE,uGAAA,sBAAsB,OAAkB;AACjD,0CAAuB"}
@@ -1,9 +1,11 @@
1
+ import { Context, DAL } from "@medusajs/types";
1
2
  import { DALUtils } from "@medusajs/utils";
2
3
  import { Order } from "../models";
3
4
  declare const OrderRepository_base: new ({ manager }: {
4
5
  manager: any;
5
6
  }) => DALUtils.MikroOrmBaseRepository<Order>;
6
7
  export declare class OrderRepository extends OrderRepository_base {
8
+ find(options?: DAL.FindOptions<Order>, context?: Context): Promise<Order[]>;
9
+ findAndCount(findOptions?: DAL.FindOptions<Order>, context?: Context): Promise<[Order[], number]>;
7
10
  }
8
11
  export {};
9
- //# sourceMappingURL=order.d.ts.map
@@ -2,10 +2,93 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderRepository = void 0;
4
4
  const utils_1 = require("@medusajs/utils");
5
+ const core_1 = require("@mikro-orm/core");
5
6
  const _models_1 = require("../models");
6
- const base_repository_find_1 = require("../utils/base-repository-find");
7
+ const transform_order_1 = require("../utils/transform-order");
7
8
  class OrderRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.Order) {
9
+ async find(options, context) {
10
+ var _a, _b, _c, _d;
11
+ const manager = this.getActiveManager(context);
12
+ const knex = manager.getKnex();
13
+ const findOptions_ = { ...options };
14
+ findOptions_.options ?? (findOptions_.options = {});
15
+ findOptions_.where ?? (findOptions_.where = {});
16
+ if (!("strategy" in findOptions_.options)) {
17
+ if (findOptions_.options.limit != null || findOptions_.options.offset) {
18
+ Object.assign(findOptions_.options, {
19
+ strategy: core_1.LoadStrategy.SELECT_IN,
20
+ });
21
+ }
22
+ else {
23
+ Object.assign(findOptions_.options, {
24
+ strategy: core_1.LoadStrategy.JOINED,
25
+ });
26
+ }
27
+ }
28
+ const config = (0, transform_order_1.mapRepositoryToOrderModel)(findOptions_);
29
+ let defaultVersion = knex.raw(`"o0"."version"`);
30
+ const strategy = config.options.strategy ?? core_1.LoadStrategy.JOINED;
31
+ if (strategy === core_1.LoadStrategy.SELECT_IN) {
32
+ const sql = manager
33
+ .qb(_models_1.Order, "_sub0")
34
+ .select("version")
35
+ .where({ id: knex.raw(`"o0"."order_id"`) })
36
+ .getKnexQuery()
37
+ .toString();
38
+ defaultVersion = knex.raw(`(${sql})`);
39
+ }
40
+ const version = config.where.version ?? defaultVersion;
41
+ delete config.where?.version;
42
+ (_a = config.options).populateWhere ?? (_a.populateWhere = {});
43
+ (_b = config.options.populateWhere).items ?? (_b.items = {});
44
+ config.options.populateWhere.items.version = version;
45
+ (_c = config.options.populateWhere).summary ?? (_c.summary = {});
46
+ config.options.populateWhere.summary.version = version;
47
+ (_d = config.options.populateWhere).shipping_methods ?? (_d.shipping_methods = {});
48
+ config.options.populateWhere.shipping_methods.version = version;
49
+ if (!config.options.orderBy) {
50
+ config.options.orderBy = { id: "ASC" };
51
+ }
52
+ return await manager.find(_models_1.Order, config.where, config.options);
53
+ }
54
+ async findAndCount(findOptions = { where: {} }, context = {}) {
55
+ var _a, _b, _c, _d;
56
+ const manager = this.getActiveManager(context);
57
+ const knex = manager.getKnex();
58
+ const findOptions_ = { ...findOptions };
59
+ findOptions_.options ?? (findOptions_.options = {});
60
+ findOptions_.where ?? (findOptions_.where = {});
61
+ if (!("strategy" in findOptions_.options)) {
62
+ Object.assign(findOptions_.options, {
63
+ strategy: core_1.LoadStrategy.SELECT_IN,
64
+ });
65
+ }
66
+ const config = (0, transform_order_1.mapRepositoryToOrderModel)(findOptions_);
67
+ let defaultVersion = knex.raw(`"o0"."version"`);
68
+ const strategy = config.options.strategy ?? core_1.LoadStrategy.JOINED;
69
+ if (strategy === core_1.LoadStrategy.SELECT_IN) {
70
+ const sql = manager
71
+ .qb(_models_1.Order, "_sub0")
72
+ .select("version")
73
+ .where({ id: knex.raw(`"o0"."order_id"`) })
74
+ .getKnexQuery()
75
+ .toString();
76
+ defaultVersion = knex.raw(`(${sql})`);
77
+ }
78
+ const version = config.where.version ?? defaultVersion;
79
+ delete config.where.version;
80
+ (_a = config.options).populateWhere ?? (_a.populateWhere = {});
81
+ (_b = config.options.populateWhere).items ?? (_b.items = {});
82
+ config.options.populateWhere.items.version = version;
83
+ (_c = config.options.populateWhere).summary ?? (_c.summary = {});
84
+ config.options.populateWhere.summary.version = version;
85
+ (_d = config.options.populateWhere).shipping_methods ?? (_d.shipping_methods = {});
86
+ config.options.populateWhere.shipping_methods.version = version;
87
+ if (!config.options.orderBy) {
88
+ config.options.orderBy = { id: "ASC" };
89
+ }
90
+ return await manager.findAndCount(_models_1.Order, config.where, config.options);
91
+ }
8
92
  }
9
93
  exports.OrderRepository = OrderRepository;
10
- (0, base_repository_find_1.setFindMethods)(OrderRepository, _models_1.Order);
11
94
  //# sourceMappingURL=order.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/repositories/order.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAA+B;AAC/B,wEAA8D;AAE9D,MAAa,eAAgB,SAAQ,gBAAQ,CAAC,6BAA6B,CACzE,eAAK,CACN;CAAG;AAFJ,0CAEI;AAEJ,IAAA,qCAAc,EAAC,eAAe,EAAE,eAAK,CAAC,CAAA"}
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/repositories/order.ts"],"names":[],"mappings":";;;AACA,2CAA0C;AAC1C,0CAA8C;AAE9C,qCAA+B;AAC/B,8DAAoE;AAEpE,MAAa,eAAgB,SAAQ,gBAAQ,CAAC,6BAA6B,CACzE,eAAK,CACN;IACC,KAAK,CAAC,IAAI,CACR,OAAgC,EAChC,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,KAAK,QAAL,KAAK,GAAK,EAAE,EAAA;QACzC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;QAEpD,MAAA,MAAM,CAAC,OAAO,CAAC,aAAa,EAAC,OAAO,QAAP,OAAO,GAAK,EAAE,EAAA;QAC3C,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;QAEtD,MAAA,MAAM,CAAC,OAAO,CAAC,aAAa,EAAC,gBAAgB,QAAhB,gBAAgB,GAAK,EAAE,EAAA;QACpD,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,OAAO,GAAG,OAAO,CAAA;QAE/D,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;YAC3B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAA;SACvC;QAED,OAAO,MAAM,OAAO,CAAC,YAAY,CAAC,eAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACxE,CAAC;CACF;AAjHD,0CAiHC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ declare const _default: Promise<void>;
3
+ export default _default;
@@ -0,0 +1,49 @@
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
@@ -0,0 +1 @@
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,3 +1,3 @@
1
+ export { default as OrderChangeService } from "./order-change-service";
1
2
  export { default as OrderModuleService } from "./order-module-service";
2
3
  export { default as OrderService } from "./order-service";
3
- //# sourceMappingURL=index.d.ts.map
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.OrderService = exports.OrderModuleService = void 0;
6
+ exports.OrderService = exports.OrderModuleService = exports.OrderChangeService = void 0;
7
+ var order_change_service_1 = require("./order-change-service");
8
+ Object.defineProperty(exports, "OrderChangeService", { enumerable: true, get: function () { return __importDefault(order_change_service_1).default; } });
7
9
  var order_module_service_1 = require("./order-module-service");
8
10
  Object.defineProperty(exports, "OrderModuleService", { enumerable: true, get: function () { return __importDefault(order_module_service_1).default; } });
9
11
  var order_service_1 = require("./order-service");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,iDAAyD;AAAhD,8HAAA,OAAO,OAAgB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,+DAAsE;AAA7D,2IAAA,OAAO,OAAsB;AACtC,iDAAyD;AAAhD,8HAAA,OAAO,OAAgB"}
@@ -0,0 +1,15 @@
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 {};
@@ -0,0 +1,96 @@
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
@@ -0,0 +1 @@
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,sBAAsB,CAC1B,OAA0B,EAC1B,SAAoC,EAAE,EACrB,gBAAyB,EAAE;QAE5C,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,CACjC,EAAE,QAAQ,EAAE,OAAO,EAAE,EACrB,MA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