@mikro-orm/core 6.3.14-dev.71 → 6.3.14-dev.73
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/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';
|
|
@@ -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.73",
|
|
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.73",
|
|
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;
|
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,
|
|
@@ -7,32 +7,28 @@ import { Configuration, type Options } from './Configuration';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class ConfigurationLoader {
|
|
9
9
|
/**
|
|
10
|
-
* Gets a named configuration
|
|
10
|
+
* Gets a named configuration
|
|
11
11
|
*
|
|
12
|
-
* @param contextName
|
|
13
|
-
* @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used.
|
|
12
|
+
* @param contextName Load a config with the given `contextName` value. Used when config file exports array or factory function. Setting it to "default" matches also config objects without `contextName` set.
|
|
13
|
+
* @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link ConfigurationLoader.getConfigPaths}.
|
|
14
14
|
* @param options Additional options to augment the final configuration with.
|
|
15
15
|
*/
|
|
16
|
-
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(contextName: string, paths
|
|
16
|
+
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(contextName: string, paths?: string[], options?: Partial<Options>): Promise<Configuration<D, EM>>;
|
|
17
17
|
/**
|
|
18
|
-
* Gets
|
|
18
|
+
* Gets the default config from the default paths
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
21
|
-
* @param paths Array of possible paths for a configuration file. Files will be checked in order, and the first existing one will be used. Defaults to the output of {@link ConfigurationLoader.getConfigPaths}
|
|
22
|
-
* @param options Additional options to augment the final configuration with.
|
|
23
|
-
*
|
|
24
|
-
* @deprecated Prefer to explicitly set the parameter values. The defaults are available for backwards compatibility.
|
|
20
|
+
* @deprecated Prefer to explicitly set the `contextName` at the first argument. This signature is available for backwards compatibility, and may be removed in v7.
|
|
25
21
|
*/
|
|
26
|
-
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(
|
|
22
|
+
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(): Promise<Configuration<D, EM>>;
|
|
27
23
|
/**
|
|
28
|
-
* Gets default configuration
|
|
24
|
+
* Gets default configuration out of the default paths, and possibly from `process.argv`
|
|
29
25
|
*
|
|
30
|
-
* @param validate
|
|
31
|
-
* @param options Additional options to augment the final configuration with.
|
|
26
|
+
* @param validate Whether to validate the final configuration.
|
|
27
|
+
* @param options Additional options to augment the final configuration with (just before validation).
|
|
32
28
|
*
|
|
33
|
-
* @deprecated Use the other
|
|
29
|
+
* @deprecated Use the other overloads of this method. This signature will be removed in v7.
|
|
34
30
|
*/
|
|
35
|
-
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate:
|
|
31
|
+
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate: boolean, options?: Partial<Options>): Promise<Configuration<D, EM>>;
|
|
36
32
|
static getPackageConfig(basePath?: string): Dictionary;
|
|
37
33
|
static getSettings(): Settings;
|
|
38
34
|
static configPathsFromArg(): string[] | undefined;
|
|
@@ -17,9 +17,11 @@ const Utils_1 = require("./Utils");
|
|
|
17
17
|
*/
|
|
18
18
|
class ConfigurationLoader {
|
|
19
19
|
static async getConfiguration(contextName = 'default', paths = ConfigurationLoader.getConfigPaths(), options = {}) {
|
|
20
|
-
if (contextName ===
|
|
20
|
+
if (typeof contextName === 'boolean' || !Array.isArray(paths)) {
|
|
21
21
|
const configPathFromArg = ConfigurationLoader.configPathsFromArg();
|
|
22
|
-
const config =
|
|
22
|
+
const config = contextName
|
|
23
|
+
? (await ConfigurationLoader.getConfiguration(process.env.MIKRO_ORM_CONTEXT_NAME ?? 'default', configPathFromArg ?? ConfigurationLoader.getConfigPaths(), Array.isArray(paths) ? {} : paths))
|
|
24
|
+
: new Configuration_1.Configuration(Utils_1.Utils.mergeConfig({}, options, this.loadEnvironmentVars()), false);
|
|
23
25
|
if (configPathFromArg) {
|
|
24
26
|
config.getLogger().warn('deprecated', 'Path for config file was inferred from the command line arguments. Instead, you should set the MIKRO_ORM_CLI_CONFIG environment variable to specify the path, or if you really must use the command line arguments, import the config manually based on them, and pass it to init.', { label: 'D0001' });
|
|
25
27
|
}
|