@medusajs/region 0.1.2-snapshot-20240607093839 → 0.1.2-snapshot-20240701122250
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -2
- package/dist/joiner-config.d.ts +1 -6
- package/dist/joiner-config.js +4 -31
- package/dist/migrations/Migration20240624200006.d.ts +5 -0
- package/dist/migrations/Migration20240624200006.js +19 -0
- package/dist/models/country.d.ts +138 -10
- package/dist/models/country.js +20 -61
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/region.d.ts +104 -19
- package/dist/models/region.js +8 -88
- package/dist/services/region-module.d.ts +20 -17
- package/dist/services/region-module.js +35 -16
- package/package.json +6 -10
- package/dist/module-definition.d.ts +0 -2
- package/dist/module-definition.js +0 -14
- package/dist/repositories/index.d.ts +0 -1
- package/dist/repositories/index.js +0 -5
- package/dist/scripts/bin/run-seed.d.ts +0 -3
- package/dist/scripts/bin/run-seed.js +0 -50
- package/dist/scripts/seed-utils.d.ts +0 -4
- package/dist/scripts/seed-utils.js +0 -12
- /package/dist/migrations/{RegionModuleSetup20240205173216.d.ts → Migration20240205173216.d.ts} +0 -0
- /package/dist/migrations/{RegionModuleSetup20240205173216.js → Migration20240205173216.js} +0 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const
|
4
|
-
|
6
|
+
const services_1 = require("./services");
|
7
|
+
const defaults_1 = __importDefault(require("./loaders/defaults"));
|
8
|
+
const moduleDefinition = {
|
9
|
+
service: services_1.RegionModuleService,
|
10
|
+
loaders: [defaults_1.default],
|
11
|
+
};
|
12
|
+
exports.default = moduleDefinition;
|
package/dist/joiner-config.d.ts
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
import { ModuleJoinerConfig } from "@medusajs/types";
|
2
1
|
import { MapToConfig } from "@medusajs/utils";
|
3
|
-
export declare const
|
4
|
-
region_id: string;
|
5
|
-
country_iso: string;
|
6
|
-
};
|
2
|
+
export declare const joinerConfig: Omit<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys"> & Required<Pick<import("@medusajs/types").ModuleJoinerConfig, "serviceName" | "primaryKeys" | "alias" | "linkableKeys">>;
|
7
3
|
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
8
|
-
export declare const joinerConfig: ModuleJoinerConfig;
|
package/dist/joiner-config.js
CHANGED
@@ -1,33 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
const
|
5
|
-
|
6
|
-
exports.
|
7
|
-
region_id: _models_1.Region.name,
|
8
|
-
country_iso: _models_1.Country.name,
|
9
|
-
};
|
10
|
-
const entityLinkableKeysMap = {};
|
11
|
-
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
12
|
-
entityLinkableKeysMap[value] ??= [];
|
13
|
-
entityLinkableKeysMap[value].push({
|
14
|
-
mapTo: key,
|
15
|
-
valueFrom: key.split("_").pop(),
|
16
|
-
});
|
17
|
-
});
|
18
|
-
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
19
|
-
exports.joinerConfig = {
|
20
|
-
serviceName: modules_sdk_1.Modules.REGION,
|
21
|
-
primaryKeys: ["id"],
|
22
|
-
linkableKeys: exports.LinkableKeys,
|
23
|
-
alias: [
|
24
|
-
{
|
25
|
-
name: ["region", "regions"],
|
26
|
-
args: { entity: _models_1.Region.name },
|
27
|
-
},
|
28
|
-
{
|
29
|
-
name: ["country", "countries"],
|
30
|
-
args: { entity: _models_1.Country.name, methodSuffix: "Countries" },
|
31
|
-
},
|
32
|
-
],
|
33
|
-
};
|
3
|
+
exports.entityNameToLinkableKeysMap = exports.joinerConfig = void 0;
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
exports.joinerConfig = (0, utils_1.defineJoinerConfig)(utils_1.Modules.REGION);
|
6
|
+
exports.entityNameToLinkableKeysMap = (0, utils_1.buildEntitiesNameToLinkableKeysMap)(exports.joinerConfig.linkableKeys);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Migration20240624200006 = void 0;
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
6
|
+
class Migration20240624200006 extends migrations_1.Migration {
|
7
|
+
async up() {
|
8
|
+
this.addSql('ALTER TABLE IF EXISTS "region_country" ADD COLUMN IF NOT EXISTS "metadata" jsonb null, ADD COLUMN "created_at" timestamptz NOT NULL DEFAULT NOW(), ADD COLUMN "updated_at" timestamptz NOT NULL DEFAULT NOW(), ADD COLUMN "deleted_at" timestamptz NULL;');
|
9
|
+
this.addSql((0, utils_1.generatePostgresAlterColummnIfExistStatement)("region_country", ["region_id"], `DROP NOT NULL`));
|
10
|
+
}
|
11
|
+
async down() {
|
12
|
+
this.addSql('ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "metadata";');
|
13
|
+
this.addSql('ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "created_at";');
|
14
|
+
this.addSql('ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "updated_at";');
|
15
|
+
this.addSql('ALTER TABLE IF EXISTS "region_country" DROP COLUMN IF EXISTS "deleted_at";');
|
16
|
+
this.addSql((0, utils_1.generatePostgresAlterColummnIfExistStatement)("region_country", ["region_id"], `SET NOT NULL`));
|
17
|
+
}
|
18
|
+
}
|
19
|
+
exports.Migration20240624200006 = Migration20240624200006;
|
package/dist/models/country.d.ts
CHANGED
@@ -1,10 +1,138 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
declare const Country: import("@medusajs/utils").DmlEntity<{
|
2
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
3
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
4
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
5
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
6
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
7
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<{
|
8
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
9
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
10
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
11
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
12
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
|
13
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
14
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
15
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
16
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
17
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
18
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
19
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
20
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
21
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
22
|
+
} & {
|
23
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
24
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
25
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
26
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
27
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
|
28
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
29
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
30
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
31
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
32
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
33
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
34
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
35
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
36
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
37
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
|
38
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
39
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
40
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
41
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
42
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
|
43
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
44
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
45
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
46
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
47
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
48
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
49
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
50
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
51
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
52
|
+
} & {
|
53
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
54
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
55
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
56
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
57
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
|
58
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
59
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
60
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
61
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
62
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
63
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
64
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
65
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
66
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
67
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
68
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
69
|
+
} & {
|
70
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
71
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
72
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
73
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
74
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
75
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<{
|
76
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
77
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
78
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
79
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
80
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
81
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
82
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
83
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
84
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
85
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
86
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
87
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
88
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
89
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
90
|
+
} & {
|
91
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
92
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
93
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
94
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
95
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
96
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
97
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
98
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
99
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
100
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
101
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
102
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
103
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
104
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
105
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
|
106
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
107
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
108
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
109
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
110
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
111
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
112
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
113
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
114
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
115
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
116
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
117
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
118
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
119
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
120
|
+
} & {
|
121
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
122
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
123
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
124
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
125
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
126
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
127
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
128
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
129
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
130
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
131
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
|
132
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
133
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
134
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
135
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
136
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
137
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>;
|
138
|
+
export default Country;
|
package/dist/models/country.js
CHANGED
@@ -1,69 +1,28 @@
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const core_1 = require("@mikro-orm/core");
|
16
6
|
const utils_1 = require("@medusajs/utils");
|
17
7
|
const region_1 = __importDefault(require("./region"));
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
(0, core_1.Property)({ columnType: "text" }),
|
39
|
-
__metadata("design:type", String)
|
40
|
-
], Country.prototype, "iso_3", void 0);
|
41
|
-
__decorate([
|
42
|
-
(0, core_1.Property)({ columnType: "text" }),
|
43
|
-
__metadata("design:type", String)
|
44
|
-
], Country.prototype, "num_code", void 0);
|
45
|
-
__decorate([
|
46
|
-
(0, core_1.Property)({ columnType: "text" }),
|
47
|
-
__metadata("design:type", String)
|
48
|
-
], Country.prototype, "name", void 0);
|
49
|
-
__decorate([
|
50
|
-
(0, core_1.Property)({ columnType: "text" }),
|
51
|
-
__metadata("design:type", String)
|
52
|
-
], Country.prototype, "display_name", void 0);
|
53
|
-
__decorate([
|
54
|
-
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
55
|
-
__metadata("design:type", Object)
|
56
|
-
], Country.prototype, "region_id", void 0);
|
57
|
-
__decorate([
|
58
|
-
(0, core_1.ManyToOne)({
|
59
|
-
entity: () => region_1.default,
|
60
|
-
fieldName: "region_id",
|
61
|
-
nullable: true,
|
62
|
-
onDelete: "set null",
|
63
|
-
}),
|
64
|
-
__metadata("design:type", Object)
|
65
|
-
], Country.prototype, "region", void 0);
|
66
|
-
Country = __decorate([
|
67
|
-
(0, core_1.Entity)({ tableName: "region_country" })
|
68
|
-
], Country);
|
8
|
+
const Country = utils_1.model
|
9
|
+
.define({ name: "Country", tableName: "region_country" }, {
|
10
|
+
iso_2: utils_1.model.text().searchable().primaryKey(),
|
11
|
+
iso_3: utils_1.model.text(),
|
12
|
+
num_code: utils_1.model.text(),
|
13
|
+
name: utils_1.model.text().searchable(),
|
14
|
+
display_name: utils_1.model.text(),
|
15
|
+
region: utils_1.model
|
16
|
+
.belongsTo(() => region_1.default, { mappedBy: "countries" })
|
17
|
+
.nullable(),
|
18
|
+
metadata: utils_1.model.json().nullable(),
|
19
|
+
})
|
20
|
+
.indexes([
|
21
|
+
{
|
22
|
+
// TODO: Remove ts-ignore when field inference takes into account the nullable property
|
23
|
+
// @ts-ignore
|
24
|
+
on: ["region_id", "iso_2"],
|
25
|
+
unique: true,
|
26
|
+
},
|
27
|
+
]);
|
69
28
|
exports.default = Country;
|
package/dist/models/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export { default as
|
1
|
+
export { default as RegionCountry } from "./country";
|
2
2
|
export { default as Region } from "./region";
|
package/dist/models/index.js
CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.Region = exports.
|
6
|
+
exports.Region = exports.RegionCountry = void 0;
|
7
7
|
var country_1 = require("./country");
|
8
|
-
Object.defineProperty(exports, "
|
8
|
+
Object.defineProperty(exports, "RegionCountry", { enumerable: true, get: function () { return __importDefault(country_1).default; } });
|
9
9
|
var region_1 = require("./region");
|
10
10
|
Object.defineProperty(exports, "Region", { enumerable: true, get: function () { return __importDefault(region_1).default; } });
|
package/dist/models/region.d.ts
CHANGED
@@ -1,19 +1,104 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
declare const Region: import("@medusajs/utils").DmlEntity<{
|
2
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
3
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
4
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
5
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
6
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
7
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
8
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
9
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
10
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
11
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
12
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<any & {
|
13
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
14
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
15
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
16
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
17
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
18
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
19
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<any & {
|
20
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
21
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
22
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
23
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
24
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
25
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
26
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
27
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
28
|
+
} & {
|
29
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
30
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
31
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
32
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
33
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
34
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<any & {
|
35
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
36
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
37
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
38
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
39
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
40
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
41
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<any & {
|
42
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
43
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
44
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
45
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
46
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
47
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
48
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
49
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
50
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
51
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
52
|
+
} & {
|
53
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
54
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
55
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
56
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
57
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
|
58
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
59
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
60
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
61
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
62
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
63
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<{
|
64
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
65
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
66
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
67
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
68
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
69
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
70
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
|
71
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
72
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
73
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
74
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
75
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
76
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
77
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
78
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
79
|
+
} & {
|
80
|
+
iso_2: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
81
|
+
iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
82
|
+
num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
83
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
84
|
+
display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
85
|
+
region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<{
|
86
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
87
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
88
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
89
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
90
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
91
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
92
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
|
93
|
+
id: import("@medusajs/utils/dist/dml/properties/id").IdProperty;
|
94
|
+
name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
95
|
+
currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
|
96
|
+
automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
|
97
|
+
countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<any>;
|
98
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
99
|
+
} & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>>;
|
100
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
101
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>>;
|
102
|
+
metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
|
103
|
+
} & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults>;
|
104
|
+
export default Region;
|
package/dist/models/region.js
CHANGED
@@ -1,96 +1,16 @@
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
6
|
const utils_1 = require("@medusajs/utils");
|
16
|
-
const core_1 = require("@mikro-orm/core");
|
17
7
|
const country_1 = __importDefault(require("./country"));
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "reg");
|
27
|
-
}
|
28
|
-
onInit() {
|
29
|
-
this.id = (0, utils_1.generateEntityId)(this.id, "reg");
|
30
|
-
}
|
31
|
-
};
|
32
|
-
__decorate([
|
33
|
-
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
34
|
-
__metadata("design:type", String)
|
35
|
-
], Region.prototype, "id", void 0);
|
36
|
-
__decorate([
|
37
|
-
(0, utils_1.Searchable)(),
|
38
|
-
(0, core_1.Property)({ columnType: "text" }),
|
39
|
-
__metadata("design:type", String)
|
40
|
-
], Region.prototype, "name", void 0);
|
41
|
-
__decorate([
|
42
|
-
(0, utils_1.Searchable)(),
|
43
|
-
(0, core_1.Property)({ columnType: "text" }),
|
44
|
-
__metadata("design:type", String)
|
45
|
-
], Region.prototype, "currency_code", void 0);
|
46
|
-
__decorate([
|
47
|
-
(0, core_1.Property)({ columnType: "boolean" }),
|
48
|
-
__metadata("design:type", Object)
|
49
|
-
], Region.prototype, "automatic_taxes", void 0);
|
50
|
-
__decorate([
|
51
|
-
(0, core_1.OneToMany)(() => country_1.default, (country) => country.region),
|
52
|
-
__metadata("design:type", Object)
|
53
|
-
], Region.prototype, "countries", void 0);
|
54
|
-
__decorate([
|
55
|
-
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
56
|
-
__metadata("design:type", Object)
|
57
|
-
], Region.prototype, "metadata", void 0);
|
58
|
-
__decorate([
|
59
|
-
(0, core_1.Property)({
|
60
|
-
onCreate: () => new Date(),
|
61
|
-
columnType: "timestamptz",
|
62
|
-
defaultRaw: "now()",
|
63
|
-
}),
|
64
|
-
__metadata("design:type", Date)
|
65
|
-
], Region.prototype, "created_at", void 0);
|
66
|
-
__decorate([
|
67
|
-
(0, core_1.Property)({
|
68
|
-
onCreate: () => new Date(),
|
69
|
-
onUpdate: () => new Date(),
|
70
|
-
columnType: "timestamptz",
|
71
|
-
defaultRaw: "now()",
|
72
|
-
}),
|
73
|
-
__metadata("design:type", Date)
|
74
|
-
], Region.prototype, "updated_at", void 0);
|
75
|
-
__decorate([
|
76
|
-
(0, core_1.Index)({ name: "IDX_region_deleted_at" }),
|
77
|
-
(0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
|
78
|
-
__metadata("design:type", Object)
|
79
|
-
], Region.prototype, "deleted_at", void 0);
|
80
|
-
__decorate([
|
81
|
-
(0, core_1.BeforeCreate)(),
|
82
|
-
__metadata("design:type", Function),
|
83
|
-
__metadata("design:paramtypes", []),
|
84
|
-
__metadata("design:returntype", void 0)
|
85
|
-
], Region.prototype, "onCreate", null);
|
86
|
-
__decorate([
|
87
|
-
(0, core_1.OnInit)(),
|
88
|
-
__metadata("design:type", Function),
|
89
|
-
__metadata("design:paramtypes", []),
|
90
|
-
__metadata("design:returntype", void 0)
|
91
|
-
], Region.prototype, "onInit", null);
|
92
|
-
Region = __decorate([
|
93
|
-
(0, core_1.Entity)({ tableName: "region" }),
|
94
|
-
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
95
|
-
], Region);
|
8
|
+
const Region = utils_1.model.define("region", {
|
9
|
+
id: utils_1.model.id({ prefix: "reg" }),
|
10
|
+
name: utils_1.model.text().searchable(),
|
11
|
+
currency_code: utils_1.model.text().searchable(),
|
12
|
+
automatic_taxes: utils_1.model.boolean().default(true),
|
13
|
+
countries: utils_1.model.hasMany(() => country_1.default),
|
14
|
+
metadata: utils_1.model.json().nullable(),
|
15
|
+
});
|
96
16
|
exports.default = Region;
|
@@ -1,32 +1,35 @@
|
|
1
|
-
import { Context, CreateRegionDTO, DAL, FilterableRegionProps,
|
2
|
-
import {
|
3
|
-
import { Country, Region } from "../models";
|
1
|
+
import { Context, CreateRegionDTO, DAL, FilterableRegionProps, IRegionModuleService, InferEntityType, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes, RegionCountryDTO, RegionDTO, SoftDeleteReturn, UpdateRegionDTO, UpsertRegionDTO } from "@medusajs/types";
|
2
|
+
import { RegionCountry as Country, Region } from "../models";
|
4
3
|
import { UpdateRegionInput } from "../types";
|
5
4
|
type InjectedDependencies = {
|
6
5
|
baseRepository: DAL.RepositoryService;
|
7
|
-
regionService: ModulesSdkTypes.
|
8
|
-
countryService: ModulesSdkTypes.
|
6
|
+
regionService: ModulesSdkTypes.IMedusaInternalService<any>;
|
7
|
+
countryService: ModulesSdkTypes.IMedusaInternalService<any>;
|
9
8
|
};
|
10
|
-
declare const RegionModuleService_base: new (
|
9
|
+
declare const RegionModuleService_base: new (...args: any[]) => import("@medusajs/utils").AbstractModuleService<{
|
10
|
+
Region: {
|
11
|
+
dto: RegionDTO;
|
12
|
+
};
|
11
13
|
Country: {
|
12
14
|
dto: RegionCountryDTO;
|
13
15
|
};
|
14
16
|
}>;
|
15
|
-
export default class RegionModuleService
|
17
|
+
export default class RegionModuleService extends RegionModuleService_base implements IRegionModuleService {
|
16
18
|
protected readonly moduleDeclaration: InternalModuleDeclaration;
|
17
19
|
protected baseRepository_: DAL.RepositoryService;
|
18
|
-
protected readonly regionService_: ModulesSdkTypes.
|
19
|
-
protected readonly countryService_: ModulesSdkTypes.
|
20
|
+
protected readonly regionService_: ModulesSdkTypes.IMedusaInternalService<typeof Region>;
|
21
|
+
protected readonly countryService_: ModulesSdkTypes.IMedusaInternalService<typeof Country>;
|
20
22
|
constructor({ baseRepository, regionService, countryService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
|
21
23
|
__joinerConfig(): ModuleJoinerConfig;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
createRegions(data: CreateRegionDTO[], sharedContext?: Context): Promise<RegionDTO[]>;
|
25
|
+
createRegions(data: CreateRegionDTO, sharedContext?: Context): Promise<RegionDTO>;
|
26
|
+
createRegions_(data: CreateRegionDTO[], sharedContext?: Context): Promise<InferEntityType<typeof Region>[]>;
|
27
|
+
softDeleteRegions(ids: string | object | string[] | object[], config?: SoftDeleteReturn<string>, sharedContext?: Context): Promise<Record<string, string[]> | void>;
|
28
|
+
upsertRegions(data: UpsertRegionDTO[], sharedContext?: Context): Promise<RegionDTO[]>;
|
29
|
+
upsertRegions(data: UpsertRegionDTO, sharedContext?: Context): Promise<RegionDTO>;
|
30
|
+
updateRegions(id: string, data: UpdateRegionDTO, sharedContext?: Context): Promise<RegionDTO>;
|
31
|
+
updateRegions(selector: FilterableRegionProps, data: UpdateRegionDTO, sharedContext?: Context): Promise<RegionDTO[]>;
|
32
|
+
protected updateRegions_(data: UpdateRegionInput[], sharedContext?: Context): Promise<InferEntityType<typeof Region>[]>;
|
30
33
|
private static normalizeInput;
|
31
34
|
/**
|
32
35
|
* Validate that countries can be assigned to a region.
|
@@ -15,8 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const utils_1 = require("@medusajs/utils");
|
16
16
|
const _models_1 = require("../models");
|
17
17
|
const joiner_config_1 = require("../joiner-config");
|
18
|
-
|
19
|
-
class RegionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceFactory(_models_1.Region, generateMethodForModels, joiner_config_1.entityNameToLinkableKeysMap) {
|
18
|
+
class RegionModuleService extends (0, utils_1.MedusaService)({ Region: _models_1.Region, Country: _models_1.RegionCountry }, joiner_config_1.entityNameToLinkableKeysMap) {
|
20
19
|
constructor({ baseRepository, regionService, countryService }, moduleDeclaration) {
|
21
20
|
// @ts-ignore
|
22
21
|
super(...arguments);
|
@@ -28,12 +27,12 @@ class RegionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
|
|
28
27
|
__joinerConfig() {
|
29
28
|
return joiner_config_1.joinerConfig;
|
30
29
|
}
|
31
|
-
async
|
30
|
+
async createRegions(data, sharedContext = {}) {
|
32
31
|
const input = Array.isArray(data) ? data : [data];
|
33
|
-
const result = await this.
|
32
|
+
const result = await this.createRegions_(input, sharedContext);
|
34
33
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
35
34
|
}
|
36
|
-
async
|
35
|
+
async createRegions_(data, sharedContext = {}) {
|
37
36
|
let normalizedInput = RegionModuleService.normalizeInput(data);
|
38
37
|
let normalizedDbRegions = normalizedInput.map((region) => (0, utils_1.removeUndefined)({
|
39
38
|
...region,
|
@@ -51,21 +50,31 @@ class RegionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
|
|
51
50
|
}
|
52
51
|
return result;
|
53
52
|
}
|
54
|
-
|
53
|
+
// @ts-ignore
|
54
|
+
async softDeleteRegions(ids, config, sharedContext = {}) {
|
55
|
+
const result = await super.softDeleteRegions(ids, config, sharedContext);
|
56
|
+
// Note: You cannot revert the state of a region by simply restoring it. The association with countries is lost.
|
57
|
+
await super.updateCountries({
|
58
|
+
selector: { region_id: ids },
|
59
|
+
data: { region_id: null },
|
60
|
+
}, sharedContext);
|
61
|
+
return result;
|
62
|
+
}
|
63
|
+
async upsertRegions(data, sharedContext = {}) {
|
55
64
|
const input = Array.isArray(data) ? data : [data];
|
56
65
|
const forUpdate = input.filter((region) => !!region.id);
|
57
66
|
const forCreate = input.filter((region) => !region.id);
|
58
67
|
const operations = [];
|
59
68
|
if (forCreate.length) {
|
60
|
-
operations.push(this.
|
69
|
+
operations.push(this.createRegions_(forCreate, sharedContext));
|
61
70
|
}
|
62
71
|
if (forUpdate.length) {
|
63
|
-
operations.push(this.
|
72
|
+
operations.push(this.updateRegions_(forUpdate, sharedContext));
|
64
73
|
}
|
65
74
|
const result = (await (0, utils_1.promiseAll)(operations)).flat();
|
66
75
|
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0]);
|
67
76
|
}
|
68
|
-
async
|
77
|
+
async updateRegions(idOrSelector, data, sharedContext = {}) {
|
69
78
|
let normalizedInput = [];
|
70
79
|
if ((0, utils_1.isString)(idOrSelector)) {
|
71
80
|
normalizedInput = [{ id: idOrSelector, ...data }];
|
@@ -77,11 +86,11 @@ class RegionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
|
|
77
86
|
...data,
|
78
87
|
}));
|
79
88
|
}
|
80
|
-
const updateResult = await this.
|
89
|
+
const updateResult = await this.updateRegions_(normalizedInput, sharedContext);
|
81
90
|
const regions = await this.baseRepository_.serialize(updateResult);
|
82
91
|
return (0, utils_1.isString)(idOrSelector) ? regions[0] : regions;
|
83
92
|
}
|
84
|
-
async
|
93
|
+
async updateRegions_(data, sharedContext = {}) {
|
85
94
|
const normalizedInput = RegionModuleService.normalizeInput(data);
|
86
95
|
// If countries are being updated for a region, first make previously set countries' region to null to get to a clean slate.
|
87
96
|
// Somewhat less efficient, but region operations will be very rare, so it is better to go with a simple solution
|
@@ -143,6 +152,7 @@ class RegionModuleService extends utils_1.ModulesSdkUtils.abstractModuleServiceF
|
|
143
152
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Countries with codes: "${missingCountries.join(", ")}" do not exist`);
|
144
153
|
}
|
145
154
|
// Countries that already have a region already assigned to them
|
155
|
+
// @ts-ignore
|
146
156
|
const countriesWithRegion = countriesInDb.filter((c) => !!c.region_id);
|
147
157
|
if (countriesWithRegion.length) {
|
148
158
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Countries with codes: "${countriesWithRegion
|
@@ -159,32 +169,41 @@ __decorate([
|
|
159
169
|
__metadata("design:type", Function),
|
160
170
|
__metadata("design:paramtypes", [Object, Object]),
|
161
171
|
__metadata("design:returntype", Promise)
|
162
|
-
], RegionModuleService.prototype, "
|
172
|
+
], RegionModuleService.prototype, "createRegions", null);
|
163
173
|
__decorate([
|
164
174
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
165
175
|
__param(1, (0, utils_1.MedusaContext)()),
|
166
176
|
__metadata("design:type", Function),
|
167
177
|
__metadata("design:paramtypes", [Array, Object]),
|
168
178
|
__metadata("design:returntype", Promise)
|
169
|
-
], RegionModuleService.prototype, "
|
179
|
+
], RegionModuleService.prototype, "createRegions_", null);
|
180
|
+
__decorate([
|
181
|
+
(0, utils_1.InjectManager)("baseRepository_")
|
182
|
+
// @ts-ignore
|
183
|
+
,
|
184
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
185
|
+
__metadata("design:type", Function),
|
186
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
187
|
+
__metadata("design:returntype", Promise)
|
188
|
+
], RegionModuleService.prototype, "softDeleteRegions", null);
|
170
189
|
__decorate([
|
171
190
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
172
191
|
__param(1, (0, utils_1.MedusaContext)()),
|
173
192
|
__metadata("design:type", Function),
|
174
193
|
__metadata("design:paramtypes", [Object, Object]),
|
175
194
|
__metadata("design:returntype", Promise)
|
176
|
-
], RegionModuleService.prototype, "
|
195
|
+
], RegionModuleService.prototype, "upsertRegions", null);
|
177
196
|
__decorate([
|
178
197
|
(0, utils_1.InjectManager)("baseRepository_"),
|
179
198
|
__param(2, (0, utils_1.MedusaContext)()),
|
180
199
|
__metadata("design:type", Function),
|
181
200
|
__metadata("design:paramtypes", [Object, Object, Object]),
|
182
201
|
__metadata("design:returntype", Promise)
|
183
|
-
], RegionModuleService.prototype, "
|
202
|
+
], RegionModuleService.prototype, "updateRegions", null);
|
184
203
|
__decorate([
|
185
204
|
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
186
205
|
__param(1, (0, utils_1.MedusaContext)()),
|
187
206
|
__metadata("design:type", Function),
|
188
207
|
__metadata("design:paramtypes", [Array, Object]),
|
189
208
|
__metadata("design:returntype", Promise)
|
190
|
-
], RegionModuleService.prototype, "
|
209
|
+
], RegionModuleService.prototype, "updateRegions_", null);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/region",
|
3
|
-
"version": "0.1.2-snapshot-
|
3
|
+
"version": "0.1.2-snapshot-20240701122250",
|
4
4
|
"description": "Medusa Region 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-region-seed": "dist/scripts/bin/run-seed.js"
|
11
|
+
"node": ">=20"
|
15
12
|
},
|
16
13
|
"repository": {
|
17
14
|
"type": "git",
|
@@ -37,20 +34,19 @@
|
|
37
34
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
38
35
|
},
|
39
36
|
"devDependencies": {
|
40
|
-
"@medusajs/types": "1.12.0-snapshot-
|
37
|
+
"@medusajs/types": "1.12.0-snapshot-20240701122250",
|
41
38
|
"@mikro-orm/cli": "5.9.7",
|
42
39
|
"cross-env": "^5.2.1",
|
43
|
-
"jest": "^29.
|
40
|
+
"jest": "^29.7.0",
|
44
41
|
"medusa-test-utils": "workspace:^",
|
45
42
|
"rimraf": "^3.0.2",
|
46
|
-
"ts-jest": "^29.1.1",
|
47
43
|
"ts-node": "^10.9.1",
|
48
44
|
"tsc-alias": "^1.8.6",
|
49
45
|
"typescript": "^5.1.6"
|
50
46
|
},
|
51
47
|
"dependencies": {
|
52
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
53
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
48
|
+
"@medusajs/modules-sdk": "1.13.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 defaults_1 = __importDefault(require("./loaders/defaults"));
|
9
|
-
const service = services_1.RegionModuleService;
|
10
|
-
const loaders = [defaults_1.default];
|
11
|
-
exports.moduleDefinition = {
|
12
|
-
service,
|
13
|
-
loaders,
|
14
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
|
@@ -1,5 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BaseRepository = void 0;
|
4
|
-
var utils_1 = require("@medusajs/utils");
|
5
|
-
Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
|
@@ -1,50 +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 RegionModels = __importStar(require("../../models"));
|
30
|
-
const os_1 = require("os");
|
31
|
-
const seed_utils_1 = require("../seed-utils");
|
32
|
-
const args = process.argv;
|
33
|
-
const path = args.pop();
|
34
|
-
exports.default = (async () => {
|
35
|
-
const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
|
36
|
-
config();
|
37
|
-
if (!path) {
|
38
|
-
throw new Error(`filePath is required.${os_1.EOL}Example: medusa-region-seed <filePath>`);
|
39
|
-
}
|
40
|
-
const run = utils_1.ModulesSdkUtils.buildSeedScript({
|
41
|
-
moduleName: modules_sdk_1.Modules.REGION,
|
42
|
-
models: RegionModels,
|
43
|
-
pathToMigrations: __dirname + "/../../migrations",
|
44
|
-
seedHandler: async ({ manager, data }) => {
|
45
|
-
const { regionData } = data;
|
46
|
-
await (0, seed_utils_1.createRegions)(manager, regionData);
|
47
|
-
},
|
48
|
-
});
|
49
|
-
await run({ path });
|
50
|
-
})();
|
@@ -1,4 +0,0 @@
|
|
1
|
-
import { RequiredEntityData } from "@mikro-orm/core";
|
2
|
-
import { SqlEntityManager } from "@mikro-orm/postgresql";
|
3
|
-
import { Region } from "../models";
|
4
|
-
export declare function createRegions(manager: SqlEntityManager, data: RequiredEntityData<Region>[]): Promise<Region[]>;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createRegions = void 0;
|
4
|
-
const _models_1 = require("../models");
|
5
|
-
async function createRegions(manager, data) {
|
6
|
-
const regions = data.map((region) => {
|
7
|
-
return manager.create(_models_1.Region, region);
|
8
|
-
});
|
9
|
-
await manager.persistAndFlush(regions);
|
10
|
-
return regions;
|
11
|
-
}
|
12
|
-
exports.createRegions = createRegions;
|
/package/dist/migrations/{RegionModuleSetup20240205173216.d.ts → Migration20240205173216.d.ts}
RENAMED
File without changes
|
File without changes
|