@medusajs/region 0.1.2 → 1.0.0-rc-20241003153304

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/dist/index.d.ts +36 -4
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +10 -19
  4. package/dist/index.js.map +1 -0
  5. package/dist/loaders/defaults.d.ts +2 -1
  6. package/dist/loaders/defaults.d.ts.map +1 -0
  7. package/dist/loaders/defaults.js +4 -4
  8. package/dist/loaders/defaults.js.map +1 -0
  9. package/dist/loaders/index.d.ts +1 -2
  10. package/dist/loaders/index.d.ts.map +1 -0
  11. package/dist/loaders/index.js +1 -2
  12. package/dist/loaders/index.js.map +1 -0
  13. package/dist/migrations/{RegionModuleSetup20240205173216.d.ts → Migration20240205173216.d.ts} +1 -0
  14. package/dist/migrations/Migration20240205173216.d.ts.map +1 -0
  15. package/dist/migrations/{RegionModuleSetup20240205173216.js → Migration20240205173216.js} +3 -2
  16. package/dist/migrations/Migration20240205173216.js.map +1 -0
  17. package/dist/migrations/Migration20240624200006.d.ts +6 -0
  18. package/dist/migrations/Migration20240624200006.d.ts.map +1 -0
  19. package/dist/migrations/Migration20240624200006.js +20 -0
  20. package/dist/migrations/Migration20240624200006.js.map +1 -0
  21. package/dist/models/country.d.ts +166 -10
  22. package/dist/models/country.d.ts.map +1 -0
  23. package/dist/models/country.js +22 -63
  24. package/dist/models/country.js.map +1 -0
  25. package/dist/models/index.d.ts +1 -0
  26. package/dist/models/index.d.ts.map +1 -0
  27. package/dist/models/index.js +1 -0
  28. package/dist/models/index.js.map +1 -0
  29. package/dist/models/region.d.ts +111 -19
  30. package/dist/models/region.d.ts.map +1 -0
  31. package/dist/models/region.js +10 -90
  32. package/dist/models/region.js.map +1 -0
  33. package/dist/services/index.d.ts +1 -0
  34. package/dist/services/index.d.ts.map +1 -0
  35. package/dist/services/index.js +1 -0
  36. package/dist/services/index.js.map +1 -0
  37. package/dist/services/region-module.d.ts +22 -17
  38. package/dist/services/region-module.d.ts.map +1 -0
  39. package/dist/services/region-module.js +43 -27
  40. package/dist/services/region-module.js.map +1 -0
  41. package/dist/tsconfig.tsbuildinfo +1 -0
  42. package/dist/types/index.d.ts +2 -1
  43. package/dist/types/index.d.ts.map +1 -0
  44. package/dist/types/index.js +1 -0
  45. package/dist/types/index.js.map +1 -0
  46. package/package.json +25 -26
  47. package/dist/initialize/index.d.ts +0 -4
  48. package/dist/initialize/index.js +0 -17
  49. package/dist/joiner-config.d.ts +0 -8
  50. package/dist/joiner-config.js +0 -33
  51. package/dist/loaders/connection.d.ts +0 -4
  52. package/dist/loaders/connection.js +0 -41
  53. package/dist/loaders/container.d.ts +0 -2
  54. package/dist/loaders/container.js +0 -34
  55. package/dist/module-definition.d.ts +0 -4
  56. package/dist/module-definition.js +0 -51
  57. package/dist/repositories/index.d.ts +0 -1
  58. package/dist/repositories/index.js +0 -5
  59. package/dist/scripts/bin/run-seed.d.ts +0 -3
  60. package/dist/scripts/bin/run-seed.js +0 -50
  61. package/dist/scripts/seed-utils.d.ts +0 -4
  62. package/dist/scripts/seed-utils.js +0 -12
@@ -1,4 +0,0 @@
1
- import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
2
- import { IRegionModuleService, ModulesSdkTypes } from "@medusajs/types";
3
- import { InitializeModuleInjectableDependencies } from "../types";
4
- export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IRegionModuleService>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialize = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- const module_definition_1 = require("../module-definition");
6
- const initialize = async (options, injectedDependencies) => {
7
- const serviceKey = modules_sdk_1.Modules.REGION;
8
- const loaded = await modules_sdk_1.MedusaModule.bootstrap({
9
- moduleKey: serviceKey,
10
- defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.REGION],
11
- declaration: options,
12
- injectedDependencies,
13
- moduleExports: module_definition_1.moduleDefinition,
14
- });
15
- return loaded[serviceKey];
16
- };
17
- exports.initialize = initialize;
@@ -1,8 +0,0 @@
1
- import { ModuleJoinerConfig } from "@medusajs/types";
2
- import { MapToConfig } from "@medusajs/utils";
3
- export declare const LinkableKeys: {
4
- region_id: string;
5
- country_iso: string;
6
- };
7
- export declare const entityNameToLinkableKeysMap: MapToConfig;
8
- export declare const joinerConfig: ModuleJoinerConfig;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
4
- const modules_sdk_1 = require("@medusajs/modules-sdk");
5
- const _models_1 = require("./models");
6
- exports.LinkableKeys = {
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] ?? (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
- };
@@ -1,4 +0,0 @@
1
- import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
2
- import { ModulesSdkTypes } from "@medusajs/types";
3
- declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
- export default _default;
@@ -1,41 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const modules_sdk_1 = require("@medusajs/modules-sdk");
27
- const utils_1 = require("@medusajs/utils");
28
- const RegionModels = __importStar(require("../models"));
29
- exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
30
- const entities = Object.values(RegionModels);
31
- const pathToMigrations = __dirname + "/../migrations";
32
- await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
33
- moduleName: modules_sdk_1.Modules.REGION,
34
- entities,
35
- container,
36
- options,
37
- moduleDeclaration,
38
- logger,
39
- pathToMigrations,
40
- });
41
- };
@@ -1,2 +0,0 @@
1
- declare const _default: ({ container, options }: import("@medusajs/types").LoaderOptions) => Promise<void>;
2
- export default _default;
@@ -1,34 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const utils_1 = require("@medusajs/utils");
27
- const ModuleModels = __importStar(require("../models"));
28
- const ModuleRepositories = __importStar(require("../repositories"));
29
- const ModuleServices = __importStar(require("../services"));
30
- exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
31
- moduleModels: ModuleModels,
32
- moduleRepositories: ModuleRepositories,
33
- moduleServices: ModuleServices,
34
- });
@@ -1,4 +0,0 @@
1
- import { ModuleExports } from "@medusajs/types";
2
- export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/types").LoaderOptions<import("@medusajs/types").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
3
- export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/types").LoaderOptions<import("@medusajs/types").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
4
- export declare const moduleDefinition: ModuleExports;
@@ -1,51 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
30
- const services_1 = require("./services");
31
- const modules_sdk_1 = require("@medusajs/modules-sdk");
32
- const utils_1 = require("@medusajs/utils");
33
- const RegionModels = __importStar(require("./models"));
34
- const connection_1 = __importDefault(require("./loaders/connection"));
35
- const container_1 = __importDefault(require("./loaders/container"));
36
- const defaults_1 = __importDefault(require("./loaders/defaults"));
37
- const migrationScriptOptions = {
38
- moduleName: modules_sdk_1.Modules.REGION,
39
- models: RegionModels,
40
- pathToMigrations: __dirname + "/migrations",
41
- };
42
- exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
43
- exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
44
- const service = services_1.RegionModuleService;
45
- const loaders = [container_1.default, connection_1.default, defaults_1.default];
46
- exports.moduleDefinition = {
47
- service,
48
- loaders,
49
- runMigrations: exports.runMigrations,
50
- revertMigration: exports.revertMigration,
51
- };
@@ -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,3 +0,0 @@
1
- #!/usr/bin/env node
2
- declare const _default: Promise<void>;
3
- export default _default;
@@ -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;