@medusajs/medusa 1.3.0 → 1.3.1-next.14
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/index.d.ts +3 -0
- package/dist/api/routes/admin/discounts/index.js +7 -0
- 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/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/commands/develop.js +1 -1
- package/dist/commands/develop.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 +8 -8
- package/dist/services/cart.js +100 -128
- package/dist/services/cart.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/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-variant.js +1 -1
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.js +2 -2
- package/dist/services/product.js.map +1 -1
- package/dist/types/cart.d.ts +1 -1
- package/dist/types/common.d.ts +20 -0
- package/dist/types/common.js.map +1 -1
- package/dist/types/discount.d.ts +1 -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/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/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/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;;gBACpB,WAAW,GAAK,GAAG,CAAC,MAAM,YAAf,CAAe;gBAEP,qBAAM,IAAA,qBAAS,EACxC,oCAAoC,EACpC,GAAG,CAAC,IAAI,CACT,EAAA;;gBAHK,kBAAkB,GAAG,SAG1B;gBAEuB,qBAAM,IAAA,qBAAS,EACrC,0C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AAA,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":"","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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,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,mDAAsD;AACtD,uDAA+C;AAC/C,sBAA+E;AAI/E,uEAAsE;AACtE,yDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;;;gBACtB,KAAgC,GAAG,CAAC,MAAM,EAAxC,WAAW,iBAAA,EAAE,YAAY,kBAAA,CAAe;gBAExB,qBAAM,IAAA,qBAAS,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AAM,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"}
|
|
@@ -13,12 +13,15 @@ export declare type AdminDiscountsListRes = PaginatedResponse & {
|
|
|
13
13
|
discounts: Discount[];
|
|
14
14
|
};
|
|
15
15
|
export * from "./add-region";
|
|
16
|
+
export * from "./create-condition";
|
|
16
17
|
export * from "./create-discount";
|
|
17
18
|
export * from "./create-dynamic-code";
|
|
19
|
+
export * from "./delete-condition";
|
|
18
20
|
export * from "./delete-discount";
|
|
19
21
|
export * from "./delete-dynamic-code";
|
|
20
22
|
export * from "./get-discount";
|
|
21
23
|
export * from "./get-discount-by-code";
|
|
22
24
|
export * from "./list-discounts";
|
|
23
25
|
export * from "./remove-region";
|
|
26
|
+
export * from "./update-condition";
|
|
24
27
|
export * from "./update-discount";
|
|
@@ -32,6 +32,10 @@ exports.default = (function (app) {
|
|
|
32
32
|
// Discount region management
|
|
33
33
|
route.post("/:discount_id/regions/:region_id", middlewares_1.default.wrap(require("./add-region").default));
|
|
34
34
|
route.delete("/:discount_id/regions/:region_id", middlewares_1.default.wrap(require("./remove-region").default));
|
|
35
|
+
// Discount condition management
|
|
36
|
+
route.post("/:discount_id/conditions/:condition_id", middlewares_1.default.wrap(require("./update-condition").default));
|
|
37
|
+
route.post("/:discount_id/conditions", middlewares_1.default.wrap(require("./create-condition").default));
|
|
38
|
+
route.delete("/:discount_id/conditions/:condition_id", middlewares_1.default.wrap(require("./delete-condition").default));
|
|
35
39
|
return app;
|
|
36
40
|
});
|
|
37
41
|
exports.defaultAdminDiscountsFields = [
|
|
@@ -58,13 +62,16 @@ exports.defaultAdminDiscountsRelations = [
|
|
|
58
62
|
"rule.conditions",
|
|
59
63
|
];
|
|
60
64
|
__exportStar(require("./add-region"), exports);
|
|
65
|
+
__exportStar(require("./create-condition"), exports);
|
|
61
66
|
__exportStar(require("./create-discount"), exports);
|
|
62
67
|
__exportStar(require("./create-dynamic-code"), exports);
|
|
68
|
+
__exportStar(require("./delete-condition"), exports);
|
|
63
69
|
__exportStar(require("./delete-discount"), exports);
|
|
64
70
|
__exportStar(require("./delete-dynamic-code"), exports);
|
|
65
71
|
__exportStar(require("./get-discount"), exports);
|
|
66
72
|
__exportStar(require("./get-discount-by-code"), exports);
|
|
67
73
|
__exportStar(require("./list-discounts"), exports);
|
|
68
74
|
__exportStar(require("./remove-region"), exports);
|
|
75
|
+
__exportStar(require("./update-condition"), exports);
|
|
69
76
|
__exportStar(require("./update-discount"), exports);
|
|
70
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,4BAAyB;AAGzB,qEAA8C;AAE9C,IAAM,KAAK,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEtB,mBAAe,UAAC,GAAG;IACjB,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;IAE5B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAW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A;AACZ,CAAC,EAAA;AAEY,QAAA,2BAA2B,GAAuB;IAC7D,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,aAAa;IACb,SAAS;IACT,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,WAAW;IACX,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,gBAAgB;CACjB,CAAA;AAEY,QAAA,8BAA8B,GAAG;IAC5C,MAAM;IACN,iBAAiB;IACjB,SAAS;IACT,iBAAiB;CAClB,CAAA;AAYD,+CAA4B;AAC5B,oDAAiC;AACjC,wDAAqC;AACrC,oDAAiC;AACjC,wDAAqC;AACrC,iDAA8B;AAC9B,yDAAsC;AACtC,mDAAgC;AAChC,kDAA+B;AAC/B,oDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/discounts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mCAAgC;AAChC,4BAAyB;AAGzB,qEAA8C;AAE9C,IAAM,KAAK,GAAG,IAAA,gBAAM,GAAE,CAAA;AAEtB,mBAAe,UAAC,GAAG;IACjB,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;IAE5B,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,qBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IACrE,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,qBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;IAEvE,KAAK,CAAC,GAAG,CACP,eAAe,EACf,qBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CACpD,CAAA;IACD,KAAK,CAAC,GAAG,CACP,aAAa,EACb,qBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC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A,2BAA2B,GAAuB;IAC7D,IAAI;IACJ,MAAM;IACN,YAAY;IACZ,aAAa;IACb,SAAS;IACT,oBAAoB;IACpB,aAAa;IACb,aAAa;IACb,WAAW;IACX,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,gBAAgB;CACjB,CAAA;AAEY,QAAA,8BAA8B,GAAG;IAC5C,MAAM;IACN,iBAAiB;IACjB,SAAS;IACT,iBAAiB;CAClB,CAAA;AAYD,+CAA4B;AAC5B,qDAAkC;AAClC,oDAAiC;AACjC,wDAAqC;AACrC,qDAAkC;AAClC,oDAAiC;AACjC,wDAAqC;AACrC,iDAA8B;AAC9B,yDAAsC;AACtC,mDAAgC;AAChC,kDAA+B;AAC/B,qDAAkC;AAClC,oDAAiC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AdminUpsertConditionsReq } from "../../../../types/discount";
|
|
2
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* @oas [post] /discounts/{discount_id}/conditions/{condition_id}
|
|
5
|
+
* operationId: "PostDiscountsDiscountConditionsCondition"
|
|
6
|
+
* summary: "Updates a DiscountCondition"
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* parameters:
|
|
9
|
+
* - (path) discount_id=* {string} The id of the Product.
|
|
10
|
+
* - (query) expand {string} (Comma separated) Which fields should be expanded in each product of the result.
|
|
11
|
+
* - (query) fields {string} (Comma separated) Which fields should be included in each product of the result.
|
|
12
|
+
* description: "Updates a DiscountCondition"
|
|
13
|
+
* requestBody:
|
|
14
|
+
* content:
|
|
15
|
+
* application/json:
|
|
16
|
+
* required:
|
|
17
|
+
* - id
|
|
18
|
+
* schema:
|
|
19
|
+
* properties:
|
|
20
|
+
* items:
|
|
21
|
+
* properties:
|
|
22
|
+
* products:
|
|
23
|
+
* type: array
|
|
24
|
+
* description: list of products
|
|
25
|
+
* product_types:
|
|
26
|
+
* type: array
|
|
27
|
+
* description: list of product types
|
|
28
|
+
* product_collections:
|
|
29
|
+
* type: array
|
|
30
|
+
* description: list of product collections
|
|
31
|
+
* product_tags:
|
|
32
|
+
* type: array
|
|
33
|
+
* description: list of product tags
|
|
34
|
+
* customer_groups:
|
|
35
|
+
* type: array
|
|
36
|
+
* description: list of customer_groups
|
|
37
|
+
* tags:
|
|
38
|
+
* - Discount
|
|
39
|
+
* responses:
|
|
40
|
+
* 200:
|
|
41
|
+
* description: OK
|
|
42
|
+
* content:
|
|
43
|
+
* application/json:
|
|
44
|
+
* schema:
|
|
45
|
+
* properties:
|
|
46
|
+
* discount:
|
|
47
|
+
* $ref: "#/components/schemas/discount"
|
|
48
|
+
*/
|
|
49
|
+
export default _default;
|
|
50
|
+
export declare class AdminPostDiscountsDiscountConditionsCondition extends AdminUpsertConditionsReq {
|
|
51
|
+
}
|
|
52
|
+
export declare class AdminPostDiscountsDiscountConditionsConditionParams {
|
|
53
|
+
expand?: string;
|
|
54
|
+
fields?: string;
|
|
55
|
+
}
|