@medusajs/medusa 1.2.2-dev.53 → 1.2.2-dev.56
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/index.js +21 -19
- package/dist/api/routes/admin/index.js.map +1 -1
- package/dist/api/routes/admin/price-lists/add-prices-batch.d.ts +70 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js +158 -0
- package/dist/api/routes/admin/price-lists/add-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/create-price-list.d.ts +87 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js +193 -0
- package/dist/api/routes/admin/price-lists/create-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.d.ts +28 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js +84 -0
- package/dist/api/routes/admin/price-lists/delete-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.d.ts +43 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js +118 -0
- package/dist/api/routes/admin/price-lists/delete-prices-batch.js.map +1 -0
- package/dist/api/routes/admin/price-lists/get-price-list.d.ts +22 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js +78 -0
- package/dist/api/routes/admin/price-lists/get-price-list.js.map +1 -0
- package/dist/api/routes/admin/price-lists/index.d.ts +21 -0
- package/dist/api/routes/admin/price-lists/index.js +52 -0
- package/dist/api/routes/admin/price-lists/index.js.map +1 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.d.ts +38 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js +197 -0
- package/dist/api/routes/admin/price-lists/list-price-lists.js.map +1 -0
- package/dist/api/routes/admin/price-lists/update-price-list.d.ts +92 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js +211 -0
- package/dist/api/routes/admin/price-lists/update-price-list.js.map +1 -0
- package/dist/api/routes/admin/products/create-product.d.ts +2 -7
- package/dist/api/routes/admin/products/create-product.js +2 -24
- package/dist/api/routes/admin/products/create-product.js.map +1 -1
- package/dist/api/routes/admin/products/create-variant.d.ts +7 -9
- package/dist/api/routes/admin/products/create-variant.js +7 -26
- package/dist/api/routes/admin/products/create-variant.js.map +1 -1
- package/dist/api/routes/admin/products/index.d.ts +1 -1
- package/dist/api/routes/admin/products/index.js +1 -1
- package/dist/api/routes/admin/products/index.js.map +1 -1
- package/dist/api/routes/admin/products/update-product.d.ts +2 -7
- package/dist/api/routes/admin/products/update-product.js +2 -24
- package/dist/api/routes/admin/products/update-product.js.map +1 -1
- package/dist/api/routes/admin/products/update-variant.d.ts +10 -9
- package/dist/api/routes/admin/products/update-variant.js +10 -26
- package/dist/api/routes/admin/products/update-variant.js.map +1 -1
- package/dist/api/routes/store/collections/list-collections.d.ts +3 -0
- package/dist/api/routes/store/collections/list-collections.js +33 -16
- package/dist/api/routes/store/collections/list-collections.js.map +1 -1
- package/dist/api/routes/store/products/list-products.d.ts +0 -1
- package/dist/api/routes/store/products/list-products.js +0 -6
- package/dist/api/routes/store/products/list-products.js.map +1 -1
- package/dist/api/routes/store/regions/list-regions.d.ts +3 -0
- package/dist/api/routes/store/regions/list-regions.js +22 -7
- package/dist/api/routes/store/regions/list-regions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.d.ts +6 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js +143 -0
- package/dist/migrations/1646915480108-update_money_amount_add_price_list.js.map +1 -0
- package/dist/models/customer-group.d.ts +3 -1
- package/dist/models/customer-group.js +7 -13
- package/dist/models/customer-group.js.map +1 -1
- package/dist/models/money-amount.d.ts +10 -3
- package/dist/models/money-amount.js +22 -5
- package/dist/models/money-amount.js.map +1 -1
- package/dist/models/price-list.d.ts +57 -0
- package/dist/models/price-list.js +142 -0
- package/dist/models/price-list.js.map +1 -0
- package/dist/repositories/money-amount.d.ts +6 -2
- package/dist/repositories/money-amount.js +102 -2
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/price-list.d.ts +4 -0
- package/dist/repositories/price-list.js +38 -0
- package/dist/repositories/price-list.js.map +1 -0
- package/dist/services/discount.js +2 -2
- package/dist/services/discount.js.map +1 -1
- package/dist/services/price-list.d.ts +86 -0
- package/dist/services/price-list.js +469 -0
- package/dist/services/price-list.js.map +1 -0
- package/dist/services/product-variant.d.ts +16 -9
- package/dist/services/product-variant.js +37 -33
- package/dist/services/product-variant.js.map +1 -1
- package/dist/types/price-list.d.ts +70 -0
- package/dist/types/price-list.js +152 -0
- package/dist/types/price-list.js.map +1 -0
- package/dist/types/product-variant.d.ts +18 -1
- package/dist/types/product-variant.js +65 -1
- package/dist/types/product-variant.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,469 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
54
|
+
var t = {};
|
|
55
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
+
t[p] = s[p];
|
|
57
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
+
t[p[i]] = s[p[i]];
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
};
|
|
64
|
+
var __values = (this && this.__values) || function(o) {
|
|
65
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
66
|
+
if (m) return m.call(o);
|
|
67
|
+
if (o && typeof o.length === "number") return {
|
|
68
|
+
next: function () {
|
|
69
|
+
if (o && i >= o.length) o = void 0;
|
|
70
|
+
return { value: o && o[i++], done: !o };
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
74
|
+
};
|
|
75
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
76
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
77
|
+
if (!m) return o;
|
|
78
|
+
var i = m.call(o), r, ar = [], e;
|
|
79
|
+
try {
|
|
80
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
81
|
+
}
|
|
82
|
+
catch (error) { e = { error: error }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e) throw e.error; }
|
|
88
|
+
}
|
|
89
|
+
return ar;
|
|
90
|
+
};
|
|
91
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
93
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
94
|
+
var exception_formatter_1 = require("../utils/exception-formatter");
|
|
95
|
+
/**
|
|
96
|
+
* Provides layer to manipulate product tags.
|
|
97
|
+
* @extends BaseService
|
|
98
|
+
*/
|
|
99
|
+
var PriceListService = /** @class */ (function (_super) {
|
|
100
|
+
__extends(PriceListService, _super);
|
|
101
|
+
function PriceListService(_a) {
|
|
102
|
+
var manager = _a.manager, customerGroupService = _a.customerGroupService, priceListRepository = _a.priceListRepository, moneyAmountRepository = _a.moneyAmountRepository;
|
|
103
|
+
var _this = _super.call(this) || this;
|
|
104
|
+
_this.manager_ = manager;
|
|
105
|
+
_this.customerGroupService_ = customerGroupService;
|
|
106
|
+
_this.priceListRepo_ = priceListRepository;
|
|
107
|
+
_this.moneyAmountRepo_ = moneyAmountRepository;
|
|
108
|
+
return _this;
|
|
109
|
+
}
|
|
110
|
+
PriceListService.prototype.withTransaction = function (transactionManager) {
|
|
111
|
+
if (!transactionManager) {
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
var cloned = new PriceListService({
|
|
115
|
+
manager: transactionManager,
|
|
116
|
+
customerGroupService: this.customerGroupService_,
|
|
117
|
+
priceListRepository: this.priceListRepo_,
|
|
118
|
+
moneyAmountRepository: this.moneyAmountRepo_,
|
|
119
|
+
});
|
|
120
|
+
cloned.transactionManager_ = transactionManager;
|
|
121
|
+
return cloned;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves a product tag by id.
|
|
125
|
+
* @param {string} priceListId - the id of the product tag to retrieve
|
|
126
|
+
* @param {Object} config - the config to retrieve the tag by
|
|
127
|
+
* @return {Promise<PriceList>} the collection.
|
|
128
|
+
*/
|
|
129
|
+
PriceListService.prototype.retrieve = function (priceListId, config) {
|
|
130
|
+
if (config === void 0) { config = {}; }
|
|
131
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
132
|
+
var priceListRepo, query, priceList;
|
|
133
|
+
return __generator(this, function (_a) {
|
|
134
|
+
switch (_a.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
137
|
+
query = this.buildQuery_({ id: priceListId }, config);
|
|
138
|
+
return [4 /*yield*/, priceListRepo.findOne(query)];
|
|
139
|
+
case 1:
|
|
140
|
+
priceList = _a.sent();
|
|
141
|
+
if (!priceList) {
|
|
142
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Price list with id: ".concat(priceListId, " was not found"));
|
|
143
|
+
}
|
|
144
|
+
return [2 /*return*/, priceList];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Creates a Price List
|
|
151
|
+
* @param {CreatePriceListInput} priceListObject - the Price List to create
|
|
152
|
+
* @return {Promise<PriceList>} created Price List
|
|
153
|
+
*/
|
|
154
|
+
PriceListService.prototype.create = function (priceListObject) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var _this = this;
|
|
157
|
+
return __generator(this, function (_a) {
|
|
158
|
+
switch (_a.label) {
|
|
159
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
160
|
+
var priceListRepo, moneyAmountRepo, prices, customer_groups, rest, entity, priceList, result, error_1;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
switch (_a.label) {
|
|
163
|
+
case 0:
|
|
164
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
165
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
166
|
+
prices = priceListObject.prices, customer_groups = priceListObject.customer_groups, rest = __rest(priceListObject, ["prices", "customer_groups"]);
|
|
167
|
+
_a.label = 1;
|
|
168
|
+
case 1:
|
|
169
|
+
_a.trys.push([1, 8, , 9]);
|
|
170
|
+
entity = priceListRepo.create(rest);
|
|
171
|
+
return [4 /*yield*/, priceListRepo.save(entity)];
|
|
172
|
+
case 2:
|
|
173
|
+
priceList = _a.sent();
|
|
174
|
+
if (!prices) return [3 /*break*/, 4];
|
|
175
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices)];
|
|
176
|
+
case 3:
|
|
177
|
+
_a.sent();
|
|
178
|
+
_a.label = 4;
|
|
179
|
+
case 4:
|
|
180
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
181
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(priceList.id, customer_groups)];
|
|
182
|
+
case 5:
|
|
183
|
+
_a.sent();
|
|
184
|
+
_a.label = 6;
|
|
185
|
+
case 6: return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
186
|
+
relations: ["prices", "customer_groups"],
|
|
187
|
+
})];
|
|
188
|
+
case 7:
|
|
189
|
+
result = _a.sent();
|
|
190
|
+
return [2 /*return*/, result];
|
|
191
|
+
case 8:
|
|
192
|
+
error_1 = _a.sent();
|
|
193
|
+
throw (0, exception_formatter_1.formatException)(error_1);
|
|
194
|
+
case 9: return [2 /*return*/];
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}); })];
|
|
198
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Updates a Price List
|
|
205
|
+
* @param {string} id - the id of the Product List to update
|
|
206
|
+
* @param {UpdatePriceListInput} update - the update to apply
|
|
207
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
208
|
+
*/
|
|
209
|
+
PriceListService.prototype.update = function (id, update) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
+
var _this = this;
|
|
212
|
+
return __generator(this, function (_a) {
|
|
213
|
+
switch (_a.label) {
|
|
214
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
+
var priceListRepo, moneyAmountRepo, priceList, prices, customer_groups, rest, _a, _b, _c, key, value, result;
|
|
216
|
+
var e_1, _d;
|
|
217
|
+
return __generator(this, function (_e) {
|
|
218
|
+
switch (_e.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
221
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
222
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
223
|
+
case 1:
|
|
224
|
+
priceList = _e.sent();
|
|
225
|
+
prices = update.prices, customer_groups = update.customer_groups, rest = __rest(update, ["prices", "customer_groups"]);
|
|
226
|
+
try {
|
|
227
|
+
for (_a = __values(Object.entries(rest)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
228
|
+
_c = __read(_b.value, 2), key = _c[0], value = _c[1];
|
|
229
|
+
priceList[key] = value;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
233
|
+
finally {
|
|
234
|
+
try {
|
|
235
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
236
|
+
}
|
|
237
|
+
finally { if (e_1) throw e_1.error; }
|
|
238
|
+
}
|
|
239
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
240
|
+
case 2:
|
|
241
|
+
_e.sent();
|
|
242
|
+
if (!prices) return [3 /*break*/, 4];
|
|
243
|
+
return [4 /*yield*/, moneyAmountRepo.updatePriceListPrices(id, prices)];
|
|
244
|
+
case 3:
|
|
245
|
+
_e.sent();
|
|
246
|
+
_e.label = 4;
|
|
247
|
+
case 4:
|
|
248
|
+
if (!customer_groups) return [3 /*break*/, 6];
|
|
249
|
+
return [4 /*yield*/, this.upsertCustomerGroups_(id, customer_groups)];
|
|
250
|
+
case 5:
|
|
251
|
+
_e.sent();
|
|
252
|
+
_e.label = 6;
|
|
253
|
+
case 6: return [4 /*yield*/, this.retrieve(id, {
|
|
254
|
+
relations: ["prices", "customer_groups"],
|
|
255
|
+
})];
|
|
256
|
+
case 7:
|
|
257
|
+
result = _e.sent();
|
|
258
|
+
return [2 /*return*/, result];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}); })];
|
|
262
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Adds prices to a price list in bulk, optionally replacing all existing prices
|
|
269
|
+
* @param id - id of the price list
|
|
270
|
+
* @param prices - prices to add
|
|
271
|
+
* @param replace - whether to replace existing prices
|
|
272
|
+
* @returns {Promise<PriceList>} updated Price List
|
|
273
|
+
*/
|
|
274
|
+
PriceListService.prototype.addPrices = function (id, prices, replace) {
|
|
275
|
+
if (replace === void 0) { replace = false; }
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var _this = this;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
281
|
+
var moneyAmountRepo, priceList, result;
|
|
282
|
+
return __generator(this, function (_a) {
|
|
283
|
+
switch (_a.label) {
|
|
284
|
+
case 0:
|
|
285
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
286
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
287
|
+
case 1:
|
|
288
|
+
priceList = _a.sent();
|
|
289
|
+
return [4 /*yield*/, moneyAmountRepo.addPriceListPrices(priceList.id, prices, replace)];
|
|
290
|
+
case 2:
|
|
291
|
+
_a.sent();
|
|
292
|
+
return [4 /*yield*/, this.retrieve(priceList.id, {
|
|
293
|
+
relations: ["prices"],
|
|
294
|
+
})];
|
|
295
|
+
case 3:
|
|
296
|
+
result = _a.sent();
|
|
297
|
+
return [2 /*return*/, result];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}); })];
|
|
301
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Removes prices from a price list and deletes the removed prices in bulk
|
|
308
|
+
* @param id - id of the price list
|
|
309
|
+
* @param priceIds - ids of the prices to delete
|
|
310
|
+
* @returns {Promise<void>} updated Price List
|
|
311
|
+
*/
|
|
312
|
+
PriceListService.prototype.deletePrices = function (id, priceIds) {
|
|
313
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
+
var _this = this;
|
|
315
|
+
return __generator(this, function (_a) {
|
|
316
|
+
switch (_a.label) {
|
|
317
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
318
|
+
var moneyAmountRepo, priceList;
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0:
|
|
322
|
+
moneyAmountRepo = manager.getCustomRepository(this.moneyAmountRepo_);
|
|
323
|
+
return [4 /*yield*/, this.retrieve(id, { select: ["id"] })];
|
|
324
|
+
case 1:
|
|
325
|
+
priceList = _a.sent();
|
|
326
|
+
return [4 /*yield*/, moneyAmountRepo.deletePriceListPrices(priceList.id, priceIds)];
|
|
327
|
+
case 2:
|
|
328
|
+
_a.sent();
|
|
329
|
+
return [2 /*return*/, Promise.resolve()];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}); })];
|
|
333
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Deletes a Price List
|
|
340
|
+
* Will never fail due to delete being idempotent.
|
|
341
|
+
* @param id - id of the price list
|
|
342
|
+
* @returns {Promise<void>} empty promise
|
|
343
|
+
*/
|
|
344
|
+
PriceListService.prototype.delete = function (id) {
|
|
345
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
346
|
+
var _this = this;
|
|
347
|
+
return __generator(this, function (_a) {
|
|
348
|
+
switch (_a.label) {
|
|
349
|
+
case 0: return [4 /*yield*/, this.atomicPhase_(function (manager) { return __awaiter(_this, void 0, void 0, function () {
|
|
350
|
+
var priceListRepo, priceList;
|
|
351
|
+
return __generator(this, function (_a) {
|
|
352
|
+
switch (_a.label) {
|
|
353
|
+
case 0:
|
|
354
|
+
priceListRepo = manager.getCustomRepository(this.priceListRepo_);
|
|
355
|
+
return [4 /*yield*/, priceListRepo.findOne({ where: { id: id } })];
|
|
356
|
+
case 1:
|
|
357
|
+
priceList = _a.sent();
|
|
358
|
+
if (!priceList) {
|
|
359
|
+
return [2 /*return*/, Promise.resolve()];
|
|
360
|
+
}
|
|
361
|
+
return [4 /*yield*/, priceListRepo.delete(priceList)];
|
|
362
|
+
case 2:
|
|
363
|
+
_a.sent();
|
|
364
|
+
return [2 /*return*/, Promise.resolve()];
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}); })];
|
|
368
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Lists Price Lists
|
|
375
|
+
* @param {Object} selector - the query object for find
|
|
376
|
+
* @param {Object} config - the config to be used for find
|
|
377
|
+
* @return {Promise<PriceList[]>} the result of the find operation
|
|
378
|
+
*/
|
|
379
|
+
PriceListService.prototype.list = function (selector, config) {
|
|
380
|
+
if (selector === void 0) { selector = {}; }
|
|
381
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
382
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
+
var priceListRepo, query;
|
|
384
|
+
return __generator(this, function (_a) {
|
|
385
|
+
switch (_a.label) {
|
|
386
|
+
case 0:
|
|
387
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
388
|
+
query = this.buildQuery_(selector, config);
|
|
389
|
+
return [4 /*yield*/, priceListRepo.find(query)];
|
|
390
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Lists Price Lists and adds count
|
|
397
|
+
* @param {Object} selector - the query object for find
|
|
398
|
+
* @param {Object} config - the config to be used for find
|
|
399
|
+
* @return {Promise} the result of the find operation
|
|
400
|
+
*/
|
|
401
|
+
PriceListService.prototype.listAndCount = function (selector, config) {
|
|
402
|
+
if (selector === void 0) { selector = {}; }
|
|
403
|
+
if (config === void 0) { config = { skip: 0, take: 20 }; }
|
|
404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
+
var priceListRepo, query;
|
|
406
|
+
return __generator(this, function (_a) {
|
|
407
|
+
switch (_a.label) {
|
|
408
|
+
case 0:
|
|
409
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
410
|
+
query = this.buildQuery_(selector, config);
|
|
411
|
+
return [4 /*yield*/, priceListRepo.findAndCount(query)];
|
|
412
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
PriceListService.prototype.upsertCustomerGroups_ = function (priceListId, customerGroups) {
|
|
418
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
419
|
+
var priceListRepo, priceList, groups, customerGroups_1, customerGroups_1_1, cg, customerGroup, e_2_1;
|
|
420
|
+
var e_2, _a;
|
|
421
|
+
return __generator(this, function (_b) {
|
|
422
|
+
switch (_b.label) {
|
|
423
|
+
case 0:
|
|
424
|
+
priceListRepo = this.manager_.getCustomRepository(this.priceListRepo_);
|
|
425
|
+
return [4 /*yield*/, this.retrieve(priceListId, { select: ["id"] })];
|
|
426
|
+
case 1:
|
|
427
|
+
priceList = _b.sent();
|
|
428
|
+
groups = [];
|
|
429
|
+
_b.label = 2;
|
|
430
|
+
case 2:
|
|
431
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
432
|
+
customerGroups_1 = __values(customerGroups), customerGroups_1_1 = customerGroups_1.next();
|
|
433
|
+
_b.label = 3;
|
|
434
|
+
case 3:
|
|
435
|
+
if (!!customerGroups_1_1.done) return [3 /*break*/, 6];
|
|
436
|
+
cg = customerGroups_1_1.value;
|
|
437
|
+
return [4 /*yield*/, this.customerGroupService_.retrieve(cg.id)];
|
|
438
|
+
case 4:
|
|
439
|
+
customerGroup = _b.sent();
|
|
440
|
+
groups.push(customerGroup);
|
|
441
|
+
_b.label = 5;
|
|
442
|
+
case 5:
|
|
443
|
+
customerGroups_1_1 = customerGroups_1.next();
|
|
444
|
+
return [3 /*break*/, 3];
|
|
445
|
+
case 6: return [3 /*break*/, 9];
|
|
446
|
+
case 7:
|
|
447
|
+
e_2_1 = _b.sent();
|
|
448
|
+
e_2 = { error: e_2_1 };
|
|
449
|
+
return [3 /*break*/, 9];
|
|
450
|
+
case 8:
|
|
451
|
+
try {
|
|
452
|
+
if (customerGroups_1_1 && !customerGroups_1_1.done && (_a = customerGroups_1.return)) _a.call(customerGroups_1);
|
|
453
|
+
}
|
|
454
|
+
finally { if (e_2) throw e_2.error; }
|
|
455
|
+
return [7 /*endfinally*/];
|
|
456
|
+
case 9:
|
|
457
|
+
priceList.customer_groups = groups;
|
|
458
|
+
return [4 /*yield*/, priceListRepo.save(priceList)];
|
|
459
|
+
case 10:
|
|
460
|
+
_b.sent();
|
|
461
|
+
return [2 /*return*/];
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
return PriceListService;
|
|
467
|
+
}(medusa_interfaces_1.BaseService));
|
|
468
|
+
exports.default = PriceListService;
|
|
469
|
+
//# sourceMappingURL=price-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price-list.js","sourceRoot":"","sources":["../../src/services/price-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAc/C,oEAA8D;AAS9D;;;GAGG;AACH;IAA+B,oCAAW;IAMxC,0BAAY,EAKgB;YAJ1B,OAAO,aAAA,EACP,oBAAoB,0BAAA,EACpB,mBAAmB,yBAAA,EACnB,qBAAqB,2BAAA;QAJvB,YAME,iBAAO,SAKR;QAJC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAA;QACjD,KAAI,CAAC,cAAc,GAAG,mBAAmB,CAAA;QACzC,KAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAA;;IAC/C,CAAC;IAED,0CAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;YAClC,OAAO,EAAE,kBAAkB;YAC3B,oBAAoB,EAAE,IAAI,CAAC,qBAAqB;YAChD,mBAAmB,EAAE,IAAI,CAAC,cAAc;YACxC,qBAAqB,EAAE,IAAI,CAAC,gBAAgB;SAC7C,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAE/C,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACG,mCAAQ,GAAd,UACE,W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AS,CAAC,eAAe,GAAG,MAAM,CAAA;wBAElC,qBAAM,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,EAAA;;wBAAnC,SAAmC,CAAA;;;;;KACpC;IACH,uBAAC;AAAD,CAAC,AA1PD,CAA+B,+BAAW,GA0PzC;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseService } from "medusa-interfaces";
|
|
2
2
|
import { EntityManager, SelectQueryBuilder } from "typeorm";
|
|
3
|
-
import { MoneyAmount } from "
|
|
3
|
+
import { MoneyAmount } from "..";
|
|
4
4
|
import { Product } from "../models/product";
|
|
5
5
|
import { ProductOptionValue } from "../models/product-option-value";
|
|
6
6
|
import { ProductVariant } from "../models/product-variant";
|
|
@@ -65,14 +65,14 @@ declare class ProductVariantService extends BaseService {
|
|
|
65
65
|
* @return {Promise} resolves to the update result.
|
|
66
66
|
*/
|
|
67
67
|
update(variantOrVariantId: string | Partial<ProductVariant>, update: UpdateProductVariantInput): Promise<ProductVariant>;
|
|
68
|
-
updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
|
|
69
68
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @param
|
|
73
|
-
* @
|
|
69
|
+
* Updates a variant's prices.
|
|
70
|
+
* Deletes any prices that are not in the update object, and is not associated with a price list.
|
|
71
|
+
* @param variantId - the id of variant variant
|
|
72
|
+
* @param prices - the update prices
|
|
73
|
+
* @returns {Promise<void>} empty promise
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
updateVariantPrices(variantId: string, prices: ProductVariantPrice[]): Promise<void>;
|
|
76
76
|
/**
|
|
77
77
|
* Gets the price specific to a region. If no region specific money amount
|
|
78
78
|
* exists the function will try to use a currency price. If no default
|
|
@@ -83,12 +83,19 @@ declare class ProductVariantService extends BaseService {
|
|
|
83
83
|
*/
|
|
84
84
|
getRegionPrice(variantId: string, regionId: string): Promise<number>;
|
|
85
85
|
/**
|
|
86
|
-
* Sets the price of a specific region
|
|
86
|
+
* Sets the default price of a specific region
|
|
87
87
|
* @param {string} variantId - the id of the variant to update
|
|
88
88
|
* @param {string} price - the price for the variant.
|
|
89
89
|
* @return {Promise} the result of the update operation
|
|
90
90
|
*/
|
|
91
91
|
setRegionPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
|
|
92
|
+
/**
|
|
93
|
+
* Sets the default price for the given currency.
|
|
94
|
+
* @param {string} variantId - the id of the variant to set prices for
|
|
95
|
+
* @param {ProductVariantPrice} price - the price for the variant
|
|
96
|
+
* @return {Promise} the result of the update operation
|
|
97
|
+
*/
|
|
98
|
+
setCurrencyPrice(variantId: string, price: ProductVariantPrice): Promise<MoneyAmount>;
|
|
92
99
|
/**
|
|
93
100
|
* Updates variant's option value.
|
|
94
101
|
* Option value must be of type string or number.
|
|
@@ -144,7 +151,7 @@ declare class ProductVariantService extends BaseService {
|
|
|
144
151
|
* @param {Object} metadata - the metadata to set
|
|
145
152
|
* @return {Object} updated metadata object
|
|
146
153
|
*/
|
|
147
|
-
setMetadata_(variant: ProductVariant, metadata: object): Record<string,
|
|
154
|
+
setMetadata_(variant: ProductVariant, metadata: object): Record<string, unknown>;
|
|
148
155
|
/**
|
|
149
156
|
* Creates a query object to be used for list queries.
|
|
150
157
|
* @param {object} selector - the selector to create the query from
|