@midwayjs/mikro 3.13.9 → 3.14.3

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.
@@ -53,7 +53,14 @@ let MikroConfiguration = class MikroConfiguration {
53
53
  // https://mikro-orm.io/docs/identity-map
54
54
  this.applicationManager.getApplications().forEach(app => {
55
55
  app.useMiddleware(async (ctx, next) => {
56
- return await core_2.RequestContext.createAsync(entityManagers, next);
56
+ if (core_2.RequestContext['createAsync']) {
57
+ // mikro-orm 5.x
58
+ return await core_2.RequestContext['createAsync'](entityManagers, next);
59
+ }
60
+ else {
61
+ // mikro-orm 6.x
62
+ return await core_2.RequestContext.create(entityManagers, next);
63
+ }
57
64
  });
58
65
  });
59
66
  }
@@ -1,8 +1,9 @@
1
- import { DataSourceManager } from '@midwayjs/core';
1
+ import { DataSourceManager, MidwayLoggerService } from '@midwayjs/core';
2
2
  import { MikroORM, IDatabaseDriver, Connection } from '@mikro-orm/core';
3
3
  export declare class MikroDataSourceManager extends DataSourceManager<MikroORM<IDatabaseDriver<Connection>>> {
4
4
  mikroConfig: any;
5
5
  baseDir: string;
6
+ loggerService: MidwayLoggerService;
6
7
  init(): Promise<void>;
7
8
  getName(): string;
8
9
  protected createDataSource(config: any, dataSourceName: string): Promise<MikroORM<IDatabaseDriver<Connection>>>;
@@ -20,6 +20,12 @@ let MikroDataSourceManager = class MikroDataSourceManager extends core_1.DataSou
20
20
  return 'mikro';
21
21
  }
22
22
  async createDataSource(config, dataSourceName) {
23
+ if (config.logger && typeof config.logger === 'string') {
24
+ const logger = this.loggerService.getLogger(config.logger);
25
+ config.logger = message => {
26
+ logger.info(message);
27
+ };
28
+ }
23
29
  return core_2.MikroORM.init(config);
24
30
  }
25
31
  async checkConnected(dataSource) {
@@ -39,6 +45,10 @@ __decorate([
39
45
  (0, core_1.Inject)(),
40
46
  __metadata("design:type", String)
41
47
  ], MikroDataSourceManager.prototype, "baseDir", void 0);
48
+ __decorate([
49
+ (0, core_1.Inject)(),
50
+ __metadata("design:type", core_1.MidwayLoggerService)
51
+ ], MikroDataSourceManager.prototype, "loggerService", void 0);
42
52
  __decorate([
43
53
  (0, core_1.Init)(),
44
54
  __metadata("design:type", Function),
@@ -1,4 +1,6 @@
1
1
  import { Options, Configuration, IDatabaseDriver } from '@mikro-orm/core';
2
2
  import { DataSourceManagerConfigOption } from '@midwayjs/core';
3
- export type MikroConfigOptions<D extends IDatabaseDriver = IDatabaseDriver> = DataSourceManagerConfigOption<Options<D> | Configuration<D>>;
3
+ export type MikroConfigOptions<D extends IDatabaseDriver = IDatabaseDriver> = DataSourceManagerConfigOption<(Options<D> | Configuration<D>) & {
4
+ logger?: string | ((message: string) => void);
5
+ }>;
4
6
  //# sourceMappingURL=interface.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/mikro",
3
- "version": "3.13.9",
3
+ "version": "3.14.3",
4
4
  "main": "dist/index.js",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -9,13 +9,11 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "devDependencies": {
12
- "@midwayjs/core": "^3.13.7",
13
- "@midwayjs/mock": "^3.13.9",
14
- "@mikro-orm/core": "5.9.6",
15
- "@mikro-orm/entity-generator": "5.9.6",
16
- "@mikro-orm/sql-highlighter": "1.0.1",
17
- "@mikro-orm/sqlite": "5.9.6",
18
- "sqlite3": "5.1.6"
12
+ "@midwayjs/core": "^3.14.3",
13
+ "@midwayjs/mock": "^3.14.3",
14
+ "@mikro-orm/core": "6.0.4",
15
+ "@mikro-orm/entity-generator": "6.0.4",
16
+ "@mikro-orm/sqlite": "6.0.4"
19
17
  },
20
18
  "author": {
21
19
  "name": "czy88840616",
@@ -34,5 +32,5 @@
34
32
  "type": "git",
35
33
  "url": "https://github.com/midwayjs/midway.git"
36
34
  },
37
- "gitHead": "00750219506f4e3ad0e1dbb167d295610005b328"
35
+ "gitHead": "7517e708722bbf9ba69d9406e73fa2597e485d24"
38
36
  }