@mikro-orm/core 7.0.0-dev.113 → 7.0.0-dev.115
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/EntityManager.d.ts +8 -8
- package/EntityManager.js +47 -69
- package/MikroORM.d.ts +1 -1
- package/MikroORM.js +2 -3
- package/drivers/DatabaseDriver.d.ts +11 -11
- package/drivers/DatabaseDriver.js +8 -9
- package/drivers/IDatabaseDriver.d.ts +12 -12
- package/entity/Collection.js +7 -6
- package/entity/EntityAssigner.js +9 -9
- package/entity/EntityFactory.js +14 -17
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +2 -2
- package/entity/EntityLoader.d.ts +3 -3
- package/entity/EntityLoader.js +22 -35
- package/entity/WrappedEntity.js +1 -1
- package/entity/defineEntity.d.ts +11 -11
- package/entity/validators.js +2 -2
- package/errors.d.ts +8 -8
- package/errors.js +14 -13
- package/hydration/ObjectHydrator.js +25 -18
- package/metadata/EntitySchema.d.ts +5 -5
- package/metadata/EntitySchema.js +23 -21
- package/metadata/MetadataDiscovery.d.ts +2 -3
- package/metadata/MetadataDiscovery.js +119 -92
- package/metadata/MetadataProvider.js +2 -0
- package/metadata/MetadataStorage.d.ts +13 -6
- package/metadata/MetadataStorage.js +64 -19
- package/metadata/MetadataValidator.d.ts +2 -2
- package/metadata/MetadataValidator.js +22 -28
- package/metadata/types.d.ts +3 -3
- package/package.json +1 -1
- package/platforms/Platform.js +2 -2
- package/serialization/EntitySerializer.js +2 -2
- package/serialization/EntityTransformer.js +6 -6
- package/serialization/SerializationContext.d.ts +6 -6
- package/typings.d.ts +19 -17
- package/typings.js +15 -10
- package/unit-of-work/ChangeSet.d.ts +2 -3
- package/unit-of-work/ChangeSet.js +2 -3
- package/unit-of-work/ChangeSetComputer.js +3 -3
- package/unit-of-work/ChangeSetPersister.js +14 -14
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +13 -13
- package/unit-of-work/UnitOfWork.d.ts +3 -3
- package/unit-of-work/UnitOfWork.js +46 -45
- package/utils/AbstractSchemaGenerator.js +7 -7
- package/utils/Configuration.d.ts +0 -5
- package/utils/Cursor.js +3 -3
- package/utils/DataloaderUtils.js +13 -11
- package/utils/EntityComparator.d.ts +6 -6
- package/utils/EntityComparator.js +30 -27
- package/utils/QueryHelper.d.ts +6 -6
- package/utils/QueryHelper.js +18 -17
- package/utils/RawQueryFragment.d.ts +11 -12
- package/utils/RawQueryFragment.js +28 -55
- package/utils/TransactionManager.js +1 -1
- package/utils/Utils.d.ts +3 -1
- package/utils/Utils.js +10 -2
- package/utils/clone.js +7 -21
- package/utils/env-vars.js +0 -1
- package/utils/upsert-utils.d.ts +4 -4
package/utils/Utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Dictionary, EntityData, EntityDictionary, EntityKey, EntityMetadat
|
|
|
2
2
|
import type { Collection } from '../entity/Collection.js';
|
|
3
3
|
import type { Platform } from '../platforms/Platform.js';
|
|
4
4
|
import type { ScalarReference } from '../entity/Reference.js';
|
|
5
|
+
import { type RawQueryFragmentSymbol } from './RawQueryFragment.js';
|
|
5
6
|
export declare function compareObjects(a: any, b: any): boolean;
|
|
6
7
|
export declare function compareArrays(a: any[] | string, b: any[] | string): boolean;
|
|
7
8
|
export declare function compareBooleans(a: unknown, b: unknown): boolean;
|
|
@@ -109,7 +110,7 @@ export declare class Utils {
|
|
|
109
110
|
/**
|
|
110
111
|
* Gets string name of given class.
|
|
111
112
|
*/
|
|
112
|
-
static className<T>(classOrName: EntityName<T>): string;
|
|
113
|
+
static className<T>(classOrName: string | EntityName<T>): string;
|
|
113
114
|
static extractChildElements(items: string[], prefix: string, allSymbol?: string): string[];
|
|
114
115
|
/**
|
|
115
116
|
* Tries to detect TypeScript support.
|
|
@@ -155,4 +156,5 @@ export declare class Utils {
|
|
|
155
156
|
static values<T extends object>(obj: T): T[keyof T][];
|
|
156
157
|
static entries<T extends object>(obj: T): [keyof T, T[keyof T]][];
|
|
157
158
|
static primaryKeyToObject<T>(meta: EntityMetadata<T>, primaryKey: Primary<T> | T, visible?: (keyof T)[]): T;
|
|
159
|
+
static getObjectQueryKeys<T extends Dictionary, K extends string = Extract<keyof T, string>>(obj: T): (K | RawQueryFragmentSymbol)[];
|
|
158
160
|
}
|
package/utils/Utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { clone } from './clone.js';
|
|
2
2
|
import { GroupOperator, PlainObject, QueryOperator, ReferenceKind } from '../enums.js';
|
|
3
3
|
import { helper } from '../entity/wrap.js';
|
|
4
|
+
import { Raw } from './RawQueryFragment.js';
|
|
4
5
|
function compareConstructors(a, b) {
|
|
5
6
|
if (a.constructor === b.constructor) {
|
|
6
7
|
return true;
|
|
@@ -34,7 +35,6 @@ export function compareObjects(a, b) {
|
|
|
34
35
|
}
|
|
35
36
|
/* v8 ignore next */
|
|
36
37
|
if ((typeof a === 'function' && typeof b === 'function') ||
|
|
37
|
-
(typeof a === 'object' && a.client && ['Ref', 'Raw'].includes(a.constructor.name) && typeof b === 'object' && b.client && ['Ref', 'Raw'].includes(b.constructor.name)) || // knex qb
|
|
38
38
|
(a instanceof RegExp && b instanceof RegExp) ||
|
|
39
39
|
(a instanceof String && b instanceof String) ||
|
|
40
40
|
(a instanceof Number && b instanceof Number)) {
|
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.115';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|
|
@@ -824,4 +824,12 @@ export class Utils {
|
|
|
824
824
|
return o;
|
|
825
825
|
}, {});
|
|
826
826
|
}
|
|
827
|
+
static getObjectQueryKeys(obj) {
|
|
828
|
+
return Reflect.ownKeys(obj).filter(key => {
|
|
829
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, key)) {
|
|
830
|
+
return false;
|
|
831
|
+
}
|
|
832
|
+
return typeof key === 'string' || Raw.isKnownFragmentSymbol(key);
|
|
833
|
+
});
|
|
834
|
+
}
|
|
827
835
|
}
|
package/utils/clone.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* clone `EventEmitter`s to get around https://github.com/mikro-orm/mikro-orm/issues/2748
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
import { RawQueryFragment } from './RawQueryFragment.js';
|
|
7
6
|
/**
|
|
8
7
|
* Get the property descriptor of a property on an object or its prototype chain.
|
|
9
8
|
*
|
|
@@ -29,10 +28,6 @@ export function clone(parent, respectCustomCloneMethod = true) {
|
|
|
29
28
|
if (parent === null) {
|
|
30
29
|
return null;
|
|
31
30
|
}
|
|
32
|
-
const raw = RawQueryFragment.getKnownFragment(parent, false);
|
|
33
|
-
if (raw && respectCustomCloneMethod) {
|
|
34
|
-
return raw.clone();
|
|
35
|
-
}
|
|
36
31
|
if (typeof parent !== 'object') {
|
|
37
32
|
return parent;
|
|
38
33
|
}
|
|
@@ -113,25 +108,16 @@ export function clone(parent, respectCustomCloneMethod = true) {
|
|
|
113
108
|
if (attrs && typeof attrs.get === 'function' && attrs.set == null) {
|
|
114
109
|
continue;
|
|
115
110
|
}
|
|
116
|
-
const raw = RawQueryFragment.getKnownFragment(i, false);
|
|
117
|
-
if (raw && respectCustomCloneMethod) {
|
|
118
|
-
const i2 = raw.clone().toString();
|
|
119
|
-
child[i2] = _clone(parent[i]);
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
111
|
child[i] = _clone(parent[i]);
|
|
123
112
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (descriptor && !descriptor.enumerable) {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
child[symbol] = _clone(parent[symbol]);
|
|
113
|
+
const symbols = Object.getOwnPropertySymbols(parent);
|
|
114
|
+
for (let i = 0; i < symbols.length; i++) {
|
|
115
|
+
const symbol = symbols[i];
|
|
116
|
+
const descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
117
|
+
if (descriptor && !descriptor.enumerable) {
|
|
118
|
+
continue;
|
|
134
119
|
}
|
|
120
|
+
child[symbol] = _clone(parent[symbol]);
|
|
135
121
|
}
|
|
136
122
|
return child;
|
|
137
123
|
}
|
package/utils/env-vars.js
CHANGED
|
@@ -60,7 +60,6 @@ export function loadEnvironmentVars() {
|
|
|
60
60
|
read1('warnWhenNoEntities', bool);
|
|
61
61
|
read1('checkDuplicateTableNames', bool);
|
|
62
62
|
read1('checkDuplicateFieldNames', bool);
|
|
63
|
-
read1('checkDuplicateEntities', bool);
|
|
64
63
|
read1('checkNonPersistentCompositeProps', bool);
|
|
65
64
|
read1('inferDefaultValues', bool);
|
|
66
65
|
read1('tsConfigPath');
|
package/utils/upsert-utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { EntityData, EntityMetadata, FilterQuery } from '../typings.js';
|
|
2
2
|
import type { UpsertOptions } from '../drivers/IDatabaseDriver.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type Raw } from '../utils/RawQueryFragment.js';
|
|
4
4
|
/** @internal */
|
|
5
|
-
export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] |
|
|
5
|
+
export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | Raw, options: UpsertOptions<T>): (keyof T)[];
|
|
6
6
|
/** @internal */
|
|
7
|
-
export declare function getOnConflictReturningFields<T, P extends string>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] |
|
|
7
|
+
export declare function getOnConflictReturningFields<T, P extends string>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | Raw, options: UpsertOptions<T, P>): (keyof T)[] | '*';
|
|
8
8
|
/** @internal */
|
|
9
|
-
export declare function getWhereCondition<T extends object>(meta: EntityMetadata<T>, onConflictFields: (keyof T)[] |
|
|
9
|
+
export declare function getWhereCondition<T extends object>(meta: EntityMetadata<T>, onConflictFields: (keyof T)[] | Raw | undefined, data: EntityData<T>, where: FilterQuery<T>): {
|
|
10
10
|
where: FilterQuery<T>;
|
|
11
11
|
propIndex: number | false;
|
|
12
12
|
};
|