@mikro-orm/core 7.0.4-dev.9 → 7.0.4
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 +884 -583
- package/EntityManager.js +1922 -1895
- package/MikroORM.d.ts +103 -74
- package/MikroORM.js +178 -179
- package/README.md +1 -1
- package/cache/CacheAdapter.d.ts +36 -36
- package/cache/FileCacheAdapter.d.ts +30 -24
- package/cache/FileCacheAdapter.js +80 -78
- package/cache/GeneratedCacheAdapter.d.ts +18 -20
- package/cache/GeneratedCacheAdapter.js +30 -30
- package/cache/MemoryCacheAdapter.d.ts +18 -20
- package/cache/MemoryCacheAdapter.js +35 -36
- package/cache/NullCacheAdapter.d.ts +16 -16
- package/cache/NullCacheAdapter.js +24 -24
- package/connections/Connection.d.ts +95 -84
- package/connections/Connection.js +165 -168
- package/drivers/DatabaseDriver.d.ts +186 -80
- package/drivers/DatabaseDriver.js +450 -443
- package/drivers/IDatabaseDriver.d.ts +440 -301
- package/entity/BaseEntity.d.ts +120 -83
- package/entity/BaseEntity.js +43 -43
- package/entity/Collection.d.ts +212 -179
- package/entity/Collection.js +727 -721
- package/entity/EntityAssigner.d.ts +88 -77
- package/entity/EntityAssigner.js +231 -230
- package/entity/EntityFactory.d.ts +66 -54
- package/entity/EntityFactory.js +425 -383
- package/entity/EntityHelper.d.ts +34 -22
- package/entity/EntityHelper.js +280 -267
- package/entity/EntityIdentifier.d.ts +4 -4
- package/entity/EntityIdentifier.js +10 -10
- package/entity/EntityLoader.d.ts +98 -72
- package/entity/EntityLoader.js +753 -723
- package/entity/EntityRepository.d.ts +316 -201
- package/entity/EntityRepository.js +213 -213
- package/entity/PolymorphicRef.d.ts +5 -5
- package/entity/PolymorphicRef.js +10 -10
- package/entity/Reference.d.ts +126 -82
- package/entity/Reference.js +278 -274
- package/entity/WrappedEntity.d.ts +115 -72
- package/entity/WrappedEntity.js +168 -166
- package/entity/defineEntity.d.ts +1315 -636
- package/entity/defineEntity.js +527 -518
- package/entity/utils.d.ts +13 -3
- package/entity/utils.js +71 -73
- package/entity/validators.js +43 -43
- package/entity/wrap.js +8 -8
- package/enums.d.ts +258 -253
- package/enums.js +251 -252
- package/errors.d.ts +114 -72
- package/errors.js +350 -253
- package/events/EventManager.d.ts +26 -14
- package/events/EventManager.js +79 -77
- package/events/EventSubscriber.d.ts +29 -29
- package/events/TransactionEventBroadcaster.d.ts +15 -8
- package/events/TransactionEventBroadcaster.js +14 -14
- package/exceptions.d.ts +23 -40
- package/exceptions.js +35 -52
- package/hydration/Hydrator.d.ts +42 -17
- package/hydration/Hydrator.js +43 -43
- package/hydration/ObjectHydrator.d.ts +50 -17
- package/hydration/ObjectHydrator.js +481 -416
- package/index.d.ts +116 -2
- package/index.js +10 -1
- package/logging/DefaultLogger.d.ts +34 -32
- package/logging/DefaultLogger.js +86 -86
- package/logging/Logger.d.ts +41 -41
- package/logging/SimpleLogger.d.ts +13 -11
- package/logging/SimpleLogger.js +22 -22
- package/logging/colors.d.ts +6 -6
- package/logging/colors.js +11 -10
- package/logging/inspect.js +7 -7
- package/metadata/EntitySchema.d.ts +211 -127
- package/metadata/EntitySchema.js +397 -398
- package/metadata/MetadataDiscovery.d.ts +114 -114
- package/metadata/MetadataDiscovery.js +1951 -1863
- package/metadata/MetadataProvider.d.ts +24 -21
- package/metadata/MetadataProvider.js +82 -84
- package/metadata/MetadataStorage.d.ts +38 -32
- package/metadata/MetadataStorage.js +118 -118
- package/metadata/MetadataValidator.d.ts +39 -39
- package/metadata/MetadataValidator.js +381 -338
- package/metadata/discover-entities.d.ts +5 -2
- package/metadata/discover-entities.js +35 -27
- package/metadata/types.d.ts +615 -531
- package/naming-strategy/AbstractNamingStrategy.d.ts +54 -39
- package/naming-strategy/AbstractNamingStrategy.js +90 -85
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
- package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
- package/naming-strategy/MongoNamingStrategy.d.ts +6 -6
- package/naming-strategy/MongoNamingStrategy.js +18 -18
- package/naming-strategy/NamingStrategy.d.ts +109 -99
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +7 -7
- package/naming-strategy/UnderscoreNamingStrategy.js +21 -21
- package/not-supported.js +7 -4
- package/package.json +1 -1
- package/platforms/ExceptionConverter.d.ts +1 -1
- package/platforms/ExceptionConverter.js +4 -4
- package/platforms/Platform.d.ts +310 -299
- package/platforms/Platform.js +663 -636
- package/serialization/EntitySerializer.d.ts +49 -26
- package/serialization/EntitySerializer.js +224 -218
- package/serialization/EntityTransformer.d.ts +10 -6
- package/serialization/EntityTransformer.js +219 -217
- package/serialization/SerializationContext.d.ts +27 -23
- package/serialization/SerializationContext.js +105 -105
- package/types/ArrayType.d.ts +8 -8
- package/types/ArrayType.js +33 -33
- package/types/BigIntType.d.ts +17 -10
- package/types/BigIntType.js +37 -37
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +13 -13
- package/types/BooleanType.d.ts +4 -4
- package/types/BooleanType.js +12 -12
- package/types/CharacterType.d.ts +2 -2
- package/types/CharacterType.js +6 -6
- package/types/DateTimeType.d.ts +5 -5
- package/types/DateTimeType.js +15 -15
- package/types/DateType.d.ts +5 -5
- package/types/DateType.js +15 -15
- package/types/DecimalType.d.ts +7 -7
- package/types/DecimalType.js +26 -26
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +12 -12
- package/types/EnumArrayType.d.ts +5 -5
- package/types/EnumArrayType.js +24 -24
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +11 -11
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +9 -9
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +9 -9
- package/types/IntervalType.d.ts +4 -4
- package/types/IntervalType.js +12 -12
- package/types/JsonType.d.ts +8 -8
- package/types/JsonType.js +32 -32
- package/types/MediumIntType.d.ts +1 -1
- package/types/MediumIntType.js +3 -3
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +9 -9
- package/types/StringType.d.ts +4 -4
- package/types/StringType.js +12 -12
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +9 -9
- package/types/TimeType.d.ts +5 -5
- package/types/TimeType.js +17 -17
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +10 -10
- package/types/Type.d.ts +83 -79
- package/types/Type.js +82 -82
- package/types/Uint8ArrayType.d.ts +4 -4
- package/types/Uint8ArrayType.js +21 -21
- package/types/UnknownType.d.ts +4 -4
- package/types/UnknownType.js +12 -12
- package/types/UuidType.d.ts +5 -5
- package/types/UuidType.js +19 -19
- package/types/index.d.ts +75 -49
- package/types/index.js +52 -26
- package/typings.d.ts +1250 -737
- package/typings.js +244 -231
- package/unit-of-work/ChangeSet.d.ts +26 -26
- package/unit-of-work/ChangeSet.js +56 -56
- package/unit-of-work/ChangeSetComputer.d.ts +12 -12
- package/unit-of-work/ChangeSetComputer.js +178 -170
- package/unit-of-work/ChangeSetPersister.d.ts +63 -44
- package/unit-of-work/ChangeSetPersister.js +442 -421
- package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
- package/unit-of-work/CommitOrderCalculator.js +89 -88
- package/unit-of-work/IdentityMap.d.ts +31 -31
- package/unit-of-work/IdentityMap.js +105 -105
- package/unit-of-work/UnitOfWork.d.ts +181 -141
- package/unit-of-work/UnitOfWork.js +1200 -1183
- package/utils/AbstractMigrator.d.ts +111 -91
- package/utils/AbstractMigrator.js +275 -275
- package/utils/AbstractSchemaGenerator.d.ts +43 -34
- package/utils/AbstractSchemaGenerator.js +121 -122
- package/utils/AsyncContext.d.ts +3 -3
- package/utils/AsyncContext.js +34 -35
- package/utils/Configuration.d.ts +852 -808
- package/utils/Configuration.js +359 -344
- package/utils/Cursor.d.ts +40 -22
- package/utils/Cursor.js +135 -127
- package/utils/DataloaderUtils.d.ts +58 -43
- package/utils/DataloaderUtils.js +203 -198
- package/utils/EntityComparator.d.ts +98 -81
- package/utils/EntityComparator.js +828 -728
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +3 -3
- package/utils/QueryHelper.d.ts +79 -51
- package/utils/QueryHelper.js +372 -361
- package/utils/RawQueryFragment.d.ts +50 -34
- package/utils/RawQueryFragment.js +107 -105
- package/utils/RequestContext.d.ts +32 -32
- package/utils/RequestContext.js +52 -53
- package/utils/TransactionContext.d.ts +16 -16
- package/utils/TransactionContext.js +27 -27
- package/utils/TransactionManager.d.ts +58 -58
- package/utils/TransactionManager.js +199 -197
- package/utils/Utils.d.ts +204 -145
- package/utils/Utils.js +812 -810
- package/utils/clone.js +104 -113
- package/utils/env-vars.js +90 -88
- package/utils/fs-utils.d.ts +15 -15
- package/utils/fs-utils.js +180 -181
- package/utils/upsert-utils.d.ts +20 -5
- package/utils/upsert-utils.js +114 -116
package/events/EventManager.d.ts
CHANGED
|
@@ -3,18 +3,30 @@ import type { EventArgs, EventSubscriber, FlushEventArgs, TransactionEventArgs }
|
|
|
3
3
|
import { EventType, type TransactionEventType } from '../enums.js';
|
|
4
4
|
/** Manages event subscribers and dispatches entity/flush/transaction lifecycle events. */
|
|
5
5
|
export declare class EventManager {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
#private;
|
|
7
|
+
constructor(subscribers: Iterable<EventSubscriber>);
|
|
8
|
+
/** Registers an event subscriber and indexes its subscribed entities and event types. */
|
|
9
|
+
registerSubscriber(subscriber: EventSubscriber): void;
|
|
10
|
+
/** Returns the set of all registered event subscribers. */
|
|
11
|
+
getSubscribers(): Set<EventSubscriber>;
|
|
12
|
+
dispatchEvent<T extends object>(
|
|
13
|
+
event: TransactionEventType,
|
|
14
|
+
args: TransactionEventArgs,
|
|
15
|
+
meta?: EntityMetadata<T>,
|
|
16
|
+
): unknown;
|
|
17
|
+
dispatchEvent<T extends object>(
|
|
18
|
+
event: EventType.onInit,
|
|
19
|
+
args: Partial<EventArgs<T>>,
|
|
20
|
+
meta?: EntityMetadata<T>,
|
|
21
|
+
): unknown;
|
|
22
|
+
dispatchEvent<T extends object>(
|
|
23
|
+
event: EventType,
|
|
24
|
+
args: Partial<EventArgs<T> | FlushEventArgs>,
|
|
25
|
+
meta?: EntityMetadata<T>,
|
|
26
|
+
): Promise<unknown>;
|
|
27
|
+
/** Checks whether there are any listeners (hooks or subscribers) for the given event type and entity. */
|
|
28
|
+
hasListeners<T>(event: EventType, meta: EntityMetadata<T>): boolean;
|
|
29
|
+
/** Creates a new EventManager with the same set of subscribers. */
|
|
30
|
+
clone(): EventManager;
|
|
31
|
+
private getSubscribedEntities;
|
|
20
32
|
}
|
package/events/EventManager.js
CHANGED
|
@@ -2,88 +2,90 @@ import { Utils } from '../utils/Utils.js';
|
|
|
2
2
|
import { EventType, EventTypeMap } from '../enums.js';
|
|
3
3
|
/** Manages event subscribers and dispatches entity/flush/transaction lifecycle events. */
|
|
4
4
|
export class EventManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
#listeners = {};
|
|
6
|
+
#entities = new Map();
|
|
7
|
+
#cache = new Map();
|
|
8
|
+
#subscribers = new Set();
|
|
9
|
+
constructor(subscribers) {
|
|
10
|
+
for (const subscriber of subscribers) {
|
|
11
|
+
this.registerSubscriber(subscriber);
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.#subscribers.add(subscriber);
|
|
20
|
-
this.#entities.set(subscriber, this.getSubscribedEntities(subscriber));
|
|
21
|
-
this.#cache.clear();
|
|
22
|
-
Utils.keys(EventType)
|
|
23
|
-
.filter(event => event in subscriber)
|
|
24
|
-
.forEach(event => {
|
|
25
|
-
this.#listeners[event] ??= new Set();
|
|
26
|
-
this.#listeners[event].add(subscriber);
|
|
27
|
-
});
|
|
13
|
+
}
|
|
14
|
+
/** Registers an event subscriber and indexes its subscribed entities and event types. */
|
|
15
|
+
registerSubscriber(subscriber) {
|
|
16
|
+
if (this.#subscribers.has(subscriber)) {
|
|
17
|
+
return;
|
|
28
18
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
this.#subscribers.add(subscriber);
|
|
20
|
+
this.#entities.set(subscriber, this.getSubscribedEntities(subscriber));
|
|
21
|
+
this.#cache.clear();
|
|
22
|
+
Utils.keys(EventType)
|
|
23
|
+
.filter(event => event in subscriber)
|
|
24
|
+
.forEach(event => {
|
|
25
|
+
this.#listeners[event] ??= new Set();
|
|
26
|
+
this.#listeners[event].add(subscriber);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** Returns the set of all registered event subscribers. */
|
|
30
|
+
getSubscribers() {
|
|
31
|
+
return this.#subscribers;
|
|
32
|
+
}
|
|
33
|
+
dispatchEvent(event, args, meta) {
|
|
34
|
+
const listeners = [];
|
|
35
|
+
const entity = args.entity;
|
|
36
|
+
// execute lifecycle hooks first
|
|
37
|
+
meta ??= entity?.__meta;
|
|
38
|
+
const hooks = meta?.hooks[event] || [];
|
|
39
|
+
listeners.push(
|
|
40
|
+
...hooks.map(hook => {
|
|
41
|
+
const prototypeHook = meta?.prototype[hook];
|
|
42
|
+
const handler = typeof hook === 'function' ? hook : (entity[hook] ?? prototypeHook);
|
|
43
|
+
return handler.bind(entity);
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
for (const listener of this.#listeners[event] ?? new Set()) {
|
|
47
|
+
const entities = this.#entities.get(listener);
|
|
48
|
+
if (entities.size === 0 || !entity || entities.has(entity.constructor.name)) {
|
|
49
|
+
listeners.push(listener[event].bind(listener));
|
|
50
|
+
}
|
|
32
51
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const hooks = (meta?.hooks[event] || []);
|
|
39
|
-
listeners.push(...hooks.map(hook => {
|
|
40
|
-
const prototypeHook = meta?.prototype[hook];
|
|
41
|
-
const handler = typeof hook === 'function' ? hook : (entity[hook] ?? prototypeHook);
|
|
42
|
-
return handler.bind(entity);
|
|
43
|
-
}));
|
|
44
|
-
for (const listener of this.#listeners[event] ?? new Set()) {
|
|
45
|
-
const entities = this.#entities.get(listener);
|
|
46
|
-
if (entities.size === 0 || !entity || entities.has(entity.constructor.name)) {
|
|
47
|
-
listeners.push(listener[event].bind(listener));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (event === EventType.onInit) {
|
|
51
|
-
for (const listener of listeners) {
|
|
52
|
-
void listener(args);
|
|
53
|
-
}
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
return Utils.runSerial(listeners, listener => listener(args));
|
|
52
|
+
if (event === EventType.onInit) {
|
|
53
|
+
for (const listener of listeners) {
|
|
54
|
+
void listener(args);
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (hasHooks) {
|
|
66
|
-
this.#cache.set(cacheKey, true);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
for (const listener of this.#listeners[event] ?? new Set()) {
|
|
70
|
-
const entities = this.#entities.get(listener);
|
|
71
|
-
if (entities.size === 0 || entities.has(meta.className)) {
|
|
72
|
-
this.#cache.set(cacheKey, true);
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.#cache.set(cacheKey, false);
|
|
77
|
-
return false;
|
|
58
|
+
return Utils.runSerial(listeners, listener => listener(args));
|
|
59
|
+
}
|
|
60
|
+
/** Checks whether there are any listeners (hooks or subscribers) for the given event type and entity. */
|
|
61
|
+
hasListeners(event, meta) {
|
|
62
|
+
const cacheKey = meta._id + EventTypeMap[event];
|
|
63
|
+
if (this.#cache.has(cacheKey)) {
|
|
64
|
+
return this.#cache.get(cacheKey);
|
|
78
65
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
const hasHooks = meta.hooks[event]?.length;
|
|
67
|
+
if (hasHooks) {
|
|
68
|
+
this.#cache.set(cacheKey, true);
|
|
69
|
+
return true;
|
|
82
70
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return
|
|
71
|
+
for (const listener of this.#listeners[event] ?? new Set()) {
|
|
72
|
+
const entities = this.#entities.get(listener);
|
|
73
|
+
if (entities.size === 0 || entities.has(meta.className)) {
|
|
74
|
+
this.#cache.set(cacheKey, true);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
88
77
|
}
|
|
78
|
+
this.#cache.set(cacheKey, false);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/** Creates a new EventManager with the same set of subscribers. */
|
|
82
|
+
clone() {
|
|
83
|
+
return new EventManager(this.#subscribers);
|
|
84
|
+
}
|
|
85
|
+
getSubscribedEntities(listener) {
|
|
86
|
+
if (!listener.getSubscribedEntities) {
|
|
87
|
+
return new Set();
|
|
88
|
+
}
|
|
89
|
+
return new Set(listener.getSubscribedEntities().map(name => Utils.className(name)));
|
|
90
|
+
}
|
|
89
91
|
}
|
|
@@ -5,42 +5,42 @@ import type { ChangeSet } from '../unit-of-work/ChangeSet.js';
|
|
|
5
5
|
import type { Transaction } from '../connections/Connection.js';
|
|
6
6
|
/** Arguments passed to entity lifecycle event hooks. */
|
|
7
7
|
export interface EventArgs<T> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
entity: T;
|
|
9
|
+
em: EntityManager;
|
|
10
|
+
meta: EntityMetadata<T>;
|
|
11
|
+
changeSet?: ChangeSet<T & {}>;
|
|
12
12
|
}
|
|
13
13
|
/** Arguments passed to flush lifecycle event hooks (beforeFlush, onFlush, afterFlush). */
|
|
14
14
|
export interface FlushEventArgs extends Omit<EventArgs<any>, 'entity' | 'changeSet' | 'meta'> {
|
|
15
|
-
|
|
15
|
+
uow: UnitOfWork;
|
|
16
16
|
}
|
|
17
17
|
/** Arguments passed to transaction lifecycle event hooks (start, commit, rollback). */
|
|
18
18
|
export interface TransactionEventArgs extends Omit<EventArgs<any>, 'entity' | 'meta' | 'changeSet'> {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
transaction?: Transaction & {
|
|
20
|
+
savepointName?: string;
|
|
21
|
+
};
|
|
22
|
+
uow?: UnitOfWork;
|
|
23
23
|
}
|
|
24
24
|
/** Interface for subscribing to entity and transaction lifecycle events. */
|
|
25
25
|
export interface EventSubscriber<T = any> {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
getSubscribedEntities?(): EntityName<T>[];
|
|
27
|
+
onInit?(args: EventArgs<T>): void;
|
|
28
|
+
onLoad?(args: EventArgs<T>): void | Promise<void>;
|
|
29
|
+
beforeCreate?(args: EventArgs<T>): void | Promise<void>;
|
|
30
|
+
afterCreate?(args: EventArgs<T>): void | Promise<void>;
|
|
31
|
+
beforeUpdate?(args: EventArgs<T>): void | Promise<void>;
|
|
32
|
+
afterUpdate?(args: EventArgs<T>): void | Promise<void>;
|
|
33
|
+
beforeUpsert?(args: EventArgs<T>): void | Promise<void>;
|
|
34
|
+
afterUpsert?(args: EventArgs<T>): void | Promise<void>;
|
|
35
|
+
beforeDelete?(args: EventArgs<T>): void | Promise<void>;
|
|
36
|
+
afterDelete?(args: EventArgs<T>): void | Promise<void>;
|
|
37
|
+
beforeFlush?(args: FlushEventArgs): void | Promise<void>;
|
|
38
|
+
onFlush?(args: FlushEventArgs): void | Promise<void>;
|
|
39
|
+
afterFlush?(args: FlushEventArgs): void | Promise<void>;
|
|
40
|
+
beforeTransactionStart?(args: TransactionEventArgs): void | Promise<void>;
|
|
41
|
+
afterTransactionStart?(args: TransactionEventArgs): void | Promise<void>;
|
|
42
|
+
beforeTransactionCommit?(args: TransactionEventArgs): void | Promise<void>;
|
|
43
|
+
afterTransactionCommit?(args: TransactionEventArgs): void | Promise<void>;
|
|
44
|
+
beforeTransactionRollback?(args: TransactionEventArgs): void | Promise<void>;
|
|
45
|
+
afterTransactionRollback?(args: TransactionEventArgs): void | Promise<void>;
|
|
46
46
|
}
|
|
@@ -3,13 +3,20 @@ import type { EntityManager } from '../EntityManager.js';
|
|
|
3
3
|
import type { TransactionEventType } from '../enums.js';
|
|
4
4
|
/** Broadcasts transaction lifecycle events (start, commit, rollback) through the EventManager. */
|
|
5
5
|
export declare class TransactionEventBroadcaster {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
private readonly em;
|
|
7
|
+
readonly context?:
|
|
8
|
+
| {
|
|
8
9
|
topLevelTransaction?: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
}
|
|
11
|
+
| undefined;
|
|
12
|
+
constructor(
|
|
13
|
+
em: EntityManager,
|
|
14
|
+
context?:
|
|
15
|
+
| {
|
|
16
|
+
topLevelTransaction?: boolean;
|
|
17
|
+
}
|
|
18
|
+
| undefined,
|
|
19
|
+
);
|
|
20
|
+
/** Dispatches a transaction lifecycle event to the EventManager. */
|
|
21
|
+
dispatchEvent(event: TransactionEventType, transaction?: Transaction): Promise<void>;
|
|
15
22
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/** Broadcasts transaction lifecycle events (start, commit, rollback) through the EventManager. */
|
|
2
2
|
export class TransactionEventBroadcaster {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
em;
|
|
4
|
+
context;
|
|
5
|
+
constructor(em, context) {
|
|
6
|
+
this.em = em;
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
/** Dispatches a transaction lifecycle event to the EventManager. */
|
|
10
|
+
async dispatchEvent(event, transaction) {
|
|
11
|
+
await this.em.getEventManager().dispatchEvent(event, {
|
|
12
|
+
em: this.em,
|
|
13
|
+
uow: this.em.getUnitOfWork(false),
|
|
14
|
+
transaction,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
17
|
}
|
package/exceptions.d.ts
CHANGED
|
@@ -2,28 +2,25 @@
|
|
|
2
2
|
* Base class for all errors detected in the driver.
|
|
3
3
|
*/
|
|
4
4
|
export declare class DriverException extends Error {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
code?: string;
|
|
6
|
+
errno?: number;
|
|
7
|
+
sqlState?: string;
|
|
8
|
+
sqlMessage?: string;
|
|
9
|
+
errmsg?: string;
|
|
10
|
+
constructor(previous: Error);
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Base class for all connection related errors detected in the driver.
|
|
14
14
|
*/
|
|
15
|
-
export declare class ConnectionException extends DriverException {
|
|
16
|
-
}
|
|
15
|
+
export declare class ConnectionException extends DriverException {}
|
|
17
16
|
/**
|
|
18
17
|
* Base class for all server related errors detected in the driver.
|
|
19
18
|
*/
|
|
20
|
-
export declare class ServerException extends DriverException {
|
|
21
|
-
}
|
|
19
|
+
export declare class ServerException extends DriverException {}
|
|
22
20
|
/**
|
|
23
21
|
* Base class for all constraint violation related errors detected in the driver.
|
|
24
22
|
*/
|
|
25
|
-
export declare class ConstraintViolationException extends ServerException {
|
|
26
|
-
}
|
|
23
|
+
export declare class ConstraintViolationException extends ServerException {}
|
|
27
24
|
/**
|
|
28
25
|
* Base class for all already existing database object related errors detected in the driver.
|
|
29
26
|
*
|
|
@@ -31,8 +28,7 @@ export declare class ConstraintViolationException extends ServerException {
|
|
|
31
28
|
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
|
32
29
|
* functions, stored procedures etc.
|
|
33
30
|
*/
|
|
34
|
-
export declare class DatabaseObjectExistsException extends ServerException {
|
|
35
|
-
}
|
|
31
|
+
export declare class DatabaseObjectExistsException extends ServerException {}
|
|
36
32
|
/**
|
|
37
33
|
* Base class for all unknown database object related errors detected in the driver.
|
|
38
34
|
*
|
|
@@ -40,65 +36,52 @@ export declare class DatabaseObjectExistsException extends ServerException {
|
|
|
40
36
|
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
|
41
37
|
* functions, stored procedures etc.
|
|
42
38
|
*/
|
|
43
|
-
export declare class DatabaseObjectNotFoundException extends ServerException {
|
|
44
|
-
}
|
|
39
|
+
export declare class DatabaseObjectNotFoundException extends ServerException {}
|
|
45
40
|
/**
|
|
46
41
|
* Exception for a deadlock error of a transaction detected in the driver.
|
|
47
42
|
*/
|
|
48
|
-
export declare class DeadlockException extends ServerException {
|
|
49
|
-
}
|
|
43
|
+
export declare class DeadlockException extends ServerException {}
|
|
50
44
|
/**
|
|
51
45
|
* Exception for a foreign key constraint violation detected in the driver.
|
|
52
46
|
*/
|
|
53
|
-
export declare class ForeignKeyConstraintViolationException extends ConstraintViolationException {
|
|
54
|
-
}
|
|
47
|
+
export declare class ForeignKeyConstraintViolationException extends ConstraintViolationException {}
|
|
55
48
|
/**
|
|
56
49
|
* Exception for a check constraint violation detected in the driver.
|
|
57
50
|
*/
|
|
58
|
-
export declare class CheckConstraintViolationException extends ConstraintViolationException {
|
|
59
|
-
}
|
|
51
|
+
export declare class CheckConstraintViolationException extends ConstraintViolationException {}
|
|
60
52
|
/**
|
|
61
53
|
* Exception for an invalid specified field name in a statement detected in the driver.
|
|
62
54
|
*/
|
|
63
|
-
export declare class InvalidFieldNameException extends ServerException {
|
|
64
|
-
}
|
|
55
|
+
export declare class InvalidFieldNameException extends ServerException {}
|
|
65
56
|
/**
|
|
66
57
|
* Exception for a lock wait timeout error of a transaction detected in the driver.
|
|
67
58
|
*/
|
|
68
|
-
export declare class LockWaitTimeoutException extends ServerException {
|
|
69
|
-
}
|
|
59
|
+
export declare class LockWaitTimeoutException extends ServerException {}
|
|
70
60
|
/**
|
|
71
61
|
* Exception for a non-unique/ambiguous specified field name in a statement detected in the driver.
|
|
72
62
|
*/
|
|
73
|
-
export declare class NonUniqueFieldNameException extends ServerException {
|
|
74
|
-
}
|
|
63
|
+
export declare class NonUniqueFieldNameException extends ServerException {}
|
|
75
64
|
/**
|
|
76
65
|
* Exception for a NOT NULL constraint violation detected in the driver.
|
|
77
66
|
*/
|
|
78
|
-
export declare class NotNullConstraintViolationException extends ConstraintViolationException {
|
|
79
|
-
}
|
|
67
|
+
export declare class NotNullConstraintViolationException extends ConstraintViolationException {}
|
|
80
68
|
/**
|
|
81
69
|
* Exception for a write operation attempt on a read-only database element detected in the driver.
|
|
82
70
|
*/
|
|
83
|
-
export declare class ReadOnlyException extends ServerException {
|
|
84
|
-
}
|
|
71
|
+
export declare class ReadOnlyException extends ServerException {}
|
|
85
72
|
/**
|
|
86
73
|
* Exception for a syntax error in a statement detected in the driver.
|
|
87
74
|
*/
|
|
88
|
-
export declare class SyntaxErrorException extends ServerException {
|
|
89
|
-
}
|
|
75
|
+
export declare class SyntaxErrorException extends ServerException {}
|
|
90
76
|
/**
|
|
91
77
|
* Exception for an already existing table referenced in a statement detected in the driver.
|
|
92
78
|
*/
|
|
93
|
-
export declare class TableExistsException extends DatabaseObjectExistsException {
|
|
94
|
-
}
|
|
79
|
+
export declare class TableExistsException extends DatabaseObjectExistsException {}
|
|
95
80
|
/**
|
|
96
81
|
* Exception for an unknown table referenced in a statement detected in the driver.
|
|
97
82
|
*/
|
|
98
|
-
export declare class TableNotFoundException extends DatabaseObjectNotFoundException {
|
|
99
|
-
}
|
|
83
|
+
export declare class TableNotFoundException extends DatabaseObjectNotFoundException {}
|
|
100
84
|
/**
|
|
101
85
|
* Exception for a unique constraint violation detected in the driver.
|
|
102
86
|
*/
|
|
103
|
-
export declare class UniqueConstraintViolationException extends ConstraintViolationException {
|
|
104
|
-
}
|
|
87
|
+
export declare class UniqueConstraintViolationException extends ConstraintViolationException {}
|
package/exceptions.js
CHANGED
|
@@ -2,41 +2,38 @@
|
|
|
2
2
|
* Base class for all errors detected in the driver.
|
|
3
3
|
*/
|
|
4
4
|
export class DriverException extends Error {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
5
|
+
code;
|
|
6
|
+
errno;
|
|
7
|
+
sqlState;
|
|
8
|
+
sqlMessage;
|
|
9
|
+
errmsg;
|
|
10
|
+
constructor(previous) {
|
|
11
|
+
super(previous.message);
|
|
12
|
+
Object.getOwnPropertyNames(previous).forEach(k => (this[k] = previous[k]));
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
if (previous.stack) {
|
|
16
|
+
this.stack +=
|
|
17
|
+
'\n\n' +
|
|
18
|
+
previous.stack
|
|
19
|
+
.split('\n')
|
|
20
|
+
.filter(l => l.trim().startsWith('at '))
|
|
21
|
+
.join('\n');
|
|
23
22
|
}
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Base class for all connection related errors detected in the driver.
|
|
27
27
|
*/
|
|
28
|
-
export class ConnectionException extends DriverException {
|
|
29
|
-
}
|
|
28
|
+
export class ConnectionException extends DriverException {}
|
|
30
29
|
/**
|
|
31
30
|
* Base class for all server related errors detected in the driver.
|
|
32
31
|
*/
|
|
33
|
-
export class ServerException extends DriverException {
|
|
34
|
-
}
|
|
32
|
+
export class ServerException extends DriverException {}
|
|
35
33
|
/**
|
|
36
34
|
* Base class for all constraint violation related errors detected in the driver.
|
|
37
35
|
*/
|
|
38
|
-
export class ConstraintViolationException extends ServerException {
|
|
39
|
-
}
|
|
36
|
+
export class ConstraintViolationException extends ServerException {}
|
|
40
37
|
/**
|
|
41
38
|
* Base class for all already existing database object related errors detected in the driver.
|
|
42
39
|
*
|
|
@@ -44,8 +41,7 @@ export class ConstraintViolationException extends ServerException {
|
|
|
44
41
|
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
|
45
42
|
* functions, stored procedures etc.
|
|
46
43
|
*/
|
|
47
|
-
export class DatabaseObjectExistsException extends ServerException {
|
|
48
|
-
}
|
|
44
|
+
export class DatabaseObjectExistsException extends ServerException {}
|
|
49
45
|
/**
|
|
50
46
|
* Base class for all unknown database object related errors detected in the driver.
|
|
51
47
|
*
|
|
@@ -53,65 +49,52 @@ export class DatabaseObjectExistsException extends ServerException {
|
|
|
53
49
|
* such as schemas, tables, views, sequences, triggers, constraints, indexes,
|
|
54
50
|
* functions, stored procedures etc.
|
|
55
51
|
*/
|
|
56
|
-
export class DatabaseObjectNotFoundException extends ServerException {
|
|
57
|
-
}
|
|
52
|
+
export class DatabaseObjectNotFoundException extends ServerException {}
|
|
58
53
|
/**
|
|
59
54
|
* Exception for a deadlock error of a transaction detected in the driver.
|
|
60
55
|
*/
|
|
61
|
-
export class DeadlockException extends ServerException {
|
|
62
|
-
}
|
|
56
|
+
export class DeadlockException extends ServerException {}
|
|
63
57
|
/**
|
|
64
58
|
* Exception for a foreign key constraint violation detected in the driver.
|
|
65
59
|
*/
|
|
66
|
-
export class ForeignKeyConstraintViolationException extends ConstraintViolationException {
|
|
67
|
-
}
|
|
60
|
+
export class ForeignKeyConstraintViolationException extends ConstraintViolationException {}
|
|
68
61
|
/**
|
|
69
62
|
* Exception for a check constraint violation detected in the driver.
|
|
70
63
|
*/
|
|
71
|
-
export class CheckConstraintViolationException extends ConstraintViolationException {
|
|
72
|
-
}
|
|
64
|
+
export class CheckConstraintViolationException extends ConstraintViolationException {}
|
|
73
65
|
/**
|
|
74
66
|
* Exception for an invalid specified field name in a statement detected in the driver.
|
|
75
67
|
*/
|
|
76
|
-
export class InvalidFieldNameException extends ServerException {
|
|
77
|
-
}
|
|
68
|
+
export class InvalidFieldNameException extends ServerException {}
|
|
78
69
|
/**
|
|
79
70
|
* Exception for a lock wait timeout error of a transaction detected in the driver.
|
|
80
71
|
*/
|
|
81
|
-
export class LockWaitTimeoutException extends ServerException {
|
|
82
|
-
}
|
|
72
|
+
export class LockWaitTimeoutException extends ServerException {}
|
|
83
73
|
/**
|
|
84
74
|
* Exception for a non-unique/ambiguous specified field name in a statement detected in the driver.
|
|
85
75
|
*/
|
|
86
|
-
export class NonUniqueFieldNameException extends ServerException {
|
|
87
|
-
}
|
|
76
|
+
export class NonUniqueFieldNameException extends ServerException {}
|
|
88
77
|
/**
|
|
89
78
|
* Exception for a NOT NULL constraint violation detected in the driver.
|
|
90
79
|
*/
|
|
91
|
-
export class NotNullConstraintViolationException extends ConstraintViolationException {
|
|
92
|
-
}
|
|
80
|
+
export class NotNullConstraintViolationException extends ConstraintViolationException {}
|
|
93
81
|
/**
|
|
94
82
|
* Exception for a write operation attempt on a read-only database element detected in the driver.
|
|
95
83
|
*/
|
|
96
|
-
export class ReadOnlyException extends ServerException {
|
|
97
|
-
}
|
|
84
|
+
export class ReadOnlyException extends ServerException {}
|
|
98
85
|
/**
|
|
99
86
|
* Exception for a syntax error in a statement detected in the driver.
|
|
100
87
|
*/
|
|
101
|
-
export class SyntaxErrorException extends ServerException {
|
|
102
|
-
}
|
|
88
|
+
export class SyntaxErrorException extends ServerException {}
|
|
103
89
|
/**
|
|
104
90
|
* Exception for an already existing table referenced in a statement detected in the driver.
|
|
105
91
|
*/
|
|
106
|
-
export class TableExistsException extends DatabaseObjectExistsException {
|
|
107
|
-
}
|
|
92
|
+
export class TableExistsException extends DatabaseObjectExistsException {}
|
|
108
93
|
/**
|
|
109
94
|
* Exception for an unknown table referenced in a statement detected in the driver.
|
|
110
95
|
*/
|
|
111
|
-
export class TableNotFoundException extends DatabaseObjectNotFoundException {
|
|
112
|
-
}
|
|
96
|
+
export class TableNotFoundException extends DatabaseObjectNotFoundException {}
|
|
113
97
|
/**
|
|
114
98
|
* Exception for a unique constraint violation detected in the driver.
|
|
115
99
|
*/
|
|
116
|
-
export class UniqueConstraintViolationException extends ConstraintViolationException {
|
|
117
|
-
}
|
|
100
|
+
export class UniqueConstraintViolationException extends ConstraintViolationException {}
|