@medusajs/medusa 1.1.63 → 1.1.64

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +3 -3
  3. package/dist/api/routes/admin/product-tags/create-collection.d.ts +0 -41
  4. package/dist/api/routes/admin/product-tags/create-collection.js +0 -125
  5. package/dist/api/routes/admin/product-tags/create-collection.js.map +0 -1
  6. package/dist/api/routes/admin/product-tags/delete-collection.d.ts +0 -28
  7. package/dist/api/routes/admin/product-tags/delete-collection.js +0 -84
  8. package/dist/api/routes/admin/product-tags/delete-collection.js.map +0 -1
  9. package/dist/api/routes/admin/product-tags/get-collection.d.ts +0 -22
  10. package/dist/api/routes/admin/product-tags/get-collection.js +0 -74
  11. package/dist/api/routes/admin/product-tags/get-collection.js.map +0 -1
  12. package/dist/api/routes/admin/product-tags/list-collections.d.ts +0 -40
  13. package/dist/api/routes/admin/product-tags/list-collections.js +0 -215
  14. package/dist/api/routes/admin/product-tags/list-collections.js.map +0 -1
  15. package/dist/api/routes/admin/product-tags/update-collection.d.ts +0 -41
  16. package/dist/api/routes/admin/product-tags/update-collection.js +0 -127
  17. package/dist/api/routes/admin/product-tags/update-collection.js.map +0 -1
  18. package/dist/api/routes/admin/tax-rates/add-to-product-types.d.ts +0 -29
  19. package/dist/api/routes/admin/tax-rates/add-to-product-types.js +0 -177
  20. package/dist/api/routes/admin/tax-rates/add-to-product-types.js.map +0 -1
  21. package/dist/api/routes/admin/tax-rates/add-to-products.d.ts +0 -29
  22. package/dist/api/routes/admin/tax-rates/add-to-products.js +0 -173
  23. package/dist/api/routes/admin/tax-rates/add-to-products.js.map +0 -1
  24. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.d.ts +0 -29
  25. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js +0 -177
  26. package/dist/api/routes/admin/tax-rates/add-to-shipping-options.js.map +0 -1
  27. package/dist/api/routes/admin/tax-rates/create-tax-rate.d.ts +0 -35
  28. package/dist/api/routes/admin/tax-rates/create-tax-rate.js +0 -286
  29. package/dist/api/routes/admin/tax-rates/create-tax-rate.js.map +0 -1
  30. package/dist/api/routes/admin/tax-rates/delete-tax-rate.d.ts +0 -28
  31. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js +0 -84
  32. package/dist/api/routes/admin/tax-rates/delete-tax-rate.js.map +0 -1
  33. package/dist/api/routes/admin/tax-rates/get-tax-rate.d.ts +0 -26
  34. package/dist/api/routes/admin/tax-rates/get-tax-rate.js +0 -106
  35. package/dist/api/routes/admin/tax-rates/get-tax-rate.js.map +0 -1
  36. package/dist/api/routes/admin/tax-rates/index.d.ts +0 -21
  37. package/dist/api/routes/admin/tax-rates/index.js +0 -74
  38. package/dist/api/routes/admin/tax-rates/index.js.map +0 -1
  39. package/dist/api/routes/admin/tax-rates/list-tax-rates.d.ts +0 -44
  40. package/dist/api/routes/admin/tax-rates/list-tax-rates.js +0 -178
  41. package/dist/api/routes/admin/tax-rates/list-tax-rates.js.map +0 -1
  42. package/dist/api/routes/admin/tax-rates/update-tax-rate.d.ts +0 -35
  43. package/dist/api/routes/admin/tax-rates/update-tax-rate.js +0 -286
  44. package/dist/api/routes/admin/tax-rates/update-tax-rate.js.map +0 -1
  45. package/dist/api/routes/admin/tax-rates/utils/get-query-config.d.ts +0 -7
  46. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js +0 -91
  47. package/dist/api/routes/admin/tax-rates/utils/get-query-config.js.map +0 -1
  48. package/dist/api/routes/store/carts/calculate-taxes.d.ts +0 -24
  49. package/dist/api/routes/store/carts/calculate-taxes.js +0 -153
  50. package/dist/api/routes/store/carts/calculate-taxes.js.map +0 -1
  51. package/dist/interfaces/cart-completion-strategy.d.ts +0 -20
  52. package/dist/interfaces/cart-completion-strategy.js +0 -10
  53. package/dist/interfaces/cart-completion-strategy.js.map +0 -1
  54. package/dist/interfaces/index.d.ts +0 -3
  55. package/dist/interfaces/index.js +0 -16
  56. package/dist/interfaces/index.js.map +0 -1
  57. package/dist/interfaces/tax-calculation-strategy.d.ts +0 -16
  58. package/dist/interfaces/tax-calculation-strategy.js +0 -10
  59. package/dist/interfaces/tax-calculation-strategy.js.map +0 -1
  60. package/dist/interfaces/tax-service.d.ts +0 -51
  61. package/dist/interfaces/tax-service.js +0 -3
  62. package/dist/interfaces/tax-service.js.map +0 -1
  63. package/dist/loaders/strategies.d.ts +0 -12
  64. package/dist/loaders/strategies.js +0 -32
  65. package/dist/loaders/strategies.js.map +0 -1
  66. package/dist/migrations/1641636508055-new_tax_system.d.ts +0 -6
  67. package/dist/migrations/1641636508055-new_tax_system.js +0 -248
  68. package/dist/migrations/1641636508055-new_tax_system.js.map +0 -1
  69. package/dist/models/line-item-tax-line.d.ts +0 -7
  70. package/dist/models/line-item-tax-line.js +0 -65
  71. package/dist/models/line-item-tax-line.js.map +0 -1
  72. package/dist/models/product-tax-rate.d.ts +0 -40
  73. package/dist/models/product-tax-rate.js +0 -88
  74. package/dist/models/product-tax-rate.js.map +0 -1
  75. package/dist/models/product-type-tax-rate.d.ts +0 -40
  76. package/dist/models/product-type-tax-rate.js +0 -88
  77. package/dist/models/product-type-tax-rate.js.map +0 -1
  78. package/dist/models/shipping-method-tax-line.d.ts +0 -7
  79. package/dist/models/shipping-method-tax-line.js +0 -65
  80. package/dist/models/shipping-method-tax-line.js.map +0 -1
  81. package/dist/models/shipping-tax-rate.d.ts +0 -40
  82. package/dist/models/shipping-tax-rate.js +0 -88
  83. package/dist/models/shipping-tax-rate.js.map +0 -1
  84. package/dist/models/tax-line.d.ts +0 -39
  85. package/dist/models/tax-line.js +0 -79
  86. package/dist/models/tax-line.js.map +0 -1
  87. package/dist/models/tax-provider.d.ts +0 -17
  88. package/dist/models/tax-provider.js +0 -44
  89. package/dist/models/tax-provider.js.map +0 -1
  90. package/dist/models/tax-rate.d.ts +0 -58
  91. package/dist/models/tax-rate.js +0 -159
  92. package/dist/models/tax-rate.js.map +0 -1
  93. package/dist/repositories/line-item-tax-line.d.ts +0 -4
  94. package/dist/repositories/line-item-tax-line.js +0 -38
  95. package/dist/repositories/line-item-tax-line.js.map +0 -1
  96. package/dist/repositories/product-tax-rate.d.ts +0 -4
  97. package/dist/repositories/product-tax-rate.js +0 -38
  98. package/dist/repositories/product-tax-rate.js.map +0 -1
  99. package/dist/repositories/shipping-method-tax-line.d.ts +0 -4
  100. package/dist/repositories/shipping-method-tax-line.js +0 -38
  101. package/dist/repositories/shipping-method-tax-line.js.map +0 -1
  102. package/dist/repositories/shipping-tax-rate.d.ts +0 -4
  103. package/dist/repositories/shipping-tax-rate.js +0 -38
  104. package/dist/repositories/shipping-tax-rate.js.map +0 -1
  105. package/dist/repositories/tax-rate.d.ts +0 -18
  106. package/dist/repositories/tax-rate.js +0 -359
  107. package/dist/repositories/tax-rate.js.map +0 -1
  108. package/dist/services/product-tax-rate.d.ts +0 -25
  109. package/dist/services/product-tax-rate.js +0 -104
  110. package/dist/services/product-tax-rate.js.map +0 -1
  111. package/dist/services/product-type.d.ts +0 -27
  112. package/dist/services/product-type.js +0 -112
  113. package/dist/services/product-type.js.map +0 -1
  114. package/dist/services/shipping-tax-rate.d.ts +0 -26
  115. package/dist/services/shipping-tax-rate.js +0 -105
  116. package/dist/services/shipping-tax-rate.js.map +0 -1
  117. package/dist/services/system-tax.d.ts +0 -9
  118. package/dist/services/system-tax.js +0 -89
  119. package/dist/services/system-tax.js.map +0 -1
  120. package/dist/services/tax-provider.d.ts +0 -105
  121. package/dist/services/tax-provider.js +0 -455
  122. package/dist/services/tax-provider.js.map +0 -1
  123. package/dist/services/tax-rate.d.ts +0 -31
  124. package/dist/services/tax-rate.js +0 -405
  125. package/dist/services/tax-rate.js.map +0 -1
  126. package/dist/strategies/cart-completion.d.ts +0 -17
  127. package/dist/strategies/cart-completion.js +0 -336
  128. package/dist/strategies/cart-completion.js.map +0 -1
  129. package/dist/strategies/tax-calculation.d.ts +0 -11
  130. package/dist/strategies/tax-calculation.js +0 -147
  131. package/dist/strategies/tax-calculation.js.map +0 -1
  132. package/dist/types/product-tax-rate.d.ts +0 -10
  133. package/dist/types/product-tax-rate.js +0 -13
  134. package/dist/types/product-tax-rate.js.map +0 -1
  135. package/dist/types/request.d.ts +0 -3
  136. package/dist/types/request.js +0 -3
  137. package/dist/types/request.js.map +0 -1
  138. package/dist/types/shipping-tax-rate.d.ts +0 -10
  139. package/dist/types/shipping-tax-rate.js +0 -13
  140. package/dist/types/shipping-tax-rate.js.map +0 -1
  141. package/dist/types/tax-rate.d.ts +0 -25
  142. package/dist/types/tax-rate.js +0 -3
  143. package/dist/types/tax-rate.js.map +0 -1
  144. package/dist/types/tax-service.d.ts +0 -34
  145. package/dist/types/tax-service.js +0 -3
  146. package/dist/types/tax-service.js.map +0 -1
  147. package/dist/types/totals.d.ts +0 -42
  148. package/dist/types/totals.js +0 -3
  149. package/dist/types/totals.js.map +0 -1
@@ -1,173 +0,0 @@
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
@@ -1 +0,0 @@
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,mEAAm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[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
- }
@@ -1,177 +0,0 @@
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
@@ -1 +0,0 @@
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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=> 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
- }