@medusajs/order 0.1.3-snapshot-20240531102054 → 0.1.3-snapshot-20240701122250

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.js +7 -2
  3. package/dist/index.js.map +1 -1
  4. package/dist/joiner-config.d.ts +1 -3
  5. package/dist/joiner-config.js +4 -42
  6. package/dist/joiner-config.js.map +1 -1
  7. package/dist/migrations/Migration20240604100512.d.ts +4 -0
  8. package/dist/migrations/Migration20240604100512.js +364 -0
  9. package/dist/migrations/Migration20240604100512.js.map +1 -0
  10. package/dist/models/claim-item-image.d.ts +18 -0
  11. package/dist/models/claim-item-image.js +108 -0
  12. package/dist/models/claim-item-image.js.map +1 -0
  13. package/dist/models/claim-item.d.ts +28 -0
  14. package/dist/models/claim-item.js +156 -0
  15. package/dist/models/claim-item.js.map +1 -0
  16. package/dist/models/claim.d.ts +35 -0
  17. package/dist/models/claim.js +196 -0
  18. package/dist/models/claim.js.map +1 -0
  19. package/dist/models/exchange-item.d.ts +23 -0
  20. package/dist/models/exchange-item.js +138 -0
  21. package/dist/models/exchange-item.js.map +1 -0
  22. package/dist/models/exchange.d.ts +33 -0
  23. package/dist/models/exchange.js +189 -0
  24. package/dist/models/exchange.js.map +1 -0
  25. package/dist/models/index.d.ts +7 -0
  26. package/dist/models/index.js +15 -1
  27. package/dist/models/index.js.map +1 -1
  28. package/dist/models/line-item-adjustment.d.ts +2 -1
  29. package/dist/models/line-item-adjustment.js +1 -1
  30. package/dist/models/line-item-adjustment.js.map +1 -1
  31. package/dist/models/line-item-tax-line.d.ts +2 -1
  32. package/dist/models/line-item-tax-line.js +1 -1
  33. package/dist/models/line-item-tax-line.js.map +1 -1
  34. package/dist/models/line-item.d.ts +1 -1
  35. package/dist/models/line-item.js +3 -3
  36. package/dist/models/line-item.js.map +1 -1
  37. package/dist/models/order-change-action.d.ts +13 -3
  38. package/dist/models/order-change-action.js +94 -0
  39. package/dist/models/order-change-action.js.map +1 -1
  40. package/dist/models/order-change.d.ts +14 -3
  41. package/dist/models/order-change.js +107 -3
  42. package/dist/models/order-change.js.map +1 -1
  43. package/dist/models/order-item.d.ts +3 -3
  44. package/dist/models/order-item.js +7 -7
  45. package/dist/models/order-item.js.map +1 -1
  46. package/dist/models/order-shipping-method.d.ts +12 -3
  47. package/dist/models/order-shipping-method.js +83 -7
  48. package/dist/models/order-shipping-method.js.map +1 -1
  49. package/dist/models/order-summary.d.ts +3 -2
  50. package/dist/models/order-summary.js +7 -4
  51. package/dist/models/order-summary.js.map +1 -1
  52. package/dist/models/order.d.ts +3 -3
  53. package/dist/models/order.js +1 -1
  54. package/dist/models/order.js.map +1 -1
  55. package/dist/models/return-item.d.ts +28 -0
  56. package/dist/models/return-item.js +170 -0
  57. package/dist/models/return-item.js.map +1 -0
  58. package/dist/models/return-reason.d.ts +3 -3
  59. package/dist/models/return-reason.js.map +1 -1
  60. package/dist/models/return.d.ts +38 -0
  61. package/dist/models/return.js +213 -0
  62. package/dist/models/return.js.map +1 -0
  63. package/dist/models/shipping-method-adjustment.d.ts +2 -1
  64. package/dist/models/shipping-method-adjustment.js +1 -1
  65. package/dist/models/shipping-method-adjustment.js.map +1 -1
  66. package/dist/models/shipping-method-tax-line.d.ts +2 -1
  67. package/dist/models/shipping-method-tax-line.js +1 -1
  68. package/dist/models/shipping-method-tax-line.js.map +1 -1
  69. package/dist/models/shipping-method.js +1 -1
  70. package/dist/models/shipping-method.js.map +1 -1
  71. package/dist/models/tax-line.js.map +1 -1
  72. package/dist/models/transaction.d.ts +11 -2
  73. package/dist/models/transaction.js +80 -1
  74. package/dist/models/transaction.js.map +1 -1
  75. package/dist/repositories/claim.d.ts +8 -0
  76. package/dist/repositories/claim.js +11 -0
  77. package/dist/repositories/claim.js.map +1 -0
  78. package/dist/repositories/exchange.d.ts +8 -0
  79. package/dist/repositories/exchange.js +11 -0
  80. package/dist/repositories/exchange.js.map +1 -0
  81. package/dist/repositories/index.d.ts +3 -1
  82. package/dist/repositories/index.js +7 -16
  83. package/dist/repositories/index.js.map +1 -1
  84. package/dist/repositories/order.d.ts +0 -3
  85. package/dist/repositories/order.js +2 -83
  86. package/dist/repositories/order.js.map +1 -1
  87. package/dist/repositories/return.d.ts +8 -0
  88. package/dist/repositories/return.js +11 -0
  89. package/dist/repositories/return.js.map +1 -0
  90. package/dist/services/actions/cancel-fulfillment.d.ts +2 -0
  91. package/dist/services/actions/cancel-fulfillment.js +32 -0
  92. package/dist/services/actions/cancel-fulfillment.js.map +1 -0
  93. package/dist/services/actions/create-claim.d.ts +2 -0
  94. package/dist/services/actions/create-claim.js +229 -0
  95. package/dist/services/actions/create-claim.js.map +1 -0
  96. package/dist/services/actions/create-exchange.d.ts +2 -0
  97. package/dist/services/actions/create-exchange.js +194 -0
  98. package/dist/services/actions/create-exchange.js.map +1 -0
  99. package/dist/services/actions/create-return.d.ts +2 -0
  100. package/dist/services/actions/create-return.js +98 -0
  101. package/dist/services/actions/create-return.js.map +1 -0
  102. package/dist/services/actions/index.d.ts +7 -0
  103. package/dist/services/actions/index.js +24 -0
  104. package/dist/services/actions/index.js.map +1 -0
  105. package/dist/services/actions/receive-return.d.ts +2 -0
  106. package/dist/services/actions/receive-return.js +75 -0
  107. package/dist/services/actions/receive-return.js.map +1 -0
  108. package/dist/services/actions/register-fulfillment.d.ts +2 -0
  109. package/dist/services/actions/register-fulfillment.js +30 -0
  110. package/dist/services/actions/register-fulfillment.js.map +1 -0
  111. package/dist/services/actions/register-shipment.d.ts +2 -0
  112. package/dist/services/actions/register-shipment.js +38 -0
  113. package/dist/services/actions/register-shipment.js.map +1 -0
  114. package/dist/services/order-change-service.d.ts +6 -6
  115. package/dist/services/order-change-service.js +4 -3
  116. package/dist/services/order-change-service.js.map +1 -1
  117. package/dist/services/order-module-service.d.ts +103 -63
  118. package/dist/services/order-module-service.js +486 -266
  119. package/dist/services/order-module-service.js.map +1 -1
  120. package/dist/services/order-service.d.ts +4 -4
  121. package/dist/services/order-service.js +1 -1
  122. package/dist/services/order-service.js.map +1 -1
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/index.js +1 -0
  125. package/dist/types/index.js.map +1 -1
  126. package/dist/types/order-change.d.ts +32 -0
  127. package/dist/types/order-change.js +34 -0
  128. package/dist/types/order-change.js.map +1 -0
  129. package/dist/types/utils/index.d.ts +25 -1
  130. package/dist/types/utils/index.js.map +1 -1
  131. package/dist/utils/action-key.d.ts +1 -0
  132. package/dist/utils/action-key.js +1 -0
  133. package/dist/utils/action-key.js.map +1 -1
  134. package/dist/utils/actions/cancel-item-fulfillment.d.ts +1 -0
  135. package/dist/utils/actions/cancel-item-fulfillment.js +39 -0
  136. package/dist/utils/actions/cancel-item-fulfillment.js.map +1 -0
  137. package/dist/utils/actions/cancel-return.js +3 -1
  138. package/dist/utils/actions/cancel-return.js.map +1 -1
  139. package/dist/utils/actions/fulfill-item.js +3 -1
  140. package/dist/utils/actions/fulfill-item.js.map +1 -1
  141. package/dist/utils/actions/index.d.ts +2 -0
  142. package/dist/utils/actions/index.js +2 -0
  143. package/dist/utils/actions/index.js.map +1 -1
  144. package/dist/utils/actions/item-add.js +10 -7
  145. package/dist/utils/actions/item-add.js.map +1 -1
  146. package/dist/utils/actions/item-remove.js +7 -5
  147. package/dist/utils/actions/item-remove.js.map +1 -1
  148. package/dist/utils/actions/receive-damaged-return-item.js +3 -1
  149. package/dist/utils/actions/receive-damaged-return-item.js.map +1 -1
  150. package/dist/utils/actions/receive-return-item.js +3 -1
  151. package/dist/utils/actions/receive-return-item.js.map +1 -1
  152. package/dist/utils/actions/return-item.js +3 -1
  153. package/dist/utils/actions/return-item.js.map +1 -1
  154. package/dist/utils/actions/ship-item.js +3 -1
  155. package/dist/utils/actions/ship-item.js.map +1 -1
  156. package/dist/utils/actions/shipping-add.js +6 -2
  157. package/dist/utils/actions/shipping-add.js.map +1 -1
  158. package/dist/utils/actions/write-off-item.js +3 -1
  159. package/dist/utils/actions/write-off-item.js.map +1 -1
  160. package/dist/utils/apply-order-changes.d.ts +14 -0
  161. package/dist/utils/apply-order-changes.js +74 -0
  162. package/dist/utils/apply-order-changes.js.map +1 -0
  163. package/dist/utils/base-repository-find.d.ts +2 -0
  164. package/dist/utils/base-repository-find.js +117 -0
  165. package/dist/utils/base-repository-find.js.map +1 -0
  166. package/dist/utils/calculate-order-change.js +5 -1
  167. package/dist/utils/calculate-order-change.js.map +1 -1
  168. package/dist/utils/index.d.ts +3 -0
  169. package/dist/utils/index.js +3 -0
  170. package/dist/utils/index.js.map +1 -1
  171. package/dist/utils/set-action-reference.d.ts +1 -0
  172. package/dist/utils/set-action-reference.js +11 -0
  173. package/dist/utils/set-action-reference.js.map +1 -0
  174. package/dist/utils/transform-order.d.ts +3 -2
  175. package/dist/utils/transform-order.js +84 -17
  176. package/dist/utils/transform-order.js.map +1 -1
  177. package/package.json +7 -11
  178. package/dist/module-definition.d.ts +0 -2
  179. package/dist/module-definition.js +0 -9
  180. package/dist/module-definition.js.map +0 -1
  181. package/dist/scripts/bin/run-seed.d.ts +0 -3
  182. package/dist/scripts/bin/run-seed.js +0 -49
  183. package/dist/scripts/bin/run-seed.js.map +0 -1
@@ -14,18 +14,39 @@ 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"));
17
19
  const order_1 = __importDefault(require("./order"));
20
+ const return_1 = __importDefault(require("./return"));
18
21
  const ReferenceIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
19
22
  tableName: "order_transaction",
20
23
  columns: "reference_id",
24
+ where: "deleted_at IS NOT NULL",
21
25
  });
22
26
  const OrderIdIndex = (0, utils_1.createPsqlIndexStatementHelper)({
23
27
  tableName: "order_transaction",
24
28
  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",
25
45
  });
26
46
  const CurrencyCodeIndex = (0, utils_1.createPsqlIndexStatementHelper)({
27
47
  tableName: "order_transaction",
28
48
  columns: "currency_code",
49
+ where: "deleted_at IS NOT NULL",
29
50
  });
30
51
  const DeletedAtIndex = (0, utils_1.createPsqlIndexStatementHelper)({
31
52
  tableName: "order_transaction",
@@ -39,6 +60,7 @@ const OrderIdVersionIndex = (0, utils_1.createPsqlIndexStatementHelper)({
39
60
  });
40
61
  let Transaction = class Transaction {
41
62
  constructor() {
63
+ this.return_id = null;
42
64
  this.version = 1;
43
65
  this.reference = null;
44
66
  this.reference_id = null;
@@ -47,10 +69,16 @@ let Transaction = class Transaction {
47
69
  onCreate() {
48
70
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
49
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;
50
75
  }
51
76
  onInit() {
52
77
  this.id = (0, utils_1.generateEntityId)(this.id, "ordtrx");
53
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;
54
82
  }
55
83
  };
56
84
  __decorate([
@@ -72,8 +100,59 @@ __decorate([
72
100
  (0, core_1.ManyToOne)(() => order_1.default, {
73
101
  persist: false,
74
102
  }),
75
- __metadata("design:type", order_1.default)
103
+ __metadata("design:type", Object)
76
104
  ], 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);
77
156
  __decorate([
78
157
  (0, core_1.Property)({
79
158
  columnType: "integer",
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/models/transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,2CAKwB;AACxB,0CAQwB;A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+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;AAIhB;IAFC,IAAA,eAAQ,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACvD,cAAc,CAAC,aAAa,EAAE;;+CACD;AAG9B;IADC,IAAA,mBAAY,GAAE;;;;2CAOd;AAGD;IADC,IAAA,aAAM,GAAE;;;;yCAOR;AAlIkB,WAAW;IAF/B,IAAA,aAAM,EAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;IAC1C,mBAAmB,CAAC,aAAa,EAAE;GACf,WAAW,CAmI/B;kBAnIoB,WAAW"}
@@ -0,0 +1,8 @@
1
+ import { DALUtils } from "@medusajs/utils";
2
+ import { OrderClaim } from "../models";
3
+ declare const OrderClaimRepository_base: new ({ manager }: {
4
+ manager: any;
5
+ }) => DALUtils.MikroOrmBaseRepository<OrderClaim>;
6
+ export declare class OrderClaimRepository extends OrderClaimRepository_base {
7
+ }
8
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderClaimRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
7
+ class OrderClaimRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.OrderClaim) {
8
+ }
9
+ exports.OrderClaimRepository = OrderClaimRepository;
10
+ (0, base_repository_find_1.setFindMethods)(OrderClaimRepository, _models_1.OrderClaim);
11
+ //# sourceMappingURL=claim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claim.js","sourceRoot":"","sources":["../../src/repositories/claim.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAAoC;AACpC,wEAA8D;AAE9D,MAAa,oBAAqB,SAAQ,gBAAQ,CAAC,6BAA6B,CAC9E,oBAAU,CACX;CAAG;AAFJ,oDAEI;AAEJ,IAAA,qCAAc,EAAC,oBAAoB,EAAE,oBAAU,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { DALUtils } from "@medusajs/utils";
2
+ import { OrderExchange } from "../models";
3
+ declare const OrderExchangeRepository_base: new ({ manager }: {
4
+ manager: any;
5
+ }) => DALUtils.MikroOrmBaseRepository<OrderExchange>;
6
+ export declare class OrderExchangeRepository extends OrderExchangeRepository_base {
7
+ }
8
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderExchangeRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
7
+ class OrderExchangeRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.OrderExchange) {
8
+ }
9
+ exports.OrderExchangeRepository = OrderExchangeRepository;
10
+ (0, base_repository_find_1.setFindMethods)(OrderExchangeRepository, _models_1.OrderExchange);
11
+ //# sourceMappingURL=exchange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../src/repositories/exchange.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAAuC;AACvC,wEAA8D;AAE9D,MAAa,uBAAwB,SAAQ,gBAAQ,CAAC,6BAA6B,CACjF,uBAAa,CACd;CAAG;AAFJ,0DAEI;AAEJ,IAAA,qCAAc,EAAC,uBAAuB,EAAE,uBAAa,CAAC,CAAA"}
@@ -1,2 +1,4 @@
1
1
  export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
- export * from "./order";
2
+ export { OrderClaimRepository } from "./claim";
3
+ export { OrderRepository } from "./order";
4
+ export { ReturnRepository } from "./return";
@@ -1,21 +1,12 @@
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
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.BaseRepository = void 0;
3
+ exports.ReturnRepository = exports.OrderRepository = exports.OrderClaimRepository = exports.BaseRepository = void 0;
18
4
  var utils_1 = require("@medusajs/utils");
19
5
  Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
20
- __exportStar(require("./order"), exports);
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; } });
21
12
  //# 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,0CAAuB"}
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,11 +1,8 @@
1
- import { Context, DAL } from "@medusajs/types";
2
1
  import { DALUtils } from "@medusajs/utils";
3
2
  import { Order } from "../models";
4
3
  declare const OrderRepository_base: new ({ manager }: {
5
4
  manager: any;
6
5
  }) => DALUtils.MikroOrmBaseRepository<Order>;
7
6
  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]>;
10
7
  }
11
8
  export {};
@@ -2,91 +2,10 @@
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");
6
5
  const _models_1 = require("../models");
7
- const transform_order_1 = require("../utils/transform-order");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
8
7
  class OrderRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.Order) {
9
- async find(options, context) {
10
- const manager = this.getActiveManager(context);
11
- const knex = manager.getKnex();
12
- const findOptions_ = { ...options };
13
- findOptions_.options ??= {};
14
- findOptions_.where ??= {};
15
- if (!("strategy" in findOptions_.options)) {
16
- if (findOptions_.options.limit != null || findOptions_.options.offset) {
17
- Object.assign(findOptions_.options, {
18
- strategy: core_1.LoadStrategy.SELECT_IN,
19
- });
20
- }
21
- else {
22
- Object.assign(findOptions_.options, {
23
- strategy: core_1.LoadStrategy.JOINED,
24
- });
25
- }
26
- }
27
- const config = (0, transform_order_1.mapRepositoryToOrderModel)(findOptions_);
28
- let defaultVersion = knex.raw(`"o0"."version"`);
29
- const strategy = config.options.strategy ?? core_1.LoadStrategy.JOINED;
30
- if (strategy === core_1.LoadStrategy.SELECT_IN) {
31
- const sql = manager
32
- .qb(_models_1.Order, "_sub0")
33
- .select("version")
34
- .where({ id: knex.raw(`"o0"."order_id"`) })
35
- .getKnexQuery()
36
- .toString();
37
- defaultVersion = knex.raw(`(${sql})`);
38
- }
39
- const version = config.where.version ?? defaultVersion;
40
- delete config.where?.version;
41
- config.options.populateWhere ??= {};
42
- config.options.populateWhere.items ??= {};
43
- config.options.populateWhere.items.version = version;
44
- config.options.populateWhere.summary ??= {};
45
- config.options.populateWhere.summary.version = version;
46
- config.options.populateWhere.shipping_methods ??= {};
47
- config.options.populateWhere.shipping_methods.version = version;
48
- if (!config.options.orderBy) {
49
- config.options.orderBy = { id: "ASC" };
50
- }
51
- return await manager.find(_models_1.Order, config.where, config.options);
52
- }
53
- async findAndCount(findOptions = { where: {} }, context = {}) {
54
- const manager = this.getActiveManager(context);
55
- const knex = manager.getKnex();
56
- const findOptions_ = { ...findOptions };
57
- findOptions_.options ??= {};
58
- findOptions_.where ??= {};
59
- if (!("strategy" in findOptions_.options)) {
60
- Object.assign(findOptions_.options, {
61
- strategy: core_1.LoadStrategy.SELECT_IN,
62
- });
63
- }
64
- const config = (0, transform_order_1.mapRepositoryToOrderModel)(findOptions_);
65
- let defaultVersion = knex.raw(`"o0"."version"`);
66
- const strategy = config.options.strategy ?? core_1.LoadStrategy.JOINED;
67
- if (strategy === core_1.LoadStrategy.SELECT_IN) {
68
- const sql = manager
69
- .qb(_models_1.Order, "_sub0")
70
- .select("version")
71
- .where({ id: knex.raw(`"o0"."order_id"`) })
72
- .getKnexQuery()
73
- .toString();
74
- defaultVersion = knex.raw(`(${sql})`);
75
- }
76
- const version = config.where.version ?? defaultVersion;
77
- delete config.where.version;
78
- config.options.populateWhere ??= {};
79
- config.options.populateWhere.items ??= {};
80
- config.options.populateWhere.items.version = version;
81
- config.options.populateWhere.summary ??= {};
82
- config.options.populateWhere.summary.version = version;
83
- config.options.populateWhere.shipping_methods ??= {};
84
- config.options.populateWhere.shipping_methods.version = version;
85
- if (!config.options.orderBy) {
86
- config.options.orderBy = { id: "ASC" };
87
- }
88
- return await manager.findAndCount(_models_1.Order, config.where, config.options);
89
- }
90
8
  }
91
9
  exports.OrderRepository = OrderRepository;
10
+ (0, base_repository_find_1.setFindMethods)(OrderRepository, _models_1.Order);
92
11
  //# sourceMappingURL=order.js.map
@@ -1 +1 @@
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,OAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAgB,OAAO,CAAC,CAAA;QAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;QAE9B,MAAM,YAAY,GAAG,EAAE,GAAG,OAAO,EAAS,CAAA;QAC1C,YAAY,CAAC,OAAO,KAAK,EAAE,CAAA;QAC3B,YAAY,CAAC,KAAK,KAAK,EAAE,CAAA;QAEzB,IAAI,CAAC,CAAC,UAAU,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1C,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACtE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;oBAClC,QAAQ,EAAE,mBAAY,CAAC,SAAS;iBACjC,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;oBAClC,QAAQ,EAAE,mBAAY,CAAC,MAAM;iBAC9B,CAAC,CAAA;YACJ,CAAC;QACH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AAQ,gBAAQ,CAAC,6BAA6B,CACzE,eAAK,CACN;CAAG;AAFJ,0CAEI;AAEJ,IAAA,qCAAc,EAAC,eAAe,EAAE,eAAK,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { DALUtils } from "@medusajs/utils";
2
+ import { Return } from "../models";
3
+ declare const ReturnRepository_base: new ({ manager }: {
4
+ manager: any;
5
+ }) => DALUtils.MikroOrmBaseRepository<Return>;
6
+ export declare class ReturnRepository extends ReturnRepository_base {
7
+ }
8
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReturnRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ const base_repository_find_1 = require("../utils/base-repository-find");
7
+ class ReturnRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.Return) {
8
+ }
9
+ exports.ReturnRepository = ReturnRepository;
10
+ (0, base_repository_find_1.setFindMethods)(ReturnRepository, _models_1.Return);
11
+ //# sourceMappingURL=return.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"return.js","sourceRoot":"","sources":["../../src/repositories/return.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,qCAAgC;AAChC,wEAA8D;AAE9D,MAAa,gBAAiB,SAAQ,gBAAQ,CAAC,6BAA6B,CAC1E,gBAAM,CACP;CAAG;AAFJ,4CAEI;AAEJ,IAAA,qCAAc,EAAC,gBAAgB,EAAE,gBAAM,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Context, OrderTypes } from "@medusajs/types";
2
+ export declare function cancelFulfillment(this: any, data: OrderTypes.CancelOrderFulfillmentDTO, sharedContext?: Context): Promise<void>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cancelFulfillment = void 0;
4
+ const utils_1 = require("../../utils");
5
+ async function cancelFulfillment(data, sharedContext) {
6
+ const items = data.items.map((item) => {
7
+ return {
8
+ action: utils_1.ChangeActionType.CANCEL_ITEM_FULFILLMENT,
9
+ internal_note: item.internal_note,
10
+ reference: data.reference,
11
+ reference_id: data.reference_id,
12
+ claim_id: data.claim_id,
13
+ exchange_id: data.exchange_id,
14
+ details: {
15
+ reference_id: item.id,
16
+ quantity: item.quantity,
17
+ metadata: item.metadata,
18
+ },
19
+ };
20
+ });
21
+ const change = await this.createOrderChange_({
22
+ order_id: data.order_id,
23
+ description: data.description,
24
+ internal_note: data.internal_note,
25
+ created_by: data.created_by,
26
+ metadata: data.metadata,
27
+ actions: items,
28
+ }, sharedContext);
29
+ await this.confirmOrderChange(change[0].id, sharedContext);
30
+ }
31
+ exports.cancelFulfillment = cancelFulfillment;
32
+ //# sourceMappingURL=cancel-fulfillment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancel-fulfillment.js","sourceRoot":"","sources":["../../../src/services/actions/cancel-fulfillment.ts"],"names":[],"mappings":";;;AACA,uCAA8C;AAEvC,KAAK,UAAU,iBAAiB,CAErC,IAA0C,EAC1C,aAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,OAAO;YACL,MAAM,EAAE,wBAAgB,CAAC,uBAAuB;YAChD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE;gBACP,YAAY,EAAE,IAAI,CAAC,EAAE;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB;SACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAC1C;QACE,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,OAAO,EAAE,KAAK;KACf,EACD,aAAa,CACd,CAAA;IAED,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA;AAC5D,CAAC;AAlCD,8CAkCC"}
@@ -0,0 +1,2 @@
1
+ import { Context, OrderTypes } from "@medusajs/types";
2
+ export declare function createClaim(this: any, data: OrderTypes.CreateOrderClaimDTO, sharedContext?: Context): Promise<any>;
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createClaim = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../../models");
6
+ const _types_1 = require("../../types");
7
+ const utils_2 = require("../../utils");
8
+ function createClaimAndReturnEntities(em, data, order) {
9
+ const claimReference = em.create(_models_1.OrderClaim, {
10
+ order_id: data.order_id,
11
+ order_version: order.version,
12
+ type: data.type,
13
+ no_notification: data.no_notification,
14
+ refund_amount: data.refund_amount ?? null,
15
+ });
16
+ const returnReference = data.type === utils_1.ClaimType.REPLACE
17
+ ? em.create(_models_1.Return, {
18
+ order_id: data.order_id,
19
+ order_version: order.version,
20
+ status: utils_1.ReturnStatus.REQUESTED,
21
+ claim_id: claimReference.id,
22
+ refund_amount: data.refund_amount ?? null,
23
+ })
24
+ : undefined;
25
+ claimReference.return_id = returnReference?.id;
26
+ return { claimReference, returnReference };
27
+ }
28
+ function createReturnItem(em, item, claimReference, returnReference, actions) {
29
+ actions.push({
30
+ action: utils_2.ChangeActionType.RETURN_ITEM,
31
+ reference: "return",
32
+ reference_id: returnReference.id,
33
+ details: {
34
+ reference_id: item.id,
35
+ return_id: returnReference.id,
36
+ claim_id: claimReference.id,
37
+ quantity: item.quantity,
38
+ metadata: item.metadata,
39
+ },
40
+ });
41
+ return em.create(_models_1.ReturnItem, {
42
+ item_id: item.id,
43
+ return_id: returnReference.id,
44
+ quantity: item.quantity,
45
+ note: item.note,
46
+ metadata: item.metadata,
47
+ });
48
+ }
49
+ function createClaimAndReturnItems(em, data, claimReference, returnReference, actions) {
50
+ const returnItems = [];
51
+ const claimItems = data.claim_items?.map((item) => {
52
+ actions.push({
53
+ action: utils_2.ChangeActionType.WRITE_OFF_ITEM,
54
+ reference: "claim",
55
+ reference_id: claimReference.id,
56
+ details: {
57
+ reference_id: item.id,
58
+ claim_id: claimReference.id,
59
+ quantity: item.quantity,
60
+ metadata: item.metadata,
61
+ },
62
+ });
63
+ returnItems.push(returnReference
64
+ ? createReturnItem(em, item, claimReference, returnReference, actions)
65
+ : undefined);
66
+ return em.create(_models_1.ClaimItem, {
67
+ item_id: item.id,
68
+ reason: item.reason,
69
+ quantity: item.quantity,
70
+ note: item.note,
71
+ metadata: item.metadata,
72
+ });
73
+ });
74
+ return [claimItems, returnItems];
75
+ }
76
+ async function processAdditionalItems(em, service, data, order, claimReference, actions, sharedContext) {
77
+ const itemsToAdd = [];
78
+ const additionalNewItems = [];
79
+ const additionalItems = [];
80
+ data.additional_items?.forEach((item) => {
81
+ const hasItem = item.id
82
+ ? order.items.find((o) => o.item.id === item.id)
83
+ : false;
84
+ if (hasItem) {
85
+ actions.push({
86
+ action: utils_2.ChangeActionType.ITEM_ADD,
87
+ claim_id: claimReference.id,
88
+ internal_note: item.internal_note,
89
+ reference: "claim",
90
+ reference_id: claimReference.id,
91
+ details: {
92
+ reference_id: item.id,
93
+ claim_id: claimReference.id,
94
+ quantity: item.quantity,
95
+ metadata: item.metadata,
96
+ },
97
+ });
98
+ additionalItems.push(em.create(_models_1.ClaimItem, {
99
+ item_id: item.id,
100
+ quantity: item.quantity,
101
+ note: item.note,
102
+ metadata: item.metadata,
103
+ is_additional_item: true,
104
+ }));
105
+ }
106
+ else {
107
+ itemsToAdd.push(item);
108
+ additionalNewItems.push(em.create(_models_1.ClaimItem, {
109
+ quantity: item.quantity,
110
+ note: item.note,
111
+ metadata: item.metadata,
112
+ is_additional_item: true,
113
+ }));
114
+ }
115
+ });
116
+ const createItems = await service.lineItemService_.create(itemsToAdd, sharedContext);
117
+ createItems.forEach((item, index) => {
118
+ const addedItem = itemsToAdd[index];
119
+ additionalNewItems[index].item_id = item.id;
120
+ actions.push({
121
+ action: utils_2.ChangeActionType.ITEM_ADD,
122
+ claim_id: claimReference.id,
123
+ internal_note: addedItem.internal_note,
124
+ reference: "claim",
125
+ reference_id: claimReference.id,
126
+ details: {
127
+ reference_id: item.id,
128
+ claim_id: claimReference.id,
129
+ quantity: addedItem.quantity,
130
+ metadata: addedItem.metadata,
131
+ },
132
+ });
133
+ });
134
+ return additionalNewItems.concat(additionalItems);
135
+ }
136
+ async function processShippingMethods(service, data, claimReference, actions, sharedContext) {
137
+ for (const shippingMethod of data.shipping_methods ?? []) {
138
+ let shippingMethodId;
139
+ if (!(0, utils_1.isString)(shippingMethod)) {
140
+ const methods = await service.createShippingMethods([
141
+ {
142
+ order_id: data.order_id,
143
+ claim_id: claimReference.id,
144
+ ...shippingMethod,
145
+ },
146
+ ], sharedContext);
147
+ shippingMethodId = methods[0].id;
148
+ }
149
+ else {
150
+ shippingMethodId = shippingMethod;
151
+ }
152
+ const method = await service.retrieveShippingMethod(shippingMethodId, { relations: ["tax_lines", "adjustments"] }, sharedContext);
153
+ const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
154
+ actions.push({
155
+ action: utils_2.ChangeActionType.SHIPPING_ADD,
156
+ reference: "order_shipping_method",
157
+ reference_id: shippingMethodId,
158
+ claim_id: claimReference.id,
159
+ amount: calculatedAmount.total,
160
+ });
161
+ }
162
+ }
163
+ async function processReturnShipping(service, data, claimReference, returnReference, actions, sharedContext) {
164
+ if (!returnReference) {
165
+ return;
166
+ }
167
+ if (data.return_shipping) {
168
+ let returnShippingMethodId;
169
+ if (!(0, utils_1.isString)(data.return_shipping)) {
170
+ const methods = await service.createShippingMethods([
171
+ {
172
+ order_id: data.order_id,
173
+ claim_id: claimReference.id,
174
+ return_id: returnReference.id,
175
+ ...data.return_shipping,
176
+ },
177
+ ], sharedContext);
178
+ returnShippingMethodId = methods[0].id;
179
+ }
180
+ else {
181
+ returnShippingMethodId = data.return_shipping;
182
+ }
183
+ const method = await service.retrieveShippingMethod(returnShippingMethodId, { relations: ["tax_lines", "adjustments"] }, sharedContext);
184
+ const calculatedAmount = (0, utils_1.getShippingMethodsTotals)([method], {})[method.id];
185
+ actions.push({
186
+ action: utils_2.ChangeActionType.SHIPPING_ADD,
187
+ reference: "order_shipping_method",
188
+ reference_id: returnShippingMethodId,
189
+ return_id: returnReference.id,
190
+ claim_id: claimReference.id,
191
+ amount: calculatedAmount.total,
192
+ });
193
+ }
194
+ }
195
+ async function createClaim(data, sharedContext) {
196
+ const order = await this.orderService_.retrieve(data.order_id, { relations: ["items"] }, sharedContext);
197
+ const actions = [];
198
+ const em = sharedContext.transactionManager;
199
+ const { claimReference, returnReference } = createClaimAndReturnEntities(em, data, order);
200
+ const [claimItems, returnItems] = createClaimAndReturnItems(em, data, claimReference, returnReference, actions);
201
+ claimReference.claim_items = claimItems;
202
+ if (returnReference) {
203
+ returnReference.items = returnItems;
204
+ }
205
+ claimReference.additional_items = await processAdditionalItems(em, this, data, order, claimReference, actions, sharedContext);
206
+ await processShippingMethods(this, data, claimReference, actions, sharedContext);
207
+ await processReturnShipping(this, data, claimReference, returnReference, actions, sharedContext);
208
+ const change = await this.createOrderChange_({
209
+ order_id: data.order_id,
210
+ claim_id: claimReference.id,
211
+ return_id: returnReference.id,
212
+ change_type: _types_1.OrderChangeType.CLAIM,
213
+ reference: "claim",
214
+ reference_id: claimReference.id,
215
+ description: data.description,
216
+ internal_note: data.internal_note,
217
+ created_by: data.created_by,
218
+ metadata: data.metadata,
219
+ actions,
220
+ }, sharedContext);
221
+ await (0, utils_1.promiseAll)([
222
+ this.createReturns([returnReference], sharedContext),
223
+ this.createOrderClaims([claimReference], sharedContext),
224
+ this.confirmOrderChange(change[0].id, sharedContext),
225
+ ]);
226
+ return claimReference;
227
+ }
228
+ exports.createClaim = createClaim;
229
+ //# sourceMappingURL=create-claim.js.map