@medusajs/tax 0.1.2-snapshot-20240607093839 → 0.1.2-snapshot-20240701122250
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/index.d.ts +2 -3
- package/dist/index.js +12 -17
- package/dist/joiner-config.d.ts +1 -3
- package/dist/joiner-config.js +4 -52
- package/dist/models/tax-rate-rule.d.ts +2 -2
- package/dist/models/tax-rate-rule.js +1 -1
- package/dist/models/tax-rate.d.ts +2 -2
- package/dist/models/tax-rate.js +3 -3
- package/dist/models/tax-region.d.ts +3 -3
- package/dist/models/tax-region.js +2 -2
- package/dist/services/tax-module-service.d.ts +25 -22
- package/dist/services/tax-module-service.js +19 -19
- package/package.json +7 -11
- package/dist/module-definition.d.ts +0 -2
- package/dist/module-definition.js +0 -14
- package/dist/scripts/bin/run-seed.d.ts +0 -3
- package/dist/scripts/bin/run-seed.js +0 -48
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
15
4
|
};
|
16
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
exports.moduleDefinition = void 0;
|
7
|
+
const _services_1 = require("./services");
|
8
|
+
const providers_1 = __importDefault(require("./loaders/providers"));
|
9
|
+
const service = _services_1.TaxModuleService;
|
10
|
+
const loaders = [providers_1.default];
|
11
|
+
exports.moduleDefinition = {
|
12
|
+
service,
|
13
|
+
loaders,
|
14
|
+
};
|
15
|
+
exports.default = exports.moduleDefinition;
|
package/dist/joiner-config.d.ts
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import { ModuleJoinerConfig } from "@medusajs/types";
|
2
1
|
import { MapToConfig } from "@medusajs/utils";
|
3
|
-
export declare const
|
2
|
+
export declare const joinerConfig: Omit<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
|
4
3
|
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
5
|
-
export declare const joinerConfig: ModuleJoinerConfig;
|
package/dist/joiner-config.js
CHANGED
@@ -1,54 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
const
|
5
|
-
|
6
|
-
exports.
|
7
|
-
tax_rate_id: _models_1.TaxRate.name,
|
8
|
-
tax_region_id: _models_1.TaxRegion.name,
|
9
|
-
tax_rate_rule_id: _models_1.TaxRateRule.name,
|
10
|
-
tax_provider_id: _models_1.TaxProvider.name,
|
11
|
-
};
|
12
|
-
const entityLinkableKeysMap = {};
|
13
|
-
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
14
|
-
entityLinkableKeysMap[value] ??= [];
|
15
|
-
entityLinkableKeysMap[value].push({
|
16
|
-
mapTo: key,
|
17
|
-
valueFrom: key.split("_").pop(),
|
18
|
-
});
|
19
|
-
});
|
20
|
-
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
21
|
-
exports.joinerConfig = {
|
22
|
-
serviceName: modules_sdk_1.Modules.TAX,
|
23
|
-
primaryKeys: ["id"],
|
24
|
-
linkableKeys: exports.LinkableKeys,
|
25
|
-
alias: [
|
26
|
-
{
|
27
|
-
name: ["tax_rate", "tax_rates"],
|
28
|
-
args: {
|
29
|
-
entity: _models_1.TaxRate.name,
|
30
|
-
},
|
31
|
-
},
|
32
|
-
{
|
33
|
-
name: ["tax_region", "tax_regions"],
|
34
|
-
args: {
|
35
|
-
entity: _models_1.TaxRegion.name,
|
36
|
-
methodSuffix: "TaxRegions",
|
37
|
-
},
|
38
|
-
},
|
39
|
-
{
|
40
|
-
name: ["tax_rate_rule", "tax_rate_rules"],
|
41
|
-
args: {
|
42
|
-
entity: _models_1.TaxRateRule.name,
|
43
|
-
methodSuffix: "TaxRateRules",
|
44
|
-
},
|
45
|
-
},
|
46
|
-
{
|
47
|
-
name: ["tax_provider", "tax_providers"],
|
48
|
-
args: {
|
49
|
-
entity: _models_1.TaxProvider.name,
|
50
|
-
methodSuffix: "TaxProviders",
|
51
|
-
},
|
52
|
-
},
|
53
|
-
],
|
54
|
-
};
|
3
|
+
exports.entityNameToLinkableKeysMap = exports.joinerConfig = void 0;
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.TAX);
|
6
|
+
exports.entityNameToLinkableKeysMap = (0, utils_1.buildEntitiesNameToLinkableKeysMap)(exports.joinerConfig.linkableKeys);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import { OptionalProps } from "@mikro-orm/core";
|
2
|
+
import { OptionalProps, Rel } from "@mikro-orm/core";
|
3
3
|
import TaxRate from "./tax-rate";
|
4
4
|
type OptionalRuleProps = DAL.SoftDeletableEntityDateColumns;
|
5
5
|
export declare const uniqueRateReferenceIndexName = "IDX_tax_rate_rule_unique_rate_reference";
|
@@ -9,7 +9,7 @@ export default class TaxRateRule {
|
|
9
9
|
tax_rate_id: string;
|
10
10
|
reference_id: string;
|
11
11
|
reference: string;
|
12
|
-
tax_rate: TaxRate
|
12
|
+
tax_rate: Rel<TaxRate>;
|
13
13
|
metadata: Record<string, unknown> | null;
|
14
14
|
created_at: Date;
|
15
15
|
updated_at: Date;
|
@@ -77,7 +77,7 @@ __decorate([
|
|
77
77
|
], TaxRateRule.prototype, "reference", void 0);
|
78
78
|
__decorate([
|
79
79
|
(0, core_1.ManyToOne)(() => tax_rate_1.default, { persist: false }),
|
80
|
-
__metadata("design:type",
|
80
|
+
__metadata("design:type", Object)
|
81
81
|
], TaxRateRule.prototype, "tax_rate", void 0);
|
82
82
|
__decorate([
|
83
83
|
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import { Collection, OptionalProps } from "@mikro-orm/core";
|
2
|
+
import { Collection, OptionalProps, Rel } from "@mikro-orm/core";
|
3
3
|
import TaxRateRule from "./tax-rate-rule";
|
4
4
|
import TaxRegion from "./tax-region";
|
5
5
|
type OptionalTaxRateProps = DAL.SoftDeletableEntityDateColumns;
|
@@ -13,7 +13,7 @@ export default class TaxRate {
|
|
13
13
|
is_default: boolean;
|
14
14
|
is_combinable: boolean;
|
15
15
|
tax_region_id: string;
|
16
|
-
tax_region: TaxRegion
|
16
|
+
tax_region: Rel<TaxRegion>;
|
17
17
|
rules: Collection<TaxRateRule, object>;
|
18
18
|
metadata: Record<string, unknown> | null;
|
19
19
|
created_at: Date;
|
package/dist/models/tax-rate.js
CHANGED
@@ -71,11 +71,11 @@ __decorate([
|
|
71
71
|
], TaxRate.prototype, "name", void 0);
|
72
72
|
__decorate([
|
73
73
|
(0, core_1.Property)({ columnType: "bool", default: false }),
|
74
|
-
__metadata("design:type",
|
74
|
+
__metadata("design:type", Boolean)
|
75
75
|
], TaxRate.prototype, "is_default", void 0);
|
76
76
|
__decorate([
|
77
77
|
(0, core_1.Property)({ columnType: "bool", default: false }),
|
78
|
-
__metadata("design:type",
|
78
|
+
__metadata("design:type", Boolean)
|
79
79
|
], TaxRate.prototype, "is_combinable", void 0);
|
80
80
|
__decorate([
|
81
81
|
(0, core_1.ManyToOne)(() => tax_region_1.default, {
|
@@ -89,7 +89,7 @@ __decorate([
|
|
89
89
|
], TaxRate.prototype, "tax_region_id", void 0);
|
90
90
|
__decorate([
|
91
91
|
(0, core_1.ManyToOne)({ entity: () => tax_region_1.default, persist: false }),
|
92
|
-
__metadata("design:type",
|
92
|
+
__metadata("design:type", Object)
|
93
93
|
], TaxRate.prototype, "tax_region", void 0);
|
94
94
|
__decorate([
|
95
95
|
(0, core_1.OneToMany)(() => tax_rate_rule_1.default, (rule) => rule.tax_rate, {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { DAL } from "@medusajs/types";
|
2
|
-
import { Collection, OptionalProps } from "@mikro-orm/core";
|
2
|
+
import { Collection, OptionalProps, Rel } from "@mikro-orm/core";
|
3
3
|
import TaxProvider from "./tax-provider";
|
4
4
|
import TaxRate from "./tax-rate";
|
5
5
|
type OptionalTaxRegionProps = DAL.SoftDeletableEntityDateColumns;
|
@@ -10,11 +10,11 @@ export default class TaxRegion {
|
|
10
10
|
[OptionalProps]?: OptionalTaxRegionProps;
|
11
11
|
id: string;
|
12
12
|
provider_id: string | null;
|
13
|
-
provider: TaxProvider
|
13
|
+
provider: Rel<TaxProvider>;
|
14
14
|
country_code: string;
|
15
15
|
province_code: string | null;
|
16
16
|
parent_id: string | null;
|
17
|
-
parent: TaxRegion
|
17
|
+
parent: Rel<TaxRegion>;
|
18
18
|
tax_rates: Collection<TaxRate, object>;
|
19
19
|
children: Collection<TaxRegion, object>;
|
20
20
|
metadata: Record<string, unknown> | null;
|
@@ -59,7 +59,7 @@ __decorate([
|
|
59
59
|
], TaxRegion.prototype, "provider_id", void 0);
|
60
60
|
__decorate([
|
61
61
|
(0, core_1.ManyToOne)(() => tax_provider_1.default, { persist: false }),
|
62
|
-
__metadata("design:type",
|
62
|
+
__metadata("design:type", Object)
|
63
63
|
], TaxRegion.prototype, "provider", void 0);
|
64
64
|
__decorate([
|
65
65
|
(0, utils_1.Searchable)(),
|
@@ -83,7 +83,7 @@ __decorate([
|
|
83
83
|
], TaxRegion.prototype, "parent_id", void 0);
|
84
84
|
__decorate([
|
85
85
|
(0, core_1.ManyToOne)(() => TaxRegion, { persist: false }),
|
86
|
-
__metadata("design:type",
|
86
|
+
__metadata("design:type", Object)
|
87
87
|
], TaxRegion.prototype, "parent", void 0);
|
88
88
|
__decorate([
|
89
89
|
(0, core_1.OneToMany)(() => tax_rate_1.default, (label) => label.tax_region, {
|
@@ -1,15 +1,18 @@
|
|
1
|
-
import { Context, DAL, ITaxModuleService, ITaxProvider,
|
1
|
+
import { Context, DAL, InternalModuleDeclaration, ITaxModuleService, ITaxProvider, ModuleJoinerConfig, ModulesSdkTypes, TaxRegionDTO, TaxTypes } from "@medusajs/types";
|
2
2
|
import { ModulesSdkUtils } from "@medusajs/utils";
|
3
3
|
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "../models";
|
4
4
|
type InjectedDependencies = {
|
5
5
|
baseRepository: DAL.RepositoryService;
|
6
|
-
taxRateService: ModulesSdkTypes.
|
7
|
-
taxRegionService: ModulesSdkTypes.
|
8
|
-
taxRateRuleService: ModulesSdkTypes.
|
9
|
-
taxProviderService: ModulesSdkTypes.
|
6
|
+
taxRateService: ModulesSdkTypes.IMedusaInternalService<any>;
|
7
|
+
taxRegionService: ModulesSdkTypes.IMedusaInternalService<any>;
|
8
|
+
taxRateRuleService: ModulesSdkTypes.IMedusaInternalService<any>;
|
9
|
+
taxProviderService: ModulesSdkTypes.IMedusaInternalService<any>;
|
10
10
|
[key: `tp_${string}`]: ITaxProvider;
|
11
11
|
};
|
12
|
-
declare const TaxModuleService_base: new (
|
12
|
+
declare const TaxModuleService_base: new (...args: any[]) => ModulesSdkUtils.AbstractModuleService<{
|
13
|
+
TaxRate: {
|
14
|
+
dto: TaxTypes.TaxRateDTO;
|
15
|
+
};
|
13
16
|
TaxRegion: {
|
14
17
|
dto: TaxTypes.TaxRegionDTO;
|
15
18
|
};
|
@@ -20,27 +23,27 @@ declare const TaxModuleService_base: new (container: InjectedDependencies) => Mo
|
|
20
23
|
dto: TaxTypes.TaxProviderDTO;
|
21
24
|
};
|
22
25
|
}>;
|
23
|
-
export default class TaxModuleService
|
26
|
+
export default class TaxModuleService extends TaxModuleService_base implements ITaxModuleService {
|
24
27
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
25
28
|
protected readonly container_: InjectedDependencies;
|
26
29
|
protected baseRepository_: DAL.RepositoryService;
|
27
|
-
protected taxRateService_: ModulesSdkTypes.
|
28
|
-
protected taxRegionService_: ModulesSdkTypes.
|
29
|
-
protected taxRateRuleService_: ModulesSdkTypes.
|
30
|
-
protected taxProviderService_: ModulesSdkTypes.
|
30
|
+
protected taxRateService_: ModulesSdkTypes.IMedusaInternalService<TaxRate>;
|
31
|
+
protected taxRegionService_: ModulesSdkTypes.IMedusaInternalService<TaxRegion>;
|
32
|
+
protected taxRateRuleService_: ModulesSdkTypes.IMedusaInternalService<TaxRateRule>;
|
33
|
+
protected taxProviderService_: ModulesSdkTypes.IMedusaInternalService<TaxProvider>;
|
31
34
|
constructor({ baseRepository, taxRateService, taxRegionService, taxRateRuleService, taxProviderService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
32
35
|
__joinerConfig(): ModuleJoinerConfig;
|
33
|
-
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
protected
|
36
|
+
createTaxRates(data: TaxTypes.CreateTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
|
37
|
+
createTaxRates(data: TaxTypes.CreateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
|
38
|
+
protected createTaxRates_(data: TaxTypes.CreateTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
|
39
|
+
updateTaxRates(id: string, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
|
40
|
+
updateTaxRates(ids: string[], data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
|
41
|
+
updateTaxRates(selector: TaxTypes.FilterableTaxRateProps, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
|
42
|
+
protected updateTaxRates_(idOrSelector: string | string[] | TaxTypes.FilterableTaxRateProps, data: TaxTypes.UpdateTaxRateDTO, sharedContext?: Context): Promise<TaxRate>;
|
40
43
|
private setTaxRateRulesForTaxRates;
|
41
44
|
private getTaxRateIdsFromSelector;
|
42
|
-
|
43
|
-
|
45
|
+
upsertTaxRates(data: TaxTypes.UpsertTaxRateDTO[], sharedContext?: Context): Promise<TaxTypes.TaxRateDTO[]>;
|
46
|
+
upsertTaxRates(data: TaxTypes.UpsertTaxRateDTO, sharedContext?: Context): Promise<TaxTypes.TaxRateDTO>;
|
44
47
|
createTaxRegions(data: TaxTypes.CreateTaxRegionDTO, sharedContext?: Context): Promise<TaxRegionDTO>;
|
45
48
|
createTaxRegions(data: TaxTypes.CreateTaxRegionDTO[], sharedContext?: Context): Promise<TaxRegionDTO[]>;
|
46
49
|
createTaxRegions_(data: TaxTypes.CreateTaxRegionDTO[], sharedContext?: Context): Promise<TaxRegionDTO[]>;
|
@@ -52,8 +55,8 @@ export default class TaxModuleService<TTaxRate extends TaxRate = TaxRate, TTaxRe
|
|
52
55
|
private normalizeTaxCalculationContext;
|
53
56
|
private prepareTaxRegionInputForCreate;
|
54
57
|
private verifyProvinceToCountryMatch;
|
55
|
-
private
|
56
|
-
private
|
58
|
+
private geTaxRatesForItem;
|
59
|
+
private geTaxRateQueryForItem;
|
57
60
|
private checkRuleMatches;
|
58
61
|
private prioritizeRates;
|
59
62
|
private normalizeRegionCodes;
|
@@ -16,8 +16,8 @@ const types_1 = require("@medusajs/types");
|
|
16
16
|
const utils_1 = require("@medusajs/utils");
|
17
17
|
const _models_1 = require("../models");
|
18
18
|
const joiner_config_1 = require("../joiner-config");
|
19
|
-
const generateForModels =
|
20
|
-
class TaxModuleService extends utils_1.ModulesSdkUtils.
|
19
|
+
const generateForModels = { TaxRate: _models_1.TaxRate, TaxRegion: _models_1.TaxRegion, TaxRateRule: _models_1.TaxRateRule, TaxProvider: _models_1.TaxProvider };
|
20
|
+
class TaxModuleService extends utils_1.ModulesSdkUtils.MedusaService(generateForModels, joiner_config_1.entityNameToLinkableKeysMap) {
|
21
21
|
constructor({ baseRepository, taxRateService, taxRegionService, taxRateRuleService, taxProviderService, }, moduleDeclaration) {
|
22
22
|
// @ts-ignore
|
23
23
|
super(...arguments);
|
@@ -32,12 +32,12 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
32
32
|
__joinerConfig() {
|
33
33
|
return joiner_config_1.joinerConfig;
|
34
34
|
}
|
35
|
-
async
|
35
|
+
async createTaxRates(data, sharedContext = {}) {
|
36
36
|
const input = Array.isArray(data) ? data : [data];
|
37
|
-
const rates = await this.
|
37
|
+
const rates = await this.createTaxRates_(input, sharedContext);
|
38
38
|
return Array.isArray(data) ? rates : rates[0];
|
39
39
|
}
|
40
|
-
async
|
40
|
+
async createTaxRates_(data, sharedContext = {}) {
|
41
41
|
const [rules, rateData] = data.reduce((acc, region) => {
|
42
42
|
const { rules, ...rest } = region;
|
43
43
|
acc[0].push(rules);
|
@@ -67,12 +67,12 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
67
67
|
populate: true,
|
68
68
|
});
|
69
69
|
}
|
70
|
-
async
|
71
|
-
const rates = await this.
|
70
|
+
async updateTaxRates(selector, data, sharedContext = {}) {
|
71
|
+
const rates = await this.updateTaxRates_(selector, data, sharedContext);
|
72
72
|
const serialized = await this.baseRepository_.serialize(rates, { populate: true });
|
73
73
|
return (0, utils_1.isString)(selector) ? serialized[0] : serialized;
|
74
74
|
}
|
75
|
-
async
|
75
|
+
async updateTaxRates_(idOrSelector, data, sharedContext = {}) {
|
76
76
|
const selector = Array.isArray(idOrSelector) || (0, utils_1.isString)(idOrSelector)
|
77
77
|
? { id: idOrSelector }
|
78
78
|
: idOrSelector;
|
@@ -118,7 +118,7 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
118
118
|
const rates = await this.taxRateService_.list(idOrSelector, { select: ["id"] }, sharedContext);
|
119
119
|
return rates.map((r) => r.id);
|
120
120
|
}
|
121
|
-
async
|
121
|
+
async upsertTaxRates(data, sharedContext = {}) {
|
122
122
|
const result = await this.taxRateService_.upsert(data, sharedContext);
|
123
123
|
const serialized = await this.baseRepository_.serialize(result, { populate: true });
|
124
124
|
return Array.isArray(data) ? serialized : serialized[0];
|
@@ -144,7 +144,7 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
144
144
|
})
|
145
145
|
.filter(Boolean);
|
146
146
|
if (rates.length !== 0) {
|
147
|
-
await this.
|
147
|
+
await this.createTaxRates(rates, sharedContext);
|
148
148
|
}
|
149
149
|
return await this.baseRepository_.serialize(regions, { populate: true });
|
150
150
|
}
|
@@ -179,11 +179,11 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
179
179
|
}
|
180
180
|
const toReturn = await (0, utils_1.promiseAll)(items.map(async (item) => {
|
181
181
|
const regionIds = regions.map((r) => r.id);
|
182
|
-
const rateQuery = this.
|
182
|
+
const rateQuery = this.geTaxRateQueryForItem(item, regionIds);
|
183
183
|
const candidateRates = await this.taxRateService_.list(rateQuery, {
|
184
184
|
relations: ["tax_region", "rules"],
|
185
185
|
}, sharedContext);
|
186
|
-
const applicableRates = await this.
|
186
|
+
const applicableRates = await this.geTaxRatesForItem(item, candidateRates);
|
187
187
|
return {
|
188
188
|
rates: applicableRates,
|
189
189
|
item,
|
@@ -274,7 +274,7 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
274
274
|
}
|
275
275
|
}
|
276
276
|
}
|
277
|
-
async
|
277
|
+
async geTaxRatesForItem(item, rates) {
|
278
278
|
if (!rates.length) {
|
279
279
|
return [];
|
280
280
|
}
|
@@ -294,7 +294,7 @@ class TaxModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFact
|
|
294
294
|
}
|
295
295
|
return ratesToReturn;
|
296
296
|
}
|
297
|
-
|
297
|
+
geTaxRateQueryForItem(item, regionIds) {
|
298
298
|
const isShipping = "shipping_option_id" in item;
|
299
299
|
let ruleQuery = isShipping
|
300
300
|
? [
|
@@ -391,35 +391,35 @@ __decorate([
|
|
391
391
|
__metadata("design:type", Function),
|
392
392
|
__metadata("design:paramtypes", [Object, Object]),
|
393
393
|
__metadata("design:returntype", Promise)
|
394
|
-
], TaxModuleService.prototype, "
|
394
|
+
], TaxModuleService.prototype, "createTaxRates", null);
|
395
395
|
__decorate([
|
396
396
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
397
397
|
__param(1, (0, utils_1.MedusaContext)()),
|
398
398
|
__metadata("design:type", Function),
|
399
399
|
__metadata("design:paramtypes", [Array, Object]),
|
400
400
|
__metadata("design:returntype", Promise)
|
401
|
-
], TaxModuleService.prototype, "
|
401
|
+
], TaxModuleService.prototype, "createTaxRates_", null);
|
402
402
|
__decorate([
|
403
403
|
(0, utils_1.InjectManager)("baseRepository_"),
|
404
404
|
__param(2, (0, utils_1.MedusaContext)()),
|
405
405
|
__metadata("design:type", Function),
|
406
406
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
407
407
|
__metadata("design:returntype", Promise)
|
408
|
-
], TaxModuleService.prototype, "
|
408
|
+
], TaxModuleService.prototype, "updateTaxRates", null);
|
409
409
|
__decorate([
|
410
410
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
411
411
|
__param(2, (0, utils_1.MedusaContext)()),
|
412
412
|
__metadata("design:type", Function),
|
413
413
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
414
414
|
__metadata("design:returntype", Promise)
|
415
|
-
], TaxModuleService.prototype, "
|
415
|
+
], TaxModuleService.prototype, "updateTaxRates_", null);
|
416
416
|
__decorate([
|
417
417
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
418
418
|
__param(1, (0, utils_1.MedusaContext)()),
|
419
419
|
__metadata("design:type", Function),
|
420
420
|
__metadata("design:paramtypes", [Object, Object]),
|
421
421
|
__metadata("design:returntype", Promise)
|
422
|
-
], TaxModuleService.prototype, "
|
422
|
+
], TaxModuleService.prototype, "upsertTaxRates", null);
|
423
423
|
__decorate([
|
424
424
|
(0, utils_1.InjectManager)("baseRepository_"),
|
425
425
|
__param(1, (0, utils_1.MedusaContext)()),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/tax",
|
3
|
-
"version": "0.1.2-snapshot-
|
3
|
+
"version": "0.1.2-snapshot-20240701122250",
|
4
4
|
"description": "Medusa Tax module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -8,10 +8,7 @@
|
|
8
8
|
"dist"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
|
-
"node": ">=
|
12
|
-
},
|
13
|
-
"bin": {
|
14
|
-
"medusa-tax-seed": "dist/scripts/bin/run-seed.js"
|
11
|
+
"node": ">=20"
|
15
12
|
},
|
16
13
|
"repository": {
|
17
14
|
"type": "git",
|
@@ -39,18 +36,17 @@
|
|
39
36
|
"devDependencies": {
|
40
37
|
"@mikro-orm/cli": "5.9.7",
|
41
38
|
"cross-env": "^5.2.1",
|
42
|
-
"jest": "^29.
|
43
|
-
"medusa-test-utils": "1.1.45-snapshot-
|
39
|
+
"jest": "^29.7.0",
|
40
|
+
"medusa-test-utils": "1.1.45-snapshot-20240701122250",
|
44
41
|
"rimraf": "^3.0.2",
|
45
|
-
"ts-jest": "^29.1.1",
|
46
42
|
"ts-node": "^10.9.1",
|
47
43
|
"tsc-alias": "^1.8.6",
|
48
44
|
"typescript": "^5.1.6"
|
49
45
|
},
|
50
46
|
"dependencies": {
|
51
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
52
|
-
"@medusajs/types": "1.12.0-snapshot-
|
53
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
47
|
+
"@medusajs/modules-sdk": "1.13.0-snapshot-20240701122250",
|
48
|
+
"@medusajs/types": "1.12.0-snapshot-20240701122250",
|
49
|
+
"@medusajs/utils": "1.12.0-snapshot-20240701122250",
|
54
50
|
"@mikro-orm/core": "5.9.7",
|
55
51
|
"@mikro-orm/migrations": "5.9.7",
|
56
52
|
"@mikro-orm/postgresql": "5.9.7",
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.moduleDefinition = void 0;
|
7
|
-
const _services_1 = require("./services");
|
8
|
-
const providers_1 = __importDefault(require("./loaders/providers"));
|
9
|
-
const service = _services_1.TaxModuleService;
|
10
|
-
const loaders = [providers_1.default];
|
11
|
-
exports.moduleDefinition = {
|
12
|
-
service,
|
13
|
-
loaders,
|
14
|
-
};
|
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
-
if (k2 === undefined) k2 = k;
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
-
}
|
9
|
-
Object.defineProperty(o, k2, desc);
|
10
|
-
}) : (function(o, m, k, k2) {
|
11
|
-
if (k2 === undefined) k2 = k;
|
12
|
-
o[k2] = m[k];
|
13
|
-
}));
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
16
|
-
}) : function(o, v) {
|
17
|
-
o["default"] = v;
|
18
|
-
});
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
20
|
-
if (mod && mod.__esModule) return mod;
|
21
|
-
var result = {};
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
23
|
-
__setModuleDefault(result, mod);
|
24
|
-
return result;
|
25
|
-
};
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
27
|
-
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
28
|
-
const utils_1 = require("@medusajs/utils");
|
29
|
-
const Models = __importStar(require("../../models"));
|
30
|
-
const os_1 = require("os");
|
31
|
-
const args = process.argv;
|
32
|
-
const path = args.pop();
|
33
|
-
exports.default = (async () => {
|
34
|
-
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
35
|
-
config();
|
36
|
-
if (!path) {
|
37
|
-
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-tax-seed <filePath>`);
|
38
|
-
}
|
39
|
-
const run = utils_1.ModulesSdkUtils.buildSeedScript({
|
40
|
-
moduleName: modules_sdk_1.Modules.TAX,
|
41
|
-
models: Models,
|
42
|
-
pathToMigrations: __dirname + "/../../migrations",
|
43
|
-
seedHandler: async ({ manager, data }) => {
|
44
|
-
// TODO: Add seed logic
|
45
|
-
},
|
46
|
-
});
|
47
|
-
await run({ path });
|
48
|
-
})();
|