@mikro-orm/core 7.0.0-dev.120 → 7.0.0-dev.122
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.
- package/EntityManager.js +2 -2
- package/drivers/DatabaseDriver.js +5 -5
- package/entity/BaseEntity.d.ts +2 -1
- package/entity/EntityHelper.js +5 -0
- package/entity/defineEntity.d.ts +4 -4
- package/index.d.ts +1 -1
- package/metadata/EntitySchema.d.ts +10 -8
- package/metadata/EntitySchema.js +6 -0
- package/package.json +1 -1
- package/typings.d.ts +38 -37
- package/utils/Utils.js +1 -1
package/EntityManager.js
CHANGED
|
@@ -571,8 +571,8 @@ export class EntityManager {
|
|
|
571
571
|
let found = false;
|
|
572
572
|
for (const e of fork.unitOfWork.getIdentityMap()) {
|
|
573
573
|
const ref = em.getReference(e.constructor, helper(e).getPrimaryKey());
|
|
574
|
-
const data = helper(e).serialize({ ignoreSerializers: true, includeHidden: true, convertCustomTypes:
|
|
575
|
-
em.config.getHydrator(this.metadata).hydrate(ref, helper(ref).__meta, data, em.entityFactory, 'full', false,
|
|
574
|
+
const data = helper(e).serialize({ ignoreSerializers: true, includeHidden: true, convertCustomTypes: false });
|
|
575
|
+
em.config.getHydrator(this.metadata).hydrate(ref, helper(ref).__meta, data, em.entityFactory, 'full', false, false);
|
|
576
576
|
Utils.merge(helper(ref).__originalEntityData, this.comparator.prepareEntity(e));
|
|
577
577
|
found ||= ref === entity;
|
|
578
578
|
}
|
|
@@ -286,26 +286,26 @@ export class DatabaseDriver {
|
|
|
286
286
|
if (!sub.embeddedProps[kkk]) {
|
|
287
287
|
throw ValidationError.invalidEmbeddableQuery(meta.class, kkk, sub.type);
|
|
288
288
|
}
|
|
289
|
-
inline(payload[sub.embedded[1]], sub.embeddedProps[kkk], [...path, sub.
|
|
289
|
+
inline(payload[sub.embedded[1]], sub.embeddedProps[kkk], [...path, sub.fieldNames[0]]);
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
data[`${path.join('.')}.${sub.
|
|
292
|
+
data[`${path.join('.')}.${sub.fieldNames[0]}`] = payload[sub.embedded[1]];
|
|
293
293
|
};
|
|
294
294
|
const parentPropName = kk.substring(0, kk.indexOf('.'));
|
|
295
295
|
// we might be using some native JSON operator, e.g. with mongodb's `$geoWithin` or `$exists`
|
|
296
296
|
if (props[kk]) {
|
|
297
297
|
/* v8 ignore next */
|
|
298
|
-
inline(data[prop.name], props[kk] || props[parentPropName], [prop.
|
|
298
|
+
inline(data[prop.name], props[kk] || props[parentPropName], [prop.fieldNames[0]]);
|
|
299
299
|
}
|
|
300
300
|
else if (props[parentPropName]) {
|
|
301
|
-
data[`${prop.
|
|
301
|
+
data[`${prop.fieldNames[0]}.${kk}`] = data[prop.name][kk];
|
|
302
302
|
}
|
|
303
303
|
else {
|
|
304
304
|
unknownProp = true;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
else if (props[kk]) {
|
|
308
|
-
data[props[kk].
|
|
308
|
+
data[props[kk].fieldNames[0]] = data[prop.name][props[kk].embedded[1]];
|
|
309
309
|
}
|
|
310
310
|
else {
|
|
311
311
|
throw ValidationError.invalidEmbeddableQuery(meta.class, kk, prop.type);
|
package/entity/BaseEntity.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import { type AssignOptions } from './EntityAssigner.js';
|
|
|
4
4
|
import type { EntityLoaderOptions } from './EntityLoader.js';
|
|
5
5
|
import { type SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
6
6
|
import type { FindOneOptions } from '../drivers/IDatabaseDriver.js';
|
|
7
|
+
import type { PopulatePath } from '../enums.js';
|
|
7
8
|
export declare abstract class BaseEntity {
|
|
8
9
|
isInitialized(): boolean;
|
|
9
10
|
populated(populated?: boolean): void;
|
|
10
|
-
populate<Entity extends this = this, Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
11
|
+
populate<Entity extends this = this, Hint extends string = never>(populate: AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
11
12
|
toReference<Entity extends this = this>(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
|
|
12
13
|
toObject<Entity extends this = this>(): EntityDTO<Entity>;
|
|
13
14
|
toObject<Entity extends this = this>(ignoreFields: never[]): EntityDTO<Entity>;
|
package/entity/EntityHelper.js
CHANGED
|
@@ -213,6 +213,11 @@ export class EntityHelper {
|
|
|
213
213
|
helper(other).__em?.getUnitOfWork().scheduleOrphanRemoval(other);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
+
// Skip setting the inverse side to null if it's a primary key - the entity will be removed via orphan removal
|
|
217
|
+
// Setting a primary key to null would corrupt the entity and cause validation errors
|
|
218
|
+
if (value == null && prop.orphanRemoval && prop2.primary) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
216
221
|
if (value == null) {
|
|
217
222
|
entity[prop2.name] = value;
|
|
218
223
|
}
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
2
|
import type { ColumnType, PropertyOptions, ReferenceOptions, EnumOptions, EmbeddedOptions, ManyToOneOptions, OneToManyOptions, OneToOneOptions, ManyToManyOptions } from '../metadata/types.js';
|
|
3
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback } from '../typings.js';
|
|
3
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback, EntityCtor } from '../typings.js';
|
|
4
4
|
import type { ScalarReference } from './Reference.js';
|
|
5
5
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
6
6
|
import type { Cascade, DeferMode, EmbeddedPrefixMode, EventType, LoadStrategy, QueryOrderMap } from '../enums.js';
|
|
@@ -436,13 +436,13 @@ export interface EntityMetadataWithProperties<TName extends string, TTableName e
|
|
|
436
436
|
}[];
|
|
437
437
|
}
|
|
438
438
|
export declare function defineEntity<const TName extends string, const TTableName extends string, const TProperties extends Record<string, any>, const TPK extends (keyof TProperties)[] | undefined = undefined, const TBase = never>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase>): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK>, TBase, TProperties>;
|
|
439
|
-
export declare function defineEntity<const TEntity = any, const TProperties extends Record<string, any> = Record<string, any>, const TClassName extends string = string, const TTableName extends string = string, const TBase = never>(meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName'> & {
|
|
440
|
-
class:
|
|
439
|
+
export declare function defineEntity<const TEntity = any, const TProperties extends Record<string, any> = Record<string, any>, const TClassName extends string = string, const TTableName extends string = string, const TBase = never, const TClass extends EntityCtor = any>(meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName'> & {
|
|
440
|
+
class: TClass;
|
|
441
441
|
className?: TClassName;
|
|
442
442
|
tableName?: TTableName;
|
|
443
443
|
extends?: EntityName<TBase>;
|
|
444
444
|
properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
|
|
445
|
-
}): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties>;
|
|
445
|
+
}): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
|
|
446
446
|
export declare namespace defineEntity {
|
|
447
447
|
var properties: {
|
|
448
448
|
bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
|
package/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
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
|
+
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, EntityCtor, } from './typings.js';
|
|
7
7
|
export * from './enums.js';
|
|
8
8
|
export * from './errors.js';
|
|
9
9
|
export * from './exceptions.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityMetadata, type AnyEntity, type EntityKey, type Constructor, type DeepPartial, type EntityName, type EntityProperty, type CleanKeys, type ExpandProperty, type IsNever, type
|
|
1
|
+
import { EntityMetadata, type AnyEntity, type EntityKey, type Constructor, type DeepPartial, type EntityName, type EntityProperty, type CleanKeys, type ExpandProperty, type IsNever, type EntityCtor } from '../typings.js';
|
|
2
2
|
import { ReferenceKind } from '../enums.js';
|
|
3
3
|
import { Type } from '../types/Type.js';
|
|
4
4
|
import type { PropertyOptions, ManyToOneOptions, OneToOneOptions, OneToManyOptions, ManyToManyOptions, EmbeddedOptions, EnumOptions, PrimaryKeyOptions, SerializedPrimaryKeyOptions, IndexOptions, UniqueOptions } from './types.js';
|
|
@@ -27,10 +27,10 @@ export type EntitySchemaProperty<Target, Owner> = ({
|
|
|
27
27
|
enum: true;
|
|
28
28
|
} & EnumOptions<Owner>) | (TypeDef<Target> & PropertyOptions<Owner>);
|
|
29
29
|
type OmitBaseProps<Entity, Base> = IsNever<Base> extends true ? Entity : Omit<Entity, keyof Base>;
|
|
30
|
-
export type EntitySchemaMetadata<Entity, Base = never> = Omit<Partial<EntityMetadata<Entity>>, 'name' | 'properties' | 'extends'> & ({
|
|
30
|
+
export type EntitySchemaMetadata<Entity, Base = never, Class extends EntityCtor = any> = Omit<Partial<EntityMetadata<Entity>>, 'name' | 'properties' | 'extends'> & ({
|
|
31
31
|
name: string;
|
|
32
32
|
} | {
|
|
33
|
-
class:
|
|
33
|
+
class: Class;
|
|
34
34
|
name?: string;
|
|
35
35
|
}) & {
|
|
36
36
|
extends?: EntityName<Base>;
|
|
@@ -39,16 +39,16 @@ export type EntitySchemaMetadata<Entity, Base = never> = Omit<Partial<EntityMeta
|
|
|
39
39
|
[Key in keyof OmitBaseProps<Entity, Base> as CleanKeys<OmitBaseProps<Entity, Base>, Key>]-?: EntitySchemaProperty<ExpandProperty<NonNullable<Entity[Key]>>, Entity>;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
-
export declare class EntitySchema<Entity = any, Base = never> {
|
|
42
|
+
export declare class EntitySchema<Entity = any, Base = never, Class extends EntityCtor = any> {
|
|
43
43
|
/**
|
|
44
44
|
* When schema links the entity class via `class` option, this registry allows the lookup from opposite side,
|
|
45
45
|
* so we can use the class in `entities` option just like the EntitySchema instance.
|
|
46
46
|
*/
|
|
47
|
-
static REGISTRY: Map<Partial<any>, EntitySchema<any, never>>;
|
|
47
|
+
static REGISTRY: Map<Partial<any>, EntitySchema<any, never, any>>;
|
|
48
48
|
private readonly _meta;
|
|
49
49
|
private internal;
|
|
50
50
|
private initialized;
|
|
51
|
-
constructor(meta: EntitySchemaMetadata<Entity, Base>);
|
|
51
|
+
constructor(meta: EntitySchemaMetadata<Entity, Base, Class>);
|
|
52
52
|
static fromMetadata<T = AnyEntity, U = never>(meta: EntityMetadata<T> | DeepPartial<EntityMetadata<T>>): EntitySchema<T, U>;
|
|
53
53
|
addProperty(name: EntityKey<Entity>, type?: TypeType, options?: PropertyOptions<Entity> | EntityProperty<Entity>): void;
|
|
54
54
|
addEnum(name: EntityKey<Entity>, type?: TypeType, options?: EnumOptions<Entity>): void;
|
|
@@ -64,11 +64,13 @@ export declare class EntitySchema<Entity = any, Base = never> {
|
|
|
64
64
|
addUnique<Key extends string>(options: UniqueOptions<Entity, Key>): void;
|
|
65
65
|
setCustomRepository(repository: () => Constructor): void;
|
|
66
66
|
setExtends(base: EntityName): void;
|
|
67
|
-
setClass(cls:
|
|
68
|
-
get meta(): EntityMetadata<Entity>;
|
|
67
|
+
setClass(cls: Class): void;
|
|
68
|
+
get meta(): EntityMetadata<Entity, Class>;
|
|
69
69
|
get name(): string | EntityName<Entity>;
|
|
70
70
|
get tableName(): string;
|
|
71
|
+
get class(): Class;
|
|
71
72
|
get properties(): Record<string, any>;
|
|
73
|
+
new(...params: ConstructorParameters<Class>): Entity;
|
|
72
74
|
/**
|
|
73
75
|
* @internal
|
|
74
76
|
*/
|
package/metadata/EntitySchema.js
CHANGED
|
@@ -175,9 +175,15 @@ export class EntitySchema {
|
|
|
175
175
|
get tableName() {
|
|
176
176
|
return this._meta.tableName;
|
|
177
177
|
}
|
|
178
|
+
get class() {
|
|
179
|
+
return this._meta.class;
|
|
180
|
+
}
|
|
178
181
|
get properties() {
|
|
179
182
|
return this._meta.properties;
|
|
180
183
|
}
|
|
184
|
+
new(...params) {
|
|
185
|
+
return new this._meta.class(...params);
|
|
186
|
+
}
|
|
181
187
|
/**
|
|
182
188
|
* @internal
|
|
183
189
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.122",
|
|
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",
|
package/typings.d.ts
CHANGED
|
@@ -159,7 +159,7 @@ export interface IWrappedEntity<Entity extends object> {
|
|
|
159
159
|
isInitialized(): boolean;
|
|
160
160
|
isManaged(): boolean;
|
|
161
161
|
populated(populated?: boolean): void;
|
|
162
|
-
populate<Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
162
|
+
populate<Hint extends string = never>(populate: readonly AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
163
163
|
init<Hint extends string = never, Fields extends string = '*', Exclude extends string = never>(options?: FindOneOptions<Entity, Hint, Fields, Exclude>): Promise<Loaded<Entity, Hint, Fields, Exclude> | null>;
|
|
164
164
|
toReference(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
|
|
165
165
|
toObject(): EntityDTO<Entity>;
|
|
@@ -209,7 +209,7 @@ export type AnyEntity<T = any> = Partial<T>;
|
|
|
209
209
|
export type EntityClass<T = any> = Function & {
|
|
210
210
|
prototype: T;
|
|
211
211
|
};
|
|
212
|
-
export type EntityName<T = any> = EntityClass<T> | EntitySchema<T, any> | {
|
|
212
|
+
export type EntityName<T = any> = EntityClass<T> | EntityCtor<T> | EntitySchema<T, any> | {
|
|
213
213
|
name: string;
|
|
214
214
|
};
|
|
215
215
|
export type GetRepository<Entity extends {
|
|
@@ -416,15 +416,15 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
416
416
|
createForeignKeyConstraint: boolean;
|
|
417
417
|
foreignKeyName?: string;
|
|
418
418
|
}
|
|
419
|
-
export declare class EntityMetadata<
|
|
419
|
+
export declare class EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
420
420
|
private static counter;
|
|
421
421
|
readonly _id: number;
|
|
422
422
|
readonly propertyOrder: Map<string, number>;
|
|
423
423
|
constructor(meta?: Partial<EntityMetadata>);
|
|
424
|
-
addProperty(prop: Partial<EntityProperty<
|
|
424
|
+
addProperty(prop: Partial<EntityProperty<Entity>>): void;
|
|
425
425
|
removeProperty(name: string, sync?: boolean): void;
|
|
426
|
-
getPrimaryProps(flatten?: boolean): EntityProperty<
|
|
427
|
-
getPrimaryProp(): EntityProperty<
|
|
426
|
+
getPrimaryProps(flatten?: boolean): EntityProperty<Entity>[];
|
|
427
|
+
getPrimaryProp(): EntityProperty<Entity>;
|
|
428
428
|
createColumnMappingObject(): Dictionary<any>;
|
|
429
429
|
get tableName(): string;
|
|
430
430
|
set tableName(name: string);
|
|
@@ -438,67 +438,68 @@ export interface SimpleColumnMeta {
|
|
|
438
438
|
name: string;
|
|
439
439
|
type: string;
|
|
440
440
|
}
|
|
441
|
-
export
|
|
441
|
+
export type EntityCtor<T = any> = abstract new (...args: any[]) => T;
|
|
442
|
+
export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
442
443
|
name?: string;
|
|
443
444
|
className: string;
|
|
444
445
|
tableName: string;
|
|
445
446
|
schema?: string;
|
|
446
447
|
pivotTable?: boolean;
|
|
447
448
|
virtual?: boolean;
|
|
448
|
-
expression?: string | ((em: any, where: ObjectQuery<
|
|
449
|
-
discriminatorColumn?: EntityKey<
|
|
449
|
+
expression?: string | ((em: any, where: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any>, stream?: boolean) => MaybePromise<Raw | object | string>);
|
|
450
|
+
discriminatorColumn?: EntityKey<Entity> | AnyString;
|
|
450
451
|
discriminatorValue?: number | string;
|
|
451
452
|
discriminatorMap?: Dictionary<EntityClass>;
|
|
452
453
|
embeddable: boolean;
|
|
453
|
-
constructorParams?: (keyof
|
|
454
|
+
constructorParams?: (keyof Entity)[];
|
|
454
455
|
forceConstructor: boolean;
|
|
455
|
-
extends?: EntityName<
|
|
456
|
+
extends?: EntityName<Entity>;
|
|
456
457
|
collection: string;
|
|
457
458
|
path: string;
|
|
458
|
-
primaryKeys: EntityKey<
|
|
459
|
+
primaryKeys: EntityKey<Entity>[];
|
|
459
460
|
simplePK: boolean;
|
|
460
461
|
compositePK: boolean;
|
|
461
|
-
versionProperty: EntityKey<
|
|
462
|
-
concurrencyCheckKeys: Set<EntityKey<
|
|
463
|
-
serializedPrimaryKey?: EntityKey<
|
|
462
|
+
versionProperty: EntityKey<Entity>;
|
|
463
|
+
concurrencyCheckKeys: Set<EntityKey<Entity>>;
|
|
464
|
+
serializedPrimaryKey?: EntityKey<Entity>;
|
|
464
465
|
properties: {
|
|
465
|
-
[K in EntityKey<
|
|
466
|
+
[K in EntityKey<Entity>]: EntityProperty<Entity>;
|
|
466
467
|
};
|
|
467
|
-
props: EntityProperty<
|
|
468
|
-
relations: EntityProperty<
|
|
469
|
-
bidirectionalRelations: EntityProperty<
|
|
468
|
+
props: EntityProperty<Entity>[];
|
|
469
|
+
relations: EntityProperty<Entity>[];
|
|
470
|
+
bidirectionalRelations: EntityProperty<Entity>[];
|
|
470
471
|
referencingProperties: {
|
|
471
|
-
meta: EntityMetadata<
|
|
472
|
-
prop: EntityProperty<
|
|
472
|
+
meta: EntityMetadata<Entity>;
|
|
473
|
+
prop: EntityProperty<Entity>;
|
|
473
474
|
}[];
|
|
474
|
-
comparableProps: EntityProperty<
|
|
475
|
-
trackingProps: EntityProperty<
|
|
476
|
-
hydrateProps: EntityProperty<
|
|
477
|
-
validateProps: EntityProperty<
|
|
478
|
-
uniqueProps: EntityProperty<
|
|
479
|
-
getterProps: EntityProperty<
|
|
475
|
+
comparableProps: EntityProperty<Entity>[];
|
|
476
|
+
trackingProps: EntityProperty<Entity>[];
|
|
477
|
+
hydrateProps: EntityProperty<Entity>[];
|
|
478
|
+
validateProps: EntityProperty<Entity>[];
|
|
479
|
+
uniqueProps: EntityProperty<Entity>[];
|
|
480
|
+
getterProps: EntityProperty<Entity>[];
|
|
480
481
|
indexes: {
|
|
481
|
-
properties?: EntityKey<
|
|
482
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
482
483
|
name?: string;
|
|
483
484
|
type?: string;
|
|
484
485
|
options?: Dictionary;
|
|
485
|
-
expression?: string | IndexCallback<
|
|
486
|
+
expression?: string | IndexCallback<Entity>;
|
|
486
487
|
}[];
|
|
487
488
|
uniques: {
|
|
488
|
-
properties?: EntityKey<
|
|
489
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
489
490
|
name?: string;
|
|
490
491
|
options?: Dictionary;
|
|
491
|
-
expression?: string | IndexCallback<
|
|
492
|
+
expression?: string | IndexCallback<Entity>;
|
|
492
493
|
deferMode?: DeferMode | `${DeferMode}`;
|
|
493
494
|
}[];
|
|
494
|
-
checks: CheckConstraint<
|
|
495
|
+
checks: CheckConstraint<Entity>[];
|
|
495
496
|
repositoryClass?: string;
|
|
496
497
|
repository: () => EntityClass<EntityRepository<any>>;
|
|
497
498
|
hooks: {
|
|
498
|
-
[K in EventType]?: (keyof
|
|
499
|
+
[K in EventType]?: (keyof Entity | EventSubscriber<Entity>[EventType])[];
|
|
499
500
|
};
|
|
500
|
-
prototype:
|
|
501
|
-
class:
|
|
501
|
+
prototype: Entity;
|
|
502
|
+
class: Class;
|
|
502
503
|
abstract: boolean;
|
|
503
504
|
filters: Dictionary<FilterDef>;
|
|
504
505
|
comment?: string;
|
|
@@ -506,7 +507,7 @@ export interface EntityMetadata<T = any> {
|
|
|
506
507
|
hasUniqueProps?: boolean;
|
|
507
508
|
readonly?: boolean;
|
|
508
509
|
polymorphs?: EntityMetadata[];
|
|
509
|
-
root: EntityMetadata<
|
|
510
|
+
root: EntityMetadata<Entity>;
|
|
510
511
|
definedProperties: Dictionary;
|
|
511
512
|
hasTriggers?: boolean;
|
|
512
513
|
/** @internal can be used for computed numeric cache keys */
|
|
@@ -849,7 +850,7 @@ export interface Seeder<T extends Dictionary = Dictionary> {
|
|
|
849
850
|
export type ConnectionType = 'read' | 'write';
|
|
850
851
|
export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
|
|
851
852
|
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
852
|
-
export interface EntitySchemaWithMeta<TName extends string = string, TTableName extends string = string, TEntity = any, TBase = never, TProperties extends Record<string, any> = Record<string, any
|
|
853
|
+
export interface EntitySchemaWithMeta<TName extends string = string, TTableName extends string = string, TEntity = any, TBase = never, TProperties extends Record<string, any> = Record<string, any>, TClass extends EntityCtor = any> extends EntitySchema<TEntity, TBase, TClass> {
|
|
853
854
|
readonly name: TName;
|
|
854
855
|
readonly properties: TProperties;
|
|
855
856
|
readonly tableName: TTableName;
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.122';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|