, PK extends keyof T, P = never> {
isInitialized(): boolean;
populated(populated?: boolean): void;
init = Populate>(populated?: boolean, populate?: P, lockMode?: LockMode): Promise;
toReference(): IdentifiedReference & LoadedReference;
toObject(ignoreFields?: string[]): Dictionary;
toJSON(...args: any[]): Dictionary;
assign(data: any, options?: AssignOptions | boolean): T;
}
export interface IWrappedEntityInternal, PK extends keyof T, P = keyof T> extends IWrappedEntity {
hasPrimaryKey(): boolean;
__meta: EntityMetadata;
__data: Dictionary;
__em?: any;
__platform: Platform;
__initialized: boolean;
__originalEntityData?: EntityData;
__identifier?: EntityIdentifier;
__managed: boolean;
__populated: boolean;
__lazyInitialized: boolean;
__primaryKey: PrimaryMap;
__primaryKeys: Primary[];
__serializedPrimaryKey: string & keyof T;
}
export declare type AnyEntity = {
[K in keyof T]?: T[K];
} & {
[PrimaryKeyType]?: unknown;
[EntityRepositoryType]?: unknown;
__helper?: IWrappedEntityInternal;
__meta?: EntityMetadata;
__platform?: Platform;
};
export declare type EntityClass> = Function & {
prototype: T;
};
export declare type EntityClassGroup> = {
entity: EntityClass;
schema: EntityMetadata | EntitySchema;
};
export declare type EntityName> = string | EntityClass | EntitySchema;
export declare type EntityDataProp = T extends Scalar ? ExpandScalar : (T | EntityData | Primary);
export declare type CollectionItem = T extends Collection | undefined ? EntityDataProp>[] : EntityDataProp;
export declare type EntityData = T | {
[K in keyof T | NonFunctionPropertyNames]?: CollectionItem;
} & Dictionary;
export declare type GetRepository, U> = T[typeof EntityRepositoryType] extends EntityRepository | undefined ? NonNullable : U;
export interface EntityProperty = any> {
name: string & keyof T;
entity: () => EntityName;
type: string;
columnTypes: string[];
customType: Type;
primary: boolean;
serializedPrimaryKey: boolean;
lazy?: boolean;
length?: any;
reference: ReferenceType;
wrappedReference?: boolean;
fieldNames: string[];
default?: string | number | boolean | null;
defaultRaw?: string;
formula?: (alias: string) => string;
prefix?: string | boolean;
embedded?: [string, string];
embeddable: Constructor;
embeddedProps: Dictionary;
index?: boolean | string;
unique?: boolean | string;
nullable?: boolean;
inherited?: boolean;
unsigned: boolean;
persist?: boolean;
hidden?: boolean;
enum?: boolean;
items?: (number | string)[];
version?: boolean;
eager?: boolean;
setter?: boolean;
getter?: boolean;
getterName?: keyof T;
cascade: Cascade[];
orphanRemoval?: boolean;
onCreate?: (entity: T) => any;
onUpdate?: (entity: T) => any;
onDelete?: 'cascade' | 'no action' | 'set null' | 'set default' | string;
onUpdateIntegrity?: 'cascade' | 'no action' | 'set null' | 'set default' | string;
strategy?: LoadStrategy;
owner: boolean;
inversedBy: string;
mappedBy: string;
orderBy?: {
[field: string]: QueryOrder;
};
fixedOrder?: boolean;
fixedOrderColumn?: string;
pivotTable: string;
joinColumns: string[];
inverseJoinColumns: string[];
referencedColumnNames: string[];
referencedTableName: string;
serializer?: (value: any) => any;
serializedName?: string;
comment?: string;
userDefined?: boolean;
}
export interface EntityMetadata = any> {
name?: string;
className: string;
tableName: string;
pivotTable: boolean;
discriminatorColumn?: string;
discriminatorValue?: string;
discriminatorMap?: Dictionary;
embeddable: boolean;
constructorParams: string[];
toJsonParams: string[];
extends: string;
collection: string;
path: string;
primaryKeys: (keyof T & string)[];
compositePK: boolean;
versionProperty: keyof T & string;
serializedPrimaryKey: keyof T & string;
properties: {
[K in keyof T & string]: EntityProperty;
};
props: EntityProperty[];
relations: EntityProperty[];
comparableProps: EntityProperty[];
indexes: {
properties: (keyof T & string) | (keyof T & string)[];
name?: string;
type?: string;
options?: Dictionary;
}[];
uniques: {
properties: (keyof T & string) | (keyof T & string)[];
name?: string;
options?: Dictionary;
}[];
customRepository: () => Constructor>;
hooks: Partial>;
prototype: T;
class: Constructor;
abstract: boolean;
useCache: boolean;
filters: Dictionary>;
comment?: string;
readonly?: boolean;
root: EntityMetadata;
}
export interface ISchemaGenerator {
generate(): Promise;
createSchema(wrap?: boolean): Promise;
ensureDatabase(): Promise;
getCreateSchemaSQL(wrap?: boolean): Promise;
dropSchema(wrap?: boolean, dropMigrationsTable?: boolean, dropDb?: boolean): Promise;
getDropSchemaSQL(wrap?: boolean, dropMigrationsTable?: boolean): Promise;
updateSchema(wrap?: boolean, safe?: boolean, dropDb?: boolean, dropTables?: boolean): Promise;
getUpdateSchemaSQL(wrap?: boolean, safe?: boolean, dropDb?: boolean, dropTables?: boolean): Promise;
createDatabase(name: string): Promise;
dropDatabase(name: string): Promise;
execute(sql: string): Promise;
}
export interface IEntityGenerator {
generate(options?: {
baseDir?: string;
save?: boolean;
}): Promise;
}
declare type UmzugMigration = {
path?: string;
file: string;
};
declare type MigrateOptions = {
from?: string | number;
to?: string | number;
migrations?: string[];
};
declare type MigrationResult = {
fileName: string;
code: string;
diff: string[];
};
declare type MigrationRow = {
name: string;
executed_at: Date;
};
export interface IMigrator {
createMigration(path?: string, blank?: boolean): Promise;
getExecutedMigrations(): Promise;
getPendingMigrations(): Promise;
up(options?: string | string[] | MigrateOptions): Promise;
down(options?: string | string[] | MigrateOptions): Promise;
}
export interface Migration {
up(): Promise;
down(): Promise;
}
export interface MigrationObject {
name: string;
class: Constructor;
}
export declare type FilterDef> = {
name: string;
cond: FilterQuery | ((args: Dictionary, type: 'read' | 'update' | 'delete') => FilterQuery | Promise>);
default?: boolean;
entity?: string[];
args?: boolean;
};
export declare type ExpandProperty = T extends Reference ? NonNullable : T extends Collection ? NonNullable : NonNullable;
export declare type PopulateChildren = {
[K in keyof T]?: PopulateMap>;
};
export declare type PopulateMap = boolean | LoadStrategy | PopulateChildren;
export declare type Populate = readonly (keyof T)[] | readonly string[] | boolean | PopulateMap;
export declare type PopulateOptions = {
field: string;
strategy?: LoadStrategy;
all?: boolean;
children?: PopulateOptions[];
};
export interface LoadedReference, P = never> extends Reference {
$: T & P;
get(): T & P;
}
export interface LoadedCollection, P = never> extends Collection {
$: readonly (T & P)[];
get(): readonly (T & P)[];
}
declare type MarkLoaded, P, H = unknown> = P extends Reference ? LoadedReference> : P extends Collection ? LoadedCollection> : P;
declare type LoadedIfInKeyHint, K extends keyof T, H> = K extends H ? MarkLoaded : T[K];
declare type LoadedIfInNestedHint, K extends keyof T, H> = K extends keyof H ? MarkLoaded : T[K];
declare type SubType = Pick;
declare type RelationsIn = SubType | Reference | undefined>;
declare type NestedLoadHint = {
[K in keyof RelationsIn]?: true | LoadStrategy | PopulateMap>;
};
export declare type Loaded, P = unknown> = unknown extends P ? T : T & {
[K in keyof RelationsIn]: P extends readonly (infer U)[] ? LoadedIfInKeyHint : P extends NestedLoadHint ? LoadedIfInNestedHint : LoadedIfInKeyHint;
};
export declare type New, P = string[]> = Loaded;
export interface Highlighter {
highlight(text: string): string;
}
export interface IMetadataStorage {
getAll(): Dictionary;
get = any>(entity: string, init?: boolean, validate?: boolean): EntityMetadata;
find = any>(entity: string): EntityMetadata | undefined;
has(entity: string): boolean;
set(entity: string, meta: EntityMetadata): EntityMetadata;
reset(entity: string): void;
}
export {};