@medusajs/medusa 1.1.63 → 1.2.0
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/CHANGELOG.md +31 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/routes/admin/collections/add-products.d.ts +32 -0
- package/dist/api/routes/admin/{product-tags/update-collection.js → collections/add-products.js} +25 -45
- package/dist/api/routes/admin/collections/add-products.js.map +1 -0
- package/dist/api/routes/admin/collections/index.d.ts +2 -0
- package/dist/api/routes/admin/collections/index.js +11 -1
- package/dist/api/routes/admin/collections/index.js.map +1 -1
- package/dist/api/routes/admin/collections/remove-products.d.ts +32 -0
- package/dist/api/routes/admin/{product-tags/create-collection.js → collections/remove-products.js} +35 -49
- package/dist/api/routes/admin/collections/remove-products.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/create-customer-group.d.ts +27 -0
- package/dist/api/routes/admin/customer-groups/create-customer-group.js +103 -0
- package/dist/api/routes/admin/customer-groups/create-customer-group.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/delete-customer-group.d.ts +28 -0
- package/dist/api/routes/admin/{product-tags/delete-collection.js → customer-groups/delete-customer-group.js} +25 -25
- package/dist/api/routes/admin/customer-groups/delete-customer-group.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.d.ts +27 -0
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.js +106 -0
- package/dist/api/routes/admin/customer-groups/delete-customers-batch.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/get-customer-group.d.ts +25 -0
- package/dist/api/routes/admin/customer-groups/get-customer-group.js +113 -0
- package/dist/api/routes/admin/customer-groups/get-customer-group.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/index.d.ts +13 -0
- package/dist/api/routes/admin/customer-groups/index.js +31 -0
- package/dist/api/routes/admin/customer-groups/index.js.map +1 -0
- package/dist/api/routes/admin/customer-groups/update-customer-group.d.ts +28 -0
- package/dist/api/routes/admin/customer-groups/update-customer-group.js +124 -0
- package/dist/api/routes/admin/customer-groups/update-customer-group.js.map +1 -0
- package/dist/api/routes/admin/customers/get-customer.js +18 -5
- package/dist/api/routes/admin/customers/get-customer.js.map +1 -1
- package/dist/api/routes/admin/customers/index.d.ts +1 -0
- package/dist/api/routes/admin/customers/index.js +2 -0
- package/dist/api/routes/admin/customers/index.js.map +1 -1
- package/dist/api/routes/admin/customers/update-customer.d.ts +14 -0
- package/dist/api/routes/admin/customers/update-customer.js +49 -10
- package/dist/api/routes/admin/customers/update-customer.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-draft-order.d.ts +3 -3
- package/dist/api/routes/admin/draft-orders/create-draft-order.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/create-line-item.js.map +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.d.ts +1 -1
- package/dist/api/routes/admin/draft-orders/update-line-item.js.map +1 -1
- package/dist/api/routes/admin/index.js +6 -0
- package/dist/api/routes/admin/index.js.map +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.d.ts +1 -1
- package/dist/api/routes/admin/orders/add-shipping-method.js.map +1 -1
- package/dist/api/routes/admin/orders/create-claim.js +9 -1
- package/dist/api/routes/admin/orders/create-claim.js.map +1 -1
- package/dist/api/routes/admin/orders/create-swap-shipment.js +1 -0
- package/dist/api/routes/admin/orders/create-swap-shipment.js.map +1 -1
- package/dist/api/routes/admin/orders/create-swap.js +7 -1
- package/dist/api/routes/admin/orders/create-swap.js.map +1 -1
- package/dist/api/routes/admin/orders/index.d.ts +0 -1
- package/dist/api/routes/admin/orders/index.js +2 -5
- package/dist/api/routes/admin/orders/index.js.map +1 -1
- package/dist/api/routes/admin/product-types/index.d.ts +15 -0
- package/dist/api/routes/admin/product-types/index.js +40 -0
- package/dist/api/routes/admin/product-types/index.js.map +1 -0
- package/dist/api/routes/admin/product-types/list-product-types.d.ts +39 -0
- package/dist/api/routes/admin/{product-tags/list-collections.js → product-types/list-product-types.js} +72 -76
- package/dist/api/routes/admin/product-types/list-product-types.js.map +1 -0
- package/dist/api/routes/admin/regions/index.js +3 -0
- package/dist/api/routes/admin/regions/index.js.map +1 -1
- package/dist/api/routes/admin/regions/list-regions.d.ts +27 -3
- package/dist/api/routes/admin/regions/list-regions.js +91 -11
- package/dist/api/routes/admin/regions/list-regions.js.map +1 -1
- package/dist/api/routes/admin/regions/update-region.d.ts +12 -0
- package/dist/api/routes/admin/regions/update-region.js +24 -0
- package/dist/api/routes/admin/regions/update-region.js.map +1 -1
- package/dist/api/routes/admin/shipping-options/index.d.ts +2 -2
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js +23 -7
- package/dist/api/routes/admin/shipping-options/list-shipping-options.js.map +1 -1
- package/dist/api/routes/admin/store/index.d.ts +4 -1
- package/dist/api/routes/admin/store/index.js +1 -0
- package/dist/api/routes/admin/store/index.js.map +1 -1
- package/dist/api/routes/admin/store/list-tax-providers.d.ts +22 -0
- package/dist/api/routes/admin/{product-tags/get-collection.js → store/list-tax-providers.js} +21 -22
- package/dist/api/routes/admin/store/list-tax-providers.js.map +1 -0
- package/dist/api/routes/admin/swaps/index.js +0 -6
- package/dist/api/routes/admin/swaps/index.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-product-types.d.ts +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-product-types.js +4 -59
- package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-products.d.ts +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-products.js +4 -55
- package/dist/api/routes/admin/tax-rates/add-to-products.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.d.ts +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +4 -59
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/create-tax-rate.js +14 -113
- package/dist/api/routes/admin/tax-rates/create-tax-rate.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/index.d.ts +3 -0
- package/dist/api/routes/admin/tax-rates/index.js +18 -3
- package/dist/api/routes/admin/tax-rates/index.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/list-tax-rates.d.ts +2 -2
- package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/remove-from-product-types.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/remove-from-product-types.js +122 -0
- package/dist/api/routes/admin/tax-rates/remove-from-product-types.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/remove-from-products.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/remove-from-products.js +122 -0
- package/dist/api/routes/admin/tax-rates/remove-from-products.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js +122 -0
- package/dist/api/routes/admin/tax-rates/remove-from-shipping-options.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/update-tax-rate.js +15 -116
- package/dist/api/routes/admin/tax-rates/update-tax-rate.js.map +1 -1
- package/dist/api/routes/store/carts/add-shipping-method.d.ts +1 -1
- package/dist/api/routes/store/carts/add-shipping-method.js.map +1 -1
- package/dist/api/routes/store/carts/complete-cart.js +11 -247
- package/dist/api/routes/store/carts/complete-cart.js.map +1 -1
- package/dist/api/routes/store/carts/index.js +2 -0
- package/dist/api/routes/store/carts/index.js.map +1 -1
- package/dist/api/routes/store/swaps/create-swap.js +7 -1
- package/dist/api/routes/store/swaps/create-swap.js.map +1 -1
- package/dist/db-subscribers/region.d.ts +6 -0
- package/dist/db-subscribers/region.js +84 -0
- package/dist/db-subscribers/region.js.map +1 -0
- package/dist/entity-subscribers/region.d.ts +6 -0
- package/dist/entity-subscribers/region.js +27 -0
- package/dist/entity-subscribers/region.js.map +1 -0
- package/dist/helpers/test-request.js +2 -0
- package/dist/helpers/test-request.js.map +1 -1
- package/dist/index.d.ts +59 -50
- package/dist/index.js +60 -101
- package/dist/index.js.map +1 -1
- package/dist/loaders/db-subscribers.d.ts +6 -0
- package/dist/loaders/db-subscribers.js +53 -0
- package/dist/loaders/db-subscribers.js.map +1 -0
- package/dist/loaders/index.d.ts +2 -1
- package/dist/loaders/index.js +17 -4
- package/dist/loaders/index.js.map +1 -1
- package/dist/loaders/models.js.map +1 -1
- package/dist/loaders/passport.js.map +1 -1
- package/dist/loaders/plugins.js +26 -0
- package/dist/loaders/plugins.js.map +1 -1
- package/dist/loaders/services.d.ts +2 -1
- package/dist/loaders/services.js +9 -7
- package/dist/loaders/services.js.map +1 -1
- package/dist/migrations/1641636508055-new_tax_system.js +9 -9
- package/dist/migrations/1641636508055-new_tax_system.js.map +1 -1
- package/dist/migrations/1644943746861-customer_groups.d.ts +6 -0
- package/dist/migrations/1644943746861-customer_groups.js +107 -0
- package/dist/migrations/1644943746861-customer_groups.js.map +1 -0
- package/dist/models/cart.d.ts +2 -1
- package/dist/models/cart.js +1 -0
- package/dist/models/cart.js.map +1 -1
- package/dist/models/customer-group.d.ts +11 -0
- package/dist/models/customer-group.js +81 -0
- package/dist/models/customer-group.js.map +1 -0
- package/dist/models/customer.d.ts +2 -0
- package/dist/models/customer.js +18 -1
- package/dist/models/customer.js.map +1 -1
- package/dist/models/line-item.d.ts +3 -0
- package/dist/models/line-item.js +9 -0
- package/dist/models/line-item.js.map +1 -1
- package/dist/models/order.d.ts +2 -1
- package/dist/models/order.js +3 -2
- package/dist/models/order.js.map +1 -1
- package/dist/models/product-tax-rate.d.ts +0 -1
- package/dist/models/product-tax-rate.js +5 -7
- package/dist/models/product-tax-rate.js.map +1 -1
- package/dist/models/product-type-tax-rate.d.ts +0 -1
- package/dist/models/product-type-tax-rate.js +2 -6
- package/dist/models/product-type-tax-rate.js.map +1 -1
- package/dist/models/product.d.ts +1 -1
- package/dist/models/product.js +2 -2
- package/dist/models/product.js.map +1 -1
- package/dist/models/region.d.ts +7 -0
- package/dist/models/region.js +31 -2
- package/dist/models/region.js.map +1 -1
- package/dist/models/shipping-method.d.ts +2 -0
- package/dist/models/shipping-method.js +7 -0
- package/dist/models/shipping-method.js.map +1 -1
- package/dist/models/shipping-tax-rate.d.ts +0 -1
- package/dist/models/shipping-tax-rate.js +2 -6
- package/dist/models/shipping-tax-rate.js.map +1 -1
- package/dist/models/swap.d.ts +1 -1
- package/dist/models/swap.js +1 -1
- package/dist/models/swap.js.map +1 -1
- package/dist/repositories/customer-group.d.ts +5 -0
- package/dist/repositories/customer-group.js +91 -0
- package/dist/repositories/customer-group.js.map +1 -0
- package/dist/repositories/line-item.d.ts +12 -0
- package/dist/repositories/line-item.js +61 -0
- package/dist/repositories/line-item.js.map +1 -1
- package/dist/repositories/money-amount.d.ts +6 -0
- package/dist/repositories/money-amount.js +97 -0
- package/dist/repositories/money-amount.js.map +1 -1
- package/dist/repositories/product.d.ts +2 -0
- package/dist/repositories/product.js +32 -0
- package/dist/repositories/product.js.map +1 -1
- package/dist/repositories/tax-provider.d.ts +4 -0
- package/dist/repositories/tax-provider.js +38 -0
- package/dist/repositories/tax-provider.js.map +1 -0
- package/dist/repositories/tax-rate.d.ts +7 -4
- package/dist/repositories/tax-rate.js +96 -21
- package/dist/repositories/tax-rate.js.map +1 -1
- package/dist/services/cart.d.ts +92 -114
- package/dist/services/cart.js +142 -144
- package/dist/services/cart.js.map +1 -1
- package/dist/services/claim.d.ts +22 -33
- package/dist/services/claim.js +106 -95
- package/dist/services/claim.js.map +1 -1
- package/dist/services/customer-group.d.ts +54 -0
- package/dist/services/customer-group.js +265 -0
- package/dist/services/customer-group.js.map +1 -0
- package/dist/services/customer.d.ts +3 -1
- package/dist/services/customer.js +28 -17
- package/dist/services/customer.js.map +1 -1
- package/dist/services/fulfillment.js +1 -1
- package/dist/services/fulfillment.js.map +1 -1
- package/dist/services/gift-card.js +1 -1
- package/dist/services/gift-card.js.map +1 -1
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +9 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/invite.d.ts +3 -3
- package/dist/services/invite.js +4 -2
- package/dist/services/invite.js.map +1 -1
- package/dist/services/line-item.d.ts +12 -1
- package/dist/services/line-item.js +49 -1
- package/dist/services/line-item.js.map +1 -1
- package/dist/services/order.d.ts +6 -2
- package/dist/services/order.js +186 -80
- package/dist/services/order.js.map +1 -1
- package/dist/services/product-collection.d.ts +2 -0
- package/dist/services/product-collection.js +49 -0
- package/dist/services/product-collection.js.map +1 -1
- package/dist/services/product-type.d.ts +15 -0
- package/dist/services/product-type.js +44 -0
- package/dist/services/product-type.js.map +1 -1
- package/dist/services/product-variant.d.ts +2 -1
- package/dist/services/product-variant.js +96 -85
- package/dist/services/product-variant.js.map +1 -1
- package/dist/services/product.js +3 -1
- package/dist/services/product.js.map +1 -1
- package/dist/services/region.d.ts +4 -1
- package/dist/services/region.js +25 -10
- package/dist/services/region.js.map +1 -1
- package/dist/services/return.d.ts +3 -1
- package/dist/services/return.js +37 -26
- package/dist/services/return.js.map +1 -1
- package/dist/services/shipping-option.d.ts +7 -4
- package/dist/services/shipping-option.js +22 -5
- package/dist/services/shipping-option.js.map +1 -1
- package/dist/services/swap.d.ts +5 -22
- package/dist/services/swap.js +308 -454
- package/dist/services/swap.js.map +1 -1
- package/dist/services/tax-provider.d.ts +3 -0
- package/dist/services/tax-provider.js +10 -0
- package/dist/services/tax-provider.js.map +1 -1
- package/dist/services/tax-rate.d.ts +13 -6
- package/dist/services/tax-rate.js +235 -41
- package/dist/services/tax-rate.js.map +1 -1
- package/dist/services/totals.d.ts +194 -59
- package/dist/services/totals.js +581 -106
- package/dist/services/totals.js.map +1 -1
- package/dist/subscribers/region.d.ts +14 -0
- package/dist/subscribers/region.js +65 -0
- package/dist/subscribers/region.js.map +1 -0
- package/dist/types/cart.d.ts +2 -1
- package/dist/types/cart.js +6 -1
- package/dist/types/cart.js.map +1 -1
- package/dist/types/common.d.ts +5 -1
- package/dist/types/common.js +22 -7
- package/dist/types/common.js.map +1 -1
- package/dist/types/customer-groups.d.ts +11 -0
- package/dist/types/customer-groups.js +43 -0
- package/dist/types/customer-groups.js.map +1 -0
- package/dist/types/orders.d.ts +2 -0
- package/dist/types/orders.js +6 -1
- package/dist/types/orders.js.map +1 -1
- package/dist/types/product.d.ts +6 -0
- package/dist/types/product.js +25 -1
- package/dist/types/product.js.map +1 -1
- package/dist/utils/format-registration-name.js +3 -0
- package/dist/utils/format-registration-name.js.map +1 -1
- package/package.json +5 -4
- package/yarn-error.log +5 -79
- package/dist/api/routes/admin/product-tags/create-collection.d.ts +0 -41
- package/dist/api/routes/admin/product-tags/create-collection.js.map +0 -1
- package/dist/api/routes/admin/product-tags/delete-collection.d.ts +0 -28
- package/dist/api/routes/admin/product-tags/delete-collection.js.map +0 -1
- package/dist/api/routes/admin/product-tags/get-collection.d.ts +0 -22
- package/dist/api/routes/admin/product-tags/get-collection.js.map +0 -1
- package/dist/api/routes/admin/product-tags/list-collections.d.ts +0 -40
- package/dist/api/routes/admin/product-tags/list-collections.js.map +0 -1
- package/dist/api/routes/admin/product-tags/update-collection.d.ts +0 -41
- package/dist/api/routes/admin/product-tags/update-collection.js.map +0 -1
|
@@ -213,7 +213,22 @@ var TaxRateRepository = /** @class */ (function (_super) {
|
|
|
213
213
|
}
|
|
214
214
|
return qb;
|
|
215
215
|
};
|
|
216
|
-
TaxRateRepository.prototype.
|
|
216
|
+
TaxRateRepository.prototype.removeFromProduct = function (id, productIds) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
return __generator(this, function (_a) {
|
|
219
|
+
switch (_a.label) {
|
|
220
|
+
case 0: return [4 /*yield*/, this.createQueryBuilder()
|
|
221
|
+
.delete()
|
|
222
|
+
.from(product_tax_rate_1.ProductTaxRate)
|
|
223
|
+
.where({ rate_id: id, product_id: (0, typeorm_1.In)(productIds) })
|
|
224
|
+
.execute()];
|
|
225
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
TaxRateRepository.prototype.addToProduct = function (id, productIds, overrideExisting) {
|
|
231
|
+
if (overrideExisting === void 0) { overrideExisting = false; }
|
|
217
232
|
return __awaiter(this, void 0, void 0, function () {
|
|
218
233
|
var toInsert, insertResult;
|
|
219
234
|
return __generator(this, function (_a) {
|
|
@@ -222,22 +237,47 @@ var TaxRateRepository = /** @class */ (function (_super) {
|
|
|
222
237
|
toInsert = productIds.map(function (pId) { return ({ rate_id: id, product_id: pId }); });
|
|
223
238
|
return [4 /*yield*/, this.createQueryBuilder()
|
|
224
239
|
.insert()
|
|
240
|
+
.orIgnore(true)
|
|
225
241
|
.into(product_tax_rate_1.ProductTaxRate)
|
|
226
242
|
.values(toInsert)
|
|
227
243
|
.execute()];
|
|
228
244
|
case 1:
|
|
229
245
|
insertResult = _a.sent();
|
|
230
|
-
return [
|
|
231
|
-
|
|
232
|
-
.
|
|
233
|
-
.
|
|
234
|
-
.
|
|
235
|
-
|
|
246
|
+
if (!overrideExisting) return [3 /*break*/, 3];
|
|
247
|
+
return [4 /*yield*/, this.createQueryBuilder()
|
|
248
|
+
.delete()
|
|
249
|
+
.from(product_tax_rate_1.ProductTaxRate)
|
|
250
|
+
.where({ rate_id: id, product_id: (0, typeorm_1.Not)((0, typeorm_1.In)(productIds)) })
|
|
251
|
+
.execute()];
|
|
252
|
+
case 2:
|
|
253
|
+
_a.sent();
|
|
254
|
+
_a.label = 3;
|
|
255
|
+
case 3: return [4 /*yield*/, this.manager
|
|
256
|
+
.createQueryBuilder(product_tax_rate_1.ProductTaxRate, "ptr")
|
|
257
|
+
.select()
|
|
258
|
+
.where(insertResult.identifiers)
|
|
259
|
+
.getMany()];
|
|
260
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
TaxRateRepository.prototype.removeFromProductType = function (id, productTypeIds) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
267
|
+
return __generator(this, function (_a) {
|
|
268
|
+
switch (_a.label) {
|
|
269
|
+
case 0: return [4 /*yield*/, this.createQueryBuilder()
|
|
270
|
+
.delete()
|
|
271
|
+
.from(product_type_tax_rate_1.ProductTypeTaxRate)
|
|
272
|
+
.where({ rate_id: id, product_type_id: (0, typeorm_1.In)(productTypeIds) })
|
|
273
|
+
.execute()];
|
|
274
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
236
275
|
}
|
|
237
276
|
});
|
|
238
277
|
});
|
|
239
278
|
};
|
|
240
|
-
TaxRateRepository.prototype.addToProductType = function (id, productTypeIds) {
|
|
279
|
+
TaxRateRepository.prototype.addToProductType = function (id, productTypeIds, overrideExisting) {
|
|
280
|
+
if (overrideExisting === void 0) { overrideExisting = false; }
|
|
241
281
|
return __awaiter(this, void 0, void 0, function () {
|
|
242
282
|
var toInsert, insertResult;
|
|
243
283
|
return __generator(this, function (_a) {
|
|
@@ -249,22 +289,47 @@ var TaxRateRepository = /** @class */ (function (_super) {
|
|
|
249
289
|
}); });
|
|
250
290
|
return [4 /*yield*/, this.createQueryBuilder()
|
|
251
291
|
.insert()
|
|
292
|
+
.orIgnore(true)
|
|
252
293
|
.into(product_type_tax_rate_1.ProductTypeTaxRate)
|
|
253
294
|
.values(toInsert)
|
|
254
295
|
.execute()];
|
|
255
296
|
case 1:
|
|
256
297
|
insertResult = _a.sent();
|
|
257
|
-
return [
|
|
258
|
-
|
|
259
|
-
.
|
|
260
|
-
.
|
|
261
|
-
.
|
|
262
|
-
|
|
298
|
+
if (!overrideExisting) return [3 /*break*/, 3];
|
|
299
|
+
return [4 /*yield*/, this.createQueryBuilder()
|
|
300
|
+
.delete()
|
|
301
|
+
.from(product_type_tax_rate_1.ProductTypeTaxRate)
|
|
302
|
+
.where({ rate_id: id, product_type_id: (0, typeorm_1.Not)((0, typeorm_1.In)(productTypeIds)) })
|
|
303
|
+
.execute()];
|
|
304
|
+
case 2:
|
|
305
|
+
_a.sent();
|
|
306
|
+
_a.label = 3;
|
|
307
|
+
case 3: return [4 /*yield*/, this.manager
|
|
308
|
+
.createQueryBuilder(product_type_tax_rate_1.ProductTypeTaxRate, "ptr")
|
|
309
|
+
.select()
|
|
310
|
+
.where(insertResult.identifiers)
|
|
311
|
+
.getMany()];
|
|
312
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
263
313
|
}
|
|
264
314
|
});
|
|
265
315
|
});
|
|
266
316
|
};
|
|
267
|
-
TaxRateRepository.prototype.
|
|
317
|
+
TaxRateRepository.prototype.removeFromShippingOption = function (id, optionIds) {
|
|
318
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
319
|
+
return __generator(this, function (_a) {
|
|
320
|
+
switch (_a.label) {
|
|
321
|
+
case 0: return [4 /*yield*/, this.createQueryBuilder()
|
|
322
|
+
.delete()
|
|
323
|
+
.from(shipping_tax_rate_1.ShippingTaxRate)
|
|
324
|
+
.where({ rate_id: id, shipping_option_id: (0, typeorm_1.In)(optionIds) })
|
|
325
|
+
.execute()];
|
|
326
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
TaxRateRepository.prototype.addToShippingOption = function (id, optionIds, overrideExisting) {
|
|
332
|
+
if (overrideExisting === void 0) { overrideExisting = false; }
|
|
268
333
|
return __awaiter(this, void 0, void 0, function () {
|
|
269
334
|
var toInsert, insertResult;
|
|
270
335
|
return __generator(this, function (_a) {
|
|
@@ -276,17 +341,27 @@ var TaxRateRepository = /** @class */ (function (_super) {
|
|
|
276
341
|
}); });
|
|
277
342
|
return [4 /*yield*/, this.createQueryBuilder()
|
|
278
343
|
.insert()
|
|
344
|
+
.orIgnore(true)
|
|
279
345
|
.into(shipping_tax_rate_1.ShippingTaxRate)
|
|
280
346
|
.values(toInsert)
|
|
281
347
|
.execute()];
|
|
282
348
|
case 1:
|
|
283
349
|
insertResult = _a.sent();
|
|
284
|
-
return [
|
|
285
|
-
|
|
286
|
-
.
|
|
287
|
-
.
|
|
288
|
-
.
|
|
289
|
-
|
|
350
|
+
if (!overrideExisting) return [3 /*break*/, 3];
|
|
351
|
+
return [4 /*yield*/, this.createQueryBuilder()
|
|
352
|
+
.delete()
|
|
353
|
+
.from(shipping_tax_rate_1.ShippingTaxRate)
|
|
354
|
+
.where({ rate_id: id, shipping_option_id: (0, typeorm_1.Not)((0, typeorm_1.In)(optionIds)) })
|
|
355
|
+
.execute()];
|
|
356
|
+
case 2:
|
|
357
|
+
_a.sent();
|
|
358
|
+
_a.label = 3;
|
|
359
|
+
case 3: return [4 /*yield*/, this.manager
|
|
360
|
+
.createQueryBuilder(shipping_tax_rate_1.ShippingTaxRate, "str")
|
|
361
|
+
.select()
|
|
362
|
+
.where(insertResult.identifiers)
|
|
363
|
+
.getMany()];
|
|
364
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
290
365
|
}
|
|
291
366
|
});
|
|
292
367
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tax-rate.js","sourceRoot":"","sources":["../../src/repositories/tax-rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"tax-rate.js","sourceRoot":"","sources":["../../src/repositories/tax-rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAChC,mCASgB;AAChB,+CAA4C;AAC5C,+DAA2D;AAC3D,yEAAoE;AACpE,iEAA6D;AAC7D,6CAA2C;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CACP,gCAAc,EACd,IAAI,EACJ,gDAAgD,CACjD;6BACA,KAAK,CAAC,mCAAmC,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAA;wBAE3D,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,WAAW,EAAE;4BAC3C,KAAK,CAAC,QAAQ,CAAC,2BAA2B,EAAE;gCAC1C,QAAQ,EAAE,MAAM,CAAC,SAAS;6BAC3B,CAAC,CAAA;yBACH;wBACM,qBAAM,KAAK,CAAC,OAAO,EAAE,EAAA;4BAA5B,sBAAO,SAAqB,EAAA;;;;KAC7B;IAtPU,iBAAiB;QAD7B,IAAA,0BAAgB,EAAC,kBAAO,CAAC;OACb,iBAAiB,CAuP7B;IAAD,wBAAC;CAAA,AAvPD,CAAuC,oBAAU,GAuPhD;AAvPY,8CAAiB"}
|
package/dist/services/cart.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ import LineItemService from "./line-item";
|
|
|
20
20
|
import PaymentProviderService from "./payment-provider";
|
|
21
21
|
import ShippingOptionService from "./shipping-option";
|
|
22
22
|
import CustomerService from "./customer";
|
|
23
|
+
import TaxProviderService from "./tax-provider";
|
|
23
24
|
import DiscountService from "./discount";
|
|
24
25
|
import GiftCardService from "./gift-card";
|
|
25
26
|
import TotalsService from "./totals";
|
|
@@ -32,6 +33,7 @@ declare type CartConstructorProps = {
|
|
|
32
33
|
addressRepository: typeof AddressRepository;
|
|
33
34
|
paymentSessionRepository: typeof PaymentSessionRepository;
|
|
34
35
|
eventBusService: EventBusService;
|
|
36
|
+
taxProviderService: TaxProviderService;
|
|
35
37
|
paymentProviderService: PaymentProviderService;
|
|
36
38
|
productService: ProductService;
|
|
37
39
|
productVariantService: ProductVariantService;
|
|
@@ -45,6 +47,9 @@ declare type CartConstructorProps = {
|
|
|
45
47
|
inventoryService: InventoryService;
|
|
46
48
|
customShippingOptionService: CustomShippingOptionService;
|
|
47
49
|
};
|
|
50
|
+
declare type TotalsConfig = {
|
|
51
|
+
force_taxes?: boolean;
|
|
52
|
+
};
|
|
48
53
|
declare class CartService extends BaseService {
|
|
49
54
|
static Events: {
|
|
50
55
|
CUSTOMER_UPDATED: string;
|
|
@@ -64,83 +69,67 @@ declare class CartService extends BaseService {
|
|
|
64
69
|
private shippingOptionService_;
|
|
65
70
|
private discountService_;
|
|
66
71
|
private giftCardService_;
|
|
72
|
+
private taxProviderService_;
|
|
67
73
|
private totalsService_;
|
|
68
74
|
private addressRepository_;
|
|
69
75
|
private paymentSessionRepository_;
|
|
70
76
|
private inventoryService_;
|
|
71
77
|
private customShippingOptionService_;
|
|
72
|
-
constructor({ manager, cartRepository, shippingMethodRepository, eventBusService, paymentProviderService, productService, productVariantService, regionService, lineItemService, shippingOptionService, customerService, discountService, giftCardService, totalsService, addressRepository, paymentSessionRepository, inventoryService, customShippingOptionService, }: CartConstructorProps);
|
|
78
|
+
constructor({ manager, cartRepository, shippingMethodRepository, eventBusService, paymentProviderService, productService, productVariantService, taxProviderService, regionService, lineItemService, shippingOptionService, customerService, discountService, giftCardService, totalsService, addressRepository, paymentSessionRepository, inventoryService, customShippingOptionService, }: CartConstructorProps);
|
|
73
79
|
withTransaction(transactionManager: EntityManager): CartService;
|
|
74
|
-
/**
|
|
75
|
-
* Used to validate cart ids. Throws an error if the cast fails
|
|
76
|
-
* @param {string} rawId - the raw cart id to validate.
|
|
77
|
-
* @return {string} the validated id
|
|
78
|
-
*/
|
|
79
|
-
/**
|
|
80
|
-
* Contents of a line item
|
|
81
|
-
* @typedef {(object | array)} LineItemContent
|
|
82
|
-
* @property {number} unit_price - the price of the content
|
|
83
|
-
* @property {object} variant - the product variant of the content
|
|
84
|
-
* @property {object} product - the product of the content
|
|
85
|
-
* @property {number} quantity - the quantity of the content
|
|
86
|
-
*/
|
|
87
|
-
/**
|
|
88
|
-
* A collection of contents grouped in the same line item
|
|
89
|
-
* @typedef {LineItemContent[]} LineItemContentArray
|
|
90
|
-
*/
|
|
91
80
|
transformQueryForTotals_(config: FindConfig<Cart>): FindConfig<Cart> & {
|
|
92
81
|
totalsToSelect: TotalField[];
|
|
93
82
|
};
|
|
94
|
-
decorateTotals_(cart: Cart, totalsToSelect: TotalField[]): Promise<Cart>;
|
|
83
|
+
decorateTotals_(cart: Cart, totalsToSelect: TotalField[], options?: TotalsConfig): Promise<Cart>;
|
|
95
84
|
/**
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @return
|
|
85
|
+
* @param selector - the query object for find
|
|
86
|
+
* @param config - config object
|
|
87
|
+
* @return the result of the find operation
|
|
99
88
|
*/
|
|
100
89
|
list(selector: FilterableCartProps, config?: FindConfig<Cart>): Promise<Cart[]>;
|
|
101
90
|
/**
|
|
102
91
|
* Gets a cart by id.
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @
|
|
92
|
+
* @param cartId - the id of the cart to get.
|
|
93
|
+
* @param options - the options to get a cart
|
|
94
|
+
* @param totalsConfig - configuration for retrieval of totals
|
|
95
|
+
* @return the cart document.
|
|
106
96
|
*/
|
|
107
|
-
retrieve(cartId: string, options?: FindConfig<Cart
|
|
97
|
+
retrieve(cartId: string, options?: FindConfig<Cart>, totalsConfig?: TotalsConfig): Promise<Cart>;
|
|
108
98
|
/**
|
|
109
99
|
* Creates a cart.
|
|
110
|
-
* @param
|
|
111
|
-
* @return
|
|
100
|
+
* @param data - the data to create the cart with
|
|
101
|
+
* @return the result of the create operation
|
|
112
102
|
*/
|
|
113
103
|
create(data: CartCreateProps): Promise<Cart>;
|
|
114
104
|
/**
|
|
115
105
|
* Removes a line item from the cart.
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @return
|
|
106
|
+
* @param cartId - the id of the cart that we will remove from
|
|
107
|
+
* @param lineItemId - the line item to remove.
|
|
108
|
+
* @return the result of the update operation
|
|
119
109
|
*/
|
|
120
110
|
removeLineItem(cartId: string, lineItemId: string): Promise<Cart>;
|
|
121
111
|
/**
|
|
122
112
|
* Checks if a given line item has a shipping method that can fulfill it.
|
|
123
113
|
* Returns true if all products in the cart can be fulfilled with the current
|
|
124
114
|
* shipping methods.
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @return
|
|
115
|
+
* @param shippingMethods - the set of shipping methods to check from
|
|
116
|
+
* @param lineItem - the line item
|
|
117
|
+
* @return boolean representing wheter shipping method is validated
|
|
128
118
|
*/
|
|
129
119
|
validateLineItemShipping_(shippingMethods: ShippingMethod[], lineItem: LineItem): boolean;
|
|
130
120
|
/**
|
|
131
121
|
* Adds a line item to the cart.
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @return
|
|
122
|
+
* @param cartId - the id of the cart that we will add to
|
|
123
|
+
* @param lineItem - the line item to add.
|
|
124
|
+
* @return the result of the update operation
|
|
135
125
|
*/
|
|
136
126
|
addLineItem(cartId: string, lineItem: LineItem): Promise<Cart>;
|
|
137
127
|
/**
|
|
138
128
|
* Updates a cart's existing line item.
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
142
|
-
*
|
|
143
|
-
* @return {Promise} the result of the update operation
|
|
129
|
+
* @param cartId - the id of the cart to update
|
|
130
|
+
* @param lineItemId - the id of the line item to update.
|
|
131
|
+
* @param lineItemUpdate - the line item to update. Must include an id field.
|
|
132
|
+
* @return the result of the update operation
|
|
144
133
|
*/
|
|
145
134
|
updateLineItem(cartId: string, lineItemId: string, lineItemUpdate: LineItemUpdate): Promise<Cart>;
|
|
146
135
|
/**
|
|
@@ -148,42 +137,39 @@ declare class CartService extends BaseService {
|
|
|
148
137
|
* shipping discount
|
|
149
138
|
* If a free shipping is present, we set shipping methods price to 0
|
|
150
139
|
* if a free shipping was present, we set shipping methods to original amount
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
140
|
+
* @param cart - the the cart to adjust free shipping for
|
|
141
|
+
* @param shouldAdd - flag to indicate, if we should add or remove
|
|
142
|
+
* @return void
|
|
153
143
|
*/
|
|
154
144
|
adjustFreeShipping_(cart: Cart, shouldAdd: boolean): Promise<void>;
|
|
155
145
|
update(cartId: string, update: CartUpdateProps): Promise<Cart>;
|
|
156
146
|
/**
|
|
157
147
|
* Sets the customer id of a cart
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
* @return
|
|
148
|
+
* @param cart - the cart to add email to
|
|
149
|
+
* @param customerId - the customer to add to cart
|
|
150
|
+
* @return the result of the update operation
|
|
161
151
|
*/
|
|
162
152
|
updateCustomerId_(cart: Cart, customerId: string): Promise<void>;
|
|
163
153
|
/**
|
|
164
154
|
* Creates or fetches a user based on an email.
|
|
165
|
-
* @param
|
|
166
|
-
* @return
|
|
155
|
+
* @param email - the email to use
|
|
156
|
+
* @return the resultign customer object
|
|
167
157
|
*/
|
|
168
158
|
createOrFetchUserFromEmail_(email: string): Promise<Customer>;
|
|
169
159
|
/**
|
|
170
160
|
* Updates the cart's billing address.
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* address
|
|
174
|
-
* @
|
|
175
|
-
* updates
|
|
176
|
-
* @return {Promise} the result of the update operation
|
|
161
|
+
* @param cart - the cart to update
|
|
162
|
+
* @param addressOrId - the value to set the billing address to
|
|
163
|
+
* @param addrRepo - the repository to use for address updates
|
|
164
|
+
* @return the result of the update operation
|
|
177
165
|
*/
|
|
178
166
|
updateBillingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
179
167
|
/**
|
|
180
168
|
* Updates the cart's shipping address.
|
|
181
|
-
* @param
|
|
182
|
-
* @param
|
|
183
|
-
* address
|
|
184
|
-
* @
|
|
185
|
-
* updates
|
|
186
|
-
* @return {Promise} the result of the update operation
|
|
169
|
+
* @param cart - the cart to update
|
|
170
|
+
* @param addressOrId - the value to set the shipping address to
|
|
171
|
+
* @param addrRepo - the repository to use for address updates
|
|
172
|
+
* @return the result of the update operation
|
|
187
173
|
*/
|
|
188
174
|
updateShippingAddress_(cart: Cart, addressOrId: Partial<Address> | string, addrRepo: AddressRepository): Promise<void>;
|
|
189
175
|
applyGiftCard_(cart: Cart, code: string): Promise<void>;
|
|
@@ -192,30 +178,23 @@ declare class CartService extends BaseService {
|
|
|
192
178
|
* If discount besides free shipping is already applied, this
|
|
193
179
|
* will be overwritten
|
|
194
180
|
* Throws if discount regions does not include the cart region
|
|
195
|
-
* @param
|
|
196
|
-
* @param
|
|
197
|
-
* @return
|
|
181
|
+
* @param cart - the cart to update
|
|
182
|
+
* @param discountCode - the discount code
|
|
183
|
+
* @return the result of the update operation
|
|
198
184
|
*/
|
|
199
185
|
applyDiscount(cart: Cart, discountCode: string): Promise<void>;
|
|
200
186
|
/**
|
|
201
187
|
* Removes a discount based on a discount code.
|
|
202
|
-
* @param
|
|
203
|
-
* @param
|
|
204
|
-
* @return
|
|
188
|
+
* @param cartId - the id of the cart to remove from
|
|
189
|
+
* @param discountCode - the discount code to remove
|
|
190
|
+
* @return the resulting cart
|
|
205
191
|
*/
|
|
206
192
|
removeDiscount(cartId: string, discountCode: string): Promise<Cart>;
|
|
207
|
-
/**
|
|
208
|
-
* A payment method represents a way for the customer to pay. The payment
|
|
209
|
-
* method will typically come from one of the payment sessions.
|
|
210
|
-
* @typedef {object} PaymentMethod
|
|
211
|
-
* @property {string} provider_id - the identifier of the payment method's
|
|
212
|
-
* provider
|
|
213
|
-
* @property {object} data - the data associated with the payment method
|
|
214
|
-
*/
|
|
215
193
|
/**
|
|
216
194
|
* Updates the currently selected payment session.
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
195
|
+
* @param cartId - the id of the cart to update the payment session for
|
|
196
|
+
* @param update - the data to update the payment session with
|
|
197
|
+
* @return the resulting cart
|
|
219
198
|
*/
|
|
220
199
|
updatePaymentSession(cartId: string, update: object): Promise<Cart>;
|
|
221
200
|
/**
|
|
@@ -224,18 +203,18 @@ declare class CartService extends BaseService {
|
|
|
224
203
|
* a payment object, that we will use to update our cart payment with.
|
|
225
204
|
* Additionally, if the payment does not require more or fails, we will
|
|
226
205
|
* set the payment on the cart.
|
|
227
|
-
* @param
|
|
228
|
-
* @param
|
|
206
|
+
* @param cartId - the id of the cart to authorize payment for
|
|
207
|
+
* @param context - object containing whatever is relevant for
|
|
229
208
|
* authorizing the payment with the payment provider. As an example,
|
|
230
209
|
* this could be IP address or similar for fraud handling.
|
|
231
|
-
* @return
|
|
210
|
+
* @return the resulting cart
|
|
232
211
|
*/
|
|
233
|
-
authorizePayment(cartId: string, context?:
|
|
212
|
+
authorizePayment(cartId: string, context?: Record<string, any>): Promise<Cart>;
|
|
234
213
|
/**
|
|
235
214
|
* Sets a payment method for a cart.
|
|
236
|
-
* @param
|
|
237
|
-
* @param
|
|
238
|
-
* @return
|
|
215
|
+
* @param cartId - the id of the cart to add payment method to
|
|
216
|
+
* @param providerId - the id of the provider to be set to the cart
|
|
217
|
+
* @return result of update operation
|
|
239
218
|
*/
|
|
240
219
|
setPaymentSession(cartId: string, providerId: string): Promise<Cart>;
|
|
241
220
|
/**
|
|
@@ -244,23 +223,22 @@ declare class CartService extends BaseService {
|
|
|
244
223
|
* provider. Additional calls will ensure that payment sessions have correct
|
|
245
224
|
* amounts, currencies, etc. as well as make sure to filter payment sessions
|
|
246
225
|
* that are not available for the cart's region.
|
|
247
|
-
* @param
|
|
248
|
-
*
|
|
249
|
-
* @return {Promise} the result of the update operation.
|
|
226
|
+
* @param cartOrCartId - the id of the cart to set payment session for
|
|
227
|
+
* @return the result of the update operation.
|
|
250
228
|
*/
|
|
251
229
|
setPaymentSessions(cartOrCartId: Cart | string): Promise<Cart>;
|
|
252
230
|
/**
|
|
253
231
|
* Removes a payment session from the cart.
|
|
254
|
-
* @param
|
|
255
|
-
* @param
|
|
232
|
+
* @param cartId - the id of the cart to remove from
|
|
233
|
+
* @param providerId - the id of the provider whoose payment session
|
|
256
234
|
* should be removed.
|
|
257
|
-
* @return
|
|
235
|
+
* @return the resulting cart.
|
|
258
236
|
*/
|
|
259
237
|
deletePaymentSession(cartId: string, providerId: string): Promise<Cart>;
|
|
260
238
|
/**
|
|
261
239
|
* Refreshes a payment session on a cart
|
|
262
|
-
* @param
|
|
263
|
-
* @param
|
|
240
|
+
* @param cartId - the id of the cart to remove from
|
|
241
|
+
* @param providerId - the id of the provider whoose payment session
|
|
264
242
|
* should be removed.
|
|
265
243
|
* @return {Promise<Cart>} the resulting cart.
|
|
266
244
|
*/
|
|
@@ -271,50 +249,50 @@ declare class CartService extends BaseService {
|
|
|
271
249
|
* Shipping Option is a possible way to ship an order. Shipping Methods may
|
|
272
250
|
* also have additional details in the data field such as an id for a package
|
|
273
251
|
* shop.
|
|
274
|
-
* @param
|
|
275
|
-
* @param
|
|
276
|
-
* @param
|
|
277
|
-
* @return
|
|
252
|
+
* @param cartId - the id of the cart to add shipping method to
|
|
253
|
+
* @param optionId - id of shipping option to add as valid method
|
|
254
|
+
* @param data - the fulmillment data for the method
|
|
255
|
+
* @return the result of the update operation
|
|
278
256
|
*/
|
|
279
|
-
addShippingMethod(cartId: string, optionId: string, data?:
|
|
257
|
+
addShippingMethod(cartId: string, optionId: string, data?: Record<string, any>): Promise<Cart>;
|
|
280
258
|
/**
|
|
281
259
|
* Finds the cart's custom shipping options based on the passed option id.
|
|
282
260
|
* throws if custom options is not empty and no shipping option corresponds to optionId
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
285
|
-
* @return
|
|
261
|
+
* @param cartCustomShippingOptions - the cart's custom shipping options
|
|
262
|
+
* @param optionId - id of the normal or custom shipping option to find in the cartCustomShippingOptions
|
|
263
|
+
* @return custom shipping option
|
|
286
264
|
*/
|
|
287
265
|
findCustomShippingOption(cartCustomShippingOptions: CustomShippingOption[], optionId: string): CustomShippingOption | undefined;
|
|
288
266
|
/**
|
|
289
267
|
* Set's the region of a cart.
|
|
290
|
-
* @param
|
|
291
|
-
* @param
|
|
292
|
-
* @param
|
|
293
|
-
* @return
|
|
268
|
+
* @param cart - the cart to set region on
|
|
269
|
+
* @param regionId - the id of the region to set the region to
|
|
270
|
+
* @param countryCode - the country code to set the country to
|
|
271
|
+
* @return the result of the update operation
|
|
294
272
|
*/
|
|
295
273
|
setRegion_(cart: Cart, regionId: string, countryCode: string | null): Promise<void>;
|
|
296
274
|
/**
|
|
297
275
|
* Deletes a cart from the database. Completed carts cannot be deleted.
|
|
298
|
-
* @param
|
|
299
|
-
* @return
|
|
300
|
-
* not found.
|
|
276
|
+
* @param cartId - the id of the cart to delete
|
|
277
|
+
* @return the deleted cart or undefined if the cart was not found.
|
|
301
278
|
*/
|
|
302
279
|
delete(cartId: string): Promise<string>;
|
|
303
280
|
/**
|
|
304
281
|
* Dedicated method to set metadata for a cart.
|
|
305
282
|
* To ensure that plugins does not overwrite each
|
|
306
283
|
* others metadata fields, setMetadata is provided.
|
|
307
|
-
* @param
|
|
308
|
-
* @param
|
|
309
|
-
* @param
|
|
310
|
-
* @return
|
|
284
|
+
* @param cartId - the cart to apply metadata to.
|
|
285
|
+
* @param key - key for metadata field
|
|
286
|
+
* @param value - value for metadata field.
|
|
287
|
+
* @return resolves to the updated result.
|
|
311
288
|
*/
|
|
312
289
|
setMetadata(cartId: string, key: string, value: string | number): Promise<Cart>;
|
|
290
|
+
createTaxLines(id: string): Promise<Cart>;
|
|
313
291
|
/**
|
|
314
292
|
* Dedicated method to delete metadata for a cart.
|
|
315
|
-
* @param
|
|
316
|
-
* @param
|
|
317
|
-
* @return
|
|
293
|
+
* @param cartId - the cart to delete metadata from.
|
|
294
|
+
* @param key - key for metadata field
|
|
295
|
+
* @return resolves to the updated result.
|
|
318
296
|
*/
|
|
319
297
|
deleteMetadata(cartId: string, key: string): Promise<Cart>;
|
|
320
298
|
}
|