@medusajs/region 0.1.2-snapshot-20240718083016 → 0.1.2-snapshot-20240719080828

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/dist/index.d.ts +36 -4
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +9 -19
  4. package/dist/loaders/defaults.d.ts +1 -0
  5. package/dist/loaders/defaults.d.ts.map +1 -0
  6. package/dist/loaders/defaults.js +2 -3
  7. package/dist/loaders/index.d.ts +1 -2
  8. package/dist/loaders/index.d.ts.map +1 -0
  9. package/dist/loaders/index.js +0 -2
  10. package/dist/migrations/{RegionModuleSetup20240205173216.d.ts → Migration20240205173216.d.ts} +1 -0
  11. package/dist/migrations/Migration20240205173216.d.ts.map +1 -0
  12. package/dist/migrations/{RegionModuleSetup20240205173216.js → Migration20240205173216.js} +1 -1
  13. package/dist/migrations/Migration20240624200006.d.ts +6 -0
  14. package/dist/migrations/Migration20240624200006.d.ts.map +1 -0
  15. package/dist/migrations/Migration20240624200006.js +19 -0
  16. package/dist/models/country.d.ts +166 -10
  17. package/dist/models/country.d.ts.map +1 -0
  18. package/dist/models/country.js +20 -62
  19. package/dist/models/index.d.ts +1 -0
  20. package/dist/models/index.d.ts.map +1 -0
  21. package/dist/models/region.d.ts +111 -19
  22. package/dist/models/region.d.ts.map +1 -0
  23. package/dist/models/region.js +8 -89
  24. package/dist/services/index.d.ts +1 -0
  25. package/dist/services/index.d.ts.map +1 -0
  26. package/dist/services/region-module.d.ts +22 -17
  27. package/dist/services/region-module.d.ts.map +1 -0
  28. package/dist/services/region-module.js +35 -20
  29. package/dist/types/index.d.ts +1 -0
  30. package/dist/types/index.d.ts.map +1 -0
  31. package/package.json +8 -14
  32. package/dist/initialize/index.d.ts +0 -4
  33. package/dist/initialize/index.js +0 -17
  34. package/dist/joiner-config.d.ts +0 -8
  35. package/dist/joiner-config.js +0 -33
  36. package/dist/loaders/connection.d.ts +0 -4
  37. package/dist/loaders/connection.js +0 -41
  38. package/dist/loaders/container.d.ts +0 -2
  39. package/dist/loaders/container.js +0 -34
  40. package/dist/module-definition.d.ts +0 -4
  41. package/dist/module-definition.js +0 -51
  42. package/dist/repositories/index.d.ts +0 -1
  43. package/dist/repositories/index.js +0 -5
  44. package/dist/scripts/bin/run-seed.d.ts +0 -3
  45. package/dist/scripts/bin/run-seed.js +0 -50
  46. package/dist/scripts/seed-utils.d.ts +0 -4
  47. package/dist/scripts/seed-utils.js +0 -12
package/dist/index.d.ts CHANGED
@@ -1,4 +1,36 @@
1
- import { moduleDefinition, revertMigration, runMigrations } from "./module-definition";
2
- export default moduleDefinition;
3
- export { revertMigration, runMigrations };
4
- export * from "./initialize";
1
+ import { RegionModuleService } from "./services";
2
+ import { Modules } from "@medusajs/utils";
3
+ declare const _default: import("@medusajs/types").ModuleExports<typeof RegionModuleService> & {
4
+ linkable: {
5
+ region: {
6
+ id: {
7
+ serviceName: Modules.REGION;
8
+ field: "region";
9
+ linkable: "region_id";
10
+ primaryKey: "id";
11
+ };
12
+ toJSON: () => {
13
+ serviceName: Modules.REGION;
14
+ field: "region";
15
+ linkable: "region_id";
16
+ primaryKey: "id";
17
+ };
18
+ };
19
+ country: {
20
+ iso_2: {
21
+ serviceName: Modules.REGION;
22
+ field: "country";
23
+ linkable: "country_iso_2";
24
+ primaryKey: "iso_2";
25
+ };
26
+ toJSON: () => {
27
+ serviceName: Modules.REGION;
28
+ field: "country";
29
+ linkable: "country_iso_2";
30
+ primaryKey: "iso_2";
31
+ };
32
+ };
33
+ };
34
+ };
35
+ export default _default;
36
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,EAAU,OAAO,EAAE,MAAM,iBAAiB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjD,wBAGE"}
package/dist/index.js CHANGED
@@ -1,22 +1,12 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
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
- exports.runMigrations = exports.revertMigration = void 0;
18
- const module_definition_1 = require("./module-definition");
19
- Object.defineProperty(exports, "revertMigration", { enumerable: true, get: function () { return module_definition_1.revertMigration; } });
20
- Object.defineProperty(exports, "runMigrations", { enumerable: true, get: function () { return module_definition_1.runMigrations; } });
21
- exports.default = module_definition_1.moduleDefinition;
22
- __exportStar(require("./initialize"), exports);
6
+ const services_1 = require("./services");
7
+ const defaults_1 = __importDefault(require("./loaders/defaults"));
8
+ const utils_1 = require("@medusajs/utils");
9
+ exports.default = (0, utils_1.Module)(utils_1.Modules.REGION, {
10
+ service: services_1.RegionModuleService,
11
+ loaders: [defaults_1.default],
12
+ });
@@ -1,3 +1,4 @@
1
1
  import { LoaderOptions } from "@medusajs/types";
2
2
  declare const _default: ({ container }: LoaderOptions) => Promise<void>;
3
3
  export default _default;
4
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/loaders/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA2B,MAAM,iBAAiB,CAAA;wCAInC,aAAa,KAAG,QAAQ,IAAI,CAAC;AAAlE,wBAwBC"}
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const utils_1 = require("@medusajs/utils");
4
- const utils_2 = require("@medusajs/utils");
5
4
  exports.default = async ({ container }) => {
6
5
  // TODO: Add default logger to the container when running tests
7
6
  const logger = container.resolve(utils_1.ContainerRegistrationKeys.LOGGER) ?? console;
8
7
  const countryService_ = container.resolve("countryService");
9
8
  try {
10
- const normalizedCountries = utils_2.DefaultsUtils.defaultCountries.map((c) => ({
9
+ const normalizedCountries = utils_1.DefaultsUtils.defaultCountries.map((c) => ({
11
10
  iso_2: c.alpha2.toLowerCase(),
12
11
  iso_3: c.alpha3.toLowerCase(),
13
12
  num_code: c.numeric,
@@ -15,7 +14,7 @@ exports.default = async ({ container }) => {
15
14
  display_name: c.name,
16
15
  }));
17
16
  const resp = await countryService_.upsert(normalizedCountries);
18
- logger.info(`Loaded ${resp.length} countries`);
17
+ logger.debug(`Loaded ${resp.length} countries`);
19
18
  }
20
19
  catch (error) {
21
20
  logger.warn(`Failed to load countries, skipping loader. Original error: ${error.message}`);
@@ -1,3 +1,2 @@
1
- export * from "./connection";
2
- export * from "./container";
3
1
  export * from "./defaults";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -14,6 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./connection"), exports);
18
- __exportStar(require("./container"), exports);
19
17
  __exportStar(require("./defaults"), exports);
@@ -2,3 +2,4 @@ import { Migration } from "@mikro-orm/migrations";
2
2
  export declare class RegionModuleSetup20240205173216 extends Migration {
3
3
  up(): Promise<void>;
4
4
  }
5
+ //# sourceMappingURL=Migration20240205173216.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20240205173216.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240205173216.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,+BAAgC,SAAQ,SAAS;IACtD,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAuC1B"}
@@ -27,7 +27,7 @@ CREATE INDEX IF NOT EXISTS "IDX_region_deleted_at" ON "region" ("deleted_at") WH
27
27
  CREATE TABLE IF NOT EXISTS "region_country" (
28
28
  "iso_2" text NOT NULL,
29
29
  "iso_3" text NOT NULL,
30
- "num_code" int NOT NULL,
30
+ "num_code" text NOT NULL,
31
31
  "name" text NOT NULL,
32
32
  "display_name" text NOT NULL,
33
33
  "region_id" text NULL,
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20240624200006 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20240624200006.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20240624200006.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20240624200006.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAanB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAqB5B"}
@@ -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;
@@ -1,10 +1,166 @@
1
- import Region from "./region";
2
- export default class Country {
3
- iso_2: string;
4
- iso_3: string;
5
- num_code: number;
6
- name: string;
7
- display_name: string;
8
- region_id?: string | null;
9
- region?: Region | null;
10
- }
1
+ declare const _default: import("@medusajs/utils").DmlEntity<{
2
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, 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/primary-key").PrimaryKeyModifier<string, 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/primary-key").PrimaryKeyModifier<string, 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
+ readonly name: "Country";
22
+ readonly tableName: "region_country";
23
+ }>>;
24
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
25
+ } & {
26
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
27
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
28
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
29
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
30
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
31
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
32
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
33
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
34
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
35
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
36
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
37
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
38
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
39
+ readonly name: "Country";
40
+ readonly tableName: "region_country";
41
+ }>>;
42
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
43
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, "region">, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
44
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
45
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
46
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
47
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
48
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
49
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
50
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
51
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
52
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
53
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
54
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
55
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
56
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
57
+ readonly name: "Country";
58
+ readonly tableName: "region_country";
59
+ }>>;
60
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
61
+ } & {
62
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
63
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
64
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
65
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
66
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<any & {
67
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
68
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
69
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
70
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
71
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
72
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
73
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
74
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
75
+ readonly name: "Country";
76
+ readonly tableName: "region_country";
77
+ }>>;
78
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
79
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, "region">>>;
80
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
81
+ } & {
82
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
83
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
84
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
85
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
86
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
87
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<() => import("@medusajs/utils").DmlEntity<{
88
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
89
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
90
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
91
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
92
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
93
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
94
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
95
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
96
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
97
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
98
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
99
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
100
+ } & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
101
+ readonly name: "Country";
102
+ readonly tableName: "region_country";
103
+ }>>;
104
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
105
+ } & {
106
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, 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/primary-key").PrimaryKeyModifier<string, 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
+ readonly name: "Country";
120
+ readonly tableName: "region_country";
121
+ }>>;
122
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
123
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, "region">, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<() => import("@medusajs/utils").DmlEntity<{
124
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
125
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
126
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
127
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
128
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
129
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
130
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
131
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
132
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
133
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
134
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
135
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
136
+ } & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
137
+ readonly name: "Country";
138
+ readonly tableName: "region_country";
139
+ }>>;
140
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
141
+ } & {
142
+ id: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/id").IdProperty>;
143
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
144
+ currency_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
145
+ automatic_taxes: import("@medusajs/utils/dist/dml/properties/boolean").BooleanProperty;
146
+ countries: import("@medusajs/utils/dist/dml/relations/has-many").HasMany<() => import("@medusajs/utils").DmlEntity<{
147
+ iso_2: import("@medusajs/utils/dist/dml/properties/primary-key").PrimaryKeyModifier<string, import("@medusajs/utils/dist/dml/properties/text").TextProperty>;
148
+ iso_3: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
149
+ num_code: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
150
+ name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
151
+ display_name: import("@medusajs/utils/dist/dml/properties/text").TextProperty;
152
+ region: import("@medusajs/utils/dist/dml/relations/nullable").NullableModifier<any, import("@medusajs/utils/dist/dml/relations/belongs-to").BelongsTo<any>>;
153
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
154
+ } & any & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
155
+ readonly name: "Country";
156
+ readonly tableName: "region_country";
157
+ }>>;
158
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
159
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, "region">>>;
160
+ metadata: import("@medusajs/utils/dist/dml/properties/nullable").NullableModifier<Record<string, unknown>, import("@medusajs/utils/dist/dml/properties/json").JSONProperty>;
161
+ } & {} & import("@medusajs/utils/dist/dml/helpers/entity-builder/create-default-properties").DMLSchemaDefaults, {
162
+ readonly name: "Country";
163
+ readonly tableName: "region_country";
164
+ }>;
165
+ export default _default;
166
+ //# sourceMappingURL=country.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"country.d.ts","sourceRoot":"","sources":["../../src/models/country.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBAsBI"}
@@ -1,69 +1,27 @@
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
- // We don't need a partial index on deleted_at here since we don't support soft deletes on countries
19
- const regionIdIsoIndexName = "IDX_region_country_region_id_iso_2_unique";
20
- const RegionIdIsoIndexStatement = (0, utils_1.createPsqlIndexStatementHelper)({
21
- name: regionIdIsoIndexName,
22
- tableName: "region_country",
23
- columns: ["region_id", "iso_2"],
24
- unique: true,
25
- });
26
- RegionIdIsoIndexStatement.MikroORMIndex();
27
- let Country = class Country {
28
- constructor() {
29
- this.region_id = null;
30
- }
31
- };
32
- __decorate([
33
- (0, core_1.PrimaryKey)({ columnType: "text" }),
34
- (0, core_1.Property)({ columnType: "text" }),
35
- __metadata("design:type", String)
36
- ], Country.prototype, "iso_2", void 0);
37
- __decorate([
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: "int" }),
43
- __metadata("design:type", Number)
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);
69
- exports.default = Country;
8
+ exports.default = 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
+ ]);
@@ -1,2 +1,3 @@
1
1
  export { default as Country } from "./country";
2
2
  export { default as Region } from "./region";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}