@mikro-orm/core 7.0.0-dev.22 → 7.0.0-dev.221
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.d.ts +101 -59
- package/EntityManager.js +302 -276
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +109 -143
- package/README.md +3 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +8 -7
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +0 -1
- package/cache/index.js +0 -1
- package/connections/Connection.d.ts +16 -7
- package/connections/Connection.js +23 -14
- package/drivers/DatabaseDriver.d.ts +25 -16
- package/drivers/DatabaseDriver.js +80 -35
- package/drivers/IDatabaseDriver.d.ts +46 -19
- package/entity/BaseEntity.d.ts +61 -2
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +94 -29
- package/entity/Collection.js +434 -97
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +26 -18
- package/entity/EntityFactory.d.ts +13 -1
- package/entity/EntityFactory.js +84 -53
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +40 -15
- package/entity/EntityLoader.d.ts +6 -6
- package/entity/EntityLoader.js +119 -82
- package/entity/EntityRepository.d.ts +27 -7
- package/entity/EntityRepository.js +8 -2
- package/entity/Reference.d.ts +6 -5
- package/entity/Reference.js +34 -9
- package/entity/WrappedEntity.d.ts +0 -5
- package/entity/WrappedEntity.js +3 -8
- package/entity/defineEntity.d.ts +595 -0
- package/entity/defineEntity.js +533 -0
- package/entity/index.d.ts +3 -2
- package/entity/index.js +3 -2
- package/entity/utils.d.ts +7 -0
- package/entity/utils.js +16 -4
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/enums.d.ts +22 -7
- package/enums.js +15 -1
- package/errors.d.ts +22 -9
- package/errors.js +56 -21
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +19 -11
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +52 -33
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +1 -0
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +7 -6
- package/logging/index.d.ts +1 -0
- package/logging/index.js +1 -0
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +40 -23
- package/metadata/EntitySchema.js +81 -34
- package/metadata/MetadataDiscovery.d.ts +7 -10
- package/metadata/MetadataDiscovery.js +391 -331
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +46 -2
- package/metadata/MetadataStorage.d.ts +13 -11
- package/metadata/MetadataStorage.js +70 -37
- package/metadata/MetadataValidator.d.ts +17 -9
- package/metadata/MetadataValidator.js +94 -40
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +1 -1
- package/metadata/types.d.ts +498 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +12 -4
- package/naming-strategy/AbstractNamingStrategy.js +14 -2
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +24 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -11
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +10 -15
- package/platforms/Platform.js +20 -43
- package/serialization/EntitySerializer.d.ts +5 -0
- package/serialization/EntitySerializer.js +47 -27
- package/serialization/EntityTransformer.js +28 -18
- package/serialization/SerializationContext.d.ts +6 -6
- package/serialization/SerializationContext.js +16 -13
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.d.ts +8 -6
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +2 -1
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +3 -3
- package/types/DoubleType.js +2 -2
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/index.d.ts +1 -1
- package/typings.d.ts +315 -155
- package/typings.js +66 -44
- package/unit-of-work/ChangeSet.d.ts +2 -6
- package/unit-of-work/ChangeSet.js +4 -5
- package/unit-of-work/ChangeSetComputer.d.ts +1 -3
- package/unit-of-work/ChangeSetComputer.js +26 -13
- package/unit-of-work/ChangeSetPersister.d.ts +5 -4
- package/unit-of-work/ChangeSetPersister.js +70 -34
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +13 -13
- package/unit-of-work/IdentityMap.d.ts +12 -0
- package/unit-of-work/IdentityMap.js +39 -1
- package/unit-of-work/UnitOfWork.d.ts +23 -3
- package/unit-of-work/UnitOfWork.js +175 -98
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +18 -16
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +791 -207
- package/utils/Configuration.js +147 -190
- package/utils/ConfigurationLoader.d.ts +1 -54
- package/utils/ConfigurationLoader.js +1 -352
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +27 -11
- package/utils/DataloaderUtils.d.ts +15 -5
- package/utils/DataloaderUtils.js +64 -30
- package/utils/EntityComparator.d.ts +13 -9
- package/utils/EntityComparator.js +101 -42
- package/utils/QueryHelper.d.ts +14 -6
- package/utils/QueryHelper.js +87 -25
- package/utils/RawQueryFragment.d.ts +60 -32
- package/utils/RawQueryFragment.js +68 -70
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +13 -126
- package/utils/Utils.js +100 -391
- package/utils/clone.js +8 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +97 -0
- package/utils/fs-utils.d.ts +33 -0
- package/utils/fs-utils.js +192 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -1
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +55 -4
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -18
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -40
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -32
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -26
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -13
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -116
- package/entity/ArrayCollection.js +0 -402
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
package/typings.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Transaction } from './connections/Connection.js';
|
|
2
|
-
import { type Cascade, type DeferMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums.js';
|
|
2
|
+
import { type Cascade, type DeferMode, type EmbeddedPrefixMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums.js';
|
|
3
3
|
import { type AssignOptions } from './entity/EntityAssigner.js';
|
|
4
4
|
import { type EntityIdentifier } from './entity/EntityIdentifier.js';
|
|
5
5
|
import { type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
@@ -7,7 +7,6 @@ import { type Collection } from './entity/Collection.js';
|
|
|
7
7
|
import { type EntityFactory } from './entity/EntityFactory.js';
|
|
8
8
|
import { type EntityRepository } from './entity/EntityRepository.js';
|
|
9
9
|
import { Reference, type ScalarReference } from './entity/Reference.js';
|
|
10
|
-
import type { MikroORM } from './MikroORM.js';
|
|
11
10
|
import type { SerializationContext } from './serialization/SerializationContext.js';
|
|
12
11
|
import type { SerializeOptions } from './serialization/EntitySerializer.js';
|
|
13
12
|
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
@@ -15,11 +14,10 @@ import type { EntitySchema } from './metadata/EntitySchema.js';
|
|
|
15
14
|
import type { Type, types } from './types/index.js';
|
|
16
15
|
import type { Platform } from './platforms/Platform.js';
|
|
17
16
|
import type { Configuration } from './utils/Configuration.js';
|
|
18
|
-
import type {
|
|
17
|
+
import type { Raw } from './utils/RawQueryFragment.js';
|
|
19
18
|
import type { EntityManager } from './EntityManager.js';
|
|
20
|
-
import type { EmbeddedPrefixMode } from './decorators/Embedded.js';
|
|
21
19
|
import type { EventSubscriber } from './events/EventSubscriber.js';
|
|
22
|
-
import type { FindOneOptions, FindOptions, LoadHint } from './drivers/IDatabaseDriver.js';
|
|
20
|
+
import type { FilterOptions, FindOneOptions, FindOptions, LoadHint } from './drivers/IDatabaseDriver.js';
|
|
23
21
|
export type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
24
22
|
export type Dictionary<T = any> = {
|
|
25
23
|
[k: string]: T;
|
|
@@ -42,7 +40,64 @@ export type IsUnknown<T> = T extends unknown ? unknown extends T ? true : never
|
|
|
42
40
|
export type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
43
41
|
export type IsNever<T, True = true, False = false> = [T] extends [never] ? True : False;
|
|
44
42
|
export type MaybePromise<T> = T | Promise<T>;
|
|
45
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Structural type for matching Collection without triggering full interface evaluation.
|
|
45
|
+
* Using `T extends CollectionShape` instead of `T extends Collection<any, any>` avoids
|
|
46
|
+
* forcing TypeScript to evaluate Collection's 30+ methods, preventing instantiation explosion
|
|
47
|
+
* (~133k → ~2k instantiations).
|
|
48
|
+
*
|
|
49
|
+
* Usage:
|
|
50
|
+
* - Matching only: `T extends CollectionShape`
|
|
51
|
+
* - With inference: `T extends CollectionShape<infer U>`
|
|
52
|
+
*/
|
|
53
|
+
type CollectionShape<T = any> = {
|
|
54
|
+
[k: number]: T;
|
|
55
|
+
readonly owner: object;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Structural type for matching LoadedCollection (extends CollectionShape with `$` property).
|
|
59
|
+
*
|
|
60
|
+
* Usage:
|
|
61
|
+
* - Matching only: `T extends LoadedCollectionShape`
|
|
62
|
+
* - With inference: `T extends LoadedCollectionShape<infer U>`
|
|
63
|
+
*/
|
|
64
|
+
type LoadedCollectionShape<T = any> = CollectionShape<T> & {
|
|
65
|
+
$: any;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Structural type for matching Reference without triggering full class evaluation.
|
|
69
|
+
* Using `T extends ReferenceShape` instead of `T extends Reference<any>` avoids
|
|
70
|
+
* forcing TypeScript to evaluate Reference's methods, preventing instantiation overhead
|
|
71
|
+
* (~800 → ~15 instantiations).
|
|
72
|
+
*
|
|
73
|
+
* Usage:
|
|
74
|
+
* - Matching only: `T extends ReferenceShape`
|
|
75
|
+
* - With inference: `T extends ReferenceShape<infer U>`
|
|
76
|
+
*/
|
|
77
|
+
type ReferenceShape<T = any> = {
|
|
78
|
+
unwrap(): T;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Structural type for matching LoadedReference (Reference with `$` property).
|
|
82
|
+
* Note: We don't parameterize ReferenceShape here because for loaded relations,
|
|
83
|
+
* the Reference unwrap() returns the base type while $ returns the Loaded type.
|
|
84
|
+
* We infer T from $ to get the full Loaded type for EntityDTO.
|
|
85
|
+
*/
|
|
86
|
+
type LoadedReferenceShape<T = any> = ReferenceShape & {
|
|
87
|
+
$: T;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Structural type for matching any loadable relation (Collection, Reference, or array).
|
|
91
|
+
* Using this instead of `Loadable<any>` in conditional type checks prevents
|
|
92
|
+
* TypeScript from evaluating the full Collection/Reference interfaces.
|
|
93
|
+
*/
|
|
94
|
+
type LoadableShape = CollectionShape | ReferenceShape | readonly any[];
|
|
95
|
+
export type UnionKeys<T> = T extends any ? keyof T : never;
|
|
96
|
+
export type UnionPropertyType<T, K extends PropertyKey> = T extends any ? (K extends keyof T ? T[K] : never) : never;
|
|
97
|
+
type IsUnion<T, U = T> = T extends any ? ([U] extends [T] ? false : true) : false;
|
|
98
|
+
export type MergeUnion<T> = [T] extends [object] ? (T extends Scalar ? T : IsUnion<T> extends true ? {
|
|
99
|
+
[K in UnionKeys<T>]: UnionPropertyType<T, K>;
|
|
100
|
+
} : T) : T;
|
|
46
101
|
export type DeepPartial<T> = T & {
|
|
47
102
|
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends Readonly<infer U>[] ? Readonly<DeepPartial<U>>[] : DeepPartial<T[P]>;
|
|
48
103
|
};
|
|
@@ -52,36 +107,63 @@ export declare const OptionalProps: unique symbol;
|
|
|
52
107
|
export declare const EagerProps: unique symbol;
|
|
53
108
|
export declare const HiddenProps: unique symbol;
|
|
54
109
|
export declare const Config: unique symbol;
|
|
55
|
-
|
|
56
|
-
declare
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
export type Opt<T = unknown> = T & Opt.Brand;
|
|
111
|
+
export declare namespace Opt {
|
|
112
|
+
const __optional: unique symbol;
|
|
113
|
+
interface Brand {
|
|
114
|
+
[__optional]?: 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export type RequiredNullable<T = never> = (T & RequiredNullable.Brand) | null;
|
|
118
|
+
export declare namespace RequiredNullable {
|
|
119
|
+
const __requiredNullable: unique symbol;
|
|
120
|
+
interface Brand {
|
|
121
|
+
[__requiredNullable]?: 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export type Hidden<T = unknown> = T & Hidden.Brand;
|
|
125
|
+
export declare namespace Hidden {
|
|
126
|
+
const __hidden: unique symbol;
|
|
127
|
+
interface Brand {
|
|
128
|
+
[__hidden]?: 1;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export type DefineConfig<T extends TypeConfig> = T & DefineConfig.Brand;
|
|
132
|
+
export declare namespace DefineConfig {
|
|
133
|
+
const __config: unique symbol;
|
|
134
|
+
interface Brand {
|
|
135
|
+
[__config]?: 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
67
138
|
export type CleanTypeConfig<T> = Compute<Pick<T, Extract<keyof T, keyof TypeConfig>>>;
|
|
68
139
|
export interface TypeConfig {
|
|
69
140
|
forceObject?: boolean;
|
|
70
141
|
}
|
|
71
|
-
|
|
142
|
+
declare const __selectedType: unique symbol;
|
|
143
|
+
declare const __loadedType: unique symbol;
|
|
144
|
+
declare const __loadHint: unique symbol;
|
|
145
|
+
/**
|
|
146
|
+
* Expands a populate hint into all its prefixes.
|
|
147
|
+
* e.g., Prefixes<'a.b.c'> = 'a' | 'a.b' | 'a.b.c'
|
|
148
|
+
* This reflects that loading 'a.b.c' means 'a' and 'a.b' are also loaded.
|
|
149
|
+
* Special case: '*' returns string to ensure Loaded<T, '*'> is assignable to any Loaded<T, Hint>.
|
|
150
|
+
*/
|
|
151
|
+
type Prefixes<S extends string> = S extends '*' ? string : S extends `${infer H}.${infer T}` ? H | `${H}.${Prefixes<T>}` : S;
|
|
152
|
+
export type UnwrapPrimary<T> = T extends Scalar ? T : T extends ReferenceShape<infer U> ? Primary<U> : Primary<T>;
|
|
72
153
|
type PrimaryPropToType<T, Keys extends (keyof T)[]> = {
|
|
73
154
|
[Index in keyof Keys]: UnwrapPrimary<T[Keys[Index]]>;
|
|
74
155
|
};
|
|
75
156
|
type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
|
|
76
157
|
export type Primary<T> = IsAny<T> extends true ? any : T extends {
|
|
77
158
|
[PrimaryKeyProp]?: infer PK;
|
|
78
|
-
} ?
|
|
159
|
+
} ? PK extends undefined ? Omit<T, typeof PrimaryKeyProp> : PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends (keyof T)[] ? ReadonlyPrimary<PrimaryPropToType<T, PK>> : PK : T extends {
|
|
79
160
|
_id?: infer PK;
|
|
80
161
|
} ? ReadonlyPrimary<PK> | string : T extends {
|
|
81
|
-
uuid?: infer PK;
|
|
82
|
-
} ? ReadonlyPrimary<PK> : T extends {
|
|
83
162
|
id?: infer PK;
|
|
163
|
+
} ? ReadonlyPrimary<PK> : T extends {
|
|
164
|
+
uuid?: infer PK;
|
|
84
165
|
} ? ReadonlyPrimary<PK> : T;
|
|
166
|
+
/** @internal */
|
|
85
167
|
export type PrimaryProperty<T> = T extends {
|
|
86
168
|
[PrimaryKeyProp]?: infer PK;
|
|
87
169
|
} ? (PK extends keyof T ? PK : (PK extends any[] ? PK[number] : never)) : T extends {
|
|
@@ -89,10 +171,10 @@ export type PrimaryProperty<T> = T extends {
|
|
|
89
171
|
} ? (T extends {
|
|
90
172
|
id?: any;
|
|
91
173
|
} ? 'id' | '_id' : '_id') : T extends {
|
|
92
|
-
uuid?: any;
|
|
93
|
-
} ? 'uuid' : T extends {
|
|
94
174
|
id?: any;
|
|
95
|
-
} ? 'id' :
|
|
175
|
+
} ? 'id' : T extends {
|
|
176
|
+
uuid?: any;
|
|
177
|
+
} ? 'uuid' : never;
|
|
96
178
|
export type IPrimaryKeyValue = number | string | bigint | Date | {
|
|
97
179
|
toHexString(): string;
|
|
98
180
|
};
|
|
@@ -100,22 +182,35 @@ export type IPrimaryKey<T extends IPrimaryKeyValue = IPrimaryKeyValue> = T;
|
|
|
100
182
|
export type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Uint8Array | {
|
|
101
183
|
toHexString(): string;
|
|
102
184
|
};
|
|
185
|
+
type Primitive = boolean | number | string | bigint | symbol;
|
|
103
186
|
export type ExpandScalar<T> = null | (T extends string ? T | RegExp : T extends Date ? Date | string : T extends bigint ? bigint | string | number : T);
|
|
187
|
+
/** Marker interface for query builders that can be used as subqueries */
|
|
188
|
+
export interface Subquery {
|
|
189
|
+
readonly __subquery: true;
|
|
190
|
+
}
|
|
104
191
|
export type OperatorMap<T> = {
|
|
105
192
|
$and?: ExpandQuery<T>[];
|
|
106
193
|
$or?: ExpandQuery<T>[];
|
|
107
|
-
$eq?: ExpandScalar<T> | readonly ExpandScalar<T>[];
|
|
108
|
-
$ne?: ExpandScalar<T
|
|
109
|
-
$in?: readonly ExpandScalar<T>[];
|
|
110
|
-
$nin?: readonly ExpandScalar<T>[];
|
|
194
|
+
$eq?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
195
|
+
$ne?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
196
|
+
$in?: readonly ExpandScalar<T>[] | readonly Primary<T>[] | Raw | Subquery;
|
|
197
|
+
$nin?: readonly ExpandScalar<T>[] | readonly Primary<T>[] | Raw | Subquery;
|
|
111
198
|
$not?: ExpandQuery<T>;
|
|
112
199
|
$none?: ExpandQuery<T>;
|
|
113
200
|
$some?: ExpandQuery<T>;
|
|
114
201
|
$every?: ExpandQuery<T>;
|
|
115
|
-
$
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
202
|
+
$size?: number | {
|
|
203
|
+
$eq?: number;
|
|
204
|
+
$ne?: number;
|
|
205
|
+
$gt?: number;
|
|
206
|
+
$gte?: number;
|
|
207
|
+
$lt?: number;
|
|
208
|
+
$lte?: number;
|
|
209
|
+
};
|
|
210
|
+
$gt?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
211
|
+
$gte?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
212
|
+
$lt?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
213
|
+
$lte?: ExpandScalar<T> | readonly ExpandScalar<T>[] | Subquery;
|
|
119
214
|
$like?: string;
|
|
120
215
|
$re?: string;
|
|
121
216
|
$ilike?: string;
|
|
@@ -128,25 +223,24 @@ export type OperatorMap<T> = {
|
|
|
128
223
|
$hasKeys?: readonly string[];
|
|
129
224
|
$hasSomeKeys?: readonly string[];
|
|
130
225
|
};
|
|
131
|
-
export type FilterItemValue<T> = T | ExpandScalar<T> | Primary<T
|
|
226
|
+
export type FilterItemValue<T> = T | ExpandScalar<T> | Primary<T> | Raw;
|
|
132
227
|
export type FilterValue<T> = OperatorMap<FilterItemValue<T>> | FilterItemValue<T> | FilterItemValue<T>[] | null;
|
|
228
|
+
type FilterObjectProp<T, K extends PropertyKey> = K extends keyof MergeUnion<T> ? MergeUnion<T>[K] : K extends keyof T ? T[K] : never;
|
|
229
|
+
type ExpandQueryMerged<T> = [T] extends [object] ? [T] extends [Scalar] ? never : FilterQuery<MergeUnion<T>> : FilterValue<T>;
|
|
133
230
|
export type FilterObject<T> = {
|
|
134
|
-
-readonly [K in EntityKey<T>]?: ExpandQuery<ExpandProperty<T
|
|
231
|
+
-readonly [K in EntityKey<T>]?: ExpandQuery<ExpandProperty<FilterObjectProp<T, K>>> | ExpandQueryMerged<ExpandProperty<FilterObjectProp<T, K>>> | FilterValue<ExpandProperty<FilterObjectProp<T, K>>> | null;
|
|
135
232
|
};
|
|
136
|
-
export type ExpandObject<T> = T extends object ? T extends Scalar ? never : FilterObject<T> : never;
|
|
137
233
|
export type ExpandQuery<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
|
|
138
234
|
export type EntityProps<T> = {
|
|
139
235
|
-readonly [K in EntityKey<T>]?: T[K];
|
|
140
236
|
};
|
|
141
237
|
export type ObjectQuery<T> = OperatorMap<T> & FilterObject<T>;
|
|
142
238
|
export type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T>>> | NonNullable<EntityProps<T> & OperatorMap<T>> | FilterQuery<T>[];
|
|
143
|
-
export type QBFilterQuery<T = any> = ObjectQuery<T> | Dictionary;
|
|
144
239
|
export interface IWrappedEntity<Entity extends object> {
|
|
145
240
|
isInitialized(): boolean;
|
|
146
|
-
isTouched(): boolean;
|
|
147
241
|
isManaged(): boolean;
|
|
148
242
|
populated(populated?: boolean): void;
|
|
149
|
-
populate<Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
243
|
+
populate<Hint extends string = never>(populate: readonly AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
150
244
|
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>;
|
|
151
245
|
toReference(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
|
|
152
246
|
toObject(): EntityDTO<Entity>;
|
|
@@ -174,7 +268,6 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
174
268
|
__factory: EntityFactory;
|
|
175
269
|
__hydrator: IHydrator;
|
|
176
270
|
__initialized: boolean;
|
|
177
|
-
__touched: boolean;
|
|
178
271
|
__originalEntityData?: EntityData<Entity>;
|
|
179
272
|
__loadedProperties: Set<string>;
|
|
180
273
|
__identifier?: EntityIdentifier | EntityIdentifier[];
|
|
@@ -194,16 +287,10 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
194
287
|
};
|
|
195
288
|
}
|
|
196
289
|
export type AnyEntity<T = any> = Partial<T>;
|
|
197
|
-
export type EntityClass<T> = Function & {
|
|
290
|
+
export type EntityClass<T = any> = Function & {
|
|
198
291
|
prototype: T;
|
|
199
292
|
};
|
|
200
|
-
export type
|
|
201
|
-
entity: EntityClass<T>;
|
|
202
|
-
schema: EntityMetadata<T> | EntitySchema<T>;
|
|
203
|
-
};
|
|
204
|
-
export type EntityName<T> = string | EntityClass<T> | EntitySchema<T, any> | {
|
|
205
|
-
name: string;
|
|
206
|
-
};
|
|
293
|
+
export type EntityName<T = any> = EntityClass<T> | EntityCtor<T> | EntitySchema<T, any>;
|
|
207
294
|
export type GetRepository<Entity extends {
|
|
208
295
|
[k: PropertyKey]: any;
|
|
209
296
|
}, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<any> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback;
|
|
@@ -223,13 +310,13 @@ type NonArrayObject = object & {
|
|
|
223
310
|
export type EntityDataProp<T, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
224
311
|
__runtime?: infer Runtime;
|
|
225
312
|
__raw?: infer Raw;
|
|
226
|
-
} ? (C extends true ? Raw : Runtime) : T extends
|
|
227
|
-
export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
313
|
+
} ? (C extends true ? Raw : Runtime) : T extends ReferenceShape<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends CollectionShape<infer U> ? U | U[] | EntityDataNested<U & object, C> | EntityDataNested<U & object, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : U[] | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
|
|
314
|
+
export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : Exclude<T, null> extends RequiredNullable.Brand ? T | null : T extends Scalar ? T : T extends {
|
|
228
315
|
__runtime?: infer Runtime;
|
|
229
316
|
__raw?: infer Raw;
|
|
230
|
-
} ? (C extends true ? Raw : Runtime) : T extends
|
|
317
|
+
} ? (C extends true ? Raw : Runtime) : T extends ReferenceShape<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends CollectionShape<infer U> ? U | U[] | RequiredEntityDataNested<U & object, O, C> | RequiredEntityDataNested<U & object, O, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : U[] | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
|
|
231
318
|
export type EntityDataNested<T, C extends boolean = false> = T extends undefined ? never : T extends any[] ? Readonly<T> : EntityData<T, C> | ExpandEntityProp<T, C>;
|
|
232
|
-
type EntityDataItem<T, C extends boolean> = C extends false ? T | EntityDataProp<T, C> | null : EntityDataProp<T, C> | null;
|
|
319
|
+
type EntityDataItem<T, C extends boolean> = C extends false ? T | EntityDataProp<T, C> | Raw | null : EntityDataProp<T, C> | Raw | null;
|
|
233
320
|
export type RequiredEntityDataNested<T, O, C extends boolean> = T extends any[] ? Readonly<T> : RequiredEntityData<T, O> | ExpandRequiredEntityProp<T, O, C>;
|
|
234
321
|
type ExplicitlyOptionalProps<T> = (T extends {
|
|
235
322
|
[OptionalProps]?: infer K;
|
|
@@ -239,17 +326,20 @@ type ExplicitlyOptionalProps<T> = (T extends {
|
|
|
239
326
|
type NullableKeys<T, V = null> = {
|
|
240
327
|
[K in keyof T]: V extends T[K] ? K : never;
|
|
241
328
|
}[keyof T];
|
|
242
|
-
type
|
|
243
|
-
|
|
329
|
+
type RequiredNullableKeys<T> = {
|
|
330
|
+
[K in keyof T]: Exclude<T[K], null> extends RequiredNullable.Brand ? K : never;
|
|
331
|
+
}[keyof T];
|
|
332
|
+
type ProbablyOptionalProps<T> = PrimaryProperty<T> | ExplicitlyOptionalProps<T> | Exclude<NonNullable<NullableKeys<T, null | undefined>>, RequiredNullableKeys<T>>;
|
|
333
|
+
type IsOptional<T, K extends keyof T, I> = T[K] extends CollectionShape ? true : ExtractType<T[K]> extends I ? true : K extends ProbablyOptionalProps<T> ? true : false;
|
|
244
334
|
type RequiredKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? CleanKeys<T, K> : never;
|
|
245
335
|
type OptionalKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? never : CleanKeys<T, K>;
|
|
246
336
|
export type EntityData<T, C extends boolean = false> = {
|
|
247
337
|
[K in EntityKey<T>]?: EntityDataItem<T[K] & {}, C>;
|
|
248
338
|
};
|
|
249
339
|
export type RequiredEntityData<T, I = never, C extends boolean = false> = {
|
|
250
|
-
[K in keyof T as RequiredKeys<T, K, I>]: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]
|
|
340
|
+
[K in keyof T as RequiredKeys<T, K, I>]: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]> | Raw;
|
|
251
341
|
} & {
|
|
252
|
-
[K in keyof T as OptionalKeys<T, K, I>]?: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]> | null;
|
|
342
|
+
[K in keyof T as OptionalKeys<T, K, I>]?: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]> | Raw | null;
|
|
253
343
|
};
|
|
254
344
|
export type EntityDictionary<T> = EntityData<T> & Record<any, any>;
|
|
255
345
|
type ExtractEagerProps<T> = T extends {
|
|
@@ -274,7 +364,7 @@ export type Ref<T> = T extends any ? IsAny<T> extends true ? Reference<T & objec
|
|
|
274
364
|
type ExtractHiddenProps<T> = (T extends {
|
|
275
365
|
[HiddenProps]?: infer K;
|
|
276
366
|
} ? K : never) | ({
|
|
277
|
-
[K in keyof T]: T[K] extends Hidden ? K : never;
|
|
367
|
+
[K in keyof T]: T[K] extends Primitive ? (T[K] extends Hidden ? K : never) : never;
|
|
278
368
|
}[keyof T] & {});
|
|
279
369
|
type ExcludeHidden<T, K extends keyof T> = K extends ExtractHiddenProps<T> ? never : K;
|
|
280
370
|
type ExtractConfig<T> = T extends {
|
|
@@ -286,9 +376,12 @@ type PrimaryOrObject<T, U, C extends TypeConfig> = PreferExplicitConfig<C, Extra
|
|
|
286
376
|
} : Primary<U>;
|
|
287
377
|
export type EntityDTOProp<E, T, C extends TypeConfig = never> = T extends Scalar ? T : T extends {
|
|
288
378
|
__serialized?: infer U;
|
|
289
|
-
} ? (IsUnknown<U> extends false ? U : T) : T extends
|
|
290
|
-
type
|
|
291
|
-
|
|
379
|
+
} ? (IsUnknown<U> extends false ? U : T) : T extends LoadedReferenceShape<infer U> ? EntityDTO<U, C> : T extends ReferenceShape<infer U> ? PrimaryOrObject<E, U, C> : T extends ScalarReference<infer U> ? U : T extends LoadedCollectionShape<infer U> ? EntityDTO<U & object, C>[] : T extends CollectionShape<infer U> ? PrimaryOrObject<E, U & object, C>[] : T extends readonly (infer U)[] ? U extends Scalar ? T : EntityDTOProp<E, U, C>[] : T extends Relation<T> ? EntityDTO<T, C> : T;
|
|
380
|
+
type UnwrapLoadedEntity<T> = T extends {
|
|
381
|
+
[__loadedType]?: infer U;
|
|
382
|
+
} ? NonNullable<U> : T;
|
|
383
|
+
type DTOProbablyOptionalProps<T> = NonNullable<NullableKeys<UnwrapLoadedEntity<T>, undefined>>;
|
|
384
|
+
type DTOIsOptional<T, K extends keyof T> = T[K] extends LoadedCollectionShape ? false : K extends PrimaryProperty<UnwrapLoadedEntity<T>> ? false : K extends DTOProbablyOptionalProps<T> ? true : false;
|
|
292
385
|
type DTORequiredKeys<T, K extends keyof T> = DTOIsOptional<T, K> extends false ? ExcludeHidden<T, K> & CleanKeys<T, K> : never;
|
|
293
386
|
type DTOOptionalKeys<T, K extends keyof T> = DTOIsOptional<T, K> extends false ? never : ExcludeHidden<T, K> & CleanKeys<T, K>;
|
|
294
387
|
export type EntityDTO<T, C extends TypeConfig = never> = {
|
|
@@ -297,18 +390,33 @@ export type EntityDTO<T, C extends TypeConfig = never> = {
|
|
|
297
390
|
[K in keyof T as DTOOptionalKeys<T, K>]?: EntityDTOProp<T, T[K], C> | AddOptional<T[K]>;
|
|
298
391
|
};
|
|
299
392
|
type TargetKeys<T> = T extends EntityClass<infer P> ? keyof P : keyof T;
|
|
300
|
-
type
|
|
301
|
-
|
|
393
|
+
type PropertyName<T> = IsUnknown<T> extends false ? TargetKeys<T> : string;
|
|
394
|
+
type TableName = {
|
|
395
|
+
name: string;
|
|
396
|
+
schema?: string;
|
|
397
|
+
toString: () => string;
|
|
398
|
+
};
|
|
399
|
+
export type FormulaTable = {
|
|
400
|
+
alias: string;
|
|
401
|
+
name: string;
|
|
402
|
+
schema?: string;
|
|
403
|
+
qualifiedName: string;
|
|
404
|
+
toString: () => string;
|
|
405
|
+
};
|
|
406
|
+
export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | Raw;
|
|
407
|
+
export type FormulaCallback<T> = (table: FormulaTable, columns: Record<PropertyName<T>, string>) => string;
|
|
408
|
+
export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string | Raw;
|
|
302
409
|
export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
|
|
303
410
|
export interface CheckConstraint<T = any> {
|
|
304
411
|
name?: string;
|
|
305
412
|
property?: string;
|
|
306
|
-
expression: string | CheckCallback<T>;
|
|
413
|
+
expression: string | Raw | CheckCallback<T>;
|
|
307
414
|
}
|
|
308
415
|
export type AnyString = string & {};
|
|
309
416
|
export interface EntityProperty<Owner = any, Target = any> {
|
|
310
417
|
name: EntityKey<Owner>;
|
|
311
418
|
entity: () => EntityName<Owner>;
|
|
419
|
+
target: EntityClass<Target>;
|
|
312
420
|
type: keyof typeof types | AnyString;
|
|
313
421
|
runtimeType: 'number' | 'string' | 'boolean' | 'bigint' | 'Buffer' | 'Date' | 'object' | 'any' | AnyString;
|
|
314
422
|
targetMeta?: EntityMetadata<Target>;
|
|
@@ -334,7 +442,8 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
334
442
|
fieldNameRaw?: string;
|
|
335
443
|
default?: string | number | boolean | null;
|
|
336
444
|
defaultRaw?: string;
|
|
337
|
-
formula?:
|
|
445
|
+
formula?: FormulaCallback<Owner>;
|
|
446
|
+
filters?: FilterOptions;
|
|
338
447
|
prefix?: string | boolean;
|
|
339
448
|
prefixMode?: EmbeddedPrefixMode;
|
|
340
449
|
embedded?: [EntityKey<Owner>, EntityKey<Owner>];
|
|
@@ -347,11 +456,13 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
347
456
|
unique?: boolean | string;
|
|
348
457
|
nullable?: boolean;
|
|
349
458
|
inherited?: boolean;
|
|
459
|
+
renamedFrom?: string;
|
|
460
|
+
stiFieldNames?: string[];
|
|
461
|
+
stiFieldNameMap?: Dictionary<string>;
|
|
350
462
|
unsigned?: boolean;
|
|
351
463
|
mapToPk?: boolean;
|
|
352
464
|
persist?: boolean;
|
|
353
465
|
hydrate?: boolean;
|
|
354
|
-
trackChanges?: boolean;
|
|
355
466
|
hidden?: boolean;
|
|
356
467
|
enum?: boolean;
|
|
357
468
|
items?: (number | string)[];
|
|
@@ -362,6 +473,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
362
473
|
setter?: boolean;
|
|
363
474
|
getter?: boolean;
|
|
364
475
|
getterName?: keyof Owner;
|
|
476
|
+
accessor?: EntityKey<Owner>;
|
|
365
477
|
cascade: Cascade[];
|
|
366
478
|
orphanRemoval?: boolean;
|
|
367
479
|
onCreate?: (entity: Owner, em: EntityManager) => any;
|
|
@@ -378,13 +490,14 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
378
490
|
fixedOrder?: boolean;
|
|
379
491
|
fixedOrderColumn?: string;
|
|
380
492
|
pivotTable: string;
|
|
381
|
-
pivotEntity:
|
|
493
|
+
pivotEntity: EntityClass<Target>;
|
|
382
494
|
joinColumns: string[];
|
|
383
495
|
ownColumns: string[];
|
|
384
496
|
inverseJoinColumns: string[];
|
|
385
497
|
referencedColumnNames: string[];
|
|
386
498
|
referencedTableName: string;
|
|
387
499
|
referencedPKs: EntityKey<Owner>[];
|
|
500
|
+
targetKey?: string;
|
|
388
501
|
serializer?: (value: any, options?: SerializeOptions<any>) => any;
|
|
389
502
|
serializedName?: string;
|
|
390
503
|
comment?: string;
|
|
@@ -394,19 +507,22 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
394
507
|
optional?: boolean;
|
|
395
508
|
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
396
509
|
deferMode?: DeferMode;
|
|
510
|
+
createForeignKeyConstraint: boolean;
|
|
397
511
|
foreignKeyName?: string;
|
|
398
512
|
}
|
|
399
|
-
export declare class EntityMetadata<
|
|
513
|
+
export declare class EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
400
514
|
private static counter;
|
|
401
515
|
readonly _id: number;
|
|
402
516
|
readonly propertyOrder: Map<string, number>;
|
|
403
517
|
constructor(meta?: Partial<EntityMetadata>);
|
|
404
|
-
addProperty(prop: Partial<EntityProperty<
|
|
518
|
+
addProperty(prop: Partial<EntityProperty<Entity>>): void;
|
|
405
519
|
removeProperty(name: string, sync?: boolean): void;
|
|
406
|
-
getPrimaryProps(): EntityProperty<
|
|
407
|
-
getPrimaryProp(): EntityProperty<
|
|
520
|
+
getPrimaryProps(flatten?: boolean): EntityProperty<Entity>[];
|
|
521
|
+
getPrimaryProp(): EntityProperty<Entity>;
|
|
522
|
+
createColumnMappingObject(): Record<PropertyName<Entity>, string>;
|
|
408
523
|
get tableName(): string;
|
|
409
524
|
set tableName(name: string);
|
|
525
|
+
get uniqueName(): string;
|
|
410
526
|
sync(initIndexes?: boolean, config?: Configuration): void;
|
|
411
527
|
private initIndexes;
|
|
412
528
|
/** @internal */
|
|
@@ -416,67 +532,77 @@ export interface SimpleColumnMeta {
|
|
|
416
532
|
name: string;
|
|
417
533
|
type: string;
|
|
418
534
|
}
|
|
419
|
-
export
|
|
535
|
+
export type EntityCtor<T = any> = abstract new (...args: any[]) => T;
|
|
536
|
+
export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
420
537
|
name?: string;
|
|
421
538
|
className: string;
|
|
422
539
|
tableName: string;
|
|
423
540
|
schema?: string;
|
|
424
541
|
pivotTable?: boolean;
|
|
425
542
|
virtual?: boolean;
|
|
426
|
-
|
|
427
|
-
|
|
543
|
+
/** True if this entity represents a database view (not a virtual entity). Accepts `{ materialized: true }` as input, normalized to `true` during sync. */
|
|
544
|
+
view?: boolean | {
|
|
545
|
+
materialized?: boolean;
|
|
546
|
+
withData?: boolean;
|
|
547
|
+
};
|
|
548
|
+
/** True if this is a materialized view (PostgreSQL only). Requires `view: true`. */
|
|
549
|
+
materialized?: boolean;
|
|
550
|
+
/** For materialized views, whether data is populated on creation. Defaults to true. */
|
|
551
|
+
withData?: boolean;
|
|
552
|
+
expression?: string | ((em: any, where: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any>, stream?: boolean) => MaybePromise<Raw | object | string>);
|
|
553
|
+
discriminatorColumn?: EntityKey<Entity> | AnyString;
|
|
428
554
|
discriminatorValue?: number | string;
|
|
429
|
-
discriminatorMap?: Dictionary<
|
|
555
|
+
discriminatorMap?: Dictionary<EntityClass>;
|
|
430
556
|
embeddable: boolean;
|
|
431
|
-
constructorParams
|
|
557
|
+
constructorParams?: (keyof Entity)[];
|
|
432
558
|
forceConstructor: boolean;
|
|
433
|
-
|
|
434
|
-
extends: string;
|
|
559
|
+
extends?: EntityName<Entity>;
|
|
435
560
|
collection: string;
|
|
436
561
|
path: string;
|
|
437
|
-
primaryKeys: EntityKey<
|
|
562
|
+
primaryKeys: EntityKey<Entity>[];
|
|
438
563
|
simplePK: boolean;
|
|
439
564
|
compositePK: boolean;
|
|
440
|
-
versionProperty: EntityKey<
|
|
441
|
-
concurrencyCheckKeys: Set<EntityKey<
|
|
442
|
-
serializedPrimaryKey
|
|
565
|
+
versionProperty: EntityKey<Entity>;
|
|
566
|
+
concurrencyCheckKeys: Set<EntityKey<Entity>>;
|
|
567
|
+
serializedPrimaryKey?: EntityKey<Entity>;
|
|
443
568
|
properties: {
|
|
444
|
-
[K in EntityKey<
|
|
569
|
+
[K in EntityKey<Entity>]: EntityProperty<Entity>;
|
|
445
570
|
};
|
|
446
|
-
props: EntityProperty<
|
|
447
|
-
relations: EntityProperty<
|
|
448
|
-
bidirectionalRelations: EntityProperty<
|
|
571
|
+
props: EntityProperty<Entity>[];
|
|
572
|
+
relations: EntityProperty<Entity>[];
|
|
573
|
+
bidirectionalRelations: EntityProperty<Entity>[];
|
|
449
574
|
referencingProperties: {
|
|
450
|
-
meta: EntityMetadata<
|
|
451
|
-
prop: EntityProperty<
|
|
575
|
+
meta: EntityMetadata<Entity>;
|
|
576
|
+
prop: EntityProperty<Entity>;
|
|
452
577
|
}[];
|
|
453
|
-
comparableProps: EntityProperty<
|
|
454
|
-
trackingProps: EntityProperty<
|
|
455
|
-
hydrateProps: EntityProperty<
|
|
456
|
-
|
|
457
|
-
|
|
578
|
+
comparableProps: EntityProperty<Entity>[];
|
|
579
|
+
trackingProps: EntityProperty<Entity>[];
|
|
580
|
+
hydrateProps: EntityProperty<Entity>[];
|
|
581
|
+
validateProps: EntityProperty<Entity>[];
|
|
582
|
+
uniqueProps: EntityProperty<Entity>[];
|
|
583
|
+
getterProps: EntityProperty<Entity>[];
|
|
458
584
|
indexes: {
|
|
459
|
-
properties
|
|
585
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
460
586
|
name?: string;
|
|
461
587
|
type?: string;
|
|
462
588
|
options?: Dictionary;
|
|
463
|
-
expression?: string
|
|
589
|
+
expression?: string | IndexCallback<Entity>;
|
|
464
590
|
}[];
|
|
465
591
|
uniques: {
|
|
466
|
-
properties
|
|
592
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
467
593
|
name?: string;
|
|
468
594
|
options?: Dictionary;
|
|
469
|
-
expression?: string
|
|
470
|
-
deferMode?: DeferMode
|
|
595
|
+
expression?: string | IndexCallback<Entity>;
|
|
596
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
471
597
|
}[];
|
|
472
|
-
checks: CheckConstraint<
|
|
598
|
+
checks: CheckConstraint<Entity>[];
|
|
473
599
|
repositoryClass?: string;
|
|
474
600
|
repository: () => EntityClass<EntityRepository<any>>;
|
|
475
601
|
hooks: {
|
|
476
|
-
[K in EventType]?: (keyof
|
|
602
|
+
[K in EventType]?: (keyof Entity | EventSubscriber<Entity>[EventType])[];
|
|
477
603
|
};
|
|
478
|
-
prototype:
|
|
479
|
-
class:
|
|
604
|
+
prototype: Entity;
|
|
605
|
+
class: Class;
|
|
480
606
|
abstract: boolean;
|
|
481
607
|
filters: Dictionary<FilterDef>;
|
|
482
608
|
comment?: string;
|
|
@@ -484,8 +610,9 @@ export interface EntityMetadata<T = any> {
|
|
|
484
610
|
hasUniqueProps?: boolean;
|
|
485
611
|
readonly?: boolean;
|
|
486
612
|
polymorphs?: EntityMetadata[];
|
|
487
|
-
root: EntityMetadata<
|
|
613
|
+
root: EntityMetadata<Entity>;
|
|
488
614
|
definedProperties: Dictionary;
|
|
615
|
+
hasTriggers?: boolean;
|
|
489
616
|
/** @internal can be used for computed numeric cache keys */
|
|
490
617
|
readonly _id: number;
|
|
491
618
|
}
|
|
@@ -496,6 +623,7 @@ export interface CreateSchemaOptions {
|
|
|
496
623
|
export interface ClearDatabaseOptions {
|
|
497
624
|
schema?: string;
|
|
498
625
|
truncate?: boolean;
|
|
626
|
+
clearIdentityMap?: boolean;
|
|
499
627
|
}
|
|
500
628
|
export interface EnsureDatabaseOptions extends CreateSchemaOptions, ClearDatabaseOptions {
|
|
501
629
|
clear?: boolean;
|
|
@@ -523,25 +651,25 @@ export interface RefreshDatabaseOptions extends CreateSchemaOptions {
|
|
|
523
651
|
createSchema?: boolean;
|
|
524
652
|
}
|
|
525
653
|
export interface ISchemaGenerator {
|
|
526
|
-
|
|
527
|
-
|
|
654
|
+
create(options?: CreateSchemaOptions): Promise<void>;
|
|
655
|
+
update(options?: UpdateSchemaOptions): Promise<void>;
|
|
656
|
+
drop(options?: DropSchemaOptions): Promise<void>;
|
|
657
|
+
refresh(options?: RefreshDatabaseOptions): Promise<void>;
|
|
658
|
+
clear(options?: ClearDatabaseOptions): Promise<void>;
|
|
659
|
+
execute(sql: string, options?: {
|
|
660
|
+
wrap?: boolean;
|
|
661
|
+
}): Promise<void>;
|
|
528
662
|
getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
|
|
529
|
-
dropSchema(options?: DropSchemaOptions): Promise<void>;
|
|
530
663
|
getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
|
|
531
|
-
updateSchema(options?: UpdateSchemaOptions): Promise<void>;
|
|
532
664
|
getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
|
|
533
665
|
getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
|
|
534
666
|
up: string;
|
|
535
667
|
down: string;
|
|
536
668
|
}>;
|
|
669
|
+
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
537
670
|
createDatabase(name?: string): Promise<void>;
|
|
538
671
|
dropDatabase(name?: string): Promise<void>;
|
|
539
|
-
execute(sql: string, options?: {
|
|
540
|
-
wrap?: boolean;
|
|
541
|
-
}): Promise<void>;
|
|
542
672
|
ensureIndexes(): Promise<void>;
|
|
543
|
-
refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
|
|
544
|
-
clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
|
|
545
673
|
}
|
|
546
674
|
export type ImportsResolver = (alias: string, basePath: string, extension: '.js' | '', originFileName: string) => {
|
|
547
675
|
path: string;
|
|
@@ -558,7 +686,10 @@ export interface GenerateOptions {
|
|
|
558
686
|
undefinedDefaults?: boolean;
|
|
559
687
|
bidirectionalRelations?: boolean;
|
|
560
688
|
identifiedReferences?: boolean;
|
|
561
|
-
|
|
689
|
+
entityDefinition?: 'decorators' | 'defineEntity' | 'entitySchema';
|
|
690
|
+
decorators?: 'es' | 'legacy';
|
|
691
|
+
inferEntityType?: boolean;
|
|
692
|
+
enumMode?: 'ts-enum' | 'union-type' | 'dictionary';
|
|
562
693
|
esmImport?: boolean;
|
|
563
694
|
scalarTypeInDecorator?: boolean;
|
|
564
695
|
scalarPropertiesForRelations?: 'always' | 'never' | 'smart';
|
|
@@ -618,26 +749,26 @@ export interface IMigrator {
|
|
|
618
749
|
/**
|
|
619
750
|
* Checks current schema for changes, generates new migration if there are any.
|
|
620
751
|
*/
|
|
621
|
-
|
|
752
|
+
create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
|
|
622
753
|
/**
|
|
623
754
|
* Checks current schema for changes.
|
|
624
755
|
*/
|
|
625
|
-
|
|
756
|
+
checkSchema(): Promise<boolean>;
|
|
626
757
|
/**
|
|
627
758
|
* Creates initial migration. This generates the schema based on metadata, and checks whether all the tables
|
|
628
759
|
* are already present. If yes, it will also automatically log the migration as executed.
|
|
629
760
|
* Initial migration can be created only if the schema is already aligned with the metadata, or when no schema
|
|
630
761
|
* is present - in such case regular migration would have the same effect.
|
|
631
762
|
*/
|
|
632
|
-
|
|
763
|
+
createInitial(path?: string): Promise<MigrationResult>;
|
|
633
764
|
/**
|
|
634
765
|
* Returns list of already executed migrations.
|
|
635
766
|
*/
|
|
636
|
-
|
|
767
|
+
getExecuted(): Promise<MigrationRow[]>;
|
|
637
768
|
/**
|
|
638
769
|
* Returns list of pending (not yet executed) migrations found in the migration directory.
|
|
639
770
|
*/
|
|
640
|
-
|
|
771
|
+
getPending(): Promise<UmzugMigration[]>;
|
|
641
772
|
/**
|
|
642
773
|
* Executes specified migrations. Without parameter it will migrate up to the latest version.
|
|
643
774
|
*/
|
|
@@ -686,12 +817,17 @@ export interface MigrationObject {
|
|
|
686
817
|
name: string;
|
|
687
818
|
class: Constructor<Migration>;
|
|
688
819
|
}
|
|
689
|
-
|
|
820
|
+
type EntityFromInput<T> = T extends readonly EntityName<infer U>[] ? U : T extends EntityName<infer U> ? U : never;
|
|
821
|
+
type FilterDefResolved<T extends object = any> = {
|
|
690
822
|
name: string;
|
|
691
|
-
cond:
|
|
823
|
+
cond: FilterQuery<T> | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, entityName?: string) => MaybePromise<FilterQuery<T>>);
|
|
692
824
|
default?: boolean;
|
|
693
|
-
entity?:
|
|
825
|
+
entity?: EntityName<T> | EntityName<T>[];
|
|
694
826
|
args?: boolean;
|
|
827
|
+
strict?: boolean;
|
|
828
|
+
};
|
|
829
|
+
export type FilterDef<T extends EntityName | readonly EntityName[] = any> = FilterDefResolved<EntityFromInput<T>> & {
|
|
830
|
+
entity?: T;
|
|
695
831
|
};
|
|
696
832
|
export type Populate<T, P extends string = never> = readonly AutoPath<T, P, `${PopulatePath}`>[] | false;
|
|
697
833
|
export type PopulateOptions<T> = {
|
|
@@ -699,40 +835,59 @@ export type PopulateOptions<T> = {
|
|
|
699
835
|
strategy?: LoadStrategy;
|
|
700
836
|
all?: boolean;
|
|
701
837
|
filter?: boolean;
|
|
838
|
+
joinType?: 'inner join' | 'left join';
|
|
702
839
|
children?: PopulateOptions<T[keyof T]>[];
|
|
840
|
+
/** When true, ignores `mapToPk` on the property and returns full entity data instead of just PKs. */
|
|
841
|
+
dataOnly?: boolean;
|
|
703
842
|
};
|
|
704
|
-
type
|
|
705
|
-
type ExtractType<T> = T extends Loadable<infer U> ? U : T;
|
|
843
|
+
type ExtractType<T> = T extends CollectionShape<infer U> ? U : T extends ReferenceShape<infer U> ? U : T extends Ref<infer U> ? U : T extends readonly (infer U)[] ? U : T;
|
|
706
844
|
type ExtractStringKeys<T> = {
|
|
707
|
-
[K in keyof T]
|
|
845
|
+
[K in keyof T]-?: CleanKeys<T, K>;
|
|
708
846
|
}[keyof T] & {};
|
|
709
|
-
|
|
847
|
+
/**
|
|
848
|
+
* Extracts string keys from an entity type, handling Collection/Reference wrappers.
|
|
849
|
+
* Simplified to just check `T extends object` since ExtractType handles the unwrapping.
|
|
850
|
+
*/
|
|
851
|
+
type StringKeys<T, E extends string = never> = T extends object ? ExtractStringKeys<ExtractType<T>> | E : never;
|
|
710
852
|
type GetStringKey<T, K extends StringKeys<T, string>, E extends string> = K extends keyof T ? ExtractType<T[K]> : (K extends E ? keyof T : never);
|
|
711
853
|
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
712
854
|
type CollectionKeys<T> = T extends object ? {
|
|
713
|
-
[K in keyof T]
|
|
855
|
+
[K in keyof T]-?: T[K] extends CollectionShape ? IsAny<T[K]> extends true ? never : K & string : never;
|
|
714
856
|
}[keyof T] & {} : never;
|
|
715
|
-
export type AutoPath<O, P extends string | boolean, E extends string = never, D extends Prev[number] = 9> = P extends boolean ? P : [D] extends [never] ? never : P extends any ? P extends string ?
|
|
857
|
+
export type AutoPath<O, P extends string | boolean, E extends string = never, D extends Prev[number] = 9> = P extends boolean ? P : [D] extends [never] ? never : P extends any ? P extends string ? P extends `${infer A}.${infer B}` ? A extends StringKeys<O, E> ? `${A}.${AutoPath<NonNullable<GetStringKey<O, A, E>>, B, E, Prev[D]>}` : never : P extends StringKeys<O, E> ? (NonNullable<GetStringKey<O, P & StringKeys<O, E>, E>> extends unknown ? Exclude<P, `${string}.`> : never) | (StringKeys<NonNullable<GetStringKey<O, P & StringKeys<O, E>, E>>, E> extends never ? never : `${P & string}.`) : StringKeys<O, E> | `${CollectionKeys<O>}:ref` : never : never;
|
|
716
858
|
export type UnboxArray<T> = T extends any[] ? ArrayElement<T> : T;
|
|
717
859
|
export type ArrayElement<ArrayType extends unknown[]> = ArrayType extends (infer ElementType)[] ? ElementType : never;
|
|
718
|
-
export type ExpandProperty<T> = T extends
|
|
719
|
-
type LoadedLoadable<T, E extends object> = T extends
|
|
860
|
+
export type ExpandProperty<T> = T extends ReferenceShape<infer U> ? NonNullable<U> : T extends CollectionShape<infer U> ? NonNullable<U> : T extends (infer U)[] ? NonNullable<U> : NonNullable<T>;
|
|
861
|
+
type LoadedLoadable<T, E extends object> = T extends CollectionShape ? LoadedCollection<E> : T extends ScalarReference<infer U> ? LoadedScalarReference<U> : T extends ReferenceShape ? T & LoadedReference<E> : T extends Scalar ? T : T extends (infer U)[] ? U extends Scalar ? T : E[] : E;
|
|
720
862
|
type IsTrue<T> = IsNever<T> extends true ? false : T extends boolean ? T extends true ? true : false : false;
|
|
721
863
|
type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
|
|
722
864
|
type Prefix<T, K> = K extends `${infer S}.${string}` ? S : (K extends '*' ? keyof T : K);
|
|
723
865
|
type IsPrefixedExclude<T, K extends keyof T, E extends string> = K extends E ? never : K;
|
|
724
|
-
export type IsPrefixed<T, K extends keyof T, L extends string, E extends string = never> = IsNever<E> extends false ? IsPrefixedExclude<T, K, E> : K extends symbol ? never : IsTrue<L> extends true ? (T[K] & {} extends
|
|
866
|
+
export type IsPrefixed<T, K extends keyof T, L extends string, E extends string = never> = IsNever<E> extends false ? IsPrefixedExclude<T, K, E> : K extends symbol ? never : IsTrue<L> extends true ? (T[K] & {} extends LoadableShape ? K : never) : IsNever<StringLiteral<L>> extends true ? never : L extends '*' ? K : K extends Prefix<T, L> ? K : K extends PrimaryProperty<T> ? K : never;
|
|
725
867
|
type Suffix<Key, Hint extends string, All = true | '*'> = Hint extends `${infer Pref}.${infer Suf}` ? (Pref extends Key ? Suf : never) : Hint extends All ? Hint : never;
|
|
726
|
-
export type IsSubset<T, U> = keyof U extends keyof T ? {} :
|
|
868
|
+
export type IsSubset<T, U> = keyof U extends keyof T ? {} : string extends keyof U ? {} : {
|
|
727
869
|
[K in keyof U as K extends keyof T ? never : CleanKeys<U, K>]: never;
|
|
728
870
|
};
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
type
|
|
734
|
-
|
|
735
|
-
|
|
871
|
+
/**
|
|
872
|
+
* Fast check if T is a Loaded type by looking for the marker symbol.
|
|
873
|
+
* This is much cheaper than matching against the full Loaded structure.
|
|
874
|
+
*/
|
|
875
|
+
type IsLoadedType<T> = T extends {
|
|
876
|
+
[__loadedType]?: any;
|
|
877
|
+
} ? true : false;
|
|
878
|
+
/**
|
|
879
|
+
* Optimized MergeSelected using intersection instead of extraction.
|
|
880
|
+
* When T is already Loaded, we intersect with a new Loaded type for the selected fields.
|
|
881
|
+
* This avoids the expensive pattern matching needed to extract hints from Loaded types.
|
|
882
|
+
*/
|
|
883
|
+
export type MergeSelected<T, U, F extends string> = IsLoadedType<T> extends true ? T & Loaded<U, never, F, never> : T;
|
|
884
|
+
/**
|
|
885
|
+
* Optimized MergeLoaded using intersection instead of extraction.
|
|
886
|
+
* When T is already Loaded, we intersect with a new Loaded type for the additional hints.
|
|
887
|
+
* This avoids the expensive pattern matching needed to extract hints from Loaded types.
|
|
888
|
+
* Used for `em.populate` and `em.refresh`.
|
|
889
|
+
*/
|
|
890
|
+
export type MergeLoaded<T, U, P extends string, F extends string, E extends string, R extends boolean = false> = IsLoadedType<T> extends true ? T & Loaded<U, P, F, E> : Loaded<T, P, F, E>;
|
|
736
891
|
export type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
|
|
737
892
|
type LoadedProp<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedLoadable<T, Loaded<ExtractType<T>, L, F, E>>;
|
|
738
893
|
export type AddEager<T> = ExtractEagerProps<T> & string;
|
|
@@ -751,18 +906,18 @@ type LoadedEntityType<T> = {
|
|
|
751
906
|
};
|
|
752
907
|
export type EntityType<T> = T | LoadedEntityType<T>;
|
|
753
908
|
export type FromEntityType<T> = T extends LoadedEntityType<infer U> ? U : T;
|
|
754
|
-
type LoadedInternal<T, L extends string = never, F extends string = '*', E extends string = never> = [
|
|
755
|
-
F
|
|
756
|
-
] extends ['*'] ? IsNever<E> extends true ? T & {
|
|
909
|
+
type LoadedInternal<T, L extends string = never, F extends string = '*', E extends string = never> = [F] extends ['*'] ? IsNever<E> extends true ? T & {
|
|
757
910
|
[K in keyof T as IsPrefixed<T, K, ExpandHint<T, L>>]: LoadedProp<NonNullable<T[K]>, Suffix<K, L>, Suffix<K, F>, Suffix<K, E>> | AddOptional<T[K]>;
|
|
758
911
|
} : {
|
|
759
912
|
[K in keyof T as IsPrefixed<T, K, ExpandHint<T, L>, E>]: LoadedProp<NonNullable<T[K]>, Suffix<K, L>, Suffix<K, F>, Suffix<K, E>> | AddOptional<T[K]>;
|
|
760
913
|
} : Selected<T, L, F>;
|
|
761
914
|
/**
|
|
762
915
|
* Represents entity with its loaded relations (`populate` hint) and selected properties (`fields` hint).
|
|
916
|
+
* The __loadHint marker uses contravariance to ensure Loaded<A, 'b'> is NOT assignable to Loaded<A, 'b.c'>.
|
|
763
917
|
*/
|
|
764
918
|
export type Loaded<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedInternal<T, L, F, E> & {
|
|
765
919
|
[__loadedType]?: T;
|
|
920
|
+
[__loadHint]?: (hint: Prefixes<L>) => void;
|
|
766
921
|
};
|
|
767
922
|
export interface LoadedReference<T> extends Reference<NonNullable<T>> {
|
|
768
923
|
$: NonNullable<T>;
|
|
@@ -782,23 +937,23 @@ export interface Highlighter {
|
|
|
782
937
|
highlight(text: string): string;
|
|
783
938
|
}
|
|
784
939
|
export interface IMetadataStorage {
|
|
785
|
-
getAll():
|
|
786
|
-
get<T = any>(entity:
|
|
787
|
-
find<T = any>(entity:
|
|
788
|
-
has(entity:
|
|
789
|
-
set(entity:
|
|
790
|
-
reset(entity:
|
|
940
|
+
getAll(): Map<EntityName, EntityMetadata>;
|
|
941
|
+
get<T = any>(entity: EntityName<T>, init?: boolean, validate?: boolean): EntityMetadata<T>;
|
|
942
|
+
find<T = any>(entity: EntityName<T>): EntityMetadata<T> | undefined;
|
|
943
|
+
has<T>(entity: EntityName<T>): boolean;
|
|
944
|
+
set<T>(entity: EntityName<T>, meta: EntityMetadata): EntityMetadata;
|
|
945
|
+
reset<T>(entity: EntityName<T>): void;
|
|
791
946
|
}
|
|
792
947
|
export interface IHydrator {
|
|
793
948
|
/**
|
|
794
949
|
* Hydrates the whole entity. This process handles custom type conversions, creating missing Collection instances,
|
|
795
950
|
* mapping FKs to entity instances, as well as merging those entities.
|
|
796
951
|
*/
|
|
797
|
-
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;
|
|
952
|
+
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;
|
|
798
953
|
/**
|
|
799
954
|
* Hydrates primary keys only
|
|
800
955
|
*/
|
|
801
|
-
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
|
|
956
|
+
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
|
|
802
957
|
isRunning(): boolean;
|
|
803
958
|
}
|
|
804
959
|
export interface HydratorConstructor {
|
|
@@ -808,17 +963,22 @@ export interface ISeedManager {
|
|
|
808
963
|
seed(...classNames: Constructor<Seeder>[]): Promise<void>;
|
|
809
964
|
/** @internal */
|
|
810
965
|
seedString(...classNames: string[]): Promise<void>;
|
|
811
|
-
|
|
966
|
+
create(className: string): Promise<string>;
|
|
812
967
|
}
|
|
813
968
|
export interface Seeder<T extends Dictionary = Dictionary> {
|
|
814
969
|
run(em: EntityManager, context?: T): void | Promise<void>;
|
|
815
970
|
}
|
|
816
971
|
export type ConnectionType = 'read' | 'write';
|
|
817
972
|
export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
973
|
+
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
974
|
+
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 = EntityCtor<TEntity>> extends EntitySchema<TEntity, TBase, TClass> {
|
|
975
|
+
readonly name: TName;
|
|
976
|
+
readonly properties: TProperties;
|
|
977
|
+
readonly tableName: TTableName;
|
|
978
|
+
/** @internal Direct entity type access - avoids expensive pattern matching */
|
|
979
|
+
readonly '~entity': TEntity;
|
|
980
|
+
}
|
|
981
|
+
export type InferEntity<Schema> = Schema extends {
|
|
982
|
+
'~entity': infer E;
|
|
983
|
+
} ? E : Schema extends EntitySchema<infer Entity> ? Entity : Schema extends EntityClass<infer Entity> ? Entity : Schema;
|
|
824
984
|
export {};
|