@medusajs/order 0.1.3-snapshot-20240701122250 → 0.1.3-snapshot-20240704061641
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/joiner-config.d.ts +0 -2
- package/dist/joiner-config.js +1 -2
- package/dist/joiner-config.js.map +1 -1
- package/dist/models/return.d.ts +2 -3
- package/dist/models/return.js.map +1 -1
- package/dist/services/actions/cancel-claim.d.ts +2 -0
- package/dist/services/actions/cancel-claim.js +108 -0
- package/dist/services/actions/cancel-claim.js.map +1 -0
- package/dist/services/actions/cancel-exchange.d.ts +2 -0
- package/dist/services/actions/cancel-exchange.js +93 -0
- package/dist/services/actions/cancel-exchange.js.map +1 -0
- package/dist/services/actions/cancel-return.d.ts +2 -0
- package/dist/services/actions/cancel-return.js +73 -0
- package/dist/services/actions/cancel-return.js.map +1 -0
- package/dist/services/actions/create-claim.js +2 -2
- package/dist/services/actions/create-claim.js.map +1 -1
- package/dist/services/actions/create-exchange.js +2 -2
- package/dist/services/actions/create-exchange.js.map +1 -1
- package/dist/services/actions/create-return.js +8 -2
- package/dist/services/actions/create-return.js.map +1 -1
- package/dist/services/actions/index.d.ts +3 -0
- package/dist/services/actions/index.js +3 -0
- package/dist/services/actions/index.js.map +1 -1
- package/dist/services/order-change-service.d.ts +2 -2
- package/dist/services/order-change-service.js.map +1 -1
- package/dist/services/order-module-service.d.ts +12 -7
- package/dist/services/order-module-service.js +119 -27
- package/dist/services/order-module-service.js.map +1 -1
- package/dist/services/order-service.d.ts +2 -2
- package/dist/services/order-service.js.map +1 -1
- package/dist/types/shipping-method.d.ts +3 -0
- package/dist/types/utils/index.d.ts +3 -3
- package/dist/utils/action-key.d.ts +4 -2
- package/dist/utils/action-key.js +3 -1
- package/dist/utils/action-key.js.map +1 -1
- package/dist/utils/actions/cancel-return.js +1 -1
- package/dist/utils/actions/cancel-return.js.map +1 -1
- package/dist/utils/actions/index.d.ts +1 -0
- package/dist/utils/actions/index.js +1 -0
- package/dist/utils/actions/index.js.map +1 -1
- package/dist/utils/actions/reinstate-item.d.ts +1 -0
- package/dist/utils/actions/reinstate-item.js +37 -0
- package/dist/utils/actions/reinstate-item.js.map +1 -0
- package/dist/utils/actions/return-item.js +2 -2
- package/dist/utils/actions/return-item.js.map +1 -1
- package/dist/utils/actions/shipping-add.js +16 -9
- package/dist/utils/actions/shipping-add.js.map +1 -1
- package/dist/utils/actions/shipping-remove.d.ts +1 -0
- package/dist/utils/actions/shipping-remove.js +42 -0
- package/dist/utils/actions/shipping-remove.js.map +1 -0
- package/dist/utils/apply-order-changes.d.ts +1 -1
- package/dist/utils/apply-order-changes.js +3 -3
- package/dist/utils/apply-order-changes.js.map +1 -1
- package/dist/utils/base-repository-find.js +12 -2
- package/dist/utils/base-repository-find.js.map +1 -1
- package/dist/utils/calculate-order-change.js +7 -7
- package/dist/utils/calculate-order-change.js.map +1 -1
- package/dist/utils/transform-order.js +35 -6
- package/dist/utils/transform-order.js.map +1 -1
- package/package.json +5 -5
@@ -1,6 +1,5 @@
|
|
1
1
|
export declare enum ChangeActionType {
|
2
2
|
CANCEL = "CANCEL",
|
3
|
-
CANCEL_RETURN = "CANCEL_RETURN",
|
4
3
|
FULFILL_ITEM = "FULFILL_ITEM",
|
5
4
|
CANCEL_ITEM_FULFILLMENT = "CANCEL_ITEM_FULFILLMENT",
|
6
5
|
ITEM_ADD = "ITEM_ADD",
|
@@ -8,7 +7,10 @@ export declare enum ChangeActionType {
|
|
8
7
|
RECEIVE_DAMAGED_RETURN_ITEM = "RECEIVE_DAMAGED_RETURN_ITEM",
|
9
8
|
RECEIVE_RETURN_ITEM = "RECEIVE_RETURN_ITEM",
|
10
9
|
RETURN_ITEM = "RETURN_ITEM",
|
10
|
+
CANCEL_RETURN_ITEM = "CANCEL_RETURN_ITEM",
|
11
11
|
SHIPPING_ADD = "SHIPPING_ADD",
|
12
|
+
SHIPPING_REMOVE = "SHIPPING_REMOVE",
|
12
13
|
SHIP_ITEM = "SHIP_ITEM",
|
13
|
-
WRITE_OFF_ITEM = "WRITE_OFF_ITEM"
|
14
|
+
WRITE_OFF_ITEM = "WRITE_OFF_ITEM",
|
15
|
+
REINSTATE_ITEM = "REINSTATE_ITEM"
|
14
16
|
}
|
package/dist/utils/action-key.js
CHANGED
@@ -4,7 +4,6 @@ exports.ChangeActionType = void 0;
|
|
4
4
|
var ChangeActionType;
|
5
5
|
(function (ChangeActionType) {
|
6
6
|
ChangeActionType["CANCEL"] = "CANCEL";
|
7
|
-
ChangeActionType["CANCEL_RETURN"] = "CANCEL_RETURN";
|
8
7
|
ChangeActionType["FULFILL_ITEM"] = "FULFILL_ITEM";
|
9
8
|
ChangeActionType["CANCEL_ITEM_FULFILLMENT"] = "CANCEL_ITEM_FULFILLMENT";
|
10
9
|
ChangeActionType["ITEM_ADD"] = "ITEM_ADD";
|
@@ -12,8 +11,11 @@ var ChangeActionType;
|
|
12
11
|
ChangeActionType["RECEIVE_DAMAGED_RETURN_ITEM"] = "RECEIVE_DAMAGED_RETURN_ITEM";
|
13
12
|
ChangeActionType["RECEIVE_RETURN_ITEM"] = "RECEIVE_RETURN_ITEM";
|
14
13
|
ChangeActionType["RETURN_ITEM"] = "RETURN_ITEM";
|
14
|
+
ChangeActionType["CANCEL_RETURN_ITEM"] = "CANCEL_RETURN_ITEM";
|
15
15
|
ChangeActionType["SHIPPING_ADD"] = "SHIPPING_ADD";
|
16
|
+
ChangeActionType["SHIPPING_REMOVE"] = "SHIPPING_REMOVE";
|
16
17
|
ChangeActionType["SHIP_ITEM"] = "SHIP_ITEM";
|
17
18
|
ChangeActionType["WRITE_OFF_ITEM"] = "WRITE_OFF_ITEM";
|
19
|
+
ChangeActionType["REINSTATE_ITEM"] = "REINSTATE_ITEM";
|
18
20
|
})(ChangeActionType || (exports.ChangeActionType = ChangeActionType = {}));
|
19
21
|
//# sourceMappingURL=action-key.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"action-key.js","sourceRoot":"","sources":["../../src/utils/action-key.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
1
|
+
{"version":3,"file":"action-key.js","sourceRoot":"","sources":["../../src/utils/action-key.ts"],"names":[],"mappings":";;;AAAA,IAAY,gBAeX;AAfD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,iDAA6B,CAAA;IAC7B,uEAAmD,CAAA;IACnD,yCAAqB,CAAA;IACrB,+CAA2B,CAAA;IAC3B,+EAA2D,CAAA;IAC3D,+DAA2C,CAAA;IAC3C,+CAA2B,CAAA;IAC3B,6DAAyC,CAAA;IACzC,iDAA6B,CAAA;IAC7B,uDAAmC,CAAA;IACnC,2CAAuB,CAAA;IACvB,qDAAiC,CAAA;IACjC,qDAAiC,CAAA;AACnC,CAAC,EAfW,gBAAgB,gCAAhB,gBAAgB,QAe3B"}
|
@@ -4,7 +4,7 @@ const utils_1 = require("@medusajs/utils");
|
|
4
4
|
const action_key_1 = require("../action-key");
|
5
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
6
|
const set_action_reference_1 = require("../set-action-reference");
|
7
|
-
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.
|
7
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.CANCEL_RETURN_ITEM, {
|
8
8
|
operation({ action, currentOrder }) {
|
9
9
|
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
10
10
|
existing.detail.return_requested_quantity ??= 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cancel-return.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel-return.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,
|
1
|
+
{"version":3,"file":"cancel-return.js","sourceRoot":"","sources":["../../../src/utils/actions/cancel-return.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AACjE,kEAA4D;AAE5D,8CA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,EAC9B,mCAAmC,CACpC,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAA,iBAAS,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,iBAAS,EAAC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,sBAAsB,MAAM,CAAC,YAAY,+CAA+C,CACzF,CAAA;QACH,CAAC;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAA;QAErE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,YAAY,KAAK,cAAc,CAChC,CAAA;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,qCAAqC,KAAK,eAAe,CAC1D,CAAA;QACH,CAAC;QAED,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CACvB,MAAM,CAAC,OAAO,EAAE,QAAQ,EACxB,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAC3C,CAAA;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,uEAAuE,KAAK,GAAG,CAChF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -25,5 +25,6 @@ __exportStar(require("./receive-return-item"), exports);
|
|
25
25
|
__exportStar(require("./return-item"), exports);
|
26
26
|
__exportStar(require("./ship-item"), exports);
|
27
27
|
__exportStar(require("./shipping-add"), exports);
|
28
|
+
__exportStar(require("./shipping-remove"), exports);
|
28
29
|
__exportStar(require("./write-off-item"), exports);
|
29
30
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,4DAAyC;AACzC,kDAA+B;AAC/B,iDAA8B;AAC9B,6CAA0B;AAC1B,gDAA6B;AAC7B,gEAA6C;AAC7C,wDAAqC;AACrC,gDAA6B;AAC7B,8CAA2B;AAC3B,iDAA8B;AAC9B,mDAAgC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/actions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,4DAAyC;AACzC,kDAA+B;AAC/B,iDAA8B;AAC9B,6CAA0B;AAC1B,gDAA6B;AAC7B,gEAA6C;AAC7C,wDAAqC;AACrC,gDAA6B;AAC7B,8CAA2B;AAC3B,iDAA8B;AAC9B,oDAAiC;AACjC,mDAAgC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("@medusajs/utils");
|
4
|
+
const action_key_1 = require("../action-key");
|
5
|
+
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
+
const set_action_reference_1 = require("../set-action-reference");
|
7
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.REINSTATE_ITEM, {
|
8
|
+
operation({ action, currentOrder }) {
|
9
|
+
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
10
|
+
existing.detail.written_off_quantity ??= 0;
|
11
|
+
existing.detail.written_off_quantity = utils_1.MathBN.sub(existing.detail.written_off_quantity, action.details.quantity);
|
12
|
+
(0, set_action_reference_1.setActionReference)(existing, action);
|
13
|
+
},
|
14
|
+
revert({ action, currentOrder }) {
|
15
|
+
const existing = currentOrder.items.find((item) => item.id === action.details.reference_id);
|
16
|
+
existing.detail.written_off_quantity = utils_1.MathBN.add(existing.detail.written_off_quantity, action.details.quantity);
|
17
|
+
},
|
18
|
+
validate({ action, currentOrder }) {
|
19
|
+
const refId = action.details?.reference_id;
|
20
|
+
if (!(0, utils_1.isDefined)(refId)) {
|
21
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Details reference ID is required.");
|
22
|
+
}
|
23
|
+
const existing = currentOrder.items.find((item) => item.id === refId);
|
24
|
+
if (!existing) {
|
25
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Item ID "${refId}" not found.`);
|
26
|
+
}
|
27
|
+
if (!action.details?.quantity) {
|
28
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to reinstate item ${refId} is required.`);
|
29
|
+
}
|
30
|
+
const quantityAvailable = existing.quantity ?? 0;
|
31
|
+
const greater = utils_1.MathBN.gt(action.details?.quantity, quantityAvailable);
|
32
|
+
if (greater) {
|
33
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Cannot unclaim more items than what was ordered.");
|
34
|
+
}
|
35
|
+
},
|
36
|
+
});
|
37
|
+
//# sourceMappingURL=reinstate-item.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"reinstate-item.js","sourceRoot":"","sources":["../../../src/utils/actions/reinstate-item.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8CAAgD;AAChD,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,cAAc,EAAE;IACxE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAChC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE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AChC,CAAA;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,8BAA8B,KAAK,eAAe,CACnD,CAAA;QACH,CAAC;QAED,MAAM,iBAAiB,GAAG,QAAS,CAAC,QAAQ,IAAI,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACtE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,kDAAkD,CACnD,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -30,10 +30,10 @@ calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.C
|
|
30
30
|
if (!action.details?.quantity) {
|
31
31
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Quantity to return of item ${refId} is required.`);
|
32
32
|
}
|
33
|
-
const quantityAvailable = utils_1.MathBN.sub(existing.detail?.
|
33
|
+
const quantityAvailable = utils_1.MathBN.sub(existing.detail?.fulfilled_quantity ?? 0, existing.detail?.return_requested_quantity ?? 0);
|
34
34
|
const greater = utils_1.MathBN.gt(action.details?.quantity, quantityAvailable);
|
35
35
|
if (greater) {
|
36
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot request to return more items than what was
|
36
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Cannot request to return more items than what was fulfilled for item ${refId}.`);
|
37
37
|
}
|
38
38
|
},
|
39
39
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"return-item.js","sourceRoot":"","sources":["../../../src/utils/actions/return-item.ts"],"names":[],"mappings":";;AAAA,2CAAgE;AAChE,8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CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,8BAA8B,KAAK,eAAe,CACnD,CAAA;QACH,CAAC;QAED,MAAM,iBAAiB,GAAG,cAAM,CAAC,GAAG,CAClC,QAAS,CAAC,MAAM,EAAE,kBAAkB,IAAI,CAAC,EACzC,QAAS,CAAC,MAAM,EAAE,yBAAyB,IAAI,CAAC,CACjD,CAAA;QAED,MAAM,OAAO,GAAG,cAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAA;QACtE,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,wEAAwE,KAAK,GAAG,CACjF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -3,26 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const utils_1 = require("@medusajs/utils");
|
4
4
|
const action_key_1 = require("../action-key");
|
5
5
|
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
+
const set_action_reference_1 = require("../set-action-reference");
|
6
7
|
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.SHIPPING_ADD, {
|
7
8
|
operation({ action, currentOrder }) {
|
8
9
|
const shipping = Array.isArray(currentOrder.shipping_methods)
|
9
10
|
? currentOrder.shipping_methods
|
10
11
|
: [currentOrder.shipping_methods];
|
11
|
-
shipping.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
const existing = shipping.find((sh) => sh.id === action.reference_id);
|
13
|
+
if (existing) {
|
14
|
+
(0, set_action_reference_1.setActionReference)(existing, action);
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
shipping.push({
|
18
|
+
id: action.reference_id,
|
19
|
+
order_id: currentOrder.id,
|
20
|
+
return_id: action.return_id,
|
21
|
+
claim_id: action.claim_id,
|
22
|
+
exchange_id: action.exchange_id,
|
23
|
+
price: action.amount,
|
24
|
+
});
|
25
|
+
}
|
19
26
|
currentOrder.shipping_methods = shipping;
|
20
27
|
},
|
21
28
|
revert({ action, currentOrder }) {
|
22
29
|
const shipping = Array.isArray(currentOrder.shipping_methods)
|
23
30
|
? currentOrder.shipping_methods
|
24
31
|
: [currentOrder.shipping_methods];
|
25
|
-
const existingIndex = shipping.findIndex((item) => item.
|
32
|
+
const existingIndex = shipping.findIndex((item) => item.id === action.reference_id);
|
26
33
|
if (existingIndex > -1) {
|
27
34
|
shipping.splice(existingIndex, 1);
|
28
35
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shipping-add.js","sourceRoot":"","sources":["../../../src/utils/actions/shipping-add.ts"],"names":[],"mappings":";;AAAA,2CAAwD;AACxD,8CAAgD;AAChD,sEAAiE;
|
1
|
+
{"version":3,"file":"shipping-add.js","sourceRoot":"","sources":["../../../src/utils/actions/shipping-add.ts"],"names":[],"mappings":";;AAAA,2CAAwD;AACxD,8CAAgD;AAChD,sEAAiE;AACjE,kEAA4D;AAE5D,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,YAAY,EAAE;IACtE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,YAAY,CAAC,gBAAgB;YAC/B,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;QAEnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAAC,CAAA;QAErE,IAAI,QAAQ,EAAE,CAAC;YACb,IAAA,yCAAkB,EAAC,QAAQ,EA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A;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const utils_1 = require("@medusajs/utils");
|
4
|
+
const action_key_1 = require("../action-key");
|
5
|
+
const calculate_order_change_1 = require("../calculate-order-change");
|
6
|
+
calculate_order_change_1.OrderChangeProcessing.registerActionType(action_key_1.ChangeActionType.SHIPPING_REMOVE, {
|
7
|
+
operation({ action, currentOrder }) {
|
8
|
+
const shipping = Array.isArray(currentOrder.shipping_methods)
|
9
|
+
? currentOrder.shipping_methods
|
10
|
+
: [currentOrder.shipping_methods];
|
11
|
+
const existingIndex = shipping.findIndex((item) => item.id === action.reference_id);
|
12
|
+
if (existingIndex > -1) {
|
13
|
+
shipping.splice(existingIndex, 1);
|
14
|
+
}
|
15
|
+
currentOrder.shipping_methods = shipping;
|
16
|
+
},
|
17
|
+
revert({ action, currentOrder }) {
|
18
|
+
const shipping = Array.isArray(currentOrder.shipping_methods)
|
19
|
+
? currentOrder.shipping_methods
|
20
|
+
: [currentOrder.shipping_methods];
|
21
|
+
const existingIndex = shipping.findIndex((item) => item.id === action.reference_id);
|
22
|
+
if (existingIndex > -1) {
|
23
|
+
shipping.push({
|
24
|
+
id: action.reference_id,
|
25
|
+
order_id: currentOrder.id,
|
26
|
+
return_id: action.return_id,
|
27
|
+
claim_id: action.claim_id,
|
28
|
+
exchange_id: action.exchange_id,
|
29
|
+
price: action.amount,
|
30
|
+
});
|
31
|
+
}
|
32
|
+
},
|
33
|
+
validate({ action }) {
|
34
|
+
if (!action.reference_id) {
|
35
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Reference ID is required.");
|
36
|
+
}
|
37
|
+
if (!(0, utils_1.isDefined)(action.amount)) {
|
38
|
+
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, "Amount is required.");
|
39
|
+
}
|
40
|
+
},
|
41
|
+
});
|
42
|
+
//# sourceMappingURL=shipping-remove.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"shipping-remove.js","sourceRoot":"","sources":["../../../src/utils/actions/shipping-remove.ts"],"names":[],"mappings":";;AAAA,2CAAwD;AACxD,8CAAgD;AAChD,sEAAiE;AAEjE,8CAAqB,CAAC,kBAAkB,CAAC,6BAAgB,CAAC,eAAe,EAAE;IACzE,SAAS,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,YAAY,CAAC,gBAAgB;YAC/B,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;QAEnC,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAC1C,CAAA;QAED,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;QACnC,CAAC;QAED,YAAY,CAAC,gBAAgB,GAAG,QAAQ,CAAA;IAC1C,CAAC;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE;QAC7B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,YAAY,CAAC,gBAAgB;YAC/B,CAAC,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAA;QAEnC,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,YAAY,CAC1C,CAAA;QAED,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC;gBACZ,EAAE,EAAE,MAAM,CAAC,YAAa;gBACxB,QAAQ,EAAE,YAAY,CAAC,EAAE;gBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,KAAK,EAAE,MAAM,CAAC,MAAgB;aAC/B,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,QAAQ,CAAC,EAAE,MAAM,EAAE;QACjB,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,2BAA2B,CAC5B,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAA,iBAAS,EAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,qBAAqB,CACtB,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
|
@@ -8,7 +8,7 @@ export interface ApplyOrderChangeDTO extends OrderChangeActionDTO {
|
|
8
8
|
}
|
9
9
|
export declare function applyChangesToOrder(orders: any[], actionsMap: Record<string, any[]>): {
|
10
10
|
itemsToUpsert: OrderItem[];
|
11
|
-
|
11
|
+
shippingMethodsToUpsert: OrderShippingMethod[];
|
12
12
|
summariesToUpsert: any[];
|
13
13
|
orderToUpdate: any[];
|
14
14
|
};
|
@@ -5,7 +5,7 @@ const utils_1 = require("@medusajs/utils");
|
|
5
5
|
const calculate_order_change_1 = require("./calculate-order-change");
|
6
6
|
function applyChangesToOrder(orders, actionsMap) {
|
7
7
|
const itemsToUpsert = [];
|
8
|
-
const
|
8
|
+
const shippingMethodsToUpsert = [];
|
9
9
|
const summariesToUpsert = [];
|
10
10
|
const orderToUpdate = [];
|
11
11
|
for (const order of orders) {
|
@@ -51,7 +51,7 @@ function applyChangesToOrder(orders, actionsMap) {
|
|
51
51
|
version,
|
52
52
|
};
|
53
53
|
delete sm.id;
|
54
|
-
|
54
|
+
shippingMethodsToUpsert.push(sm);
|
55
55
|
}
|
56
56
|
orderToUpdate.push({
|
57
57
|
selector: {
|
@@ -65,7 +65,7 @@ function applyChangesToOrder(orders, actionsMap) {
|
|
65
65
|
}
|
66
66
|
return {
|
67
67
|
itemsToUpsert,
|
68
|
-
|
68
|
+
shippingMethodsToUpsert,
|
69
69
|
summariesToUpsert,
|
70
70
|
orderToUpdate,
|
71
71
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"apply-order-changes.js","sourceRoot":"","sources":["../../src/utils/apply-order-changes.ts"],"names":[],"mappings":";;;AACA,2CAAkE;AAElE,qEAA+D;AAS/D,SAAgB,mBAAmB,CACjC,MAAa,EACb,UAAiC;IAEjC,MAAM,aAAa,GAAgB,EAAE,CAAA;IACrC,MAAM,uBAAuB,GAA0B,EAAE,CAAA;IACzD,MAAM,iBAAiB,GAAU,EAAE,CAAA;IACnC,MAAM,aAAa,GAAU,EAAE,CAAA;IAE/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,IAAA,6CAAoB,EAAC;YACtC,KAAK,EAAE,KAAY;YACnB,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,EAAE;SACvC,CAAC,CAAA;QAEF,IAAA,wCAAgC,EAAC,UAAU,CAAC,CAAA;QAE5C,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAA;QAEpD,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAI,IAAI,CAAC,MAAc,IAAI,IAAI,CAA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AAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,aAAa;QACb,uBAAuB;QACvB,iBAAiB;QACjB,aAAa;KACd,CAAA;AACH,CAAC;AAhFD,kDAgFC"}
|
@@ -28,10 +28,16 @@ function setFindMethods(klass, entity) {
|
|
28
28
|
const config = (0, _1.mapRepositoryToOrderModel)(findOptions_, isRelatedEntity);
|
29
29
|
let orderAlias = "o0";
|
30
30
|
if (isRelatedEntity) {
|
31
|
+
if (!config.options.populate.includes("order.items")) {
|
32
|
+
config.options.populate.unshift("order.items");
|
33
|
+
}
|
31
34
|
// first relation is always order if the entity is not Order
|
35
|
+
const index = config.options.populate.findIndex((p) => p === "order");
|
36
|
+
if (index > -1) {
|
37
|
+
config.options.populate.splice(index, 1);
|
38
|
+
}
|
32
39
|
config.options.populate.unshift("order");
|
33
40
|
orderAlias = "o1";
|
34
|
-
config.options.populate.unshift("order.items");
|
35
41
|
}
|
36
42
|
let defaultVersion = knex.raw(`"${orderAlias}"."version"`);
|
37
43
|
const strategy = config.options.strategy ?? core_1.LoadStrategy.JOINED;
|
@@ -78,7 +84,11 @@ function setFindMethods(klass, entity) {
|
|
78
84
|
const config = (0, _1.mapRepositoryToOrderModel)(findOptions_, isRelatedEntity);
|
79
85
|
let orderAlias = "o0";
|
80
86
|
if (isRelatedEntity) {
|
81
|
-
// first relation is always order if entity is not Order
|
87
|
+
// first relation is always order if the entity is not Order
|
88
|
+
const index = config.options.populate.findIndex((p) => p === "order");
|
89
|
+
if (index > -1) {
|
90
|
+
config.options.populate.splice(index, 1);
|
91
|
+
}
|
82
92
|
config.options.populate.unshift("order");
|
83
93
|
orderAlias = "o1";
|
84
94
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"base-repository-find.js","sourceRoot":"","sources":["../../src/utils/base-repository-find.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,qCAA+B;AAC/B,wBAA6C;AAE7C,SAAgB,cAAc,CAAI,KAAqB,EAAE,M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IAAI,GAAG,GAAG,CAAC,CAAA;QACvC,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,cAAc,CAAA;QACtD,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAA;QAE3B,MAAM,CAAC,OAAO,CAAC,aAAa,KAAK,EAAE,CAAA;QACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAA;QAE7C,IAAI,eAAe,EAAE,CAAC;YACpB,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAA;QACvB,CAAC;QAED,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;QAE9D,UAAU,CAAC,OAAO,KAAK,EAAE,CAAA;QACzB,UAAU,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;QAEpC,UAAU,CAAC,KAAK,KAAK,EAAE,CAAA;QACvB,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;QAElC,QAAQ,CAAC,gBAAgB,KAAK,EAAE,CAAA;QAChC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,GAAG,OAAO,CAAA;QAE3C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC5B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,CAAA;QACxC,CAAC;QAED,OAAO,MAAM,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACzE,CAAC,CAAA;AACH,CAAC;AA/JD,wCA+JC"}
|
@@ -68,9 +68,9 @@ class OrderChangeProcessing {
|
|
68
68
|
...OrderChangeProcessing.typeDefinition[action.action],
|
69
69
|
};
|
70
70
|
const amount = utils_1.MathBN.mult(action.amount, type.isDeduction ? -1 : 1);
|
71
|
-
if (action.
|
72
|
-
this.groupTotal[action.
|
73
|
-
this.groupTotal[action.
|
71
|
+
if (action.change_id && !action.evaluationOnly) {
|
72
|
+
this.groupTotal[action.change_id] ??= 0;
|
73
|
+
this.groupTotal[action.change_id] = utils_1.MathBN.add(this.groupTotal[action.change_id], amount);
|
74
74
|
}
|
75
75
|
if (type.awaitRequired && !this.isEventDone(action)) {
|
76
76
|
if (action.evaluationOnly) {
|
@@ -84,7 +84,7 @@ class OrderChangeProcessing {
|
|
84
84
|
summary.future_difference = utils_1.MathBN.add(summary.future_difference, amount);
|
85
85
|
}
|
86
86
|
else {
|
87
|
-
if (!this.isEventDone(action) && !action.
|
87
|
+
if (!this.isEventDone(action) && !action.change_id) {
|
88
88
|
summary.difference_sum = utils_1.MathBN.add(summary.difference_sum, amount);
|
89
89
|
}
|
90
90
|
summary.current_order_total = utils_1.MathBN.add(summary.current_order_total, amount);
|
@@ -145,8 +145,8 @@ class OrderChangeProcessing {
|
|
145
145
|
if (action.resolve.reference_id) {
|
146
146
|
this.resolveReferences(action);
|
147
147
|
}
|
148
|
-
const groupId = action.resolve.
|
149
|
-
if (action.resolve.
|
148
|
+
const groupId = action.resolve.change_id ?? "__default";
|
149
|
+
if (action.resolve.change_id) {
|
150
150
|
// resolve all actions in the same group
|
151
151
|
this.resolveGroup(action);
|
152
152
|
}
|
@@ -201,7 +201,7 @@ class OrderChangeProcessing {
|
|
201
201
|
const type = OrderChangeProcessing.typeDefinition[actionKey];
|
202
202
|
const actions = this.actionsProcessed[actionKey];
|
203
203
|
for (const action of actions) {
|
204
|
-
if (!resolve?.
|
204
|
+
if (!resolve?.change_id || action?.change_id !== resolve.change_id) {
|
205
205
|
continue;
|
206
206
|
}
|
207
207
|
if (type.revert &&
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"calculate-order-change.js","sourceRoot":"","sources":["../../src/utils/calculate-order-change.ts"],"names":[],"mappings":";;;AACA,2CAMwB;AACxB,mCAQe;AAMf,MAAa,qBAAqB;IAezB,M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,2BAA2B,CACpC;YACD,kBAAkB,EAAE,IAAI,iBAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC;YAC7D,cAAc,EAAE,IAAI,iBAAS,CAAC,OAAO,CAAC,cAAc,CAAC;YACrD,UAAU,EAAE,IAAI,iBAAS,CAAC,OAAO,CAAC,UAAU,CAAC;YAC7C,cAAc,EAAE,IAAI,iBAAS,CAAC,OAAO,CAAC,cAAc,CAAC;SACxB,CAAA;QAE/B,OAAO,YAAY,CAAA;IACrB,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;;AA9WH,sDA+WC;AA9WgB,oCAAc,GAA4C,EAAE,AAA9C,CAA8C;AAC5D,mCAAa,GAAG;IAC7B,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;CACnB,AAH2B,CAG3B;AA4WH,SAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,OAAO,GAAG,EAAE,GAKb;IACC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAA;IACxE,IAAI,CAAC,cAAc,EAAE,CAAA;IAErB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;QAC1B,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE;KAC9B,CAAA;AACH,CAAC;AAhBD,oDAgBC"}
|
1
|
+
{"version":3,"file":"calculate-order-change.js","sourceRoot":"","sources":["../../src/utils/calculate-order-change.ts"],"names":[],"mappings":";;;AACA,2CAMwB;AACxB,mCAQe;AAMf,MAAa,qBAAqB;IAezB,MAAM,CAAC,kBAAkB,CAAC,GAAW,EAAE,IAA0B;QACtE,qBAAqB,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAClD,CAAC;IAED,YAAY,EACV,KAAK,EACL,YAAY,EACZ,OAAO,GAKR;QAhBO,qBAAgB,GAAkD,EAAE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C,cAAc,EAAE,IAAI,iBAAS,CAAC,OAAO,CAAC,cAAc,CAAC;SACxB,CAAA;QAE/B,OAAO,YAAY,CAAA;IACrB,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;;AA9WH,sDA+WC;AA9WgB,oCAAc,GAA4C,EAAE,AAA9C,CAA8C;AAC5D,mCAAa,GAAG;IAC7B,aAAa,EAAE,KAAK;IACpB,WAAW,EAAE,KAAK;CACnB,AAH2B,CAG3B;AA4WH,SAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,OAAO,GAAG,EAAE,GAKb;IACC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAA;IACxE,IAAI,CAAC,cAAc,EAAE,CAAA;IAErB,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;QAC1B,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE;KAC9B,CAAA;AACH,CAAC;AAhBD,oDAgBC"}
|
@@ -2,13 +2,15 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.mapRepositoryToOrderModel = exports.formatOrder = void 0;
|
4
4
|
const utils_1 = require("@medusajs/utils");
|
5
|
-
|
5
|
+
// Reshape the order object to match the OrderDTO
|
6
|
+
// This function is used to format the order object before returning to the main module methods
|
6
7
|
function formatOrder(order, options) {
|
7
8
|
const isArray = Array.isArray(order);
|
8
9
|
const orders = [...(isArray ? order : [order])];
|
9
10
|
orders.map((order) => {
|
10
11
|
let mainOrder = order;
|
11
|
-
const isRelatedEntity = options?.entity !==
|
12
|
+
const isRelatedEntity = options?.entity?.name !== "Order";
|
13
|
+
// If the entity is a related entity, the original order is located in the order property
|
12
14
|
if (isRelatedEntity) {
|
13
15
|
if (!order.order) {
|
14
16
|
return order;
|
@@ -30,13 +32,14 @@ function formatOrder(order, options) {
|
|
30
32
|
if (order.return) {
|
31
33
|
formatOrderReturn(order.return, mainOrder);
|
32
34
|
}
|
33
|
-
|
35
|
+
const entityName = options.entity.name;
|
36
|
+
if (entityName === "OrderClaim") {
|
34
37
|
formatClaim(order);
|
35
38
|
}
|
36
|
-
else if (
|
39
|
+
else if (entityName === "OrderExchange") {
|
37
40
|
formatExchange(order);
|
38
41
|
}
|
39
|
-
else if (
|
42
|
+
else if (entityName === "Return") {
|
40
43
|
formatReturn(order);
|
41
44
|
}
|
42
45
|
}
|
@@ -62,7 +65,6 @@ function formatOrder(order, options) {
|
|
62
65
|
}
|
63
66
|
exports.formatOrder = formatOrder;
|
64
67
|
function formatOrderReturn(orderReturn, mainOrder) {
|
65
|
-
orderReturn.items = orderReturn.items.filter((item) => !item.is_additional_item);
|
66
68
|
orderReturn.items.forEach((orderItem) => {
|
67
69
|
const item = mainOrder.items?.find((item) => item.id === orderItem.item_id);
|
68
70
|
orderItem.detail = item?.detail;
|
@@ -103,7 +105,14 @@ function formatReturn(returnOrder) {
|
|
103
105
|
orderItem.detail = item?.detail;
|
104
106
|
});
|
105
107
|
}
|
108
|
+
// Map the public order model to the repository model format
|
109
|
+
// As the public responses have a different shape than the repository responses, this function is used to map the public properties to the internal db entities
|
110
|
+
// e.g "items" is the relation between "line-item" and "order" + "version", The line item itself is in "items.item"
|
111
|
+
// This helper maps to the correct repository to query the DB, and the function "formatOrder" remap the response to the public shape
|
106
112
|
function mapRepositoryToOrderModel(config, isRelatedEntity = false) {
|
113
|
+
if (isRelatedEntity) {
|
114
|
+
return mapRepositoryToRelatedEntity(config);
|
115
|
+
}
|
107
116
|
const conf = { ...config };
|
108
117
|
function replace(obj, type) {
|
109
118
|
if (!(0, utils_1.isDefined)(obj[type])) {
|
@@ -161,4 +170,24 @@ function mapRepositoryToOrderModel(config, isRelatedEntity = false) {
|
|
161
170
|
return conf;
|
162
171
|
}
|
163
172
|
exports.mapRepositoryToOrderModel = mapRepositoryToOrderModel;
|
173
|
+
// This function has the same purpose as "mapRepositoryToOrderModel" but for returns, claims and exchanges
|
174
|
+
function mapRepositoryToRelatedEntity(config) {
|
175
|
+
const conf = { ...config };
|
176
|
+
function replace(obj, type) {
|
177
|
+
if (!(0, utils_1.isDefined)(obj[type])) {
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
return (0, utils_1.deduplicate)(obj[type].sort().map((rel) => {
|
181
|
+
if (rel.includes("shipping_methods") &&
|
182
|
+
!rel.includes("shipping_methods.shipping_method")) {
|
183
|
+
obj.populate.push("shipping_methods.shipping_method");
|
184
|
+
return rel.replace("shipping_methods", "shipping_methods.shipping_method");
|
185
|
+
}
|
186
|
+
return rel;
|
187
|
+
}));
|
188
|
+
}
|
189
|
+
conf.options.fields = replace(config.options, "fields");
|
190
|
+
conf.options.populate = replace(config.options, "populate");
|
191
|
+
return conf;
|
192
|
+
}
|
164
193
|
//# sourceMappingURL=transform-order.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transform-order.js","sourceRoot":"","sources":["../../src/utils/transform-order.ts"],"names":[],"mappings":";;;AACA,2CAKwB;
|
1
|
+
{"version":3,"file":"transform-order.js","sourceRoot":"","sources":["../../src/utils/transform-order.ts"],"names":[],"mappings":";;;AACA,2CAKwB;AAExB,iDAAiD;AACjD,+FAA+F;AAC/F,SAAgB,WAAW,CACzB,KAAK,EACL,OAGC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACpC,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAE/C,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,IAAI,SAAS,GAAG,KAAK,CAAA;QAErB,MAAM,eAAe,GAAG,OAAO,EAAE,MAAM,EAAE,IAAI,KAAK,OAAO,CAAA;QAEzD,yFAAyF;QACzF,IAAI,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