@mikro-orm/core 7.0.0-dev.45 → 7.0.0-dev.46

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/MikroORM.d.ts CHANGED
@@ -27,7 +27,6 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
27
27
  * - database connection will be established when you first interact with the database (or you can use `orm.connect()` explicitly)
28
28
  * - no loading of the `config` file, `options` parameter is mandatory
29
29
  * - no support for folder based discovery
30
- * - no check for mismatched package versions
31
30
  */
32
31
  constructor(options: Options<Driver, EM>);
33
32
  /**
package/MikroORM.js CHANGED
@@ -27,17 +27,10 @@ export class MikroORM {
27
27
  if (!options) {
28
28
  throw new Error(`options parameter is required`);
29
29
  }
30
- const coreVersion = ConfigurationLoader.checkPackageVersion();
31
30
  options.discovery ??= {};
32
31
  options.discovery.skipSyncDiscovery ??= true;
33
32
  const orm = new this(options);
34
- orm.logger.log('info', `MikroORM version: ${colors.green(coreVersion)}`);
35
- // we need to allow global context here as we are not in a scope of requests yet
36
- const allowGlobalContext = orm.config.get('allowGlobalContext');
37
- orm.config.set('allowGlobalContext', true);
38
33
  await orm.discoverEntities();
39
- orm.config.set('allowGlobalContext', allowGlobalContext);
40
- orm.driver.getPlatform().init(orm);
41
34
  return orm;
42
35
  }
43
36
  /**
@@ -45,11 +38,11 @@ export class MikroORM {
45
38
  * - database connection will be established when you first interact with the database (or you can use `orm.connect()` explicitly)
46
39
  * - no loading of the `config` file, `options` parameter is mandatory
47
40
  * - no support for folder based discovery
48
- * - no check for mismatched package versions
49
41
  */
50
42
  constructor(options) {
51
43
  ConfigurationLoader.registerDotenv(options);
52
44
  const env = ConfigurationLoader.loadEnvironmentVarsSync();
45
+ const coreVersion = ConfigurationLoader.checkPackageVersion();
53
46
  options = Utils.merge(options, env);
54
47
  this.config = new Configuration(options);
55
48
  const discovery = this.config.get('discovery');
@@ -60,18 +53,15 @@ export class MikroORM {
60
53
  }
61
54
  this.driver = this.config.getDriver();
62
55
  this.logger = this.config.getLogger();
56
+ this.logger.log('info', `MikroORM version: ${colors.green(coreVersion)}`);
63
57
  this.discovery = new MetadataDiscovery(new MetadataStorage(), this.driver.getPlatform(), this.config);
64
- if (!discovery.skipSyncDiscovery) {
65
- // we need to allow global context here as we are not in a scope of requests yet
66
- const allowGlobalContext = this.config.get('allowGlobalContext');
67
- this.config.set('allowGlobalContext', true);
68
- this.discoverEntitiesSync();
69
- this.config.set('allowGlobalContext', allowGlobalContext);
70
- this.driver.getPlatform().init(this);
71
- }
58
+ this.driver.getPlatform().init(this);
72
59
  for (const extension of this.config.get('extensions')) {
73
60
  extension.register(this);
74
61
  }
62
+ if (!discovery.skipSyncDiscovery) {
63
+ this.discoverEntitiesSync();
64
+ }
75
65
  }
76
66
  /**
77
67
  * Connects to the database.
@@ -125,12 +115,20 @@ export class MikroORM {
125
115
  return this.metadata;
126
116
  }
127
117
  async discoverEntities() {
118
+ // we need to allow global context here as we are not in a scope of requests yet
119
+ const allowGlobalContext = this.config.get('allowGlobalContext');
120
+ this.config.set('allowGlobalContext', true);
128
121
  this.metadata = await this.discovery.discover(this.config.get('preferTs'));
129
122
  this.createEntityManager();
123
+ this.config.set('allowGlobalContext', allowGlobalContext);
130
124
  }
131
125
  discoverEntitiesSync() {
126
+ // we need to allow global context here as we are not in a scope of requests yet
127
+ const allowGlobalContext = this.config.get('allowGlobalContext');
128
+ this.config.set('allowGlobalContext', true);
132
129
  this.metadata = this.discovery.discoverSync();
133
130
  this.createEntityManager();
131
+ this.config.set('allowGlobalContext', allowGlobalContext);
134
132
  }
135
133
  createEntityManager() {
136
134
  this.driver.setMetadata(this.metadata);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.45",
4
+ "version": "7.0.0-dev.46",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -54,7 +54,7 @@
54
54
  "dataloader": "2.2.3",
55
55
  "dotenv": "17.2.3",
56
56
  "esprima": "4.0.1",
57
- "mikro-orm": "7.0.0-dev.45",
57
+ "mikro-orm": "7.0.0-dev.46",
58
58
  "reflect-metadata": "0.2.2",
59
59
  "tinyglobby": "0.2.13"
60
60
  }