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

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 +23 -11
  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,65 @@
1
+ import { Utils } from '../utils/Utils.js';
2
+ import { ValidationError } from '../errors.js';
3
+ import { isRaw } from '../utils/RawQueryFragment.js';
4
+ import { SCALAR_TYPES } from '../enums.js';
5
+ /** @internal */
6
+ export function validateProperty(prop, givenValue, entity) {
7
+ if (givenValue == null || isRaw(givenValue)) {
8
+ return;
9
+ }
10
+ const expectedType = prop.runtimeType;
11
+ const propName = prop.embedded ? prop.name.replace(/~/g, '.') : prop.name;
12
+ const givenType = Utils.getObjectType(givenValue);
13
+ if (prop.enum && prop.items) {
14
+ /* v8 ignore next */
15
+ if (!prop.items.some(it => it === givenValue)) {
16
+ throw ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
17
+ }
18
+ }
19
+ else {
20
+ if (givenType !== expectedType && SCALAR_TYPES.has(expectedType)) {
21
+ throw ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
22
+ }
23
+ }
24
+ }
25
+ function getValue(o, prop) {
26
+ if (prop.embedded && prop.embedded[0] in o) {
27
+ return o[prop.embedded[0]]?.[prop.embedded[1]];
28
+ }
29
+ /* v8 ignore next */
30
+ if (prop.ref) {
31
+ return o[prop.name]?.unwrap();
32
+ }
33
+ return o[prop.name];
34
+ }
35
+ /** @internal */
36
+ export function validateEntity(entity, meta) {
37
+ for (const prop of meta.validateProps) {
38
+ validateProperty(prop, getValue(entity, prop), entity);
39
+ }
40
+ }
41
+ /** @internal */
42
+ export function validateParams(params, type = 'search condition', field) {
43
+ if (Utils.isPrimaryKey(params) || Utils.isEntity(params)) {
44
+ return;
45
+ }
46
+ if (Array.isArray(params)) {
47
+ return params.forEach(item => validateParams(item, type, field));
48
+ }
49
+ if (Utils.isPlainObject(params)) {
50
+ Object.keys(params).forEach(k => validateParams(params[k], type, k));
51
+ }
52
+ }
53
+ /** @internal */
54
+ export function validatePrimaryKey(entity, meta) {
55
+ const pkExists = meta.primaryKeys.every(pk => entity[pk] != null) || (meta.serializedPrimaryKey && entity[meta.serializedPrimaryKey] != null);
56
+ if (!entity || !pkExists) {
57
+ throw ValidationError.fromMergeWithoutPK(meta);
58
+ }
59
+ }
60
+ /** @internal */
61
+ export function validateEmptyWhere(where) {
62
+ if (Utils.isEmpty(where)) {
63
+ throw new Error(`You cannot call 'EntityManager.findOne()' with empty 'where' parameter`);
64
+ }
65
+ }
package/enums.d.ts CHANGED
@@ -66,7 +66,7 @@ export declare enum QueryOrderNumeric {
66
66
  ASC = 1,
67
67
  DESC = -1
68
68
  }
69
- export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric | keyof typeof QueryOrder;
69
+ export type QueryOrderKeysFlat = QueryOrder | QueryOrderNumeric | `${QueryOrder}`;
70
70
  export type QueryOrderKeys<T> = QueryOrderKeysFlat | QueryOrderMap<T>;
71
71
  export type QueryOrderMap<T> = {
72
72
  [K in EntityKey<T>]?: QueryOrderKeys<ExpandProperty<T[K]>>;
@@ -85,9 +85,11 @@ export declare enum QueryFlag {
85
85
  INCLUDE_LAZY_FORMULAS = "INCLUDE_LAZY_FORMULAS",
86
86
  AUTO_JOIN_ONE_TO_ONE_OWNER = "AUTO_JOIN_ONE_TO_ONE_OWNER",
87
87
  INFER_POPULATE = "INFER_POPULATE",
88
- IDENTITY_INSERT = "IDENTITY_INSERT"
88
+ DISABLE_NESTED_INNER_JOIN = "DISABLE_NESTED_INNER_JOIN",
89
+ IDENTITY_INSERT = "IDENTITY_INSERT",// mssql only
90
+ OUTPUT_TABLE = "OUTPUT_TABLE"
89
91
  }
90
- export declare const SCALAR_TYPES: string[];
92
+ export declare const SCALAR_TYPES: Set<string>;
91
93
  export declare enum ReferenceKind {
92
94
  SCALAR = "scalar",
93
95
  ONE_TO_ONE = "1:1",
@@ -108,7 +110,8 @@ export declare enum Cascade {
108
110
  }
109
111
  export declare enum LoadStrategy {
110
112
  SELECT_IN = "select-in",
111
- JOINED = "joined"
113
+ JOINED = "joined",
114
+ BALANCED = "balanced"
112
115
  }
113
116
  export declare enum DataloaderType {
114
117
  NONE = 0,
@@ -156,12 +159,22 @@ export declare enum EventType {
156
159
  }
157
160
  export declare const EventTypeMap: Record<EventType, number>;
158
161
  export type TransactionEventType = EventType.beforeTransactionStart | EventType.afterTransactionStart | EventType.beforeTransactionCommit | EventType.afterTransactionCommit | EventType.beforeTransactionRollback | EventType.afterTransactionRollback;
162
+ export declare enum TransactionPropagation {
163
+ REQUIRED = "required",
164
+ REQUIRES_NEW = "requires_new",
165
+ NESTED = "nested",
166
+ NOT_SUPPORTED = "not_supported",
167
+ SUPPORTS = "supports",
168
+ MANDATORY = "mandatory",
169
+ NEVER = "never"
170
+ }
159
171
  export interface TransactionOptions {
160
172
  ctx?: Transaction;
161
- isolationLevel?: IsolationLevel;
173
+ propagation?: TransactionPropagation | `${TransactionPropagation}`;
174
+ isolationLevel?: IsolationLevel | `${IsolationLevel}`;
162
175
  readOnly?: boolean;
163
176
  clear?: boolean;
164
- flushMode?: FlushMode;
177
+ flushMode?: FlushMode | `${FlushMode}`;
165
178
  ignoreNestedTransactions?: boolean;
166
179
  loggerContext?: LogContext;
167
180
  }
@@ -171,3 +184,5 @@ export declare enum DeferMode {
171
184
  INITIALLY_IMMEDIATE = "immediate",
172
185
  INITIALLY_DEFERRED = "deferred"
173
186
  }
187
+ /** With `absolute` the prefix is set at the root of the entity (regardless of the nesting level) */
188
+ export type EmbeddedPrefixMode = 'absolute' | 'relative';
package/enums.js CHANGED
@@ -95,9 +95,11 @@ export var QueryFlag;
95
95
  QueryFlag["INCLUDE_LAZY_FORMULAS"] = "INCLUDE_LAZY_FORMULAS";
96
96
  QueryFlag["AUTO_JOIN_ONE_TO_ONE_OWNER"] = "AUTO_JOIN_ONE_TO_ONE_OWNER";
97
97
  QueryFlag["INFER_POPULATE"] = "INFER_POPULATE";
98
+ QueryFlag["DISABLE_NESTED_INNER_JOIN"] = "DISABLE_NESTED_INNER_JOIN";
98
99
  QueryFlag["IDENTITY_INSERT"] = "IDENTITY_INSERT";
100
+ QueryFlag["OUTPUT_TABLE"] = "OUTPUT_TABLE";
99
101
  })(QueryFlag || (QueryFlag = {}));
100
- export const SCALAR_TYPES = ['string', 'number', 'boolean', 'bigint', 'Date', 'Buffer', 'RegExp'];
102
+ export const SCALAR_TYPES = new Set(['string', 'number', 'boolean', 'bigint', 'Uint8Array', 'Date', 'Buffer', 'RegExp']);
101
103
  export var ReferenceKind;
102
104
  (function (ReferenceKind) {
103
105
  ReferenceKind["SCALAR"] = "scalar";
@@ -122,6 +124,7 @@ export var LoadStrategy;
122
124
  (function (LoadStrategy) {
123
125
  LoadStrategy["SELECT_IN"] = "select-in";
124
126
  LoadStrategy["JOINED"] = "joined";
127
+ LoadStrategy["BALANCED"] = "balanced";
125
128
  })(LoadStrategy || (LoadStrategy = {}));
126
129
  export var DataloaderType;
127
130
  (function (DataloaderType) {
@@ -175,6 +178,16 @@ export const EventTypeMap = Object.keys(EventType).reduce((a, b, i) => {
175
178
  a[b] = i;
176
179
  return a;
177
180
  }, {});
181
+ export var TransactionPropagation;
182
+ (function (TransactionPropagation) {
183
+ TransactionPropagation["REQUIRED"] = "required";
184
+ TransactionPropagation["REQUIRES_NEW"] = "requires_new";
185
+ TransactionPropagation["NESTED"] = "nested";
186
+ TransactionPropagation["NOT_SUPPORTED"] = "not_supported";
187
+ TransactionPropagation["SUPPORTS"] = "supports";
188
+ TransactionPropagation["MANDATORY"] = "mandatory";
189
+ TransactionPropagation["NEVER"] = "never";
190
+ })(TransactionPropagation || (TransactionPropagation = {}));
178
191
  export class PlainObject {
179
192
  }
180
193
  export var DeferMode;
package/errors.d.ts CHANGED
@@ -8,7 +8,6 @@ export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Er
8
8
  getEntity(): AnyEntity | undefined;
9
9
  static fromWrongPropertyType(entity: AnyEntity, property: string, expectedType: string, givenType: string, givenValue: string): ValidationError;
10
10
  static fromWrongRepositoryType(entityName: string, repoType: string, method: string): ValidationError;
11
- static fromCollectionNotInitialized(entity: AnyEntity, prop: EntityProperty): ValidationError;
12
11
  static fromMergeWithoutPK(meta: EntityMetadata): ValidationError;
13
12
  static transactionRequired(): ValidationError;
14
13
  static entityNotManaged(entity: AnyEntity): ValidationError;
@@ -24,6 +23,7 @@ export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Er
24
23
  static cannotCommit(): ValidationError;
25
24
  static cannotUseGlobalContext(): ValidationError;
26
25
  static cannotUseOperatorsInsideEmbeddables(className: string, propName: string, payload: unknown): ValidationError;
26
+ static cannotUseGroupOperatorsInsideScalars(className: string, propName: string, payload: unknown): ValidationError;
27
27
  static invalidEmbeddableQuery(className: string, propName: string, embeddableType: string): ValidationError;
28
28
  }
29
29
  export declare class CursorError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
@@ -43,7 +43,6 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
43
43
  static fromWrongOwnership(meta: EntityMetadata, prop: EntityProperty, key: 'inversedBy' | 'mappedBy'): MetadataError;
44
44
  static fromWrongReferenceKind(meta: EntityMetadata, owner: EntityProperty, prop: EntityProperty): MetadataError;
45
45
  static fromInversideSidePrimary(meta: EntityMetadata, owner: EntityProperty, prop: EntityProperty): MetadataError;
46
- static entityNotFound(name: string, path: string): MetadataError;
47
46
  static unknownIndexProperty(meta: EntityMetadata, prop: string, type: string): MetadataError;
48
47
  static multipleVersionFields(meta: EntityMetadata, fields: string[]): MetadataError;
49
48
  static invalidVersionFieldType(meta: EntityMetadata): MetadataError;
@@ -66,3 +65,8 @@ export declare class NotFoundError<T extends AnyEntity = AnyEntity> extends Vali
66
65
  static findOneFailed(name: string, where: Dictionary | IPrimaryKey): NotFoundError;
67
66
  static findExactlyOneFailed(name: string, where: Dictionary | IPrimaryKey): NotFoundError;
68
67
  }
68
+ export declare class TransactionStateError extends ValidationError {
69
+ static requiredTransactionNotFound(propagation: string): TransactionStateError;
70
+ static transactionNotAllowed(propagation: string): TransactionStateError;
71
+ static invalidPropagation(propagation: string): TransactionStateError;
72
+ }
package/errors.js CHANGED
@@ -23,11 +23,6 @@ export class ValidationError extends Error {
23
23
  const msg = `Trying to use EntityRepository.${method}() with '${entityName}' entity while the repository is of type '${repoType}'`;
24
24
  return new ValidationError(msg);
25
25
  }
26
- static fromCollectionNotInitialized(entity, prop) {
27
- const entityName = entity.constructor.name;
28
- const msg = `${entityName}.${prop.name} is not initialized, define it as '${prop.name} = new Collection<${prop.type}>(this);'`;
29
- return new ValidationError(msg);
30
- }
31
26
  static fromMergeWithoutPK(meta) {
32
27
  return new ValidationError(`You cannot merge entity '${meta.className}' without identifier!`);
33
28
  }
@@ -94,6 +89,9 @@ export class ValidationError extends Error {
94
89
  static cannotUseOperatorsInsideEmbeddables(className, propName, payload) {
95
90
  return new ValidationError(`Using operators inside embeddables is not allowed, move the operator above. (property: ${className}.${propName}, payload: ${inspect(payload)})`);
96
91
  }
92
+ static cannotUseGroupOperatorsInsideScalars(className, propName, payload) {
93
+ return new ValidationError(`Using group operators ($and/$or) inside scalar properties is not allowed, move the operator above. (property: ${className}.${propName}, payload: ${inspect(payload)})`);
94
+ }
97
95
  static invalidEmbeddableQuery(className, propName, embeddableType) {
98
96
  return new ValidationError(`Invalid query for entity '${className}', property '${propName}' does not exist in embeddable '${embeddableType}'`);
99
97
  }
@@ -151,10 +149,6 @@ export class MetadataError extends ValidationError {
151
149
  static fromInversideSidePrimary(meta, owner, prop) {
152
150
  return new MetadataError(`${meta.className}.${prop.name} cannot be primary key as it is defined as inverse side. Maybe you should swap the use of 'inversedBy' and 'mappedBy'.`);
153
151
  }
154
- /* v8 ignore next 3 */
155
- static entityNotFound(name, path) {
156
- return new MetadataError(`Entity '${name}' not found in ${path}`);
157
- }
158
152
  static unknownIndexProperty(meta, prop, type) {
159
153
  return new MetadataError(`Entity ${meta.className} has wrong ${type} definition: '${prop}' does not exist. You need to use property name, not column name.`);
160
154
  }
@@ -220,3 +214,14 @@ export class NotFoundError extends ValidationError {
220
214
  return new NotFoundError(`Wrong number of ${name} entities found for query ${inspect(where)}, expected exactly one`);
221
215
  }
222
216
  }
217
+ export class TransactionStateError extends ValidationError {
218
+ static requiredTransactionNotFound(propagation) {
219
+ return new TransactionStateError(`No existing transaction found for transaction marked with propagation "${propagation}"`);
220
+ }
221
+ static transactionNotAllowed(propagation) {
222
+ return new TransactionStateError(`Existing transaction found for transaction marked with propagation "${propagation}"`);
223
+ }
224
+ static invalidPropagation(propagation) {
225
+ return new TransactionStateError(`Unsupported transaction propagation type: ${propagation}`);
226
+ }
227
+ }
@@ -13,7 +13,9 @@ export interface FlushEventArgs extends Omit<EventArgs<any>, 'entity' | 'changeS
13
13
  uow: UnitOfWork;
14
14
  }
15
15
  export interface TransactionEventArgs extends Omit<EventArgs<any>, 'entity' | 'meta' | 'changeSet'> {
16
- transaction?: Transaction;
16
+ transaction?: Transaction & {
17
+ savepointName?: string;
18
+ };
17
19
  uow?: UnitOfWork;
18
20
  }
19
21
  export interface EventSubscriber<T = any> {
@@ -1,4 +1,4 @@
1
- /* v8 ignore start */
1
+ /* v8 ignore next */
2
2
  export class Hydrator {
3
3
  metadata;
4
4
  platform;
@@ -45,4 +45,3 @@ export class Hydrator {
45
45
  entity[prop.name] = data[prop.name];
46
46
  }
47
47
  }
48
- /* v8 ignore stop */
@@ -1,22 +1,22 @@
1
1
  import type { EntityData, EntityMetadata } from '../typings.js';
2
2
  import { Hydrator } from './Hydrator.js';
3
3
  import type { EntityFactory } from '../entity/EntityFactory.js';
4
- type EntityHydrator<T extends object> = (entity: T, data: EntityData<T>, factory: EntityFactory, newEntity: boolean, convertCustomTypes: boolean, schema?: string, parentSchema?: string) => void;
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
5
  export declare class ObjectHydrator extends Hydrator {
6
6
  private readonly hydrators;
7
7
  private tmpIndex;
8
8
  /**
9
9
  * @inheritDoc
10
10
  */
11
- hydrate<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, type: 'full' | 'reference', newEntity?: boolean, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
11
+ hydrate<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, type: 'full' | 'reference', newEntity?: boolean, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
12
12
  /**
13
13
  * @inheritDoc
14
14
  */
15
- hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
15
+ hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
16
16
  /**
17
17
  * @internal Highly performance-sensitive method.
18
18
  */
19
- getEntityHydrator<T extends object>(meta: EntityMetadata<T>, type: 'full' | 'reference'): EntityHydrator<T>;
19
+ getEntityHydrator<T extends object>(meta: EntityMetadata<T>, type: 'full' | 'reference', normalizeAccessors?: boolean): EntityHydrator<T>;
20
20
  private createCollectionItemMapper;
21
21
  private wrap;
22
22
  private safeKey;
@@ -6,37 +6,40 @@ import { ReferenceKind } from '../enums.js';
6
6
  import { RawQueryFragment } from '../utils/RawQueryFragment.js';
7
7
  export class ObjectHydrator extends Hydrator {
8
8
  hydrators = {
9
- full: new Map(),
10
- reference: new Map(),
9
+ 'full~true': new Map(),
10
+ 'full~false': new Map(),
11
+ 'reference~true': new Map(),
12
+ 'reference~false': new Map(),
11
13
  };
12
14
  tmpIndex = 0;
13
15
  /**
14
16
  * @inheritDoc
15
17
  */
16
- hydrate(entity, meta, data, factory, type, newEntity = false, convertCustomTypes = false, schema, parentSchema) {
17
- const hydrate = this.getEntityHydrator(meta, type);
18
+ hydrate(entity, meta, data, factory, type, newEntity = false, convertCustomTypes = false, schema, parentSchema, normalizeAccessors) {
19
+ const hydrate = this.getEntityHydrator(meta, type, normalizeAccessors);
18
20
  const running = this.running;
19
21
  // the running state is used to consider propagation as hydration, saving the values directly to the entity data,
20
22
  // but we don't want that for new entities, their propagation should result in entity updates when flushing
21
23
  this.running = !newEntity;
22
- Utils.callCompiledFunction(hydrate, entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema);
24
+ Utils.callCompiledFunction(hydrate, entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema, normalizeAccessors);
23
25
  this.running = running;
24
26
  }
25
27
  /**
26
28
  * @inheritDoc
27
29
  */
28
- hydrateReference(entity, meta, data, factory, convertCustomTypes = false, schema, parentSchema) {
29
- const hydrate = this.getEntityHydrator(meta, 'reference');
30
+ hydrateReference(entity, meta, data, factory, convertCustomTypes = false, schema, parentSchema, normalizeAccessors) {
31
+ const hydrate = this.getEntityHydrator(meta, 'reference', normalizeAccessors);
30
32
  const running = this.running;
31
33
  this.running = true;
32
- Utils.callCompiledFunction(hydrate, entity, data, factory, false, convertCustomTypes, schema, parentSchema);
34
+ Utils.callCompiledFunction(hydrate, entity, data, factory, false, convertCustomTypes, schema, parentSchema, normalizeAccessors);
33
35
  this.running = running;
34
36
  }
35
37
  /**
36
38
  * @internal Highly performance-sensitive method.
37
39
  */
38
- getEntityHydrator(meta, type) {
39
- const exists = this.hydrators[type].get(meta.className);
40
+ getEntityHydrator(meta, type, normalizeAccessors = false) {
41
+ const key = `${type}~${normalizeAccessors}`;
42
+ const exists = this.hydrators[key].get(meta.className);
40
43
  if (exists) {
41
44
  return exists;
42
45
  }
@@ -48,7 +51,7 @@ export class ObjectHydrator extends Hydrator {
48
51
  context.set('Reference', Reference);
49
52
  const registerCustomType = (prop, convertorKey, method, context) => {
50
53
  context.set(`${method}_${convertorKey}`, (val) => {
51
- /* v8 ignore next 3 */
54
+ /* v8 ignore next */
52
55
  if (RawQueryFragment.isKnownFragment(val)) {
53
56
  return val;
54
57
  }
@@ -63,7 +66,7 @@ export class ObjectHydrator extends Hydrator {
63
66
  const ret = [];
64
67
  const idx = this.tmpIndex++;
65
68
  const nullVal = this.config.get('forceUndefined') ? 'undefined' : 'null';
66
- if (prop.getter && !prop.setter) {
69
+ if (prop.getter && !prop.setter && prop.persist === false) {
67
70
  return [];
68
71
  }
69
72
  if (prop.ref) {
@@ -71,7 +74,14 @@ export class ObjectHydrator extends Hydrator {
71
74
  ret.push(` const oldValue_${idx} = entity${entityKey};`);
72
75
  }
73
76
  ret.push(` if (data${dataKey} === null) {`);
74
- ret.push(` entity${entityKey} = ${nullVal};`);
77
+ if (prop.ref) {
78
+ ret.push(` entity${entityKey} = new ScalarReference();`);
79
+ ret.push(` entity${entityKey}.bind(entity, '${prop.name}');`);
80
+ ret.push(` entity${entityKey}.set(${nullVal});`);
81
+ }
82
+ else {
83
+ ret.push(` entity${entityKey} = ${nullVal};`);
84
+ }
75
85
  ret.push(` } else if (typeof data${dataKey} !== 'undefined') {`);
76
86
  if (prop.customType) {
77
87
  registerCustomType(prop, convertorKey, 'convertToJSValue', context);
@@ -126,17 +136,17 @@ export class ObjectHydrator extends Hydrator {
126
136
  ret.push(` } else if (typeof data${dataKey} !== 'undefined') {`);
127
137
  ret.push(` if (isPrimaryKey(data${dataKey}, true)) {`);
128
138
  if (prop.ref) {
129
- ret.push(` entity${entityKey} = Reference.create(factory.createReference('${prop.type}', data${dataKey}, { merge: true, convertCustomTypes, schema }));`);
139
+ ret.push(` entity${entityKey} = Reference.create(factory.createReference('${prop.type}', data${dataKey}, { merge: true, convertCustomTypes, normalizeAccessors, schema }));`);
130
140
  }
131
141
  else {
132
- ret.push(` entity${entityKey} = factory.createReference('${prop.type}', data${dataKey}, { merge: true, convertCustomTypes, schema });`);
142
+ ret.push(` entity${entityKey} = factory.createReference('${prop.type}', data${dataKey}, { merge: true, convertCustomTypes, normalizeAccessors, schema });`);
133
143
  }
134
144
  ret.push(` } else if (data${dataKey} && typeof data${dataKey} === 'object') {`);
135
145
  if (prop.ref) {
136
- ret.push(` entity${entityKey} = Reference.create(factory.${method}('${prop.type}', data${dataKey}, { initialized: true, merge: true, newEntity, convertCustomTypes, schema }));`);
146
+ ret.push(` entity${entityKey} = Reference.create(factory.${method}('${prop.type}', data${dataKey}, { initialized: true, merge: true, newEntity, convertCustomTypes, normalizeAccessors, schema }));`);
137
147
  }
138
148
  else {
139
- ret.push(` entity${entityKey} = factory.${method}('${prop.type}', data${dataKey}, { initialized: true, merge: true, newEntity, convertCustomTypes, schema });`);
149
+ ret.push(` entity${entityKey} = factory.${method}('${prop.type}', data${dataKey}, { initialized: true, merge: true, newEntity, convertCustomTypes, normalizeAccessors, schema });`);
140
150
  }
141
151
  ret.push(` }`);
142
152
  ret.push(` }`);
@@ -245,7 +255,7 @@ export class ObjectHydrator extends Hydrator {
245
255
  // weak comparison as we can have numbers that might have been converted to strings due to being object keys
246
256
  ret.push(` if (data${childDataKey} == '${childMeta.discriminatorValue}') {`);
247
257
  ret.push(` if (entity${entityKey} == null) {`);
248
- ret.push(` entity${entityKey} = factory.createEmbeddable('${childMeta.className}', embeddedData, { newEntity, convertCustomTypes });`);
258
+ ret.push(` entity${entityKey} = factory.createEmbeddable('${childMeta.className}', embeddedData, { newEntity, convertCustomTypes, normalizeAccessors });`);
249
259
  ret.push(` }`);
250
260
  meta.props
251
261
  .filter(p => p.embedded?.[0] === prop.name)
@@ -256,6 +266,7 @@ export class ObjectHydrator extends Hydrator {
256
266
  ...prop2,
257
267
  name: childProp.name,
258
268
  embedded: childProp.embedded,
269
+ embeddedProps: childProp.embeddedProps,
259
270
  };
260
271
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
261
272
  ret.push(...hydrateProperty(prop3, childProp.object, [...path, childProp.embedded[1]], childDataKey).map(l => ' ' + l));
@@ -265,7 +276,7 @@ export class ObjectHydrator extends Hydrator {
265
276
  }
266
277
  else {
267
278
  ret.push(` if (entity${entityKey} == null) {`);
268
- ret.push(` entity${entityKey} = factory.createEmbeddable('${prop.targetMeta.className}', embeddedData, { newEntity, convertCustomTypes });`);
279
+ ret.push(` entity${entityKey} = factory.createEmbeddable('${prop.targetMeta.className}', embeddedData, { newEntity, convertCustomTypes, normalizeAccessors });`);
269
280
  ret.push(` }`);
270
281
  meta.props
271
282
  .filter(p => p.embedded?.[0] === prop.name)
@@ -303,7 +314,7 @@ export class ObjectHydrator extends Hydrator {
303
314
  };
304
315
  const hydrateProperty = (prop, object = prop.object, path = [prop.name], dataKey) => {
305
316
  const entityKey = path.map(k => this.wrap(k)).join('');
306
- dataKey = dataKey ?? (object ? entityKey : this.wrap(prop.name));
317
+ dataKey = dataKey ?? (object ? entityKey : this.wrap(normalizeAccessors ? (prop.accessor ?? prop.name) : prop.name));
307
318
  const ret = [];
308
319
  if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && !prop.mapToPk) {
309
320
  ret.push(...hydrateToOne(prop, dataKey, entityKey));
@@ -333,11 +344,11 @@ export class ObjectHydrator extends Hydrator {
333
344
  for (const prop of props) {
334
345
  lines.push(...hydrateProperty(prop));
335
346
  }
336
- const code = `// compiled hydrator for entity ${meta.className} (${type})\n`
337
- + `return function(entity, data, factory, newEntity, convertCustomTypes, schema) {\n`
347
+ const code = `// compiled hydrator for entity ${meta.className} (${type + normalizeAccessors ? ' normalized' : ''})\n`
348
+ + `return function(entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema, normalizeAccessors) {\n`
338
349
  + `${lines.join('\n')}\n}`;
339
350
  const hydrator = Utils.createFunction(context, code);
340
- this.hydrators[type].set(meta.className, hydrator);
351
+ this.hydrators[key].set(meta.className, hydrator);
341
352
  return hydrator;
342
353
  }
343
354
  createCollectionItemMapper(prop) {
@@ -350,9 +361,9 @@ export class ObjectHydrator extends Hydrator {
350
361
  lines.push(` value = { ...value, ['${prop2.name}']: Reference.wrapReference(entity, { ref: ${prop2.ref} }) };`);
351
362
  lines.push(` }`);
352
363
  }
353
- lines.push(` if (isPrimaryKey(value, ${meta.compositePK})) return factory.createReference('${prop.type}', value, { convertCustomTypes, schema, merge: true });`);
364
+ lines.push(` if (isPrimaryKey(value, ${meta.compositePK})) return factory.createReference('${prop.type}', value, { convertCustomTypes, schema, normalizeAccessors, merge: true });`);
354
365
  lines.push(` if (value && value.__entity) return value;`);
355
- lines.push(` return factory.create('${prop.type}', value, { newEntity, convertCustomTypes, schema, merge: true });`);
366
+ lines.push(` return factory.create('${prop.type}', value, { newEntity, convertCustomTypes, schema, normalizeAccessors, merge: true });`);
356
367
  lines.push(` }`);
357
368
  return lines;
358
369
  }
package/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * @packageDocumentation
3
3
  * @module core
4
4
  */
5
- export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings.js';
5
+ export { EntityMetadata, PrimaryKeyProp, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config } from './typings.js';
6
+ export type { Constructor, ConnectionType, Dictionary, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, RequiredEntityData, CheckCallback, IndexCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, EntityDataValue, FilterKey, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, FilterValue, MergeLoaded, MergeSelected, TypeConfig, AnyString, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, RequiredNullable, DefineConfig, Opt, Hidden, EntitySchemaWithMeta, InferEntity, CheckConstraint, GeneratedColumnCallback, FilterDef, } from './typings.js';
6
7
  export * from './enums.js';
7
8
  export * from './errors.js';
8
9
  export * from './exceptions.js';
@@ -22,4 +23,3 @@ export * from './types/index.js';
22
23
  export * from './naming-strategy/index.js';
23
24
  export * from './metadata/index.js';
24
25
  export * from './cache/index.js';
25
- export * from './decorators/index.js';
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @packageDocumentation
3
3
  * @module core
4
4
  */
5
- export { PrimaryKeyProp, EntityMetadata, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config, } from './typings.js';
5
+ export { EntityMetadata, PrimaryKeyProp, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config } from './typings.js';
6
6
  export * from './enums.js';
7
7
  export * from './errors.js';
8
8
  export * from './exceptions.js';
@@ -22,4 +22,3 @@ export * from './types/index.js';
22
22
  export * from './naming-strategy/index.js';
23
23
  export * from './metadata/index.js';
24
24
  export * from './cache/index.js';
25
- export * from './decorators/index.js';
@@ -29,5 +29,5 @@ export declare class DefaultLogger implements Logger {
29
29
  logQuery(context: {
30
30
  query: string;
31
31
  } & LogContext): void;
32
- static create(options: LoggerOptions): DefaultLogger;
32
+ static create(this: void, options: LoggerOptions): DefaultLogger;
33
33
  }
@@ -14,5 +14,5 @@ export declare class SimpleLogger extends DefaultLogger {
14
14
  logQuery(context: {
15
15
  query: string;
16
16
  } & LogContext): void;
17
- static create(options: LoggerOptions): SimpleLogger;
17
+ static create(this: void, options: LoggerOptions): SimpleLogger;
18
18
  }
@@ -1,15 +1,7 @@
1
1
  import { EntityMetadata, type AnyEntity, type EntityKey, type Constructor, type DeepPartial, type EntityName, type EntityProperty, type CleanKeys, type ExpandProperty, type IsNever, type EntityClass } from '../typings.js';
2
- import type { EmbeddedOptions } from '../decorators/Embedded.js';
3
- import type { EnumOptions } from '../decorators/Enum.js';
4
- import type { IndexOptions, UniqueOptions } from '../decorators/Indexed.js';
5
- import type { ManyToManyOptions } from '../decorators/ManyToMany.js';
6
- import type { ManyToOneOptions } from '../decorators/ManyToOne.js';
7
- import type { OneToManyOptions } from '../decorators/OneToMany.js';
8
- import type { OneToOneOptions } from '../decorators/OneToOne.js';
9
- import type { PrimaryKeyOptions, SerializedPrimaryKeyOptions } from '../decorators/PrimaryKey.js';
10
- import type { PropertyOptions } from '../decorators/Property.js';
11
2
  import { ReferenceKind } from '../enums.js';
12
3
  import { Type } from '../types/Type.js';
4
+ import type { PropertyOptions, ManyToOneOptions, OneToOneOptions, OneToManyOptions, ManyToManyOptions, EmbeddedOptions, EnumOptions, PrimaryKeyOptions, SerializedPrimaryKeyOptions, IndexOptions, UniqueOptions } from './types.js';
13
5
  type TypeType = string | NumberConstructor | StringConstructor | BooleanConstructor | DateConstructor | ArrayConstructor | Constructor<Type<any>> | Type<any>;
14
6
  type TypeDef<Target> = {
15
7
  type: TypeType;
@@ -31,7 +23,7 @@ export type EntitySchemaProperty<Target, Owner> = ({
31
23
  kind: ReferenceKind.MANY_TO_MANY | 'm:n';
32
24
  } & TypeDef<Target> & ManyToManyOptions<Owner, Target>) | ({
33
25
  kind: ReferenceKind.EMBEDDED | 'embedded';
34
- } & EmbeddedTypeDef<Target> & EmbeddedOptions & PropertyOptions<Owner>) | ({
26
+ } & EmbeddedTypeDef<Target> & EmbeddedOptions<Owner, Target> & PropertyOptions<Owner>) | ({
35
27
  enum: true;
36
28
  } & EnumOptions<Owner>) | (TypeDef<Target> & PropertyOptions<Owner>);
37
29
  type OmitBaseProps<Entity, Base> = IsNever<Base> extends true ? Entity : Omit<Entity, keyof Base>;
@@ -41,7 +33,7 @@ export type EntitySchemaMetadata<Entity, Base = never> = Omit<Partial<EntityMeta
41
33
  class: EntityClass<Entity>;
42
34
  name?: string;
43
35
  }) & {
44
- extends?: string | EntitySchema<Base>;
36
+ extends?: EntityName<Base>;
45
37
  } & {
46
38
  properties?: {
47
39
  [Key in keyof OmitBaseProps<Entity, Base> as CleanKeys<OmitBaseProps<Entity, Base>, Key>]-?: EntitySchemaProperty<ExpandProperty<NonNullable<Entity[Key]>>, Entity>;
@@ -63,7 +55,7 @@ export declare class EntitySchema<Entity = any, Base = never> {
63
55
  addVersion(name: EntityKey<Entity>, type: TypeType, options?: PropertyOptions<Entity>): void;
64
56
  addPrimaryKey(name: EntityKey<Entity>, type: TypeType, options?: PrimaryKeyOptions<Entity>): void;
65
57
  addSerializedPrimaryKey(name: EntityKey<Entity>, type: TypeType, options?: SerializedPrimaryKeyOptions<Entity>): void;
66
- addEmbedded<Target = AnyEntity>(name: EntityKey<Entity>, options: EmbeddedOptions): void;
58
+ addEmbedded<Target = AnyEntity>(name: EntityKey<Entity>, options: EmbeddedOptions<Entity, Target>): void;
67
59
  addManyToOne<Target = AnyEntity>(name: EntityKey<Entity>, type: TypeType, options: ManyToOneOptions<Entity, Target>): void;
68
60
  addManyToMany<Target = AnyEntity>(name: EntityKey<Entity>, type: TypeType, options: ManyToManyOptions<Entity, Target>): void;
69
61
  addOneToMany<Target = AnyEntity>(name: EntityKey<Entity>, type: TypeType, options: OneToManyOptions<Entity, Target>): void;
@@ -71,10 +63,12 @@ export declare class EntitySchema<Entity = any, Base = never> {
71
63
  addIndex<Key extends string>(options: IndexOptions<Entity, Key>): void;
72
64
  addUnique<Key extends string>(options: UniqueOptions<Entity, Key>): void;
73
65
  setCustomRepository(repository: () => Constructor): void;
74
- setExtends(base: string | EntitySchema): void;
66
+ setExtends(base: EntityName<any>): void;
75
67
  setClass(proto: EntityClass<Entity>): void;
76
68
  get meta(): EntityMetadata<Entity>;
77
69
  get name(): EntityName<Entity>;
70
+ get tableName(): string;
71
+ get properties(): Record<string, any>;
78
72
  /**
79
73
  * @internal
80
74
  */
@@ -83,5 +77,7 @@ export declare class EntitySchema<Entity = any, Base = never> {
83
77
  private initPrimaryKeys;
84
78
  private normalizeType;
85
79
  private createProperty;
80
+ private rename;
81
+ private renameCompositeOptions;
86
82
  }
87
83
  export {};