@medusajs/order 3.0.0-snapshot-20250410112222 → 3.0.0-snapshot-20251104011621

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/migrations/Migration20240219102530.d.ts +1 -1
  2. package/dist/migrations/Migration20240219102530.d.ts.map +1 -1
  3. package/dist/migrations/Migration20240219102530.js +1 -1
  4. package/dist/migrations/Migration20240219102530.js.map +1 -1
  5. package/dist/migrations/Migration20240604100512.d.ts +1 -1
  6. package/dist/migrations/Migration20240604100512.d.ts.map +1 -1
  7. package/dist/migrations/Migration20240604100512.js +1 -1
  8. package/dist/migrations/Migration20240604100512.js.map +1 -1
  9. package/dist/migrations/Migration20240715102100.d.ts +1 -1
  10. package/dist/migrations/Migration20240715102100.d.ts.map +1 -1
  11. package/dist/migrations/Migration20240715102100.js +1 -1
  12. package/dist/migrations/Migration20240715102100.js.map +1 -1
  13. package/dist/migrations/Migration20240715174100.d.ts +1 -1
  14. package/dist/migrations/Migration20240715174100.d.ts.map +1 -1
  15. package/dist/migrations/Migration20240715174100.js +1 -1
  16. package/dist/migrations/Migration20240715174100.js.map +1 -1
  17. package/dist/migrations/Migration20240716081800.d.ts +1 -1
  18. package/dist/migrations/Migration20240716081800.d.ts.map +1 -1
  19. package/dist/migrations/Migration20240716081800.js +1 -1
  20. package/dist/migrations/Migration20240716081800.js.map +1 -1
  21. package/dist/migrations/Migration20240801085921.d.ts +1 -1
  22. package/dist/migrations/Migration20240801085921.d.ts.map +1 -1
  23. package/dist/migrations/Migration20240801085921.js +1 -1
  24. package/dist/migrations/Migration20240801085921.js.map +1 -1
  25. package/dist/migrations/Migration20240821164505.d.ts +1 -1
  26. package/dist/migrations/Migration20240821164505.d.ts.map +1 -1
  27. package/dist/migrations/Migration20240821164505.js +1 -1
  28. package/dist/migrations/Migration20240821164505.js.map +1 -1
  29. package/dist/migrations/Migration20240821170920.d.ts +1 -1
  30. package/dist/migrations/Migration20240821170920.d.ts.map +1 -1
  31. package/dist/migrations/Migration20240821170920.js +1 -1
  32. package/dist/migrations/Migration20240821170920.js.map +1 -1
  33. package/dist/migrations/Migration20240827133639.d.ts +1 -1
  34. package/dist/migrations/Migration20240827133639.d.ts.map +1 -1
  35. package/dist/migrations/Migration20240827133639.js +1 -1
  36. package/dist/migrations/Migration20240827133639.js.map +1 -1
  37. package/dist/migrations/Migration20240902195921.d.ts +1 -1
  38. package/dist/migrations/Migration20240902195921.d.ts.map +1 -1
  39. package/dist/migrations/Migration20240902195921.js +1 -1
  40. package/dist/migrations/Migration20240902195921.js.map +1 -1
  41. package/dist/migrations/Migration20240913092514.d.ts +1 -1
  42. package/dist/migrations/Migration20240913092514.d.ts.map +1 -1
  43. package/dist/migrations/Migration20240913092514.js +1 -1
  44. package/dist/migrations/Migration20240913092514.js.map +1 -1
  45. package/dist/migrations/Migration20240930122627.d.ts +1 -1
  46. package/dist/migrations/Migration20240930122627.d.ts.map +1 -1
  47. package/dist/migrations/Migration20240930122627.js +1 -1
  48. package/dist/migrations/Migration20240930122627.js.map +1 -1
  49. package/dist/migrations/Migration20241014142943.d.ts +1 -1
  50. package/dist/migrations/Migration20241014142943.d.ts.map +1 -1
  51. package/dist/migrations/Migration20241014142943.js +1 -1
  52. package/dist/migrations/Migration20241014142943.js.map +1 -1
  53. package/dist/migrations/Migration20241106085223.d.ts +1 -1
  54. package/dist/migrations/Migration20241106085223.d.ts.map +1 -1
  55. package/dist/migrations/Migration20241106085223.js +1 -1
  56. package/dist/migrations/Migration20241106085223.js.map +1 -1
  57. package/dist/migrations/Migration20241129124827.d.ts +1 -1
  58. package/dist/migrations/Migration20241129124827.d.ts.map +1 -1
  59. package/dist/migrations/Migration20241129124827.js +1 -1
  60. package/dist/migrations/Migration20241129124827.js.map +1 -1
  61. package/dist/migrations/Migration20241217162224.d.ts +1 -1
  62. package/dist/migrations/Migration20241217162224.d.ts.map +1 -1
  63. package/dist/migrations/Migration20241217162224.js +1 -1
  64. package/dist/migrations/Migration20241217162224.js.map +1 -1
  65. package/dist/migrations/Migration20250326151554.d.ts +1 -1
  66. package/dist/migrations/Migration20250326151554.d.ts.map +1 -1
  67. package/dist/migrations/Migration20250326151554.js +1 -1
  68. package/dist/migrations/Migration20250326151554.js.map +1 -1
  69. package/dist/migrations/Migration20250522181137.d.ts +6 -0
  70. package/dist/migrations/Migration20250522181137.d.ts.map +1 -0
  71. package/dist/migrations/Migration20250522181137.js +19 -0
  72. package/dist/migrations/Migration20250522181137.js.map +1 -0
  73. package/dist/migrations/Migration20250702095353.d.ts +6 -0
  74. package/dist/migrations/Migration20250702095353.d.ts.map +1 -0
  75. package/dist/migrations/Migration20250702095353.js +14 -0
  76. package/dist/migrations/Migration20250702095353.js.map +1 -0
  77. package/dist/migrations/Migration20250704120229.d.ts +6 -0
  78. package/dist/migrations/Migration20250704120229.d.ts.map +1 -0
  79. package/dist/migrations/Migration20250704120229.js +16 -0
  80. package/dist/migrations/Migration20250704120229.js.map +1 -0
  81. package/dist/migrations/Migration20250910130000.d.ts +6 -0
  82. package/dist/migrations/Migration20250910130000.d.ts.map +1 -0
  83. package/dist/migrations/Migration20250910130000.js +239 -0
  84. package/dist/migrations/Migration20250910130000.js.map +1 -0
  85. package/dist/migrations/Migration20251016182939.d.ts +6 -0
  86. package/dist/migrations/Migration20251016182939.d.ts.map +1 -0
  87. package/dist/migrations/Migration20251016182939.js +38 -0
  88. package/dist/migrations/Migration20251016182939.js.map +1 -0
  89. package/dist/migrations/Migration20251017155709.d.ts +6 -0
  90. package/dist/migrations/Migration20251017155709.d.ts.map +1 -0
  91. package/dist/migrations/Migration20251017155709.js +20 -0
  92. package/dist/migrations/Migration20251017155709.js.map +1 -0
  93. package/dist/models/claim-item-image.js +1 -1
  94. package/dist/models/claim-item-image.js.map +1 -1
  95. package/dist/models/claim-item.js +2 -2
  96. package/dist/models/claim-item.js.map +1 -1
  97. package/dist/models/claim.js +3 -3
  98. package/dist/models/claim.js.map +1 -1
  99. package/dist/models/credit-line.d.ts +6 -5
  100. package/dist/models/credit-line.d.ts.map +1 -1
  101. package/dist/models/credit-line.js +11 -4
  102. package/dist/models/credit-line.js.map +1 -1
  103. package/dist/models/exchange-item.js +2 -2
  104. package/dist/models/exchange-item.js.map +1 -1
  105. package/dist/models/exchange.js +3 -3
  106. package/dist/models/exchange.js.map +1 -1
  107. package/dist/models/line-item-adjustment.d.ts.map +1 -1
  108. package/dist/models/line-item-adjustment.js +1 -0
  109. package/dist/models/line-item-adjustment.js.map +1 -1
  110. package/dist/models/line-item.js +3 -3
  111. package/dist/models/line-item.js.map +1 -1
  112. package/dist/models/order-change-action.js +6 -6
  113. package/dist/models/order-change-action.js.map +1 -1
  114. package/dist/models/order-change.js +6 -6
  115. package/dist/models/order-change.js.map +1 -1
  116. package/dist/models/order-item.js +5 -5
  117. package/dist/models/order-item.js.map +1 -1
  118. package/dist/models/order-shipping-method.js +8 -8
  119. package/dist/models/order-shipping-method.js.map +1 -1
  120. package/dist/models/order-summary.js +1 -1
  121. package/dist/models/order-summary.js.map +1 -1
  122. package/dist/models/order.d.ts.map +1 -1
  123. package/dist/models/order.js +19 -11
  124. package/dist/models/order.js.map +1 -1
  125. package/dist/models/return-item.js +3 -3
  126. package/dist/models/return-item.js.map +1 -1
  127. package/dist/models/return-reason.js +2 -2
  128. package/dist/models/return-reason.js.map +1 -1
  129. package/dist/models/return.js +4 -4
  130. package/dist/models/return.js.map +1 -1
  131. package/dist/models/transaction.d.ts +4 -1
  132. package/dist/models/transaction.d.ts.map +1 -1
  133. package/dist/models/transaction.js +7 -7
  134. package/dist/models/transaction.js.map +1 -1
  135. package/dist/services/actions/cancel-return.d.ts.map +1 -1
  136. package/dist/services/actions/cancel-return.js +1 -0
  137. package/dist/services/actions/cancel-return.js.map +1 -1
  138. package/dist/services/actions/create-return.d.ts.map +1 -1
  139. package/dist/services/actions/create-return.js +1 -0
  140. package/dist/services/actions/create-return.js.map +1 -1
  141. package/dist/services/order-module-service.d.ts +41 -56
  142. package/dist/services/order-module-service.d.ts.map +1 -1
  143. package/dist/services/order-module-service.js +579 -281
  144. package/dist/services/order-module-service.js.map +1 -1
  145. package/dist/services/order-service.d.ts +5 -44
  146. package/dist/services/order-service.d.ts.map +1 -1
  147. package/dist/tsconfig.tsbuildinfo +1 -1
  148. package/dist/utils/apply-order-changes.d.ts +58 -2
  149. package/dist/utils/apply-order-changes.d.ts.map +1 -1
  150. package/dist/utils/apply-order-changes.js +21 -13
  151. package/dist/utils/apply-order-changes.js.map +1 -1
  152. package/dist/utils/base-repository-find.d.ts.map +1 -1
  153. package/dist/utils/base-repository-find.js +5 -6
  154. package/dist/utils/base-repository-find.js.map +1 -1
  155. package/dist/utils/calculate-order-change.d.ts.map +1 -1
  156. package/dist/utils/calculate-order-change.js +1 -18
  157. package/dist/utils/calculate-order-change.js.map +1 -1
  158. package/dist/utils/transform-order.js.map +1 -1
  159. package/package.json +14 -28
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
21
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
23
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
31
41
  var __metadata = (this && this.__metadata) || function (k, v) {
32
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
43
  };
@@ -35,9 +45,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
35
45
  return function (target, key) { decorator(target, key, paramIndex); }
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
+ const core_1 = require("@medusajs/framework/mikro-orm/core");
38
49
  const types_1 = require("@medusajs/framework/types");
39
50
  const utils_1 = require("@medusajs/framework/utils");
40
- const core_1 = require("@mikro-orm/core");
41
51
  const _models_1 = require("../models");
42
52
  const joiner_config_1 = require("../joiner-config");
43
53
  const utils_2 = require("../utils");
@@ -70,11 +80,15 @@ const generateMethodForModels = {
70
80
  {
71
81
  const MikroORMEntity = (0, utils_1.toMikroORMEntity)(_models_1.OrderChangeAction);
72
82
  MikroORMEntity.prototype["onInit_OrderChangeAction"] = function () {
73
- this.version ??= this.order_change?.version ?? null;
74
- this.order_id ??= this.order_change?.order_id ?? null;
75
- this.claim_id ??= this.order_change?.claim_id ?? null;
76
- this.exchange_id ??= this.order_change?.exchange_id ?? null;
77
- if (!this.claim_id && !this.exchange_id) {
83
+ if (this.order_change) {
84
+ this.version ??= this.order_change.version ?? null;
85
+ this.order_id ??= this.order_change.order_id ?? null;
86
+ this.claim_id ??= this.order_change.claim_id ?? null;
87
+ this.exchange_id ??= this.order_change.exchange_id ?? null;
88
+ }
89
+ if (!this.claim_id &&
90
+ !this.exchange_id &&
91
+ (this.return || this.order_change)) {
78
92
  this.return_id = this.return?.id ?? this.order_change?.return_id ?? null;
79
93
  }
80
94
  };
@@ -84,12 +98,9 @@ const generateMethodForModels = {
84
98
  {
85
99
  const MikroORMEntity = (0, utils_1.toMikroORMEntity)(_models_1.OrderShipping);
86
100
  MikroORMEntity.prototype["onInit_OrderShipping"] = function () {
87
- this.version ??= this.order?.version ?? null;
88
- this.order ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.Order), this.order?.id ?? null);
89
- this.return ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.Return), this.return?.id ?? null);
90
- this.claim ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.OrderClaim), this.claim?.id ?? null);
91
- this.exchange ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.OrderExchange), this.exchange?.id ?? null);
92
- this.shipping_method ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.OrderShippingMethod), this.shipping_method?.id ?? null);
101
+ if (this.order) {
102
+ this.version ??= this.order.version ?? null;
103
+ }
93
104
  };
94
105
  (0, core_1.OnInit)()(MikroORMEntity.prototype, "onInit_OrderShipping");
95
106
  (0, core_1.BeforeCreate)()(MikroORMEntity.prototype, "onInit_OrderShipping");
@@ -97,9 +108,9 @@ const generateMethodForModels = {
97
108
  {
98
109
  const MikroORMEntity = (0, utils_1.toMikroORMEntity)(_models_1.OrderItem);
99
110
  MikroORMEntity.prototype["onInit_OrderItem"] = function () {
100
- this.version ??= this.order?.version ?? null;
101
- this.order ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.Order), this.order?.id ?? null);
102
- this.item ??= (0, core_1.rel)((0, utils_1.toMikroORMEntity)(_models_1.OrderLineItem), this.item?.id ?? null);
111
+ if (this.order) {
112
+ this.version ??= this.order.version ?? null;
113
+ }
103
114
  };
104
115
  (0, core_1.OnInit)()(MikroORMEntity.prototype, "onInit_OrderItem");
105
116
  (0, core_1.BeforeCreate)()(MikroORMEntity.prototype, "onInit_OrderItem");
@@ -145,6 +156,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
145
156
  "discount_tax_total",
146
157
  "original_total",
147
158
  "original_tax_total",
159
+ "pending_difference",
148
160
  "item_total",
149
161
  "item_subtotal",
150
162
  "item_tax_total",
@@ -157,9 +169,13 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
157
169
  "original_shipping_tax_total",
158
170
  "original_shipping_subtotal",
159
171
  "original_shipping_total",
172
+ "original_total",
173
+ "original_subtotal",
174
+ "original_tax_total",
160
175
  "credit_line_total",
161
176
  "credit_line_tax_total",
162
177
  "credit_line_subtotal",
178
+ "refundable_amount",
163
179
  ];
164
180
  const includeTotals = (config?.select ?? []).some((field) => totalFields.includes(field));
165
181
  if (includeTotals) {
@@ -201,6 +217,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
201
217
  }
202
218
  // @ts-expect-error
203
219
  async listOrders(filters, config, sharedContext) {
220
+ const orders = await this.listOrders_(filters, config, sharedContext);
221
+ return this.baseRepository_.serialize(orders);
222
+ }
223
+ async listOrders_(filters, config, sharedContext) {
204
224
  config ??= {};
205
225
  const includeTotals = this.shouldIncludeTotals(config);
206
226
  const orders = await super.listOrders(filters, config, sharedContext);
@@ -349,7 +369,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
349
369
  const lineItemsToCreate = [];
350
370
  const creditLinesToCreate = [];
351
371
  const createdOrders = [];
352
- for (const { items, shipping_methods, credit_lines, ...order } of data) {
372
+ for (const { items, shipping_methods, credit_lines, shipping_address, billing_address, ...order } of data) {
353
373
  const ord = order;
354
374
  const shippingMethods = shipping_methods?.map((sm) => {
355
375
  return {
@@ -431,11 +451,33 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
431
451
  });
432
452
  }
433
453
  // @ts-expect-error
454
+ async deleteOrders(orderIds, sharedContext = {}) {
455
+ const ids = Array.isArray(orderIds) ? orderIds : [orderIds];
456
+ const orders = await this.orderService_.list({ id: ids }, {
457
+ select: ["id", "shipping_address_id", "billing_address_id"],
458
+ }, sharedContext);
459
+ const orderAddressIds = orders
460
+ .map((order) => [order.shipping_address_id, order.billing_address_id])
461
+ .flat(1);
462
+ const orderChanges = await this.orderChangeService_.list({ order_id: ids }, { select: ["id"] }, sharedContext);
463
+ const orderChangeIds = orderChanges.map((orderChange) => orderChange.id);
464
+ const orderItems = await this.orderItemService_.list({ order_id: ids }, { select: ["id", "item_id"] }, sharedContext);
465
+ const lineItemIds = orderItems.map((orderItem) => orderItem.item_id);
466
+ const orderShipping = await this.orderShippingService_.list({ order_id: ids }, { select: ["shipping_method_id"] }, sharedContext);
467
+ const orderShippingMethodIds = orderShipping.map((orderShipping) => orderShipping.shipping_method_id);
468
+ await this.orderAddressService_.delete(orderAddressIds, sharedContext);
469
+ await this.orderChangeService_.delete(orderChangeIds, sharedContext);
470
+ // Delete order, order items, summary, shipping methods, transactions and credit lines
471
+ await super.deleteOrders(ids, sharedContext);
472
+ await (0, utils_1.promiseAll)([
473
+ this.orderLineItemService_.delete(lineItemIds, sharedContext),
474
+ this.orderShippingMethodService_.delete(orderShippingMethodIds, sharedContext),
475
+ ]);
476
+ }
477
+ // @ts-expect-error
434
478
  async updateOrders(dataOrIdOrSelector, data, sharedContext = {}) {
435
479
  const result = await this.updateOrders_(dataOrIdOrSelector, data, sharedContext);
436
- const serializedResult = await this.baseRepository_.serialize(result, {
437
- populate: true,
438
- });
480
+ const serializedResult = await this.baseRepository_.serialize(result);
439
481
  return (0, utils_1.isString)(dataOrIdOrSelector) ? serializedResult[0] : serializedResult;
440
482
  }
441
483
  async updateOrders_(dataOrIdOrSelector, data, sharedContext = {}) {
@@ -474,7 +516,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
474
516
  ? orderIdOrData
475
517
  : [orderIdOrData];
476
518
  const allOrderIds = data.map((dt) => dt.order_id);
477
- const order = await this.listOrders({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
519
+ const order = await this.listOrders_({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
478
520
  const mapOrderVersion = order.reduce((acc, curr) => {
479
521
  acc[curr.id] = curr.version;
480
522
  return acc;
@@ -487,9 +529,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
487
529
  });
488
530
  items = await this.createOrderLineItemsBulk_(lineItems, sharedContext);
489
531
  }
490
- return await this.baseRepository_.serialize(items, {
491
- populate: true,
492
- });
532
+ return await this.baseRepository_.serialize(items);
493
533
  }
494
534
  async createOrderLineItems_(orderId, items, sharedContext = {}) {
495
535
  const order = await this.retrieveOrder(orderId, { select: ["id", "version"] }, sharedContext);
@@ -527,9 +567,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
527
567
  let items = [];
528
568
  if ((0, utils_1.isString)(lineItemIdOrDataOrSelector)) {
529
569
  const item = await this.updateOrderLineItem_(lineItemIdOrDataOrSelector, data, sharedContext);
530
- return await this.baseRepository_.serialize(item, {
531
- populate: true,
532
- });
570
+ return await this.baseRepository_.serialize(item);
533
571
  }
534
572
  const toUpdate = Array.isArray(lineItemIdOrDataOrSelector)
535
573
  ? lineItemIdOrDataOrSelector
@@ -540,9 +578,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
540
578
  },
541
579
  ];
542
580
  items = await this.updateOrderLineItemsWithSelector_(toUpdate, sharedContext);
543
- return await this.baseRepository_.serialize(items, {
544
- populate: true,
545
- });
581
+ return await this.baseRepository_.serialize(items);
546
582
  }
547
583
  async updateOrderLineItem_(lineItemId, data, sharedContext = {}) {
548
584
  const [item] = await this.orderLineItemService_.update([{ id: lineItemId, ...data }], sharedContext);
@@ -560,7 +596,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
560
596
  let toUpdate = [];
561
597
  const detailsToUpdate = [];
562
598
  for (const { selector, data } of updates) {
563
- const items = await this.listOrderLineItems({ ...selector }, {}, sharedContext);
599
+ const items = await this.orderLineItemService_.list({ ...selector }, {}, sharedContext);
564
600
  items.forEach((item) => {
565
601
  toUpdate.push({
566
602
  ...data,
@@ -583,9 +619,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
583
619
  let items = [];
584
620
  if ((0, utils_1.isString)(orderItemIdOrDataOrSelector)) {
585
621
  const item = await this.updateOrderItem_(orderItemIdOrDataOrSelector, data, sharedContext);
586
- return await this.baseRepository_.serialize(item, {
587
- populate: true,
588
- });
622
+ return await this.baseRepository_.serialize(item);
589
623
  }
590
624
  const toUpdate = Array.isArray(orderItemIdOrDataOrSelector)
591
625
  ? orderItemIdOrDataOrSelector
@@ -596,9 +630,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
596
630
  },
597
631
  ];
598
632
  items = await this.updateOrderItemWithSelector_(toUpdate, sharedContext);
599
- return await this.baseRepository_.serialize(items, {
600
- populate: true,
601
- });
633
+ return await this.baseRepository_.serialize(items);
602
634
  }
603
635
  async updateOrderItem_(orderItemId, data, sharedContext = {}) {
604
636
  const [detail] = await this.orderItemService_.update([{ id: orderItemId, ...data }], sharedContext);
@@ -607,7 +639,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
607
639
  async updateOrderItemWithSelector_(updates, sharedContext = {}) {
608
640
  let toUpdate = [];
609
641
  for (const { selector, data } of updates) {
610
- const details = await this.listOrderItems({ ...selector }, {}, sharedContext);
642
+ const details = await this.orderItemService_.list({ ...selector }, {}, sharedContext);
611
643
  details.forEach((detail) => {
612
644
  toUpdate.push({
613
645
  ...data,
@@ -628,7 +660,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
628
660
  ? orderIdOrData
629
661
  : [orderIdOrData];
630
662
  const allOrderIds = data.map((dt) => dt.order_id);
631
- const order = await this.listOrders({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
663
+ const order = await this.listOrders_({ id: allOrderIds }, { select: ["id", "version"] }, sharedContext);
632
664
  const mapOrderVersion = order.reduce((acc, curr) => {
633
665
  acc[curr.id] = curr.version;
634
666
  return acc;
@@ -645,7 +677,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
645
677
  });
646
678
  methods = await this.createOrderShippingMethodsBulk_(orderShippingMethodData, sharedContext);
647
679
  }
648
- return await this.baseRepository_.serialize(methods, { populate: true });
680
+ return await this.baseRepository_.serialize(methods);
649
681
  }
650
682
  async createOrderShippingMethods_(orderId, data, sharedContext = {}) {
651
683
  const order = await this.retrieveOrder(orderId, { select: ["id", "version"] }, sharedContext);
@@ -666,7 +698,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
666
698
  return sm.map((s) => s.shipping_method);
667
699
  }
668
700
  // @ts-ignore
669
- async softDeleteOrderShippingMethods(ids, config, sharedContext) {
701
+ async softDeleteOrderShippingMethods(ids, config, sharedContext = {}) {
702
+ return await this.softDeleteOrderShippingMethods_(ids, config, sharedContext);
703
+ }
704
+ async softDeleteOrderShippingMethods_(ids, config, sharedContext = {}) {
670
705
  const rel = await super.listOrderShippings({
671
706
  shipping_method_id: ids,
672
707
  }, {
@@ -680,7 +715,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
680
715
  return returned;
681
716
  }
682
717
  // @ts-ignore
683
- async restoreOrderShippingMethods(ids, config, sharedContext) {
718
+ async restoreOrderShippingMethods(ids, config, sharedContext = {}) {
719
+ return await this.restoreOrderShippingMethods_(ids, config, sharedContext);
720
+ }
721
+ async restoreOrderShippingMethods_(ids, config, sharedContext = {}) {
684
722
  const rel = await super.listOrderShippings({
685
723
  shipping_method_id: ids,
686
724
  }, {
@@ -695,6 +733,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
695
733
  }
696
734
  // @ts-expect-error
697
735
  async createOrderLineItemAdjustments(orderIdOrData, adjustments, sharedContext = {}) {
736
+ const addedAdjustments = await this.createOrderLineItemAdjustments_(orderIdOrData, adjustments, sharedContext);
737
+ return await this.baseRepository_.serialize(addedAdjustments);
738
+ }
739
+ async createOrderLineItemAdjustments_(orderIdOrData, adjustments, sharedContext = {}) {
698
740
  let addedAdjustments = [];
699
741
  if ((0, utils_1.isString)(orderIdOrData)) {
700
742
  const order = await this.retrieveOrder(orderIdOrData, { select: ["id"], relations: ["items.item"] }, sharedContext);
@@ -712,17 +754,20 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
712
754
  : [orderIdOrData];
713
755
  addedAdjustments = await this.orderLineItemAdjustmentService_.create(data, sharedContext);
714
756
  }
715
- return await this.baseRepository_.serialize(addedAdjustments, {
716
- populate: true,
717
- });
757
+ return addedAdjustments;
718
758
  }
719
759
  async upsertOrderLineItemAdjustments(adjustments, sharedContext = {}) {
720
- let result = await this.orderLineItemAdjustmentService_.upsert(adjustments, sharedContext);
721
- return await this.baseRepository_.serialize(result, {
722
- populate: true,
723
- });
760
+ let result = await this.upsertOrderLineItemAdjustments_(adjustments, sharedContext);
761
+ return await this.baseRepository_.serialize(result);
762
+ }
763
+ async upsertOrderLineItemAdjustments_(adjustments, sharedContext = {}) {
764
+ return await this.orderLineItemAdjustmentService_.upsert(adjustments, sharedContext);
724
765
  }
725
766
  async setOrderLineItemAdjustments(orderId, adjustments, sharedContext = {}) {
767
+ const result = await this.setOrderLineItemAdjustments_(orderId, adjustments, sharedContext);
768
+ return await this.baseRepository_.serialize(result);
769
+ }
770
+ async setOrderLineItemAdjustments_(orderId, adjustments, sharedContext = {}) {
726
771
  const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["items.item.adjustments"] }, sharedContext);
727
772
  const existingAdjustments = (order.items ?? [])
728
773
  .map((item) => item.adjustments ?? [])
@@ -741,18 +786,21 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
741
786
  if (toDelete.length) {
742
787
  await this.orderLineItemAdjustmentService_.delete(toDelete, sharedContext);
743
788
  }
744
- let result = await this.orderLineItemAdjustmentService_.upsert(adjustments, sharedContext);
745
- return await this.baseRepository_.serialize(result, {
746
- populate: true,
747
- });
789
+ const result = await this.orderLineItemAdjustmentService_.upsert(adjustments, sharedContext);
790
+ return result;
748
791
  }
749
792
  async upsertOrderShippingMethodAdjustments(adjustments, sharedContext = {}) {
750
- const result = await this.orderShippingMethodAdjustmentService_.upsert(adjustments, sharedContext);
751
- return await this.baseRepository_.serialize(result, {
752
- populate: true,
753
- });
793
+ const result = await this.upsertOrderShippingMethodAdjustments_(adjustments, sharedContext);
794
+ return await this.baseRepository_.serialize(result);
795
+ }
796
+ async upsertOrderShippingMethodAdjustments_(adjustments, sharedContext = {}) {
797
+ return await this.orderShippingMethodAdjustmentService_.upsert(adjustments, sharedContext);
754
798
  }
755
799
  async setOrderShippingMethodAdjustments(orderId, adjustments, sharedContext = {}) {
800
+ const result = await this.setOrderShippingMethodAdjustments_(orderId, adjustments, sharedContext);
801
+ return await this.baseRepository_.serialize(result);
802
+ }
803
+ async setOrderShippingMethodAdjustments_(orderId, adjustments, sharedContext = {}) {
756
804
  const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["shipping_methods.adjustments"] }, sharedContext);
757
805
  const existingAdjustments = (order.shipping_methods ?? [])
758
806
  .map((shippingMethod) => shippingMethod.adjustments ?? [])
@@ -772,12 +820,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
772
820
  await this.orderShippingMethodAdjustmentService_.delete(toDelete, sharedContext);
773
821
  }
774
822
  const result = await this.orderShippingMethodAdjustmentService_.upsert(adjustments, sharedContext);
775
- return await this.baseRepository_.serialize(result, {
776
- populate: true,
777
- });
823
+ return result;
778
824
  }
779
825
  // @ts-expect-error
780
826
  async createOrderShippingMethodAdjustments(orderIdOrData, adjustments, sharedContext = {}) {
827
+ const addedAdjustments = await this.createOrderShippingMethodAdjustments_(orderIdOrData, adjustments, sharedContext);
828
+ return await this.baseRepository_.serialize(addedAdjustments);
829
+ }
830
+ async createOrderShippingMethodAdjustments_(orderIdOrData, adjustments, sharedContext = {}) {
781
831
  let addedAdjustments = [];
782
832
  if ((0, utils_1.isString)(orderIdOrData)) {
783
833
  const order = await this.retrieveOrder(orderIdOrData, { select: ["id"], relations: ["shipping_methods"] }, sharedContext);
@@ -798,16 +848,20 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
798
848
  await this.orderShippingMethodAdjustmentService_.create(data, sharedContext);
799
849
  }
800
850
  if ((0, utils_1.isObject)(orderIdOrData)) {
801
- return await this.baseRepository_.serialize(addedAdjustments[0], {
802
- populate: true,
803
- });
851
+ return addedAdjustments[0];
804
852
  }
805
- return await this.baseRepository_.serialize(addedAdjustments, {
806
- populate: true,
807
- });
853
+ return addedAdjustments;
808
854
  }
809
855
  // @ts-expect-error
810
856
  async createOrderLineItemTaxLines(orderIdOrData, taxLines, sharedContext = {}) {
857
+ const addedTaxLines = await this.createOrderLineItemTaxLines_(orderIdOrData, taxLines, sharedContext);
858
+ const serialized = await this.baseRepository_.serialize(addedTaxLines);
859
+ if ((0, utils_1.isObject)(orderIdOrData)) {
860
+ return serialized[0];
861
+ }
862
+ return serialized;
863
+ }
864
+ async createOrderLineItemTaxLines_(orderIdOrData, taxLines, sharedContext = {}) {
811
865
  let addedTaxLines;
812
866
  if ((0, utils_1.isString)(orderIdOrData)) {
813
867
  const lines = Array.isArray(taxLines) ? taxLines : [taxLines];
@@ -819,21 +873,24 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
819
873
  : [orderIdOrData];
820
874
  addedTaxLines = await this.orderLineItemTaxLineService_.create(data, sharedContext);
821
875
  }
822
- const serialized = await this.baseRepository_.serialize(addedTaxLines, {
823
- populate: true,
824
- });
825
876
  if ((0, utils_1.isObject)(orderIdOrData)) {
826
- return serialized[0];
877
+ return addedTaxLines[0];
827
878
  }
828
- return serialized;
879
+ return addedTaxLines;
829
880
  }
830
881
  async upsertOrderLineItemTaxLines(taxLines, sharedContext = {}) {
882
+ const result = await this.upsertOrderLineItemTaxLines_(taxLines, sharedContext);
883
+ return await this.baseRepository_.serialize(result);
884
+ }
885
+ async upsertOrderLineItemTaxLines_(taxLines, sharedContext = {}) {
831
886
  const result = await this.orderLineItemTaxLineService_.upsert(taxLines, sharedContext);
832
- return await this.baseRepository_.serialize(result, {
833
- populate: true,
834
- });
887
+ return result;
835
888
  }
836
889
  async setOrderLineItemTaxLines(orderId, taxLines, sharedContext = {}) {
890
+ const result = await this.setOrderLineItemTaxLines_(orderId, taxLines, sharedContext);
891
+ return await this.baseRepository_.serialize(result);
892
+ }
893
+ async setOrderLineItemTaxLines_(orderId, taxLines, sharedContext = {}) {
837
894
  const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["items.item.tax_lines"] }, sharedContext);
838
895
  const existingTaxLines = (order.items ?? [])
839
896
  .map((item) => item.tax_lines ?? [])
@@ -852,12 +909,18 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
852
909
  await this.orderLineItemTaxLineService_.delete(toDelete, sharedContext);
853
910
  }
854
911
  const result = await this.orderLineItemTaxLineService_.upsert(taxLines, sharedContext);
855
- return await this.baseRepository_.serialize(result, {
856
- populate: true,
857
- });
912
+ return result;
858
913
  }
859
914
  // @ts-expect-error
860
915
  async createOrderShippingMethodTaxLines(orderIdOrData, taxLines, sharedContext = {}) {
916
+ const addedTaxLines = await this.createOrderShippingMethodTaxLines_(orderIdOrData, taxLines, sharedContext);
917
+ const serialized = await this.baseRepository_.serialize(addedTaxLines);
918
+ if ((0, utils_1.isObject)(orderIdOrData)) {
919
+ return serialized[0];
920
+ }
921
+ return serialized;
922
+ }
923
+ async createOrderShippingMethodTaxLines_(orderIdOrData, taxLines, sharedContext = {}) {
861
924
  let addedTaxLines;
862
925
  if ((0, utils_1.isString)(orderIdOrData)) {
863
926
  const lines = Array.isArray(taxLines) ? taxLines : [taxLines];
@@ -866,21 +929,17 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
866
929
  else {
867
930
  addedTaxLines = await this.orderShippingMethodTaxLineService_.create(taxLines, sharedContext);
868
931
  }
869
- const serialized = await this.baseRepository_.serialize(addedTaxLines[0], {
870
- populate: true,
871
- });
872
- if ((0, utils_1.isObject)(orderIdOrData)) {
873
- return serialized[0];
874
- }
875
- return serialized;
932
+ return addedTaxLines;
876
933
  }
877
934
  async upsertOrderShippingMethodTaxLines(taxLines, sharedContext = {}) {
878
935
  const result = await this.orderShippingMethodTaxLineService_.upsert(taxLines, sharedContext);
879
- return await this.baseRepository_.serialize(result, {
880
- populate: true,
881
- });
936
+ return await this.baseRepository_.serialize(result);
882
937
  }
883
938
  async setOrderShippingMethodTaxLines(orderId, taxLines, sharedContext = {}) {
939
+ const result = await this.setOrderShippingMethodTaxLines_(orderId, taxLines, sharedContext);
940
+ return await this.baseRepository_.serialize(result);
941
+ }
942
+ async setOrderShippingMethodTaxLines_(orderId, taxLines, sharedContext = {}) {
884
943
  const order = await this.retrieveOrder(orderId, { select: ["id"], relations: ["shipping_methods.tax_lines"] }, sharedContext);
885
944
  const existingTaxLines = (order.shipping_methods ?? [])
886
945
  .map((shippingMethod) => shippingMethod.tax_lines ?? [])
@@ -899,32 +958,24 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
899
958
  await this.orderShippingMethodTaxLineService_.delete(toDelete, sharedContext);
900
959
  }
901
960
  const result = await this.orderShippingMethodTaxLineService_.upsert(taxLines, sharedContext);
902
- return await this.baseRepository_.serialize(result, {
903
- populate: true,
904
- });
961
+ return result;
905
962
  }
906
963
  // @ts-expect-error
907
- async createReturns(data, sharedContext) {
964
+ async createReturns(data, sharedContext = {}) {
908
965
  const created = await this.createOrderRelatedEntity_(data, this.returnService_, sharedContext);
909
- return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
910
- populate: true,
911
- });
966
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created);
912
967
  }
913
968
  // @ts-expect-error
914
- async createOrderClaims(data, sharedContext) {
969
+ async createOrderClaims(data, sharedContext = {}) {
915
970
  const created = await this.createOrderRelatedEntity_(data, this.orderClaimService_, sharedContext);
916
- return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
917
- populate: true,
918
- });
971
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created);
919
972
  }
920
973
  // @ts-expect-error
921
- async createOrderExchanges(data, sharedContext) {
974
+ async createOrderExchanges(data, sharedContext = {}) {
922
975
  const created = await this.createOrderRelatedEntity_(data, this.orderExchangeService_, sharedContext);
923
- return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created, {
924
- populate: true,
925
- });
976
+ return await this.baseRepository_.serialize(!Array.isArray(data) ? created[0] : created);
926
977
  }
927
- async createOrderRelatedEntity_(data, service, sharedContext) {
978
+ async createOrderRelatedEntity_(data, service, sharedContext = {}) {
928
979
  const data_ = Array.isArray(data) ? data : [data];
929
980
  const inputDataMap = data_.reduce((acc, curr) => {
930
981
  acc[curr.order_id] = curr;
@@ -942,17 +993,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
942
993
  }
943
994
  return await service.create(data_, sharedContext);
944
995
  }
945
- async createOrderChange(data, sharedContext) {
996
+ async createOrderChange(data, sharedContext = {}) {
946
997
  const changes = await this.createOrderChange_(data, sharedContext);
947
- return await this.baseRepository_.serialize(Array.isArray(data) ? changes : changes[0], {
948
- populate: true,
949
- });
998
+ return await this.baseRepository_.serialize(Array.isArray(data) ? changes : changes[0]);
950
999
  }
951
- async createOrderChange_(data, sharedContext) {
1000
+ async createOrderChange_(data, sharedContext = {}) {
952
1001
  const dataArr = Array.isArray(data) ? data : [data];
953
1002
  const orderIds = [];
954
1003
  const dataMap = {};
955
- const orderChanges = await this.listOrderChanges({
1004
+ const orderChanges = await this.orderChangeService_.list({
956
1005
  order_id: dataArr.map((data) => data.order_id),
957
1006
  status: [utils_1.OrderChangeStatus.PENDING, utils_1.OrderChangeStatus.REQUESTED],
958
1007
  }, {}, sharedContext);
@@ -979,7 +1028,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
979
1028
  });
980
1029
  return await this.orderChangeService_.create(input, sharedContext);
981
1030
  }
982
- async previewOrderChange(orderId, sharedContext) {
1031
+ async previewOrderChange(orderId, sharedContext = {}) {
983
1032
  const order = await this.retrieveOrder(orderId, {
984
1033
  select: ["id", "version", "items.detail", "summary", "total"],
985
1034
  relations: ["transactions", "credit_lines"],
@@ -997,7 +1046,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
997
1046
  (0, utils_1.createRawPropertiesFromBigNumber)(calcOrder);
998
1047
  return calcOrder;
999
1048
  }
1000
- async includeTaxLinesAndAdjustementsToPreview(order, itemsToUpsert, shippingMethodsToUpsert, sharedContext) {
1049
+ async includeTaxLinesAndAdjustementsToPreview(order, itemsToUpsert, shippingMethodsToUpsert, sharedContext = {}) {
1001
1050
  const addedItems = {};
1002
1051
  const addedShippingMethods = {};
1003
1052
  for (const item of order.items) {
@@ -1073,7 +1122,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1073
1122
  });
1074
1123
  }
1075
1124
  }
1076
- async cancelOrderChange(orderChangeIdOrData, sharedContext) {
1125
+ async cancelOrderChange(orderChangeIdOrData, sharedContext = {}) {
1077
1126
  const data = Array.isArray(orderChangeIdOrData)
1078
1127
  ? orderChangeIdOrData
1079
1128
  : [orderChangeIdOrData];
@@ -1090,7 +1139,11 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1090
1139
  });
1091
1140
  await this.orderChangeService_.update(updates, sharedContext);
1092
1141
  }
1093
- async confirmOrderChange(orderChangeIdOrData, sharedContext) {
1142
+ async confirmOrderChange(orderChangeIdOrData, sharedContext = {}) {
1143
+ const result = await this.confirmOrderChange_(orderChangeIdOrData, sharedContext);
1144
+ return await this.baseRepository_.serialize(result);
1145
+ }
1146
+ async confirmOrderChange_(orderChangeIdOrData, sharedContext = {}) {
1094
1147
  const data = Array.isArray(orderChangeIdOrData)
1095
1148
  ? orderChangeIdOrData
1096
1149
  : [orderChangeIdOrData];
@@ -1111,7 +1164,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1111
1164
  });
1112
1165
  return await this.applyOrderChanges_(orderChanges.flat(), sharedContext);
1113
1166
  }
1114
- async declineOrderChange(orderChangeIdOrData, sharedContext) {
1167
+ async declineOrderChange(orderChangeIdOrData, sharedContext = {}) {
1168
+ await this.declineOrderChange_(orderChangeIdOrData, sharedContext);
1169
+ }
1170
+ async declineOrderChange_(orderChangeIdOrData, sharedContext = {}) {
1115
1171
  const data = Array.isArray(orderChangeIdOrData)
1116
1172
  ? orderChangeIdOrData
1117
1173
  : [orderChangeIdOrData];
@@ -1128,11 +1184,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1128
1184
  });
1129
1185
  await this.orderChangeService_.update(updates, sharedContext);
1130
1186
  }
1131
- async registerOrderChange(data, sharedContext) {
1187
+ async registerOrderChange(data, sharedContext = {}) {
1188
+ const result = await this.registerOrderChange_(data, sharedContext);
1189
+ return await this.baseRepository_.serialize(result);
1190
+ }
1191
+ async registerOrderChange_(data, sharedContext = {}) {
1132
1192
  const inputData = Array.isArray(data) ? data : [data];
1133
1193
  const orders = await this.orderService_.list({ id: inputData.map((d) => d.order_id) }, { select: ["id", "version"] }, sharedContext);
1134
1194
  const orderVersionsMap = new Map(orders.map((o) => [o.id, o.version]));
1135
- const changes = (await this.orderChangeService_.create(inputData.map((d) => ({
1195
+ const changes = await this.orderChangeService_.create(inputData.map((d) => ({
1136
1196
  order_id: d.order_id,
1137
1197
  change_type: d.change_type,
1138
1198
  internal_note: d.internal_note,
@@ -1151,10 +1211,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1151
1211
  applied: true,
1152
1212
  },
1153
1213
  ],
1154
- })), sharedContext));
1155
- return Array.isArray(data) ? changes : changes[0];
1214
+ })), sharedContext);
1215
+ return changes;
1216
+ }
1217
+ async applyPendingOrderActions(orderId, sharedContext = {}) {
1218
+ const result = await this.applyPendingOrderActions_(orderId, sharedContext);
1219
+ return await this.baseRepository_.serialize(result);
1156
1220
  }
1157
- async applyPendingOrderActions(orderId, sharedContext) {
1221
+ async applyPendingOrderActions_(orderId, sharedContext = {}) {
1158
1222
  const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1159
1223
  const orders = await this.orderService_.list({ id: orderIds }, {
1160
1224
  select: ["id", "version"],
@@ -1187,7 +1251,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1187
1251
  }, sharedContext);
1188
1252
  return await this.applyOrderChanges_(changes, sharedContext);
1189
1253
  }
1190
- async revertLastVersion(orderId, sharedContext) {
1254
+ async revertLastVersion(orderId, sharedContext = {}) {
1191
1255
  const order = await super.retrieveOrder(orderId, {
1192
1256
  select: ["id", "version"],
1193
1257
  }, sharedContext);
@@ -1196,7 +1260,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1196
1260
  }
1197
1261
  return await this.revertLastChange_(order, sharedContext);
1198
1262
  }
1199
- async undoLastChange(orderId, lastOrderChange, sharedContext) {
1263
+ async undoLastChange(orderId, lastOrderChange, sharedContext = {}) {
1200
1264
  const order = await super.retrieveOrder(orderId, {
1201
1265
  select: ["id", "version"],
1202
1266
  }, sharedContext);
@@ -1205,7 +1269,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1205
1269
  }
1206
1270
  return await this.undoLastChange_(order, lastOrderChange, sharedContext);
1207
1271
  }
1208
- async undoLastChange_(order, lastOrderChange, sharedContext) {
1272
+ async undoLastChange_(order, lastOrderChange, sharedContext = {}) {
1209
1273
  const currentVersion = order.version;
1210
1274
  const updatePromises = [];
1211
1275
  // Order Changes
@@ -1254,6 +1318,13 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1254
1318
  }, { select: ["id", "version"] }, sharedContext);
1255
1319
  const orderShippingIds = orderShippings.map((sh) => sh.id);
1256
1320
  updatePromises.push(this.orderShippingService_.softDelete(orderShippingIds, sharedContext));
1321
+ // Order Credit Lines
1322
+ const orderCreditLines = await this.orderCreditLineService_.list({
1323
+ order_id: order.id,
1324
+ version: currentVersion,
1325
+ }, { select: ["id", "version"] }, sharedContext);
1326
+ const orderCreditLineIds = orderCreditLines.map((cl) => cl.id);
1327
+ updatePromises.push(this.orderCreditLineService_.softDelete(orderCreditLineIds, sharedContext));
1257
1328
  // Order
1258
1329
  updatePromises.push(this.orderService_.update({
1259
1330
  selector: {
@@ -1265,7 +1336,7 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1265
1336
  }, sharedContext));
1266
1337
  await (0, utils_1.promiseAll)(updatePromises);
1267
1338
  }
1268
- async revertLastChange_(order, sharedContext) {
1339
+ async revertLastChange_(order, sharedContext = {}) {
1269
1340
  const currentVersion = order.version;
1270
1341
  const updatePromises = [];
1271
1342
  // Order Changes
@@ -1303,6 +1374,13 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1303
1374
  }, { select: ["id", "version"] }, sharedContext);
1304
1375
  const orderShippingIds = orderShippings.map((sh) => sh.id);
1305
1376
  updatePromises.push(this.orderShippingService_.softDelete(orderShippingIds, sharedContext));
1377
+ // Order Credit Lines
1378
+ const orderCreditLines = await this.orderCreditLineService_.list({
1379
+ order_id: order.id,
1380
+ version: currentVersion,
1381
+ }, { select: ["id", "version"] }, sharedContext);
1382
+ const orderCreditLineIds = orderCreditLines.map((cl) => cl.id);
1383
+ updatePromises.push(this.orderCreditLineService_.softDelete(orderCreditLineIds, sharedContext));
1306
1384
  // Order
1307
1385
  updatePromises.push(this.orderService_.update({
1308
1386
  selector: {
@@ -1397,7 +1475,12 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1397
1475
  }
1398
1476
  return orderChanges;
1399
1477
  }
1400
- async addOrderAction(data, sharedContext) {
1478
+ async addOrderAction(data, sharedContext = {}) {
1479
+ const actions = await this.addOrderAction_(data, sharedContext);
1480
+ const serializedActions = await this.baseRepository_.serialize(actions);
1481
+ return Array.isArray(data) ? serializedActions : serializedActions[0];
1482
+ }
1483
+ async addOrderAction_(data, sharedContext = {}) {
1401
1484
  let dataArr = Array.isArray(data) ? data : [data];
1402
1485
  const orderChangeMap = {};
1403
1486
  const orderChangeIds = dataArr
@@ -1420,10 +1503,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1420
1503
  });
1421
1504
  }
1422
1505
  }
1423
- const actions = (await this.orderChangeActionService_.create(dataArr, sharedContext));
1424
- return Array.isArray(data) ? actions : actions[0];
1506
+ const actions = await this.orderChangeActionService_.create(dataArr, sharedContext);
1507
+ return actions;
1425
1508
  }
1426
- async applyOrderChanges_(changeActions, sharedContext) {
1509
+ async applyOrderChanges_(changeActions, sharedContext = {}) {
1427
1510
  const actionsMap = {};
1428
1511
  const ordersIds = [];
1429
1512
  const usedActions = [];
@@ -1450,18 +1533,18 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1450
1533
  credit_lines: [],
1451
1534
  };
1452
1535
  }
1453
- let orders = await this.listOrders({ id: (0, utils_1.deduplicate)(ordersIds) }, {
1536
+ let orders = await this.listOrders_({ id: (0, utils_1.deduplicate)(ordersIds) }, {
1454
1537
  select: ["id", "version", "items.detail", "summary", "total"],
1455
1538
  relations: ["transactions", "credit_lines"],
1456
1539
  }, sharedContext);
1457
- const { itemsToUpsert, shippingMethodsToUpsert, summariesToUpsert, orderToUpdate, creditLinesToCreate, } = await (0, utils_2.applyChangesToOrder)(orders, actionsMap, {
1540
+ const { itemsToUpsert, shippingMethodsToUpsert, summariesToUpsert, orderToUpdate, creditLinesToUpsert, } = await (0, utils_2.applyChangesToOrder)(orders, actionsMap, {
1458
1541
  addActionReferenceToObject: true,
1459
1542
  includeTaxLinesAndAdjustementsToPreview: async (...args) => {
1460
1543
  args.push(sharedContext);
1461
1544
  return await this.includeTaxLinesAndAdjustementsToPreview.apply(this, args);
1462
1545
  },
1463
1546
  });
1464
- const [_orderUpdate, _orderChangeActionUpdate, orderItems, _orderSummaryUpdate, orderShippingMethods, createdOrderCreditLines,] = await (0, utils_1.promiseAll)([
1547
+ const [_orderUpdate, _orderChangeActionUpdate, orderItems, _orderSummaryUpdate, orderShippingMethods, orderCreditLines,] = await (0, utils_1.promiseAll)([
1465
1548
  orderToUpdate.length
1466
1549
  ? this.orderService_.update(orderToUpdate, sharedContext)
1467
1550
  : null,
@@ -1477,17 +1560,24 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1477
1560
  shippingMethodsToUpsert.length
1478
1561
  ? this.orderShippingService_.upsert(shippingMethodsToUpsert, sharedContext)
1479
1562
  : null,
1480
- creditLinesToCreate.length
1481
- ? this.orderCreditLineService_.create(creditLinesToCreate, sharedContext)
1563
+ creditLinesToUpsert.length
1564
+ ? this.orderCreditLineService_.upsert(creditLinesToUpsert, sharedContext)
1482
1565
  : null,
1483
1566
  ]);
1484
1567
  return {
1485
1568
  items: orderItems ?? [],
1486
1569
  shipping_methods: orderShippingMethods ?? [],
1487
- credit_lines: createdOrderCreditLines ?? [],
1570
+ credit_lines: orderCreditLines ?? [],
1488
1571
  };
1489
1572
  }
1490
- async addOrderTransactions(transactionData, sharedContext) {
1573
+ async addOrderTransactions(transactionData, sharedContext = {}) {
1574
+ const created = await this.addOrderTransactions_(transactionData, sharedContext);
1575
+ const serializedTransactions = await this.baseRepository_.serialize(created);
1576
+ return Array.isArray(transactionData)
1577
+ ? serializedTransactions
1578
+ : serializedTransactions[0];
1579
+ }
1580
+ async addOrderTransactions_(transactionData, sharedContext = {}) {
1491
1581
  const orders = await this.orderService_.list({
1492
1582
  id: Array.isArray(transactionData)
1493
1583
  ? transactionData.map((t) => t.order_id)
@@ -1507,12 +1597,10 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1507
1597
  }
1508
1598
  const created = (await this.orderTransactionService_.create(data, sharedContext));
1509
1599
  await this.updateOrderPaidRefundableAmount_(created, false, sharedContext);
1510
- return await this.baseRepository_.serialize(!Array.isArray(transactionData) ? created[0] : created, {
1511
- populate: true,
1512
- });
1600
+ return created;
1513
1601
  }
1514
1602
  // @ts-ignore
1515
- async deleteOrderTransactions(transactionIds, sharedContext) {
1603
+ async deleteOrderTransactions(transactionIds, sharedContext = {}) {
1516
1604
  const data = Array.isArray(transactionIds)
1517
1605
  ? transactionIds
1518
1606
  : [transactionIds];
@@ -1525,7 +1613,11 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1525
1613
  await this.updateOrderPaidRefundableAmount_(transactions, true, sharedContext);
1526
1614
  }
1527
1615
  // @ts-ignore
1528
- async softDeleteOrderTransactions(transactionIds, config, sharedContext) {
1616
+ async softDeleteOrderTransactions(transactionIds, config, sharedContext = {}) {
1617
+ const returned = await this.softDeleteOrderTransactions_(transactionIds, config, sharedContext);
1618
+ return returned;
1619
+ }
1620
+ async softDeleteOrderTransactions_(transactionIds, config, sharedContext = {}) {
1529
1621
  const transactions = await super.listOrderTransactions({
1530
1622
  id: transactionIds,
1531
1623
  }, {
@@ -1536,7 +1628,11 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1536
1628
  return returned;
1537
1629
  }
1538
1630
  // @ts-ignore
1539
- async restoreOrderTransactions(transactionIds, config, sharedContext) {
1631
+ async restoreOrderTransactions(transactionIds, config, sharedContext = {}) {
1632
+ const returned = await this.restoreOrderTransactions_(transactionIds, config, sharedContext);
1633
+ return returned;
1634
+ }
1635
+ async restoreOrderTransactions_(transactionIds, config, sharedContext = {}) {
1540
1636
  const transactions = await super.listOrderTransactions({
1541
1637
  id: transactionIds,
1542
1638
  }, {
@@ -1547,8 +1643,8 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1547
1643
  await this.updateOrderPaidRefundableAmount_(transactions, false, sharedContext);
1548
1644
  return returned;
1549
1645
  }
1550
- async updateOrderPaidRefundableAmount_(transactionData, isRemoved, sharedContext) {
1551
- const summaries = await super.listOrderSummaries({
1646
+ async updateOrderPaidRefundableAmount_(transactionData, isRemoved, sharedContext = {}) {
1647
+ const summaries = await this.listOrderSummaries({
1552
1648
  order_id: transactionData.map((trx) => trx.order_id),
1553
1649
  version: transactionData[0].version,
1554
1650
  }, {}, sharedContext);
@@ -1575,9 +1671,13 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1575
1671
  (0, utils_1.createRawPropertiesFromBigNumber)(summaries);
1576
1672
  await this.orderSummaryService_.update(summaries, sharedContext);
1577
1673
  }
1578
- async archive(orderId, sharedContext) {
1674
+ async archive(orderId, sharedContext = {}) {
1675
+ const orders = await this.archive_(orderId, sharedContext);
1676
+ return await this.baseRepository_.serialize(Array.isArray(orderId) ? orders : orders[0]);
1677
+ }
1678
+ async archive_(orderId, sharedContext = {}) {
1579
1679
  const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1580
- const orders = await this.listOrders({
1680
+ const orders = await this.listOrders_({
1581
1681
  id: orderIds,
1582
1682
  }, {}, sharedContext);
1583
1683
  const notAllowed = [];
@@ -1600,11 +1700,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1600
1700
  status: utils_1.OrderStatus.ARCHIVED,
1601
1701
  };
1602
1702
  }), sharedContext);
1603
- return Array.isArray(orderId) ? orders : orders[0];
1703
+ return orders;
1604
1704
  }
1605
- async completeOrder(orderId, sharedContext) {
1705
+ async completeOrder(orderId, sharedContext = {}) {
1706
+ const orders = await this.completeOrder_(orderId, sharedContext);
1707
+ return await this.baseRepository_.serialize(Array.isArray(orderId) ? orders : orders[0]);
1708
+ }
1709
+ async completeOrder_(orderId, sharedContext = {}) {
1606
1710
  const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1607
- const orders = await this.listOrders({
1711
+ const orders = await this.listOrders_({
1608
1712
  id: orderIds,
1609
1713
  }, {}, sharedContext);
1610
1714
  const notAllowed = [];
@@ -1623,11 +1727,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1623
1727
  status: utils_1.OrderStatus.COMPLETED,
1624
1728
  };
1625
1729
  }), sharedContext);
1626
- return Array.isArray(orderId) ? orders : orders[0];
1730
+ return orders;
1731
+ }
1732
+ async cancel(orderId, sharedContext = {}) {
1733
+ const orders = await this.cancel_(orderId, sharedContext);
1734
+ return await this.baseRepository_.serialize(Array.isArray(orderId) ? orders : orders[0]);
1627
1735
  }
1628
- async cancel(orderId, sharedContext) {
1736
+ async cancel_(orderId, sharedContext = {}) {
1629
1737
  const orderIds = Array.isArray(orderId) ? orderId : [orderId];
1630
- const orders = await this.listOrders({
1738
+ const orders = await this.listOrders_({
1631
1739
  id: orderIds,
1632
1740
  }, {}, sharedContext);
1633
1741
  const canceled_at = new Date();
@@ -1642,10 +1750,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1642
1750
  canceled_at,
1643
1751
  };
1644
1752
  }), sharedContext);
1645
- return Array.isArray(orderId) ? orders : orders[0];
1753
+ return orders;
1646
1754
  }
1647
1755
  // ------------------- Bundled Order Actions
1648
- async createReturn(data, sharedContext) {
1756
+ async createReturn(data, sharedContext = {}) {
1757
+ const ret = await this.createReturn_(data, sharedContext);
1758
+ return await this.baseRepository_.serialize(ret);
1759
+ }
1760
+ async createReturn_(data, sharedContext = {}) {
1649
1761
  const ret = await BundledActions.createReturn.bind(this)(data, sharedContext);
1650
1762
  return await this.retrieveReturn(ret.id, {
1651
1763
  relations: [
@@ -1656,9 +1768,9 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1656
1768
  ],
1657
1769
  }, sharedContext);
1658
1770
  }
1659
- async receiveReturn(data, sharedContext) {
1771
+ async receiveReturn(data, sharedContext = {}) {
1660
1772
  const ret = await this.receiveReturn_(data, sharedContext);
1661
- return await this.retrieveReturn(ret.id, {
1773
+ const returned = await this.retrieveReturn(ret[0].id, {
1662
1774
  relations: [
1663
1775
  "items",
1664
1776
  "items.item",
@@ -1667,13 +1779,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1667
1779
  "shipping_methods.adjustments",
1668
1780
  ],
1669
1781
  });
1782
+ return await this.baseRepository_.serialize(returned);
1670
1783
  }
1671
- async receiveReturn_(data, sharedContext) {
1784
+ async receiveReturn_(data, sharedContext = {}) {
1672
1785
  return await BundledActions.receiveReturn.bind(this)(data, sharedContext);
1673
1786
  }
1674
- async cancelReturn(data, sharedContext) {
1787
+ async cancelReturn(data, sharedContext = {}) {
1675
1788
  const ret = await this.cancelReturn_(data, sharedContext);
1676
- return await this.retrieveReturn(ret.id, {
1789
+ const returned = await this.retrieveReturn(ret.id, {
1677
1790
  relations: [
1678
1791
  "items",
1679
1792
  "shipping_methods",
@@ -1681,11 +1794,12 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1681
1794
  "shipping_methods.adjustments",
1682
1795
  ],
1683
1796
  });
1797
+ return await this.baseRepository_.serialize(returned);
1684
1798
  }
1685
- async cancelReturn_(data, sharedContext) {
1799
+ async cancelReturn_(data, sharedContext = {}) {
1686
1800
  return await BundledActions.cancelReturn.bind(this)(data, sharedContext);
1687
1801
  }
1688
- async createClaim(data, sharedContext) {
1802
+ async createClaim(data, sharedContext = {}) {
1689
1803
  const ret = await this.createClaim_(data, sharedContext);
1690
1804
  const claim = await this.retrieveOrderClaim(ret.id, {
1691
1805
  relations: [
@@ -1701,23 +1815,22 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1701
1815
  "transactions",
1702
1816
  ],
1703
1817
  }, sharedContext);
1704
- return await this.baseRepository_.serialize(claim, {
1705
- populate: true,
1706
- });
1818
+ return await this.baseRepository_.serialize(claim);
1707
1819
  }
1708
- async createClaim_(data, sharedContext) {
1820
+ async createClaim_(data, sharedContext = {}) {
1709
1821
  return await BundledActions.createClaim.bind(this)(data, sharedContext);
1710
1822
  }
1711
- async cancelClaim(data, sharedContext) {
1823
+ async cancelClaim(data, sharedContext = {}) {
1712
1824
  const ret = await this.cancelClaim_(data, sharedContext);
1713
- return await this.retrieveOrderClaim(ret.id, {
1825
+ const claim = await this.retrieveOrderClaim(ret.id, {
1714
1826
  relations: ["additional_items", "claim_items", "return", "return.items"],
1715
1827
  });
1828
+ return await this.baseRepository_.serialize(claim);
1716
1829
  }
1717
- async cancelClaim_(data, sharedContext) {
1830
+ async cancelClaim_(data, sharedContext = {}) {
1718
1831
  return await BundledActions.cancelClaim.bind(this)(data, sharedContext);
1719
1832
  }
1720
- async createExchange(data, sharedContext) {
1833
+ async createExchange(data, sharedContext = {}) {
1721
1834
  const ret = await this.createExchange_(data, sharedContext);
1722
1835
  const exchange = await this.retrieveOrderExchange(ret.id, {
1723
1836
  relations: [
@@ -1731,12 +1844,14 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1731
1844
  "transactions",
1732
1845
  ],
1733
1846
  }, sharedContext);
1734
- return await this.baseRepository_.serialize(exchange, {
1735
- populate: true,
1736
- });
1847
+ return await this.baseRepository_.serialize(exchange);
1737
1848
  }
1738
1849
  // @ts-expect-error
1739
1850
  async updateReturnReasons(idOrSelector, data, sharedContext = {}) {
1851
+ const reasons = await this.updateReturnReasons_(idOrSelector, data, sharedContext);
1852
+ return await this.baseRepository_.serialize((0, utils_1.isString)(idOrSelector) ? reasons[0] : reasons);
1853
+ }
1854
+ async updateReturnReasons_(idOrSelector, data, sharedContext = {}) {
1740
1855
  let normalizedInput = [];
1741
1856
  if ((0, utils_1.isString)(idOrSelector)) {
1742
1857
  // Check if the return reason exists in the first place
@@ -1751,34 +1866,32 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1751
1866
  }));
1752
1867
  }
1753
1868
  const reasons = await this.returnReasonService_.update(normalizedInput, sharedContext);
1754
- const updatedReturnReasons = await this.baseRepository_.serialize(reasons);
1755
- return (0, utils_1.isString)(idOrSelector)
1756
- ? updatedReturnReasons[0]
1757
- : updatedReturnReasons;
1869
+ return reasons;
1758
1870
  }
1759
- async createExchange_(data, sharedContext) {
1871
+ async createExchange_(data, sharedContext = {}) {
1760
1872
  return await BundledActions.createExchange.bind(this)(data, sharedContext);
1761
1873
  }
1762
- async cancelExchange(data, sharedContext) {
1874
+ async cancelExchange(data, sharedContext = {}) {
1763
1875
  const ret = await this.cancelExchange_(data, sharedContext);
1764
- return await this.retrieveOrderExchange(ret.id, {
1876
+ const exchange = await this.retrieveOrderExchange(ret.id, {
1765
1877
  relations: ["additional_items", "return", "return.items"],
1766
1878
  });
1879
+ return await this.baseRepository_.serialize(exchange);
1767
1880
  }
1768
- async cancelExchange_(data, sharedContext) {
1881
+ async cancelExchange_(data, sharedContext = {}) {
1769
1882
  return await BundledActions.cancelExchange.bind(this)(data, sharedContext);
1770
1883
  }
1771
- async registerFulfillment(data, sharedContext) {
1772
- return await BundledActions.registerFulfillment.bind(this)(data, sharedContext);
1884
+ async registerFulfillment(data, sharedContext = {}) {
1885
+ await BundledActions.registerFulfillment.bind(this)(data, sharedContext);
1773
1886
  }
1774
- async cancelFulfillment(data, sharedContext) {
1775
- return await BundledActions.cancelFulfillment.bind(this)(data, sharedContext);
1887
+ async cancelFulfillment(data, sharedContext = {}) {
1888
+ await BundledActions.cancelFulfillment.bind(this)(data, sharedContext);
1776
1889
  }
1777
- async registerShipment(data, sharedContext) {
1778
- return await BundledActions.registerShipment.bind(this)(data, sharedContext);
1890
+ async registerShipment(data, sharedContext = {}) {
1891
+ await BundledActions.registerShipment.bind(this)(data, sharedContext);
1779
1892
  }
1780
- async registerDelivery(data, sharedContext) {
1781
- return await BundledActions.registerDelivery.bind(this)(data, sharedContext);
1893
+ async registerDelivery(data, sharedContext = {}) {
1894
+ await BundledActions.registerDelivery.bind(this)(data, sharedContext);
1782
1895
  }
1783
1896
  // @ts-expect-error
1784
1897
  async createReturnItems(data, sharedContext) {
@@ -1786,80 +1899,15 @@ class OrderModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateM
1786
1899
  }
1787
1900
  }
1788
1901
  exports.default = OrderModuleService;
1789
- __decorate([
1790
- __param(2, (0, utils_1.MedusaContext)()),
1791
- __metadata("design:type", Function),
1792
- __metadata("design:paramtypes", [String, Object, Object]),
1793
- __metadata("design:returntype", Promise)
1794
- ], OrderModuleService.prototype, "retrieveOrder", null);
1795
- __decorate([
1796
- __param(2, (0, utils_1.MedusaContext)()),
1797
- __metadata("design:type", Function),
1798
- __metadata("design:paramtypes", [Object, Object, Object]),
1799
- __metadata("design:returntype", Promise)
1800
- ], OrderModuleService.prototype, "listOrders", null);
1801
- __decorate([
1802
- __param(2, (0, utils_1.MedusaContext)()),
1803
- __metadata("design:type", Function),
1804
- __metadata("design:paramtypes", [Object, Object, Object]),
1805
- __metadata("design:returntype", Promise)
1806
- ], OrderModuleService.prototype, "listAndCountOrders", null);
1807
- __decorate([
1808
- __param(2, (0, utils_1.MedusaContext)()),
1809
- __metadata("design:type", Function),
1810
- __metadata("design:paramtypes", [String, Object, Object]),
1811
- __metadata("design:returntype", Promise)
1812
- ], OrderModuleService.prototype, "retrieveReturn", null);
1813
- __decorate([
1814
- __param(2, (0, utils_1.MedusaContext)()),
1815
- __metadata("design:type", Function),
1816
- __metadata("design:paramtypes", [Object, Object, Object]),
1817
- __metadata("design:returntype", Promise)
1818
- ], OrderModuleService.prototype, "listReturns", null);
1819
- __decorate([
1820
- __param(2, (0, utils_1.MedusaContext)()),
1821
- __metadata("design:type", Function),
1822
- __metadata("design:paramtypes", [Object, Object, Object]),
1823
- __metadata("design:returntype", Promise)
1824
- ], OrderModuleService.prototype, "listAndCountReturns", null);
1825
- __decorate([
1826
- __param(2, (0, utils_1.MedusaContext)()),
1827
- __metadata("design:type", Function),
1828
- __metadata("design:paramtypes", [String, Object, Object]),
1829
- __metadata("design:returntype", Promise)
1830
- ], OrderModuleService.prototype, "retrieveOrderClaim", null);
1831
- __decorate([
1832
- __param(2, (0, utils_1.MedusaContext)()),
1833
- __metadata("design:type", Function),
1834
- __metadata("design:paramtypes", [Object, Object, Object]),
1835
- __metadata("design:returntype", Promise)
1836
- ], OrderModuleService.prototype, "listOrderClaims", null);
1837
- __decorate([
1838
- __param(2, (0, utils_1.MedusaContext)()),
1839
- __metadata("design:type", Function),
1840
- __metadata("design:paramtypes", [Object, Object, Object]),
1841
- __metadata("design:returntype", Promise)
1842
- ], OrderModuleService.prototype, "listAndCountOrderClaims", null);
1843
- __decorate([
1844
- __param(2, (0, utils_1.MedusaContext)()),
1845
- __metadata("design:type", Function),
1846
- __metadata("design:paramtypes", [String, Object, Object]),
1847
- __metadata("design:returntype", Promise)
1848
- ], OrderModuleService.prototype, "retrieveOrderExchange", null);
1849
- __decorate([
1850
- __param(2, (0, utils_1.MedusaContext)()),
1851
- __metadata("design:type", Function),
1852
- __metadata("design:paramtypes", [Object, Object, Object]),
1853
- __metadata("design:returntype", Promise)
1854
- ], OrderModuleService.prototype, "listOrderExchanges", null);
1855
1902
  __decorate([
1856
1903
  __param(2, (0, utils_1.MedusaContext)()),
1857
1904
  __metadata("design:type", Function),
1858
1905
  __metadata("design:paramtypes", [Object, Object, Object]),
1859
1906
  __metadata("design:returntype", Promise)
1860
- ], OrderModuleService.prototype, "listAndCountOrderExchanges", null);
1907
+ ], OrderModuleService.prototype, "listOrders_", null);
1861
1908
  __decorate([
1862
- (0, utils_1.InjectManager)()
1909
+ (0, utils_1.InjectManager)(),
1910
+ (0, utils_1.EmitEvents)()
1863
1911
  // @ts-expect-error
1864
1912
  ,
1865
1913
  __param(1, (0, utils_1.MedusaContext)()),
@@ -1882,7 +1930,18 @@ __decorate([
1882
1930
  __metadata("design:returntype", Promise)
1883
1931
  ], OrderModuleService.prototype, "createOrderAddresses_", null);
1884
1932
  __decorate([
1885
- (0, utils_1.InjectManager)()
1933
+ (0, utils_1.InjectTransactionManager)(),
1934
+ (0, utils_1.EmitEvents)()
1935
+ // @ts-expect-error
1936
+ ,
1937
+ __param(1, (0, utils_1.MedusaContext)()),
1938
+ __metadata("design:type", Function),
1939
+ __metadata("design:paramtypes", [Object, Object]),
1940
+ __metadata("design:returntype", Promise)
1941
+ ], OrderModuleService.prototype, "deleteOrders", null);
1942
+ __decorate([
1943
+ (0, utils_1.InjectManager)(),
1944
+ (0, utils_1.EmitEvents)()
1886
1945
  // @ts-expect-error
1887
1946
  ,
1888
1947
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1898,7 +1957,8 @@ __decorate([
1898
1957
  __metadata("design:returntype", Promise)
1899
1958
  ], OrderModuleService.prototype, "updateOrders_", null);
1900
1959
  __decorate([
1901
- (0, utils_1.InjectManager)()
1960
+ (0, utils_1.InjectManager)(),
1961
+ (0, utils_1.EmitEvents)()
1902
1962
  // @ts-expect-error
1903
1963
  ,
1904
1964
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1921,7 +1981,8 @@ __decorate([
1921
1981
  __metadata("design:returntype", Promise)
1922
1982
  ], OrderModuleService.prototype, "createOrderLineItemsBulk_", null);
1923
1983
  __decorate([
1924
- (0, utils_1.InjectManager)()
1984
+ (0, utils_1.InjectManager)(),
1985
+ (0, utils_1.EmitEvents)()
1925
1986
  // @ts-expect-error
1926
1987
  ,
1927
1988
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1945,6 +2006,7 @@ __decorate([
1945
2006
  ], OrderModuleService.prototype, "updateOrderLineItemsWithSelector_", null);
1946
2007
  __decorate([
1947
2008
  (0, utils_1.InjectManager)(),
2009
+ (0, utils_1.EmitEvents)(),
1948
2010
  __param(2, (0, utils_1.MedusaContext)()),
1949
2011
  __metadata("design:type", Function),
1950
2012
  __metadata("design:paramtypes", [Object, Object, Object]),
@@ -1965,7 +2027,8 @@ __decorate([
1965
2027
  __metadata("design:returntype", Promise)
1966
2028
  ], OrderModuleService.prototype, "updateOrderItemWithSelector_", null);
1967
2029
  __decorate([
1968
- (0, utils_1.InjectManager)()
2030
+ (0, utils_1.InjectManager)(),
2031
+ (0, utils_1.EmitEvents)()
1969
2032
  // @ts-expect-error
1970
2033
  ,
1971
2034
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1988,7 +2051,8 @@ __decorate([
1988
2051
  __metadata("design:returntype", Promise)
1989
2052
  ], OrderModuleService.prototype, "createOrderShippingMethodsBulk_", null);
1990
2053
  __decorate([
1991
- (0, utils_1.InjectManager)()
2054
+ (0, utils_1.InjectManager)(),
2055
+ (0, utils_1.EmitEvents)()
1992
2056
  // @ts-ignore
1993
2057
  ,
1994
2058
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1997,7 +2061,15 @@ __decorate([
1997
2061
  __metadata("design:returntype", Promise)
1998
2062
  ], OrderModuleService.prototype, "softDeleteOrderShippingMethods", null);
1999
2063
  __decorate([
2000
- (0, utils_1.InjectManager)()
2064
+ (0, utils_1.InjectTransactionManager)(),
2065
+ __param(2, (0, utils_1.MedusaContext)()),
2066
+ __metadata("design:type", Function),
2067
+ __metadata("design:paramtypes", [Object, Object, Object]),
2068
+ __metadata("design:returntype", Promise)
2069
+ ], OrderModuleService.prototype, "softDeleteOrderShippingMethods_", null);
2070
+ __decorate([
2071
+ (0, utils_1.InjectManager)(),
2072
+ (0, utils_1.EmitEvents)()
2001
2073
  // @ts-ignore
2002
2074
  ,
2003
2075
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2006,7 +2078,15 @@ __decorate([
2006
2078
  __metadata("design:returntype", Promise)
2007
2079
  ], OrderModuleService.prototype, "restoreOrderShippingMethods", null);
2008
2080
  __decorate([
2009
- (0, utils_1.InjectTransactionManager)()
2081
+ (0, utils_1.InjectTransactionManager)(),
2082
+ __param(2, (0, utils_1.MedusaContext)()),
2083
+ __metadata("design:type", Function),
2084
+ __metadata("design:paramtypes", [Object, Object, Object]),
2085
+ __metadata("design:returntype", Promise)
2086
+ ], OrderModuleService.prototype, "restoreOrderShippingMethods_", null);
2087
+ __decorate([
2088
+ (0, utils_1.InjectManager)(),
2089
+ (0, utils_1.EmitEvents)()
2010
2090
  // @ts-expect-error
2011
2091
  ,
2012
2092
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2016,6 +2096,14 @@ __decorate([
2016
2096
  ], OrderModuleService.prototype, "createOrderLineItemAdjustments", null);
2017
2097
  __decorate([
2018
2098
  (0, utils_1.InjectTransactionManager)(),
2099
+ __param(2, (0, utils_1.MedusaContext)()),
2100
+ __metadata("design:type", Function),
2101
+ __metadata("design:paramtypes", [Object, Array, Object]),
2102
+ __metadata("design:returntype", Promise)
2103
+ ], OrderModuleService.prototype, "createOrderLineItemAdjustments_", null);
2104
+ __decorate([
2105
+ (0, utils_1.InjectManager)(),
2106
+ (0, utils_1.EmitEvents)(),
2019
2107
  __param(1, (0, utils_1.MedusaContext)()),
2020
2108
  __metadata("design:type", Function),
2021
2109
  __metadata("design:paramtypes", [Array, Object]),
@@ -2023,6 +2111,14 @@ __decorate([
2023
2111
  ], OrderModuleService.prototype, "upsertOrderLineItemAdjustments", null);
2024
2112
  __decorate([
2025
2113
  (0, utils_1.InjectTransactionManager)(),
2114
+ __param(1, (0, utils_1.MedusaContext)()),
2115
+ __metadata("design:type", Function),
2116
+ __metadata("design:paramtypes", [Array, Object]),
2117
+ __metadata("design:returntype", Promise)
2118
+ ], OrderModuleService.prototype, "upsertOrderLineItemAdjustments_", null);
2119
+ __decorate([
2120
+ (0, utils_1.InjectManager)(),
2121
+ (0, utils_1.EmitEvents)(),
2026
2122
  __param(2, (0, utils_1.MedusaContext)()),
2027
2123
  __metadata("design:type", Function),
2028
2124
  __metadata("design:paramtypes", [String, Array, Object]),
@@ -2030,6 +2126,14 @@ __decorate([
2030
2126
  ], OrderModuleService.prototype, "setOrderLineItemAdjustments", null);
2031
2127
  __decorate([
2032
2128
  (0, utils_1.InjectTransactionManager)(),
2129
+ __param(2, (0, utils_1.MedusaContext)()),
2130
+ __metadata("design:type", Function),
2131
+ __metadata("design:paramtypes", [String, Array, Object]),
2132
+ __metadata("design:returntype", Promise)
2133
+ ], OrderModuleService.prototype, "setOrderLineItemAdjustments_", null);
2134
+ __decorate([
2135
+ (0, utils_1.InjectManager)(),
2136
+ (0, utils_1.EmitEvents)(),
2033
2137
  __param(1, (0, utils_1.MedusaContext)()),
2034
2138
  __metadata("design:type", Function),
2035
2139
  __metadata("design:paramtypes", [Array, Object]),
@@ -2037,13 +2141,29 @@ __decorate([
2037
2141
  ], OrderModuleService.prototype, "upsertOrderShippingMethodAdjustments", null);
2038
2142
  __decorate([
2039
2143
  (0, utils_1.InjectTransactionManager)(),
2144
+ __param(1, (0, utils_1.MedusaContext)()),
2145
+ __metadata("design:type", Function),
2146
+ __metadata("design:paramtypes", [Array, Object]),
2147
+ __metadata("design:returntype", Promise)
2148
+ ], OrderModuleService.prototype, "upsertOrderShippingMethodAdjustments_", null);
2149
+ __decorate([
2150
+ (0, utils_1.InjectManager)(),
2151
+ (0, utils_1.EmitEvents)(),
2040
2152
  __param(2, (0, utils_1.MedusaContext)()),
2041
2153
  __metadata("design:type", Function),
2042
2154
  __metadata("design:paramtypes", [String, Array, Object]),
2043
2155
  __metadata("design:returntype", Promise)
2044
2156
  ], OrderModuleService.prototype, "setOrderShippingMethodAdjustments", null);
2045
2157
  __decorate([
2046
- (0, utils_1.InjectTransactionManager)()
2158
+ (0, utils_1.InjectTransactionManager)(),
2159
+ __param(2, (0, utils_1.MedusaContext)()),
2160
+ __metadata("design:type", Function),
2161
+ __metadata("design:paramtypes", [String, Array, Object]),
2162
+ __metadata("design:returntype", Promise)
2163
+ ], OrderModuleService.prototype, "setOrderShippingMethodAdjustments_", null);
2164
+ __decorate([
2165
+ (0, utils_1.InjectManager)(),
2166
+ (0, utils_1.EmitEvents)()
2047
2167
  // @ts-expect-error
2048
2168
  ,
2049
2169
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2052,7 +2172,15 @@ __decorate([
2052
2172
  __metadata("design:returntype", Promise)
2053
2173
  ], OrderModuleService.prototype, "createOrderShippingMethodAdjustments", null);
2054
2174
  __decorate([
2055
- (0, utils_1.InjectTransactionManager)()
2175
+ (0, utils_1.InjectTransactionManager)(),
2176
+ __param(2, (0, utils_1.MedusaContext)()),
2177
+ __metadata("design:type", Function),
2178
+ __metadata("design:paramtypes", [Object, Array, Object]),
2179
+ __metadata("design:returntype", Promise)
2180
+ ], OrderModuleService.prototype, "createOrderShippingMethodAdjustments_", null);
2181
+ __decorate([
2182
+ (0, utils_1.InjectManager)(),
2183
+ (0, utils_1.EmitEvents)()
2056
2184
  // @ts-expect-error
2057
2185
  ,
2058
2186
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2062,6 +2190,14 @@ __decorate([
2062
2190
  ], OrderModuleService.prototype, "createOrderLineItemTaxLines", null);
2063
2191
  __decorate([
2064
2192
  (0, utils_1.InjectTransactionManager)(),
2193
+ __param(2, (0, utils_1.MedusaContext)()),
2194
+ __metadata("design:type", Function),
2195
+ __metadata("design:paramtypes", [Object, Object, Object]),
2196
+ __metadata("design:returntype", Promise)
2197
+ ], OrderModuleService.prototype, "createOrderLineItemTaxLines_", null);
2198
+ __decorate([
2199
+ (0, utils_1.InjectManager)(),
2200
+ (0, utils_1.EmitEvents)(),
2065
2201
  __param(1, (0, utils_1.MedusaContext)()),
2066
2202
  __metadata("design:type", Function),
2067
2203
  __metadata("design:paramtypes", [Array, Object]),
@@ -2069,13 +2205,29 @@ __decorate([
2069
2205
  ], OrderModuleService.prototype, "upsertOrderLineItemTaxLines", null);
2070
2206
  __decorate([
2071
2207
  (0, utils_1.InjectTransactionManager)(),
2208
+ __param(1, (0, utils_1.MedusaContext)()),
2209
+ __metadata("design:type", Function),
2210
+ __metadata("design:paramtypes", [Array, Object]),
2211
+ __metadata("design:returntype", Promise)
2212
+ ], OrderModuleService.prototype, "upsertOrderLineItemTaxLines_", null);
2213
+ __decorate([
2214
+ (0, utils_1.InjectManager)(),
2215
+ (0, utils_1.EmitEvents)(),
2072
2216
  __param(2, (0, utils_1.MedusaContext)()),
2073
2217
  __metadata("design:type", Function),
2074
2218
  __metadata("design:paramtypes", [String, Array, Object]),
2075
2219
  __metadata("design:returntype", Promise)
2076
2220
  ], OrderModuleService.prototype, "setOrderLineItemTaxLines", null);
2077
2221
  __decorate([
2078
- (0, utils_1.InjectTransactionManager)()
2222
+ (0, utils_1.InjectTransactionManager)(),
2223
+ __param(2, (0, utils_1.MedusaContext)()),
2224
+ __metadata("design:type", Function),
2225
+ __metadata("design:paramtypes", [String, Array, Object]),
2226
+ __metadata("design:returntype", Promise)
2227
+ ], OrderModuleService.prototype, "setOrderLineItemTaxLines_", null);
2228
+ __decorate([
2229
+ (0, utils_1.InjectManager)(),
2230
+ (0, utils_1.EmitEvents)()
2079
2231
  // @ts-expect-error
2080
2232
  ,
2081
2233
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2085,20 +2237,37 @@ __decorate([
2085
2237
  ], OrderModuleService.prototype, "createOrderShippingMethodTaxLines", null);
2086
2238
  __decorate([
2087
2239
  (0, utils_1.InjectTransactionManager)(),
2240
+ __param(2, (0, utils_1.MedusaContext)()),
2241
+ __metadata("design:type", Function),
2242
+ __metadata("design:paramtypes", [Object, Object, Object]),
2243
+ __metadata("design:returntype", Promise)
2244
+ ], OrderModuleService.prototype, "createOrderShippingMethodTaxLines_", null);
2245
+ __decorate([
2246
+ (0, utils_1.InjectManager)(),
2247
+ (0, utils_1.EmitEvents)(),
2088
2248
  __param(1, (0, utils_1.MedusaContext)()),
2089
2249
  __metadata("design:type", Function),
2090
2250
  __metadata("design:paramtypes", [Array, Object]),
2091
2251
  __metadata("design:returntype", Promise)
2092
2252
  ], OrderModuleService.prototype, "upsertOrderShippingMethodTaxLines", null);
2093
2253
  __decorate([
2094
- (0, utils_1.InjectTransactionManager)(),
2254
+ (0, utils_1.InjectManager)(),
2255
+ (0, utils_1.EmitEvents)(),
2095
2256
  __param(2, (0, utils_1.MedusaContext)()),
2096
2257
  __metadata("design:type", Function),
2097
2258
  __metadata("design:paramtypes", [String, Array, Object]),
2098
2259
  __metadata("design:returntype", Promise)
2099
2260
  ], OrderModuleService.prototype, "setOrderShippingMethodTaxLines", null);
2100
2261
  __decorate([
2101
- (0, utils_1.InjectTransactionManager)()
2262
+ (0, utils_1.InjectTransactionManager)(),
2263
+ __param(2, (0, utils_1.MedusaContext)()),
2264
+ __metadata("design:type", Function),
2265
+ __metadata("design:paramtypes", [String, Array, Object]),
2266
+ __metadata("design:returntype", Promise)
2267
+ ], OrderModuleService.prototype, "setOrderShippingMethodTaxLines_", null);
2268
+ __decorate([
2269
+ (0, utils_1.InjectManager)(),
2270
+ (0, utils_1.EmitEvents)()
2102
2271
  // @ts-expect-error
2103
2272
  ,
2104
2273
  __param(1, (0, utils_1.MedusaContext)()),
@@ -2107,7 +2276,8 @@ __decorate([
2107
2276
  __metadata("design:returntype", Promise)
2108
2277
  ], OrderModuleService.prototype, "createReturns", null);
2109
2278
  __decorate([
2110
- (0, utils_1.InjectTransactionManager)()
2279
+ (0, utils_1.InjectManager)(),
2280
+ (0, utils_1.EmitEvents)()
2111
2281
  // @ts-expect-error
2112
2282
  ,
2113
2283
  __param(1, (0, utils_1.MedusaContext)()),
@@ -2116,7 +2286,8 @@ __decorate([
2116
2286
  __metadata("design:returntype", Promise)
2117
2287
  ], OrderModuleService.prototype, "createOrderClaims", null);
2118
2288
  __decorate([
2119
- (0, utils_1.InjectTransactionManager)()
2289
+ (0, utils_1.InjectManager)(),
2290
+ (0, utils_1.EmitEvents)()
2120
2291
  // @ts-expect-error
2121
2292
  ,
2122
2293
  __param(1, (0, utils_1.MedusaContext)()),
@@ -2126,12 +2297,14 @@ __decorate([
2126
2297
  ], OrderModuleService.prototype, "createOrderExchanges", null);
2127
2298
  __decorate([
2128
2299
  (0, utils_1.InjectTransactionManager)(),
2300
+ __param(2, (0, utils_1.MedusaContext)()),
2129
2301
  __metadata("design:type", Function),
2130
2302
  __metadata("design:paramtypes", [Object, Object, Object]),
2131
2303
  __metadata("design:returntype", Promise)
2132
2304
  ], OrderModuleService.prototype, "createOrderRelatedEntity_", null);
2133
2305
  __decorate([
2134
2306
  (0, utils_1.InjectManager)(),
2307
+ (0, utils_1.EmitEvents)(),
2135
2308
  __param(1, (0, utils_1.MedusaContext)()),
2136
2309
  __metadata("design:type", Function),
2137
2310
  __metadata("design:paramtypes", [Object, Object]),
@@ -2146,12 +2319,14 @@ __decorate([
2146
2319
  ], OrderModuleService.prototype, "createOrderChange_", null);
2147
2320
  __decorate([
2148
2321
  (0, utils_1.InjectManager)(),
2322
+ __param(1, (0, utils_1.MedusaContext)()),
2149
2323
  __metadata("design:type", Function),
2150
2324
  __metadata("design:paramtypes", [String, Object]),
2151
2325
  __metadata("design:returntype", Promise)
2152
2326
  ], OrderModuleService.prototype, "previewOrderChange", null);
2153
2327
  __decorate([
2154
2328
  (0, utils_1.InjectTransactionManager)(),
2329
+ (0, utils_1.EmitEvents)(),
2155
2330
  __param(1, (0, utils_1.MedusaContext)()),
2156
2331
  __metadata("design:type", Function),
2157
2332
  __metadata("design:paramtypes", [Object, Object]),
@@ -2159,6 +2334,7 @@ __decorate([
2159
2334
  ], OrderModuleService.prototype, "cancelOrderChange", null);
2160
2335
  __decorate([
2161
2336
  (0, utils_1.InjectManager)(),
2337
+ (0, utils_1.EmitEvents)(),
2162
2338
  __param(1, (0, utils_1.MedusaContext)()),
2163
2339
  __metadata("design:type", Function),
2164
2340
  __metadata("design:paramtypes", [Object, Object]),
@@ -2170,22 +2346,55 @@ __decorate([
2170
2346
  __metadata("design:type", Function),
2171
2347
  __metadata("design:paramtypes", [Object, Object]),
2172
2348
  __metadata("design:returntype", Promise)
2349
+ ], OrderModuleService.prototype, "confirmOrderChange_", null);
2350
+ __decorate([
2351
+ (0, utils_1.InjectManager)(),
2352
+ (0, utils_1.EmitEvents)(),
2353
+ __param(1, (0, utils_1.MedusaContext)()),
2354
+ __metadata("design:type", Function),
2355
+ __metadata("design:paramtypes", [Object, Object]),
2356
+ __metadata("design:returntype", Promise)
2173
2357
  ], OrderModuleService.prototype, "declineOrderChange", null);
2358
+ __decorate([
2359
+ (0, utils_1.InjectTransactionManager)(),
2360
+ __param(1, (0, utils_1.MedusaContext)()),
2361
+ __metadata("design:type", Function),
2362
+ __metadata("design:paramtypes", [Object, Object]),
2363
+ __metadata("design:returntype", Promise)
2364
+ ], OrderModuleService.prototype, "declineOrderChange_", null);
2174
2365
  __decorate([
2175
2366
  (0, utils_1.InjectManager)(),
2367
+ (0, utils_1.EmitEvents)(),
2368
+ __param(1, (0, utils_1.MedusaContext)()),
2176
2369
  __metadata("design:type", Function),
2177
2370
  __metadata("design:paramtypes", [Object, Object]),
2178
2371
  __metadata("design:returntype", Promise)
2179
2372
  ], OrderModuleService.prototype, "registerOrderChange", null);
2373
+ __decorate([
2374
+ (0, utils_1.InjectTransactionManager)(),
2375
+ __param(1, (0, utils_1.MedusaContext)()),
2376
+ __metadata("design:type", Function),
2377
+ __metadata("design:paramtypes", [Object, Object]),
2378
+ __metadata("design:returntype", Promise)
2379
+ ], OrderModuleService.prototype, "registerOrderChange_", null);
2180
2380
  __decorate([
2181
2381
  (0, utils_1.InjectManager)(),
2382
+ (0, utils_1.EmitEvents)(),
2182
2383
  __param(1, (0, utils_1.MedusaContext)()),
2183
2384
  __metadata("design:type", Function),
2184
2385
  __metadata("design:paramtypes", [Object, Object]),
2185
2386
  __metadata("design:returntype", Promise)
2186
2387
  ], OrderModuleService.prototype, "applyPendingOrderActions", null);
2388
+ __decorate([
2389
+ (0, utils_1.InjectTransactionManager)(),
2390
+ __param(1, (0, utils_1.MedusaContext)()),
2391
+ __metadata("design:type", Function),
2392
+ __metadata("design:paramtypes", [Object, Object]),
2393
+ __metadata("design:returntype", Promise)
2394
+ ], OrderModuleService.prototype, "applyPendingOrderActions_", null);
2187
2395
  __decorate([
2188
2396
  (0, utils_1.InjectManager)(),
2397
+ (0, utils_1.EmitEvents)(),
2189
2398
  __param(1, (0, utils_1.MedusaContext)()),
2190
2399
  __metadata("design:type", Function),
2191
2400
  __metadata("design:paramtypes", [String, Object]),
@@ -2193,6 +2402,7 @@ __decorate([
2193
2402
  ], OrderModuleService.prototype, "revertLastVersion", null);
2194
2403
  __decorate([
2195
2404
  (0, utils_1.InjectManager)(),
2405
+ (0, utils_1.EmitEvents)(),
2196
2406
  __param(2, (0, utils_1.MedusaContext)()),
2197
2407
  __metadata("design:type", Function),
2198
2408
  __metadata("design:paramtypes", [String, Object, Object]),
@@ -2200,18 +2410,21 @@ __decorate([
2200
2410
  ], OrderModuleService.prototype, "undoLastChange", null);
2201
2411
  __decorate([
2202
2412
  (0, utils_1.InjectTransactionManager)(),
2413
+ __param(2, (0, utils_1.MedusaContext)()),
2203
2414
  __metadata("design:type", Function),
2204
2415
  __metadata("design:paramtypes", [Object, Object, Object]),
2205
2416
  __metadata("design:returntype", Promise)
2206
2417
  ], OrderModuleService.prototype, "undoLastChange_", null);
2207
2418
  __decorate([
2208
2419
  (0, utils_1.InjectTransactionManager)(),
2420
+ __param(1, (0, utils_1.MedusaContext)()),
2209
2421
  __metadata("design:type", Function),
2210
2422
  __metadata("design:paramtypes", [Object, Object]),
2211
2423
  __metadata("design:returntype", Promise)
2212
2424
  ], OrderModuleService.prototype, "revertLastChange_", null);
2213
2425
  __decorate([
2214
- (0, utils_1.InjectTransactionManager)(),
2426
+ (0, utils_1.InjectManager)(),
2427
+ (0, utils_1.EmitEvents)(),
2215
2428
  __param(1, (0, utils_1.MedusaContext)()),
2216
2429
  __metadata("design:type", Function),
2217
2430
  __metadata("design:paramtypes", [Object, Object]),
@@ -2219,19 +2432,36 @@ __decorate([
2219
2432
  ], OrderModuleService.prototype, "addOrderAction", null);
2220
2433
  __decorate([
2221
2434
  (0, utils_1.InjectTransactionManager)(),
2435
+ __param(1, (0, utils_1.MedusaContext)()),
2436
+ __metadata("design:type", Function),
2437
+ __metadata("design:paramtypes", [Object, Object]),
2438
+ __metadata("design:returntype", Promise)
2439
+ ], OrderModuleService.prototype, "addOrderAction_", null);
2440
+ __decorate([
2441
+ (0, utils_1.InjectTransactionManager)(),
2442
+ __param(1, (0, utils_1.MedusaContext)()),
2222
2443
  __metadata("design:type", Function),
2223
2444
  __metadata("design:paramtypes", [Array, Object]),
2224
2445
  __metadata("design:returntype", Promise)
2225
2446
  ], OrderModuleService.prototype, "applyOrderChanges_", null);
2226
2447
  __decorate([
2227
2448
  (0, utils_1.InjectManager)(),
2449
+ (0, utils_1.EmitEvents)(),
2228
2450
  __param(1, (0, utils_1.MedusaContext)()),
2229
2451
  __metadata("design:type", Function),
2230
2452
  __metadata("design:paramtypes", [Object, Object]),
2231
2453
  __metadata("design:returntype", Promise)
2232
2454
  ], OrderModuleService.prototype, "addOrderTransactions", null);
2233
2455
  __decorate([
2234
- (0, utils_1.InjectManager)()
2456
+ (0, utils_1.InjectTransactionManager)(),
2457
+ __param(1, (0, utils_1.MedusaContext)()),
2458
+ __metadata("design:type", Function),
2459
+ __metadata("design:paramtypes", [Object, Object]),
2460
+ __metadata("design:returntype", Promise)
2461
+ ], OrderModuleService.prototype, "addOrderTransactions_", null);
2462
+ __decorate([
2463
+ (0, utils_1.InjectTransactionManager)(),
2464
+ (0, utils_1.EmitEvents)()
2235
2465
  // @ts-ignore
2236
2466
  ,
2237
2467
  __param(1, (0, utils_1.MedusaContext)()),
@@ -2240,7 +2470,8 @@ __decorate([
2240
2470
  __metadata("design:returntype", Promise)
2241
2471
  ], OrderModuleService.prototype, "deleteOrderTransactions", null);
2242
2472
  __decorate([
2243
- (0, utils_1.InjectManager)()
2473
+ (0, utils_1.InjectManager)(),
2474
+ (0, utils_1.EmitEvents)()
2244
2475
  // @ts-ignore
2245
2476
  ,
2246
2477
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2249,7 +2480,15 @@ __decorate([
2249
2480
  __metadata("design:returntype", Promise)
2250
2481
  ], OrderModuleService.prototype, "softDeleteOrderTransactions", null);
2251
2482
  __decorate([
2252
- (0, utils_1.InjectManager)()
2483
+ (0, utils_1.InjectTransactionManager)(),
2484
+ __param(2, (0, utils_1.MedusaContext)()),
2485
+ __metadata("design:type", Function),
2486
+ __metadata("design:paramtypes", [Object, Object, Object]),
2487
+ __metadata("design:returntype", Promise)
2488
+ ], OrderModuleService.prototype, "softDeleteOrderTransactions_", null);
2489
+ __decorate([
2490
+ (0, utils_1.InjectManager)(),
2491
+ (0, utils_1.EmitEvents)()
2253
2492
  // @ts-ignore
2254
2493
  ,
2255
2494
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2259,12 +2498,21 @@ __decorate([
2259
2498
  ], OrderModuleService.prototype, "restoreOrderTransactions", null);
2260
2499
  __decorate([
2261
2500
  (0, utils_1.InjectTransactionManager)(),
2501
+ __param(2, (0, utils_1.MedusaContext)()),
2502
+ __metadata("design:type", Function),
2503
+ __metadata("design:paramtypes", [Object, Object, Object]),
2504
+ __metadata("design:returntype", Promise)
2505
+ ], OrderModuleService.prototype, "restoreOrderTransactions_", null);
2506
+ __decorate([
2507
+ (0, utils_1.InjectTransactionManager)(),
2508
+ __param(2, (0, utils_1.MedusaContext)()),
2262
2509
  __metadata("design:type", Function),
2263
2510
  __metadata("design:paramtypes", [Array, Boolean, Object]),
2264
2511
  __metadata("design:returntype", Promise)
2265
2512
  ], OrderModuleService.prototype, "updateOrderPaidRefundableAmount_", null);
2266
2513
  __decorate([
2267
- (0, utils_1.InjectTransactionManager)(),
2514
+ (0, utils_1.InjectManager)(),
2515
+ (0, utils_1.EmitEvents)(),
2268
2516
  __param(1, (0, utils_1.MedusaContext)()),
2269
2517
  __metadata("design:type", Function),
2270
2518
  __metadata("design:paramtypes", [Object, Object]),
@@ -2276,6 +2524,14 @@ __decorate([
2276
2524
  __metadata("design:type", Function),
2277
2525
  __metadata("design:paramtypes", [Object, Object]),
2278
2526
  __metadata("design:returntype", Promise)
2527
+ ], OrderModuleService.prototype, "archive_", null);
2528
+ __decorate([
2529
+ (0, utils_1.InjectManager)(),
2530
+ (0, utils_1.EmitEvents)(),
2531
+ __param(1, (0, utils_1.MedusaContext)()),
2532
+ __metadata("design:type", Function),
2533
+ __metadata("design:paramtypes", [Object, Object]),
2534
+ __metadata("design:returntype", Promise)
2279
2535
  ], OrderModuleService.prototype, "completeOrder", null);
2280
2536
  __decorate([
2281
2537
  (0, utils_1.InjectTransactionManager)(),
@@ -2283,6 +2539,14 @@ __decorate([
2283
2539
  __metadata("design:type", Function),
2284
2540
  __metadata("design:paramtypes", [Object, Object]),
2285
2541
  __metadata("design:returntype", Promise)
2542
+ ], OrderModuleService.prototype, "completeOrder_", null);
2543
+ __decorate([
2544
+ (0, utils_1.InjectManager)(),
2545
+ (0, utils_1.EmitEvents)(),
2546
+ __param(1, (0, utils_1.MedusaContext)()),
2547
+ __metadata("design:type", Function),
2548
+ __metadata("design:paramtypes", [Object, Object]),
2549
+ __metadata("design:returntype", Promise)
2286
2550
  ], OrderModuleService.prototype, "cancel", null);
2287
2551
  __decorate([
2288
2552
  (0, utils_1.InjectTransactionManager)(),
@@ -2290,9 +2554,25 @@ __decorate([
2290
2554
  __metadata("design:type", Function),
2291
2555
  __metadata("design:paramtypes", [Object, Object]),
2292
2556
  __metadata("design:returntype", Promise)
2557
+ ], OrderModuleService.prototype, "cancel_", null);
2558
+ __decorate([
2559
+ (0, utils_1.InjectManager)(),
2560
+ (0, utils_1.EmitEvents)(),
2561
+ __param(1, (0, utils_1.MedusaContext)()),
2562
+ __metadata("design:type", Function),
2563
+ __metadata("design:paramtypes", [Object, Object]),
2564
+ __metadata("design:returntype", Promise)
2293
2565
  ], OrderModuleService.prototype, "createReturn", null);
2566
+ __decorate([
2567
+ (0, utils_1.InjectTransactionManager)(),
2568
+ __param(1, (0, utils_1.MedusaContext)()),
2569
+ __metadata("design:type", Function),
2570
+ __metadata("design:paramtypes", [Object, Object]),
2571
+ __metadata("design:returntype", Promise)
2572
+ ], OrderModuleService.prototype, "createReturn_", null);
2294
2573
  __decorate([
2295
2574
  (0, utils_1.InjectManager)(),
2575
+ (0, utils_1.EmitEvents)(),
2296
2576
  __param(1, (0, utils_1.MedusaContext)()),
2297
2577
  __metadata("design:type", Function),
2298
2578
  __metadata("design:paramtypes", [Object, Object]),
@@ -2307,6 +2587,7 @@ __decorate([
2307
2587
  ], OrderModuleService.prototype, "receiveReturn_", null);
2308
2588
  __decorate([
2309
2589
  (0, utils_1.InjectManager)(),
2590
+ (0, utils_1.EmitEvents)(),
2310
2591
  __param(1, (0, utils_1.MedusaContext)()),
2311
2592
  __metadata("design:type", Function),
2312
2593
  __metadata("design:paramtypes", [Object, Object]),
@@ -2321,6 +2602,7 @@ __decorate([
2321
2602
  ], OrderModuleService.prototype, "cancelReturn_", null);
2322
2603
  __decorate([
2323
2604
  (0, utils_1.InjectManager)(),
2605
+ (0, utils_1.EmitEvents)(),
2324
2606
  __param(1, (0, utils_1.MedusaContext)()),
2325
2607
  __metadata("design:type", Function),
2326
2608
  __metadata("design:paramtypes", [Object, Object]),
@@ -2335,6 +2617,7 @@ __decorate([
2335
2617
  ], OrderModuleService.prototype, "createClaim_", null);
2336
2618
  __decorate([
2337
2619
  (0, utils_1.InjectManager)(),
2620
+ (0, utils_1.EmitEvents)(),
2338
2621
  __param(1, (0, utils_1.MedusaContext)()),
2339
2622
  __metadata("design:type", Function),
2340
2623
  __metadata("design:paramtypes", [Object, Object]),
@@ -2349,13 +2632,15 @@ __decorate([
2349
2632
  ], OrderModuleService.prototype, "cancelClaim_", null);
2350
2633
  __decorate([
2351
2634
  (0, utils_1.InjectManager)(),
2635
+ (0, utils_1.EmitEvents)(),
2352
2636
  __param(1, (0, utils_1.MedusaContext)()),
2353
2637
  __metadata("design:type", Function),
2354
2638
  __metadata("design:paramtypes", [Object, Object]),
2355
2639
  __metadata("design:returntype", Promise)
2356
2640
  ], OrderModuleService.prototype, "createExchange", null);
2357
2641
  __decorate([
2358
- (0, utils_1.InjectManager)()
2642
+ (0, utils_1.InjectManager)(),
2643
+ (0, utils_1.EmitEvents)()
2359
2644
  // @ts-expect-error
2360
2645
  ,
2361
2646
  __param(2, (0, utils_1.MedusaContext)()),
@@ -2363,6 +2648,13 @@ __decorate([
2363
2648
  __metadata("design:paramtypes", [Object, Object, Object]),
2364
2649
  __metadata("design:returntype", Promise)
2365
2650
  ], OrderModuleService.prototype, "updateReturnReasons", null);
2651
+ __decorate([
2652
+ (0, utils_1.InjectTransactionManager)(),
2653
+ __param(2, (0, utils_1.MedusaContext)()),
2654
+ __metadata("design:type", Function),
2655
+ __metadata("design:paramtypes", [Object, Object, Object]),
2656
+ __metadata("design:returntype", Promise)
2657
+ ], OrderModuleService.prototype, "updateReturnReasons_", null);
2366
2658
  __decorate([
2367
2659
  (0, utils_1.InjectTransactionManager)(),
2368
2660
  __param(1, (0, utils_1.MedusaContext)()),
@@ -2372,6 +2664,7 @@ __decorate([
2372
2664
  ], OrderModuleService.prototype, "createExchange_", null);
2373
2665
  __decorate([
2374
2666
  (0, utils_1.InjectManager)(),
2667
+ (0, utils_1.EmitEvents)(),
2375
2668
  __param(1, (0, utils_1.MedusaContext)()),
2376
2669
  __metadata("design:type", Function),
2377
2670
  __metadata("design:paramtypes", [Object, Object]),
@@ -2386,6 +2679,7 @@ __decorate([
2386
2679
  ], OrderModuleService.prototype, "cancelExchange_", null);
2387
2680
  __decorate([
2388
2681
  (0, utils_1.InjectTransactionManager)(),
2682
+ (0, utils_1.EmitEvents)(),
2389
2683
  __param(1, (0, utils_1.MedusaContext)()),
2390
2684
  __metadata("design:type", Function),
2391
2685
  __metadata("design:paramtypes", [Object, Object]),
@@ -2393,6 +2687,7 @@ __decorate([
2393
2687
  ], OrderModuleService.prototype, "registerFulfillment", null);
2394
2688
  __decorate([
2395
2689
  (0, utils_1.InjectTransactionManager)(),
2690
+ (0, utils_1.EmitEvents)(),
2396
2691
  __param(1, (0, utils_1.MedusaContext)()),
2397
2692
  __metadata("design:type", Function),
2398
2693
  __metadata("design:paramtypes", [Object, Object]),
@@ -2400,6 +2695,7 @@ __decorate([
2400
2695
  ], OrderModuleService.prototype, "cancelFulfillment", null);
2401
2696
  __decorate([
2402
2697
  (0, utils_1.InjectTransactionManager)(),
2698
+ (0, utils_1.EmitEvents)(),
2403
2699
  __param(1, (0, utils_1.MedusaContext)()),
2404
2700
  __metadata("design:type", Function),
2405
2701
  __metadata("design:paramtypes", [Object, Object]),
@@ -2407,13 +2703,15 @@ __decorate([
2407
2703
  ], OrderModuleService.prototype, "registerShipment", null);
2408
2704
  __decorate([
2409
2705
  (0, utils_1.InjectTransactionManager)(),
2706
+ (0, utils_1.EmitEvents)(),
2410
2707
  __param(1, (0, utils_1.MedusaContext)()),
2411
2708
  __metadata("design:type", Function),
2412
2709
  __metadata("design:paramtypes", [Object, Object]),
2413
2710
  __metadata("design:returntype", Promise)
2414
2711
  ], OrderModuleService.prototype, "registerDelivery", null);
2415
2712
  __decorate([
2416
- (0, utils_1.InjectManager)()
2713
+ (0, utils_1.InjectManager)(),
2714
+ (0, utils_1.EmitEvents)()
2417
2715
  // @ts-expect-error
2418
2716
  ,
2419
2717
  __metadata("design:type", Function),