@mikro-orm/nestjs 5.2.0 → 5.2.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.
@@ -2,6 +2,11 @@ import type { AnyEntity } from '@mikro-orm/core';
2
2
  import type { DynamicModule } from '@nestjs/common';
3
3
  import type { MikroOrmModuleAsyncOptions, MikroOrmModuleSyncOptions, MikroOrmMiddlewareModuleOptions, MikroOrmModuleFeatureOptions, EntityName } from './typings';
4
4
  export declare class MikroOrmModule {
5
+ /**
6
+ * Clears the entity storage. This is useful for testing purposes, when you want to isolate the tests.
7
+ * Keep in mind that this should be called when using a test runner that keeps the context alive between tests (like Vitest with threads disabled).
8
+ */
9
+ static clearStorage(contextName?: string): void;
5
10
  static forRoot(options?: MikroOrmModuleSyncOptions): DynamicModule;
6
11
  static forRootAsync(options: MikroOrmModuleAsyncOptions): DynamicModule;
7
12
  static forFeature(options: EntityName<AnyEntity>[] | MikroOrmModuleFeatureOptions, contextName?: string): DynamicModule;
@@ -15,6 +15,13 @@ const mikro_orm_core_module_1 = require("./mikro-orm-core.module");
15
15
  const mikro_orm_middleware_module_1 = require("./mikro-orm-middleware.module");
16
16
  const mikro_orm_entities_storage_1 = require("./mikro-orm.entities.storage");
17
17
  let MikroOrmModule = exports.MikroOrmModule = MikroOrmModule_1 = class MikroOrmModule {
18
+ /**
19
+ * Clears the entity storage. This is useful for testing purposes, when you want to isolate the tests.
20
+ * Keep in mind that this should be called when using a test runner that keeps the context alive between tests (like Vitest with threads disabled).
21
+ */
22
+ static clearStorage(contextName) {
23
+ mikro_orm_entities_storage_1.MikroOrmEntitiesStorage.clear(contextName);
24
+ }
18
25
  static forRoot(options) {
19
26
  return {
20
27
  module: MikroOrmModule_1,
@@ -9,6 +9,7 @@ function createMikroOrmProvider(contextName) {
9
9
  return {
10
10
  provide: contextName ? (0, mikro_orm_common_1.getMikroORMToken)(contextName) : core_1.MikroORM,
11
11
  useFactory: async (options) => {
12
+ options = { ...options };
12
13
  if (options?.autoLoadEntities) {
13
14
  options.entities = [...(options.entities || []), ...mikro_orm_entities_storage_1.MikroOrmEntitiesStorage.getEntities(contextName)];
14
15
  options.entitiesTs = [...(options.entitiesTs || []), ...mikro_orm_entities_storage_1.MikroOrmEntitiesStorage.getEntities(contextName)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/nestjs",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Martin Adamek",
@@ -54,17 +54,17 @@
54
54
  "@types/jest": "^29.5.2",
55
55
  "@types/node": "^20.3.1",
56
56
  "@types/supertest": "^2.0.12",
57
- "@typescript-eslint/eslint-plugin": "~5.60.0",
58
- "@typescript-eslint/parser": "~5.60.0",
59
- "conventional-changelog": "^3.1.25",
60
- "conventional-changelog-cli": "^2.2.2",
57
+ "@typescript-eslint/eslint-plugin": "~5.61.0",
58
+ "@typescript-eslint/parser": "~5.61.0",
59
+ "conventional-changelog": "^4.0.0",
60
+ "conventional-changelog-cli": "^3.0.0",
61
61
  "eslint": "^8.43.0",
62
62
  "jest": "^29.5.0",
63
63
  "rxjs": "^7.8.1",
64
64
  "supertest": "^6.3.3",
65
65
  "ts-jest": "^29.1.0",
66
66
  "ts-node": "^10.9.1",
67
- "typescript": "5.1.3"
67
+ "typescript": "5.1.6"
68
68
  },
69
69
  "commitlint": {
70
70
  "extends": [
@@ -104,5 +104,5 @@
104
104
  "engines": {
105
105
  "node": ">= 14.0.0"
106
106
  },
107
- "packageManager": "yarn@3.6.0"
107
+ "packageManager": "yarn@3.6.1"
108
108
  }