@medusajs/medusa 1.1.62 → 1.1.63-adminc.21
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/collections/list-collections.d.ts +16 -3
- package/dist/api/routes/admin/collections/list-collections.js +88 -10
- package/dist/api/routes/admin/collections/list-collections.js.map +1 -1
- package/dist/api/routes/admin/discounts/list-discounts.d.ts +6 -0
- package/dist/api/routes/admin/discounts/list-discounts.js +45 -8
- package/dist/api/routes/admin/discounts/list-discounts.js.map +1 -1
- package/dist/api/routes/admin/orders/list-orders.js +1 -1
- package/dist/api/routes/admin/orders/list-orders.js.map +1 -1
- package/dist/api/routes/admin/products/list-products.js +1 -2
- package/dist/api/routes/admin/products/list-products.js.map +1 -1
- package/dist/api/routes/admin/tax-rates/add-to-product-types.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/add-to-product-types.js +177 -0
- package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/add-to-products.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/add-to-products.js +173 -0
- package/dist/api/routes/admin/tax-rates/add-to-products.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.d.ts +29 -0
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +177 -0
- package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/create-tax-rate.d.ts +35 -0
- package/dist/api/routes/admin/tax-rates/create-tax-rate.js +286 -0
- package/dist/api/routes/admin/tax-rates/create-tax-rate.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/delete-tax-rate.d.ts +28 -0
- package/dist/api/routes/admin/tax-rates/delete-tax-rate.js +84 -0
- package/dist/api/routes/admin/tax-rates/delete-tax-rate.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/get-tax-rate.d.ts +26 -0
- package/dist/api/routes/admin/tax-rates/get-tax-rate.js +106 -0
- package/dist/api/routes/admin/tax-rates/get-tax-rate.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/index.d.ts +21 -0
- package/dist/api/routes/admin/tax-rates/index.js +74 -0
- package/dist/api/routes/admin/tax-rates/index.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/list-tax-rates.d.ts +44 -0
- package/dist/api/routes/admin/tax-rates/list-tax-rates.js +178 -0
- package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/update-tax-rate.d.ts +35 -0
- package/dist/api/routes/admin/tax-rates/update-tax-rate.js +286 -0
- package/dist/api/routes/admin/tax-rates/update-tax-rate.js.map +1 -0
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +7 -0
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +91 -0
- package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +1 -0
- package/dist/api/routes/store/carts/calculate-taxes.d.ts +24 -0
- package/dist/api/routes/store/carts/calculate-taxes.js +153 -0
- package/dist/api/routes/store/carts/calculate-taxes.js.map +1 -0
- package/dist/interfaces/cart-completion-strategy.d.ts +20 -0
- package/dist/interfaces/cart-completion-strategy.js +10 -0
- package/dist/interfaces/cart-completion-strategy.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +16 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/tax-calculation-strategy.d.ts +16 -0
- package/dist/interfaces/tax-calculation-strategy.js +10 -0
- package/dist/interfaces/tax-calculation-strategy.js.map +1 -0
- package/dist/interfaces/tax-service.d.ts +51 -0
- package/dist/interfaces/tax-service.js +3 -0
- package/dist/interfaces/tax-service.js.map +1 -0
- package/dist/loaders/strategies.d.ts +12 -0
- package/dist/loaders/strategies.js +32 -0
- package/dist/loaders/strategies.js.map +1 -0
- package/dist/migrations/1641636508055-new_tax_system.d.ts +6 -0
- package/dist/migrations/1641636508055-new_tax_system.js +248 -0
- package/dist/migrations/1641636508055-new_tax_system.js.map +1 -0
- package/dist/models/discount.js +2 -1
- package/dist/models/discount.js.map +1 -1
- package/dist/models/line-item-tax-line.d.ts +7 -0
- package/dist/models/line-item-tax-line.js +65 -0
- package/dist/models/line-item-tax-line.js.map +1 -0
- package/dist/models/product-tax-rate.d.ts +40 -0
- package/dist/models/product-tax-rate.js +88 -0
- package/dist/models/product-tax-rate.js.map +1 -0
- package/dist/models/product-type-tax-rate.d.ts +40 -0
- package/dist/models/product-type-tax-rate.js +88 -0
- package/dist/models/product-type-tax-rate.js.map +1 -0
- package/dist/models/shipping-method-tax-line.d.ts +7 -0
- package/dist/models/shipping-method-tax-line.js +65 -0
- package/dist/models/shipping-method-tax-line.js.map +1 -0
- package/dist/models/shipping-tax-rate.d.ts +40 -0
- package/dist/models/shipping-tax-rate.js +88 -0
- package/dist/models/shipping-tax-rate.js.map +1 -0
- package/dist/models/tax-line.d.ts +39 -0
- package/dist/models/tax-line.js +79 -0
- package/dist/models/tax-line.js.map +1 -0
- package/dist/models/tax-provider.d.ts +17 -0
- package/dist/models/tax-provider.js +44 -0
- package/dist/models/tax-provider.js.map +1 -0
- package/dist/models/tax-rate.d.ts +58 -0
- package/dist/models/tax-rate.js +159 -0
- package/dist/models/tax-rate.js.map +1 -0
- package/dist/repositories/line-item-tax-line.d.ts +4 -0
- package/dist/repositories/line-item-tax-line.js +38 -0
- package/dist/repositories/line-item-tax-line.js.map +1 -0
- package/dist/repositories/product-tax-rate.d.ts +4 -0
- package/dist/repositories/product-tax-rate.js +38 -0
- package/dist/repositories/product-tax-rate.js.map +1 -0
- package/dist/repositories/shipping-method-tax-line.d.ts +4 -0
- package/dist/repositories/shipping-method-tax-line.js +38 -0
- package/dist/repositories/shipping-method-tax-line.js.map +1 -0
- package/dist/repositories/shipping-tax-rate.d.ts +4 -0
- package/dist/repositories/shipping-tax-rate.js +38 -0
- package/dist/repositories/shipping-tax-rate.js.map +1 -0
- package/dist/repositories/tax-rate.d.ts +18 -0
- package/dist/repositories/tax-rate.js +359 -0
- package/dist/repositories/tax-rate.js.map +1 -0
- package/dist/services/product-tax-rate.d.ts +25 -0
- package/dist/services/product-tax-rate.js +104 -0
- package/dist/services/product-tax-rate.js.map +1 -0
- package/dist/services/product-type.d.ts +27 -0
- package/dist/services/product-type.js +112 -0
- package/dist/services/product-type.js.map +1 -0
- package/dist/services/shipping-tax-rate.d.ts +26 -0
- package/dist/services/shipping-tax-rate.js +105 -0
- package/dist/services/shipping-tax-rate.js.map +1 -0
- package/dist/services/system-tax.d.ts +9 -0
- package/dist/services/system-tax.js +89 -0
- package/dist/services/system-tax.js.map +1 -0
- package/dist/services/tax-provider.d.ts +105 -0
- package/dist/services/tax-provider.js +455 -0
- package/dist/services/tax-provider.js.map +1 -0
- package/dist/services/tax-rate.d.ts +31 -0
- package/dist/services/tax-rate.js +405 -0
- package/dist/services/tax-rate.js.map +1 -0
- package/dist/strategies/cart-completion.d.ts +17 -0
- package/dist/strategies/cart-completion.js +336 -0
- package/dist/strategies/cart-completion.js.map +1 -0
- package/dist/strategies/tax-calculation.d.ts +11 -0
- package/dist/strategies/tax-calculation.js +147 -0
- package/dist/strategies/tax-calculation.js.map +1 -0
- package/dist/types/discount.js.map +1 -1
- package/dist/types/orders.js +1 -1
- package/dist/types/orders.js.map +1 -1
- package/dist/types/product-tax-rate.d.ts +10 -0
- package/dist/types/product-tax-rate.js +13 -0
- package/dist/types/product-tax-rate.js.map +1 -0
- package/dist/types/request.d.ts +3 -0
- package/dist/types/request.js +3 -0
- package/dist/types/request.js.map +1 -0
- package/dist/types/shipping-tax-rate.d.ts +10 -0
- package/dist/types/shipping-tax-rate.js +13 -0
- package/dist/types/shipping-tax-rate.js.map +1 -0
- package/dist/types/tax-rate.d.ts +25 -0
- package/dist/types/tax-rate.js +3 -0
- package/dist/types/tax-rate.js.map +1 -0
- package/dist/types/tax-service.d.ts +34 -0
- package/dist/types/tax-service.js +3 -0
- package/dist/types/tax-service.js.map +1 -0
- package/dist/types/totals.d.ts +42 -0
- package/dist/types/totals.js +3 -0
- package/dist/types/totals.js.map +1 -0
- package/jest.config.js +17 -0
- package/package.json +3 -3
- package/yarn-error.log +79 -5
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
55
|
+
/**
|
|
56
|
+
* Provides layer to manipulate product variants.
|
|
57
|
+
* @extends BaseService
|
|
58
|
+
*/
|
|
59
|
+
var ProductTaxRateService = /** @class */ (function (_super) {
|
|
60
|
+
__extends(ProductTaxRateService, _super);
|
|
61
|
+
function ProductTaxRateService(_a) {
|
|
62
|
+
var manager = _a.manager, productTaxRateRepository = _a.productTaxRateRepository;
|
|
63
|
+
var _this = _super.call(this) || this;
|
|
64
|
+
/** @private @const {EntityManager} */
|
|
65
|
+
_this.manager_ = manager;
|
|
66
|
+
/** @private @const {ProductVariantModel} */
|
|
67
|
+
_this.productTaxRateRepository_ = productTaxRateRepository;
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
ProductTaxRateService.prototype.withTransaction = function (transactionManager) {
|
|
71
|
+
if (!transactionManager) {
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
var cloned = new ProductTaxRateService({
|
|
75
|
+
manager: transactionManager,
|
|
76
|
+
productTaxRateRepository: this.productTaxRateRepository_,
|
|
77
|
+
});
|
|
78
|
+
cloned.transactionManager_ = transactionManager;
|
|
79
|
+
return cloned;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* @param {FilterableProductVariantProps} selector - the query object for find
|
|
83
|
+
* @param {FindConfig<ProductVariant>} config - query config object for variant retrieval
|
|
84
|
+
* @return {Promise} the result of the find operation
|
|
85
|
+
*/
|
|
86
|
+
ProductTaxRateService.prototype.list = function (selector, config) {
|
|
87
|
+
if (config === void 0) { config = { relations: [], skip: 0, take: 20 }; }
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var pTaxRateRepo, query;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
pTaxRateRepo = this.manager_.getCustomRepository(this.productTaxRateRepository_);
|
|
94
|
+
query = this.buildQuery_(selector, config);
|
|
95
|
+
return [4 /*yield*/, pTaxRateRepo.find(query)];
|
|
96
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
return ProductTaxRateService;
|
|
102
|
+
}(medusa_interfaces_1.BaseService));
|
|
103
|
+
exports.default = ProductTaxRateService;
|
|
104
|
+
//# sourceMappingURL=product-tax-rate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-tax-rate.js","sourceRoot":"","sources":["../../src/services/product-tax-rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAO/C;;;GAGG;AACH;IAAoC,yCAAW;IAI7C,+BAAY,EAAqC;YAAnC,OAAO,aAAA,EAAE,wBAAwB,8BAAA;QAA/C,YACE,iBAAO,SAOR;QALC,sCAAsC;QACtC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QAEvB,4CAA4C;QAC5C,KAAI,CAAC,yBAAyB,GAAG,wBAAwB,CAAA;;IAC3D,CAAC;IAED,+CAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC;YACvC,OAAO,EAAE,kBAAkB;YAC3B,wBAAwB,EAAE,IAAI,CAAC,yBAAyB;SACzD,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAE/C,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;OAIG;IACG,oCAAI,GAAV,UACE,QAAuC,EACvC,MAAyE;QAAzE,uBAAA,EAAA,WAAuC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;;;;;;wBAEnE,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CACpD,IAAI,CAAC,yBAAyB,CAC/B,CAAA;wBAEK,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;wBAEzC,qBAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA;4BAArC,sBAAO,SAA8B,EAAA;;;;KACtC;IACH,4BAAC;AAAD,CAAC,AA9CD,CAAoC,+BAAW,GA8C9C;AAED,kBAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseService } from "medusa-interfaces";
|
|
2
|
+
import { EntityManager } from "typeorm";
|
|
3
|
+
import { FindConfig } from "../types/common";
|
|
4
|
+
import { ProductType } from "../models/product-type";
|
|
5
|
+
/**
|
|
6
|
+
* Provides layer to manipulate products.
|
|
7
|
+
* @extends BaseService
|
|
8
|
+
*/
|
|
9
|
+
declare class ProductTypeService extends BaseService {
|
|
10
|
+
private manager_;
|
|
11
|
+
private typeRepository_;
|
|
12
|
+
constructor({ manager, productTypeRepository }: {
|
|
13
|
+
manager: any;
|
|
14
|
+
productTypeRepository: any;
|
|
15
|
+
});
|
|
16
|
+
withTransaction(transactionManager: EntityManager): ProductTypeService;
|
|
17
|
+
/**
|
|
18
|
+
* Gets a product by id.
|
|
19
|
+
* Throws in case of DB Error and if product was not found.
|
|
20
|
+
* @param id - id of the product to get.
|
|
21
|
+
* @param config - object that defines what should be included in the
|
|
22
|
+
* query response
|
|
23
|
+
* @return {Promise<Product>} the result of the find one operation.
|
|
24
|
+
*/
|
|
25
|
+
retrieve(id: string, config?: FindConfig<ProductType>): Promise<ProductType>;
|
|
26
|
+
}
|
|
27
|
+
export default ProductTypeService;
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
55
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
56
|
+
/**
|
|
57
|
+
* Provides layer to manipulate products.
|
|
58
|
+
* @extends BaseService
|
|
59
|
+
*/
|
|
60
|
+
var ProductTypeService = /** @class */ (function (_super) {
|
|
61
|
+
__extends(ProductTypeService, _super);
|
|
62
|
+
function ProductTypeService(_a) {
|
|
63
|
+
var manager = _a.manager, productTypeRepository = _a.productTypeRepository;
|
|
64
|
+
var _this = _super.call(this) || this;
|
|
65
|
+
_this.manager_ = manager;
|
|
66
|
+
_this.typeRepository_ = productTypeRepository;
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
ProductTypeService.prototype.withTransaction = function (transactionManager) {
|
|
70
|
+
if (!transactionManager) {
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
var cloned = new ProductTypeService({
|
|
74
|
+
manager: transactionManager,
|
|
75
|
+
productTypeRepository: this.typeRepository_,
|
|
76
|
+
});
|
|
77
|
+
cloned.transactionManager_ = transactionManager;
|
|
78
|
+
cloned.manager_ = transactionManager;
|
|
79
|
+
return cloned;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Gets a product by id.
|
|
83
|
+
* Throws in case of DB Error and if product was not found.
|
|
84
|
+
* @param id - id of the product to get.
|
|
85
|
+
* @param config - object that defines what should be included in the
|
|
86
|
+
* query response
|
|
87
|
+
* @return {Promise<Product>} the result of the find one operation.
|
|
88
|
+
*/
|
|
89
|
+
ProductTypeService.prototype.retrieve = function (id, config) {
|
|
90
|
+
if (config === void 0) { config = {}; }
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var typeRepo, query, type;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
typeRepo = this.manager_.getCustomRepository(this.typeRepository_);
|
|
97
|
+
query = this.buildQuery_({ id: id }, config);
|
|
98
|
+
return [4 /*yield*/, typeRepo.findOne(query)];
|
|
99
|
+
case 1:
|
|
100
|
+
type = _a.sent();
|
|
101
|
+
if (!type) {
|
|
102
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Product with id: ".concat(id, " was not found"));
|
|
103
|
+
}
|
|
104
|
+
return [2 /*return*/, type];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
return ProductTypeService;
|
|
110
|
+
}(medusa_interfaces_1.BaseService));
|
|
111
|
+
exports.default = ProductTypeService;
|
|
112
|
+
//# sourceMappingURL=product-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-type.js","sourceRoot":"","sources":["../../src/services/product-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,uDAA+C;AAM/C;;;GAGG;AACH;IAAiC,sCAAW;IAG1C,4BAAY,EAAkC;YAAhC,OAAO,aAAA,EAAE,qBAAqB,2BAAA;QAA5C,YACE,iBAAO,SAIR;QAFC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,KAAI,CAAC,eAAe,GAAG,qBAAqB,CAAA;;IAC9C,CAAC;IAED,4CAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC;YACpC,OAAO,EAAE,kBAAkB;YAC3B,qBAAqB,EAAE,IAAI,CAAC,eAAe;SAC5C,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAC/C,MAAM,CAAC,QAAQ,GAAG,kBAAkB,CAAA;QAEpC,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;;;OAOG;IACG,qCAAQ,GAAd,UACE,EAAU,EACV,MAAoC;QAApC,uBAAA,EAAA,WAAoC;;;;;;wBAE9B,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;wBAElE,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAA,EAAE,EAAE,MAAM,CAAC,CAAA;wBACjC,qBAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAA;;wBAApC,IAAI,GAAG,SAA6B;wBAE1C,IAAI,CAAC,IAAI,EAAE;4BACT,MAAM,IAAI,+BAAW,CACnB,+BAAW,CAAC,KAAK,CAAC,SAAS,EAC3B,2BAAoB,EAAE,mBAAgB,CACvC,CAAA;yBACF;wBAED,sBAAO,IAAI,EAAA;;;;KACZ;IACH,yBAAC;AAAD,CAAC,AApDD,CAAiC,+BAAW,GAoD3C;AAED,kBAAe,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseService } from "medusa-interfaces";
|
|
2
|
+
import { EntityManager } from "typeorm";
|
|
3
|
+
import { ShippingTaxRate } from "../models/shipping-tax-rate";
|
|
4
|
+
import { FindConfig } from "../types/common";
|
|
5
|
+
import { FilterableShippingTaxRateProps } from "../types/shipping-tax-rate";
|
|
6
|
+
/**
|
|
7
|
+
* Provides layer to manipulate Shipping variants.
|
|
8
|
+
* @extends BaseService
|
|
9
|
+
*/
|
|
10
|
+
declare class ShippingTaxRateService extends BaseService {
|
|
11
|
+
private manager_;
|
|
12
|
+
private shippingTaxRateRepository_;
|
|
13
|
+
constructor({ manager, shippingTaxRateRepository }: {
|
|
14
|
+
manager: any;
|
|
15
|
+
shippingTaxRateRepository: any;
|
|
16
|
+
});
|
|
17
|
+
withTransaction(transactionManager: EntityManager): ShippingTaxRateService;
|
|
18
|
+
/**
|
|
19
|
+
* Lists Shipping Tax Rates given a certain query.
|
|
20
|
+
* @param selector - the query object for find
|
|
21
|
+
* @param config - query config object for variant retrieval
|
|
22
|
+
* @return the result of the find operation
|
|
23
|
+
*/
|
|
24
|
+
list(selector: FilterableShippingTaxRateProps, config?: FindConfig<ShippingTaxRate>): Promise<ShippingTaxRate[]>;
|
|
25
|
+
}
|
|
26
|
+
export default ShippingTaxRateService;
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
55
|
+
/**
|
|
56
|
+
* Provides layer to manipulate Shipping variants.
|
|
57
|
+
* @extends BaseService
|
|
58
|
+
*/
|
|
59
|
+
var ShippingTaxRateService = /** @class */ (function (_super) {
|
|
60
|
+
__extends(ShippingTaxRateService, _super);
|
|
61
|
+
function ShippingTaxRateService(_a) {
|
|
62
|
+
var manager = _a.manager, shippingTaxRateRepository = _a.shippingTaxRateRepository;
|
|
63
|
+
var _this = _super.call(this) || this;
|
|
64
|
+
/** @private @const {EntityManager} */
|
|
65
|
+
_this.manager_ = manager;
|
|
66
|
+
/** @private @const {ShippingVariantModel} */
|
|
67
|
+
_this.shippingTaxRateRepository_ = shippingTaxRateRepository;
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
ShippingTaxRateService.prototype.withTransaction = function (transactionManager) {
|
|
71
|
+
if (!transactionManager) {
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
var cloned = new ShippingTaxRateService({
|
|
75
|
+
manager: transactionManager,
|
|
76
|
+
shippingTaxRateRepository: this.ShippingTaxRateRepository_,
|
|
77
|
+
});
|
|
78
|
+
cloned.transactionManager_ = transactionManager;
|
|
79
|
+
return cloned;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Lists Shipping Tax Rates given a certain query.
|
|
83
|
+
* @param selector - the query object for find
|
|
84
|
+
* @param config - query config object for variant retrieval
|
|
85
|
+
* @return the result of the find operation
|
|
86
|
+
*/
|
|
87
|
+
ShippingTaxRateService.prototype.list = function (selector, config) {
|
|
88
|
+
if (config === void 0) { config = { relations: [], skip: 0, take: 20 }; }
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var sTaxRateRepo, query;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
sTaxRateRepo = this.manager_.getCustomRepository(this.shippingTaxRateRepository_);
|
|
95
|
+
query = this.buildQuery_(selector, config);
|
|
96
|
+
return [4 /*yield*/, sTaxRateRepo.find(query)];
|
|
97
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return ShippingTaxRateService;
|
|
103
|
+
}(medusa_interfaces_1.BaseService));
|
|
104
|
+
exports.default = ShippingTaxRateService;
|
|
105
|
+
//# sourceMappingURL=shipping-tax-rate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shipping-tax-rate.js","sourceRoot":"","sources":["../../src/services/shipping-tax-rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAO/C;;;GAGG;AACH;IAAqC,0CAAW;IAI9C,gCAAY,EAAsC;YAApC,OAAO,aAAA,EAAE,yBAAyB,+BAAA;QAAhD,YACE,iBAAO,SAOR;QALC,sCAAsC;QACtC,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QAEvB,6CAA6C;QAC7C,KAAI,CAAC,0BAA0B,GAAG,yBAAyB,CAAA;;IAC7D,CAAC;IAED,gDAAe,GAAf,UAAgB,kBAAiC;QAC/C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,IAAI,CAAA;SACZ;QAED,IAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC;YACxC,OAAO,EAAE,kBAAkB;YAC3B,yBAAyB,EAAE,IAAI,CAAC,0BAA0B;SAC3D,CAAC,CAAA;QAEF,MAAM,CAAC,mBAAmB,GAAG,kBAAkB,CAAA;QAE/C,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;;OAKG;IACG,qCAAI,GAAV,UACE,QAAwC,EACxC,MAA0E;QAA1E,uBAAA,EAAA,WAAwC,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;;;;;;wBAEpE,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CACpD,IAAI,CAAC,0BAA0B,CAChC,CAAA;wBAEK,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;wBAEzC,qBAAM,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA;4BAArC,sBAAO,SAA8B,EAAA;;;;KACtC;IACH,6BAAC;AAAD,CAAC,AA/CD,CAAqC,+BAAW,GA+C/C;AAED,kBAAe,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseService } from "medusa-interfaces";
|
|
2
|
+
import { ITaxService, ItemTaxCalculationLine, ShippingTaxCalculationLine, TaxCalculationContext } from "../interfaces/tax-service";
|
|
3
|
+
import { ProviderTaxLine } from "../types/tax-service";
|
|
4
|
+
declare class SystemTaxService extends BaseService implements ITaxService {
|
|
5
|
+
static identifier: string;
|
|
6
|
+
constructor();
|
|
7
|
+
getTaxLines(itemLines: ItemTaxCalculationLine[], shippingLines: ShippingTaxCalculationLine[], context: TaxCalculationContext): Promise<ProviderTaxLine[]>;
|
|
8
|
+
}
|
|
9
|
+
export default SystemTaxService;
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var medusa_interfaces_1 = require("medusa-interfaces");
|
|
55
|
+
var SystemTaxService = /** @class */ (function (_super) {
|
|
56
|
+
__extends(SystemTaxService, _super);
|
|
57
|
+
function SystemTaxService() {
|
|
58
|
+
return _super.call(this) || this;
|
|
59
|
+
}
|
|
60
|
+
SystemTaxService.prototype.getTaxLines = function (itemLines, shippingLines, context // eslint-disable-line
|
|
61
|
+
) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var taxLines;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
taxLines = itemLines.flatMap(function (l) {
|
|
66
|
+
return l.rates.map(function (r) { return ({
|
|
67
|
+
rate: r.rate || 0,
|
|
68
|
+
name: r.name,
|
|
69
|
+
code: r.code,
|
|
70
|
+
item_id: l.item.id,
|
|
71
|
+
}); });
|
|
72
|
+
});
|
|
73
|
+
taxLines = taxLines.concat(shippingLines.flatMap(function (l) {
|
|
74
|
+
return l.rates.map(function (r) { return ({
|
|
75
|
+
rate: r.rate || 0,
|
|
76
|
+
name: r.name,
|
|
77
|
+
code: r.code,
|
|
78
|
+
shipping_method_id: l.shipping_method.id,
|
|
79
|
+
}); });
|
|
80
|
+
}));
|
|
81
|
+
return [2 /*return*/, taxLines];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
SystemTaxService.identifier = "system";
|
|
86
|
+
return SystemTaxService;
|
|
87
|
+
}(medusa_interfaces_1.BaseService));
|
|
88
|
+
exports.default = SystemTaxService;
|
|
89
|
+
//# sourceMappingURL=system-tax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-tax.js","sourceRoot":"","sources":["../../src/services/system-tax.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAU/C;IAA+B,oCAAW;IAGxC;eACE,iBAAO;IACT,CAAC;IAEK,sCAAW,GAAjB,UACE,SAAmC,EACnC,aAA2C,EAC3C,OAA8B,CAAC,sBAAsB;;;;;gBAEjD,QAAQ,GAAsB,SAAS,CAAC,OAAO,CAAC,UAAC,CAAC;oBACpD,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC;wBACzB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;wBACjB,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE;qBACnB,CAAC,EALwB,CAKxB,CAAC,CAAA;gBACL,CAAC,CAAC,CAAA;gBAEF,QAAQ,GAAG,QAAQ,CAAC,MAAM,CACxB,aAAa,CAAC,OAAO,CAAC,UAAC,CAAC;oBACtB,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC;wBACzB,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;wBACjB,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;wBACZ,kBAAkB,EAAE,CAAC,CAAC,eAAe,CAAC,EAAE;qBACzC,CAAC,EALwB,CAKxB,CAAC,CAAA;gBACL,CAAC,CAAC,CACH,CAAA;gBAED,sBAAO,QAAQ,EAAA;;;KAChB;IAhCM,2BAAU,GAAG,QAAQ,CAAA;IAiC9B,uBAAC;CAAA,AAlCD,CAA+B,+BAAW,GAkCzC;AAED,kBAAe,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { AwilixContainer } from "awilix";
|
|
2
|
+
import { BaseService } from "medusa-interfaces";
|
|
3
|
+
import { EntityManager } from "typeorm";
|
|
4
|
+
import { LineItemTaxLine } from "../models/line-item-tax-line";
|
|
5
|
+
import { LineItem } from "../models/line-item";
|
|
6
|
+
import { ShippingMethodTaxLine } from "../models/shipping-method-tax-line";
|
|
7
|
+
import { ShippingMethod } from "../models/shipping-method";
|
|
8
|
+
import { Region } from "../models/region";
|
|
9
|
+
import { Cart } from "../models/cart";
|
|
10
|
+
import { ITaxService, TaxCalculationContext } from "../interfaces/tax-service";
|
|
11
|
+
import { TaxServiceRate } from "../types/tax-service";
|
|
12
|
+
/**
|
|
13
|
+
* Finds tax providers and assists in tax related operations.
|
|
14
|
+
*/
|
|
15
|
+
declare class TaxProviderService extends BaseService {
|
|
16
|
+
private container_;
|
|
17
|
+
private manager_;
|
|
18
|
+
private transactionManager_;
|
|
19
|
+
private taxRateService_;
|
|
20
|
+
private taxLineRepo_;
|
|
21
|
+
private smTaxLineRepo_;
|
|
22
|
+
private redis_;
|
|
23
|
+
constructor(container: AwilixContainer);
|
|
24
|
+
withTransaction(transactionManager: EntityManager): TaxProviderService;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the relevant tax provider for the given region.
|
|
27
|
+
* @param region - the region to get tax provider for.
|
|
28
|
+
* @return the region specific tax provider
|
|
29
|
+
*/
|
|
30
|
+
retrieveProvider(region: Region): ITaxService;
|
|
31
|
+
/**
|
|
32
|
+
* Persists the tax lines relevant for an order to the database.
|
|
33
|
+
* @param cartOrLineItems - the cart or line items to create tax lines for
|
|
34
|
+
* @param calculationContext - the calculation context to get tax lines by
|
|
35
|
+
* @return the newly created tax lines
|
|
36
|
+
*/
|
|
37
|
+
createTaxLines(cartOrLineItems: Cart | LineItem[], calculationContext: TaxCalculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Persists the tax lines relevant for a shipping method to the database. Used
|
|
40
|
+
* for return shipping methods.
|
|
41
|
+
* @param shippingMethod - the shipping method to create tax lines for
|
|
42
|
+
* @param calculationContext - the calculation context to get tax lines by
|
|
43
|
+
* @return the newly created tax lines
|
|
44
|
+
*/
|
|
45
|
+
createShippingTaxLines(shippingMethod: ShippingMethod, calculationContext: TaxCalculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the relevant tax lines for a shipping method. Note: this method
|
|
48
|
+
* doesn't persist the tax lines. Use createShippingTaxLines if you wish to
|
|
49
|
+
* persist the tax lines to the DB layer.
|
|
50
|
+
* @param shippingMethod - the shipping method to get tax lines for
|
|
51
|
+
* @param calculationContext - the calculation context to get tax lines by
|
|
52
|
+
* @return the computed tax lines
|
|
53
|
+
*/
|
|
54
|
+
getShippingTaxLines(shippingMethod: ShippingMethod, calculationContext: TaxCalculationContext): Promise<ShippingMethodTaxLine[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the relevant tax lines for an order or cart. If an order is provided
|
|
57
|
+
* the order's tax lines will be returned. If a cart is provided the tax lines
|
|
58
|
+
* will be computed from the tax rules and potentially a 3rd party tax plugin.
|
|
59
|
+
* Note: this method doesn't persist the tax lines. Use createTaxLines if you
|
|
60
|
+
* wish to persist the tax lines to the DB layer.
|
|
61
|
+
* @param lineItems - the cart or order to get tax lines for
|
|
62
|
+
* @param calculationContext - the calculation context to get tax lines by
|
|
63
|
+
* @return the computed tax lines
|
|
64
|
+
*/
|
|
65
|
+
getTaxLines(lineItems: LineItem[], calculationContext: TaxCalculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the tax rates configured for a shipping option. The rates are cached
|
|
68
|
+
* between calls.
|
|
69
|
+
* @param optionId - the option id of the shipping method.
|
|
70
|
+
* @param region - the region to get configured rates for.
|
|
71
|
+
* @return the tax rates configured for the shipping option.
|
|
72
|
+
*/
|
|
73
|
+
getRegionRatesForShipping(optionId: string, region: Region): Promise<TaxServiceRate[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the tax rates configured for a product. The rates are cached between
|
|
76
|
+
* calls.
|
|
77
|
+
* @param productId - the product id to get rates for
|
|
78
|
+
* @param region - the region to get configured rates for.
|
|
79
|
+
* @return the tax rates configured for the shipping option.
|
|
80
|
+
*/
|
|
81
|
+
getRegionRatesForProduct(productId: string, region: Region): Promise<TaxServiceRate[]>;
|
|
82
|
+
/**
|
|
83
|
+
* The cache key to get cache hits by.
|
|
84
|
+
* @param productId - the product id to cache
|
|
85
|
+
* @param regionId - the region id to cache
|
|
86
|
+
* @return the cache key to use for the id set
|
|
87
|
+
*/
|
|
88
|
+
private getCacheKey;
|
|
89
|
+
/**
|
|
90
|
+
* Sets the cache results for a set of ids
|
|
91
|
+
* @param productId - the product id to cache
|
|
92
|
+
* @param regionId - the region id to cache
|
|
93
|
+
* @param value - tax rates to cache
|
|
94
|
+
* @return promise that resolves after the cache has been set
|
|
95
|
+
*/
|
|
96
|
+
private setCache;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the cache results for a set of ids
|
|
99
|
+
* @param productId - the product id to cache
|
|
100
|
+
* @param regionId - the region id to cache
|
|
101
|
+
* @return the cached result or null
|
|
102
|
+
*/
|
|
103
|
+
private getCacheEntry;
|
|
104
|
+
}
|
|
105
|
+
export default TaxProviderService;
|