@mikro-orm/core 7.0.2-dev.9 → 7.0.3-dev.0
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 +4 -0
- package/EntityManager.js +4 -0
- package/MikroORM.d.ts +2 -0
- package/MikroORM.js +2 -0
- package/README.md +128 -294
- package/cache/CacheAdapter.d.ts +2 -0
- package/cache/GeneratedCacheAdapter.d.ts +1 -0
- package/cache/GeneratedCacheAdapter.js +1 -0
- package/cache/MemoryCacheAdapter.d.ts +1 -0
- package/cache/MemoryCacheAdapter.js +1 -0
- package/cache/NullCacheAdapter.d.ts +1 -0
- package/cache/NullCacheAdapter.js +1 -0
- package/connections/Connection.d.ts +13 -0
- package/connections/Connection.js +9 -0
- package/drivers/DatabaseDriver.d.ts +12 -0
- package/drivers/DatabaseDriver.js +12 -0
- package/drivers/IDatabaseDriver.d.ts +44 -0
- package/drivers/IDatabaseDriver.js +1 -0
- package/entity/BaseEntity.d.ts +11 -0
- package/entity/BaseEntity.js +11 -0
- package/entity/Collection.d.ts +26 -0
- package/entity/Collection.js +15 -0
- package/entity/EntityAssigner.d.ts +3 -0
- package/entity/EntityAssigner.js +2 -0
- package/entity/EntityFactory.d.ts +16 -0
- package/entity/EntityFactory.js +19 -0
- package/entity/EntityLoader.d.ts +19 -0
- package/entity/EntityLoader.js +2 -0
- package/entity/EntityRepository.d.ts +2 -0
- package/entity/EntityRepository.js +2 -0
- package/entity/Reference.d.ts +20 -0
- package/entity/Reference.js +16 -0
- package/entity/WrappedEntity.d.ts +20 -0
- package/entity/WrappedEntity.js +21 -1
- package/entity/defineEntity.d.ts +12 -2
- package/entity/defineEntity.js +1 -0
- package/enums.d.ts +132 -0
- package/enums.js +132 -0
- package/errors.d.ts +6 -0
- package/errors.js +6 -0
- package/events/EventManager.d.ts +5 -0
- package/events/EventManager.js +5 -0
- package/events/EventSubscriber.d.ts +4 -0
- package/events/TransactionEventBroadcaster.d.ts +2 -0
- package/events/TransactionEventBroadcaster.js +2 -0
- package/hydration/Hydrator.d.ts +2 -0
- package/hydration/Hydrator.js +2 -0
- package/hydration/ObjectHydrator.d.ts +1 -0
- package/hydration/ObjectHydrator.js +1 -0
- package/logging/DefaultLogger.d.ts +3 -0
- package/logging/DefaultLogger.js +3 -0
- package/logging/Logger.d.ts +5 -0
- package/metadata/EntitySchema.d.ts +22 -0
- package/metadata/EntitySchema.js +22 -2
- package/metadata/MetadataDiscovery.d.ts +4 -0
- package/metadata/MetadataDiscovery.js +18 -11
- package/metadata/MetadataProvider.d.ts +8 -0
- package/metadata/MetadataProvider.js +9 -1
- package/metadata/MetadataStorage.d.ts +14 -0
- package/metadata/MetadataStorage.js +14 -1
- package/naming-strategy/AbstractNamingStrategy.d.ts +1 -0
- package/naming-strategy/AbstractNamingStrategy.js +1 -0
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -0
- package/naming-strategy/MongoNamingStrategy.js +1 -0
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -0
- package/naming-strategy/UnderscoreNamingStrategy.js +1 -0
- package/package.json +1 -1
- package/platforms/ExceptionConverter.d.ts +1 -0
- package/platforms/ExceptionConverter.js +1 -0
- package/platforms/Platform.d.ts +65 -0
- package/platforms/Platform.js +65 -0
- package/serialization/EntitySerializer.d.ts +2 -0
- package/serialization/EntitySerializer.js +2 -0
- package/serialization/EntityTransformer.d.ts +2 -0
- package/serialization/EntityTransformer.js +2 -0
- package/serialization/SerializationContext.d.ts +5 -0
- package/serialization/SerializationContext.js +5 -0
- package/types/ArrayType.d.ts +1 -0
- package/types/ArrayType.js +1 -0
- package/types/BlobType.d.ts +1 -0
- package/types/BlobType.js +1 -0
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +1 -0
- package/types/CharacterType.d.ts +1 -0
- package/types/CharacterType.js +1 -0
- package/types/DateTimeType.d.ts +1 -0
- package/types/DateTimeType.js +1 -0
- package/types/DateType.d.ts +1 -0
- package/types/DateType.js +1 -0
- package/types/EnumArrayType.d.ts +1 -0
- package/types/EnumArrayType.js +1 -0
- package/types/EnumType.d.ts +1 -0
- package/types/EnumType.js +1 -0
- package/types/FloatType.d.ts +1 -0
- package/types/FloatType.js +1 -0
- package/types/IntegerType.d.ts +1 -0
- package/types/IntegerType.js +1 -0
- package/types/IntervalType.d.ts +1 -0
- package/types/IntervalType.js +1 -0
- package/types/JsonType.d.ts +1 -0
- package/types/JsonType.js +1 -0
- package/types/MediumIntType.d.ts +1 -0
- package/types/MediumIntType.js +1 -0
- package/types/SmallIntType.d.ts +1 -0
- package/types/SmallIntType.js +1 -0
- package/types/StringType.d.ts +1 -0
- package/types/StringType.js +1 -0
- package/types/TextType.d.ts +1 -0
- package/types/TextType.js +1 -0
- package/types/TimeType.d.ts +1 -0
- package/types/TimeType.js +1 -0
- package/types/TinyIntType.d.ts +1 -0
- package/types/TinyIntType.js +1 -0
- package/types/Type.d.ts +11 -0
- package/types/Type.js +11 -0
- package/types/Uint8ArrayType.d.ts +1 -0
- package/types/Uint8ArrayType.js +1 -0
- package/types/UnknownType.d.ts +1 -0
- package/types/UnknownType.js +1 -0
- package/types/UuidType.d.ts +1 -0
- package/types/UuidType.js +1 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +13 -1
- package/typings.d.ts +177 -0
- package/typings.js +11 -0
- package/unit-of-work/ChangeSet.d.ts +4 -0
- package/unit-of-work/ChangeSet.js +4 -0
- package/unit-of-work/ChangeSetComputer.d.ts +2 -0
- package/unit-of-work/ChangeSetComputer.js +15 -2
- package/unit-of-work/ChangeSetPersister.d.ts +4 -0
- package/unit-of-work/ChangeSetPersister.js +4 -0
- package/unit-of-work/IdentityMap.d.ts +7 -0
- package/unit-of-work/IdentityMap.js +7 -0
- package/unit-of-work/UnitOfWork.d.ts +15 -0
- package/unit-of-work/UnitOfWork.js +15 -0
- package/utils/Configuration.d.ts +8 -0
- package/utils/Configuration.js +8 -0
- package/utils/EntityComparator.d.ts +2 -0
- package/utils/EntityComparator.js +2 -0
- package/utils/NullHighlighter.d.ts +1 -0
- package/utils/NullHighlighter.js +1 -0
- package/utils/RawQueryFragment.d.ts +10 -0
- package/utils/RawQueryFragment.js +9 -0
- package/utils/RequestContext.d.ts +1 -0
- package/utils/TransactionContext.d.ts +1 -0
- package/utils/TransactionContext.js +1 -0
- package/utils/Utils.d.ts +6 -0
- package/utils/Utils.js +7 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Utils } from './Utils.js';
|
|
2
|
+
/** Represents a raw SQL fragment with optional parameters, usable as both a value and an object key via Symbol coercion. */
|
|
2
3
|
export class RawQueryFragment {
|
|
3
4
|
sql;
|
|
4
5
|
params;
|
|
@@ -8,6 +9,7 @@ export class RawQueryFragment {
|
|
|
8
9
|
this.sql = sql;
|
|
9
10
|
this.params = params;
|
|
10
11
|
}
|
|
12
|
+
/** Returns a unique symbol key for this fragment, creating and caching it on first access. */
|
|
11
13
|
get key() {
|
|
12
14
|
if (!this.#key) {
|
|
13
15
|
this.#key = Symbol(this.toJSON());
|
|
@@ -15,6 +17,7 @@ export class RawQueryFragment {
|
|
|
15
17
|
}
|
|
16
18
|
return this.#key;
|
|
17
19
|
}
|
|
20
|
+
/** Creates a new fragment with an alias appended via `as ??`. */
|
|
18
21
|
as(alias) {
|
|
19
22
|
return new RawQueryFragment(`${this.sql} as ??`, [...this.params, alias]);
|
|
20
23
|
}
|
|
@@ -35,19 +38,23 @@ export class RawQueryFragment {
|
|
|
35
38
|
clone() {
|
|
36
39
|
return this;
|
|
37
40
|
}
|
|
41
|
+
/** Checks whether the given value is a symbol that maps to a known raw query fragment. */
|
|
38
42
|
static isKnownFragmentSymbol(key) {
|
|
39
43
|
return typeof key === 'symbol' && this.#rawQueryReferences.has(key);
|
|
40
44
|
}
|
|
45
|
+
/** Checks whether an object has any symbol keys that are known raw query fragments. */
|
|
41
46
|
static hasObjectFragments(object) {
|
|
42
47
|
return (Utils.isPlainObject(object) &&
|
|
43
48
|
Object.getOwnPropertySymbols(object).some(symbol => this.isKnownFragmentSymbol(symbol)));
|
|
44
49
|
}
|
|
50
|
+
/** Checks whether the given value is a RawQueryFragment instance or a known fragment symbol. */
|
|
45
51
|
static isKnownFragment(key) {
|
|
46
52
|
if (key instanceof RawQueryFragment) {
|
|
47
53
|
return true;
|
|
48
54
|
}
|
|
49
55
|
return this.isKnownFragmentSymbol(key);
|
|
50
56
|
}
|
|
57
|
+
/** Retrieves the RawQueryFragment associated with the given key (instance or symbol). */
|
|
51
58
|
static getKnownFragment(key) {
|
|
52
59
|
if (key instanceof RawQueryFragment) {
|
|
53
60
|
return key;
|
|
@@ -70,6 +77,7 @@ export { RawQueryFragment as Raw };
|
|
|
70
77
|
Object.defineProperties(RawQueryFragment.prototype, {
|
|
71
78
|
__raw: { value: true, enumerable: false },
|
|
72
79
|
});
|
|
80
|
+
/** Checks whether the given value is a `RawQueryFragment` instance. */
|
|
73
81
|
export function isRaw(value) {
|
|
74
82
|
return typeof value === 'object' && value !== null && '__raw' in value;
|
|
75
83
|
}
|
|
@@ -178,6 +186,7 @@ export function raw(sql, params) {
|
|
|
178
186
|
export function sql(sql, ...values) {
|
|
179
187
|
return raw(sql.join('?'), values);
|
|
180
188
|
}
|
|
189
|
+
/** Creates a raw SQL function expression wrapping the given key (e.g., `lower(name)`). */
|
|
181
190
|
export function createSqlFunction(func, key) {
|
|
182
191
|
if (typeof key === 'string') {
|
|
183
192
|
return raw(`${func}(${key})`);
|
|
@@ -35,6 +35,7 @@ export declare class RequestContext {
|
|
|
35
35
|
static getEntityManager(name?: string): EntityManager | undefined;
|
|
36
36
|
private static createContext;
|
|
37
37
|
}
|
|
38
|
+
/** Options for creating a new RequestContext, allowing schema and logger overrides. */
|
|
38
39
|
export interface CreateContextOptions {
|
|
39
40
|
schema?: string;
|
|
40
41
|
loggerContext?: LoggingOptions;
|
package/utils/Utils.d.ts
CHANGED
|
@@ -3,15 +3,21 @@ 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
5
|
import { type RawQueryFragmentSymbol } from './RawQueryFragment.js';
|
|
6
|
+
/** Deeply compares two objects for equality, handling dates, regexes, and raw fragments. */
|
|
6
7
|
export declare function compareObjects(a: any, b: any): boolean;
|
|
8
|
+
/** Compares two arrays element-by-element for deep equality. */
|
|
7
9
|
export declare function compareArrays(a: any[] | string, b: any[] | string): boolean;
|
|
10
|
+
/** Compares two boolean values, treating numeric 0/1 as false/true. */
|
|
8
11
|
export declare function compareBooleans(a: unknown, b: unknown): boolean;
|
|
12
|
+
/** Compares two byte arrays element-by-element. */
|
|
9
13
|
export declare function compareBuffers(a: Uint8Array, b: Uint8Array): boolean;
|
|
10
14
|
/**
|
|
11
15
|
* Checks if arguments are deeply (but not strictly) equal.
|
|
12
16
|
*/
|
|
13
17
|
export declare function equals(a: any, b: any): boolean;
|
|
18
|
+
/** Parses a JSON string safely, returning the original value if parsing fails. */
|
|
14
19
|
export declare function parseJsonSafe<T = unknown>(value: unknown): T;
|
|
20
|
+
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
15
21
|
export declare class Utils {
|
|
16
22
|
#private;
|
|
17
23
|
static readonly PK_SEPARATOR = "~~~";
|
package/utils/Utils.js
CHANGED
|
@@ -14,6 +14,7 @@ function compareConstructors(a, b) {
|
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
+
/** Deeply compares two objects for equality, handling dates, regexes, and raw fragments. */
|
|
17
18
|
export function compareObjects(a, b) {
|
|
18
19
|
if (a === b || (a == null && b == null)) {
|
|
19
20
|
return true;
|
|
@@ -59,6 +60,7 @@ export function compareObjects(a, b) {
|
|
|
59
60
|
}
|
|
60
61
|
return true;
|
|
61
62
|
}
|
|
63
|
+
/** Compares two arrays element-by-element for deep equality. */
|
|
62
64
|
export function compareArrays(a, b) {
|
|
63
65
|
const length = a.length;
|
|
64
66
|
if (length !== b.length) {
|
|
@@ -72,11 +74,13 @@ export function compareArrays(a, b) {
|
|
|
72
74
|
}
|
|
73
75
|
return true;
|
|
74
76
|
}
|
|
77
|
+
/** Compares two boolean values, treating numeric 0/1 as false/true. */
|
|
75
78
|
export function compareBooleans(a, b) {
|
|
76
79
|
a = typeof a === 'number' ? Boolean(a) : a;
|
|
77
80
|
b = typeof b === 'number' ? Boolean(b) : b;
|
|
78
81
|
return a === b;
|
|
79
82
|
}
|
|
83
|
+
/** Compares two byte arrays element-by-element. */
|
|
80
84
|
export function compareBuffers(a, b) {
|
|
81
85
|
const length = a.length;
|
|
82
86
|
if (length !== b.length) {
|
|
@@ -108,6 +112,7 @@ export function equals(a, b) {
|
|
|
108
112
|
return Number.isNaN(a) && Number.isNaN(b);
|
|
109
113
|
}
|
|
110
114
|
const equalsFn = equals;
|
|
115
|
+
/** Parses a JSON string safely, returning the original value if parsing fails. */
|
|
111
116
|
export function parseJsonSafe(value) {
|
|
112
117
|
if (typeof value === 'string') {
|
|
113
118
|
/* v8 ignore next */
|
|
@@ -121,9 +126,10 @@ export function parseJsonSafe(value) {
|
|
|
121
126
|
}
|
|
122
127
|
return value;
|
|
123
128
|
}
|
|
129
|
+
/** Collection of general-purpose utility methods used throughout the ORM. */
|
|
124
130
|
export class Utils {
|
|
125
131
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.
|
|
132
|
+
static #ORM_VERSION = '7.0.3-dev.0';
|
|
127
133
|
/**
|
|
128
134
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
135
|
*/
|