@mikro-orm/core 7.0.2-dev.13 → 7.0.2-dev.15

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.
Files changed (147) hide show
  1. package/EntityManager.d.ts +4 -0
  2. package/EntityManager.js +4 -0
  3. package/MikroORM.d.ts +2 -0
  4. package/MikroORM.js +2 -0
  5. package/cache/CacheAdapter.d.ts +2 -0
  6. package/cache/GeneratedCacheAdapter.d.ts +1 -0
  7. package/cache/GeneratedCacheAdapter.js +1 -0
  8. package/cache/MemoryCacheAdapter.d.ts +1 -0
  9. package/cache/MemoryCacheAdapter.js +1 -0
  10. package/cache/NullCacheAdapter.d.ts +1 -0
  11. package/cache/NullCacheAdapter.js +1 -0
  12. package/connections/Connection.d.ts +13 -0
  13. package/connections/Connection.js +9 -0
  14. package/drivers/DatabaseDriver.d.ts +12 -0
  15. package/drivers/DatabaseDriver.js +12 -0
  16. package/drivers/IDatabaseDriver.d.ts +44 -0
  17. package/drivers/IDatabaseDriver.js +1 -0
  18. package/entity/BaseEntity.d.ts +11 -0
  19. package/entity/BaseEntity.js +11 -0
  20. package/entity/Collection.d.ts +26 -0
  21. package/entity/Collection.js +15 -0
  22. package/entity/EntityAssigner.d.ts +3 -0
  23. package/entity/EntityAssigner.js +2 -0
  24. package/entity/EntityFactory.d.ts +16 -0
  25. package/entity/EntityFactory.js +19 -0
  26. package/entity/EntityLoader.d.ts +19 -0
  27. package/entity/EntityLoader.js +2 -0
  28. package/entity/EntityRepository.d.ts +2 -0
  29. package/entity/EntityRepository.js +2 -0
  30. package/entity/Reference.d.ts +20 -0
  31. package/entity/Reference.js +16 -0
  32. package/entity/WrappedEntity.d.ts +20 -0
  33. package/entity/WrappedEntity.js +21 -1
  34. package/entity/defineEntity.d.ts +10 -0
  35. package/entity/defineEntity.js +1 -0
  36. package/enums.d.ts +132 -0
  37. package/enums.js +132 -0
  38. package/errors.d.ts +6 -0
  39. package/errors.js +6 -0
  40. package/events/EventManager.d.ts +5 -0
  41. package/events/EventManager.js +5 -0
  42. package/events/EventSubscriber.d.ts +4 -0
  43. package/events/TransactionEventBroadcaster.d.ts +2 -0
  44. package/events/TransactionEventBroadcaster.js +2 -0
  45. package/hydration/Hydrator.d.ts +2 -0
  46. package/hydration/Hydrator.js +2 -0
  47. package/hydration/ObjectHydrator.d.ts +1 -0
  48. package/hydration/ObjectHydrator.js +1 -0
  49. package/logging/DefaultLogger.d.ts +3 -0
  50. package/logging/DefaultLogger.js +3 -0
  51. package/logging/Logger.d.ts +5 -0
  52. package/metadata/EntitySchema.d.ts +22 -0
  53. package/metadata/EntitySchema.js +20 -0
  54. package/metadata/MetadataDiscovery.d.ts +4 -0
  55. package/metadata/MetadataDiscovery.js +4 -0
  56. package/metadata/MetadataProvider.d.ts +8 -0
  57. package/metadata/MetadataProvider.js +8 -0
  58. package/metadata/MetadataStorage.d.ts +14 -0
  59. package/metadata/MetadataStorage.js +13 -0
  60. package/naming-strategy/AbstractNamingStrategy.d.ts +1 -0
  61. package/naming-strategy/AbstractNamingStrategy.js +1 -0
  62. package/naming-strategy/MongoNamingStrategy.d.ts +1 -0
  63. package/naming-strategy/MongoNamingStrategy.js +1 -0
  64. package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -0
  65. package/naming-strategy/UnderscoreNamingStrategy.js +1 -0
  66. package/package.json +1 -1
  67. package/platforms/ExceptionConverter.d.ts +1 -0
  68. package/platforms/ExceptionConverter.js +1 -0
  69. package/platforms/Platform.d.ts +65 -0
  70. package/platforms/Platform.js +65 -0
  71. package/serialization/EntitySerializer.d.ts +2 -0
  72. package/serialization/EntitySerializer.js +2 -0
  73. package/serialization/EntityTransformer.d.ts +2 -0
  74. package/serialization/EntityTransformer.js +2 -0
  75. package/serialization/SerializationContext.d.ts +5 -0
  76. package/serialization/SerializationContext.js +5 -0
  77. package/types/ArrayType.d.ts +1 -0
  78. package/types/ArrayType.js +1 -0
  79. package/types/BlobType.d.ts +1 -0
  80. package/types/BlobType.js +1 -0
  81. package/types/BooleanType.d.ts +1 -0
  82. package/types/BooleanType.js +1 -0
  83. package/types/CharacterType.d.ts +1 -0
  84. package/types/CharacterType.js +1 -0
  85. package/types/DateTimeType.d.ts +1 -0
  86. package/types/DateTimeType.js +1 -0
  87. package/types/DateType.d.ts +1 -0
  88. package/types/DateType.js +1 -0
  89. package/types/EnumArrayType.d.ts +1 -0
  90. package/types/EnumArrayType.js +1 -0
  91. package/types/EnumType.d.ts +1 -0
  92. package/types/EnumType.js +1 -0
  93. package/types/FloatType.d.ts +1 -0
  94. package/types/FloatType.js +1 -0
  95. package/types/IntegerType.d.ts +1 -0
  96. package/types/IntegerType.js +1 -0
  97. package/types/IntervalType.d.ts +1 -0
  98. package/types/IntervalType.js +1 -0
  99. package/types/JsonType.d.ts +1 -0
  100. package/types/JsonType.js +1 -0
  101. package/types/MediumIntType.d.ts +1 -0
  102. package/types/MediumIntType.js +1 -0
  103. package/types/SmallIntType.d.ts +1 -0
  104. package/types/SmallIntType.js +1 -0
  105. package/types/StringType.d.ts +1 -0
  106. package/types/StringType.js +1 -0
  107. package/types/TextType.d.ts +1 -0
  108. package/types/TextType.js +1 -0
  109. package/types/TimeType.d.ts +1 -0
  110. package/types/TimeType.js +1 -0
  111. package/types/TinyIntType.d.ts +1 -0
  112. package/types/TinyIntType.js +1 -0
  113. package/types/Type.d.ts +3 -0
  114. package/types/Type.js +1 -0
  115. package/types/Uint8ArrayType.d.ts +1 -0
  116. package/types/Uint8ArrayType.js +1 -0
  117. package/types/UnknownType.d.ts +1 -0
  118. package/types/UnknownType.js +1 -0
  119. package/types/UuidType.d.ts +1 -0
  120. package/types/UuidType.js +1 -0
  121. package/types/index.d.ts +2 -0
  122. package/types/index.js +2 -0
  123. package/typings.d.ts +177 -0
  124. package/typings.js +11 -0
  125. package/unit-of-work/ChangeSet.d.ts +4 -0
  126. package/unit-of-work/ChangeSet.js +4 -0
  127. package/unit-of-work/ChangeSetComputer.d.ts +2 -0
  128. package/unit-of-work/ChangeSetComputer.js +15 -2
  129. package/unit-of-work/ChangeSetPersister.d.ts +4 -0
  130. package/unit-of-work/ChangeSetPersister.js +4 -0
  131. package/unit-of-work/IdentityMap.d.ts +7 -0
  132. package/unit-of-work/IdentityMap.js +7 -0
  133. package/unit-of-work/UnitOfWork.d.ts +15 -0
  134. package/unit-of-work/UnitOfWork.js +15 -0
  135. package/utils/Configuration.d.ts +8 -0
  136. package/utils/Configuration.js +8 -0
  137. package/utils/EntityComparator.d.ts +2 -0
  138. package/utils/EntityComparator.js +2 -0
  139. package/utils/NullHighlighter.d.ts +1 -0
  140. package/utils/NullHighlighter.js +1 -0
  141. package/utils/RawQueryFragment.d.ts +10 -0
  142. package/utils/RawQueryFragment.js +9 -0
  143. package/utils/RequestContext.d.ts +1 -0
  144. package/utils/TransactionContext.d.ts +1 -0
  145. package/utils/TransactionContext.js +1 -0
  146. package/utils/Utils.d.ts +6 -0
  147. package/utils/Utils.js +7 -1
package/enums.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** Controls when the `EntityManager` flushes pending changes to the database. */
1
2
  export var FlushMode;
2
3
  (function (FlushMode) {
3
4
  /** The `EntityManager` delays the flush until the current Transaction is committed. */
@@ -7,84 +8,148 @@ export var FlushMode;
7
8
  /** Flushes the `EntityManager` before every query. */
8
9
  FlushMode["ALWAYS"] = "always";
9
10
  })(FlushMode || (FlushMode = {}));
11
+ /** Controls how populate hints are resolved when using `FindOptions.populateWhere`. */
10
12
  export var PopulateHint;
11
13
  (function (PopulateHint) {
14
+ /** Infer population hints from the `where` condition. */
12
15
  PopulateHint["INFER"] = "infer";
16
+ /** Apply population hints to all relations. */
13
17
  PopulateHint["ALL"] = "all";
14
18
  })(PopulateHint || (PopulateHint = {}));
19
+ /** Special tokens used as populate path values in `FindOptions.populate`. */
15
20
  export var PopulatePath;
16
21
  (function (PopulatePath) {
22
+ /** Infer which relations to populate based on fields accessed in the `where` or `orderBy` clause. */
17
23
  PopulatePath["INFER"] = "$infer";
24
+ /** Populate all relations. */
18
25
  PopulatePath["ALL"] = "*";
19
26
  })(PopulatePath || (PopulatePath = {}));
27
+ /** Logical grouping operators for combining query conditions. */
20
28
  export var GroupOperator;
21
29
  (function (GroupOperator) {
30
+ /** Logical AND — all conditions must match. */
22
31
  GroupOperator["$and"] = "and";
32
+ /** Logical OR — at least one condition must match. */
23
33
  GroupOperator["$or"] = "or";
24
34
  })(GroupOperator || (GroupOperator = {}));
35
+ /** Comparison and filtering operators used in query conditions. */
25
36
  export var QueryOperator;
26
37
  (function (QueryOperator) {
38
+ /** Equal. */
27
39
  QueryOperator["$eq"] = "=";
40
+ /** Included in the given list. */
28
41
  QueryOperator["$in"] = "in";
42
+ /** Not included in the given list. */
29
43
  QueryOperator["$nin"] = "not in";
44
+ /** Greater than. */
30
45
  QueryOperator["$gt"] = ">";
46
+ /** Greater than or equal to. */
31
47
  QueryOperator["$gte"] = ">=";
48
+ /** Less than. */
32
49
  QueryOperator["$lt"] = "<";
50
+ /** Less than or equal to. */
33
51
  QueryOperator["$lte"] = "<=";
52
+ /** Not equal. */
34
53
  QueryOperator["$ne"] = "!=";
54
+ /** Negation wrapper. */
35
55
  QueryOperator["$not"] = "not";
56
+ /** SQL LIKE pattern matching. */
36
57
  QueryOperator["$like"] = "like";
58
+ /** Regular expression matching. */
37
59
  QueryOperator["$re"] = "regexp";
60
+ /** Full-text search. */
38
61
  QueryOperator["$fulltext"] = "fulltext";
62
+ /** Checks that the value is not null (i.e., exists). */
39
63
  QueryOperator["$exists"] = "not null";
64
+ /** Case-insensitive LIKE (PostgreSQL only). */
40
65
  QueryOperator["$ilike"] = "ilike";
66
+ /** Array overlap operator (PostgreSQL only). */
41
67
  QueryOperator["$overlap"] = "&&";
68
+ /** Array/JSON contains operator (PostgreSQL only). */
42
69
  QueryOperator["$contains"] = "@>";
70
+ /** Array/JSON contained-by operator (PostgreSQL only). */
43
71
  QueryOperator["$contained"] = "<@";
72
+ /** No element in the collection matches (SQL only). */
44
73
  QueryOperator["$none"] = "none";
74
+ /** At least one element in the collection matches (SQL only). */
45
75
  QueryOperator["$some"] = "some";
76
+ /** Every element in the collection matches (SQL only). */
46
77
  QueryOperator["$every"] = "every";
78
+ /** Matches collections by their size (SQL only). */
47
79
  QueryOperator["$size"] = "size";
80
+ /** JSON object has the given key (PostgreSQL only). */
48
81
  QueryOperator["$hasKey"] = "?";
82
+ /** JSON object has all of the given keys (PostgreSQL only). */
49
83
  QueryOperator["$hasKeys"] = "?&";
84
+ /** JSON object has at least one of the given keys (PostgreSQL only). */
50
85
  QueryOperator["$hasSomeKeys"] = "?|";
86
+ /** Matches an element inside a JSON array (SQL only). */
51
87
  QueryOperator["$elemMatch"] = "elemMatch";
52
88
  })(QueryOperator || (QueryOperator = {}));
53
89
  export const ARRAY_OPERATORS = ['$eq', '$gt', '$gte', '$lt', '$lte', '$ne', '$overlap', '$contains', '$contained'];
54
90
  export const JSON_KEY_OPERATORS = ['$hasKey', '$hasKeys', '$hasSomeKeys'];
91
+ /** Sort direction for query results. Both upper- and lower-case variants are accepted. */
55
92
  export var QueryOrder;
56
93
  (function (QueryOrder) {
94
+ /** Ascending order. */
57
95
  QueryOrder["ASC"] = "ASC";
96
+ /** Ascending order with nulls sorted last. */
58
97
  QueryOrder["ASC_NULLS_LAST"] = "ASC NULLS LAST";
98
+ /** Ascending order with nulls sorted first. */
59
99
  QueryOrder["ASC_NULLS_FIRST"] = "ASC NULLS FIRST";
100
+ /** Descending order. */
60
101
  QueryOrder["DESC"] = "DESC";
102
+ /** Descending order with nulls sorted last. */
61
103
  QueryOrder["DESC_NULLS_LAST"] = "DESC NULLS LAST";
104
+ /** Descending order with nulls sorted first. */
62
105
  QueryOrder["DESC_NULLS_FIRST"] = "DESC NULLS FIRST";
106
+ /** Ascending order (lower-case variant). */
63
107
  QueryOrder["asc"] = "asc";
108
+ /** Ascending order with nulls sorted last (lower-case variant). */
64
109
  QueryOrder["asc_nulls_last"] = "asc nulls last";
110
+ /** Ascending order with nulls sorted first (lower-case variant). */
65
111
  QueryOrder["asc_nulls_first"] = "asc nulls first";
112
+ /** Descending order (lower-case variant). */
66
113
  QueryOrder["desc"] = "desc";
114
+ /** Descending order with nulls sorted last (lower-case variant). */
67
115
  QueryOrder["desc_nulls_last"] = "desc nulls last";
116
+ /** Descending order with nulls sorted first (lower-case variant). */
68
117
  QueryOrder["desc_nulls_first"] = "desc nulls first";
69
118
  })(QueryOrder || (QueryOrder = {}));
119
+ /** Numeric sort direction, compatible with MongoDB-style ordering. */
70
120
  export var QueryOrderNumeric;
71
121
  (function (QueryOrderNumeric) {
122
+ /** Ascending order. */
72
123
  QueryOrderNumeric[QueryOrderNumeric["ASC"] = 1] = "ASC";
124
+ /** Descending order. */
73
125
  QueryOrderNumeric[QueryOrderNumeric["DESC"] = -1] = "DESC";
74
126
  })(QueryOrderNumeric || (QueryOrderNumeric = {}));
127
+ /** Flags that modify query builder behavior. */
75
128
  export var QueryFlag;
76
129
  (function (QueryFlag) {
130
+ /** Add a DISTINCT clause to the SELECT statement. */
77
131
  QueryFlag["DISTINCT"] = "DISTINCT";
132
+ /** Enable result pagination via a sub-query for the primary keys. */
78
133
  QueryFlag["PAGINATE"] = "PAGINATE";
134
+ /** Disable the automatic pagination sub-query. */
79
135
  QueryFlag["DISABLE_PAGINATE"] = "DISABLE_PAGINATE";
136
+ /** Wrap UPDATE statements in a sub-query. */
80
137
  QueryFlag["UPDATE_SUB_QUERY"] = "UPDATE_SUB_QUERY";
138
+ /** Wrap DELETE statements in a sub-query. */
81
139
  QueryFlag["DELETE_SUB_QUERY"] = "DELETE_SUB_QUERY";
140
+ /** Convert values through custom type mappings when reading results. */
82
141
  QueryFlag["CONVERT_CUSTOM_TYPES"] = "CONVERT_CUSTOM_TYPES";
142
+ /** Include lazy formula properties in the SELECT clause. */
83
143
  QueryFlag["INCLUDE_LAZY_FORMULAS"] = "INCLUDE_LAZY_FORMULAS";
144
+ /** Automatically join the owning side of one-to-one relations. */
84
145
  QueryFlag["AUTO_JOIN_ONE_TO_ONE_OWNER"] = "AUTO_JOIN_ONE_TO_ONE_OWNER";
146
+ /** Infer the populate hint from the query fields. */
85
147
  QueryFlag["INFER_POPULATE"] = "INFER_POPULATE";
148
+ /** Prevent nested conditions from being promoted to INNER JOINs. */
86
149
  QueryFlag["DISABLE_NESTED_INNER_JOIN"] = "DISABLE_NESTED_INNER_JOIN";
150
+ /** Enable IDENTITY_INSERT for explicit PK values (MSSQL only). */
87
151
  QueryFlag["IDENTITY_INSERT"] = "IDENTITY_INSERT";
152
+ /** Use an OUTPUT...INTO temp table for returning rows (MSSQL only). */
88
153
  QueryFlag["OUTPUT_TABLE"] = "OUTPUT_TABLE";
89
154
  })(QueryFlag || (QueryFlag = {}));
90
155
  export const SCALAR_TYPES = new Set([
@@ -97,98 +162,165 @@ export const SCALAR_TYPES = new Set([
97
162
  'Buffer',
98
163
  'RegExp',
99
164
  ]);
165
+ /** Describes the kind of relationship a property represents. */
100
166
  export var ReferenceKind;
101
167
  (function (ReferenceKind) {
168
+ /** A plain scalar property (not a relation). */
102
169
  ReferenceKind["SCALAR"] = "scalar";
170
+ /** A one-to-one relation. */
103
171
  ReferenceKind["ONE_TO_ONE"] = "1:1";
172
+ /** A one-to-many relation (inverse side of a many-to-one). */
104
173
  ReferenceKind["ONE_TO_MANY"] = "1:m";
174
+ /** A many-to-one relation (owning side). */
105
175
  ReferenceKind["MANY_TO_ONE"] = "m:1";
176
+ /** A many-to-many relation. */
106
177
  ReferenceKind["MANY_TO_MANY"] = "m:n";
178
+ /** An embedded entity (inline object stored within the parent). */
107
179
  ReferenceKind["EMBEDDED"] = "embedded";
108
180
  })(ReferenceKind || (ReferenceKind = {}));
181
+ /** Cascade operations that propagate from a parent entity to its relations. */
109
182
  export var Cascade;
110
183
  (function (Cascade) {
184
+ /** Cascade persist — new related entities are automatically persisted. */
111
185
  Cascade["PERSIST"] = "persist";
186
+ /** Cascade merge — detached related entities are merged into the identity map. */
112
187
  Cascade["MERGE"] = "merge";
188
+ /** Cascade remove — removing the parent also removes related entities. */
113
189
  Cascade["REMOVE"] = "remove";
190
+ /** Enable all cascade operations (persist, merge, remove). */
114
191
  Cascade["ALL"] = "all";
115
192
  /** @internal */
116
193
  Cascade["SCHEDULE_ORPHAN_REMOVAL"] = "schedule_orphan_removal";
117
194
  /** @internal */
118
195
  Cascade["CANCEL_ORPHAN_REMOVAL"] = "cancel_orphan_removal";
119
196
  })(Cascade || (Cascade = {}));
197
+ /** Strategy used to load related entities when populating. */
120
198
  export var LoadStrategy;
121
199
  (function (LoadStrategy) {
200
+ /** Load relations with a separate SELECT ... WHERE pk IN (...) query. */
122
201
  LoadStrategy["SELECT_IN"] = "select-in";
202
+ /** Load relations via SQL JOINs in a single query. */
123
203
  LoadStrategy["JOINED"] = "joined";
204
+ /** Use joined strategy for to-one relations and select-in for to-many. */
124
205
  LoadStrategy["BALANCED"] = "balanced";
125
206
  })(LoadStrategy || (LoadStrategy = {}));
207
+ /** Controls which relation types use the dataloader for batched loading. */
126
208
  export var DataloaderType;
127
209
  (function (DataloaderType) {
210
+ /** Dataloader is disabled. */
128
211
  DataloaderType[DataloaderType["NONE"] = 0] = "NONE";
212
+ /** Use the dataloader for Reference (to-one) relations only. */
129
213
  DataloaderType[DataloaderType["REFERENCE"] = 1] = "REFERENCE";
214
+ /** Use the dataloader for Collection (to-many) relations only. */
130
215
  DataloaderType[DataloaderType["COLLECTION"] = 2] = "COLLECTION";
216
+ /** Use the dataloader for both Reference and Collection relations. */
131
217
  DataloaderType[DataloaderType["ALL"] = 3] = "ALL";
132
218
  })(DataloaderType || (DataloaderType = {}));
219
+ /** Locking strategy for concurrency control. */
133
220
  export var LockMode;
134
221
  (function (LockMode) {
222
+ /** No locking. */
135
223
  LockMode[LockMode["NONE"] = 0] = "NONE";
224
+ /** Optimistic locking via a version column. */
136
225
  LockMode[LockMode["OPTIMISTIC"] = 1] = "OPTIMISTIC";
226
+ /** Pessimistic shared lock (FOR SHARE). */
137
227
  LockMode[LockMode["PESSIMISTIC_READ"] = 2] = "PESSIMISTIC_READ";
228
+ /** Pessimistic exclusive lock (FOR UPDATE). */
138
229
  LockMode[LockMode["PESSIMISTIC_WRITE"] = 3] = "PESSIMISTIC_WRITE";
230
+ /** Pessimistic exclusive lock that skips already-locked rows (FOR UPDATE SKIP LOCKED). */
139
231
  LockMode[LockMode["PESSIMISTIC_PARTIAL_WRITE"] = 4] = "PESSIMISTIC_PARTIAL_WRITE";
232
+ /** Pessimistic exclusive lock that fails immediately if the row is locked (FOR UPDATE NOWAIT). */
140
233
  LockMode[LockMode["PESSIMISTIC_WRITE_OR_FAIL"] = 5] = "PESSIMISTIC_WRITE_OR_FAIL";
234
+ /** Pessimistic shared lock that skips already-locked rows (FOR SHARE SKIP LOCKED). */
141
235
  LockMode[LockMode["PESSIMISTIC_PARTIAL_READ"] = 6] = "PESSIMISTIC_PARTIAL_READ";
236
+ /** Pessimistic shared lock that fails immediately if the row is locked (FOR SHARE NOWAIT). */
142
237
  LockMode[LockMode["PESSIMISTIC_READ_OR_FAIL"] = 7] = "PESSIMISTIC_READ_OR_FAIL";
143
238
  })(LockMode || (LockMode = {}));
239
+ /** Transaction isolation levels as defined by the SQL standard (plus vendor extensions). */
144
240
  export var IsolationLevel;
145
241
  (function (IsolationLevel) {
242
+ /** Allows dirty reads, non-repeatable reads, and phantom reads. */
146
243
  IsolationLevel["READ_UNCOMMITTED"] = "read uncommitted";
244
+ /** Prevents dirty reads; non-repeatable and phantom reads are still possible. */
147
245
  IsolationLevel["READ_COMMITTED"] = "read committed";
246
+ /** Snapshot isolation — each transaction sees a consistent snapshot of the database (MSSQL). */
148
247
  IsolationLevel["SNAPSHOT"] = "snapshot";
248
+ /** Prevents dirty and non-repeatable reads; phantom reads are still possible. */
149
249
  IsolationLevel["REPEATABLE_READ"] = "repeatable read";
250
+ /** Full isolation — transactions are executed as if they were run sequentially. */
150
251
  IsolationLevel["SERIALIZABLE"] = "serializable";
151
252
  })(IsolationLevel || (IsolationLevel = {}));
253
+ /** Lifecycle and transaction events emitted by the ORM. */
152
254
  export var EventType;
153
255
  (function (EventType) {
256
+ /** Fired when an entity instance is created (via constructor or `em.create`). */
154
257
  EventType["onInit"] = "onInit";
258
+ /** Fired after an entity is loaded from the database. */
155
259
  EventType["onLoad"] = "onLoad";
260
+ /** Fired before a new entity is inserted into the database. */
156
261
  EventType["beforeCreate"] = "beforeCreate";
262
+ /** Fired after a new entity has been inserted into the database. */
157
263
  EventType["afterCreate"] = "afterCreate";
264
+ /** Fired before an existing entity is updated in the database. */
158
265
  EventType["beforeUpdate"] = "beforeUpdate";
266
+ /** Fired after an existing entity has been updated in the database. */
159
267
  EventType["afterUpdate"] = "afterUpdate";
268
+ /** Fired before an upsert operation. */
160
269
  EventType["beforeUpsert"] = "beforeUpsert";
270
+ /** Fired after an upsert operation. */
161
271
  EventType["afterUpsert"] = "afterUpsert";
272
+ /** Fired before an entity is deleted from the database. */
162
273
  EventType["beforeDelete"] = "beforeDelete";
274
+ /** Fired after an entity has been deleted from the database. */
163
275
  EventType["afterDelete"] = "afterDelete";
276
+ /** Fired at the very beginning of `em.flush()`, before change detection. */
164
277
  EventType["beforeFlush"] = "beforeFlush";
278
+ /** Fired during `em.flush()` after change detection but before database writes. */
165
279
  EventType["onFlush"] = "onFlush";
280
+ /** Fired after `em.flush()` has completed all database writes. */
166
281
  EventType["afterFlush"] = "afterFlush";
282
+ /** Fired before a new database transaction is started. */
167
283
  EventType["beforeTransactionStart"] = "beforeTransactionStart";
284
+ /** Fired after a new database transaction has been started. */
168
285
  EventType["afterTransactionStart"] = "afterTransactionStart";
286
+ /** Fired before a database transaction is committed. */
169
287
  EventType["beforeTransactionCommit"] = "beforeTransactionCommit";
288
+ /** Fired after a database transaction has been committed. */
170
289
  EventType["afterTransactionCommit"] = "afterTransactionCommit";
290
+ /** Fired before a database transaction is rolled back. */
171
291
  EventType["beforeTransactionRollback"] = "beforeTransactionRollback";
292
+ /** Fired after a database transaction has been rolled back. */
172
293
  EventType["afterTransactionRollback"] = "afterTransactionRollback";
173
294
  })(EventType || (EventType = {}));
174
295
  export const EventTypeMap = Object.keys(EventType).reduce((a, b, i) => {
175
296
  a[b] = i;
176
297
  return a;
177
298
  }, {});
299
+ /** Controls how a transactional operation interacts with an existing transaction. */
178
300
  export var TransactionPropagation;
179
301
  (function (TransactionPropagation) {
302
+ /** Join the current transaction or create a new one if none exists. */
180
303
  TransactionPropagation["REQUIRED"] = "required";
304
+ /** Always create a new transaction, suspending the current one if it exists. */
181
305
  TransactionPropagation["REQUIRES_NEW"] = "requires_new";
306
+ /** Create a nested savepoint within the current transaction, or a new transaction if none exists. */
182
307
  TransactionPropagation["NESTED"] = "nested";
308
+ /** Execute non-transactionally, suspending the current transaction if one exists. */
183
309
  TransactionPropagation["NOT_SUPPORTED"] = "not_supported";
310
+ /** Join the current transaction if one exists, otherwise execute non-transactionally. */
184
311
  TransactionPropagation["SUPPORTS"] = "supports";
312
+ /** Join the current transaction; throw if no transaction is active. */
185
313
  TransactionPropagation["MANDATORY"] = "mandatory";
314
+ /** Execute non-transactionally; throw if a transaction is active. */
186
315
  TransactionPropagation["NEVER"] = "never";
187
316
  })(TransactionPropagation || (TransactionPropagation = {}));
188
317
  export class PlainObject {
189
318
  }
319
+ /** Constraint deferral mode for database constraints (e.g., foreign keys, unique). */
190
320
  export var DeferMode;
191
321
  (function (DeferMode) {
322
+ /** The constraint is checked immediately by default, but can be deferred within a transaction. */
192
323
  DeferMode["INITIALLY_IMMEDIATE"] = "immediate";
324
+ /** The constraint is deferred until the transaction is committed. */
193
325
  DeferMode["INITIALLY_DEFERRED"] = "deferred";
194
326
  })(DeferMode || (DeferMode = {}));
package/errors.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AnyEntity, Constructor, Dictionary, EntityMetadata, EntityName, EntityProperty, IPrimaryKey } from './typings.js';
2
+ /** Base error class for ORM validation errors such as invalid entity state or incorrect usage. */
2
3
  export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Error {
3
4
  readonly entity?: T | undefined;
4
5
  constructor(message: string, entity?: T | undefined);
@@ -29,15 +30,18 @@ export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Er
29
30
  static invalidEmbeddableQuery(entityName: EntityName, propName: string, embeddableType: string): ValidationError;
30
31
  static invalidQueryCondition(cond: unknown): ValidationError;
31
32
  }
33
+ /** Error thrown when cursor-based pagination encounters missing or invalid cursor values. */
32
34
  export declare class CursorError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
33
35
  static entityNotPopulated(entity: AnyEntity, prop: string): ValidationError;
34
36
  static missingValue(entityName: string, prop: string): ValidationError;
35
37
  }
38
+ /** Error thrown when an optimistic lock conflict is detected during entity persistence. */
36
39
  export declare class OptimisticLockError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
37
40
  static notVersioned(meta: EntityMetadata): OptimisticLockError;
38
41
  static lockFailed(entityOrName: AnyEntity | string): OptimisticLockError;
39
42
  static lockFailedVersionMismatch(entity: AnyEntity, expectedLockVersion: number | Date, actualLockVersion: number | Date): OptimisticLockError;
40
43
  }
44
+ /** Error thrown when entity metadata is invalid, incomplete, or inconsistent. */
41
45
  export declare class MetadataError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
42
46
  static fromMissingPrimaryKey(meta: EntityMetadata): MetadataError;
43
47
  static fromWrongReference(meta: EntityMetadata, prop: EntityProperty, key: 'inversedBy' | 'mappedBy', owner?: EntityProperty): MetadataError;
@@ -72,11 +76,13 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
72
76
  static tptNotSupportedByDriver(meta: EntityMetadata): MetadataError;
73
77
  private static fromMessage;
74
78
  }
79
+ /** Error thrown when an entity lookup fails to find the expected result. */
75
80
  export declare class NotFoundError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
76
81
  static findOneFailed(name: string, where: Dictionary | IPrimaryKey): NotFoundError;
77
82
  static findExactlyOneFailed(name: string, where: Dictionary | IPrimaryKey): NotFoundError;
78
83
  static failedToLoadProperty(name: string, propName: string, where: unknown): NotFoundError;
79
84
  }
85
+ /** Error thrown when a transaction propagation requirement is not satisfied. */
80
86
  export declare class TransactionStateError extends ValidationError {
81
87
  static requiredTransactionNotFound(propagation: string): TransactionStateError;
82
88
  static transactionNotAllowed(propagation: string): TransactionStateError;
package/errors.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { inspect } from './logging/inspect.js';
2
2
  import { Utils } from './utils/Utils.js';
3
+ /** Base error class for ORM validation errors such as invalid entity state or incorrect usage. */
3
4
  export class ValidationError extends Error {
4
5
  entity;
5
6
  constructor(message, entity) {
@@ -107,6 +108,7 @@ export class ValidationError extends Error {
107
108
  return new ValidationError(`Invalid query condition: ${inspect(cond, { depth: 5 })}`);
108
109
  }
109
110
  }
111
+ /** Error thrown when cursor-based pagination encounters missing or invalid cursor values. */
110
112
  export class CursorError extends ValidationError {
111
113
  static entityNotPopulated(entity, prop) {
112
114
  return new CursorError(`Cannot create cursor, value for '${entity.constructor.name}.${prop}' is missing.`);
@@ -115,6 +117,7 @@ export class CursorError extends ValidationError {
115
117
  return new CursorError(`Invalid cursor condition, value for '${entityName}.${prop}' is missing.`);
116
118
  }
117
119
  }
120
+ /** Error thrown when an optimistic lock conflict is detected during entity persistence. */
118
121
  export class OptimisticLockError extends ValidationError {
119
122
  static notVersioned(meta) {
120
123
  return new OptimisticLockError(`Cannot obtain optimistic lock on unversioned entity ${meta.className}`);
@@ -130,6 +133,7 @@ export class OptimisticLockError extends ValidationError {
130
133
  return new OptimisticLockError(`The optimistic lock failed, version ${expectedLockVersion} was expected, but is actually ${actualLockVersion}`, entity);
131
134
  }
132
135
  }
136
+ /** Error thrown when entity metadata is invalid, incomplete, or inconsistent. */
133
137
  export class MetadataError extends ValidationError {
134
138
  static fromMissingPrimaryKey(meta) {
135
139
  return new MetadataError(`${meta.className} entity is missing @PrimaryKey()`);
@@ -243,6 +247,7 @@ export class MetadataError extends ValidationError {
243
247
  return new MetadataError(`${meta.className}.${prop.name} ${message}`);
244
248
  }
245
249
  }
250
+ /** Error thrown when an entity lookup fails to find the expected result. */
246
251
  export class NotFoundError extends ValidationError {
247
252
  static findOneFailed(name, where) {
248
253
  return new NotFoundError(`${name} not found (${inspect(where)})`);
@@ -255,6 +260,7 @@ export class NotFoundError extends ValidationError {
255
260
  return new NotFoundError(`${name} (${whereString}) failed to load property '${propName}'`);
256
261
  }
257
262
  }
263
+ /** Error thrown when a transaction propagation requirement is not satisfied. */
258
264
  export class TransactionStateError extends ValidationError {
259
265
  static requiredTransactionNotFound(propagation) {
260
266
  return new TransactionStateError(`No existing transaction found for transaction marked with propagation "${propagation}"`);
@@ -1,15 +1,20 @@
1
1
  import type { EntityMetadata } from '../typings.js';
2
2
  import type { EventArgs, EventSubscriber, FlushEventArgs, TransactionEventArgs } from './EventSubscriber.js';
3
3
  import { EventType, type TransactionEventType } from '../enums.js';
4
+ /** Manages event subscribers and dispatches entity/flush/transaction lifecycle events. */
4
5
  export declare class EventManager {
5
6
  #private;
6
7
  constructor(subscribers: Iterable<EventSubscriber>);
8
+ /** Registers an event subscriber and indexes its subscribed entities and event types. */
7
9
  registerSubscriber(subscriber: EventSubscriber): void;
10
+ /** Returns the set of all registered event subscribers. */
8
11
  getSubscribers(): Set<EventSubscriber>;
9
12
  dispatchEvent<T extends object>(event: TransactionEventType, args: TransactionEventArgs, meta?: EntityMetadata<T>): unknown;
10
13
  dispatchEvent<T extends object>(event: EventType.onInit, args: Partial<EventArgs<T>>, meta?: EntityMetadata<T>): unknown;
11
14
  dispatchEvent<T extends object>(event: EventType, args: Partial<EventArgs<T> | FlushEventArgs>, meta?: EntityMetadata<T>): Promise<unknown>;
15
+ /** Checks whether there are any listeners (hooks or subscribers) for the given event type and entity. */
12
16
  hasListeners<T>(event: EventType, meta: EntityMetadata<T>): boolean;
17
+ /** Creates a new EventManager with the same set of subscribers. */
13
18
  clone(): EventManager;
14
19
  private getSubscribedEntities;
15
20
  }
@@ -1,5 +1,6 @@
1
1
  import { Utils } from '../utils/Utils.js';
2
2
  import { EventType, EventTypeMap } from '../enums.js';
3
+ /** Manages event subscribers and dispatches entity/flush/transaction lifecycle events. */
3
4
  export class EventManager {
4
5
  #listeners = {};
5
6
  #entities = new Map();
@@ -10,6 +11,7 @@ export class EventManager {
10
11
  this.registerSubscriber(subscriber);
11
12
  }
12
13
  }
14
+ /** Registers an event subscriber and indexes its subscribed entities and event types. */
13
15
  registerSubscriber(subscriber) {
14
16
  if (this.#subscribers.has(subscriber)) {
15
17
  return;
@@ -24,6 +26,7 @@ export class EventManager {
24
26
  this.#listeners[event].add(subscriber);
25
27
  });
26
28
  }
29
+ /** Returns the set of all registered event subscribers. */
27
30
  getSubscribers() {
28
31
  return this.#subscribers;
29
32
  }
@@ -52,6 +55,7 @@ export class EventManager {
52
55
  }
53
56
  return Utils.runSerial(listeners, listener => listener(args));
54
57
  }
58
+ /** Checks whether there are any listeners (hooks or subscribers) for the given event type and entity. */
55
59
  hasListeners(event, meta) {
56
60
  const cacheKey = meta._id + EventTypeMap[event];
57
61
  if (this.#cache.has(cacheKey)) {
@@ -72,6 +76,7 @@ export class EventManager {
72
76
  this.#cache.set(cacheKey, false);
73
77
  return false;
74
78
  }
79
+ /** Creates a new EventManager with the same set of subscribers. */
75
80
  clone() {
76
81
  return new EventManager(this.#subscribers);
77
82
  }
@@ -3,21 +3,25 @@ import type { EntityManager } from '../EntityManager.js';
3
3
  import type { UnitOfWork } from '../unit-of-work/UnitOfWork.js';
4
4
  import type { ChangeSet } from '../unit-of-work/ChangeSet.js';
5
5
  import type { Transaction } from '../connections/Connection.js';
6
+ /** Arguments passed to entity lifecycle event hooks. */
6
7
  export interface EventArgs<T> {
7
8
  entity: T;
8
9
  em: EntityManager;
9
10
  meta: EntityMetadata<T>;
10
11
  changeSet?: ChangeSet<T & {}>;
11
12
  }
13
+ /** Arguments passed to flush lifecycle event hooks (beforeFlush, onFlush, afterFlush). */
12
14
  export interface FlushEventArgs extends Omit<EventArgs<any>, 'entity' | 'changeSet' | 'meta'> {
13
15
  uow: UnitOfWork;
14
16
  }
17
+ /** Arguments passed to transaction lifecycle event hooks (start, commit, rollback). */
15
18
  export interface TransactionEventArgs extends Omit<EventArgs<any>, 'entity' | 'meta' | 'changeSet'> {
16
19
  transaction?: Transaction & {
17
20
  savepointName?: string;
18
21
  };
19
22
  uow?: UnitOfWork;
20
23
  }
24
+ /** Interface for subscribing to entity and transaction lifecycle events. */
21
25
  export interface EventSubscriber<T = any> {
22
26
  getSubscribedEntities?(): EntityName<T>[];
23
27
  onInit?(args: EventArgs<T>): void;
@@ -1,6 +1,7 @@
1
1
  import type { Transaction } from '../connections/Connection.js';
2
2
  import type { EntityManager } from '../EntityManager.js';
3
3
  import type { TransactionEventType } from '../enums.js';
4
+ /** Broadcasts transaction lifecycle events (start, commit, rollback) through the EventManager. */
4
5
  export declare class TransactionEventBroadcaster {
5
6
  private readonly em;
6
7
  readonly context?: {
@@ -9,5 +10,6 @@ export declare class TransactionEventBroadcaster {
9
10
  constructor(em: EntityManager, context?: {
10
11
  topLevelTransaction?: boolean;
11
12
  } | undefined);
13
+ /** Dispatches a transaction lifecycle event to the EventManager. */
12
14
  dispatchEvent(event: TransactionEventType, transaction?: Transaction): Promise<void>;
13
15
  }
@@ -1,3 +1,4 @@
1
+ /** Broadcasts transaction lifecycle events (start, commit, rollback) through the EventManager. */
1
2
  export class TransactionEventBroadcaster {
2
3
  em;
3
4
  context;
@@ -5,6 +6,7 @@ export class TransactionEventBroadcaster {
5
6
  this.em = em;
6
7
  this.context = context;
7
8
  }
9
+ /** Dispatches a transaction lifecycle event to the EventManager. */
8
10
  async dispatchEvent(event, transaction) {
9
11
  await this.em.getEventManager().dispatchEvent(event, {
10
12
  em: this.em,
@@ -3,6 +3,7 @@ import type { EntityFactory } from '../entity/EntityFactory.js';
3
3
  import type { Platform } from '../platforms/Platform.js';
4
4
  import type { MetadataStorage } from '../metadata/MetadataStorage.js';
5
5
  import type { Configuration } from '../utils/Configuration.js';
6
+ /** Abstract base class for hydrating entity instances from raw database data. */
6
7
  export declare abstract class Hydrator implements IHydrator {
7
8
  protected readonly metadata: MetadataStorage;
8
9
  protected readonly platform: Platform;
@@ -17,6 +18,7 @@ export declare abstract class Hydrator implements IHydrator {
17
18
  * @inheritDoc
18
19
  */
19
20
  hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
21
+ /** Returns whether the hydrator is currently in the middle of hydrating an entity. */
20
22
  isRunning(): boolean;
21
23
  protected getProperties<T extends object>(meta: EntityMetadata<T>, type: 'full' | 'reference'): EntityProperty<T>[];
22
24
  protected hydrateProperty<T extends object>(entity: T, prop: EntityProperty<T>, data: EntityData<T>, factory: EntityFactory, newEntity?: boolean, convertCustomTypes?: boolean): void;
@@ -1,3 +1,4 @@
1
+ /** Abstract base class for hydrating entity instances from raw database data. */
1
2
  /* v8 ignore next */
2
3
  export class Hydrator {
3
4
  metadata;
@@ -32,6 +33,7 @@ export class Hydrator {
32
33
  });
33
34
  this.running = false;
34
35
  }
36
+ /** Returns whether the hydrator is currently in the middle of hydrating an entity. */
35
37
  isRunning() {
36
38
  return this.running;
37
39
  }
@@ -2,6 +2,7 @@ import type { EntityData, EntityMetadata } from '../typings.js';
2
2
  import { Hydrator } from './Hydrator.js';
3
3
  import type { EntityFactory } from '../entity/EntityFactory.js';
4
4
  type EntityHydrator<T extends object> = (entity: T, data: EntityData<T>, factory: EntityFactory, newEntity: boolean, convertCustomTypes: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean) => void;
5
+ /** @internal JIT-compiled hydrator that converts raw database rows into entity instances with optimized generated code. */
5
6
  export declare class ObjectHydrator extends Hydrator {
6
7
  #private;
7
8
  /**
@@ -6,6 +6,7 @@ import { parseJsonSafe, Utils } from '../utils/Utils.js';
6
6
  import { ReferenceKind } from '../enums.js';
7
7
  import { Raw } from '../utils/RawQueryFragment.js';
8
8
  import { ValidationError } from '../errors.js';
9
+ /** @internal JIT-compiled hydrator that converts raw database rows into entity instances with optimized generated code. */
9
10
  export class ObjectHydrator extends Hydrator {
10
11
  #hydrators = {
11
12
  'full~true': new Map(),
@@ -1,4 +1,5 @@
1
1
  import type { Logger, LoggerNamespace, LogContext, LoggerOptions } from './Logger.js';
2
+ /** Default logger implementation with colored output, query formatting, and namespace-based filtering. */
2
3
  export declare class DefaultLogger implements Logger {
3
4
  private readonly options;
4
5
  debugMode: boolean | LoggerNamespace[];
@@ -22,6 +23,7 @@ export declare class DefaultLogger implements Logger {
22
23
  * @inheritDoc
23
24
  */
24
25
  setDebugMode(debugMode: boolean | LoggerNamespace[]): void;
26
+ /** Checks whether logging is enabled for the given namespace, considering context overrides. */
25
27
  isEnabled(namespace: LoggerNamespace, context?: LogContext): boolean;
26
28
  /**
27
29
  * @inheritDoc
@@ -29,5 +31,6 @@ export declare class DefaultLogger implements Logger {
29
31
  logQuery(context: {
30
32
  query: string;
31
33
  } & LogContext): void;
34
+ /** Factory method for creating a new DefaultLogger instance. */
32
35
  static create(this: void, options: LoggerOptions): DefaultLogger;
33
36
  }
@@ -1,4 +1,5 @@
1
1
  import { colors } from './colors.js';
2
+ /** Default logger implementation with colored output, query formatting, and namespace-based filtering. */
2
3
  export class DefaultLogger {
3
4
  options;
4
5
  debugMode;
@@ -50,6 +51,7 @@ export class DefaultLogger {
50
51
  setDebugMode(debugMode) {
51
52
  this.debugMode = debugMode;
52
53
  }
54
+ /** Checks whether logging is enabled for the given namespace, considering context overrides. */
53
55
  isEnabled(namespace, context) {
54
56
  if (context?.enabled !== undefined) {
55
57
  return context.enabled;
@@ -89,6 +91,7 @@ export class DefaultLogger {
89
91
  }
90
92
  return this.log(namespace, msg, context);
91
93
  }
94
+ /** Factory method for creating a new DefaultLogger instance. */
92
95
  static create(options) {
93
96
  return new DefaultLogger(options);
94
97
  }
@@ -1,4 +1,5 @@
1
1
  import type { AnyString, Dictionary, Highlighter } from '../typings.js';
2
+ /** Interface for ORM logging, supporting namespaced log levels and query logging. */
2
3
  export interface Logger {
3
4
  /**
4
5
  * Logs a message inside given namespace.
@@ -20,9 +21,12 @@ export interface Logger {
20
21
  * Sets active namespaces. Pass `true` to enable all logging.
21
22
  */
22
23
  setDebugMode(debugMode: boolean | LoggerNamespace[]): void;
24
+ /** Checks whether logging is enabled for the given namespace. */
23
25
  isEnabled(namespace: LoggerNamespace, context?: LogContext): boolean;
24
26
  }
27
+ /** Available logging namespaces that can be individually enabled or disabled. */
25
28
  export type LoggerNamespace = 'query' | 'query-params' | 'schema' | 'discovery' | 'info' | 'deprecated' | 'slow-query';
29
+ /** Contextual metadata passed alongside log messages, including query details and timing. */
26
30
  export interface LogContext extends Dictionary {
27
31
  query?: string;
28
32
  label?: string;
@@ -39,6 +43,7 @@ export interface LogContext extends Dictionary {
39
43
  name?: string;
40
44
  };
41
45
  }
46
+ /** Options for constructing a Logger instance. */
42
47
  export interface LoggerOptions {
43
48
  writer: (message: string) => void;
44
49
  debugMode?: boolean | LoggerNamespace[];