@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,29 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [post] /tax-rates/:id/products
|
|
4
|
+
* operationId: "PostTaxRatesTaxRateProducts"
|
|
5
|
+
* summary: "Add Tax Rate to Products"
|
|
6
|
+
* description: "Associates a Tax Rate with a list of Products"
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* tags:
|
|
9
|
+
* - Tax Rates
|
|
10
|
+
* responses:
|
|
11
|
+
* 200:
|
|
12
|
+
* description: OK
|
|
13
|
+
* content:
|
|
14
|
+
* application/json:
|
|
15
|
+
* schema:
|
|
16
|
+
* properties:
|
|
17
|
+
* tax_rate:
|
|
18
|
+
* type: array
|
|
19
|
+
* items:
|
|
20
|
+
* $ref: "#/components/schemas/tax_rate"
|
|
21
|
+
*/
|
|
22
|
+
export default _default;
|
|
23
|
+
export declare class AdminPostTaxRatesTaxRateProductsReq {
|
|
24
|
+
products: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare class AdminPostTaxRatesTaxRateProductsParams {
|
|
27
|
+
expand?: string[];
|
|
28
|
+
fields?: string[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
63
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
64
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
+
if (ar || !(i in from)) {
|
|
66
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
+
ar[i] = from[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.AdminPostTaxRatesTaxRateProductsParams = exports.AdminPostTaxRatesTaxRateProductsReq = void 0;
|
|
74
|
+
var get_query_config_1 = require("./utils/get-query-config");
|
|
75
|
+
var class_validator_1 = require("class-validator");
|
|
76
|
+
var validator_1 = require("../../../../utils/validator");
|
|
77
|
+
/**
|
|
78
|
+
* @oas [post] /tax-rates/:id/products
|
|
79
|
+
* operationId: "PostTaxRatesTaxRateProducts"
|
|
80
|
+
* summary: "Add Tax Rate to Products"
|
|
81
|
+
* description: "Associates a Tax Rate with a list of Products"
|
|
82
|
+
* x-authenticated: true
|
|
83
|
+
* tags:
|
|
84
|
+
* - Tax Rates
|
|
85
|
+
* responses:
|
|
86
|
+
* 200:
|
|
87
|
+
* description: OK
|
|
88
|
+
* content:
|
|
89
|
+
* application/json:
|
|
90
|
+
* schema:
|
|
91
|
+
* properties:
|
|
92
|
+
* tax_rate:
|
|
93
|
+
* type: array
|
|
94
|
+
* items:
|
|
95
|
+
* $ref: "#/components/schemas/tax_rate"
|
|
96
|
+
*/
|
|
97
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
var value, query, productService, rateService, err_1, config, rate, data;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, (0, validator_1.validator)(AdminPostTaxRatesTaxRateProductsReq, req.body)];
|
|
102
|
+
case 1:
|
|
103
|
+
value = _a.sent();
|
|
104
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminPostTaxRatesTaxRateProductsParams, req.query)];
|
|
105
|
+
case 2:
|
|
106
|
+
query = _a.sent();
|
|
107
|
+
productService = req.scope.resolve("productService");
|
|
108
|
+
rateService = req.scope.resolve("taxRateService");
|
|
109
|
+
_a.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
_a.trys.push([3, 5, , 8]);
|
|
112
|
+
return [4 /*yield*/, rateService.addToProduct(req.params.id, value.products)];
|
|
113
|
+
case 4:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [3 /*break*/, 8];
|
|
116
|
+
case 5:
|
|
117
|
+
err_1 = _a.sent();
|
|
118
|
+
if (!(err_1.code === "23503")) return [3 /*break*/, 7];
|
|
119
|
+
// A foreign key constraint failed meaning some thing doesn't exist
|
|
120
|
+
// either it is a product or the tax rate itself. Using Promise.all
|
|
121
|
+
// will try to retrieve all of the resources and will fail when
|
|
122
|
+
// something is not found.
|
|
123
|
+
return [4 /*yield*/, Promise.all(__spreadArray([
|
|
124
|
+
rateService.retrieve(req.params.id, { select: ["id"] })
|
|
125
|
+
], __read(value.products.map(function (id) {
|
|
126
|
+
return productService.retrieve(id, { select: ["id"] });
|
|
127
|
+
})), false))];
|
|
128
|
+
case 6:
|
|
129
|
+
// A foreign key constraint failed meaning some thing doesn't exist
|
|
130
|
+
// either it is a product or the tax rate itself. Using Promise.all
|
|
131
|
+
// will try to retrieve all of the resources and will fail when
|
|
132
|
+
// something is not found.
|
|
133
|
+
_a.sent();
|
|
134
|
+
_a.label = 7;
|
|
135
|
+
case 7: throw err_1;
|
|
136
|
+
case 8:
|
|
137
|
+
config = (0, get_query_config_1.getRetrieveConfig)(query.fields, query.expand);
|
|
138
|
+
return [4 /*yield*/, rateService.retrieve(req.params.id, config)];
|
|
139
|
+
case 9:
|
|
140
|
+
rate = _a.sent();
|
|
141
|
+
data = (0, get_query_config_1.pickByConfig)(rate, config);
|
|
142
|
+
res.json({ tax_rate: data });
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}); });
|
|
147
|
+
var AdminPostTaxRatesTaxRateProductsReq = /** @class */ (function () {
|
|
148
|
+
function AdminPostTaxRatesTaxRateProductsReq() {
|
|
149
|
+
}
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, class_validator_1.IsArray)(),
|
|
152
|
+
__metadata("design:type", Array)
|
|
153
|
+
], AdminPostTaxRatesTaxRateProductsReq.prototype, "products", void 0);
|
|
154
|
+
return AdminPostTaxRatesTaxRateProductsReq;
|
|
155
|
+
}());
|
|
156
|
+
exports.AdminPostTaxRatesTaxRateProductsReq = AdminPostTaxRatesTaxRateProductsReq;
|
|
157
|
+
var AdminPostTaxRatesTaxRateProductsParams = /** @class */ (function () {
|
|
158
|
+
function AdminPostTaxRatesTaxRateProductsParams() {
|
|
159
|
+
}
|
|
160
|
+
__decorate([
|
|
161
|
+
(0, class_validator_1.IsArray)(),
|
|
162
|
+
(0, class_validator_1.IsOptional)(),
|
|
163
|
+
__metadata("design:type", Array)
|
|
164
|
+
], AdminPostTaxRatesTaxRateProductsParams.prototype, "expand", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, class_validator_1.IsArray)(),
|
|
167
|
+
(0, class_validator_1.IsOptional)(),
|
|
168
|
+
__metadata("design:type", Array)
|
|
169
|
+
], AdminPostTaxRatesTaxRateProductsParams.prototype, "fields", void 0);
|
|
170
|
+
return AdminPostTaxRatesTaxRateProductsParams;
|
|
171
|
+
}());
|
|
172
|
+
exports.AdminPostTaxRatesTaxRateProductsParams = AdminPostTaxRatesTaxRateProductsParams;
|
|
173
|
+
//# sourceMappingURL=add-to-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to-products.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/tax-rates/add-to-products.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0E;AAC1E,mDAAqD;AAIrD,yDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;oBACd,qBAAM,IAAA,qBAAS,EAAC,mCAAmC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAA;;gBAAtE,KAAK,GAAG,SAA8D;gBAE9D,qBAAM,IAAA,qBAAS,EAC3B,sCAAsC,EACtC,GAAG,CAAC,KAAK,CACV,EAAA;;gBAHK,KAAK,GAAG,SAGb;gBAEK,cAAc,GAAmB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;gBACpE,WAAW,GAAmB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;;;;gBAGrE,qBAAM,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAA;;gBAA7D,SAA6D,CAAA;;;;qBAEzD,CAAA,KAAG,CAAC,IAAI,KAAK,OAAO,CAAA,EAApB,wBAAoB;gBACtB,mEAAmE;gBACnE,mEAAmE;gBACnE,+DAA+D;gBAC/D,0BAA0B;gBAC1B,qBAAM,OAAO,CAAC,GAAG;wBACf,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;8BACpD,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAC,EAAE;wBACvB,OAAA,cAAc,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;oBAA/C,CAA+C,CAChD,UACD,EAAA;;gBATF,mEAAmE;gBACnE,mEAAmE;gBACnE,+DAA+D;gBAC/D,0BAA0B;gBAC1B,SAKE,CAAA;;oBAGJ,MAAM,KAAG,CAAA;;gBAGL,MAAM,GAAG,IAAA,oCAAiB,EAC9B,KAAK,CAAC,MAA2B,EACjC,KAAK,CAAC,MAAM,CACb,CAAA;gBACY,qBAAM,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,EAAA;;gBAAxD,IAAI,GAAG,SAAiD;gBACxD,IAAI,GAAG,IAAA,+BAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBAEvC,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;KAC7B,EAAA;AAED;IAAA;IAGA,CAAC;IADC;QADC,IAAA,yBAAO,GAAE;;yEACQ;IACpB,0CAAC;CAAA,AAHD,IAGC;AAHY,kFAAmC;AAKhD;IAAA;IAQA,CAAC;IALC;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;0EACI;IAIjB;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;0EACI;IACnB,6CAAC;CAAA,AARD,IAQC;AARY,wFAAsC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [post] /tax-rates/:id/product-types
|
|
4
|
+
* operationId: "PostTaxRatesTaxRateShippingOptions"
|
|
5
|
+
* summary: "Add Tax Rate to Product Types"
|
|
6
|
+
* description: "Associates a Tax Rate with a list of Product Types"
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* tags:
|
|
9
|
+
* - Tax Rates
|
|
10
|
+
* responses:
|
|
11
|
+
* 200:
|
|
12
|
+
* description: OK
|
|
13
|
+
* content:
|
|
14
|
+
* application/json:
|
|
15
|
+
* schema:
|
|
16
|
+
* properties:
|
|
17
|
+
* tax_rate:
|
|
18
|
+
* type: array
|
|
19
|
+
* items:
|
|
20
|
+
* $ref: "#/components/schemas/tax_rate"
|
|
21
|
+
*/
|
|
22
|
+
export default _default;
|
|
23
|
+
export declare class AdminPostTaxRatesTaxRateShippingOptionsReq {
|
|
24
|
+
shipping_options: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare class AdminPostTaxRatesTaxRateShippingOptionsParams {
|
|
27
|
+
expand?: string[];
|
|
28
|
+
fields?: string[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
48
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
49
|
+
if (!m) return o;
|
|
50
|
+
var i = m.call(o), r, ar = [], e;
|
|
51
|
+
try {
|
|
52
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
53
|
+
}
|
|
54
|
+
catch (error) { e = { error: error }; }
|
|
55
|
+
finally {
|
|
56
|
+
try {
|
|
57
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
58
|
+
}
|
|
59
|
+
finally { if (e) throw e.error; }
|
|
60
|
+
}
|
|
61
|
+
return ar;
|
|
62
|
+
};
|
|
63
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
64
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
65
|
+
if (ar || !(i in from)) {
|
|
66
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
67
|
+
ar[i] = from[i];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.AdminPostTaxRatesTaxRateShippingOptionsParams = exports.AdminPostTaxRatesTaxRateShippingOptionsReq = void 0;
|
|
74
|
+
var get_query_config_1 = require("./utils/get-query-config");
|
|
75
|
+
var class_validator_1 = require("class-validator");
|
|
76
|
+
var validator_1 = require("../../../../utils/validator");
|
|
77
|
+
/**
|
|
78
|
+
* @oas [post] /tax-rates/:id/product-types
|
|
79
|
+
* operationId: "PostTaxRatesTaxRateShippingOptions"
|
|
80
|
+
* summary: "Add Tax Rate to Product Types"
|
|
81
|
+
* description: "Associates a Tax Rate with a list of Product Types"
|
|
82
|
+
* x-authenticated: true
|
|
83
|
+
* tags:
|
|
84
|
+
* - Tax Rates
|
|
85
|
+
* responses:
|
|
86
|
+
* 200:
|
|
87
|
+
* description: OK
|
|
88
|
+
* content:
|
|
89
|
+
* application/json:
|
|
90
|
+
* schema:
|
|
91
|
+
* properties:
|
|
92
|
+
* tax_rate:
|
|
93
|
+
* type: array
|
|
94
|
+
* items:
|
|
95
|
+
* $ref: "#/components/schemas/tax_rate"
|
|
96
|
+
*/
|
|
97
|
+
exports.default = (function (req, res) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
var value, query, rateService, optionService, err_1, config, rate, data;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, (0, validator_1.validator)(AdminPostTaxRatesTaxRateShippingOptionsReq, req.body)];
|
|
102
|
+
case 1:
|
|
103
|
+
value = _a.sent();
|
|
104
|
+
return [4 /*yield*/, (0, validator_1.validator)(AdminPostTaxRatesTaxRateShippingOptionsParams, req.query)];
|
|
105
|
+
case 2:
|
|
106
|
+
query = _a.sent();
|
|
107
|
+
rateService = req.scope.resolve("taxRateService");
|
|
108
|
+
optionService = req.scope.resolve("shippingOptionService");
|
|
109
|
+
_a.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
_a.trys.push([3, 5, , 8]);
|
|
112
|
+
return [4 /*yield*/, rateService.addToShippingOption(req.params.id, value.shipping_options)];
|
|
113
|
+
case 4:
|
|
114
|
+
_a.sent();
|
|
115
|
+
return [3 /*break*/, 8];
|
|
116
|
+
case 5:
|
|
117
|
+
err_1 = _a.sent();
|
|
118
|
+
if (!(err_1.code === "23503")) return [3 /*break*/, 7];
|
|
119
|
+
// A foreign key constraint failed meaning some thing doesn't exist
|
|
120
|
+
// either it is a product type or the tax rate itself. Using Promise.all
|
|
121
|
+
// will try to retrieve all of the resources and will fail when something
|
|
122
|
+
// is not found.
|
|
123
|
+
return [4 /*yield*/, Promise.all(__spreadArray([
|
|
124
|
+
rateService.retrieve(req.params.id, {
|
|
125
|
+
select: ["id"],
|
|
126
|
+
})
|
|
127
|
+
], __read(value.shipping_options.map(function (id) {
|
|
128
|
+
return optionService.retrieve(id, {
|
|
129
|
+
select: ["id"],
|
|
130
|
+
});
|
|
131
|
+
})), false))];
|
|
132
|
+
case 6:
|
|
133
|
+
// A foreign key constraint failed meaning some thing doesn't exist
|
|
134
|
+
// either it is a product type or the tax rate itself. Using Promise.all
|
|
135
|
+
// will try to retrieve all of the resources and will fail when something
|
|
136
|
+
// is not found.
|
|
137
|
+
_a.sent();
|
|
138
|
+
_a.label = 7;
|
|
139
|
+
case 7: throw err_1;
|
|
140
|
+
case 8:
|
|
141
|
+
config = (0, get_query_config_1.getRetrieveConfig)(query.fields, query.expand);
|
|
142
|
+
return [4 /*yield*/, rateService.retrieve(req.params.id, config)];
|
|
143
|
+
case 9:
|
|
144
|
+
rate = _a.sent();
|
|
145
|
+
data = (0, get_query_config_1.pickByConfig)(rate, config);
|
|
146
|
+
res.json({ tax_rate: data });
|
|
147
|
+
return [2 /*return*/];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); });
|
|
151
|
+
var AdminPostTaxRatesTaxRateShippingOptionsReq = /** @class */ (function () {
|
|
152
|
+
function AdminPostTaxRatesTaxRateShippingOptionsReq() {
|
|
153
|
+
}
|
|
154
|
+
__decorate([
|
|
155
|
+
(0, class_validator_1.IsArray)(),
|
|
156
|
+
__metadata("design:type", Array)
|
|
157
|
+
], AdminPostTaxRatesTaxRateShippingOptionsReq.prototype, "shipping_options", void 0);
|
|
158
|
+
return AdminPostTaxRatesTaxRateShippingOptionsReq;
|
|
159
|
+
}());
|
|
160
|
+
exports.AdminPostTaxRatesTaxRateShippingOptionsReq = AdminPostTaxRatesTaxRateShippingOptionsReq;
|
|
161
|
+
var AdminPostTaxRatesTaxRateShippingOptionsParams = /** @class */ (function () {
|
|
162
|
+
function AdminPostTaxRatesTaxRateShippingOptionsParams() {
|
|
163
|
+
}
|
|
164
|
+
__decorate([
|
|
165
|
+
(0, class_validator_1.IsArray)(),
|
|
166
|
+
(0, class_validator_1.IsOptional)(),
|
|
167
|
+
__metadata("design:type", Array)
|
|
168
|
+
], AdminPostTaxRatesTaxRateShippingOptionsParams.prototype, "expand", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
(0, class_validator_1.IsArray)(),
|
|
171
|
+
(0, class_validator_1.IsOptional)(),
|
|
172
|
+
__metadata("design:type", Array)
|
|
173
|
+
], AdminPostTaxRatesTaxRateShippingOptionsParams.prototype, "fields", void 0);
|
|
174
|
+
return AdminPostTaxRatesTaxRateShippingOptionsParams;
|
|
175
|
+
}());
|
|
176
|
+
exports.AdminPostTaxRatesTaxRateShippingOptionsParams = AdminPostTaxRatesTaxRateShippingOptionsParams;
|
|
177
|
+
//# sourceMappingURL=add-to-shipping-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-to-shipping-options.js","sourceRoot":"","sources":["../../../../../src/api/routes/admin/tax-rates/add-to-shipping-options.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0E;AAC1E,mDAAqD;AAIrD,yDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,mBAAe,UAAO,GAAG,EAAE,GAAG;;;;oBACd,qBAAM,IAAA,qBAAS,EAC3B,0CAA0C,EAC1C,GAAG,CAAC,IAAI,CACT,EAAA;;gBAHK,KAAK,GAAG,SAGb;gBAEa,qBAAM,IAAA,qBAAS,EAC3B,6CAA6C,EAC7C,GAAG,CAAC,KAAK,CACV,EAAA;;gBAHK,KAAK,GAAG,SAGb;gBAEK,WAAW,GAAmB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;gBACjE,aAAa,GAA0B,GAAG,CAAC,KAAK,CAAC,OAAO,CAC5D,uBAAuB,CACxB,CAAA;;;;gBAGC,qBAAM,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,gBAAgB,CAAC,EAAA;;gBAA5E,SAA4E,CAAA;;;;qBAExE,CAAA,KAAG,CAAC,IAAI,KAAK,OAAO,CAAA,EAApB,wBAAoB;gBACtB,mEAAmE;gBACnE,wEAAwE;gBACxE,yEAAyE;gBACzE,gBAAgB;gBAChB,qBAAM,OAAO,CAAC,GAAG;wBACf,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE;4BAClC,MAAM,EAAE,CAAC,IAAI,CAAC;yBACf,CAAqB;8BACnB,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAC3B,UAAC,EAAE;wBACD,OAAA,aAAa,CAAC,QAAQ,CAAC,EAAE,EAAE;4BACzB,MAAM,EAAE,CAAC,IAAI,CAAC;yBACf,CAAqB;oBAFtB,CAEsB,CACzB,UACD,EAAA;;gBAdF,mEAAmE;gBACnE,wEAAwE;gBACxE,yEAAyE;gBACzE,gBAAgB;gBAChB,SAUE,CAAA;;oBAGJ,MAAM,KAAG,CAAA;;gBAGL,MAAM,GAAG,IAAA,oCAAiB,EAC9B,KAAK,CAAC,MAA2B,EACjC,KAAK,CAAC,MAAM,CACb,CAAA;gBACY,qBAAM,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,EAAA;;gBAAxD,IAAI,GAAG,SAAiD;gBACxD,IAAI,GAAG,IAAA,+BAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBAEvC,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;KAC7B,EAAA;AAED;IAAA;IAGA,CAAC;IADC;QADC,IAAA,yBAAO,GAAE;;wFACgB;IAC5B,iDAAC;CAAA,AAHD,IAGC;AAHY,gGAA0C;AAKvD;IAAA;IAQA,CAAC;IALC;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;iFACI;IAIjB;QAFC,IAAA,yBAAO,GAAE;QACT,IAAA,4BAAU,GAAE;;iFACI;IACnB,oDAAC;CAAA,AARD,IAQC;AARY,sGAA6C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare const _default: (req: any, res: any) => Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* @oas [post] /tax-rates
|
|
4
|
+
* operationId: "PostTaxRates"
|
|
5
|
+
* summary: "Create a Tax Rate"
|
|
6
|
+
* description: "Creates a Tax Rate"
|
|
7
|
+
* x-authenticated: true
|
|
8
|
+
* tags:
|
|
9
|
+
* - Tax Rates
|
|
10
|
+
* responses:
|
|
11
|
+
* 200:
|
|
12
|
+
* description: OK
|
|
13
|
+
* content:
|
|
14
|
+
* application/json:
|
|
15
|
+
* schema:
|
|
16
|
+
* properties:
|
|
17
|
+
* tax_rate:
|
|
18
|
+
* type: array
|
|
19
|
+
* items:
|
|
20
|
+
* $ref: "#/components/schemas/tax_rate"
|
|
21
|
+
*/
|
|
22
|
+
export default _default;
|
|
23
|
+
export declare class AdminPostTaxRatesReq {
|
|
24
|
+
code: string;
|
|
25
|
+
name: string;
|
|
26
|
+
region_id: string;
|
|
27
|
+
rate?: number | null;
|
|
28
|
+
products?: string[];
|
|
29
|
+
shipping_options?: string[];
|
|
30
|
+
product_types?: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare class AdminPostTaxRatesParams {
|
|
33
|
+
expand?: string[];
|
|
34
|
+
fields?: string[];
|
|
35
|
+
}
|