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

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 +6 -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 +2 -0
  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
@@ -9,27 +9,39 @@ import { Type } from '../types/index.js';
9
9
  import type { MikroORM } from '../MikroORM.js';
10
10
  import type { TransformContext } from '../types/Type.js';
11
11
  import { Raw } from '../utils/RawQueryFragment.js';
12
+ /** Symbol used to tag cloned embeddable data for JSON serialization handling. */
12
13
  export declare const JsonProperty: unique symbol;
14
+ /** Abstract base class providing database-specific behavior and SQL dialect differences. */
13
15
  export declare abstract class Platform {
14
16
  protected readonly exceptionConverter: ExceptionConverter;
15
17
  protected config: Configuration;
16
18
  protected namingStrategy: NamingStrategy;
17
19
  protected timezone?: string;
20
+ /** Whether this driver uses pivot tables for M:N relations (SQL drivers do, MongoDB does not). */
18
21
  usesPivotTable(): boolean;
22
+ /** Whether this driver supports database transactions. */
19
23
  supportsTransactions(): boolean;
24
+ /** Whether the driver wraps operations in implicit transactions by default. */
20
25
  usesImplicitTransactions(): boolean;
26
+ /** Returns the default naming strategy constructor for this platform. */
21
27
  getNamingStrategy(): {
22
28
  new (): NamingStrategy;
23
29
  };
30
+ /** Whether the driver supports RETURNING clause (e.g. PostgreSQL). */
24
31
  usesReturningStatement(): boolean;
32
+ /** Whether the driver supports OUTPUT clause (e.g. MSSQL). */
25
33
  usesOutputStatement(): boolean;
34
+ /** Whether DELETE statements require explicit CASCADE keyword. */
26
35
  usesCascadeStatement(): boolean;
27
36
  /** for postgres native enums */
28
37
  supportsNativeEnums(): boolean;
29
38
  /** for postgres text enums (default) */
30
39
  usesEnumCheckConstraints(): boolean;
40
+ /** Whether this platform supports materialized views. */
31
41
  supportsMaterializedViews(): boolean;
42
+ /** Returns the schema helper instance for this platform, or undefined if not supported. */
32
43
  getSchemaHelper(): unknown;
44
+ /** Whether the platform automatically creates indexes on foreign key columns. */
33
45
  indexForeignKeys(): boolean;
34
46
  /**
35
47
  * Whether or not the driver supports retuning list of created PKs back when multi-inserting
@@ -39,6 +51,7 @@ export declare abstract class Platform {
39
51
  * Whether or not the driver supports updating many records at once
40
52
  */
41
53
  usesBatchUpdates(): boolean;
54
+ /** Whether the platform supports the DEFAULT keyword in INSERT statements. */
42
55
  usesDefaultKeyword(): boolean;
43
56
  /**
44
57
  * Normalizes primary key wrapper to scalar value (e.g. mongodb's ObjectId to string)
@@ -52,15 +65,23 @@ export declare abstract class Platform {
52
65
  * Returns the SQL specific for the platform to get the current timestamp
53
66
  */
54
67
  getCurrentTimestampSQL(length?: number): string;
68
+ /** Returns the SQL type declaration for datetime columns. */
55
69
  getDateTimeTypeDeclarationSQL(column: {
56
70
  length?: number;
57
71
  }): string;
72
+ /** Returns the default fractional seconds precision for datetime columns. */
58
73
  getDefaultDateTimeLength(): number;
74
+ /** Returns the default length for varchar columns. */
59
75
  getDefaultVarcharLength(): number;
76
+ /** Returns the default length for char columns. */
60
77
  getDefaultCharLength(): number;
78
+ /** Returns the SQL type declaration for date columns. */
61
79
  getDateTypeDeclarationSQL(length?: number): string;
80
+ /** Returns the SQL type declaration for time columns. */
62
81
  getTimeTypeDeclarationSQL(length?: number): string;
82
+ /** Returns the SQL operator used for regular expression matching. */
63
83
  getRegExpOperator(val?: unknown, flags?: string): string;
84
+ /** Builds the SQL clause and parameters for a regular expression condition. */
64
85
  mapRegExpCondition(mappedKey: string, value: {
65
86
  $re: string;
66
87
  $flags?: string;
@@ -68,19 +89,28 @@ export declare abstract class Platform {
68
89
  sql: string;
69
90
  params: unknown[];
70
91
  };
92
+ /** Converts a JavaScript RegExp into a platform-specific regex representation. */
71
93
  getRegExpValue(val: RegExp): {
72
94
  $re: string;
73
95
  $flags?: string;
74
96
  };
97
+ /** Whether the given operator is allowed at the top level of a query condition. */
75
98
  isAllowedTopLevelOperator(operator: string): boolean;
99
+ /** Converts a version field value for comparison in optimistic locking queries. */
76
100
  convertVersionValue(value: Date | number, prop: EntityProperty): Date | string | number | {
77
101
  $in: (string | number)[];
78
102
  };
103
+ /** Returns the default fractional seconds precision for version timestamp columns. */
79
104
  getDefaultVersionLength(): number;
105
+ /** Whether the platform supports tuple comparison in WHERE clauses. */
80
106
  allowsComparingTuples(): boolean;
107
+ /** Whether the given property maps to a bigint database column. */
81
108
  isBigIntProperty(prop: EntityProperty): boolean;
109
+ /** Returns the default schema name for this platform (e.g. "public" for PostgreSQL). */
82
110
  getDefaultSchemaName(): string | undefined;
111
+ /** Returns the SQL type declaration for boolean columns. */
83
112
  getBooleanTypeDeclarationSQL(): string;
113
+ /** Returns the SQL type declaration for integer columns. */
84
114
  getIntegerTypeDeclarationSQL(column: {
85
115
  length?: number;
86
116
  unsigned?: boolean;
@@ -134,6 +164,7 @@ export declare abstract class Platform {
134
164
  getUuidTypeDeclarationSQL(column: {
135
165
  length?: number;
136
166
  }): string;
167
+ /** Extracts the base type name from a full SQL type declaration (e.g. "varchar(255)" -> "varchar"). */
137
168
  extractSimpleType(type: string): string;
138
169
  /**
139
170
  * This should be used only to compare types, it can strip some information like the length.
@@ -143,18 +174,26 @@ export declare abstract class Platform {
143
174
  precision?: number;
144
175
  scale?: number;
145
176
  }): string;
177
+ /** Returns the mapped Type instance for a given SQL/runtime type string. */
146
178
  getMappedType(type: string): Type<unknown>;
179
+ /** Returns the default mapped Type for a given type string when no custom mapping is configured. */
147
180
  getDefaultMappedType(type: string): Type<unknown>;
181
+ /** Whether the platform supports multiple cascade paths to the same table. */
148
182
  supportsMultipleCascadePaths(): boolean;
149
183
  /**
150
184
  * Returns true if the platform supports ON UPDATE foreign key rules.
151
185
  * Oracle doesn't support ON UPDATE rules.
152
186
  */
153
187
  supportsOnUpdate(): boolean;
188
+ /** Whether the connection supports executing multiple SQL statements in a single call. */
154
189
  supportsMultipleStatements(): boolean;
190
+ /** Whether the platform supports the UNION WHERE optimization for multi-branch queries. */
155
191
  supportsUnionWhere(): boolean;
192
+ /** Returns the SQL type declaration used for array storage. */
156
193
  getArrayDeclarationSQL(): string;
194
+ /** Serializes a string array into its database storage format. */
157
195
  marshallArray(values: string[]): string;
196
+ /** Deserializes a database-stored array string back into a string array. */
158
197
  unmarshallArray(value: string): string[];
159
198
  getBlobDeclarationSQL(): string;
160
199
  getJsonDeclarationSQL(): string;
@@ -168,8 +207,11 @@ export declare abstract class Platform {
168
207
  getFullTextWhereClause(prop: EntityProperty): string;
169
208
  supportsCreatingFullTextIndex(): boolean;
170
209
  getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
210
+ /** Whether the driver automatically parses JSON columns into JS objects. */
171
211
  convertsJsonAutomatically(): boolean;
212
+ /** Converts a JS value to its JSON database representation (typically JSON.stringify). */
172
213
  convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
214
+ /** Converts a database JSON value to its JS representation. */
173
215
  convertJsonToJSValue(value: unknown, context?: TransformContext): unknown;
174
216
  convertDateToJSValue(value: string | Date): string;
175
217
  convertIntervalToJSValue(value: string): unknown;
@@ -182,9 +224,13 @@ export declare abstract class Platform {
182
224
  compareUuids(): string;
183
225
  convertUuidToJSValue(value: unknown): unknown;
184
226
  convertUuidToDatabaseValue(value: unknown): unknown;
227
+ /** Parses a string or numeric value into a Date object. */
185
228
  parseDate(value: string | number): Date;
229
+ /** Returns the default EntityRepository class used by this platform. */
186
230
  getRepositoryClass<T extends object>(): Constructor<EntityRepository<T>>;
231
+ /** Returns the default character set for this platform. */
187
232
  getDefaultCharset(): string;
233
+ /** Returns the exception converter for translating native errors to driver exceptions. */
188
234
  getExceptionConverter(): ExceptionConverter;
189
235
  /**
190
236
  * Allows registering extensions of the driver automatically (e.g. `SchemaGenerator` extension in SQL drivers).
@@ -192,35 +238,54 @@ export declare abstract class Platform {
192
238
  lookupExtensions(orm: MikroORM): void;
193
239
  /** @internal */
194
240
  init(orm: MikroORM): void;
241
+ /** Retrieves a registered extension (e.g. SchemaGenerator, Migrator), throwing if not found. */
195
242
  getExtension<T>(extensionName: string, extensionKey: string, moduleName: string, em: EntityManager): T;
196
243
  getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): ISchemaGenerator;
244
+ /** Processes a date value before persisting, applying timezone or format conversions. */
197
245
  processDateProperty(value: unknown): string | number | Date;
246
+ /** Wraps a table or column identifier with the platform-specific quote character. */
198
247
  quoteIdentifier(id: string | {
199
248
  toString: () => string;
200
249
  }, quote?: string): string;
250
+ /** Quotes a literal value for safe embedding in SQL. */
201
251
  quoteValue(value: any): string;
202
252
  escape(value: any): string;
253
+ /** Replaces `?` placeholders in SQL with quoted parameter values. */
203
254
  formatQuery(sql: string, params: readonly any[]): string;
255
+ /** Deep-clones embeddable data and tags it for JSON serialization. */
204
256
  cloneEmbeddable<T>(data: T): T;
257
+ /** Initializes the platform with the ORM configuration. */
205
258
  setConfig(config: Configuration): void;
259
+ /** Returns the current ORM configuration. */
206
260
  getConfig(): Configuration;
261
+ /** Returns the configured timezone, or undefined if not set. */
207
262
  getTimezone(): string | undefined;
263
+ /** Whether the given property represents a numeric database column. */
208
264
  isNumericProperty(prop: EntityProperty, ignoreCustomType?: boolean): boolean;
265
+ /** Whether the given mapped type represents a numeric column. */
209
266
  isNumericColumn(mappedType: Type<unknown>): boolean;
267
+ /** Whether the platform supports unsigned integer columns. */
210
268
  supportsUnsigned(): boolean;
211
269
  /**
212
270
  * Returns the default name of index for the given columns
213
271
  */
214
272
  getIndexName(tableName: string, columns: string[], type: 'index' | 'unique' | 'foreign' | 'primary' | 'sequence'): string;
273
+ /** Returns the default primary key constraint name. */
215
274
  getDefaultPrimaryName(tableName: string, columns: string[]): string;
275
+ /** Whether the platform supports custom names for primary key constraints. */
216
276
  supportsCustomPrimaryKeyNames(): boolean;
277
+ /** Whether the given property key is included in the populate hint. */
217
278
  isPopulated<T>(key: string, populate: readonly PopulateOptions<T>[] | boolean): boolean;
279
+ /** Whether the given property should be included as a column in the SELECT query. */
218
280
  shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean, ignoreInlineEmbeddables?: boolean): boolean;
219
281
  /**
220
282
  * Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
221
283
  */
284
+ /** Whether the platform supports generating down migrations. */
222
285
  supportsDownMigrations(): boolean;
286
+ /** Whether the platform supports deferred unique constraints. */
223
287
  supportsDeferredUniqueConstraints(): boolean;
288
+ /** Platform-specific validation of entity metadata. */
224
289
  validateMetadata(meta: EntityMetadata): void;
225
290
  /**
226
291
  * Generates a custom order by statement given a set of in order values, eg.
@@ -6,30 +6,39 @@ import { ArrayType, BigIntType, BlobType, BooleanType, CharacterType, DateTimeTy
6
6
  import { parseJsonSafe, Utils } from '../utils/Utils.js';
7
7
  import { ReferenceKind } from '../enums.js';
8
8
  import { Raw } from '../utils/RawQueryFragment.js';
9
+ /** Symbol used to tag cloned embeddable data for JSON serialization handling. */
9
10
  export const JsonProperty = Symbol('JsonProperty');
11
+ /** Abstract base class providing database-specific behavior and SQL dialect differences. */
10
12
  export class Platform {
11
13
  exceptionConverter = new ExceptionConverter();
12
14
  config;
13
15
  namingStrategy;
14
16
  timezone;
17
+ /** Whether this driver uses pivot tables for M:N relations (SQL drivers do, MongoDB does not). */
15
18
  usesPivotTable() {
16
19
  return false;
17
20
  }
21
+ /** Whether this driver supports database transactions. */
18
22
  supportsTransactions() {
19
23
  return !this.config.get('disableTransactions');
20
24
  }
25
+ /** Whether the driver wraps operations in implicit transactions by default. */
21
26
  usesImplicitTransactions() {
22
27
  return true;
23
28
  }
29
+ /** Returns the default naming strategy constructor for this platform. */
24
30
  getNamingStrategy() {
25
31
  return UnderscoreNamingStrategy;
26
32
  }
33
+ /** Whether the driver supports RETURNING clause (e.g. PostgreSQL). */
27
34
  usesReturningStatement() {
28
35
  return false;
29
36
  }
37
+ /** Whether the driver supports OUTPUT clause (e.g. MSSQL). */
30
38
  usesOutputStatement() {
31
39
  return false;
32
40
  }
41
+ /** Whether DELETE statements require explicit CASCADE keyword. */
33
42
  usesCascadeStatement() {
34
43
  return false;
35
44
  }
@@ -41,12 +50,15 @@ export class Platform {
41
50
  usesEnumCheckConstraints() {
42
51
  return false;
43
52
  }
53
+ /** Whether this platform supports materialized views. */
44
54
  supportsMaterializedViews() {
45
55
  return false;
46
56
  }
57
+ /** Returns the schema helper instance for this platform, or undefined if not supported. */
47
58
  getSchemaHelper() {
48
59
  return undefined;
49
60
  }
61
+ /** Whether the platform automatically creates indexes on foreign key columns. */
50
62
  indexForeignKeys() {
51
63
  return false;
52
64
  }
@@ -62,6 +74,7 @@ export class Platform {
62
74
  usesBatchUpdates() {
63
75
  return true;
64
76
  }
77
+ /** Whether the platform supports the DEFAULT keyword in INSERT statements. */
65
78
  usesDefaultKeyword() {
66
79
  return true;
67
80
  }
@@ -83,59 +96,76 @@ export class Platform {
83
96
  getCurrentTimestampSQL(length) {
84
97
  return 'current_timestamp' + (length ? `(${length})` : '');
85
98
  }
99
+ /** Returns the SQL type declaration for datetime columns. */
86
100
  getDateTimeTypeDeclarationSQL(column) {
87
101
  return 'datetime' + (column.length ? `(${column.length})` : '');
88
102
  }
103
+ /** Returns the default fractional seconds precision for datetime columns. */
89
104
  getDefaultDateTimeLength() {
90
105
  return 0;
91
106
  }
107
+ /** Returns the default length for varchar columns. */
92
108
  getDefaultVarcharLength() {
93
109
  return 255;
94
110
  }
111
+ /** Returns the default length for char columns. */
95
112
  getDefaultCharLength() {
96
113
  return 1;
97
114
  }
115
+ /** Returns the SQL type declaration for date columns. */
98
116
  getDateTypeDeclarationSQL(length) {
99
117
  return 'date' + (length ? `(${length})` : '');
100
118
  }
119
+ /** Returns the SQL type declaration for time columns. */
101
120
  getTimeTypeDeclarationSQL(length) {
102
121
  return 'time' + (length ? `(${length})` : '');
103
122
  }
123
+ /** Returns the SQL operator used for regular expression matching. */
104
124
  getRegExpOperator(val, flags) {
105
125
  return 'regexp';
106
126
  }
127
+ /** Builds the SQL clause and parameters for a regular expression condition. */
107
128
  mapRegExpCondition(mappedKey, value) {
108
129
  const operator = this.getRegExpOperator(value.$re, value.$flags);
109
130
  const quotedKey = this.quoteIdentifier(mappedKey);
110
131
  return { sql: `${quotedKey} ${operator} ?`, params: [value.$re] };
111
132
  }
133
+ /** Converts a JavaScript RegExp into a platform-specific regex representation. */
112
134
  getRegExpValue(val) {
113
135
  if (val.flags.includes('i')) {
114
136
  return { $re: `(?i)${val.source}` };
115
137
  }
116
138
  return { $re: val.source };
117
139
  }
140
+ /** Whether the given operator is allowed at the top level of a query condition. */
118
141
  isAllowedTopLevelOperator(operator) {
119
142
  return operator === '$not';
120
143
  }
144
+ /** Converts a version field value for comparison in optimistic locking queries. */
121
145
  convertVersionValue(value, prop) {
122
146
  return value;
123
147
  }
148
+ /** Returns the default fractional seconds precision for version timestamp columns. */
124
149
  getDefaultVersionLength() {
125
150
  return 3;
126
151
  }
152
+ /** Whether the platform supports tuple comparison in WHERE clauses. */
127
153
  allowsComparingTuples() {
128
154
  return true;
129
155
  }
156
+ /** Whether the given property maps to a bigint database column. */
130
157
  isBigIntProperty(prop) {
131
158
  return prop.columnTypes?.[0] === 'bigint';
132
159
  }
160
+ /** Returns the default schema name for this platform (e.g. "public" for PostgreSQL). */
133
161
  getDefaultSchemaName() {
134
162
  return undefined;
135
163
  }
164
+ /** Returns the SQL type declaration for boolean columns. */
136
165
  getBooleanTypeDeclarationSQL() {
137
166
  return 'boolean';
138
167
  }
168
+ /** Returns the SQL type declaration for integer columns. */
139
169
  getIntegerTypeDeclarationSQL(column) {
140
170
  return 'int';
141
171
  }
@@ -184,6 +214,7 @@ export class Platform {
184
214
  column.length ??= 36;
185
215
  return this.getVarcharTypeDeclarationSQL(column);
186
216
  }
217
+ /** Extracts the base type name from a full SQL type declaration (e.g. "varchar(255)" -> "varchar"). */
187
218
  extractSimpleType(type) {
188
219
  return /[^(), ]+/.exec(type.toLowerCase())[0];
189
220
  }
@@ -193,10 +224,12 @@ export class Platform {
193
224
  normalizeColumnType(type, options) {
194
225
  return type.toLowerCase();
195
226
  }
227
+ /** Returns the mapped Type instance for a given SQL/runtime type string. */
196
228
  getMappedType(type) {
197
229
  const mappedType = this.config.get('discovery').getMappedType?.(type, this);
198
230
  return mappedType ?? this.getDefaultMappedType(type);
199
231
  }
232
+ /** Returns the default mapped Type for a given type string when no custom mapping is configured. */
200
233
  getDefaultMappedType(type) {
201
234
  if (type.endsWith('[]')) {
202
235
  return Type.getType(ArrayType);
@@ -257,6 +290,7 @@ export class Platform {
257
290
  return Type.getType(UnknownType);
258
291
  }
259
292
  }
293
+ /** Whether the platform supports multiple cascade paths to the same table. */
260
294
  supportsMultipleCascadePaths() {
261
295
  return true;
262
296
  }
@@ -267,18 +301,23 @@ export class Platform {
267
301
  supportsOnUpdate() {
268
302
  return true;
269
303
  }
304
+ /** Whether the connection supports executing multiple SQL statements in a single call. */
270
305
  supportsMultipleStatements() {
271
306
  return this.config.get('multipleStatements');
272
307
  }
308
+ /** Whether the platform supports the UNION WHERE optimization for multi-branch queries. */
273
309
  supportsUnionWhere() {
274
310
  return false;
275
311
  }
312
+ /** Returns the SQL type declaration used for array storage. */
276
313
  getArrayDeclarationSQL() {
277
314
  return 'text';
278
315
  }
316
+ /** Serializes a string array into its database storage format. */
279
317
  marshallArray(values) {
280
318
  return values.join(',');
281
319
  }
320
+ /** Deserializes a database-stored array string back into a string array. */
282
321
  unmarshallArray(value) {
283
322
  if (value === '') {
284
323
  return [];
@@ -335,12 +374,15 @@ export class Platform {
335
374
  getFullTextIndexExpression(indexName, schemaName, tableName, columns) {
336
375
  throw new Error('Full text searching is not supported by this driver.');
337
376
  }
377
+ /** Whether the driver automatically parses JSON columns into JS objects. */
338
378
  convertsJsonAutomatically() {
339
379
  return true;
340
380
  }
381
+ /** Converts a JS value to its JSON database representation (typically JSON.stringify). */
341
382
  convertJsonToDatabaseValue(value, context) {
342
383
  return JSON.stringify(value);
343
384
  }
385
+ /** Converts a database JSON value to its JS representation. */
344
386
  convertJsonToJSValue(value, context) {
345
387
  return parseJsonSafe(value);
346
388
  }
@@ -369,6 +411,7 @@ export class Platform {
369
411
  convertUuidToDatabaseValue(value) {
370
412
  return value;
371
413
  }
414
+ /** Parses a string or numeric value into a Date object. */
372
415
  parseDate(value) {
373
416
  const date = new Date(value);
374
417
  /* v8 ignore next */
@@ -377,12 +420,15 @@ export class Platform {
377
420
  }
378
421
  return date;
379
422
  }
423
+ /** Returns the default EntityRepository class used by this platform. */
380
424
  getRepositoryClass() {
381
425
  return EntityRepository;
382
426
  }
427
+ /** Returns the default character set for this platform. */
383
428
  getDefaultCharset() {
384
429
  return 'utf8';
385
430
  }
431
+ /** Returns the exception converter for translating native errors to driver exceptions. */
386
432
  getExceptionConverter() {
387
433
  return this.exceptionConverter;
388
434
  }
@@ -396,6 +442,7 @@ export class Platform {
396
442
  init(orm) {
397
443
  this.lookupExtensions(orm);
398
444
  }
445
+ /** Retrieves a registered extension (e.g. SchemaGenerator, Migrator), throwing if not found. */
399
446
  getExtension(extensionName, extensionKey, moduleName, em) {
400
447
  const extension = this.config.getExtension(extensionKey);
401
448
  if (extension) {
@@ -408,9 +455,11 @@ export class Platform {
408
455
  getSchemaGenerator(driver, em) {
409
456
  throw new Error(`${driver.constructor.name} does not support SchemaGenerator`);
410
457
  }
458
+ /** Processes a date value before persisting, applying timezone or format conversions. */
411
459
  processDateProperty(value) {
412
460
  return value;
413
461
  }
462
+ /** Wraps a table or column identifier with the platform-specific quote character. */
414
463
  quoteIdentifier(id, quote = '`') {
415
464
  const raw = Raw.getKnownFragment(id);
416
465
  if (raw) {
@@ -418,6 +467,7 @@ export class Platform {
418
467
  }
419
468
  return `${quote}${id.toString().replace('.', `${quote}.${quote}`)}${quote}`;
420
469
  }
470
+ /** Quotes a literal value for safe embedding in SQL. */
421
471
  quoteValue(value) {
422
472
  return value;
423
473
  }
@@ -425,6 +475,7 @@ export class Platform {
425
475
  escape(value) {
426
476
  return value;
427
477
  }
478
+ /** Replaces `?` placeholders in SQL with quoted parameter values. */
428
479
  formatQuery(sql, params) {
429
480
  if (params.length === 0) {
430
481
  return sql;
@@ -464,12 +515,14 @@ export class Platform {
464
515
  }
465
516
  return ret;
466
517
  }
518
+ /** Deep-clones embeddable data and tags it for JSON serialization. */
467
519
  cloneEmbeddable(data) {
468
520
  const copy = clone(data);
469
521
  // tag the copy so we know it should be stringified when quoting (so we know how to treat JSON arrays)
470
522
  Object.defineProperty(copy, JsonProperty, { enumerable: false, value: true });
471
523
  return copy;
472
524
  }
525
+ /** Initializes the platform with the ORM configuration. */
473
526
  setConfig(config) {
474
527
  this.config = config;
475
528
  this.namingStrategy = config.getNamingStrategy();
@@ -480,19 +533,24 @@ export class Platform {
480
533
  this.timezone = this.config.get('timezone');
481
534
  }
482
535
  }
536
+ /** Returns the current ORM configuration. */
483
537
  getConfig() {
484
538
  return this.config;
485
539
  }
540
+ /** Returns the configured timezone, or undefined if not set. */
486
541
  getTimezone() {
487
542
  return this.timezone;
488
543
  }
544
+ /** Whether the given property represents a numeric database column. */
489
545
  isNumericProperty(prop, ignoreCustomType = false) {
490
546
  const numericMappedType = prop.columnTypes?.[0] && this.isNumericColumn(this.getMappedType(prop.columnTypes[0]));
491
547
  return numericMappedType || prop.type === 'number' || this.isBigIntProperty(prop);
492
548
  }
549
+ /** Whether the given mapped type represents a numeric column. */
493
550
  isNumericColumn(mappedType) {
494
551
  return [IntegerType, SmallIntType, BigIntType, TinyIntType].some(t => mappedType instanceof t);
495
552
  }
553
+ /** Whether the platform supports unsigned integer columns. */
496
554
  supportsUnsigned() {
497
555
  return false;
498
556
  }
@@ -502,15 +560,19 @@ export class Platform {
502
560
  getIndexName(tableName, columns, type) {
503
561
  return this.namingStrategy.indexName(tableName, columns, type);
504
562
  }
563
+ /** Returns the default primary key constraint name. */
505
564
  getDefaultPrimaryName(tableName, columns) {
506
565
  return 'primary';
507
566
  }
567
+ /** Whether the platform supports custom names for primary key constraints. */
508
568
  supportsCustomPrimaryKeyNames() {
509
569
  return false;
510
570
  }
571
+ /** Whether the given property key is included in the populate hint. */
511
572
  isPopulated(key, populate) {
512
573
  return populate === true || (populate !== false && populate.some(p => p.field === key || p.all));
513
574
  }
575
+ /** Whether the given property should be included as a column in the SELECT query. */
514
576
  shouldHaveColumn(prop, populate, exclude, includeFormulas = true, ignoreInlineEmbeddables = true) {
515
577
  if (exclude?.includes(prop.name)) {
516
578
  return false;
@@ -538,12 +600,15 @@ export class Platform {
538
600
  /**
539
601
  * Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
540
602
  */
603
+ /** Whether the platform supports generating down migrations. */
541
604
  supportsDownMigrations() {
542
605
  return true;
543
606
  }
607
+ /** Whether the platform supports deferred unique constraints. */
544
608
  supportsDeferredUniqueConstraints() {
545
609
  return true;
546
610
  }
611
+ /** Platform-specific validation of entity metadata. */
547
612
  validateMetadata(meta) {
548
613
  return;
549
614
  }
@@ -1,6 +1,8 @@
1
1
  import type { ArrayElement, AutoPath, CleanTypeConfig, SerializeDTO, FromEntityType, TypeConfig, UnboxArray } from '../typings.js';
2
2
  import { type PopulatePath } from '../enums.js';
3
+ /** Converts entity instances to plain DTOs via `serialize()`, with fine-grained control over populate, exclude, and serialization groups. */
3
4
  export declare class EntitySerializer {
5
+ /** Serializes an entity to a plain DTO, with fine-grained control over population, exclusion, groups, and custom types. */
4
6
  static serialize<T extends object, P extends string = never, E extends string = never>(entity: T, options?: SerializeOptions<T, P, E>): SerializeDTO<T, P, E>;
5
7
  private static propertyName;
6
8
  private static processProperty;
@@ -30,7 +30,9 @@ function isPopulated(propName, options) {
30
30
  }
31
31
  return false;
32
32
  }
33
+ /** Converts entity instances to plain DTOs via `serialize()`, with fine-grained control over populate, exclude, and serialization groups. */
33
34
  export class EntitySerializer {
35
+ /** Serializes an entity to a plain DTO, with fine-grained control over population, exclusion, groups, and custom types. */
34
36
  static serialize(entity, options = {}) {
35
37
  const wrapped = helper(entity);
36
38
  const meta = wrapped.__meta;
@@ -1,5 +1,7 @@
1
1
  import type { EntityDTO, EntityKey } from '../typings.js';
2
+ /** Converts entity instances to plain objects via `toObject()`, respecting populate hints, hidden fields, and serialization context. */
2
3
  export declare class EntityTransformer {
4
+ /** Converts an entity to a plain object, respecting populate hints, hidden fields, and custom serializers. */
3
5
  static toObject<Entity extends object, Ignored extends EntityKey<Entity> = never>(entity: Entity, ignoreFields?: Ignored[], raw?: boolean): Omit<EntityDTO<Entity>, Ignored>;
4
6
  private static propertyName;
5
7
  private static processProperty;
@@ -9,7 +9,9 @@ function isVisible(meta, propName, ignoreFields = []) {
9
9
  const prefixed = prop && !prop.primary && !prop.accessor && propName.startsWith('_'); // ignore prefixed properties, if it's not a PK
10
10
  return visible && !prefixed && !ignoreFields.includes(propName);
11
11
  }
12
+ /** Converts entity instances to plain objects via `toObject()`, respecting populate hints, hidden fields, and serialization context. */
12
13
  export class EntityTransformer {
14
+ /** Converts an entity to a plain object, respecting populate hints, hidden fields, and custom serializers. */
13
15
  static toObject(entity, ignoreFields = [], raw = false) {
14
16
  if (!Array.isArray(ignoreFields)) {
15
17
  ignoreFields = [];
@@ -13,14 +13,19 @@ export declare class SerializationContext<T extends object> {
13
13
  * Returns true when there is a cycle detected.
14
14
  */
15
15
  visit(entityName: EntityName, prop: string): boolean;
16
+ /** Removes the last entry from the visit path after processing a property. */
16
17
  leave(entityName: EntityName, prop: string): void;
18
+ /** Cleans up the serialization context by removing root references from all tracked entities. */
17
19
  close(): void;
18
20
  /**
19
21
  * When initializing new context, we need to propagate it to the whole entity graph recursively.
20
22
  */
21
23
  static propagate(root: SerializationContext<any>, entity: AnyEntity, isVisible: (meta: EntityMetadata, prop: string) => boolean): void;
24
+ /** Checks whether a property is explicitly listed in the populate hints for the current path. */
22
25
  isMarkedAsPopulated(entityName: EntityName, prop: string): boolean;
26
+ /** Checks whether a property is excluded from serialization via the exclude list. */
23
27
  isExcluded(entityName: EntityName, prop: string): boolean;
28
+ /** Checks whether a property is included in the partial fields selection for the current path. */
24
29
  isPartiallyLoaded(entityName: EntityName, prop: string): boolean;
25
30
  private register;
26
31
  }
@@ -32,6 +32,7 @@ export class SerializationContext {
32
32
  this.path.push([entityName, prop]);
33
33
  return false;
34
34
  }
35
+ /** Removes the last entry from the visit path after processing a property. */
35
36
  leave(entityName, prop) {
36
37
  const last = this.path.pop();
37
38
  /* v8 ignore next */
@@ -39,6 +40,7 @@ export class SerializationContext {
39
40
  throw new Error(`Trying to leave wrong property: ${entityName}.${prop} instead of ${last?.join('.')}`);
40
41
  }
41
42
  }
43
+ /** Cleans up the serialization context by removing root references from all tracked entities. */
42
44
  close() {
43
45
  for (const entity of this.#entities) {
44
46
  delete helper(entity).__serializationContext.root;
@@ -70,6 +72,7 @@ export class SerializationContext {
70
72
  }
71
73
  }
72
74
  }
75
+ /** Checks whether a property is explicitly listed in the populate hints for the current path. */
73
76
  isMarkedAsPopulated(entityName, prop) {
74
77
  let populate = this.#populate ?? [];
75
78
  for (const segment of this.path) {
@@ -90,6 +93,7 @@ export class SerializationContext {
90
93
  }
91
94
  return !!populate?.some(p => p.field === prop);
92
95
  }
96
+ /** Checks whether a property is excluded from serialization via the exclude list. */
93
97
  isExcluded(entityName, prop) {
94
98
  if (!this.#exclude || this.#exclude.length === 0) {
95
99
  return false;
@@ -97,6 +101,7 @@ export class SerializationContext {
97
101
  const fullPath = this.path.map(segment => segment[1] + '.').join('') + prop;
98
102
  return this.#exclude.includes(fullPath);
99
103
  }
104
+ /** Checks whether a property is included in the partial fields selection for the current path. */
100
105
  isPartiallyLoaded(entityName, prop) {
101
106
  if (!this.#fields) {
102
107
  return true;
@@ -1,6 +1,7 @@
1
1
  import { type TransformContext, Type } from './Type.js';
2
2
  import type { EntityProperty } from '../typings.js';
3
3
  import type { Platform } from '../platforms/Platform.js';
4
+ /** Maps a database text/array column to a JS array, using platform-specific marshalling (e.g., PostgreSQL arrays or comma-separated strings). */
4
5
  export declare class ArrayType<T = string> extends Type<T[] | null, string | null> {
5
6
  private readonly toJsValue;
6
7
  private readonly toDbValue;
@@ -1,5 +1,6 @@
1
1
  import { Type } from './Type.js';
2
2
  import { ValidationError } from '../errors.js';
3
+ /** Maps a database text/array column to a JS array, using platform-specific marshalling (e.g., PostgreSQL arrays or comma-separated strings). */
3
4
  export class ArrayType extends Type {
4
5
  toJsValue;
5
6
  toDbValue;