@nest-boot/mikro-orm 8.0.0-beta.0 → 8.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
- /** Interface for entities that have an `id` primary key. */
2
1
  export interface IdEntity<ID = number | string | bigint> {
3
- /** The entity's primary key. */
4
2
  id: ID;
5
3
  }
@@ -1,3 +1,2 @@
1
1
  import { MikroOrmModuleOptions as BaseMikroOrmModuleOptions } from "@mikro-orm/nestjs";
2
- /** Configuration options for the MikroORM module (excludes context management handled internally). */
3
2
  export type MikroOrmModuleOptions = Omit<BaseMikroOrmModuleOptions, "registerRequestContext" | "context">;
@@ -1,3 +1,9 @@
1
1
  import { MikroOrmModuleOptions } from "./interfaces/mikro-orm-module-options.interface.js";
2
2
  export declare const MODULE_OPTIONS_TOKEN: unique symbol;
3
- export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<MikroOrmModuleOptions, "forRoot", "create", {}>, BASE_MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: MikroOrmModuleOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<MikroOrmModuleOptions, "create"> & Partial<{}>;
3
+ export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<MikroOrmModuleOptions, "forRoot", "create", {
4
+ driverHint?: MikroOrmModuleOptions["driver"];
5
+ }>, BASE_MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: MikroOrmModuleOptions & Partial<{
6
+ driverHint?: MikroOrmModuleOptions["driver"];
7
+ }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<MikroOrmModuleOptions, "create"> & Partial<{
8
+ driverHint?: MikroOrmModuleOptions["driver"];
9
+ }>;
@@ -2,5 +2,6 @@ import { ConfigurableModuleBuilder } from "@nestjs/common";
2
2
  export const MODULE_OPTIONS_TOKEN = Symbol("MikroOrmModuleOptions");
3
3
  export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN: BASE_MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE, } = new ConfigurableModuleBuilder()
4
4
  .setClassMethodName("forRoot")
5
+ .setExtras({ driverHint: undefined })
5
6
  .build();
6
7
  //# sourceMappingURL=mikro-orm.module-definition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mikro-orm.module-definition.js","sourceRoot":"","sources":["../src/mikro-orm.module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAI3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,EACX,uBAAuB,EACvB,oBAAoB,EAAE,yBAAyB,EAC/C,YAAY,EACZ,kBAAkB,GACnB,GAAG,IAAI,yBAAyB,EAAyB;KACvD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"mikro-orm.module-definition.js","sourceRoot":"","sources":["../src/mikro-orm.module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAI3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,EACX,uBAAuB,EACvB,oBAAoB,EAAE,yBAAyB,EAC/C,YAAY,EACZ,kBAAkB,GACnB,GAAG,IAAI,yBAAyB,EAAyB;KACvD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,SAAS,CAEP,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;KAC5B,KAAK,EAAE,CAAC"}
@@ -2,48 +2,15 @@ import { MikroORM } from "@mikro-orm/core";
2
2
  import { MikroOrmModule as BaseMikroOrmModule } from "@mikro-orm/nestjs";
3
3
  import { type DynamicModule, OnModuleInit } from "@nestjs/common";
4
4
  import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from "./mikro-orm.module-definition.js";
5
- /**
6
- * MikroORM integration module with request-scoped entity manager.
7
- *
8
- * @remarks
9
- * Wraps `@mikro-orm/nestjs` with automatic environment-based configuration
10
- * and request context integration for per-request entity manager forking.
11
- */
12
5
  export declare class MikroOrmModule extends ConfigurableModuleClass implements OnModuleInit {
13
6
  private readonly orm;
14
- /**
15
- * Registers the MikroOrmModule with the given options.
16
- * @param options - MikroORM configuration options
17
- * @returns Dynamic module configuration
18
- */
19
7
  static forRoot(options: typeof OPTIONS_TYPE): DynamicModule;
20
- /**
21
- * Registers the MikroOrmModule asynchronously with factory functions.
22
- * @param options - Async configuration options
23
- * @returns Dynamic module configuration
24
- */
25
8
  static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
26
- /** Creates a new MikroOrmModule instance.
27
- * @param orm - The MikroORM instance
28
- */
9
+ private static createOptionsModule;
10
+ private static createRootModule;
29
11
  constructor(orm: MikroORM);
30
- /**
31
- * Registers entity classes for use in the given module scope.
32
- * @param args - forFeature arguments (entity classes, options)
33
- * @returns Dynamic module configuration
34
- */
35
12
  static forFeature(...args: Parameters<typeof BaseMikroOrmModule.forFeature>): DynamicModule;
36
- /**
37
- * Registers MikroORM middleware for the module.
38
- * @param args - forMiddleware arguments
39
- * @returns Dynamic module configuration
40
- */
41
13
  static forMiddleware(...args: Parameters<typeof BaseMikroOrmModule.forMiddleware>): DynamicModule;
42
- /**
43
- * Clears the MikroORM metadata storage.
44
- * @param args - clearStorage arguments
45
- */
46
14
  static clearStorage(...args: Parameters<typeof BaseMikroOrmModule.clearStorage>): void;
47
- /** Registers the MikroORM entity manager fork middleware in the request context. */
48
15
  onModuleInit(): void;
49
16
  }
@@ -7,69 +7,105 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ var MikroOrmModule_1;
10
11
  import { EntityManager, MikroORM } from "@mikro-orm/core";
11
12
  import { MikroOrmModule as BaseMikroOrmModule } from "@mikro-orm/nestjs";
12
13
  import { RequestContext, RequestContextModule, } from "@nest-boot/request-context";
13
14
  import { Global, Logger, Module, } from "@nestjs/common";
14
15
  import { BASE_MODULE_OPTIONS_TOKEN, ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, } from "./mikro-orm.module-definition.js";
15
16
  import { loadConfigFromEnv } from "./utils/load-config-from-env.util.js";
16
- /**
17
- * MikroORM integration module with request-scoped entity manager.
18
- *
19
- * @remarks
20
- * Wraps `@mikro-orm/nestjs` with automatic environment-based configuration
21
- * and request context integration for per-request entity manager forking.
22
- */
23
- let MikroOrmModule = class MikroOrmModule extends ConfigurableModuleClass {
17
+ import { loadDefaultConfig } from "./utils/load-default-config.util.js";
18
+ const CONNECTION_TARGET_OPTION_KEYS = [
19
+ "dbName",
20
+ "clientUrl",
21
+ "host",
22
+ "port",
23
+ "user",
24
+ "password",
25
+ "replicas",
26
+ ];
27
+ let MikroOrmOptionsHostModule = class MikroOrmOptionsHostModule {
28
+ };
29
+ MikroOrmOptionsHostModule = __decorate([
30
+ Module({})
31
+ ], MikroOrmOptionsHostModule);
32
+ function hasExplicitConnectionTarget(options) {
33
+ return CONNECTION_TARGET_OPTION_KEYS.some((key) => options[key] !== undefined);
34
+ }
35
+ let MikroOrmModule = MikroOrmModule_1 = class MikroOrmModule extends ConfigurableModuleClass {
24
36
  orm;
25
- /**
26
- * Registers the MikroOrmModule with the given options.
27
- * @param options - MikroORM configuration options
28
- * @returns Dynamic module configuration
29
- */
30
37
  static forRoot(options) {
31
- return super.forRoot(options);
38
+ const optionsModule = this.createOptionsModule(super.forRoot(options));
39
+ return {
40
+ module: MikroOrmModule_1,
41
+ imports: [
42
+ optionsModule,
43
+ this.createRootModule(optionsModule, options.driver),
44
+ ],
45
+ };
32
46
  }
33
- /**
34
- * Registers the MikroOrmModule asynchronously with factory functions.
35
- * @param options - Async configuration options
36
- * @returns Dynamic module configuration
37
- */
38
47
  static forRootAsync(options) {
39
- return super.forRootAsync(options);
48
+ const optionsModule = this.createOptionsModule(super.forRootAsync(options));
49
+ return {
50
+ module: MikroOrmModule_1,
51
+ imports: [
52
+ optionsModule,
53
+ this.createRootModule(optionsModule, options.driverHint),
54
+ ],
55
+ };
56
+ }
57
+ static createOptionsModule(configurableModule) {
58
+ return {
59
+ module: MikroOrmOptionsHostModule,
60
+ imports: configurableModule.imports,
61
+ providers: configurableModule.providers,
62
+ exports: [BASE_MODULE_OPTIONS_TOKEN],
63
+ };
64
+ }
65
+ static createRootModule(optionsModule, driver) {
66
+ return BaseMikroOrmModule.forRootAsync({
67
+ driver,
68
+ imports: [optionsModule],
69
+ inject: [BASE_MODULE_OPTIONS_TOKEN],
70
+ useFactory: async (options) => {
71
+ const logger = new Logger("MikroORM");
72
+ const envOptions = hasExplicitConnectionTarget(options)
73
+ ? loadDefaultConfig()
74
+ : await loadConfigFromEnv();
75
+ const resolvedOptions = {
76
+ registerRequestContext: false,
77
+ context: () => {
78
+ if (RequestContext.isActive()) {
79
+ return RequestContext.get(EntityManager);
80
+ }
81
+ },
82
+ logger: (msg) => {
83
+ logger.log(msg);
84
+ },
85
+ ...envOptions,
86
+ ...options,
87
+ };
88
+ if (options.entities !== undefined &&
89
+ options.entitiesTs === undefined) {
90
+ resolvedOptions.entitiesTs = options.entities;
91
+ }
92
+ return resolvedOptions;
93
+ },
94
+ });
40
95
  }
41
- /** Creates a new MikroOrmModule instance.
42
- * @param orm - The MikroORM instance
43
- */
44
96
  constructor(orm) {
45
97
  super();
46
98
  this.orm = orm;
47
99
  }
48
- /**
49
- * Registers entity classes for use in the given module scope.
50
- * @param args - forFeature arguments (entity classes, options)
51
- * @returns Dynamic module configuration
52
- */
53
100
  static forFeature(...args) {
54
101
  return BaseMikroOrmModule.forFeature(...args);
55
102
  }
56
- /**
57
- * Registers MikroORM middleware for the module.
58
- * @param args - forMiddleware arguments
59
- * @returns Dynamic module configuration
60
- */
61
103
  static forMiddleware(...args) {
62
104
  return BaseMikroOrmModule.forMiddleware(...args);
63
105
  }
64
- /**
65
- * Clears the MikroORM metadata storage.
66
- * @param args - clearStorage arguments
67
- */
68
106
  static clearStorage(...args) {
69
- // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
70
107
  return BaseMikroOrmModule.clearStorage(...args);
71
108
  }
72
- /** Registers the MikroORM entity manager fork middleware in the request context. */
73
109
  onModuleInit() {
74
110
  RequestContext.registerMiddleware("mikro-orm", (ctx, next) => {
75
111
  ctx.set(EntityManager, this.orm.em.fork({ useContext: true }));
@@ -77,31 +113,10 @@ let MikroOrmModule = class MikroOrmModule extends ConfigurableModuleClass {
77
113
  });
78
114
  }
79
115
  };
80
- MikroOrmModule = __decorate([
116
+ MikroOrmModule = MikroOrmModule_1 = __decorate([
81
117
  Global(),
82
118
  Module({
83
- imports: [
84
- RequestContextModule,
85
- BaseMikroOrmModule.forRootAsync({
86
- inject: [MODULE_OPTIONS_TOKEN],
87
- useFactory: async (options) => {
88
- const logger = new Logger("MikroORM");
89
- return {
90
- registerRequestContext: false,
91
- context: () => {
92
- if (RequestContext.isActive()) {
93
- return RequestContext.get(EntityManager);
94
- }
95
- },
96
- logger: (msg) => {
97
- logger.log(msg);
98
- },
99
- ...(await loadConfigFromEnv()),
100
- ...options,
101
- };
102
- },
103
- }),
104
- ],
119
+ imports: [RequestContextModule],
105
120
  providers: [
106
121
  {
107
122
  provide: MODULE_OPTIONS_TOKEN,
@@ -1 +1 @@
1
- {"version":3,"file":"mikro-orm.module.js","sourceRoot":"","sources":["../src/mikro-orm.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,mBAAmB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7B,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,yBAAyB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBAC9D,UAAU,EAAE,CAAC,OAA+B,EAAE,EAAE,CAAC,OAAO,IAAI,EAAE;aAC/D;SACF;QACD,OAAO,EAAE,CAAC,oBAAoB,CAAC;KAChC,CAAC;qCA+FkC,QAAQ;GA9F/B,cAAc,CAwI1B"}
@@ -1,23 +1,7 @@
1
1
  import { EntityProperty, Platform } from "@mikro-orm/core";
2
2
  import { VectorType as BaseVectorType } from "pgvector/mikro-orm";
3
- /**
4
- * Custom MikroORM property type for pgvector vector columns with configurable dimensions.
5
- *
6
- * @remarks
7
- * Extends the base pgvector `VectorType` to support specifying the vector
8
- * dimension at the property level (e.g. `vector(1536)`).
9
- */
10
3
  export declare class VectorType extends BaseVectorType {
11
4
  private readonly dimensions?;
12
- /** Creates a new VectorType instance.
13
- * @param dimensions - Optional vector dimension (e.g. 1536 for OpenAI embeddings)
14
- */
15
5
  constructor(dimensions?: number | undefined);
16
- /**
17
- * Returns the SQL column type for the vector property.
18
- * @param prop - The entity property metadata
19
- * @param platform - The database platform
20
- * @returns The column type string (e.g. `vector(1536)`)
21
- */
22
6
  getColumnType(prop: EntityProperty, platform: Platform): any;
23
7
  }
@@ -1,26 +1,10 @@
1
1
  import { VectorType as BaseVectorType } from "pgvector/mikro-orm";
2
- /**
3
- * Custom MikroORM property type for pgvector vector columns with configurable dimensions.
4
- *
5
- * @remarks
6
- * Extends the base pgvector `VectorType` to support specifying the vector
7
- * dimension at the property level (e.g. `vector(1536)`).
8
- */
9
2
  export class VectorType extends BaseVectorType {
10
3
  dimensions;
11
- /** Creates a new VectorType instance.
12
- * @param dimensions - Optional vector dimension (e.g. 1536 for OpenAI embeddings)
13
- */
14
4
  constructor(dimensions) {
15
5
  super();
16
6
  this.dimensions = dimensions;
17
7
  }
18
- /**
19
- * Returns the SQL column type for the vector property.
20
- * @param prop - The entity property metadata
21
- * @param platform - The database platform
22
- * @returns The column type string (e.g. `vector(1536)`)
23
- */
24
8
  getColumnType(prop, platform) {
25
9
  return super.getColumnType({ dimensions: this.dimensions, ...prop }, platform);
26
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vector.type.js","sourceRoot":"","sources":["../../src/property-types/vector.type.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IAIf;IAH7B;;OAEG;IACH,YAA6B,UAAmB;QAC9C,KAAK,EAAE,CAAC;QADmB,eAAU,GAAV,UAAU,CAAS;IAEhD,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,IAAoB,EAAE,QAAkB;QACpD,OAAO,KAAK,CAAC,aAAa,CACxB,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,EAAE,EACxC,QAAQ,CACT,CAAC;IACJ,CAAC;CACF"}
1
+ {"version":3,"file":"vector.type.js","sourceRoot":"","sources":["../../src/property-types/vector.type.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASlE,MAAM,OAAO,UAAW,SAAQ,cAAc;IAIf;IAA7B,YAA6B,UAAmB;QAC9C,KAAK,EAAE,CAAC;QADmB,eAAU,GAAV,UAAU,CAAS;IAEhD,CAAC;IAQD,aAAa,CAAC,IAAoB,EAAE,QAAkB;QACpD,OAAO,KAAK,CAAC,aAAa,CACxB,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,EAAE,EACxC,QAAQ,CACT,CAAC;IACJ,CAAC;CACF"}
@@ -3,89 +3,21 @@ import { Type } from "@nestjs/common";
3
3
  import type { IdEntity } from "../interfaces/id-entity.interface.js";
4
4
  import type { ChunkByIdOptions } from "../types/chunk-by-id-options.type.js";
5
5
  import type { IdOrEntity } from "../types/id-or-entity.type.js";
6
- /** Options for configuring an {@link EntityService} instance. */
7
6
  export interface EntityServiceOptions<Entity extends IdEntity> {
8
- /** Entity property key used for soft-delete timestamps (defaults to `"deletedAt"`). */
9
7
  softDeleteKey?: keyof Entity;
10
8
  }
11
- /**
12
- * Generic CRUD service for MikroORM entities with DataLoader batching.
13
- *
14
- * @remarks
15
- * Provides batched `create`, `findOne`, `update`, and `remove` operations
16
- * via DataLoader for automatic N+1 prevention, plus standard `findAll`,
17
- * `count`, and `chunkById` methods.
18
- *
19
- * @typeParam Entity - The entity type, which must have an `id` property
20
- */
21
9
  export declare class EntityService<Entity extends IdEntity> {
22
10
  #private;
23
11
  protected readonly entityClass: Type<Entity>;
24
12
  protected readonly em: EntityManager;
25
13
  protected readonly options?: EntityServiceOptions<Entity> | undefined;
26
- /**
27
- * Creates a new EntityService instance.
28
- * @param entityClass - The entity class to manage
29
- * @param em - MikroORM entity manager
30
- * @param options - Optional service configuration (e.g. soft-delete key)
31
- */
32
14
  constructor(entityClass: Type<Entity>, em: EntityManager, options?: EntityServiceOptions<Entity> | undefined);
33
- /**
34
- * Creates a new entity and persists it.
35
- * @param data - The entity data to create
36
- * @returns The created entity
37
- */
38
15
  create(data: RequiredEntityData<Entity>): Promise<Entity>;
39
- /**
40
- * Finds a single entity by ID, entity reference, or filter query.
41
- * @param idOrEntityOrWhere - The entity ID, entity instance, or filter query
42
- * @returns The found entity or null
43
- */
44
16
  findOne(idOrEntityOrWhere: IdOrEntity<Entity> | FilterQuery<NoInfer<Entity>>): Promise<Loaded<Entity> | null>;
45
- /**
46
- * Finds a single entity by ID, entity reference, or filter query, throwing if not found.
47
- * @param idOrEntityOrWhere - The entity ID, entity instance, or filter query
48
- * @returns The found entity
49
- * @throws NotFoundException if the entity is not found
50
- */
51
17
  findOneOrFail(idOrEntityOrWhere: IdOrEntity<Entity> | FilterQuery<Entity>): Promise<Loaded<Entity>>;
52
- /**
53
- * Finds all entities matching the given filter query.
54
- * @param where - Filter query
55
- * @param options - Find options (populate, limit, offset, etc.)
56
- * @returns Array of matching entities
57
- */
58
18
  findAll<Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never>(where: FilterQuery<NoInfer<Entity>>, options?: FindOptions<Entity, Hint, Fields, Excludes>): Promise<Loaded<Entity, Hint, Fields, Excludes>[]>;
59
- /**
60
- * Counts entities matching the given filter query.
61
- * @param where - Filter query
62
- * @param options - Count options
63
- * @returns The number of matching entities
64
- */
65
19
  count<Hint extends string = never>(where: FilterQuery<NoInfer<Entity>>, options?: CountOptions<Entity, Hint>): Promise<number>;
66
- /**
67
- * Updates an entity by ID or reference.
68
- * @param idOrEntity - The entity ID or entity instance to update
69
- * @param data - The data to assign to the entity
70
- * @param options - Optional assign options
71
- * @returns The updated entity
72
- * @throws NotFoundException if the entity is not found
73
- */
74
20
  update<Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Convert extends boolean = false, Data extends EntityData<Naked, Convert> | Partial<EntityDTO<Naked>> = EntityData<Naked, Convert> | Partial<EntityDTO<Naked>>>(idOrEntity: IdOrEntity<Entity>, data: Data & IsSubset<EntityData<Naked, Convert>, Data>, options?: AssignOptions<Convert>): Promise<Entity>;
75
- /**
76
- * Removes an entity by ID or reference (supports soft-delete).
77
- * @param idOrEntity - The entity ID or entity instance to remove
78
- * @param softDelete - Whether to soft-delete (default: true)
79
- * @returns The removed entity
80
- * @throws NotFoundException if the entity is not found
81
- */
82
21
  remove(idOrEntity: IdOrEntity<Entity>, softDelete?: boolean): Promise<Entity>;
83
- /**
84
- * Iterates over entities in chunks ordered by ID, useful for batch processing.
85
- * @param where - Filter query
86
- * @param options - Find options (limit determines chunk size)
87
- * @param callback - Async callback invoked with each chunk of entities
88
- * @returns This service instance for chaining
89
- */
90
22
  chunkById<Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never>(where: ExpandQuery<Entity>, options: ChunkByIdOptions<Entity, Hint, Fields, Excludes>, callback: (entities: Loaded<Entity, Hint, Fields, Excludes>[]) => Promise<void>): Promise<this>;
91
23
  }
@@ -1,42 +1,34 @@
1
1
  import { QueryOrder, } from "@mikro-orm/core";
2
2
  import { NotFoundException } from "@nestjs/common";
3
3
  import DataLoader from "dataloader";
4
- import _ from "lodash";
5
- /**
6
- * Generic CRUD service for MikroORM entities with DataLoader batching.
7
- *
8
- * @remarks
9
- * Provides batched `create`, `findOne`, `update`, and `remove` operations
10
- * via DataLoader for automatic N+1 prevention, plus standard `findAll`,
11
- * `count`, and `chunkById` methods.
12
- *
13
- * @typeParam Entity - The entity type, which must have an `id` property
14
- */
4
+ import { capitalize, isPlainObject } from "lodash-es";
15
5
  export class EntityService {
16
6
  entityClass;
17
7
  em;
18
8
  options;
19
- /**
20
- * Creates a new EntityService instance.
21
- * @param entityClass - The entity class to manage
22
- * @param em - MikroORM entity manager
23
- * @param options - Optional service configuration (e.g. soft-delete key)
24
- */
9
+ #dataLoadersByEntityManager = new WeakMap();
25
10
  constructor(entityClass, em, options) {
26
11
  this.entityClass = entityClass;
27
12
  this.em = em;
28
13
  this.options = options;
29
14
  }
30
- get #getDataLoader() {
31
- return new DataLoader(async (items) => {
32
- const uow = this.em.getUnitOfWork();
33
- // Get all IDs
15
+ get #dataLoaders() {
16
+ const em = this.em.getContext(false);
17
+ const existingDataLoaders = this.#dataLoadersByEntityManager.get(em);
18
+ if (existingDataLoaders) {
19
+ return existingDataLoaders;
20
+ }
21
+ const dataLoaders = this.#createDataLoaders(em);
22
+ this.#dataLoadersByEntityManager.set(em, dataLoaders);
23
+ return dataLoaders;
24
+ }
25
+ #createDataLoaders(em) {
26
+ const findOne = new DataLoader(async (items) => {
27
+ const uow = em.getUnitOfWork();
34
28
  const ids = items.map(({ idOrEntity }) => typeof idOrEntity === "object" ? idOrEntity.id : idOrEntity);
35
- // First try to get already loaded entities from UnitOfWork
36
29
  const entitiesFromUow = [];
37
30
  const idsToFetch = [];
38
31
  for (const id of ids) {
39
- // Try to get entity from UnitOfWork's identity map
40
32
  const entity = uow.getById(this.entityClass, id);
41
33
  if (entity) {
42
34
  entitiesFromUow.push(entity);
@@ -45,34 +37,27 @@ export class EntityService {
45
37
  idsToFetch.push(id);
46
38
  }
47
39
  }
48
- // If there are IDs that need to be fetched from the database, execute the query
49
40
  let entitiesFromDb = [];
50
41
  if (idsToFetch.length > 0) {
51
- entitiesFromDb = await this.em.find(this.entityClass, {
42
+ entitiesFromDb = await em.find(this.entityClass, {
52
43
  id: { $in: idsToFetch },
53
44
  }, { limit: idsToFetch.length });
54
45
  }
55
- // Merge results from UnitOfWork and database query
56
46
  const allEntities = [...entitiesFromUow, ...entitiesFromDb];
57
- // Return results in the original order
58
47
  return ids.map((id) => {
59
48
  return allEntities.find((entity) => entity.id === id) ?? null;
60
49
  });
61
50
  }, { cache: false });
62
- }
63
- get #createDataLoader() {
64
- return new DataLoader(async (data) => {
51
+ const create = new DataLoader(async (data) => {
65
52
  const entities = data.map((item) => {
66
- return this.em.create(this.entityClass, item, {
53
+ return em.create(this.entityClass, item, {
67
54
  persist: true,
68
55
  });
69
56
  });
70
- await this.em.flush();
57
+ await em.flush();
71
58
  return entities;
72
59
  }, { cache: false });
73
- }
74
- get #updateDataLoader() {
75
- return new DataLoader(async (items) => {
60
+ const update = new DataLoader(async (items) => {
76
61
  const entitiesOrErrors = (await Promise.all(items.map(({ idOrEntity }) => this.findOne(idOrEntity)))).map((entity) => {
77
62
  if (entity === null) {
78
63
  return new NotFoundException(`${this.entityClass.name.toLowerCase()}.not_found`);
@@ -84,16 +69,13 @@ export class EntityService {
84
69
  return entityOrError;
85
70
  }
86
71
  const { data, options } = items[index];
87
- // Filter out undefined values
88
72
  const filteredData = Object.fromEntries(Object.entries(data).filter(([, value]) => value !== undefined));
89
- this.em.assign(entityOrError, filteredData, options);
73
+ em.assign(entityOrError, filteredData, options);
90
74
  });
91
- await this.em.flush();
75
+ await em.flush();
92
76
  return entitiesOrErrors;
93
77
  }, { cache: false });
94
- }
95
- get #removeDataLoader() {
96
- return new DataLoader(async (items) => {
78
+ const remove = new DataLoader(async (items) => {
97
79
  const entitiesOrErrors = (await Promise.all(items.map(({ idOrEntity }) => this.findOne(idOrEntity)))).map((entity) => {
98
80
  if (entity === null) {
99
81
  return new NotFoundException(`${this.entityClass.name.toLowerCase()}.not_found`);
@@ -111,115 +93,63 @@ export class EntityService {
111
93
  entityOrError[softDeleteKey] = new Date();
112
94
  }
113
95
  else {
114
- this.em.remove(entityOrError);
96
+ em.remove(entityOrError);
115
97
  }
116
98
  });
117
- await this.em.flush();
99
+ await em.flush();
118
100
  return entitiesOrErrors;
119
101
  };
120
- if (this.em.isInTransaction()) {
102
+ if (em.isInTransaction()) {
121
103
  return await removeHandler();
122
104
  }
123
- return await this.em.transactional(removeHandler);
105
+ return await em.transactional(removeHandler);
124
106
  }, { cache: false });
107
+ return {
108
+ create,
109
+ findOne,
110
+ remove,
111
+ update,
112
+ };
125
113
  }
126
- /**
127
- * Creates a new entity and persists it.
128
- * @param data - The entity data to create
129
- * @returns The created entity
130
- */
131
114
  create(data) {
132
- return this.#createDataLoader.load(data);
115
+ return this.#dataLoaders.create.load(data);
133
116
  }
134
- /**
135
- * Finds a single entity by ID, entity reference, or filter query.
136
- * @param idOrEntityOrWhere - The entity ID, entity instance, or filter query
137
- * @returns The found entity or null
138
- */
139
117
  async findOne(idOrEntityOrWhere) {
140
- if (_.isPlainObject(idOrEntityOrWhere)) {
118
+ if (isPlainObject(idOrEntityOrWhere)) {
141
119
  return await this.em.findOne(this.entityClass, idOrEntityOrWhere);
142
120
  }
143
121
  else {
144
- return (await this.#getDataLoader.load({
122
+ return (await this.#dataLoaders.findOne.load({
145
123
  idOrEntity: idOrEntityOrWhere,
146
124
  }));
147
125
  }
148
126
  }
149
- /**
150
- * Finds a single entity by ID, entity reference, or filter query, throwing if not found.
151
- * @param idOrEntityOrWhere - The entity ID, entity instance, or filter query
152
- * @returns The found entity
153
- * @throws NotFoundException if the entity is not found
154
- */
155
127
  async findOneOrFail(idOrEntityOrWhere) {
156
128
  const entity = await this.findOne(idOrEntityOrWhere);
157
129
  if (entity === null) {
158
- throw new NotFoundException(`${_.capitalize(this.entityClass.name)} not found`);
130
+ throw new NotFoundException(`${capitalize(this.entityClass.name)} not found`);
159
131
  }
160
132
  return entity;
161
133
  }
162
- /**
163
- * Finds all entities matching the given filter query.
164
- * @param where - Filter query
165
- * @param options - Find options (populate, limit, offset, etc.)
166
- * @returns Array of matching entities
167
- */
168
134
  async findAll(where, options) {
169
135
  return await this.em.find(this.entityClass, where, options);
170
136
  }
171
- /**
172
- * Counts entities matching the given filter query.
173
- * @param where - Filter query
174
- * @param options - Count options
175
- * @returns The number of matching entities
176
- */
177
137
  async count(where, options) {
178
138
  return await this.em.count(this.entityClass, where, options);
179
139
  }
180
- /**
181
- * Updates an entity by ID or reference.
182
- * @param idOrEntity - The entity ID or entity instance to update
183
- * @param data - The data to assign to the entity
184
- * @param options - Optional assign options
185
- * @returns The updated entity
186
- * @throws NotFoundException if the entity is not found
187
- */
188
140
  async update(idOrEntity, data, options) {
189
- const entity = await this.#updateDataLoader.load({
141
+ return await this.#dataLoaders.update.load({
190
142
  idOrEntity,
191
143
  data,
192
144
  options,
193
145
  });
194
- if (entity instanceof Error) {
195
- throw entity;
196
- }
197
- return entity;
198
146
  }
199
- /**
200
- * Removes an entity by ID or reference (supports soft-delete).
201
- * @param idOrEntity - The entity ID or entity instance to remove
202
- * @param softDelete - Whether to soft-delete (default: true)
203
- * @returns The removed entity
204
- * @throws NotFoundException if the entity is not found
205
- */
206
147
  async remove(idOrEntity, softDelete = true) {
207
- const entity = await this.#removeDataLoader.load({
148
+ return await this.#dataLoaders.remove.load({
208
149
  idOrEntity,
209
150
  softDelete,
210
151
  });
211
- if (entity instanceof Error) {
212
- throw entity;
213
- }
214
- return entity;
215
152
  }
216
- /**
217
- * Iterates over entities in chunks ordered by ID, useful for batch processing.
218
- * @param where - Filter query
219
- * @param options - Find options (limit determines chunk size)
220
- * @param callback - Async callback invoked with each chunk of entities
221
- * @returns This service instance for chaining
222
- */
223
153
  async chunkById(where, options, callback) {
224
154
  let lastId;
225
155
  let count = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"entity.service.js","sourceRoot":"","sources":["../../src/services/entity.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAcL,UAAU,GAGX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAQ,MAAM,gBAAgB,CAAC;AACzD,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,CAAC,MAAM,QAAQ,CAAC;AAkCvB;;;;;;;;;GASG;AACH,MAAM,OAAO,aAAa;IAQH;IACA;IACA;IATrB;;;;;OAKG;IACH,YACqB,WAAyB,EACzB,EAAiB,EACjB,OAAsC;QAFtC,gBAAW,GAAX,WAAW,CAAc;QACzB,OAAE,GAAF,EAAE,CAAe;QACjB,YAAO,GAAP,OAAO,CAA+B;IACxD,CAAC;IAEJ,IAAI,cAAc;QAChB,OAAO,IAAI,UAAU,CACnB,KAAK,EAAE,KAAqC,EAAE,EAAE;YAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;YAEpC,cAAc;YACd,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CACvC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAC5D,CAAC;YAEF,2DAA2D;YAC3D,MAAM,eAAe,GAAqB,EAAE,CAAC;YAC7C,MAAM,UAAU,GAAiC,EAAE,CAAC;YAEpD,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;gBACrB,mDAAmD;gBACnD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CACxB,IAAI,CAAC,WAAW,EAChB,EAAqB,CACtB,CAAC;gBAEF,IAAI,MAAM,EAAE,CAAC;oBACX,eAAe,CAAC,IAAI,CAAC,MAAwB,CAAC,CAAC;gBACjD,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yD,EACzD,QAEkB;QAElB,IAAI,MAA4C,CAAC;QACjD,IAAI,KAAK,GAAG,CAAC,CAAC;QAEd,GAAG,CAAC;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CACjC,IAAI,CAAC,WAAW,EAChB;gBACE,IAAI,EAAE;oBACJ,KAAK;oBACL,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACpE;aACgC,EACnC;gBACE,GAAG,OAAO;gBACV,OAAO,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,GAAG,EAAsC;aAC7D,CACT,CAAC;YAEF,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC;YAExB,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,MAAM,GAAI,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAY,EAAE,EAAE,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,MAAM;YACR,CAAC;YAED,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,QAAQ,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE;QAEzC,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -1,3 +1,2 @@
1
1
  import type { FindOptions, PopulatePath } from "@mikro-orm/core";
2
- /** Options for {@link EntityService.chunkById}, excluding offset and orderBy (managed internally). */
3
2
  export type ChunkByIdOptions<Entity, Hint extends string = never, Fields extends string = PopulatePath.ALL, Excludes extends string = never> = Omit<FindOptions<Entity, Hint, Fields, Excludes>, "offset" | "orderBy">;
@@ -1,3 +1,2 @@
1
1
  import type { IdEntity } from "../interfaces/id-entity.interface.js";
2
- /** Accepts either an entity's ID value or the entity instance itself. */
3
2
  export type IdOrEntity<Entity extends IdEntity> = Entity["id"] | Entity;
@@ -1,37 +1,18 @@
1
- import { Configuration, type IDatabaseDriver } from "@mikro-orm/core";
2
- /** Constructor type for a MikroORM database driver. */
1
+ import { Configuration, IDatabaseDriver, type Options } from "@mikro-orm/core";
3
2
  export type DatabaseDriverConstructor = new (config: Configuration) => IDatabaseDriver;
4
- /** Database driver configuration for MikroORM. */
5
3
  export interface DriverConfig {
6
- /** Database driver class constructor. */
7
4
  driver?: DatabaseDriverConstructor;
8
5
  }
9
- /** URL-based database connection configuration. */
10
6
  export interface UrlConfig {
11
- /** Database connection URL. */
12
7
  clientUrl?: string;
13
8
  }
14
- /** Host-based database connection configuration. */
15
9
  export interface HostConfig {
16
- /** Database host. */
17
10
  host?: string;
18
- /** Database port. */
19
11
  port?: number;
20
- /** Database name. */
21
12
  dbName?: string;
22
- /** Database user. */
23
13
  user?: string;
24
- /** Database password. */
25
14
  password?: string;
15
+ schema?: string;
16
+ driverOptions?: Options["driverOptions"];
26
17
  }
27
- /**
28
- * Loads MikroORM configuration from environment variables.
29
- *
30
- * @remarks
31
- * Supports both connection URL (`DB_URL` / `DATABASE_URL`) and individual
32
- * host/port/dbName/user/password variables. Automatically resolves the
33
- * database driver based on the URL protocol or `DB_TYPE`.
34
- *
35
- * @returns MikroORM options derived from environment variables
36
- */
37
- export declare function loadConfigFromEnv(): Promise<DriverConfig & (UrlConfig | HostConfig)>;
18
+ export declare function loadConfigFromEnv(): Promise<DriverConfig & HostConfig>;
@@ -1,74 +1,201 @@
1
- import { DataloaderType, } from "@mikro-orm/core";
2
- import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
3
- async function getDriver(type) {
4
- switch (type) {
5
- case "mysql":
1
+ import { readFile } from "node:fs/promises";
2
+ import { fileURLToPath } from "node:url";
3
+ import { loadDefaultConfig } from "./load-default-config.util.js";
4
+ async function getDriver(protocol) {
5
+ switch (protocol) {
6
+ case "file:":
7
+ return (await import("@mikro-orm/sqlite")).SqliteDriver;
8
+ case "mysql:":
6
9
  return (await import("@mikro-orm/mysql")).MySqlDriver;
7
- case "postgres":
8
- case "postgresql":
10
+ case "postgres:":
11
+ case "postgresql:":
9
12
  return (await import("@mikro-orm/postgresql")).PostgreSqlDriver;
13
+ default:
14
+ throw new TypeError(`Unsupported DATABASE_URL protocol: ${protocol}`);
10
15
  }
11
16
  }
12
- /**
13
- * Loads MikroORM configuration from environment variables.
14
- *
15
- * @remarks
16
- * Supports both connection URL (`DB_URL` / `DATABASE_URL`) and individual
17
- * host/port/dbName/user/password variables. Automatically resolves the
18
- * database driver based on the URL protocol or `DB_TYPE`.
19
- *
20
- * @returns MikroORM options derived from environment variables
21
- */
22
- export async function loadConfigFromEnv() {
23
- const baseConfig = {
24
- colors: false,
25
- debug: !!(process.env.DB_DEBUG ?? process.env.DATABASE_DEBUG),
26
- dataloader: DataloaderType.ALL,
27
- timezone: "UTC",
28
- metadataProvider: TsMorphMetadataProvider,
29
- entities: ["dist/**/*.entity.js"],
30
- entitiesTs: ["src/**/*.entity.ts"],
31
- migrations: {
32
- snapshot: false,
33
- path: "dist/database/migrations",
34
- pathTs: "src/database/migrations",
35
- },
36
- seeder: {
37
- path: "dist/database/seeders",
38
- pathTs: "src/database/seeders",
39
- defaultSeeder: "DatabaseSeeder",
40
- fileName: (className) => className,
41
- },
17
+ function normalizeHostname(hostname) {
18
+ if (hostname.startsWith("[") && hostname.endsWith("]")) {
19
+ return hostname.slice(1, -1);
20
+ }
21
+ return hostname;
22
+ }
23
+ async function loadTlsFiles(files) {
24
+ const ssl = {};
25
+ let hasTlsFile = false;
26
+ for (const [path, sslKey] of files) {
27
+ if (typeof path === "string" && path) {
28
+ ssl[sslKey] = await readFile(path, "utf8");
29
+ hasTlsFile = true;
30
+ }
31
+ }
32
+ return hasTlsFile ? ssl : undefined;
33
+ }
34
+ async function loadPostgreSqlTlsFiles(connection) {
35
+ const ssl = await loadTlsFiles([
36
+ [connection.sslrootcert, "ca"],
37
+ [connection.sslcert, "cert"],
38
+ [connection.sslkey, "key"],
39
+ ]);
40
+ delete connection.sslrootcert;
41
+ delete connection.sslcert;
42
+ delete connection.sslkey;
43
+ return ssl;
44
+ }
45
+ async function loadMySqlTlsConfig(connection) {
46
+ const supportedParameters = ["ssl-mode", "ssl-ca", "ssl-cert", "ssl-key"];
47
+ for (const parameter of Object.keys(connection)) {
48
+ if (!supportedParameters.includes(parameter)) {
49
+ throw new TypeError(`Unsupported MySQL DATABASE_URL parameter: ${parameter}`);
50
+ }
51
+ }
52
+ const sslMode = connection["ssl-mode"];
53
+ const tlsFiles = [
54
+ [connection["ssl-ca"], "ca"],
55
+ [connection["ssl-cert"], "cert"],
56
+ [connection["ssl-key"], "key"],
57
+ ];
58
+ delete connection["ssl-ca"];
59
+ delete connection["ssl-cert"];
60
+ delete connection["ssl-key"];
61
+ delete connection["ssl-mode"];
62
+ const normalizedSslMode = typeof sslMode === "string" ? sslMode.toUpperCase() : sslMode;
63
+ if (normalizedSslMode === "DISABLED") {
64
+ connection.ssl = false;
65
+ return;
66
+ }
67
+ if (normalizedSslMode === "PREFERRED") {
68
+ throw new TypeError("Unsupported MySQL ssl-mode: PREFERRED");
69
+ }
70
+ const ssl = await loadTlsFiles(tlsFiles);
71
+ switch (normalizedSslMode) {
72
+ case "REQUIRED":
73
+ connection.ssl = { ...ssl, rejectUnauthorized: false };
74
+ break;
75
+ case "VERIFY_CA":
76
+ if (!ssl?.ca) {
77
+ throw new TypeError("MySQL ssl-mode=VERIFY_CA requires ssl-ca");
78
+ }
79
+ connection.ssl = {
80
+ ...ssl,
81
+ rejectUnauthorized: true,
82
+ verifyIdentity: false,
83
+ };
84
+ break;
85
+ case "VERIFY_IDENTITY":
86
+ if (!ssl?.ca) {
87
+ throw new TypeError("MySQL ssl-mode=VERIFY_IDENTITY requires ssl-ca");
88
+ }
89
+ connection.ssl = {
90
+ ...ssl,
91
+ rejectUnauthorized: true,
92
+ verifyIdentity: true,
93
+ };
94
+ break;
95
+ case undefined:
96
+ if (ssl) {
97
+ connection.ssl = {
98
+ ...ssl,
99
+ rejectUnauthorized: true,
100
+ verifyIdentity: false,
101
+ };
102
+ }
103
+ break;
104
+ default:
105
+ throw new TypeError(`Unsupported MySQL ssl-mode: ${String(sslMode)}`);
106
+ }
107
+ }
108
+ async function loadQueryConfig(url, protocol) {
109
+ const connection = Object.fromEntries(url.searchParams);
110
+ const schema = url.searchParams.get("schema") ?? undefined;
111
+ delete connection.schema;
112
+ if (protocol === "mysql:") {
113
+ await loadMySqlTlsConfig(connection);
114
+ }
115
+ if (protocol === "postgres:" || protocol === "postgresql:") {
116
+ if (connection.ssl !== undefined) {
117
+ throw new TypeError("Unsupported PostgreSQL DATABASE_URL parameter: ssl");
118
+ }
119
+ if (connection.uselibpqcompat !== undefined) {
120
+ throw new TypeError("Unsupported PostgreSQL DATABASE_URL parameter: uselibpqcompat");
121
+ }
122
+ const sslMode = connection.sslmode;
123
+ delete connection.uselibpqcompat;
124
+ delete connection.sslmode;
125
+ if (sslMode === "disable") {
126
+ delete connection.sslrootcert;
127
+ delete connection.sslcert;
128
+ delete connection.sslkey;
129
+ connection.ssl = false;
130
+ }
131
+ else if (sslMode === "allow" || sslMode === "prefer") {
132
+ throw new TypeError(`Unsupported PostgreSQL sslmode: ${sslMode}`);
133
+ }
134
+ else {
135
+ const tls = await loadPostgreSqlTlsFiles(connection);
136
+ if (tls) {
137
+ connection.ssl = tls;
138
+ }
139
+ switch (sslMode) {
140
+ case "require":
141
+ connection.ssl = tls?.ca
142
+ ? { ...tls, checkServerIdentity: () => undefined }
143
+ : { ...tls, rejectUnauthorized: false };
144
+ break;
145
+ case "verify-ca":
146
+ if (!tls?.ca) {
147
+ throw new TypeError("PostgreSQL sslmode=verify-ca requires sslrootcert");
148
+ }
149
+ connection.ssl = { ...tls, checkServerIdentity: () => undefined };
150
+ break;
151
+ case "verify-full":
152
+ connection.ssl = tls ?? {};
153
+ break;
154
+ case undefined:
155
+ break;
156
+ default:
157
+ throw new TypeError(`Unsupported PostgreSQL sslmode: ${String(sslMode)}`);
158
+ }
159
+ }
160
+ }
161
+ return {
162
+ schema,
163
+ driverOptions: Object.keys(connection).length ? { connection } : undefined,
42
164
  };
43
- const dbUrl = process.env.DB_URL ?? process.env.DATABASE_URL;
44
- if (dbUrl) {
45
- const dbType = new URL(dbUrl).protocol.replace(":", "");
165
+ }
166
+ export async function loadConfigFromEnv() {
167
+ const baseConfig = loadDefaultConfig();
168
+ const databaseUrl = process.env.DATABASE_URL;
169
+ if (databaseUrl) {
170
+ const url = new URL(databaseUrl);
171
+ const driver = await getDriver(url.protocol);
172
+ if (url.protocol === "file:") {
173
+ return {
174
+ ...baseConfig,
175
+ driver,
176
+ dbName: fileURLToPath(url),
177
+ };
178
+ }
179
+ const dbName = url.pathname.slice(1);
46
180
  return {
47
181
  ...baseConfig,
48
- driver: await getDriver(dbType),
49
- clientUrl: dbUrl,
182
+ driver,
183
+ host: normalizeHostname(url.hostname),
184
+ port: +url.port,
185
+ dbName: dbName ? decodeURIComponent(dbName) : undefined,
186
+ user: decodeURIComponent(url.username),
187
+ password: decodeURIComponent(url.password),
188
+ ...(await loadQueryConfig(url, url.protocol)),
50
189
  };
51
190
  }
52
- const dbType = process.env.DB_TYPE ?? process.env.DATABASE_TYPE;
53
- const dbHost = process.env.DB_HOST ?? process.env.DATABASE_HOST;
54
- const dbPort = process.env.DB_PORT ?? process.env.DATABASE_PORT;
55
- const dbName = process.env.DB_NAME ?? process.env.DB_DATABASE ?? process.env.DATABASE_NAME;
56
- const dbUsername = process.env.DB_USER ??
57
- process.env.DB_USERNAME ??
58
- process.env.DATABASE_USER ??
59
- process.env.DATABASE_USERNAME;
60
- const dbPassword = process.env.DB_PASS ??
61
- process.env.DB_PASSWORD ??
62
- process.env.DATABASE_PASS ??
63
- process.env.DATABASE_PASSWORD;
64
191
  return {
65
192
  ...baseConfig,
66
- driver: await getDriver(dbType),
67
- host: dbHost,
68
- port: dbPort ? +dbPort : undefined,
69
- dbName,
70
- user: dbUsername,
71
- password: dbPassword,
193
+ driver: undefined,
194
+ host: undefined,
195
+ port: undefined,
196
+ dbName: undefined,
197
+ user: undefined,
198
+ password: undefined,
72
199
  };
73
200
  }
74
201
  //# sourceMappingURL=load-config-from-env.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-config-from-env.util.js","sourceRoot":"","sources":["../../src/utils/load-config-from-env.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,KAAK,UAAU,SAAS,CACtB,IAAa;IAEb,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC;QACxD,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY;YACf,OAAO,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IACpE,CAAC;AACH,CAAC;AAiCD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IAGrC,MAAM,UAAU,GAAqB;QACnC,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC7D,UAAU,EAAE,cAAc,CAAC,GAAG;QAC9B,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,uBAAuB;QACzC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;QACjC,UAAU,EAAE,CAAC,oBAAoB,CAAC;QAClC,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,0BAA0B;YAChC,MAAM,EAAE,yBAAyB;SAClC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,uBAAuB;YAC7B,MAAM,EAAE,sBAAsB;YAC9B,aAAa,EAAE,gBAAgB;YAC/B,QAAQ,EAAE,CAA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AAC;SAC9C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,UAAU;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,SAAS;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { DataloaderType } from "@mikro-orm/core";
2
+ import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
3
+ export declare function loadDefaultConfig(): {
4
+ colors: false;
5
+ debug: false;
6
+ dataloader: DataloaderType.ALL;
7
+ timezone: string;
8
+ metadataProvider: typeof TsMorphMetadataProvider;
9
+ entities: string[];
10
+ entitiesTs: string[];
11
+ migrations: {
12
+ snapshot: false;
13
+ path: string;
14
+ pathTs: string;
15
+ };
16
+ seeder: {
17
+ path: string;
18
+ pathTs: string;
19
+ defaultSeeder: string;
20
+ fileName: (className: string) => string;
21
+ };
22
+ };
@@ -0,0 +1,25 @@
1
+ import { DataloaderType } from "@mikro-orm/core";
2
+ import { TsMorphMetadataProvider } from "@mikro-orm/reflection";
3
+ export function loadDefaultConfig() {
4
+ return {
5
+ colors: false,
6
+ debug: false,
7
+ dataloader: DataloaderType.ALL,
8
+ timezone: "UTC",
9
+ metadataProvider: TsMorphMetadataProvider,
10
+ entities: ["dist/**/*.entity.js"],
11
+ entitiesTs: ["src/**/*.entity.ts"],
12
+ migrations: {
13
+ snapshot: false,
14
+ path: "dist/database/migrations",
15
+ pathTs: "src/database/migrations",
16
+ },
17
+ seeder: {
18
+ path: "dist/database/seeders",
19
+ pathTs: "src/database/seeders",
20
+ defaultSeeder: "DatabaseSeeder",
21
+ fileName: (className) => className,
22
+ },
23
+ };
24
+ }
25
+ //# sourceMappingURL=load-default-config.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-default-config.util.js","sourceRoot":"","sources":["../../src/utils/load-default-config.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAKhE,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,KAAK;QACZ,UAAU,EAAE,cAAc,CAAC,GAAG;QAC9B,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,uBAAuB;QACzC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;QACjC,UAAU,EAAE,CAAC,oBAAoB,CAAC;QAClC,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,0BAA0B;YAChC,MAAM,EAAE,yBAAyB;SAClC;QACD,MAAM,EAAE;YACN,IAAI,EAAE,uBAAuB;YAC7B,MAAM,EAAE,sBAAsB;YAC9B,aAAa,EAAE,gBAAgB;YAC/B,QAAQ,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,SAAS;SAC3C;KAC8B,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-boot/mikro-orm",
3
- "version": "8.0.0-beta.0",
3
+ "version": "8.0.0-beta.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nest-boot/nest-boot.git",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "homepage": "",
16
16
  "license": "MIT",
17
- "main": "dist/index.js",
18
- "types": "dist/index.d.ts",
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
19
  "directories": {
20
20
  "lib": "dist"
21
21
  },
@@ -24,46 +24,48 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "dataloader": "^2.2.3",
27
- "lodash": "^4.17.21",
27
+ "lodash-es": "^4.17.21",
28
28
  "pgvector": "^0.2.1",
29
29
  "prettier": "^3.6.2",
30
30
  "sql-formatter": "^15.6.9"
31
31
  },
32
32
  "devDependencies": {
33
- "@mikro-orm/core": "7.1.4",
34
- "@mikro-orm/decorators": "7.1.4",
35
- "@mikro-orm/mysql": "7.1.4",
33
+ "@mikro-orm/core": "7.1.14",
34
+ "@mikro-orm/decorators": "7.1.14",
35
+ "@mikro-orm/mysql": "7.1.14",
36
36
  "@mikro-orm/nestjs": "^7.0.2",
37
- "@mikro-orm/postgresql": "7.1.4",
38
- "@mikro-orm/reflection": "7.1.4",
39
- "@nestjs/common": "next",
40
- "@nestjs/core": "next",
41
- "@nestjs/testing": "next",
42
- "@types/lodash": "^4.17.20",
37
+ "@mikro-orm/postgresql": "7.1.14",
38
+ "@mikro-orm/reflection": "7.1.14",
39
+ "@mikro-orm/sqlite": "7.1.14",
40
+ "@nestjs/common": "^12.0.1",
41
+ "@nestjs/core": "^12.0.1",
42
+ "@nestjs/testing": "^12.0.1",
43
+ "@types/lodash-es": "^4.17.12",
43
44
  "@types/node": "^26.0.0",
44
- "@vitest/coverage-v8": "^4.1.2",
45
+ "@vitest/coverage-v8": "^4.1.11",
45
46
  "dataloader": "^2.2.3",
46
47
  "dotenv": "^17.2.3",
47
48
  "eslint": "^9.39.3",
48
49
  "reflect-metadata": "^0.2.2",
49
50
  "rxjs": "^7.8.2",
50
51
  "typescript": "^6.0.3",
51
- "vitest": "^4.1.2",
52
- "@nest-boot/eslint-config": "^8.0.0-beta.0",
53
- "@nest-boot/eslint-plugin": "^8.0.0-beta.0",
54
- "@nest-boot/request-context": "^8.0.0-beta.0",
55
- "@nest-boot/tsconfig": "^8.0.0-beta.0"
52
+ "vite-tsconfig-paths": "^5.1.4",
53
+ "vitest": "^4.1.11",
54
+ "@nest-boot/eslint-config": "^8.0.0-beta.2",
55
+ "@nest-boot/eslint-plugin": "^8.0.0-beta.2",
56
+ "@nest-boot/request-context": "^8.0.0-beta.2",
57
+ "@nest-boot/tsconfig": "^8.0.0-beta.2"
56
58
  },
57
59
  "peerDependencies": {
58
60
  "@mikro-orm/core": "^7.0.0",
59
61
  "@mikro-orm/decorators": "^7.0.0",
60
62
  "@mikro-orm/nestjs": "^7.0.0",
61
63
  "@mikro-orm/reflection": "^7.0.0",
62
- "@nestjs/common": "^12.0.0-alpha.5",
63
- "@nestjs/core": "^12.0.0-alpha.5",
64
+ "@nestjs/common": "^12.0.0",
65
+ "@nestjs/core": "^12.0.0",
64
66
  "reflect-metadata": "^0.2.2",
65
67
  "rxjs": "^7.0.0",
66
- "@nest-boot/request-context": "^8.0.0-beta.0"
68
+ "@nest-boot/request-context": "^8.0.0-beta.2"
67
69
  },
68
70
  "publishConfig": {
69
71
  "access": "public"
@@ -75,6 +77,16 @@
75
77
  ]
76
78
  },
77
79
  "type": "module",
80
+ "engines": {
81
+ "node": ">=26.0.0"
82
+ },
83
+ "exports": {
84
+ ".": {
85
+ "types": "./dist/index.d.ts",
86
+ "import": "./dist/index.js"
87
+ },
88
+ "./package.json": "./package.json"
89
+ },
78
90
  "scripts": {
79
91
  "build": "tsc -p tsconfig.build.json",
80
92
  "clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
@@ -84,6 +96,7 @@
84
96
  "test": "vitest run",
85
97
  "test:cov": "vitest run --coverage",
86
98
  "test:watch": "vitest",
87
- "test:debug": "vitest --inspect-brk --no-file-parallelism"
99
+ "test:debug": "vitest --inspect-brk --no-file-parallelism",
100
+ "test:e2e": "vitest run --config ./vitest.config.e2e.ts"
88
101
  }
89
102
  }