@mikro-orm/core 7.0.0-dev.8 → 7.0.0-dev.80

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 (181) hide show
  1. package/EntityManager.d.ts +85 -48
  2. package/EntityManager.js +300 -225
  3. package/MikroORM.d.ts +40 -31
  4. package/MikroORM.js +98 -137
  5. package/README.md +3 -2
  6. package/cache/FileCacheAdapter.d.ts +1 -1
  7. package/cache/FileCacheAdapter.js +6 -5
  8. package/cache/GeneratedCacheAdapter.d.ts +0 -1
  9. package/cache/GeneratedCacheAdapter.js +0 -2
  10. package/cache/index.d.ts +0 -1
  11. package/cache/index.js +0 -1
  12. package/connections/Connection.d.ts +11 -7
  13. package/connections/Connection.js +16 -14
  14. package/drivers/DatabaseDriver.d.ts +11 -5
  15. package/drivers/DatabaseDriver.js +17 -8
  16. package/drivers/IDatabaseDriver.d.ts +27 -5
  17. package/entity/BaseEntity.d.ts +0 -1
  18. package/entity/BaseEntity.js +0 -3
  19. package/entity/Collection.d.ts +98 -30
  20. package/entity/Collection.js +432 -93
  21. package/entity/EntityAssigner.d.ts +1 -1
  22. package/entity/EntityAssigner.js +15 -7
  23. package/entity/EntityFactory.d.ts +7 -0
  24. package/entity/EntityFactory.js +64 -41
  25. package/entity/EntityHelper.js +26 -9
  26. package/entity/EntityLoader.d.ts +5 -4
  27. package/entity/EntityLoader.js +73 -40
  28. package/entity/EntityRepository.d.ts +1 -1
  29. package/entity/Reference.d.ts +9 -7
  30. package/entity/Reference.js +33 -6
  31. package/entity/WrappedEntity.d.ts +2 -4
  32. package/entity/WrappedEntity.js +1 -5
  33. package/entity/defineEntity.d.ts +549 -0
  34. package/entity/defineEntity.js +529 -0
  35. package/entity/index.d.ts +3 -2
  36. package/entity/index.js +3 -2
  37. package/entity/utils.d.ts +7 -0
  38. package/entity/utils.js +16 -4
  39. package/entity/validators.d.ts +11 -0
  40. package/entity/validators.js +65 -0
  41. package/enums.d.ts +21 -6
  42. package/enums.js +14 -1
  43. package/errors.d.ts +6 -2
  44. package/errors.js +14 -9
  45. package/events/EventSubscriber.d.ts +3 -1
  46. package/hydration/Hydrator.js +1 -2
  47. package/hydration/ObjectHydrator.d.ts +4 -4
  48. package/hydration/ObjectHydrator.js +36 -25
  49. package/index.d.ts +2 -2
  50. package/index.js +1 -2
  51. package/logging/DefaultLogger.d.ts +1 -1
  52. package/logging/SimpleLogger.d.ts +1 -1
  53. package/metadata/EntitySchema.d.ts +9 -13
  54. package/metadata/EntitySchema.js +44 -26
  55. package/metadata/MetadataDiscovery.d.ts +6 -9
  56. package/metadata/MetadataDiscovery.js +167 -206
  57. package/metadata/MetadataProvider.d.ts +11 -2
  58. package/metadata/MetadataProvider.js +44 -2
  59. package/metadata/MetadataStorage.d.ts +1 -6
  60. package/metadata/MetadataStorage.js +6 -18
  61. package/metadata/MetadataValidator.d.ts +0 -7
  62. package/metadata/MetadataValidator.js +4 -13
  63. package/metadata/discover-entities.d.ts +5 -0
  64. package/metadata/discover-entities.js +40 -0
  65. package/metadata/index.d.ts +1 -1
  66. package/metadata/index.js +1 -1
  67. package/metadata/types.d.ts +480 -0
  68. package/metadata/types.js +1 -0
  69. package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
  70. package/naming-strategy/AbstractNamingStrategy.js +8 -2
  71. package/naming-strategy/NamingStrategy.d.ts +11 -1
  72. package/not-supported.d.ts +2 -0
  73. package/not-supported.js +4 -0
  74. package/package.json +18 -10
  75. package/platforms/ExceptionConverter.js +1 -1
  76. package/platforms/Platform.d.ts +6 -10
  77. package/platforms/Platform.js +14 -39
  78. package/serialization/EntitySerializer.d.ts +2 -0
  79. package/serialization/EntitySerializer.js +32 -14
  80. package/serialization/EntityTransformer.js +22 -12
  81. package/serialization/SerializationContext.js +16 -13
  82. package/types/ArrayType.d.ts +1 -1
  83. package/types/ArrayType.js +2 -3
  84. package/types/BigIntType.d.ts +8 -6
  85. package/types/BigIntType.js +1 -1
  86. package/types/BlobType.d.ts +0 -1
  87. package/types/BlobType.js +0 -3
  88. package/types/BooleanType.d.ts +2 -1
  89. package/types/BooleanType.js +3 -0
  90. package/types/DecimalType.d.ts +6 -4
  91. package/types/DecimalType.js +3 -3
  92. package/types/DoubleType.js +2 -2
  93. package/types/JsonType.d.ts +1 -1
  94. package/types/JsonType.js +7 -2
  95. package/types/TinyIntType.js +1 -1
  96. package/types/Type.d.ts +2 -1
  97. package/types/Type.js +1 -1
  98. package/types/Uint8ArrayType.d.ts +0 -1
  99. package/types/Uint8ArrayType.js +1 -4
  100. package/types/index.d.ts +1 -1
  101. package/typings.d.ts +113 -77
  102. package/typings.js +41 -35
  103. package/unit-of-work/ChangeSetComputer.d.ts +1 -3
  104. package/unit-of-work/ChangeSetComputer.js +11 -9
  105. package/unit-of-work/ChangeSetPersister.d.ts +5 -4
  106. package/unit-of-work/ChangeSetPersister.js +58 -20
  107. package/unit-of-work/UnitOfWork.d.ts +8 -1
  108. package/unit-of-work/UnitOfWork.js +115 -57
  109. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  110. package/utils/AbstractSchemaGenerator.js +11 -9
  111. package/utils/Configuration.d.ts +757 -206
  112. package/utils/Configuration.js +139 -187
  113. package/utils/ConfigurationLoader.d.ts +1 -54
  114. package/utils/ConfigurationLoader.js +1 -352
  115. package/utils/Cursor.d.ts +3 -3
  116. package/utils/Cursor.js +4 -1
  117. package/utils/DataloaderUtils.d.ts +15 -5
  118. package/utils/DataloaderUtils.js +54 -8
  119. package/utils/EntityComparator.d.ts +8 -4
  120. package/utils/EntityComparator.js +111 -64
  121. package/utils/QueryHelper.d.ts +9 -1
  122. package/utils/QueryHelper.js +70 -9
  123. package/utils/RawQueryFragment.d.ts +36 -4
  124. package/utils/RawQueryFragment.js +35 -14
  125. package/utils/TransactionManager.d.ts +65 -0
  126. package/utils/TransactionManager.js +223 -0
  127. package/utils/Utils.d.ts +8 -97
  128. package/utils/Utils.js +88 -303
  129. package/utils/clone.js +2 -3
  130. package/utils/env-vars.d.ts +3 -0
  131. package/utils/env-vars.js +87 -0
  132. package/utils/fs-utils.d.ts +12 -0
  133. package/utils/fs-utils.js +96 -0
  134. package/utils/index.d.ts +2 -1
  135. package/utils/index.js +2 -1
  136. package/utils/upsert-utils.d.ts +7 -2
  137. package/utils/upsert-utils.js +55 -4
  138. package/decorators/Check.d.ts +0 -3
  139. package/decorators/Check.js +0 -13
  140. package/decorators/CreateRequestContext.d.ts +0 -3
  141. package/decorators/CreateRequestContext.js +0 -32
  142. package/decorators/Embeddable.d.ts +0 -8
  143. package/decorators/Embeddable.js +0 -11
  144. package/decorators/Embedded.d.ts +0 -18
  145. package/decorators/Embedded.js +0 -18
  146. package/decorators/Entity.d.ts +0 -18
  147. package/decorators/Entity.js +0 -12
  148. package/decorators/Enum.d.ts +0 -9
  149. package/decorators/Enum.js +0 -16
  150. package/decorators/Filter.d.ts +0 -2
  151. package/decorators/Filter.js +0 -8
  152. package/decorators/Formula.d.ts +0 -4
  153. package/decorators/Formula.js +0 -15
  154. package/decorators/Indexed.d.ts +0 -19
  155. package/decorators/Indexed.js +0 -20
  156. package/decorators/ManyToMany.d.ts +0 -40
  157. package/decorators/ManyToMany.js +0 -14
  158. package/decorators/ManyToOne.d.ts +0 -30
  159. package/decorators/ManyToOne.js +0 -14
  160. package/decorators/OneToMany.d.ts +0 -28
  161. package/decorators/OneToMany.js +0 -17
  162. package/decorators/OneToOne.d.ts +0 -24
  163. package/decorators/OneToOne.js +0 -7
  164. package/decorators/PrimaryKey.d.ts +0 -8
  165. package/decorators/PrimaryKey.js +0 -20
  166. package/decorators/Property.d.ts +0 -250
  167. package/decorators/Property.js +0 -32
  168. package/decorators/Transactional.d.ts +0 -13
  169. package/decorators/Transactional.js +0 -28
  170. package/decorators/hooks.d.ts +0 -16
  171. package/decorators/hooks.js +0 -47
  172. package/decorators/index.d.ts +0 -17
  173. package/decorators/index.js +0 -17
  174. package/entity/ArrayCollection.d.ts +0 -116
  175. package/entity/ArrayCollection.js +0 -402
  176. package/entity/EntityValidator.d.ts +0 -19
  177. package/entity/EntityValidator.js +0 -150
  178. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  179. package/metadata/ReflectMetadataProvider.js +0 -44
  180. package/utils/resolveContextProvider.d.ts +0 -10
  181. package/utils/resolveContextProvider.js +0 -28
@@ -0,0 +1,480 @@
1
+ import type { AnyEntity, Constructor, EntityName, AnyString, CheckCallback, GeneratedColumnCallback, FilterQuery, Dictionary, AutoPath, EntityClass, IndexCallback, ObjectQuery } from '../typings.js';
2
+ import type { Cascade, LoadStrategy, DeferMode, QueryOrderMap, EmbeddedPrefixMode } from '../enums.js';
3
+ import type { Type, types } from '../types/index.js';
4
+ import type { EntityManager } from '../EntityManager.js';
5
+ import type { FilterOptions, FindOptions } from '../drivers/IDatabaseDriver.js';
6
+ import type { SerializeOptions } from '../serialization/EntitySerializer.js';
7
+ export type EntityOptions<T, E = T extends EntityClass<infer P> ? P : T> = {
8
+ /** Override default collection/table name. Alias for `collection`. */
9
+ tableName?: string;
10
+ /** Sets the schema name. */
11
+ schema?: string;
12
+ /** Override default collection/table name. Alias for `tableName`. */
13
+ collection?: string;
14
+ /** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
15
+ discriminatorColumn?: (T extends EntityClass<infer P> ? keyof P : string) | AnyString;
16
+ /** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
17
+ discriminatorMap?: Dictionary<string>;
18
+ /** For {@doclink inheritance-mapping#single-table-inheritance | Single Table Inheritance}. */
19
+ discriminatorValue?: number | string;
20
+ /** Enforce use of constructor when creating managed entity instances. */
21
+ forceConstructor?: boolean;
22
+ /** Specify constructor parameters to be used in `em.create` or when `forceConstructor` is enabled. Those should be names of declared entity properties in the same order as your constructor uses them. The ORM tries to infer those automatically, use this option in case the inference fails. */
23
+ constructorParams?: (T extends EntityClass<infer P> ? keyof P : string)[];
24
+ /** Specify comment to table. (SQL only) */
25
+ comment?: string;
26
+ /** Marks entity as abstract, such entities are inlined during discovery. */
27
+ abstract?: boolean;
28
+ /** Disables change tracking - such entities are ignored during flush. */
29
+ readonly?: boolean;
30
+ /** Marks entity as {@doclink virtual-entities | virtual}. This is set automatically when you use `expression` option. */
31
+ virtual?: boolean;
32
+ /** Used to make ORM aware of externally defined triggers. This is needed for MS SQL Server multi inserts, ignored in other dialects. */
33
+ hasTriggers?: boolean;
34
+ /** SQL query that maps to a {@doclink virtual-entities | virtual entity}. */
35
+ expression?: string | ((em: any, where: ObjectQuery<E>, options: FindOptions<E, any, any, any>, stream?: boolean) => object);
36
+ /** Set {@doclink repositories#custom-repository | custom repository class}. */
37
+ repository?: () => Constructor;
38
+ };
39
+ export interface PropertyOptions<Owner> {
40
+ /**
41
+ * Alias for `fieldName`.
42
+ */
43
+ name?: string;
44
+ /**
45
+ * Specify database column name for this property.
46
+ *
47
+ * @see https://mikro-orm.io/docs/naming-strategy
48
+ */
49
+ fieldName?: string;
50
+ /**
51
+ * Specify database column names for this property.
52
+ * Same as `fieldName` but for composite FKs.
53
+ *
54
+ * @see https://mikro-orm.io/docs/naming-strategy
55
+ */
56
+ fieldNames?: string[];
57
+ /**
58
+ * Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is only for simple properties represented by a single column. (SQL only)
59
+ */
60
+ columnType?: ColumnType | AnyString;
61
+ /**
62
+ * Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is suitable for composite keys, where one property is represented by multiple columns. (SQL only)
63
+ */
64
+ columnTypes?: (ColumnType | AnyString)[];
65
+ /**
66
+ * Explicitly specify the runtime type.
67
+ *
68
+ * @see https://mikro-orm.io/docs/metadata-providers
69
+ * @see https://mikro-orm.io/docs/custom-types
70
+ */
71
+ type?: keyof typeof types | 'ObjectId' | Date | Constructor<AnyEntity> | Constructor<Type<any>> | Type<any> | (() => unknown) | ColumnType | AnyString;
72
+ /**
73
+ * Runtime type of the property. This is the JS type that your property is mapped to, e.g. `string` or `number`, and is normally inferred automatically via `reflect-metadata`.
74
+ * In some cases, the inference won't work, and you might need to specify the `runtimeType` explicitly - the most common one is when you use a union type with null like `foo: number | null`.
75
+ */
76
+ runtimeType?: string;
77
+ /**
78
+ * Set length of database column, used for datetime/timestamp/varchar column types for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
79
+ */
80
+ length?: number;
81
+ /**
82
+ * Set precision of database column to represent the number of significant digits. (SQL only)
83
+ */
84
+ precision?: number;
85
+ /**
86
+ * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
87
+ */
88
+ scale?: number;
89
+ /**
90
+ * Explicitly specify the auto increment of the primary key.
91
+ */
92
+ autoincrement?: boolean;
93
+ /**
94
+ * Add the property to the `returning` statement.
95
+ */
96
+ returning?: boolean;
97
+ /**
98
+ * Automatically set the property value when entity gets created, executed during flush operation.
99
+ * @param entity
100
+ */
101
+ onCreate?: (entity: Owner, em: EntityManager) => any;
102
+ /**
103
+ * Automatically update the property value every time entity gets updated, executed during flush operation.
104
+ * @param entity
105
+ */
106
+ onUpdate?: (entity: Owner, em: EntityManager) => any;
107
+ /**
108
+ * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
109
+ * This is a runtime value, assignable to the entity property. (SQL only)
110
+ */
111
+ default?: string | string[] | number | number[] | boolean | null;
112
+ /**
113
+ * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
114
+ * Since v4 you should use defaultRaw for SQL functions. e.g. now()
115
+ */
116
+ defaultRaw?: string;
117
+ /**
118
+ * Set to map some SQL snippet for the entity.
119
+ *
120
+ * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
121
+ */
122
+ formula?: string | ((alias: string) => string);
123
+ /**
124
+ * For generated columns. This will be appended to the column type after the `generated always` clause.
125
+ */
126
+ generated?: string | GeneratedColumnCallback<Owner>;
127
+ /**
128
+ * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
129
+ */
130
+ nullable?: boolean;
131
+ /**
132
+ * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
133
+ */
134
+ unsigned?: boolean;
135
+ /**
136
+ * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
137
+ */
138
+ persist?: boolean;
139
+ /**
140
+ * Set false to disable hydration of this property. Useful for persisted getters.
141
+ */
142
+ hydrate?: boolean;
143
+ /**
144
+ * Enable `ScalarReference` wrapper for lazy values. Use this in combination with `lazy: true` to have a type-safe accessor object in place of the value.
145
+ */
146
+ ref?: boolean;
147
+ /**
148
+ * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
149
+ */
150
+ hidden?: boolean;
151
+ /**
152
+ * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
153
+ */
154
+ version?: boolean;
155
+ /**
156
+ * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
157
+ */
158
+ concurrencyCheck?: boolean;
159
+ /**
160
+ * Explicitly specify index on a property.
161
+ */
162
+ index?: boolean | string;
163
+ /**
164
+ * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
165
+ */
166
+ unique?: boolean | string;
167
+ /**
168
+ * Specify column with check constraints. (Postgres driver only)
169
+ *
170
+ * @see https://mikro-orm.io/docs/defining-entities#check-constraints
171
+ */
172
+ check?: string | CheckCallback<Owner>;
173
+ /**
174
+ * Set to omit the property from the select clause for lazy loading.
175
+ *
176
+ * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
177
+ */
178
+ lazy?: boolean;
179
+ /**
180
+ * Set true to define entity's unique primary key identifier.
181
+ * Alias for `@PrimaryKey()` decorator
182
+ *
183
+ * @see https://mikro-orm.io/docs/decorators#primarykey
184
+ */
185
+ primary?: boolean;
186
+ /**
187
+ * Set true to define the properties as setter. (virtual)
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * @Property({ setter: true })
192
+ * set address(value: string) {
193
+ * this._address = value.toLocaleLowerCase();
194
+ * }
195
+ * ```
196
+ */
197
+ setter?: boolean;
198
+ /**
199
+ * Set true to define the properties as getter. (virtual)
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * @Property({ getter: true })
204
+ * get fullName() {
205
+ * return this.firstName + this.lastName;
206
+ * }
207
+ * ```
208
+ */
209
+ getter?: boolean;
210
+ /**
211
+ * When defining a property over a method (not a getter, a regular function), you can use this option to point
212
+ * to the method name.
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * @Property({ getter: true })
217
+ * getFullName() {
218
+ * return this.firstName + this.lastName;
219
+ * }
220
+ * ```
221
+ */
222
+ getterName?: keyof Owner;
223
+ /**
224
+ * When using a private property backed by a public get/set pair, use the `accessor` option to point to the other side.
225
+ *
226
+ * > The `fieldName` will be inferred based on the accessor name unless specified explicitly.
227
+ *
228
+ * If the `accessor` option points to something, the ORM will use the backing property directly.
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * @Entity()
233
+ * export class User {
234
+ * // the ORM will use the backing field directly
235
+ * @Property({ accessor: 'email' })
236
+ * private _email: string;
237
+ *
238
+ * get email() {
239
+ * return this._email;
240
+ * }
241
+ *
242
+ * set email() {
243
+ * return this._email;
244
+ * }
245
+ * }
246
+ *```
247
+ *
248
+ * If you want to the ORM to use your accessor internally too, use `accessor: true` on the get/set property instead.
249
+ * This is handy if you want to use a native private property for the backing field.
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * @Entity({ forceConstructor: true })
254
+ * export class User {
255
+ * #email: string;
256
+ *
257
+ * // the ORM will use the accessor internally
258
+ * @Property({ accessor: true })
259
+ * get email() {
260
+ * return this.#email;
261
+ * }
262
+ *
263
+ * set email() {
264
+ * return this.#email;
265
+ * }
266
+ * }
267
+ * ```
268
+ */
269
+ accessor?: keyof Owner | AnyString | boolean;
270
+ /**
271
+ * Set to define serialized primary key for MongoDB. (virtual)
272
+ * Alias for `@SerializedPrimaryKey()` decorator.
273
+ *
274
+ * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
275
+ */
276
+ serializedPrimaryKey?: boolean;
277
+ /**
278
+ * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
279
+ *
280
+ * @see https://mikro-orm.io/docs/serializing#property-serializers
281
+ */
282
+ serializer?: (value: any, options?: SerializeOptions<any>) => any;
283
+ /**
284
+ * Specify name of key for the serialized value.
285
+ */
286
+ serializedName?: string;
287
+ /**
288
+ * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
289
+ * otherwise only properties with a matching group are included.
290
+ */
291
+ groups?: string[];
292
+ /**
293
+ * Specify a custom order based on the values. (SQL only)
294
+ */
295
+ customOrder?: string[] | number[] | boolean[];
296
+ /**
297
+ * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
298
+ */
299
+ comment?: string;
300
+ /** mysql only */
301
+ extra?: string;
302
+ /**
303
+ * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
304
+ *
305
+ * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
306
+ */
307
+ ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
308
+ }
309
+ export interface ReferenceOptions<Owner, Target> extends PropertyOptions<Owner> {
310
+ /** Set target entity type. */
311
+ entity?: string | (() => EntityName<Target>);
312
+ /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
313
+ cascade?: Cascade[];
314
+ /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
315
+ eager?: boolean;
316
+ /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
317
+ strategy?: LoadStrategy | `${LoadStrategy}`;
318
+ /** Control filter parameters for the relation. This will serve as a default value when processing filters on this relation. It's value can be overridden via `em.fork()` or `FindOptions`. */
319
+ filters?: FilterOptions;
320
+ }
321
+ /**
322
+ * Inspired by https://github.com/typeorm/typeorm/blob/941b584ba135617e55d6685caef671172ec1dc03/src/driver/types/ColumnTypes.ts
323
+ * @ignore
324
+ */
325
+ export type ColumnType = 'int' | 'int4' | 'integer' | 'bigint' | 'int8' | 'int2' | 'tinyint' | 'smallint' | 'mediumint' | 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4' | 'datetime' | 'time' | 'time with time zone' | 'timestamp' | 'timestamp with time zone' | 'timetz' | 'timestamptz' | 'date' | 'interval' | 'character varying' | 'varchar' | 'char' | 'character' | 'uuid' | 'text' | 'tinytext' | 'mediumtext' | 'longtext' | 'boolean' | 'bool' | 'bit' | 'enum' | 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea' | 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry' | 'tsvector' | 'tsquery' | 'json' | 'jsonb';
326
+ export interface ManyToOneOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
327
+ /** Point to the inverse side property name. */
328
+ inversedBy?: (string & keyof Target) | ((e: Target) => any);
329
+ /** Wrap the entity in {@apilink Reference} wrapper. */
330
+ ref?: boolean;
331
+ /** Use this relation as a primary key. */
332
+ primary?: boolean;
333
+ /** Map this relation to the primary key value instead of an entity. */
334
+ mapToPk?: boolean;
335
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
336
+ joinColumn?: string;
337
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
338
+ joinColumns?: string[];
339
+ /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
340
+ ownColumns?: string[];
341
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
342
+ referenceColumnName?: string;
343
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
344
+ referencedColumnNames?: string[];
345
+ /** What to do when the target entity gets deleted. */
346
+ deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
347
+ /** What to do when the reference to the target entity gets updated. */
348
+ updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
349
+ /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
350
+ deferMode?: DeferMode | `${DeferMode}`;
351
+ /** Enable/disable foreign key constraint creation on this relation */
352
+ createForeignKeyConstraint?: boolean;
353
+ /** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
354
+ foreignKeyName?: string;
355
+ }
356
+ export interface OneToManyOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
357
+ /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
358
+ orphanRemoval?: boolean;
359
+ /** Set default ordering. */
360
+ orderBy?: QueryOrderMap<Target> | QueryOrderMap<Target>[];
361
+ /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
362
+ where?: FilterQuery<Target>;
363
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
364
+ joinColumn?: string;
365
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
366
+ joinColumns?: string[];
367
+ /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
368
+ inverseJoinColumn?: string;
369
+ /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
370
+ inverseJoinColumns?: string[];
371
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
372
+ referenceColumnName?: string;
373
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
374
+ referencedColumnNames?: string[];
375
+ /** Point to the owning side property name. */
376
+ mappedBy: (string & keyof Target) | ((e: Target) => any);
377
+ }
378
+ export interface OneToOneOptions<Owner, Target> extends Partial<Omit<OneToManyOptions<Owner, Target>, 'orderBy'>> {
379
+ /** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
380
+ owner?: boolean;
381
+ /** Point to the inverse side property name. */
382
+ inversedBy?: (string & keyof Target) | ((e: Target) => any);
383
+ /** Wrap the entity in {@apilink Reference} wrapper. */
384
+ ref?: boolean;
385
+ /** Use this relation as a primary key. */
386
+ primary?: boolean;
387
+ /** Map this relation to the primary key value instead of an entity. */
388
+ mapToPk?: boolean;
389
+ /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
390
+ ownColumns?: string[];
391
+ /** What to do when the target entity gets deleted. */
392
+ deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
393
+ /** What to do when the reference to the target entity gets updated. */
394
+ updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
395
+ /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
396
+ deferMode?: DeferMode | `${DeferMode}`;
397
+ /** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
398
+ foreignKeyName?: string;
399
+ /** Enable/disable foreign key constraint creation on this relation */
400
+ createForeignKeyConstraint?: boolean;
401
+ }
402
+ export interface ManyToManyOptions<Owner, Target> extends ReferenceOptions<Owner, Target> {
403
+ /** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
404
+ owner?: boolean;
405
+ /** Point to the inverse side property name. */
406
+ inversedBy?: (string & keyof Target) | ((e: Target) => any);
407
+ /** Point to the owning side property name. */
408
+ mappedBy?: (string & keyof Target) | ((e: Target) => any);
409
+ /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
410
+ where?: FilterQuery<Target>;
411
+ /** Set default ordering. */
412
+ orderBy?: QueryOrderMap<Target> | QueryOrderMap<Target>[];
413
+ /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
414
+ fixedOrder?: boolean;
415
+ /** Override default order column name (`id`) for fixed ordering. */
416
+ fixedOrderColumn?: string;
417
+ /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
418
+ pivotTable?: string;
419
+ /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
420
+ pivotEntity?: string | (() => EntityName<any>);
421
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
422
+ joinColumn?: string;
423
+ /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
424
+ joinColumns?: string[];
425
+ /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
426
+ inverseJoinColumn?: string;
427
+ /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
428
+ inverseJoinColumns?: string[];
429
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
430
+ referenceColumnName?: string;
431
+ /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
432
+ referencedColumnNames?: string[];
433
+ /** What to do when the target entity gets deleted. */
434
+ deleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
435
+ /** What to do when the reference to the target entity gets updated. */
436
+ updateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString;
437
+ /** Enable/disable foreign key constraint creation on this relation */
438
+ createForeignKeyConstraint?: boolean;
439
+ }
440
+ export interface EmbeddedOptions<Owner, Target> extends PropertyOptions<Owner> {
441
+ entity?: string | (() => EntityName<Target> | EntityName<Target>[]);
442
+ prefix?: string | boolean;
443
+ prefixMode?: EmbeddedPrefixMode;
444
+ object?: boolean;
445
+ array?: boolean;
446
+ }
447
+ export interface EmbeddableOptions<Owner> {
448
+ /** Specify constructor parameters to be used in `em.create` or when `forceConstructor` is enabled. Those should be names of declared entity properties in the same order as your constructor uses them. The ORM tries to infer those automatically, use this option in case the inference fails. */
449
+ constructorParams?: (Owner extends EntityClass<infer P> ? keyof P : string)[];
450
+ discriminatorColumn?: (Owner extends EntityClass<infer P> ? keyof P : string) | AnyString;
451
+ discriminatorMap?: Dictionary<string>;
452
+ discriminatorValue?: number | string;
453
+ abstract?: boolean;
454
+ }
455
+ export interface EnumOptions<T> extends PropertyOptions<T> {
456
+ items?: (number | string)[] | (() => Dictionary);
457
+ array?: boolean;
458
+ /** for postgres, by default it uses text column with check constraint */
459
+ nativeEnumName?: string;
460
+ }
461
+ export interface PrimaryKeyOptions<T> extends PropertyOptions<T> {
462
+ }
463
+ export interface SerializedPrimaryKeyOptions<T> extends PropertyOptions<T> {
464
+ type?: any;
465
+ }
466
+ type MaybeArray<T> = T | T[];
467
+ type Properties<T, H extends string> = MaybeArray<AutoPath<T, H>>;
468
+ interface BaseOptions<T, H extends string> {
469
+ name?: string;
470
+ properties?: (T extends EntityClass<infer P> ? Properties<P, H> : Properties<T, H>);
471
+ options?: Dictionary;
472
+ expression?: string | (T extends EntityClass<infer P> ? IndexCallback<P> : IndexCallback<T>);
473
+ }
474
+ export interface UniqueOptions<T, H extends string = string> extends BaseOptions<T, H> {
475
+ deferMode?: DeferMode | `${DeferMode}`;
476
+ }
477
+ export interface IndexOptions<T, H extends string = string> extends BaseOptions<T, H> {
478
+ type?: string;
479
+ }
480
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -12,7 +12,11 @@ export declare abstract class AbstractNamingStrategy implements NamingStrategy {
12
12
  /**
13
13
  * @inheritDoc
14
14
  */
15
- getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
15
+ getEnumClassName(columnName: string, tableName: string | undefined, schemaName?: string): string;
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ getEnumTypeName(columnName: string, tableName: string | undefined, schemaName?: string): string;
16
20
  /**
17
21
  * @inheritDoc
18
22
  */
@@ -14,7 +14,7 @@ export class AbstractNamingStrategy {
14
14
  return migrationName;
15
15
  }
16
16
  indexName(tableName, columns, type) {
17
- /* v8 ignore next 3 */
17
+ /* v8 ignore next */
18
18
  if (tableName.includes('.')) {
19
19
  tableName = tableName.substring(tableName.indexOf('.') + 1);
20
20
  }
@@ -48,7 +48,13 @@ export class AbstractNamingStrategy {
48
48
  * @inheritDoc
49
49
  */
50
50
  getEnumClassName(columnName, tableName, schemaName) {
51
- return this.getEntityName(`${tableName}_${columnName}`, schemaName);
51
+ return this.getEntityName(tableName ? `${tableName}_${columnName}` : columnName, schemaName);
52
+ }
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ getEnumTypeName(columnName, tableName, schemaName) {
57
+ return 'T' + this.getEnumClassName(columnName, tableName, schemaName);
52
58
  }
53
59
  /**
54
60
  * @inheritDoc
@@ -25,7 +25,17 @@ export interface NamingStrategy {
25
25
  *
26
26
  * @return A new class name that will be used for the enum.
27
27
  */
28
- getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
28
+ getEnumClassName(columnName: string, tableName: string | undefined, schemaName?: string): string;
29
+ /**
30
+ * Get an enum type name. Used with `enumType: 'dictionary'` and `enumType: 'union-type'` entity generator option.
31
+ *
32
+ * @param columnName The column name which has the enum.
33
+ * @param tableName The table name of the column.
34
+ * @param schemaName The schema name of the column.
35
+ *
36
+ * @return A new type name that will be used for the enum.
37
+ */
38
+ getEnumTypeName(columnName: string, tableName: string | undefined, schemaName?: string): string;
29
39
  /**
30
40
  * Get an enum option name for a given enum value.
31
41
  *
@@ -0,0 +1,2 @@
1
+ export declare function discoverEntities(): void;
2
+ export declare const fs: {};
@@ -0,0 +1,4 @@
1
+ export function discoverEntities() {
2
+ throw new Error('Folder-based discovery is not supported in this environment.');
3
+ }
4
+ export const fs = new Proxy({}, { get: () => { throw new Error('File system is not supported in this environment.'); } });
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.8",
4
+ "version": "7.0.0-dev.80",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
8
- ".": "./index.js"
8
+ ".": "./index.js",
9
+ "./file-discovery": {
10
+ "node": "./metadata/discover-entities.js",
11
+ "browser": "./not-supported.js"
12
+ },
13
+ "./fs-utils": {
14
+ "node": "./utils/fs-utils.js",
15
+ "browser": "./not-supported.js"
16
+ }
9
17
  },
10
18
  "repository": {
11
19
  "type": "git",
@@ -39,7 +47,7 @@
39
47
  },
40
48
  "homepage": "https://mikro-orm.io",
41
49
  "engines": {
42
- "node": ">= 22.11.0"
50
+ "node": ">= 22.17.0"
43
51
  },
44
52
  "scripts": {
45
53
  "build": "yarn clean && yarn compile && yarn copy",
@@ -50,12 +58,12 @@
50
58
  "publishConfig": {
51
59
  "access": "public"
52
60
  },
53
- "dependencies": {
54
- "dataloader": "2.2.3",
55
- "dotenv": "16.4.7",
56
- "esprima": "4.0.1",
57
- "globby": "11.1.0",
58
- "mikro-orm": "7.0.0-dev.8",
59
- "reflect-metadata": "0.2.2"
61
+ "peerDependencies": {
62
+ "dataloader": "2.2.3"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "dataloader": {
66
+ "optional": true
67
+ }
60
68
  }
61
69
  }
@@ -1,6 +1,6 @@
1
1
  import { DriverException } from '../exceptions.js';
2
2
  export class ExceptionConverter {
3
- /* v8 ignore next 3 */
3
+ /* v8 ignore next */
4
4
  convertException(exception) {
5
5
  return new DriverException(exception);
6
6
  }