@mikro-orm/nestjs 6.1.0 → 6.1.2-dev.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Dario Mancuso, Martin Adámek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -132,7 +132,7 @@ Instead of relying on this discovery, you can provide the driver type explicitly
132
132
  export class AppModule {}
133
133
  ```
134
134
 
135
- ## Auto entities automatically
135
+ ## Load entities automatically
136
136
 
137
137
  Manually adding entities to the entities array of the connection options can be
138
138
  tedious. In addition, referencing entities from the root module breaks application
@@ -178,7 +178,7 @@ But middlewares are executed only for regular HTTP request handles, what if we n
178
178
  a request scoped method outside of that? One example of that is queue handlers or
179
179
  scheduled tasks.
180
180
 
181
- We can use the `@UseRequestContext()` decorator. It requires you to first inject the
181
+ We can use the `@CreateRequestContext()` decorator. It requires you to first inject the
182
182
  `MikroORM` instance to current context, it will be then used to create the context
183
183
  for you. Under the hood, the decorator will register new request context for your
184
184
  method and execute it inside the context.
@@ -189,7 +189,7 @@ export class MyService {
189
189
 
190
190
  constructor(private readonly orm: MikroORM) { }
191
191
 
192
- @UseRequestContext()
192
+ @CreateRequestContext()
193
193
  async doSomething() {
194
194
  // this will be executed in a separate context
195
195
  }
@@ -1,3 +1,3 @@
1
1
  import type { MikroOrmMiddlewareModuleOptions } from './typings';
2
- import type { MiddlewareConsumer } from '@nestjs/common';
2
+ import { type MiddlewareConsumer } from '@nestjs/common';
3
3
  export declare function forRoutesPath(options: MikroOrmMiddlewareModuleOptions, consumer: MiddlewareConsumer): string;
@@ -1,13 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.forRoutesPath = forRoutesPath;
4
+ const common_1 = require("@nestjs/common");
4
5
  function forRoutesPath(options, consumer) {
5
- const isNestMiddleware = (consumer) => {
6
- return typeof consumer.httpAdapter === 'object';
7
- };
8
- const usingFastify = (consumer) => {
6
+ if (options.forRoutesPath) {
7
+ return options.forRoutesPath;
8
+ }
9
+ // detect nest v11 based on a newly added enum value
10
+ if (common_1.HttpStatus.MULTI_STATUS) {
11
+ return '{*all}';
12
+ }
13
+ const isFastify = (consumer) => {
14
+ if (typeof consumer.httpAdapter !== 'object') {
15
+ return false;
16
+ }
9
17
  return consumer.httpAdapter.constructor.name.toLowerCase().startsWith('fastify');
10
18
  };
11
- return options.forRoutesPath ??
12
- (isNestMiddleware(consumer) && usingFastify(consumer) ? '(.*)' : '*');
19
+ return isFastify(consumer) ? '(.*)' : '*';
13
20
  }
@@ -65,7 +65,7 @@ async function tryRequire(name) {
65
65
  }
66
66
  // TODO: provide the package name via some platform method, prefer that over the static map when available
67
67
  const PACKAGES = {
68
- MongoDriver: '@mikro-orm/mongo',
68
+ MongoDriver: '@mikro-orm/mongodb',
69
69
  MySqlDriver: '@mikro-orm/mysql',
70
70
  MsSqlDriver: '@mikro-orm/mssql',
71
71
  MariaDbDriver: '@mikro-orm/mariadb',
@@ -248,7 +248,7 @@ let MikroOrmCoreModule = MikroOrmCoreModule_1 = class MikroOrmCoreModule {
248
248
  return config?.getDriver().createEntityManager();
249
249
  }
250
250
  catch {
251
- if (options && 'useFactory' in options && 'inject' in options && options.inject.length > 0) {
251
+ if (options && 'useFactory' in options && 'inject' in options && !options.driver && options.inject.length > 0) {
252
252
  // eslint-disable-next-line no-console
253
253
  console.warn('Support for driver specific imports in modules defined with `useFactory` and `inject` requires an explicit `driver` option. See https://github.com/mikro-orm/nestjs/pull/204');
254
254
  }
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var MikroOrmModule_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.MikroOrmModule = void 0;
11
- const core_1 = require("@mikro-orm/core");
12
11
  const common_1 = require("@nestjs/common");
13
12
  const mikro_orm_core_module_1 = require("./mikro-orm-core.module");
14
13
  const mikro_orm_middleware_module_1 = require("./mikro-orm-middleware.module");
@@ -39,7 +38,7 @@ let MikroOrmModule = MikroOrmModule_1 = class MikroOrmModule {
39
38
  const name = (Array.isArray(options) || contextName) ? contextName : options.contextName;
40
39
  const providers = (0, mikro_orm_providers_1.createMikroOrmRepositoryProviders)(entities, name);
41
40
  for (const e of entities) {
42
- if (!core_1.Utils.isString(e)) {
41
+ if (typeof e !== 'string') {
43
42
  mikro_orm_entities_storage_1.MikroOrmEntitiesStorage.addEntity(e, name);
44
43
  }
45
44
  }
@@ -29,7 +29,7 @@ function createMikroOrmProvider(contextName, type = core_1.MikroORM) {
29
29
  if (!options || Object.keys(options).length === 0) {
30
30
  const config = await core_1.ConfigurationLoader.getConfiguration();
31
31
  config.set('logger', mikro_orm_common_1.logger.log.bind(mikro_orm_common_1.logger));
32
- options = config;
32
+ options = config.getAll();
33
33
  }
34
34
  return core_1.MikroORM.init(options);
35
35
  },
@@ -48,7 +48,7 @@ function createEntityManagerProvider(scope = common_1.Scope.DEFAULT, entityManag
48
48
  return {
49
49
  provide: contextName ? (0, mikro_orm_common_1.getEntityManagerToken)(contextName) : entityManager,
50
50
  scope,
51
- useFactory: (orm) => scope === common_1.Scope.DEFAULT ? orm.em : orm.em.fork(forkOptions),
51
+ useFactory: (orm) => scope === common_1.Scope.DEFAULT ? orm.em : orm.em.fork({ useContext: true, ...forkOptions }),
52
52
  inject: [contextName ? (0, mikro_orm_common_1.getMikroORMToken)(contextName) : core_1.MikroORM],
53
53
  };
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/nestjs",
3
- "version": "6.1.0",
3
+ "version": "6.1.2-dev.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Martin Adamek",
@@ -31,16 +31,17 @@
31
31
  },
32
32
  "readme": "./README.md",
33
33
  "scripts": {
34
- "build": "rm -rf dist && tsc -p tsconfig.build.json && cp package.json README.md dist/",
34
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && cp package.json README.md ",
35
+ "copy": "node scripts/copy.mjs",
35
36
  "test": "jest --runInBand",
36
37
  "tsc-check-tests": "tsc --noEmit --project tests/tsconfig.json",
37
38
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
38
39
  "release": "yarn build && cd dist && npm publish && cd ..",
39
40
  "coverage": "yarn test --coverage",
40
- "lint": "eslint src/**/*.ts"
41
+ "lint": "eslint **/*.js"
41
42
  },
42
43
  "peerDependencies": {
43
- "@mikro-orm/core": "^6.0.0 || ^6.0.0-dev.0",
44
+ "@mikro-orm/core": "^6.0.0 || ^6.0.0-dev.0 || ^7.0.0-dev.0",
44
45
  "@nestjs/common": "^10.0.0 || ^11.0.5",
45
46
  "@nestjs/core": "^10.0.0 || ^11.0.5"
46
47
  },
@@ -51,21 +52,21 @@
51
52
  "@nestjs/core": "^11.0.5",
52
53
  "@nestjs/platform-express": "^11.0.5",
53
54
  "@nestjs/testing": "^11.0.5",
55
+ "@stylistic/eslint-plugin-ts": "^4.0.0",
54
56
  "@types/jest": "^29.5.12",
55
- "@types/node": "^22.0.0",
56
- "@types/supertest": "^6.0.2",
57
- "@typescript-eslint/eslint-plugin": "~7.18.0",
58
- "@typescript-eslint/parser": "~7.18.0",
59
- "conventional-changelog": "^6.0.0",
57
+ "@types/node": "^24.0.0",
58
+ "@types/supertest": "^7.0.0",
59
+ "conventional-changelog": "^7.0.0",
60
60
  "conventional-changelog-cli": "^5.0.0",
61
- "eslint": "^8.57.0",
62
- "eslint-plugin-import": "^2.29.1",
61
+ "eslint": "^9.19.0",
62
+ "eslint-plugin-import": "^2.31.0",
63
63
  "jest": "^29.7.0",
64
64
  "rxjs": "^7.8.1",
65
65
  "supertest": "^7.0.0",
66
66
  "ts-jest": "^29.1.2",
67
67
  "ts-node": "^10.9.2",
68
- "typescript": "5.7.3"
68
+ "typescript": "5.9.3",
69
+ "typescript-eslint": "^8.22.0"
69
70
  },
70
71
  "commitlint": {
71
72
  "extends": [
@@ -74,7 +75,7 @@
74
75
  },
75
76
  "lint-staged": {
76
77
  "*.ts": [
77
- "eslint src/**/*.ts --fix"
78
+ "eslint **/*.js --fix"
78
79
  ]
79
80
  },
80
81
  "renovate": {
@@ -105,5 +106,5 @@
105
106
  "engines": {
106
107
  "node": ">= 18.12.0"
107
108
  },
108
- "packageManager": "yarn@4.6.0"
109
+ "packageManager": "yarn@4.12.0"
109
110
  }