@mikro-orm/core 6.3.14-dev.70 → 6.3.14-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/MikroORM.js +2 -2
- package/errors.d.ts +1 -0
- package/errors.js +3 -0
- package/metadata/MetadataDiscovery.js +2 -2
- package/metadata/MetadataValidator.js +5 -2
- package/package.json +2 -2
- package/utils/Configuration.d.ts +11 -2
- package/utils/Configuration.js +4 -1
package/MikroORM.js
CHANGED
|
@@ -174,11 +174,11 @@ class MikroORM {
|
|
|
174
174
|
return this.metadata;
|
|
175
175
|
}
|
|
176
176
|
async discoverEntities() {
|
|
177
|
-
this.metadata = await this.discovery.discover(this.config.get('
|
|
177
|
+
this.metadata = await this.discovery.discover(this.config.get('preferTs'));
|
|
178
178
|
this.createEntityManager();
|
|
179
179
|
}
|
|
180
180
|
discoverEntitiesSync() {
|
|
181
|
-
this.metadata = this.discovery.discoverSync(this.config.get('
|
|
181
|
+
this.metadata = this.discovery.discoverSync(this.config.get('preferTs'));
|
|
182
182
|
this.createEntityManager();
|
|
183
183
|
}
|
|
184
184
|
createEntityManager() {
|
package/errors.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
|
|
|
55
55
|
static invalidPrimaryKey(meta: EntityMetadata, prop: EntityProperty, requiredName: string): MetadataError<Partial<any>>;
|
|
56
56
|
static invalidManyToManyWithPivotEntity(meta1: EntityMetadata, prop1: EntityProperty, meta2: EntityMetadata, prop2: EntityProperty): MetadataError<Partial<any>>;
|
|
57
57
|
static targetIsAbstract(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
|
|
58
|
+
static nonPersistentCompositeProp(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
|
|
58
59
|
static propertyTargetsEntityType(meta: EntityMetadata, prop: EntityProperty, target: EntityMetadata): MetadataError<Partial<any>>;
|
|
59
60
|
static fromMissingOption(meta: EntityMetadata, prop: EntityProperty, option: string): MetadataError<Partial<any>>;
|
|
60
61
|
private static fromMessage;
|
package/errors.js
CHANGED
|
@@ -198,6 +198,9 @@ class MetadataError extends ValidationError {
|
|
|
198
198
|
static targetIsAbstract(meta, prop) {
|
|
199
199
|
return this.fromMessage(meta, prop, `targets abstract entity ${prop.type}. Maybe you forgot to put @Entity() decorator on the ${prop.type} class?`);
|
|
200
200
|
}
|
|
201
|
+
static nonPersistentCompositeProp(meta, prop) {
|
|
202
|
+
return this.fromMessage(meta, prop, `is non-persistent relation which targets composite primary key. This is not supported and will cause issues, 'persist: false' should be added to the properties representing single columns instead.`);
|
|
203
|
+
}
|
|
201
204
|
static propertyTargetsEntityType(meta, prop, target) {
|
|
202
205
|
/* istanbul ignore next */
|
|
203
206
|
const suggestion = target.embeddable ? 'Embedded' : 'ManyToOne';
|
|
@@ -127,10 +127,10 @@ class MetadataDiscovery {
|
|
|
127
127
|
return meta;
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
findEntities(
|
|
130
|
+
findEntities(preferTs, sync = false) {
|
|
131
131
|
this.discovered.length = 0;
|
|
132
132
|
const options = this.config.get('discovery');
|
|
133
|
-
const key = (
|
|
133
|
+
const key = (preferTs && this.config.get('preferTs', Utils_1.Utils.detectTsNode()) && this.config.get('entitiesTs').length > 0) ? 'entitiesTs' : 'entities';
|
|
134
134
|
const paths = this.config.get(key).filter(item => Utils_1.Utils.isString(item));
|
|
135
135
|
const refs = this.config.get(key).filter(item => !Utils_1.Utils.isString(item));
|
|
136
136
|
if (paths.length > 0) {
|
|
@@ -41,7 +41,7 @@ class MetadataValidator {
|
|
|
41
41
|
this.validateIndexes(meta, meta.uniques ?? [], 'unique');
|
|
42
42
|
for (const prop of utils_1.Utils.values(meta.properties)) {
|
|
43
43
|
if (prop.kind !== enums_1.ReferenceKind.SCALAR) {
|
|
44
|
-
this.validateReference(meta, prop, metadata);
|
|
44
|
+
this.validateReference(meta, prop, metadata, options);
|
|
45
45
|
this.validateBidirectional(meta, prop, metadata);
|
|
46
46
|
}
|
|
47
47
|
else if (metadata.has(prop.type)) {
|
|
@@ -98,7 +98,7 @@ class MetadataValidator {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
validateReference(meta, prop, metadata) {
|
|
101
|
+
validateReference(meta, prop, metadata, options) {
|
|
102
102
|
// references do have types
|
|
103
103
|
if (!prop.type) {
|
|
104
104
|
throw errors_1.MetadataError.fromWrongTypeDefinition(meta, prop);
|
|
@@ -110,6 +110,9 @@ class MetadataValidator {
|
|
|
110
110
|
if (metadata.find(prop.type).abstract && !metadata.find(prop.type).discriminatorColumn) {
|
|
111
111
|
throw errors_1.MetadataError.targetIsAbstract(meta, prop);
|
|
112
112
|
}
|
|
113
|
+
if (prop.persist === false && metadata.find(prop.type).compositePK && options.checkNonPersistentCompositeProps) {
|
|
114
|
+
throw errors_1.MetadataError.nonPersistentCompositeProp(meta, prop);
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
validateBidirectional(meta, prop, metadata) {
|
|
115
118
|
if (prop.inversedBy) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.14-dev.
|
|
3
|
+
"version": "6.3.14-dev.72",
|
|
4
4
|
"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.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.3.14-dev.
|
|
67
|
+
"mikro-orm": "6.3.14-dev.72",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -34,9 +34,10 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
34
34
|
requireEntitiesArray: false;
|
|
35
35
|
checkDuplicateTableNames: true;
|
|
36
36
|
checkDuplicateFieldNames: true;
|
|
37
|
+
checkDuplicateEntities: true;
|
|
38
|
+
checkNonPersistentCompositeProps: true;
|
|
37
39
|
alwaysAnalyseProperties: true;
|
|
38
40
|
disableDynamicFileAccess: false;
|
|
39
|
-
checkDuplicateEntities: true;
|
|
40
41
|
inferDefaultValues: true;
|
|
41
42
|
};
|
|
42
43
|
strict: false;
|
|
@@ -294,11 +295,12 @@ export interface MetadataDiscoveryOptions {
|
|
|
294
295
|
requireEntitiesArray?: boolean;
|
|
295
296
|
checkDuplicateTableNames?: boolean;
|
|
296
297
|
checkDuplicateFieldNames?: boolean;
|
|
298
|
+
checkDuplicateEntities?: boolean;
|
|
299
|
+
checkNonPersistentCompositeProps?: boolean;
|
|
297
300
|
alwaysAnalyseProperties?: boolean;
|
|
298
301
|
disableDynamicFileAccess?: boolean;
|
|
299
302
|
inferDefaultValues?: boolean;
|
|
300
303
|
getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
|
|
301
|
-
checkDuplicateEntities?: boolean;
|
|
302
304
|
onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
|
|
303
305
|
afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
|
|
304
306
|
tsConfigPath?: string;
|
|
@@ -370,6 +372,13 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
370
372
|
debug: boolean | LoggerNamespace[];
|
|
371
373
|
ignoreDeprecations: boolean | string[];
|
|
372
374
|
highlighter: Highlighter;
|
|
375
|
+
/**
|
|
376
|
+
* Using this option, you can force the ORM to use the TS options regardless of whether the TypeScript support
|
|
377
|
+
* is detected or not. This effectively means using `entitiesTs` for discovery and `pathTs` for migrations and
|
|
378
|
+
* seeders. Should be used only for tests and stay disabled for production builds.
|
|
379
|
+
*/
|
|
380
|
+
preferTs?: boolean;
|
|
381
|
+
/** @deprecated use `preferTs` instead */
|
|
373
382
|
tsNode?: boolean;
|
|
374
383
|
baseDir: string;
|
|
375
384
|
migrations: MigrationsOptions;
|
package/utils/Configuration.js
CHANGED
|
@@ -27,9 +27,10 @@ class Configuration {
|
|
|
27
27
|
requireEntitiesArray: false,
|
|
28
28
|
checkDuplicateTableNames: true,
|
|
29
29
|
checkDuplicateFieldNames: true,
|
|
30
|
+
checkDuplicateEntities: true,
|
|
31
|
+
checkNonPersistentCompositeProps: true,
|
|
30
32
|
alwaysAnalyseProperties: true,
|
|
31
33
|
disableDynamicFileAccess: false,
|
|
32
|
-
checkDuplicateEntities: true,
|
|
33
34
|
inferDefaultValues: true,
|
|
34
35
|
},
|
|
35
36
|
strict: false,
|
|
@@ -145,6 +146,7 @@ class Configuration {
|
|
|
145
146
|
}
|
|
146
147
|
this.options = Utils_1.Utils.mergeConfig({}, Configuration.DEFAULTS, options);
|
|
147
148
|
this.options.baseDir = Utils_1.Utils.absolutePath(this.options.baseDir);
|
|
149
|
+
this.options.preferTs ??= options.tsNode;
|
|
148
150
|
if (validate) {
|
|
149
151
|
this.validateOptions();
|
|
150
152
|
}
|
|
@@ -330,6 +332,7 @@ class Configuration {
|
|
|
330
332
|
}
|
|
331
333
|
sync() {
|
|
332
334
|
process.env.MIKRO_ORM_COLORS = '' + this.options.colors;
|
|
335
|
+
this.options.tsNode = this.options.preferTs;
|
|
333
336
|
this.logger.setDebugMode(this.options.debug);
|
|
334
337
|
}
|
|
335
338
|
/**
|