@mikro-orm/core 7.0.0-dev.113 → 7.0.0-dev.115

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 (61) hide show
  1. package/EntityManager.d.ts +8 -8
  2. package/EntityManager.js +47 -69
  3. package/MikroORM.d.ts +1 -1
  4. package/MikroORM.js +2 -3
  5. package/drivers/DatabaseDriver.d.ts +11 -11
  6. package/drivers/DatabaseDriver.js +8 -9
  7. package/drivers/IDatabaseDriver.d.ts +12 -12
  8. package/entity/Collection.js +7 -6
  9. package/entity/EntityAssigner.js +9 -9
  10. package/entity/EntityFactory.js +14 -17
  11. package/entity/EntityHelper.d.ts +2 -2
  12. package/entity/EntityHelper.js +2 -2
  13. package/entity/EntityLoader.d.ts +3 -3
  14. package/entity/EntityLoader.js +22 -35
  15. package/entity/WrappedEntity.js +1 -1
  16. package/entity/defineEntity.d.ts +11 -11
  17. package/entity/validators.js +2 -2
  18. package/errors.d.ts +8 -8
  19. package/errors.js +14 -13
  20. package/hydration/ObjectHydrator.js +25 -18
  21. package/metadata/EntitySchema.d.ts +5 -5
  22. package/metadata/EntitySchema.js +23 -21
  23. package/metadata/MetadataDiscovery.d.ts +2 -3
  24. package/metadata/MetadataDiscovery.js +119 -92
  25. package/metadata/MetadataProvider.js +2 -0
  26. package/metadata/MetadataStorage.d.ts +13 -6
  27. package/metadata/MetadataStorage.js +64 -19
  28. package/metadata/MetadataValidator.d.ts +2 -2
  29. package/metadata/MetadataValidator.js +22 -28
  30. package/metadata/types.d.ts +3 -3
  31. package/package.json +1 -1
  32. package/platforms/Platform.js +2 -2
  33. package/serialization/EntitySerializer.js +2 -2
  34. package/serialization/EntityTransformer.js +6 -6
  35. package/serialization/SerializationContext.d.ts +6 -6
  36. package/typings.d.ts +19 -17
  37. package/typings.js +15 -10
  38. package/unit-of-work/ChangeSet.d.ts +2 -3
  39. package/unit-of-work/ChangeSet.js +2 -3
  40. package/unit-of-work/ChangeSetComputer.js +3 -3
  41. package/unit-of-work/ChangeSetPersister.js +14 -14
  42. package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
  43. package/unit-of-work/CommitOrderCalculator.js +13 -13
  44. package/unit-of-work/UnitOfWork.d.ts +3 -3
  45. package/unit-of-work/UnitOfWork.js +46 -45
  46. package/utils/AbstractSchemaGenerator.js +7 -7
  47. package/utils/Configuration.d.ts +0 -5
  48. package/utils/Cursor.js +3 -3
  49. package/utils/DataloaderUtils.js +13 -11
  50. package/utils/EntityComparator.d.ts +6 -6
  51. package/utils/EntityComparator.js +30 -27
  52. package/utils/QueryHelper.d.ts +6 -6
  53. package/utils/QueryHelper.js +18 -17
  54. package/utils/RawQueryFragment.d.ts +11 -12
  55. package/utils/RawQueryFragment.js +28 -55
  56. package/utils/TransactionManager.js +1 -1
  57. package/utils/Utils.d.ts +3 -1
  58. package/utils/Utils.js +10 -2
  59. package/utils/clone.js +7 -21
  60. package/utils/env-vars.js +0 -1
  61. package/utils/upsert-utils.d.ts +4 -4
@@ -8,7 +8,7 @@ import type { EntityManager } from '../EntityManager.js';
8
8
  import type { DriverException } from '../exceptions.js';
9
9
  import type { Configuration } from '../utils/Configuration.js';
10
10
  import type { LoggingOptions, LogContext } from '../logging/Logger.js';
11
- import type { RawQueryFragment } from '../utils/RawQueryFragment.js';
11
+ import type { Raw } from '../utils/RawQueryFragment.js';
12
12
  export declare const EntityManagerType: unique symbol;
13
13
  export interface IDatabaseDriver<C extends Connection = Connection> {
14
14
  [EntityManagerType]: EntityManager<this>;
@@ -25,21 +25,21 @@ export interface IDatabaseDriver<C extends Connection = Connection> {
25
25
  /**
26
26
  * Finds selection of entities
27
27
  */
28
- find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
28
+ find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
29
29
  /**
30
30
  * Finds single entity (table row, document)
31
31
  */
32
- findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
33
- findVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
32
+ findOne<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
33
+ findVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
34
34
  stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T>): AsyncIterableIterator<T>;
35
- nativeInsert<T extends object>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
36
- nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
37
- nativeUpdate<T extends object>(entityName: string, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
38
- nativeUpdateMany<T extends object>(entityName: string, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
39
- nativeDelete<T extends object>(entityName: string, where: FilterQuery<T>, options?: NativeDeleteOptions<T>): Promise<QueryResult<T>>;
35
+ nativeInsert<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
36
+ nativeInsertMany<T extends object>(entityName: EntityName<T>, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>, transform?: (sql: string) => string): Promise<QueryResult<T>>;
37
+ nativeUpdate<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
38
+ nativeUpdateMany<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>[], data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
39
+ nativeDelete<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options?: NativeDeleteOptions<T>): Promise<QueryResult<T>>;
40
40
  syncCollections<T extends object, O extends object>(collections: Iterable<Collection<T, O>>, options?: DriverMethodOptions): Promise<void>;
41
- count<T extends object, P extends string = never>(entityName: string, where: FilterQuery<T>, options?: CountOptions<T, P>): Promise<number>;
42
- aggregate(entityName: string, pipeline: any[]): Promise<any[]>;
41
+ count<T extends object, P extends string = never>(entityName: EntityName<T>, where: FilterQuery<T>, options?: CountOptions<T, P>): Promise<number>;
42
+ aggregate(entityName: EntityName, pipeline: any[]): Promise<any[]>;
43
43
  mapResult<T extends object>(result: EntityDictionary<T>, meta: EntityMetadata<T>, populate?: PopulateOptions<T>[]): EntityData<T> | null;
44
44
  /**
45
45
  * When driver uses pivot tables for M:N, this method will load identifiers for given collections from them
@@ -189,7 +189,7 @@ export interface NativeInsertUpdateManyOptions<T> extends NativeInsertUpdateOpti
189
189
  processCollections?: boolean;
190
190
  }
191
191
  export interface UpsertOptions<Entity, Fields extends string = never> extends Omit<NativeInsertUpdateOptions<Entity>, 'upsert'> {
192
- onConflictFields?: (keyof Entity)[] | RawQueryFragment;
192
+ onConflictFields?: (keyof Entity)[] | Raw;
193
193
  onConflictAction?: 'ignore' | 'merge';
194
194
  onConflictMergeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
195
195
  onConflictExcludeFields?: AutoPath<Entity, Fields, `${PopulatePath.ALL}`>[];
@@ -4,6 +4,7 @@ import { DataloaderType, ReferenceKind } from '../enums.js';
4
4
  import { Reference } from './Reference.js';
5
5
  import { helper, wrap } from './wrap.js';
6
6
  import { QueryHelper } from '../utils/QueryHelper.js';
7
+ import { Raw } from '../utils/RawQueryFragment.js';
7
8
  import { inspect } from '../logging/inspect.js';
8
9
  export class Collection {
9
10
  owner;
@@ -83,7 +84,7 @@ export class Collection {
83
84
  return this._count = this.length;
84
85
  }
85
86
  const cond = this.createLoadCountCondition(where ?? {});
86
- const count = await em.count(this.property.type, cond, countOptions);
87
+ const count = await em.count(this.property.targetMeta.class, cond, countOptions);
87
88
  if (!where) {
88
89
  this._count = count;
89
90
  }
@@ -95,12 +96,12 @@ export class Collection {
95
96
  opts.orderBy = this.createOrderBy(opts.orderBy);
96
97
  let items;
97
98
  if (this.property.kind === ReferenceKind.MANY_TO_MANY && em.getPlatform().usesPivotTable()) {
98
- const cond = await em.applyFilters(this.property.type, where, options.filters ?? {}, 'read');
99
+ const cond = await em.applyFilters(this.property.targetMeta.class, where, options.filters ?? {}, 'read');
99
100
  const map = await em.getDriver().loadFromPivotTable(this.property, [helper(this.owner).__primaryKeys], cond, opts.orderBy, ctx, options);
100
- items = map[helper(this.owner).getSerializedPrimaryKey()].map((item) => em.merge(this.property.type, item, { convertCustomTypes: true }));
101
+ items = map[helper(this.owner).getSerializedPrimaryKey()].map((item) => em.merge(this.property.targetMeta.class, item, { convertCustomTypes: true }));
101
102
  }
102
103
  else {
103
- items = await em.find(this.property.type, this.createCondition(where), opts);
104
+ items = await em.find(this.property.targetMeta.class, this.createCondition(where), opts);
104
105
  }
105
106
  if (options.store) {
106
107
  this.hydrate(items, true);
@@ -298,7 +299,7 @@ export class Collection {
298
299
  return cond;
299
300
  }
300
301
  createOrderBy(orderBy = []) {
301
- if (Utils.isEmpty(orderBy) && this.property.orderBy) {
302
+ if (Utils.isEmpty(orderBy) && !Raw.hasObjectFragments(orderBy) && this.property.orderBy) {
302
303
  orderBy = this.property.orderBy;
303
304
  }
304
305
  return Utils.asArray(orderBy);
@@ -330,7 +331,7 @@ export class Collection {
330
331
  }
331
332
  checkInitialized() {
332
333
  if (!this.isInitialized()) {
333
- throw new Error(`Collection<${this.property.type}> of entity ${this.owner.constructor.name}[${helper(this.owner).getSerializedPrimaryKey()}] not initialized`);
334
+ throw new Error(`Collection<${this.property.type}> of entity ${helper(this.owner).__meta.name}[${helper(this.owner).getSerializedPrimaryKey()}] not initialized`);
334
335
  }
335
336
  }
336
337
  /**
@@ -77,7 +77,7 @@ export class EntityAssigner {
77
77
  if (options.updateByPrimaryKey) {
78
78
  const pk = Utils.extractPK(value, prop.targetMeta);
79
79
  if (pk) {
80
- const ref = options.em.getReference(prop.type, pk, options);
80
+ const ref = options.em.getReference(prop.targetMeta.class, pk, options);
81
81
  // if the PK differs, we want to change the target entity, not update it
82
82
  const wrappedChild = helper(ref);
83
83
  const sameTarget = wrappedChild.getSerializedPrimaryKey() === wrapped.getSerializedPrimaryKey();
@@ -141,13 +141,13 @@ export class EntityAssigner {
141
141
  entity[prop.name] = Reference.wrapReference(value, prop);
142
142
  }
143
143
  else if (Utils.isPrimaryKey(value, true) && EntityAssigner.validateEM(em)) {
144
- entity[prop.name] = prop.mapToPk ? value : Reference.wrapReference(em.getReference(prop.type, value, options), prop);
144
+ entity[prop.name] = prop.mapToPk ? value : Reference.wrapReference(em.getReference(prop.targetMeta.class, value, options), prop);
145
145
  }
146
146
  else if (Utils.isPlainObject(value) && options.merge && EntityAssigner.validateEM(em)) {
147
- entity[prop.name] = Reference.wrapReference(em.merge(prop.type, value, options), prop);
147
+ entity[prop.name] = Reference.wrapReference(em.merge(prop.targetMeta.class, value, options), prop);
148
148
  }
149
149
  else if (Utils.isPlainObject(value) && EntityAssigner.validateEM(em)) {
150
- entity[prop.name] = Reference.wrapReference(em.create(prop.type, value, options), prop);
150
+ entity[prop.name] = Reference.wrapReference(em.create(prop.targetMeta.class, value, options), prop);
151
151
  }
152
152
  else {
153
153
  const name = entity.constructor.name;
@@ -166,7 +166,7 @@ export class EntityAssigner {
166
166
  if (options.updateNestedEntities && options.updateByPrimaryKey && Utils.isPlainObject(item)) {
167
167
  const pk = Utils.extractPK(item, prop.targetMeta);
168
168
  if (pk && EntityAssigner.validateEM(em)) {
169
- const ref = em.getUnitOfWork().getById(prop.type, pk, options.schema);
169
+ const ref = em.getUnitOfWork().getById(prop.targetMeta.class, pk, options.schema);
170
170
  if (ref) {
171
171
  return EntityAssigner.assign(ref, item, options);
172
172
  }
@@ -207,7 +207,7 @@ export class EntityAssigner {
207
207
  entity[propName].push(...Object.values(tmp));
208
208
  });
209
209
  }
210
- const create = () => EntityAssigner.validateEM(em) && em.getEntityFactory().createEmbeddable(prop.type, value, {
210
+ const create = () => EntityAssigner.validateEM(em) && em.getEntityFactory().createEmbeddable(prop.targetMeta.class, value, {
211
211
  convertCustomTypes: options.convertCustomTypes,
212
212
  newEntity: options.mergeEmbeddedProperties ? !('propName' in entity) : true,
213
213
  });
@@ -221,13 +221,13 @@ export class EntityAssigner {
221
221
  return item;
222
222
  }
223
223
  if (Utils.isPrimaryKey(item) && EntityAssigner.validateEM(em)) {
224
- return em.getReference(prop.type, item, options);
224
+ return em.getReference(prop.targetMeta.class, item, options);
225
225
  }
226
226
  if (Utils.isPlainObject(item) && options.merge && EntityAssigner.validateEM(em)) {
227
- return em.merge(prop.type, item, options);
227
+ return em.merge(prop.targetMeta.class, item, options);
228
228
  }
229
229
  if (Utils.isPlainObject(item) && EntityAssigner.validateEM(em)) {
230
- return em.create(prop.type, item, options);
230
+ return em.create(prop.targetMeta.class, item, options);
231
231
  }
232
232
  invalid.push(item);
233
233
  return item;
@@ -30,7 +30,6 @@ export class EntityFactory {
30
30
  if (data.__entity) {
31
31
  return data;
32
32
  }
33
- entityName = Utils.className(entityName);
34
33
  const meta = this.metadata.get(entityName);
35
34
  if (meta.virtual) {
36
35
  data = { ...data };
@@ -110,12 +109,12 @@ export class EntityFactory {
110
109
  data = QueryHelper.processParams(data);
111
110
  const existsData = this.comparator.prepareEntity(entity);
112
111
  const originalEntityData = helper(entity).__originalEntityData ?? {};
113
- const diff = this.comparator.diffEntities(meta.className, originalEntityData, existsData);
112
+ const diff = this.comparator.diffEntities(meta.class, originalEntityData, existsData);
114
113
  // version properties are not part of entity snapshots
115
114
  if (meta.versionProperty && data[meta.versionProperty] && data[meta.versionProperty] !== originalEntityData[meta.versionProperty]) {
116
115
  diff[meta.versionProperty] = data[meta.versionProperty];
117
116
  }
118
- const diff2 = this.comparator.diffEntities(meta.className, existsData, data, { includeInverseSides: true });
117
+ const diff2 = this.comparator.diffEntities(meta.class, existsData, data, { includeInverseSides: true });
119
118
  // do not override values changed by user
120
119
  Utils.keys(diff).forEach(key => delete diff2[key]);
121
120
  Utils.keys(diff2).filter(key => {
@@ -152,18 +151,17 @@ export class EntityFactory {
152
151
  // we just create the entity from scratch, which will automatically pick the right one from the identity map and call `mergeData` on it
153
152
  data[prop.name]
154
153
  .filter(child => Utils.isPlainObject(child)) // objects with prototype can be PKs (e.g. `ObjectId`)
155
- .forEach(child => this.create(prop.type, child, options)); // we can ignore the value, we just care about the `mergeData` call
154
+ .forEach(child => this.create(prop.targetMeta.class, child, options)); // we can ignore the value, we just care about the `mergeData` call
156
155
  return;
157
156
  }
158
157
  if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && Utils.isPlainObject(data[prop.name]) && entity[prop.name] && helper(entity[prop.name]).__initialized) {
159
- this.create(prop.type, data[prop.name], options); // we can ignore the value, we just care about the `mergeData` call
158
+ this.create(prop.targetMeta.class, data[prop.name], options); // we can ignore the value, we just care about the `mergeData` call
160
159
  }
161
160
  });
162
161
  this.unitOfWork.normalizeEntityData(meta, originalEntityData);
163
162
  }
164
163
  createReference(entityName, id, options = {}) {
165
164
  options.convertCustomTypes ??= true;
166
- entityName = Utils.className(entityName);
167
165
  const meta = this.metadata.get(entityName);
168
166
  const schema = this.driver.getSchemaName(meta, options);
169
167
  if (meta.simplePK) {
@@ -188,7 +186,6 @@ export class EntityFactory {
188
186
  return this.create(entityName, id, { ...options, initialized: false });
189
187
  }
190
188
  createEmbeddable(entityName, data, options = {}) {
191
- entityName = Utils.className(entityName);
192
189
  data = { ...data };
193
190
  const meta = this.metadata.get(entityName);
194
191
  const meta2 = this.processDiscriminatorColumn(meta, data);
@@ -200,7 +197,7 @@ export class EntityFactory {
200
197
  createEntity(data, meta, options) {
201
198
  const schema = this.driver.getSchemaName(meta, options);
202
199
  if (options.newEntity || meta.forceConstructor || meta.virtual) {
203
- if (!meta.class) {
200
+ if (meta.polymorphs) {
204
201
  throw new Error(`Cannot create entity ${meta.className}, class prototype is unknown`);
205
202
  }
206
203
  const params = this.extractConstructorParams(meta, data, options);
@@ -263,13 +260,13 @@ export class EntityFactory {
263
260
  findEntity(data, meta, options) {
264
261
  const schema = this.driver.getSchemaName(meta, options);
265
262
  if (meta.simplePK) {
266
- return this.unitOfWork.getById(meta.className, data[meta.primaryKeys[0]], schema);
263
+ return this.unitOfWork.getById(meta.class, data[meta.primaryKeys[0]], schema);
267
264
  }
268
265
  if (!Array.isArray(data) && meta.primaryKeys.some(pk => data[pk] == null)) {
269
266
  return undefined;
270
267
  }
271
268
  const pks = Utils.getOrderedPrimaryKeys(data, meta, this.platform, options.convertCustomTypes);
272
- return this.unitOfWork.getById(meta.className, pks, schema);
269
+ return this.unitOfWork.getById(meta.class, pks, schema);
273
270
  }
274
271
  processDiscriminatorColumn(meta, data) {
275
272
  if (!meta.root.discriminatorColumn) {
@@ -278,7 +275,7 @@ export class EntityFactory {
278
275
  const prop = meta.properties[meta.root.discriminatorColumn];
279
276
  const value = data[prop.name];
280
277
  const type = meta.root.discriminatorMap[value];
281
- meta = type ? this.metadata.find(type) : meta;
278
+ meta = type ? this.metadata.get(type) : meta;
282
279
  return meta;
283
280
  }
284
281
  /**
@@ -307,7 +304,7 @@ export class EntityFactory {
307
304
  const value = data[k];
308
305
  if (prop && [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && value) {
309
306
  const pk = Reference.unwrapReference(value);
310
- const entity = this.unitOfWork.getById(prop.type, pk, options.schema, true);
307
+ const entity = this.unitOfWork.getById(prop.targetMeta.class, pk, options.schema, true);
311
308
  if (entity) {
312
309
  return entity;
313
310
  }
@@ -316,10 +313,10 @@ export class EntityFactory {
316
313
  }
317
314
  const nakedPk = Utils.extractPK(value, prop.targetMeta, true);
318
315
  if (Utils.isObject(value) && !nakedPk) {
319
- return this.create(prop.type, value, options);
316
+ return this.create(prop.targetMeta.class, value, options);
320
317
  }
321
318
  const { newEntity, initialized, ...rest } = options;
322
- const target = this.createReference(prop.type, nakedPk, rest);
319
+ const target = this.createReference(prop.targetMeta.class, nakedPk, rest);
323
320
  return Reference.wrapReference(target, prop);
324
321
  }
325
322
  if (prop?.kind === ReferenceKind.EMBEDDED && value) {
@@ -327,7 +324,7 @@ export class EntityFactory {
327
324
  if (Utils.isEntity(value)) {
328
325
  return value;
329
326
  }
330
- return this.createEmbeddable(prop.type, value, options);
327
+ return this.createEmbeddable(prop.targetMeta.class, value, options);
331
328
  }
332
329
  if (!prop) {
333
330
  const tmp = { ...data };
@@ -335,8 +332,8 @@ export class EntityFactory {
335
332
  if (!options.convertCustomTypes || !prop.customType || tmp[prop.name] == null) {
336
333
  continue;
337
334
  }
338
- if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && Utils.isPlainObject(tmp[prop.name]) && !Utils.extractPK(tmp[prop.name], meta.properties[prop.name].targetMeta, true)) {
339
- tmp[prop.name] = Reference.wrapReference(this.create(meta.properties[prop.name].type, tmp[prop.name], options), prop);
335
+ if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && Utils.isPlainObject(tmp[prop.name]) && !Utils.extractPK(tmp[prop.name], prop.targetMeta, true)) {
336
+ tmp[prop.name] = Reference.wrapReference(this.create(prop.targetMeta.class, tmp[prop.name], options), prop);
340
337
  }
341
338
  else if (prop.kind === ReferenceKind.SCALAR) {
342
339
  tmp[prop.name] = prop.customType.convertToJSValue(tmp[prop.name], this.platform);
@@ -6,9 +6,9 @@ import { type EntityMetadata, type EntityProperty, type IHydrator } from '../typ
6
6
  export declare class EntityHelper {
7
7
  static decorate<T extends object>(meta: EntityMetadata<T>, em: EntityManager): void;
8
8
  /**
9
- * As a performance optimization, we create entity state methods in a lazy manner. We first add
9
+ * As a performance optimization, we create entity state methods lazily. We first add
10
10
  * the `null` value to the prototype to reserve space in memory. Then we define a setter on the
11
- * prototype, that will be executed exactly once per entity instance. There we redefine given
11
+ * prototype that will be executed exactly once per entity instance. There we redefine the given
12
12
  * property on the entity instance, so shadowing the prototype setter.
13
13
  */
14
14
  private static defineBaseProperties;
@@ -38,9 +38,9 @@ export class EntityHelper {
38
38
  }
39
39
  }
40
40
  /**
41
- * As a performance optimization, we create entity state methods in a lazy manner. We first add
41
+ * As a performance optimization, we create entity state methods lazily. We first add
42
42
  * the `null` value to the prototype to reserve space in memory. Then we define a setter on the
43
- * prototype, that will be executed exactly once per entity instance. There we redefine given
43
+ * prototype that will be executed exactly once per entity instance. There we redefine the given
44
44
  * property on the entity instance, so shadowing the prototype setter.
45
45
  */
46
46
  static defineBaseProperties(meta, prototype, em) {
@@ -1,4 +1,4 @@
1
- import type { AnyEntity, ConnectionType, EntityProperty, FilterQuery, PopulateOptions } from '../typings.js';
1
+ import type { AnyEntity, ConnectionType, EntityName, EntityProperty, FilterQuery, PopulateOptions } from '../typings.js';
2
2
  import type { EntityManager } from '../EntityManager.js';
3
3
  import { LoadStrategy, type LockMode, type PopulateHint, PopulatePath, type QueryOrderMap } from '../enums.js';
4
4
  import type { EntityField, FilterOptions } from '../drivers/IDatabaseDriver.js';
@@ -30,8 +30,8 @@ export declare class EntityLoader {
30
30
  * Loads specified relations in batch.
31
31
  * This will execute one query for each relation, that will populate it on all the specified entities.
32
32
  */
33
- populate<Entity extends object, Fields extends string = PopulatePath.ALL>(entityName: string, entities: Entity[], populate: PopulateOptions<Entity>[] | boolean, options: EntityLoaderOptions<Entity, Fields>): Promise<void>;
34
- normalizePopulate<Entity>(entityName: string, populate: (PopulateOptions<Entity> | boolean)[] | PopulateOptions<Entity> | boolean, strategy?: LoadStrategy, lookup?: boolean): PopulateOptions<Entity>[];
33
+ populate<Entity extends object, Fields extends string = PopulatePath.ALL>(entityName: EntityName<Entity>, entities: Entity[], populate: PopulateOptions<Entity>[] | boolean, options: EntityLoaderOptions<Entity, Fields>): Promise<void>;
34
+ normalizePopulate<Entity>(entityName: EntityName<Entity>, populate: (PopulateOptions<Entity> | boolean)[] | PopulateOptions<Entity> | boolean, strategy?: LoadStrategy, lookup?: boolean): PopulateOptions<Entity>[];
35
35
  private setSerializationContext;
36
36
  /**
37
37
  * Merge multiple populates for the same entity with different children. Also skips `*` fields, those can come from
@@ -4,8 +4,8 @@ import { ValidationError } from '../errors.js';
4
4
  import { LoadStrategy, PopulatePath, ReferenceKind, } from '../enums.js';
5
5
  import { Reference } from './Reference.js';
6
6
  import { helper } from './wrap.js';
7
- import { raw, RawQueryFragment } from '../utils/RawQueryFragment.js';
8
7
  import { expandDotPaths } from './utils.js';
8
+ import { Raw } from '../utils/RawQueryFragment.js';
9
9
  export class EntityLoader {
10
10
  em;
11
11
  metadata;
@@ -157,7 +157,7 @@ export class EntityLoader {
157
157
  const ids = Utils.unique(filtered.map(e => Utils.getPrimaryKeyValues(e, meta, true)));
158
158
  const where = this.mergePrimaryCondition(ids, pk, options, meta, this.metadata, this.driver.getPlatform());
159
159
  const { filters, convertCustomTypes, lockMode, strategy, populateWhere, connectionType, logging, fields } = options;
160
- await this.em.find(meta.className, where, {
160
+ await this.em.find(meta.class, where, {
161
161
  filters, convertCustomTypes, lockMode, strategy, populateWhere, connectionType, logging,
162
162
  fields: fields,
163
163
  populate: [],
@@ -181,7 +181,7 @@ export class EntityLoader {
181
181
  for (const child of children) {
182
182
  const pk = child.__helper.__data[prop.mappedBy] ?? child[prop.mappedBy];
183
183
  if (pk) {
184
- const key = helper(mapToPk ? this.em.getReference(prop.type, pk) : pk).getSerializedPrimaryKey();
184
+ const key = helper(mapToPk ? this.em.getReference(prop.targetMeta.class, pk) : pk).getSerializedPrimaryKey();
185
185
  map[key]?.push(child);
186
186
  }
187
187
  }
@@ -237,28 +237,14 @@ export class EntityLoader {
237
237
  if (typeof populateWhere === 'object') {
238
238
  populateWhere = await this.extractChildCondition({ where: populateWhere }, prop);
239
239
  }
240
- if (!Utils.isEmpty(prop.where)) {
240
+ if (!Utils.isEmpty(prop.where) || Raw.hasObjectFragments(prop.where)) {
241
241
  where = { $and: [where, prop.where] };
242
242
  }
243
- const propOrderBy = [];
244
- if (prop.orderBy) {
245
- for (const item of Utils.asArray(prop.orderBy)) {
246
- for (const field of Utils.keys(item)) {
247
- const rawField = RawQueryFragment.getKnownFragment(field, false);
248
- if (rawField) {
249
- const raw2 = raw(rawField.sql, rawField.params);
250
- propOrderBy.push({ [raw2.toString()]: item[field] });
251
- continue;
252
- }
253
- propOrderBy.push({ [field]: item[field] });
254
- }
255
- }
256
- }
257
- const orderBy = [...Utils.asArray(options.orderBy), ...propOrderBy].filter((order, idx, array) => {
243
+ const orderBy = [...Utils.asArray(options.orderBy), ...Utils.asArray(prop.orderBy)].filter((order, idx, array) => {
258
244
  // skip consecutive ordering with the same key to get around mongo issues
259
- return idx === 0 || !Utils.equals(Object.keys(array[idx - 1]), Object.keys(order));
245
+ return idx === 0 || !Utils.equals(Utils.getObjectQueryKeys(array[idx - 1]), Utils.getObjectQueryKeys(order));
260
246
  });
261
- const items = await this.em.find(prop.type, where, {
247
+ const items = await this.em.find(meta.class, where, {
262
248
  filters, convertCustomTypes, lockMode, populateWhere, logging,
263
249
  orderBy,
264
250
  populate: populate.children ?? populate.all ?? [],
@@ -297,7 +283,7 @@ export class EntityLoader {
297
283
  return { items, partial };
298
284
  }
299
285
  mergePrimaryCondition(ids, pk, options, meta, metadata, platform) {
300
- const cond1 = QueryHelper.processWhere({ where: { [pk]: { $in: ids } }, entityName: meta.className, metadata, platform, convertCustomTypes: !options.convertCustomTypes });
286
+ const cond1 = QueryHelper.processWhere({ where: { [pk]: { $in: ids } }, entityName: meta.class, metadata, platform, convertCustomTypes: !options.convertCustomTypes });
301
287
  const where = { ...options.where };
302
288
  Utils.dropUndefinedProperties(where);
303
289
  return where[pk]
@@ -349,7 +335,11 @@ export class EntityLoader {
349
335
  for (const entity of entities) {
350
336
  visited.add(entity);
351
337
  }
352
- await this.populate(prop.type, unique, populate.children ?? populate.all, {
338
+ // skip lazy scalar properties
339
+ if (!prop.targetMeta) {
340
+ return;
341
+ }
342
+ await this.populate(prop.targetMeta.class, unique, populate.children ?? populate.all, {
353
343
  where: await this.extractChildCondition(options, prop, false),
354
344
  orderBy: innerOrderBy,
355
345
  fields,
@@ -394,12 +384,12 @@ export class EntityLoader {
394
384
  for (const entity of filtered) {
395
385
  const items = map[entity.__helper.getSerializedPrimaryKey()].map(item => {
396
386
  if (pivotJoin) {
397
- return this.em.getReference(prop.type, item, {
387
+ return this.em.getReference(prop.targetMeta.class, item, {
398
388
  convertCustomTypes: true,
399
389
  schema: options.schema ?? this.em.config.get('schema'),
400
390
  });
401
391
  }
402
- const entity = this.em.getEntityFactory().create(prop.type, item, {
392
+ const entity = this.em.getEntityFactory().create(prop.targetMeta.class, item, {
403
393
  refresh,
404
394
  merge: true,
405
395
  convertCustomTypes: true,
@@ -415,16 +405,13 @@ export class EntityLoader {
415
405
  async extractChildCondition(options, prop, filters = false) {
416
406
  const where = options.where;
417
407
  const subCond = Utils.isPlainObject(where[prop.name]) ? where[prop.name] : {};
418
- const meta2 = this.metadata.find(prop.type);
419
- if (!meta2) {
420
- return {};
421
- }
408
+ const meta2 = prop.targetMeta;
422
409
  const pk = Utils.getPrimaryKeyHash(meta2.primaryKeys);
423
410
  ['$and', '$or'].forEach(op => {
424
411
  if (where[op]) {
425
412
  const child = where[op]
426
413
  .map((cond) => cond[prop.name])
427
- .filter((sub) => sub != null && !(Utils.isPlainObject(sub) && Object.keys(sub).every(key => Utils.isOperator(key, false))))
414
+ .filter((sub) => sub != null && !(Utils.isPlainObject(sub) && Utils.getObjectQueryKeys(sub).every(key => Utils.isOperator(key, false))))
428
415
  .map((cond) => {
429
416
  if (Utils.isPrimaryKey(cond)) {
430
417
  return { [pk]: cond };
@@ -445,7 +432,7 @@ export class EntityLoader {
445
432
  });
446
433
  }
447
434
  if (filters) {
448
- return this.em.applyFilters(prop.type, subCond, options.filters, 'read', options);
435
+ return this.em.applyFilters(meta2.class, subCond, options.filters, 'read', options);
449
436
  }
450
437
  return subCond;
451
438
  }
@@ -578,10 +565,10 @@ export class EntityLoader {
578
565
  if (!meta && !prefix) {
579
566
  return populate;
580
567
  }
581
- if (visited.includes(entityName) || !meta) {
568
+ if (!meta || visited.includes(meta)) {
582
569
  return [];
583
570
  }
584
- visited.push(entityName);
571
+ visited.push(meta);
585
572
  const ret = prefix === '' ? [...populate] : [];
586
573
  meta.relations
587
574
  .filter(prop => {
@@ -594,12 +581,12 @@ export class EntityLoader {
594
581
  const field = this.getRelationName(meta, prop);
595
582
  const prefixed = prefix ? `${prefix}.${field}` : field;
596
583
  const nestedPopulate = populate.filter(p => p.field === prop.name).flatMap(p => p.children).filter(Boolean);
597
- const nested = this.lookupEagerLoadedRelationships(prop.type, nestedPopulate, strategy, prefixed, visited.slice());
584
+ const nested = this.lookupEagerLoadedRelationships(prop.targetMeta.class, nestedPopulate, strategy, prefixed, visited.slice());
598
585
  if (nested.length > 0) {
599
586
  ret.push(...nested);
600
587
  }
601
588
  else {
602
- const selfReferencing = [meta.className, meta.root.className, ...visited].includes(prop.type) && prop.eager;
589
+ const selfReferencing = [meta.tableName, ...visited.map(m => m.tableName)].includes(prop.targetMeta.tableName) && prop.eager;
603
590
  ret.push({
604
591
  field: prefixed,
605
592
  // enforce select-in strategy for self-referencing relations
@@ -71,7 +71,7 @@ export class WrappedEntity {
71
71
  if (!this.__em) {
72
72
  throw ValidationError.entityNotManaged(this.entity);
73
73
  }
74
- return this.__em.findOne(this.entity.constructor.name, this.entity, { ...options, refresh: true, schema: this.__schema });
74
+ return this.__em.findOne(this.entity.constructor, this.entity, { ...options, refresh: true, schema: this.__schema });
75
75
  }
76
76
  async populate(populate, options = {}) {
77
77
  if (!this.__em) {
@@ -326,7 +326,7 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
326
326
  /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
327
327
  pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
328
328
  /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
329
- pivotEntity(pivotEntity: string | (() => EntityName<any>)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
329
+ pivotEntity(pivotEntity: () => EntityName): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
330
330
  /** 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. */
331
331
  joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
332
332
  /** 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. */
@@ -380,15 +380,15 @@ declare const propertyBuilders: {
380
380
  time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
381
381
  type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
382
382
  enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
383
- embedded: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any> | EntitySchemaWithMeta<any, any, any, any, any>[] | EntityClass<any>[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
384
- manyToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
383
+ embedded: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass | EntitySchemaWithMeta<any, any, any, any, any>[] | EntityClass[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
384
+ manyToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
385
385
  kind: "m:n";
386
386
  }, IncludeKeysForManyToManyOptions>;
387
- manyToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
387
+ manyToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
388
388
  kind: "m:1";
389
389
  }, IncludeKeysForManyToOneOptions>;
390
- oneToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
391
- oneToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
390
+ oneToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
391
+ oneToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
392
392
  kind: "1:1";
393
393
  }, IncludeKeysForOneToOneOptions>;
394
394
  date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
@@ -454,15 +454,15 @@ export declare namespace defineEntity {
454
454
  time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
455
455
  type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
456
456
  enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
457
- embedded: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any> | EntitySchemaWithMeta<any, any, any, any, any>[] | EntityClass<any>[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
458
- manyToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
457
+ embedded: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass | EntitySchemaWithMeta<any, any, any, any, any>[] | EntityClass[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
458
+ manyToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
459
459
  kind: "m:n";
460
460
  }, IncludeKeysForManyToManyOptions>;
461
- manyToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
461
+ manyToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
462
462
  kind: "m:1";
463
463
  }, IncludeKeysForManyToOneOptions>;
464
- oneToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
465
- oneToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
464
+ oneToMany: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
465
+ oneToOne: <Target extends EntitySchemaWithMeta<any, any, any, any, any> | EntityClass>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
466
466
  kind: "1:1";
467
467
  }, IncludeKeysForOneToOneOptions>;
468
468
  date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
@@ -1,6 +1,6 @@
1
1
  import { Utils } from '../utils/Utils.js';
2
2
  import { ValidationError } from '../errors.js';
3
- import { isRaw } from '../utils/RawQueryFragment.js';
3
+ import { isRaw, Raw } from '../utils/RawQueryFragment.js';
4
4
  import { SCALAR_TYPES } from '../enums.js';
5
5
  /** @internal */
6
6
  export function validateProperty(prop, givenValue, entity) {
@@ -59,7 +59,7 @@ export function validatePrimaryKey(entity, meta) {
59
59
  }
60
60
  /** @internal */
61
61
  export function validateEmptyWhere(where) {
62
- if (Utils.isEmpty(where)) {
62
+ if (Utils.isEmpty(where) && !Raw.hasObjectFragments(where)) {
63
63
  throw new Error(`You cannot call 'EntityManager.findOne()' with empty 'where' parameter`);
64
64
  }
65
65
  }
package/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AnyEntity, Constructor, Dictionary, EntityMetadata, EntityProperty, IPrimaryKey } from './typings.js';
1
+ import type { AnyEntity, Constructor, Dictionary, EntityMetadata, EntityName, EntityProperty, IPrimaryKey } from './typings.js';
2
2
  export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Error {
3
3
  readonly entity?: T | undefined;
4
4
  constructor(message: string, entity?: T | undefined);
@@ -13,7 +13,7 @@ export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Er
13
13
  static entityNotManaged(entity: AnyEntity): ValidationError;
14
14
  static notEntity(owner: AnyEntity, prop: EntityProperty, data: any): ValidationError;
15
15
  static notDiscoveredEntity(data: any, meta?: EntityMetadata, action?: string): ValidationError;
16
- static invalidPropertyName(entityName: string, invalid: string): ValidationError;
16
+ static invalidPropertyName(entityName: EntityName, invalid: string): ValidationError;
17
17
  static invalidCollectionValues(entityName: string, propName: string, invalid: unknown): ValidationError;
18
18
  static invalidEnumArrayItems(entityName: string, invalid: unknown): ValidationError;
19
19
  static invalidType(type: Constructor<any>, value: any, mode: string): ValidationError;
@@ -24,9 +24,9 @@ export declare class ValidationError<T extends AnyEntity = AnyEntity> extends Er
24
24
  static invalidCompositeIdentifier(meta: EntityMetadata): ValidationError;
25
25
  static cannotCommit(): ValidationError;
26
26
  static cannotUseGlobalContext(): ValidationError;
27
- static cannotUseOperatorsInsideEmbeddables(className: string, propName: string, payload: unknown): ValidationError;
28
- static cannotUseGroupOperatorsInsideScalars(className: string, propName: string, payload: unknown): ValidationError;
29
- static invalidEmbeddableQuery(className: string, propName: string, embeddableType: string): ValidationError;
27
+ static cannotUseOperatorsInsideEmbeddables(entityName: EntityName, propName: string, payload: unknown): ValidationError;
28
+ static cannotUseGroupOperatorsInsideScalars(entityName: EntityName, propName: string, payload: unknown): ValidationError;
29
+ static invalidEmbeddableQuery(entityName: EntityName, propName: string, embeddableType: string): ValidationError;
30
30
  static invalidQueryCondition(cond: unknown): ValidationError;
31
31
  }
32
32
  export declare class CursorError<T extends AnyEntity = AnyEntity> extends ValidationError<T> {
@@ -49,11 +49,11 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
49
49
  static unknownIndexProperty(meta: EntityMetadata, prop: string, type: string): MetadataError;
50
50
  static multipleVersionFields(meta: EntityMetadata, fields: string[]): MetadataError;
51
51
  static invalidVersionFieldType(meta: EntityMetadata): MetadataError;
52
- static fromUnknownEntity(className: string, source: string): MetadataError;
52
+ static fromUnknownEntity(entityName: string, source: string): MetadataError;
53
53
  static noEntityDiscovered(): MetadataError;
54
54
  static onlyAbstractEntitiesDiscovered(): MetadataError;
55
- static duplicateEntityDiscovered(paths: string[], subject?: string): MetadataError;
56
- static duplicateFieldName(className: string, names: [string, string][]): MetadataError;
55
+ static duplicateEntityDiscovered(paths: string[]): MetadataError;
56
+ static duplicateFieldName(entityName: EntityName, names: [string, string][]): MetadataError;
57
57
  static multipleDecorators(entityName: string, propertyName: string): MetadataError;
58
58
  static missingMetadata(entity: string): MetadataError;
59
59
  static invalidPrimaryKey(meta: EntityMetadata, prop: EntityProperty, requiredName: string): MetadataError<Partial<any>>;