@medusajs/medusa 1.3.0 → 1.3.1-next.26
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.
- package/dist/api/routes/admin/discounts/create-condition.d.ts +58 -0
- package/dist/api/routes/admin/discounts/create-condition.js +186 -0
- package/dist/api/routes/admin/discounts/create-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/create-discount.js +0 -1
- package/dist/api/routes/admin/discounts/create-discount.js.map +1 -1
- package/dist/api/routes/admin/discounts/delete-condition.d.ts +36 -0
- package/dist/api/routes/admin/discounts/delete-condition.js +151 -0
- package/dist/api/routes/admin/discounts/delete-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/get-condition.d.ts +31 -0
- package/dist/api/routes/admin/discounts/get-condition.js +125 -0
- package/dist/api/routes/admin/discounts/get-condition.js.map +1 -0
- package/dist/api/routes/admin/discounts/index.d.ts +10 -0
- package/dist/api/routes/admin/discounts/index.js +12 -1
- package/dist/api/routes/admin/discounts/index.js.map +1 -1
- package/dist/api/routes/admin/discounts/update-condition.d.ts +55 -0
- package/dist/api/routes/admin/discounts/update-condition.js +184 -0
- package/dist/api/routes/admin/discounts/update-condition.js.map +1 -0
- package/dist/api/routes/admin/orders/create-claim.js +6 -0
- package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
- package/dist/api/routes/admin/price-lists/index.js +1 -1
- package/dist/api/routes/admin/price-lists/index.js.map +1 -1
- package/dist/api/routes/admin/price-lists/list-price-list-products.js +62 -21
- package/dist/api/routes/admin/price-lists/list-price-list-products.js.map +1 -1
- package/dist/api/routes/admin/product-tags/list-product-tags.d.ts +2 -1
- package/dist/api/routes/admin/product-tags/list-product-tags.js +6 -3
- package/dist/api/routes/admin/product-tags/list-product-tags.js.map +1 -1
- package/dist/api/routes/admin/product-types/list-product-types.d.ts +2 -1
- package/dist/api/routes/admin/product-types/list-product-types.js +6 -3
- package/dist/api/routes/admin/product-types/list-product-types.js.map +1 -1
- package/dist/api/routes/admin/products/index.d.ts +2 -1
- package/dist/api/routes/admin/products/index.js +7 -2
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/list-variants.d.ts +35 -0
- package/dist/api/routes/admin/products/list-variants.js +173 -0
- package/dist/api/routes/admin/products/list-variants.js.map +1 -0
- package/dist/api/routes/admin/shipping-options/list-shipping-options.d.ts +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/commands/develop.js +1 -1
- package/dist/commands/develop.js.map +1 -1
- package/dist/helpers/test-request.js +11 -10
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/index.js +1 -1
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/transaction-base-service.d.ts +23 -0
- package/dist/interfaces/{base-service.js → transaction-base-service.js} +38 -216
- package/dist/interfaces/transaction-base-service.js.map +1 -0
- package/dist/loaders/plugins.d.ts +20 -0
- package/dist/loaders/plugins.js +3 -2
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/models/discount-condition.js +3 -0
- package/dist/models/discount-condition.js.map +1 -1
- package/dist/repositories/discount-condition.d.ts +4 -0
- package/dist/repositories/discount-condition.js +13 -0
- package/dist/repositories/discount-condition.js.map +1 -1
- package/dist/repositories/money-amount.d.ts +1 -0
- package/dist/repositories/money-amount.js +28 -6
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/order.d.ts +1 -1
- package/dist/repositories/price-list.d.ts +8 -1
- package/dist/repositories/price-list.js +209 -0
- package/dist/repositories/price-list.js.map +1 -1
- package/dist/services/cart.d.ts +12 -12
- package/dist/services/cart.js +130 -157
- package/dist/services/cart.js.map +1 -1
- package/dist/services/claim.js +62 -19
- package/dist/services/claim.js.map +1 -1
- package/dist/services/customer.d.ts +0 -7
- package/dist/services/customer.js +4 -33
- package/dist/services/customer.js.map +1 -1
- package/dist/services/discount-condition.d.ts +31 -0
- package/dist/services/discount-condition.js +223 -0
- package/dist/services/discount-condition.js.map +1 -0
- package/dist/services/discount.d.ts +4 -8
- package/dist/services/discount.js +73 -175
- package/dist/services/discount.js.map +1 -1
- package/dist/services/line-item.js +3 -3
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/order.d.ts +0 -13
- package/dist/services/order.js +0 -26
- package/dist/services/order.js.map +1 -1
- package/dist/services/price-list.d.ts +16 -2
- package/dist/services/price-list.js +181 -24
- package/dist/services/price-list.js.map +1 -1
- package/dist/services/product-tag.d.ts +2 -2
- package/dist/services/product-tag.js +15 -2
- package/dist/services/product-tag.js.map +1 -1
- package/dist/services/product-type.d.ts +1 -1
- package/dist/services/product-type.js +14 -1
- package/dist/services/product-type.js.map +1 -1
- package/dist/services/product-variant.js +1 -1
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.d.ts +2 -1
- package/dist/services/product.js +14 -7
- package/dist/services/product.js.map +1 -1
- package/dist/services/return.js +2 -0
- package/dist/services/return.js.map +1 -1
- package/dist/types/cart.d.ts +1 -1
- package/dist/types/common.d.ts +31 -11
- package/dist/types/common.js +1 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/discount.d.ts +1 -0
- package/dist/types/global.d.ts +9 -0
- package/dist/types/price-list.d.ts +1 -0
- package/dist/types/price-list.js +5 -0
- package/dist/types/price-list.js.map +1 -1
- package/dist/types/product.d.ts +2 -0
- package/dist/types/product.js +18 -4
- package/dist/types/product.js.map +1 -1
- package/dist/utils/build-query.d.ts +8 -0
- package/dist/utils/build-query.js +114 -0
- package/dist/utils/build-query.js.map +1 -0
- package/dist/utils/get-query-config.js +4 -4
- package/dist/utils/get-query-config.js.map +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/set-metadata.d.ts +9 -0
- package/dist/utils/set-metadata.js +72 -0
- package/dist/utils/set-metadata.js.map +1 -0
- package/dist/utils/validate-id.d.ts +4 -0
- package/dist/utils/validate-id.js +47 -0
- package/dist/utils/validate-id.js.map +1 -0
- package/package.json +7 -7
- package/dist/api/routes/admin/products/get-variants.d.ts +0 -24
- package/dist/api/routes/admin/products/get-variants.js +0 -76
- package/dist/api/routes/admin/products/get-variants.js.map +0 -1
- package/dist/interfaces/base-service.d.ts +0 -66
- package/dist/interfaces/base-service.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DiscountConditionOperator } from "../../../../models/discount-condition";
|
|
2
|
+
import { AdminUpsertConditionsReq } from "../../../../types/discount";
|
|
3
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* @oas [post] /discounts/{discount_id}/conditions
|
|
6
|
+
* operationId: "PostDiscountsDiscountConditions"
|
|
7
|
+
* summary: "Creates a DiscountCondition"
|
|
8
|
+
* x-authenticated: true
|
|
9
|
+
* parameters:
|
|
10
|
+
* - (path) discount_id=* {string} The id of the Product.
|
|
11
|
+
* - (query) expand {string} (Comma separated) Which fields should be expanded in each product of the result.
|
|
12
|
+
* - (query) fields {string} (Comma separated) Which fields should be included in each product of the result.
|
|
13
|
+
* description: "Creates a DiscountCondition"
|
|
14
|
+
* requestBody:
|
|
15
|
+
* content:
|
|
16
|
+
* application/json:
|
|
17
|
+
* schema:
|
|
18
|
+
* properties:
|
|
19
|
+
* operator:
|
|
20
|
+
* description: Operator of the condition
|
|
21
|
+
* type: string
|
|
22
|
+
* items:
|
|
23
|
+
* properties:
|
|
24
|
+
* products:
|
|
25
|
+
* type: array
|
|
26
|
+
* description: list of products
|
|
27
|
+
* product_types:
|
|
28
|
+
* type: array
|
|
29
|
+
* description: list of product types
|
|
30
|
+
* product_collections:
|
|
31
|
+
* type: array
|
|
32
|
+
* description: list of product collections
|
|
33
|
+
* product_tags:
|
|
34
|
+
* type: array
|
|
35
|
+
* description: list of product tags
|
|
36
|
+
* customer_groups:
|
|
37
|
+
* type: array
|
|
38
|
+
* description: list of customer_groups
|
|
39
|
+
* tags:
|
|
40
|
+
* - Discount
|
|
41
|
+
* responses:
|
|
42
|
+
* 200:
|
|
43
|
+
* description: OK
|
|
44
|
+
* content:
|
|
45
|
+
* application/json:
|
|
46
|
+
* schema:
|
|
47
|
+
* properties:
|
|
48
|
+
* discount:
|
|
49
|
+
* $ref: "#/components/schemas/discount"
|
|
50
|
+
*/
|
|
51
|
+
export default _default;
|
|
52
|
+
export declare class AdminPostDiscountsDiscountConditions extends AdminUpsertConditionsReq {
|
|
53
|
+
operator: DiscountConditionOperator;
|
|
54
|
+
}
|
|
55
|
+
export declare class AdminPostDiscountsDiscountConditionsParams {
|
|
56
|
+
expand?: string;
|
|
57
|
+
fields?: string;
|
|
58
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
29
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
+
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;
|
|
32
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33
|
+
};
|
|
34
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
35
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
36
|
+
};
|
|
37
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
38
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
47
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
48
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
49
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
50
|
+
function step(op) {
|
|
51
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
52
|
+
while (_) try {
|
|
53
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
54
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
55
|
+
switch (op[0]) {
|
|
56
|
+
case 0: case 1: t = op; break;
|
|
57
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
58
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
59
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
60
|
+
default:
|
|
61
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
62
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
63
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
64
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
65
|
+
if (t[2]) _.ops.pop();
|
|
66
|
+
_.trys.pop(); continue;
|
|
67
|
+
}
|
|
68
|
+
op = body.call(thisArg, _);
|
|
69
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
70
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
+
exports.AdminPostDiscountsDiscountConditionsParams = exports.AdminPostDiscountsDiscountConditions = void 0;
|
|
75
|
+
var class_validator_1 = require("class-validator");
|
|
76
|
+
var _1 = require(".");
|
|
77
|
+
var discount_condition_1 = require("../../../../models/discount-condition");
|
|
78
|
+
var discount_1 = require("../../../../types/discount");
|
|
79
|
+
var get_query_config_1 = require("../../../../utils/get-query-config");
|
|
80
|
+
var validator_1 = require("../../../../utils/validator");
|
|
81
|
+
/**
|
|
82
|
+
* @oas [post] /discounts/{discount_id}/conditions
|
|
83
|
+
* operationId: "PostDiscountsDiscountConditions"
|
|
84
|
+
* summary: "Creates a DiscountCondition"
|
|
85
|
+
* x-authenticated: true
|
|
86
|
+
* parameters:
|
|
87
|
+
* - (path) discount_id=* {string} The id of the Product.
|
|
88
|
+
* - (query) expand {string} (Comma separated) Which fields should be expanded in each product of the result.
|
|
89
|
+
* - (query) fields {string} (Comma separated) Which fields should be included in each product of the result.
|
|
90
|
+
* description: "Creates a DiscountCondition"
|
|
91
|
+
* requestBody:
|
|
92
|
+
* content:
|
|
93
|
+
* application/json:
|
|
94
|
+
* schema:
|
|
95
|
+
* properties:
|
|
96
|
+
* operator:
|
|
97
|
+
* description: Operator of the condition
|
|
98
|
+
* type: string
|
|
99
|
+
* items:
|
|
100
|
+
* properties:
|
|
101
|
+
* products:
|
|
102
|
+
* type: array
|
|
103
|
+
* description: list of products
|
|
104
|
+
* product_types:
|
|
105
|
+
* type: array
|
|
106
|
+
* description: list of product types
|
|
107
|
+
* product_collections:
|
|
108
|
+
* type: array
|
|
109
|
+
* description: list of product collections
|
|
110
|
+
* product_tags:
|
|
111
|
+
* type: array
|
|
112
|
+
* description: list of product tags
|
|
113
|
+
* customer_groups:
|
|
114
|
+
* type: array
|
|
115
|
+
* description: list of customer_groups
|
|
116
|
+
* tags:
|
|
117
|
+
* - Discount
|
|
118
|
+
* responses:
|
|
119
|
+
* 200:
|
|
120
|
+
* description: OK
|
|
121
|
+
* content:
|
|
122
|
+
* application/json:
|
|
123
|
+
* schema:
|
|
124
|
+
* properties:
|
|
125
|
+
* discount:
|
|
126
|
+
* $ref: "#/components/schemas/discount"
|
|
127
|
+
*/
|
|
128
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
+
var discount_id, validatedCondition, validatedParams, conditionService, discountService, discount, config;
|
|
130
|
+
var _a, _b;
|
|
131
|
+
return __generator(this, function (_c) {
|
|
132
|
+
switch (_c.label) {
|
|
133
|
+
case 0:
|
|
134
|
+
discount_id = req.params.discount_id;
|
|
135
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminPostDiscountsDiscountConditions, req.body)];
|
|
136
|
+
case 1:
|
|
137
|
+
validatedCondition = _c.sent();
|
|
138
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminPostDiscountsDiscountConditionsParams, req.query)];
|
|
139
|
+
case 2:
|
|
140
|
+
validatedParams = _c.sent();
|
|
141
|
+
conditionService = req.scope.resolve("discountConditionService");
|
|
142
|
+
discountService = req.scope.resolve("discountService");
|
|
143
|
+
return [4 /*yield*/, discountService.retrieve(discount_id)];
|
|
144
|
+
case 3:
|
|
145
|
+
discount = _c.sent();
|
|
146
|
+
return [4 /*yield*/, conditionService.upsertCondition(__assign(__assign({}, validatedCondition), { rule_id: discount.rule_id }))];
|
|
147
|
+
case 4:
|
|
148
|
+
_c.sent();
|
|
149
|
+
config = (0, get_query_config_1.getRetrieveConfig)(_1.defaultAdminDiscountsFields, _1.defaultAdminDiscountsRelations, (_a = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.fields) === null || _a === void 0 ? void 0 : _a.split(","), (_b = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.expand) === null || _b === void 0 ? void 0 : _b.split(","));
|
|
150
|
+
return [4 /*yield*/, discountService.retrieve(discount.id, config)];
|
|
151
|
+
case 5:
|
|
152
|
+
discount = _c.sent();
|
|
153
|
+
res.status(200).json({ discount: discount });
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}); });
|
|
158
|
+
var AdminPostDiscountsDiscountConditions = /** @class */ (function (_super) {
|
|
159
|
+
__extends(AdminPostDiscountsDiscountConditions, _super);
|
|
160
|
+
function AdminPostDiscountsDiscountConditions() {
|
|
161
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
162
|
+
}
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, class_validator_1.IsString)(),
|
|
165
|
+
__metadata("design:type", String)
|
|
166
|
+
], AdminPostDiscountsDiscountConditions.prototype, "operator", void 0);
|
|
167
|
+
return AdminPostDiscountsDiscountConditions;
|
|
168
|
+
}(discount_1.AdminUpsertConditionsReq));
|
|
169
|
+
exports.AdminPostDiscountsDiscountConditions = AdminPostDiscountsDiscountConditions;
|
|
170
|
+
var AdminPostDiscountsDiscountConditionsParams = /** @class */ (function () {
|
|
171
|
+
function AdminPostDiscountsDiscountConditionsParams() {
|
|
172
|
+
}
|
|
173
|
+
__decorate([
|
|
174
|
+
(0, class_validator_1.IsString)(),
|
|
175
|
+
(0, class_validator_1.IsOptional)(),
|
|
176
|
+
__metadata("design:type", String)
|
|
177
|
+
], AdminPostDiscountsDiscountConditionsParams.prototype, "expand", void 0);
|
|
178
|
+
__decorate([
|
|
179
|
+
(0, class_validator_1.IsString)(),
|
|
180
|
+
(0, class_validator_1.IsOptional)(),
|
|
181
|
+
__metadata("design:type", String)
|
|
182
|
+
], AdminPostDiscountsDiscountConditionsParams.prototype, "fields", void 0);
|
|
183
|
+
return AdminPostDiscountsDiscountConditionsParams;
|
|
184
|
+
}());
|
|
185
|
+
exports.AdminPostDiscountsDiscountConditionsParams = AdminPostDiscountsDiscountConditionsParams;
|
|
186
|
+
//# sourceMappingURL=create-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-condition.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/create-condition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAsD;AACtD,sBAA+E;AAE/E,4EAAiF;AAGjF,uDAAqE;AACrE,uEAAsE;AACtE,yDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;QADC,IAAA,0BAAQ,GAAE;;0EACwB;IACrC,2CAAC;CAAA,AAHD,CAA0D,mCAAwB,GAGjF;AAHY,oFAAoC;AAKjD;IAAA;IAQA,CAAC;IALC;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;8EACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;8EACE;IACjB,iDAAC;CAAA,AARD,IAQC;AARY,gGAA0C"}
|
|
@@ -137,7 +137,6 @@ exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0
|
|
|
137
137
|
case 0: return [4 /*yield*/, (0, validator_1.validator)(AdminPostDiscountsReq, req.body)];
|
|
138
138
|
case 1:
|
|
139
139
|
validated = _c.sent();
|
|
140
|
-
console.log(validated.rule.conditions);
|
|
141
140
|
return [4 /*yield*/, (0, validator_1.validator)(update_discount_1.AdminPostDiscountsDiscountParams, req.query)];
|
|
142
141
|
case 2:
|
|
143
142
|
validatedParams = _c.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-discount.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/create-discount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAwC;AACxC,mDAWwB;AACxB,sBAA+E;AAE/E,4EAAiF;AAEjF,uDAAqE;AACrE,uEAAsE;AACtE,yDAAuD;AACvD,0EAAyE;AACzE,kFAAiF;AACjF,qDAAoE;AACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;oBACV,qBAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,GAAG,CAAC,IAAI,CAAC,EAAA;;gBAA5D,SAAS,GAAG,SAAgD;
|
|
1
|
+
{"version":3,"file":"create-discount.js","sourceRoot":"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,4BAAU,GAAE;;uEACO;IAIpB;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;gEACD;IAGZ;QADC,IAAA,0BAAQ,GAAE;;iEACE;IAIb;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;sEACK;IAMlB;QAJC,IAAA,4BAAU,GAAE;QACZ,IAAA,yBAAO,GAAE;QACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC9B,IAAA,wBAAI,EAAC,cAAM,OAAA,oBAAoB,EAApB,CAAoB,CAAC;;sEACE;IACrC,qCAAC;CAAA,AArBD,IAqBC;AArBY,wEAA8B;AAuB3C;IAA0C,wCAAwB;IAAlE;;IAGA,CAAC;IADC;QADC,IAAA,0BAAQ,GAAE;;0DACwB;IACrC,2BAAC;CAAA,AAHD,CAA0C,mCAAwB,GAGjE;AAHY,oDAAoB;AAKjC;IAAA;IAQA,CAAC;IALC;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;4DACI;IAIjB;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;4DACI;IACnB,+BAAC;CAAA,AARD,IAQC;AARY,4DAAwB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<any>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [delete] /discounts/{discount_id}/conditions/{condition_id}
|
|
4
|
+
* operationId: "DeleteDiscountsDiscountConditionsCondition"
|
|
5
|
+
* summary: "Delete a DiscountCondition"
|
|
6
|
+
* description: "Deletes a DiscountCondition"
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* parameters:
|
|
9
|
+
* - (path) id=* {string} The id of the Discount
|
|
10
|
+
* - (path) condition_id=* {string} The id of the DiscountCondition
|
|
11
|
+
* tags:
|
|
12
|
+
* - Discount
|
|
13
|
+
* responses:
|
|
14
|
+
* 200:
|
|
15
|
+
* description: OK
|
|
16
|
+
* content:
|
|
17
|
+
* application/json:
|
|
18
|
+
* schema:
|
|
19
|
+
* properties:
|
|
20
|
+
* id:
|
|
21
|
+
* type: string
|
|
22
|
+
* description: The id of the deleted DiscountCondition
|
|
23
|
+
* object:
|
|
24
|
+
* type: string
|
|
25
|
+
* description: The type of the object that was deleted.
|
|
26
|
+
* deleted:
|
|
27
|
+
* type: boolean
|
|
28
|
+
* discount:
|
|
29
|
+
* type: object
|
|
30
|
+
* description: The Discount to which the condition used to belong
|
|
31
|
+
*/
|
|
32
|
+
export default _default;
|
|
33
|
+
export declare class AdminDeleteDiscountsDiscountConditionsConditionParams {
|
|
34
|
+
expand?: string;
|
|
35
|
+
fields?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AdminDeleteDiscountsDiscountConditionsConditionParams = void 0;
|
|
49
|
+
var class_validator_1 = require("class-validator");
|
|
50
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
51
|
+
var _1 = require(".");
|
|
52
|
+
var get_query_config_1 = require("../../../../utils/get-query-config");
|
|
53
|
+
var validator_1 = require("../../../../utils/validator");
|
|
54
|
+
/**
|
|
55
|
+
* @oas [delete] /discounts/{discount_id}/conditions/{condition_id}
|
|
56
|
+
* operationId: "DeleteDiscountsDiscountConditionsCondition"
|
|
57
|
+
* summary: "Delete a DiscountCondition"
|
|
58
|
+
* description: "Deletes a DiscountCondition"
|
|
59
|
+
* x-authenticated: true
|
|
60
|
+
* parameters:
|
|
61
|
+
* - (path) id=* {string} The id of the Discount
|
|
62
|
+
* - (path) condition_id=* {string} The id of the DiscountCondition
|
|
63
|
+
* tags:
|
|
64
|
+
* - Discount
|
|
65
|
+
* responses:
|
|
66
|
+
* 200:
|
|
67
|
+
* description: OK
|
|
68
|
+
* content:
|
|
69
|
+
* application/json:
|
|
70
|
+
* schema:
|
|
71
|
+
* properties:
|
|
72
|
+
* id:
|
|
73
|
+
* type: string
|
|
74
|
+
* description: The id of the deleted DiscountCondition
|
|
75
|
+
* object:
|
|
76
|
+
* type: string
|
|
77
|
+
* description: The type of the object that was deleted.
|
|
78
|
+
* deleted:
|
|
79
|
+
* type: boolean
|
|
80
|
+
* discount:
|
|
81
|
+
* type: object
|
|
82
|
+
* description: The Discount to which the condition used to belong
|
|
83
|
+
*/
|
|
84
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
var _a, discount_id, condition_id, validatedParams, conditionService, condition, discountService, discount, existsOnDiscount, config;
|
|
86
|
+
var _b, _c;
|
|
87
|
+
return __generator(this, function (_d) {
|
|
88
|
+
switch (_d.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
_a = req.params, discount_id = _a.discount_id, condition_id = _a.condition_id;
|
|
91
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminDeleteDiscountsDiscountConditionsConditionParams, req.query)];
|
|
92
|
+
case 1:
|
|
93
|
+
validatedParams = _d.sent();
|
|
94
|
+
conditionService = req.scope.resolve("discountConditionService");
|
|
95
|
+
return [4 /*yield*/, conditionService
|
|
96
|
+
.retrieve(condition_id)
|
|
97
|
+
.catch(function () { return void 0; })];
|
|
98
|
+
case 2:
|
|
99
|
+
condition = _d.sent();
|
|
100
|
+
if (!condition) {
|
|
101
|
+
// resolves idempotently in case of non-existing condition
|
|
102
|
+
return [2 /*return*/, res.json({
|
|
103
|
+
id: condition_id,
|
|
104
|
+
object: "discount-condition",
|
|
105
|
+
deleted: true,
|
|
106
|
+
})];
|
|
107
|
+
}
|
|
108
|
+
discountService = req.scope.resolve("discountService");
|
|
109
|
+
return [4 /*yield*/, discountService.retrieve(discount_id, {
|
|
110
|
+
relations: ["rule", "rule.conditions"],
|
|
111
|
+
})];
|
|
112
|
+
case 3:
|
|
113
|
+
discount = _d.sent();
|
|
114
|
+
existsOnDiscount = discount.rule.conditions.some(function (c) { return c.id === condition_id; });
|
|
115
|
+
if (!existsOnDiscount) {
|
|
116
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Condition with id ".concat(condition_id, " does not belong to Discount with id ").concat(discount_id));
|
|
117
|
+
}
|
|
118
|
+
return [4 /*yield*/, conditionService.delete(condition_id)];
|
|
119
|
+
case 4:
|
|
120
|
+
_d.sent();
|
|
121
|
+
config = (0, get_query_config_1.getRetrieveConfig)(_1.defaultAdminDiscountsFields, _1.defaultAdminDiscountsRelations, (_b = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.fields) === null || _b === void 0 ? void 0 : _b.split(","), (_c = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.expand) === null || _c === void 0 ? void 0 : _c.split(","));
|
|
122
|
+
return [4 /*yield*/, discountService.retrieve(discount_id, config)];
|
|
123
|
+
case 5:
|
|
124
|
+
discount = _d.sent();
|
|
125
|
+
res.json({
|
|
126
|
+
id: condition_id,
|
|
127
|
+
object: "discount-condition",
|
|
128
|
+
deleted: true,
|
|
129
|
+
discount: discount,
|
|
130
|
+
});
|
|
131
|
+
return [2 /*return*/];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}); });
|
|
135
|
+
var AdminDeleteDiscountsDiscountConditionsConditionParams = /** @class */ (function () {
|
|
136
|
+
function AdminDeleteDiscountsDiscountConditionsConditionParams() {
|
|
137
|
+
}
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, class_validator_1.IsString)(),
|
|
140
|
+
(0, class_validator_1.IsOptional)(),
|
|
141
|
+
__metadata("design:type", String)
|
|
142
|
+
], AdminDeleteDiscountsDiscountConditionsConditionParams.prototype, "expand", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, class_validator_1.IsString)(),
|
|
145
|
+
(0, class_validator_1.IsOptional)(),
|
|
146
|
+
__metadata("design:type", String)
|
|
147
|
+
], AdminDeleteDiscountsDiscountConditionsConditionParams.prototype, "fields", void 0);
|
|
148
|
+
return AdminDeleteDiscountsDiscountConditionsConditionParams;
|
|
149
|
+
}());
|
|
150
|
+
exports.AdminDeleteDiscountsDiscountConditionsConditionParams = AdminDeleteDiscountsDiscountConditionsConditionParams;
|
|
151
|
+
//# sourceMappingURL=delete-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-condition.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/delete-condition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,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,SAAS,EAC3B,4BAAqB,YAAY,kDAAwC,WAAW,CAAE,CACvF,CAAA;iBACF;gBAED,qBAAM,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,EAAA;;gBAA3C,SAA2C,CAAA;gBAErC,MAAM,GAAG,IAAA,oCAAiB,EAC9B,8BAA2B,EAC3B,iCAA8B,EAC9B,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,0CAAE,KAAK,CAAC,GAAG,CAAuB,EACzD,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,MAAM,0CAAE,KAAK,CAAC,GAAG,CAAC,CACpC,CAAA;gBAEU,qBAAM,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,EAAA;;gBAA9D,QAAQ,GAAG,SAAmD,CAAA;gBAE9D,GAAG,CAAC,IAAI,CAAC;oBACP,EAAE,EAAE,YAAY;oBAChB,MAAM,EAAE,oBAAoB;oBAC5B,OAAO,EAAE,IAAI;oBACb,QAAQ,UAAA;iBACT,CAAC,CAAA;;;;KACH,EAAA;AAED;IAAA;IAQA,CAAC;IALC;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;yFACE;IAIf;QAFC,IAAA,0BAAQ,GAAE;QACV,IAAA,4BAAU,GAAE;;yFACE;IACjB,4DAAC;CAAA,AARD,IAQC;AARY,sHAAqD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [get] /discounts/{discount_id}/conditions/{condition_id}
|
|
4
|
+
* operationId: "GetDiscountsDiscountConditionsCondition"
|
|
5
|
+
* summary: "Gets a DiscountCondition"
|
|
6
|
+
* x-authenticated: true
|
|
7
|
+
* parameters:
|
|
8
|
+
* - (path) discount_id=* {string} The id of the Discount.
|
|
9
|
+
* - (path) condition_id=* {string} The id of the DiscountCondition.
|
|
10
|
+
* query:
|
|
11
|
+
* - (query) expand {string} Comma separated list of relations to include in the results.
|
|
12
|
+
* - (query) fields {string} Comma separated list of fields to include in the results.
|
|
13
|
+
* description: "Gets a DiscountCondition"
|
|
14
|
+
|
|
15
|
+
* tags:
|
|
16
|
+
* - DiscountCondition
|
|
17
|
+
* responses:
|
|
18
|
+
* 200:
|
|
19
|
+
* description: OK
|
|
20
|
+
* content:
|
|
21
|
+
* application/json:
|
|
22
|
+
* schema:
|
|
23
|
+
* properties:
|
|
24
|
+
* discount_condition:
|
|
25
|
+
* $ref: "#/components/schemas/discount_condition"
|
|
26
|
+
*/
|
|
27
|
+
export default _default;
|
|
28
|
+
export declare class AdminGetDiscountsDiscountConditionsConditionParams {
|
|
29
|
+
expand?: string;
|
|
30
|
+
fields?: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.AdminGetDiscountsDiscountConditionsConditionParams = void 0;
|
|
49
|
+
var class_validator_1 = require("class-validator");
|
|
50
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
51
|
+
var _1 = require(".");
|
|
52
|
+
var get_query_config_1 = require("../../../../utils/get-query-config");
|
|
53
|
+
var validator_1 = require("../../../../utils/validator");
|
|
54
|
+
/**
|
|
55
|
+
* @oas [get] /discounts/{discount_id}/conditions/{condition_id}
|
|
56
|
+
* operationId: "GetDiscountsDiscountConditionsCondition"
|
|
57
|
+
* summary: "Gets a DiscountCondition"
|
|
58
|
+
* x-authenticated: true
|
|
59
|
+
* parameters:
|
|
60
|
+
* - (path) discount_id=* {string} The id of the Discount.
|
|
61
|
+
* - (path) condition_id=* {string} The id of the DiscountCondition.
|
|
62
|
+
* query:
|
|
63
|
+
* - (query) expand {string} Comma separated list of relations to include in the results.
|
|
64
|
+
* - (query) fields {string} Comma separated list of fields to include in the results.
|
|
65
|
+
* description: "Gets a DiscountCondition"
|
|
66
|
+
|
|
67
|
+
* tags:
|
|
68
|
+
* - DiscountCondition
|
|
69
|
+
* responses:
|
|
70
|
+
* 200:
|
|
71
|
+
* description: OK
|
|
72
|
+
* content:
|
|
73
|
+
* application/json:
|
|
74
|
+
* schema:
|
|
75
|
+
* properties:
|
|
76
|
+
* discount_condition:
|
|
77
|
+
* $ref: "#/components/schemas/discount_condition"
|
|
78
|
+
*/
|
|
79
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var _a, discount_id, condition_id, validatedParams, discountService, discount, existsOnDiscount, config, conditionService, discountCondition;
|
|
81
|
+
var _b, _c;
|
|
82
|
+
return __generator(this, function (_d) {
|
|
83
|
+
switch (_d.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
_a = req.params, discount_id = _a.discount_id, condition_id = _a.condition_id;
|
|
86
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminGetDiscountsDiscountConditionsConditionParams, req.query)];
|
|
87
|
+
case 1:
|
|
88
|
+
validatedParams = _d.sent();
|
|
89
|
+
discountService = req.scope.resolve("discountService");
|
|
90
|
+
return [4 /*yield*/, discountService.retrieve(discount_id, {
|
|
91
|
+
relations: ["rule", "rule.conditions"],
|
|
92
|
+
})];
|
|
93
|
+
case 2:
|
|
94
|
+
discount = _d.sent();
|
|
95
|
+
existsOnDiscount = discount.rule.conditions.some(function (c) { return c.id === condition_id; });
|
|
96
|
+
if (!existsOnDiscount) {
|
|
97
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Condition with id ".concat(condition_id, " does not belong to Discount with id ").concat(discount_id));
|
|
98
|
+
}
|
|
99
|
+
config = (0, get_query_config_1.getRetrieveConfig)(_1.defaultAdminDiscountConditionFields, _1.defaultAdminDiscountConditionRelations, (_b = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.fields) === null || _b === void 0 ? void 0 : _b.split(","), (_c = validatedParams === null || validatedParams === void 0 ? void 0 : validatedParams.expand) === null || _c === void 0 ? void 0 : _c.split(","));
|
|
100
|
+
conditionService = req.scope.resolve("discountConditionService");
|
|
101
|
+
return [4 /*yield*/, conditionService.retrieve(condition_id, config)];
|
|
102
|
+
case 3:
|
|
103
|
+
discountCondition = _d.sent();
|
|
104
|
+
res.status(200).json({ discount_condition: discountCondition });
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}); });
|
|
109
|
+
var AdminGetDiscountsDiscountConditionsConditionParams = /** @class */ (function () {
|
|
110
|
+
function AdminGetDiscountsDiscountConditionsConditionParams() {
|
|
111
|
+
}
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, class_validator_1.IsString)(),
|
|
114
|
+
(0, class_validator_1.IsOptional)(),
|
|
115
|
+
__metadata("design:type", String)
|
|
116
|
+
], AdminGetDiscountsDiscountConditionsConditionParams.prototype, "expand", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
(0, class_validator_1.IsString)(),
|
|
119
|
+
(0, class_validator_1.IsOptional)(),
|
|
120
|
+
__metadata("design:type", String)
|
|
121
|
+
], AdminGetDiscountsDiscountConditionsConditionParams.prototype, "fields", void 0);
|
|
122
|
+
return AdminGetDiscountsDiscountConditionsConditionParams;
|
|
123
|
+
}());
|
|
124
|
+
exports.AdminGetDiscountsDiscountConditionsConditionParams = AdminGetDiscountsDiscountConditionsConditionParams;
|
|
125
|
+
//# sourceMappingURL=get-condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-condition.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/get-condition.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAsD;AACtD,uDAA+C;AAC/C,sBAGU;AAIV,uEAAsE;AACtE,yDAAuD;AACvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;;gBACtB,KAAgC,GAAG,CAAC,MAAM,EAAxC,WAAW,iBAAA,EAAE,YAAY,kBAAA,CAAe;gBAExB,qBAAM,IAAA,qBAAS,EACrC,kDAAkD,EAClD,GAAG,CAAC,KAAK,CACV,EAAA;;gBAHK,eAAe,GAAG,SAGvB;gBAEK,eAAe,GAAoB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;gBAE5D,qBAAM,eAAe,CAAC,QAAQ,CAAC,WAAW,EAAE;wBAC3D,SAAS,EAAE,CAAC,MAAM,EAAE,iBAAiB,CAAC;q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