@mikro-orm/core 7.0.0-dev.71 → 7.0.0-dev.72
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/package.json +1 -1
- package/unit-of-work/UnitOfWork.js +2 -1
- package/utils/ConfigurationLoader.js +69 -59
- package/utils/Utils.d.ts +0 -6
- package/utils/Utils.js +0 -15
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.
|
|
4
|
+
"version": "7.0.0-dev.72",
|
|
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",
|
|
@@ -327,7 +327,8 @@ export class UnitOfWork {
|
|
|
327
327
|
this.filterCollectionUpdates();
|
|
328
328
|
// nothing to do, do not start transaction
|
|
329
329
|
if (this.changeSets.size === 0 && this.collectionUpdates.size === 0 && this.extraUpdates.size === 0) {
|
|
330
|
-
|
|
330
|
+
await this.eventManager.dispatchEvent(EventType.afterFlush, { em: this.em, uow: this });
|
|
331
|
+
return;
|
|
331
332
|
}
|
|
332
333
|
const groups = this.getChangeSetGroups();
|
|
333
334
|
const platform = this.em.getPlatform();
|
|
@@ -7,78 +7,88 @@ import { colors } from '../logging/colors.js';
|
|
|
7
7
|
export class ConfigurationLoader {
|
|
8
8
|
static loadEnvironmentVars() {
|
|
9
9
|
const ret = {};
|
|
10
|
+
const getEnvKey = (key, envPrefix = 'MIKRO_ORM_') => {
|
|
11
|
+
return envPrefix + key
|
|
12
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1_$2')
|
|
13
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
|
|
14
|
+
.toUpperCase();
|
|
15
|
+
};
|
|
10
16
|
const array = (v) => v.split(',').map(vv => vv.trim());
|
|
11
17
|
const bool = (v) => ['true', 't', '1'].includes(v.toLowerCase());
|
|
12
18
|
const num = (v) => +v;
|
|
13
|
-
const read = (o,
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
const read = (o, envPrefix, key, mapper = v => v) => {
|
|
20
|
+
const envKey = getEnvKey(key, envPrefix);
|
|
21
|
+
if (envKey in process.env) {
|
|
22
|
+
o[key] = mapper(process.env[envKey]);
|
|
16
23
|
}
|
|
17
|
-
const val = process.env[envKey];
|
|
18
|
-
o[key] = mapper(val);
|
|
19
24
|
};
|
|
20
25
|
const cleanup = (o, k) => Utils.hasObjectKeys(o[k]) ? {} : delete o[k];
|
|
21
|
-
read(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
const read0 = read.bind(null, ret, 'MIKRO_ORM_');
|
|
27
|
+
read0('baseDir');
|
|
28
|
+
read0('entities', array);
|
|
29
|
+
read0('entitiesTs', array);
|
|
30
|
+
read0('clientUrl');
|
|
31
|
+
read0('host');
|
|
32
|
+
read0('port', num);
|
|
33
|
+
read0('user');
|
|
34
|
+
read0('password');
|
|
35
|
+
read0('dbName');
|
|
36
|
+
read0('schema');
|
|
37
|
+
read0('loadStrategy');
|
|
38
|
+
read0('batchSize', num);
|
|
39
|
+
read0('useBatchInserts', bool);
|
|
40
|
+
read0('useBatchUpdates', bool);
|
|
41
|
+
read0('strict', bool);
|
|
42
|
+
read0('validate', bool);
|
|
43
|
+
read0('allowGlobalContext', bool);
|
|
44
|
+
read0('autoJoinOneToOneOwner', bool);
|
|
45
|
+
read0('populateAfterFlush', bool);
|
|
46
|
+
read0('forceEntityConstructor', bool);
|
|
47
|
+
read0('forceUndefined', bool);
|
|
48
|
+
read0('forceUtcTimezone', bool);
|
|
49
|
+
read0('timezone');
|
|
50
|
+
read0('ensureIndexes', bool);
|
|
51
|
+
read0('implicitTransactions', bool);
|
|
52
|
+
read0('debug', bool);
|
|
53
|
+
read0('colors', bool);
|
|
48
54
|
ret.discovery = {};
|
|
49
|
-
read(ret.discovery, '
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
const read1 = read.bind(null, ret.discovery, 'MIKRO_ORM_DISCOVERY_');
|
|
56
|
+
read1('warnWhenNoEntities', bool);
|
|
57
|
+
read1('checkDuplicateTableNames', bool);
|
|
58
|
+
read1('checkDuplicateFieldNames', bool);
|
|
59
|
+
read1('checkDuplicateEntities', bool);
|
|
60
|
+
read1('checkNonPersistentCompositeProps', bool);
|
|
61
|
+
read1('inferDefaultValues', bool);
|
|
62
|
+
read1('tsConfigPath');
|
|
56
63
|
cleanup(ret, 'discovery');
|
|
57
64
|
ret.migrations = {};
|
|
58
|
-
read(ret.migrations, '
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const read2 = read.bind(null, ret.migrations, 'MIKRO_ORM_MIGRATIONS_');
|
|
66
|
+
read2('tableName');
|
|
67
|
+
read2('path');
|
|
68
|
+
read2('pathTs');
|
|
69
|
+
read2('glob');
|
|
70
|
+
read2('transactional', bool);
|
|
71
|
+
read2('disableForeignKeys', bool);
|
|
72
|
+
read2('allOrNothing', bool);
|
|
73
|
+
read2('dropTables', bool);
|
|
74
|
+
read2('safe', bool);
|
|
75
|
+
read2('silent', bool);
|
|
76
|
+
read2('emit');
|
|
77
|
+
read2('snapshot', bool);
|
|
78
|
+
read2('snapshotName');
|
|
71
79
|
cleanup(ret, 'migrations');
|
|
72
80
|
ret.schemaGenerator = {};
|
|
73
|
-
read(ret.schemaGenerator, '
|
|
74
|
-
|
|
81
|
+
const read3 = read.bind(null, ret.schemaGenerator, 'MIKRO_ORM_SCHEMA_GENERATOR_');
|
|
82
|
+
read3('disableForeignKeys', bool);
|
|
83
|
+
read3('createForeignKeyConstraints', bool);
|
|
75
84
|
cleanup(ret, 'schemaGenerator');
|
|
76
85
|
ret.seeder = {};
|
|
77
|
-
read(ret.seeder, '
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
const read4 = read.bind(null, ret.seeder, 'MIKRO_ORM_SEEDER_');
|
|
87
|
+
read4('path');
|
|
88
|
+
read4('pathTs');
|
|
89
|
+
read4('glob');
|
|
90
|
+
read4('emit');
|
|
91
|
+
read4('defaultSeeder');
|
|
82
92
|
cleanup(ret, 'seeder');
|
|
83
93
|
return ret;
|
|
84
94
|
}
|
package/utils/Utils.d.ts
CHANGED
|
@@ -168,12 +168,6 @@ export declare class Utils {
|
|
|
168
168
|
* @param [from] Location to start the node resolution
|
|
169
169
|
*/
|
|
170
170
|
static requireFrom<T extends Dictionary>(id: string, from?: string): T;
|
|
171
|
-
/**
|
|
172
|
-
* Resolve path to a module.
|
|
173
|
-
* @param id The module to require
|
|
174
|
-
* @param [from] Location to start the node resolution
|
|
175
|
-
*/
|
|
176
|
-
static resolveModulePath(id: string, from?: string): string;
|
|
177
171
|
static dynamicImport<T = any>(id: string): Promise<T>;
|
|
178
172
|
static ensureDir(path: string): void;
|
|
179
173
|
static readJSONSync(path: string): Dictionary;
|
package/utils/Utils.js
CHANGED
|
@@ -762,21 +762,6 @@ export class Utils {
|
|
|
762
762
|
}
|
|
763
763
|
return createRequire(resolve(from))(id);
|
|
764
764
|
}
|
|
765
|
-
/**
|
|
766
|
-
* Resolve path to a module.
|
|
767
|
-
* @param id The module to require
|
|
768
|
-
* @param [from] Location to start the node resolution
|
|
769
|
-
*/
|
|
770
|
-
static resolveModulePath(id, from = process.cwd()) {
|
|
771
|
-
if (!extname(from)) {
|
|
772
|
-
from = join(from, '__fake.js');
|
|
773
|
-
}
|
|
774
|
-
const path = Utils.normalizePath(createRequire(resolve(from)).resolve(id));
|
|
775
|
-
const parts = path.split('/');
|
|
776
|
-
const idx = parts.lastIndexOf(id) + 1;
|
|
777
|
-
parts.splice(idx, parts.length - idx);
|
|
778
|
-
return parts.join('/');
|
|
779
|
-
}
|
|
780
765
|
static async dynamicImport(id) {
|
|
781
766
|
/* v8 ignore next */
|
|
782
767
|
const specifier = id.startsWith('file://') ? id : pathToFileURL(id).href;
|