@mikro-orm/nestjs 5.1.0 → 5.1.1

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,5 @@
1
- import type { EntityName } from '@mikro-orm/core';
2
1
  import { Logger } from '@nestjs/common';
2
+ import type { EntityName } from './typings';
3
3
  export declare const MIKRO_ORM_MODULE_OPTIONS: unique symbol;
4
4
  export declare const CONTEXT_NAMES: string[];
5
5
  export declare const logger: Logger;
@@ -7,5 +7,5 @@ export declare const getMikroORMToken: (name: string) => string;
7
7
  export declare const InjectMikroORM: (name: string) => (target: object, key: string | symbol, index?: number | undefined) => void;
8
8
  export declare const getEntityManagerToken: (name: string) => string;
9
9
  export declare const InjectEntityManager: (name: string) => (target: object, key: string | symbol, index?: number | undefined) => void;
10
- export declare const getRepositoryToken: <T>(entity: EntityName<T>, name?: string | undefined) => string;
11
- export declare const InjectRepository: <T>(entity: EntityName<T>, name?: string | undefined) => (target: object, key: string | symbol, index?: number | undefined) => void;
10
+ export declare const getRepositoryToken: <T>(entity: EntityName<T>, name?: string) => string;
11
+ export declare const InjectRepository: <T>(entity: EntityName<T>, name?: string) => (target: object, key: string | symbol, index?: number | undefined) => void;
@@ -1,4 +1,5 @@
1
- import type { AnyEntity, EntityName } from '@mikro-orm/core';
1
+ import type { AnyEntity } from '@mikro-orm/core';
2
+ import type { EntityName } from './typings';
2
3
  export declare class MikroOrmEntitiesStorage {
3
4
  private static readonly storage;
4
5
  static addEntity(entity: EntityName<AnyEntity>, contextName?: string): void;
@@ -1,6 +1,6 @@
1
- import type { AnyEntity, EntityName } from '@mikro-orm/core';
1
+ import type { AnyEntity } from '@mikro-orm/core';
2
2
  import type { DynamicModule } from '@nestjs/common';
3
- import type { MikroOrmModuleAsyncOptions, MikroOrmModuleSyncOptions, MikroOrmMiddlewareModuleOptions, MikroOrmModuleFeatureOptions } from './typings';
3
+ import type { MikroOrmModuleAsyncOptions, MikroOrmModuleSyncOptions, MikroOrmMiddlewareModuleOptions, MikroOrmModuleFeatureOptions, EntityName } from './typings';
4
4
  export declare class MikroOrmModule {
5
5
  static forRoot(options?: MikroOrmModuleSyncOptions): DynamicModule;
6
6
  static forRootAsync(options: MikroOrmModuleAsyncOptions): DynamicModule;
@@ -1,6 +1,6 @@
1
- import type { AnyEntity, EntityName } from '@mikro-orm/core';
1
+ import type { AnyEntity } from '@mikro-orm/core';
2
2
  import { EntityManager } from '@mikro-orm/core';
3
- import type { MikroOrmModuleAsyncOptions } from './typings';
3
+ import type { MikroOrmModuleAsyncOptions, EntityName } from './typings';
4
4
  import type { Provider, Type } from '@nestjs/common';
5
5
  import { Scope } from '@nestjs/common';
6
6
  export declare function createMikroOrmProvider(contextName?: string): Provider;
@@ -27,6 +27,14 @@ function createMikroOrmProvider(contextName) {
27
27
  }
28
28
  exports.createMikroOrmProvider = createMikroOrmProvider;
29
29
  function createEntityManagerProvider(scope = common_1.Scope.DEFAULT, entityManager = core_1.EntityManager, contextName) {
30
+ if (!contextName && entityManager !== core_1.EntityManager) {
31
+ return {
32
+ provide: entityManager,
33
+ scope,
34
+ useFactory: (em) => em,
35
+ inject: [core_1.EntityManager], // depend on the EM from core package
36
+ };
37
+ }
30
38
  return {
31
39
  provide: contextName ? (0, mikro_orm_common_1.getEntityManagerToken)(contextName) : entityManager,
32
40
  scope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/nestjs",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Martin Adamek",
@@ -66,8 +66,8 @@
66
66
  "@types/jest": "^28.0.0",
67
67
  "@types/node": "^17.0.17",
68
68
  "@types/supertest": "^2.0.11",
69
- "@typescript-eslint/eslint-plugin": "~5.26.0",
70
- "@typescript-eslint/parser": "~5.26.0",
69
+ "@typescript-eslint/eslint-plugin": "~5.33.0",
70
+ "@typescript-eslint/parser": "~5.33.0",
71
71
  "conventional-changelog": "^3.1.25",
72
72
  "conventional-changelog-cli": "^2.2.2",
73
73
  "eslint": "^8.9.0",
@@ -76,7 +76,7 @@
76
76
  "supertest": "^6.2.2",
77
77
  "ts-jest": "^28.0.0",
78
78
  "ts-node": "^10.5.0",
79
- "typescript": "4.6.4"
79
+ "typescript": "4.7.4"
80
80
  },
81
81
  "commitlint": {
82
82
  "extends": [
package/typings.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AnyEntity, EntityName, IDatabaseDriver, Options } from '@mikro-orm/core';
1
+ import type { AnyEntity, EntityName as CoreEntityName, EntitySchema, IDatabaseDriver, Options } from '@mikro-orm/core';
2
2
  import type { MiddlewareConsumer, ModuleMetadata, Scope, Type } from '@nestjs/common';
3
3
  import type { AbstractHttpAdapter } from '@nestjs/core';
4
4
  export interface NestMiddlewareConsumer extends MiddlewareConsumer {
@@ -37,4 +37,5 @@ export interface MikroOrmModuleAsyncOptions<D extends IDatabaseDriver = IDatabas
37
37
  useFactory?: (...args: any[]) => Promise<Omit<MikroOrmModuleOptions<D>, 'contextName'>> | Omit<MikroOrmModuleOptions<D>, 'contextName'>;
38
38
  inject?: any[];
39
39
  }
40
+ export declare type EntityName<T extends AnyEntity<T>> = CoreEntityName<T> | EntitySchema<any>;
40
41
  export {};