@mikro-orm/core 7.0.0-dev.18 → 7.0.0-dev.181
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 +99 -57
- package/EntityManager.js +302 -276
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +103 -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 +44 -17
- package/entity/BaseEntity.d.ts +2 -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 +35 -15
- package/entity/EntityLoader.d.ts +6 -6
- package/entity/EntityLoader.js +117 -77
- package/entity/EntityRepository.d.ts +24 -4
- package/entity/EntityRepository.js +8 -2
- package/entity/Reference.d.ts +6 -5
- package/entity/Reference.js +34 -9
- package/entity/WrappedEntity.d.ts +2 -7
- package/entity/WrappedEntity.js +3 -8
- package/entity/defineEntity.d.ts +583 -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 +21 -5
- package/enums.js +15 -1
- package/errors.d.ts +23 -9
- package/errors.js +59 -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 +20 -22
- package/metadata/EntitySchema.js +59 -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 +96 -39
- 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 +502 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +8 -4
- package/naming-strategy/AbstractNamingStrategy.js +8 -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 +14 -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 +18 -11
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +7 -13
- 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 +189 -116
- package/typings.js +59 -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 +764 -207
- package/utils/Configuration.js +146 -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 +48 -25
- package/utils/RawQueryFragment.js +66 -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 +32 -0
- package/utils/fs-utils.js +178 -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/exports.d.ts +0 -24
- package/exports.js +0 -23
- 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;
|
|
@@ -43,6 +41,11 @@ 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
|
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
44
|
+
export type UnionKeys<T> = T extends any ? keyof T : never;
|
|
45
|
+
export type UnionPropertyType<T, K extends PropertyKey> = T extends any ? K extends keyof T ? T[K] : never : never;
|
|
46
|
+
export type MergeUnion<T> = [T] extends [object] ? T extends Scalar ? T : {
|
|
47
|
+
[K in UnionKeys<T>]: UnionPropertyType<T, K>;
|
|
48
|
+
} : T;
|
|
46
49
|
export type DeepPartial<T> = T & {
|
|
47
50
|
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends Readonly<infer U>[] ? Readonly<DeepPartial<U>>[] : DeepPartial<T[P]>;
|
|
48
51
|
};
|
|
@@ -52,18 +55,34 @@ export declare const OptionalProps: unique symbol;
|
|
|
52
55
|
export declare const EagerProps: unique symbol;
|
|
53
56
|
export declare const HiddenProps: unique symbol;
|
|
54
57
|
export declare const Config: unique symbol;
|
|
55
|
-
|
|
56
|
-
declare
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
export type Opt<T = unknown> = T & Opt.Brand;
|
|
59
|
+
export declare namespace Opt {
|
|
60
|
+
const __optional: unique symbol;
|
|
61
|
+
interface Brand {
|
|
62
|
+
[__optional]?: 1;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export type RequiredNullable<T = never> = (T & RequiredNullable.Brand) | null;
|
|
66
|
+
export declare namespace RequiredNullable {
|
|
67
|
+
const __requiredNullable: unique symbol;
|
|
68
|
+
interface Brand {
|
|
69
|
+
[__requiredNullable]?: 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export type Hidden<T = unknown> = T & Hidden.Brand;
|
|
73
|
+
export declare namespace Hidden {
|
|
74
|
+
const __hidden: unique symbol;
|
|
75
|
+
interface Brand {
|
|
76
|
+
[__hidden]?: 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export type DefineConfig<T extends TypeConfig> = T & DefineConfig.Brand;
|
|
80
|
+
export declare namespace DefineConfig {
|
|
81
|
+
const __config: unique symbol;
|
|
82
|
+
interface Brand {
|
|
83
|
+
[__config]?: 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
67
86
|
export type CleanTypeConfig<T> = Compute<Pick<T, Extract<keyof T, keyof TypeConfig>>>;
|
|
68
87
|
export interface TypeConfig {
|
|
69
88
|
forceObject?: boolean;
|
|
@@ -75,13 +94,14 @@ type PrimaryPropToType<T, Keys extends (keyof T)[]> = {
|
|
|
75
94
|
type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
|
|
76
95
|
export type Primary<T> = IsAny<T> extends true ? any : T extends {
|
|
77
96
|
[PrimaryKeyProp]?: infer PK;
|
|
78
|
-
} ?
|
|
97
|
+
} ? 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
98
|
_id?: infer PK;
|
|
80
99
|
} ? ReadonlyPrimary<PK> | string : T extends {
|
|
81
|
-
uuid?: infer PK;
|
|
82
|
-
} ? ReadonlyPrimary<PK> : T extends {
|
|
83
100
|
id?: infer PK;
|
|
101
|
+
} ? ReadonlyPrimary<PK> : T extends {
|
|
102
|
+
uuid?: infer PK;
|
|
84
103
|
} ? ReadonlyPrimary<PK> : T;
|
|
104
|
+
/** @internal */
|
|
85
105
|
export type PrimaryProperty<T> = T extends {
|
|
86
106
|
[PrimaryKeyProp]?: infer PK;
|
|
87
107
|
} ? (PK extends keyof T ? PK : (PK extends any[] ? PK[number] : never)) : T extends {
|
|
@@ -89,10 +109,10 @@ export type PrimaryProperty<T> = T extends {
|
|
|
89
109
|
} ? (T extends {
|
|
90
110
|
id?: any;
|
|
91
111
|
} ? 'id' | '_id' : '_id') : T extends {
|
|
92
|
-
uuid?: any;
|
|
93
|
-
} ? 'uuid' : T extends {
|
|
94
112
|
id?: any;
|
|
95
|
-
} ? 'id' :
|
|
113
|
+
} ? 'id' : T extends {
|
|
114
|
+
uuid?: any;
|
|
115
|
+
} ? 'uuid' : never;
|
|
96
116
|
export type IPrimaryKeyValue = number | string | bigint | Date | {
|
|
97
117
|
toHexString(): string;
|
|
98
118
|
};
|
|
@@ -100,6 +120,7 @@ export type IPrimaryKey<T extends IPrimaryKeyValue = IPrimaryKeyValue> = T;
|
|
|
100
120
|
export type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Uint8Array | {
|
|
101
121
|
toHexString(): string;
|
|
102
122
|
};
|
|
123
|
+
type Primitive = boolean | number | string | bigint | symbol;
|
|
103
124
|
export type ExpandScalar<T> = null | (T extends string ? T | RegExp : T extends Date ? Date | string : T extends bigint ? bigint | string | number : T);
|
|
104
125
|
export type OperatorMap<T> = {
|
|
105
126
|
$and?: ExpandQuery<T>[];
|
|
@@ -112,6 +133,14 @@ export type OperatorMap<T> = {
|
|
|
112
133
|
$none?: ExpandQuery<T>;
|
|
113
134
|
$some?: ExpandQuery<T>;
|
|
114
135
|
$every?: ExpandQuery<T>;
|
|
136
|
+
$size?: number | {
|
|
137
|
+
$eq?: number;
|
|
138
|
+
$ne?: number;
|
|
139
|
+
$gt?: number;
|
|
140
|
+
$gte?: number;
|
|
141
|
+
$lt?: number;
|
|
142
|
+
$lte?: number;
|
|
143
|
+
};
|
|
115
144
|
$gt?: ExpandScalar<T>;
|
|
116
145
|
$gte?: ExpandScalar<T>;
|
|
117
146
|
$lt?: ExpandScalar<T>;
|
|
@@ -130,10 +159,11 @@ export type OperatorMap<T> = {
|
|
|
130
159
|
};
|
|
131
160
|
export type FilterItemValue<T> = T | ExpandScalar<T> | Primary<T>;
|
|
132
161
|
export type FilterValue<T> = OperatorMap<FilterItemValue<T>> | FilterItemValue<T> | FilterItemValue<T>[] | null;
|
|
162
|
+
type FilterObjectProp<T, K extends PropertyKey> = K extends keyof MergeUnion<T> ? MergeUnion<T>[K] : K extends keyof T ? T[K] : never;
|
|
163
|
+
type ExpandQueryMerged<T> = [T] extends [object] ? [T] extends [Scalar] ? never : FilterQuery<MergeUnion<T>> : FilterValue<T>;
|
|
133
164
|
export type FilterObject<T> = {
|
|
134
|
-
-readonly [K in EntityKey<T>]?: ExpandQuery<ExpandProperty<T
|
|
165
|
+
-readonly [K in EntityKey<T> | EntityKey<MergeUnion<T>>]?: ExpandQuery<ExpandProperty<FilterObjectProp<T, K>>> | ExpandQueryMerged<ExpandProperty<FilterObjectProp<T, K>>> | FilterValue<ExpandProperty<FilterObjectProp<T, K>>> | null;
|
|
135
166
|
};
|
|
136
|
-
export type ExpandObject<T> = T extends object ? T extends Scalar ? never : FilterObject<T> : never;
|
|
137
167
|
export type ExpandQuery<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
|
|
138
168
|
export type EntityProps<T> = {
|
|
139
169
|
-readonly [K in EntityKey<T>]?: T[K];
|
|
@@ -143,10 +173,9 @@ export type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T
|
|
|
143
173
|
export type QBFilterQuery<T = any> = ObjectQuery<T> | Dictionary;
|
|
144
174
|
export interface IWrappedEntity<Entity extends object> {
|
|
145
175
|
isInitialized(): boolean;
|
|
146
|
-
isTouched(): boolean;
|
|
147
176
|
isManaged(): boolean;
|
|
148
177
|
populated(populated?: boolean): void;
|
|
149
|
-
populate<Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
178
|
+
populate<Hint extends string = never>(populate: readonly AutoPath<Entity, Hint, PopulatePath.ALL>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
150
179
|
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
180
|
toReference(): Ref<Entity> & LoadedReference<Loaded<Entity, AddEager<Entity>>>;
|
|
152
181
|
toObject(): EntityDTO<Entity>;
|
|
@@ -174,7 +203,6 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
174
203
|
__factory: EntityFactory;
|
|
175
204
|
__hydrator: IHydrator;
|
|
176
205
|
__initialized: boolean;
|
|
177
|
-
__touched: boolean;
|
|
178
206
|
__originalEntityData?: EntityData<Entity>;
|
|
179
207
|
__loadedProperties: Set<string>;
|
|
180
208
|
__identifier?: EntityIdentifier | EntityIdentifier[];
|
|
@@ -194,16 +222,10 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
194
222
|
};
|
|
195
223
|
}
|
|
196
224
|
export type AnyEntity<T = any> = Partial<T>;
|
|
197
|
-
export type EntityClass<T> = Function & {
|
|
225
|
+
export type EntityClass<T = any> = Function & {
|
|
198
226
|
prototype: T;
|
|
199
227
|
};
|
|
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
|
-
};
|
|
228
|
+
export type EntityName<T = any> = EntityClass<T> | EntityCtor<T> | EntitySchema<T, any>;
|
|
207
229
|
export type GetRepository<Entity extends {
|
|
208
230
|
[k: PropertyKey]: any;
|
|
209
231
|
}, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<any> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback;
|
|
@@ -224,7 +246,7 @@ export type EntityDataProp<T, C extends boolean> = T extends Date ? string | Dat
|
|
|
224
246
|
__runtime?: infer Runtime;
|
|
225
247
|
__raw?: infer Raw;
|
|
226
248
|
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends Collection<infer U, any> ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : U[] | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
|
|
227
|
-
export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
249
|
+
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
250
|
__runtime?: infer Runtime;
|
|
229
251
|
__raw?: infer Raw;
|
|
230
252
|
} ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends Collection<infer U, any> ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, 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>;
|
|
@@ -239,7 +261,10 @@ type ExplicitlyOptionalProps<T> = (T extends {
|
|
|
239
261
|
type NullableKeys<T, V = null> = {
|
|
240
262
|
[K in keyof T]: V extends T[K] ? K : never;
|
|
241
263
|
}[keyof T];
|
|
242
|
-
type
|
|
264
|
+
type RequiredNullableKeys<T> = {
|
|
265
|
+
[K in keyof T]: Exclude<T[K], null> extends RequiredNullable.Brand ? K : never;
|
|
266
|
+
}[keyof T];
|
|
267
|
+
type ProbablyOptionalProps<T> = PrimaryProperty<T> | ExplicitlyOptionalProps<T> | Exclude<NonNullable<NullableKeys<T, null | undefined>>, RequiredNullableKeys<T>>;
|
|
243
268
|
type IsOptional<T, K extends keyof T, I> = T[K] extends Collection<any, any> ? true : ExtractType<T[K]> extends I ? true : K extends ProbablyOptionalProps<T> ? true : false;
|
|
244
269
|
type RequiredKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? CleanKeys<T, K> : never;
|
|
245
270
|
type OptionalKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? never : CleanKeys<T, K>;
|
|
@@ -274,7 +299,7 @@ export type Ref<T> = T extends any ? IsAny<T> extends true ? Reference<T & objec
|
|
|
274
299
|
type ExtractHiddenProps<T> = (T extends {
|
|
275
300
|
[HiddenProps]?: infer K;
|
|
276
301
|
} ? K : never) | ({
|
|
277
|
-
[K in keyof T]: T[K] extends Hidden ? K : never;
|
|
302
|
+
[K in keyof T]: T[K] extends Primitive ? (T[K] extends Hidden ? K : never) : never;
|
|
278
303
|
}[keyof T] & {});
|
|
279
304
|
type ExcludeHidden<T, K extends keyof T> = K extends ExtractHiddenProps<T> ? never : K;
|
|
280
305
|
type ExtractConfig<T> = T extends {
|
|
@@ -297,8 +322,22 @@ export type EntityDTO<T, C extends TypeConfig = never> = {
|
|
|
297
322
|
[K in keyof T as DTOOptionalKeys<T, K>]?: EntityDTOProp<T, T[K], C> | AddOptional<T[K]>;
|
|
298
323
|
};
|
|
299
324
|
type TargetKeys<T> = T extends EntityClass<infer P> ? keyof P : keyof T;
|
|
300
|
-
type
|
|
301
|
-
|
|
325
|
+
type PropertyName<T> = IsUnknown<T> extends false ? TargetKeys<T> : string;
|
|
326
|
+
type TableName = {
|
|
327
|
+
name: string;
|
|
328
|
+
schema?: string;
|
|
329
|
+
toString: () => string;
|
|
330
|
+
};
|
|
331
|
+
export type FormulaTable = {
|
|
332
|
+
alias: string;
|
|
333
|
+
name: string;
|
|
334
|
+
schema?: string;
|
|
335
|
+
qualifiedName: string;
|
|
336
|
+
toString: () => string;
|
|
337
|
+
};
|
|
338
|
+
export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | Raw;
|
|
339
|
+
export type FormulaCallback<T> = (table: FormulaTable, columns: Record<PropertyName<T>, string>) => string;
|
|
340
|
+
export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string;
|
|
302
341
|
export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
|
|
303
342
|
export interface CheckConstraint<T = any> {
|
|
304
343
|
name?: string;
|
|
@@ -309,6 +348,7 @@ export type AnyString = string & {};
|
|
|
309
348
|
export interface EntityProperty<Owner = any, Target = any> {
|
|
310
349
|
name: EntityKey<Owner>;
|
|
311
350
|
entity: () => EntityName<Owner>;
|
|
351
|
+
target: EntityClass<Target>;
|
|
312
352
|
type: keyof typeof types | AnyString;
|
|
313
353
|
runtimeType: 'number' | 'string' | 'boolean' | 'bigint' | 'Buffer' | 'Date' | 'object' | 'any' | AnyString;
|
|
314
354
|
targetMeta?: EntityMetadata<Target>;
|
|
@@ -334,7 +374,8 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
334
374
|
fieldNameRaw?: string;
|
|
335
375
|
default?: string | number | boolean | null;
|
|
336
376
|
defaultRaw?: string;
|
|
337
|
-
formula?:
|
|
377
|
+
formula?: FormulaCallback<Owner>;
|
|
378
|
+
filters?: FilterOptions;
|
|
338
379
|
prefix?: string | boolean;
|
|
339
380
|
prefixMode?: EmbeddedPrefixMode;
|
|
340
381
|
embedded?: [EntityKey<Owner>, EntityKey<Owner>];
|
|
@@ -347,11 +388,13 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
347
388
|
unique?: boolean | string;
|
|
348
389
|
nullable?: boolean;
|
|
349
390
|
inherited?: boolean;
|
|
391
|
+
renamedFrom?: string;
|
|
392
|
+
stiFieldNames?: string[];
|
|
393
|
+
stiFieldNameMap?: Dictionary<string>;
|
|
350
394
|
unsigned?: boolean;
|
|
351
395
|
mapToPk?: boolean;
|
|
352
396
|
persist?: boolean;
|
|
353
397
|
hydrate?: boolean;
|
|
354
|
-
trackChanges?: boolean;
|
|
355
398
|
hidden?: boolean;
|
|
356
399
|
enum?: boolean;
|
|
357
400
|
items?: (number | string)[];
|
|
@@ -362,6 +405,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
362
405
|
setter?: boolean;
|
|
363
406
|
getter?: boolean;
|
|
364
407
|
getterName?: keyof Owner;
|
|
408
|
+
accessor?: EntityKey<Owner>;
|
|
365
409
|
cascade: Cascade[];
|
|
366
410
|
orphanRemoval?: boolean;
|
|
367
411
|
onCreate?: (entity: Owner, em: EntityManager) => any;
|
|
@@ -378,13 +422,14 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
378
422
|
fixedOrder?: boolean;
|
|
379
423
|
fixedOrderColumn?: string;
|
|
380
424
|
pivotTable: string;
|
|
381
|
-
pivotEntity:
|
|
425
|
+
pivotEntity: EntityClass<Target>;
|
|
382
426
|
joinColumns: string[];
|
|
383
427
|
ownColumns: string[];
|
|
384
428
|
inverseJoinColumns: string[];
|
|
385
429
|
referencedColumnNames: string[];
|
|
386
430
|
referencedTableName: string;
|
|
387
431
|
referencedPKs: EntityKey<Owner>[];
|
|
432
|
+
targetKey?: string;
|
|
388
433
|
serializer?: (value: any, options?: SerializeOptions<any>) => any;
|
|
389
434
|
serializedName?: string;
|
|
390
435
|
comment?: string;
|
|
@@ -394,19 +439,22 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
394
439
|
optional?: boolean;
|
|
395
440
|
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
396
441
|
deferMode?: DeferMode;
|
|
442
|
+
createForeignKeyConstraint: boolean;
|
|
397
443
|
foreignKeyName?: string;
|
|
398
444
|
}
|
|
399
|
-
export declare class EntityMetadata<
|
|
445
|
+
export declare class EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
400
446
|
private static counter;
|
|
401
447
|
readonly _id: number;
|
|
402
448
|
readonly propertyOrder: Map<string, number>;
|
|
403
449
|
constructor(meta?: Partial<EntityMetadata>);
|
|
404
|
-
addProperty(prop: Partial<EntityProperty<
|
|
450
|
+
addProperty(prop: Partial<EntityProperty<Entity>>): void;
|
|
405
451
|
removeProperty(name: string, sync?: boolean): void;
|
|
406
|
-
getPrimaryProps(): EntityProperty<
|
|
407
|
-
getPrimaryProp(): EntityProperty<
|
|
452
|
+
getPrimaryProps(flatten?: boolean): EntityProperty<Entity>[];
|
|
453
|
+
getPrimaryProp(): EntityProperty<Entity>;
|
|
454
|
+
createColumnMappingObject(): Record<PropertyName<Entity>, string>;
|
|
408
455
|
get tableName(): string;
|
|
409
456
|
set tableName(name: string);
|
|
457
|
+
get uniqueName(): string;
|
|
410
458
|
sync(initIndexes?: boolean, config?: Configuration): void;
|
|
411
459
|
private initIndexes;
|
|
412
460
|
/** @internal */
|
|
@@ -416,67 +464,74 @@ export interface SimpleColumnMeta {
|
|
|
416
464
|
name: string;
|
|
417
465
|
type: string;
|
|
418
466
|
}
|
|
419
|
-
export
|
|
467
|
+
export type EntityCtor<T = any> = abstract new (...args: any[]) => T;
|
|
468
|
+
export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> = EntityCtor<Entity>> {
|
|
420
469
|
name?: string;
|
|
421
470
|
className: string;
|
|
422
471
|
tableName: string;
|
|
423
472
|
schema?: string;
|
|
424
473
|
pivotTable?: boolean;
|
|
425
474
|
virtual?: boolean;
|
|
426
|
-
|
|
427
|
-
|
|
475
|
+
/** True if this entity represents a database view (not a virtual entity). */
|
|
476
|
+
view?: boolean;
|
|
477
|
+
/** True if this is a materialized view (PostgreSQL only). Requires `view: true`. */
|
|
478
|
+
materialized?: boolean;
|
|
479
|
+
/** For materialized views, whether data is populated on creation. Defaults to true. */
|
|
480
|
+
withData?: boolean;
|
|
481
|
+
expression?: string | ((em: any, where: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any>, stream?: boolean) => MaybePromise<Raw | object | string>);
|
|
482
|
+
discriminatorColumn?: EntityKey<Entity> | AnyString;
|
|
428
483
|
discriminatorValue?: number | string;
|
|
429
|
-
discriminatorMap?: Dictionary<
|
|
484
|
+
discriminatorMap?: Dictionary<EntityClass>;
|
|
430
485
|
embeddable: boolean;
|
|
431
|
-
constructorParams
|
|
486
|
+
constructorParams?: (keyof Entity)[];
|
|
432
487
|
forceConstructor: boolean;
|
|
433
|
-
|
|
434
|
-
extends: string;
|
|
488
|
+
extends?: EntityName<Entity>;
|
|
435
489
|
collection: string;
|
|
436
490
|
path: string;
|
|
437
|
-
primaryKeys: EntityKey<
|
|
491
|
+
primaryKeys: EntityKey<Entity>[];
|
|
438
492
|
simplePK: boolean;
|
|
439
493
|
compositePK: boolean;
|
|
440
|
-
versionProperty: EntityKey<
|
|
441
|
-
concurrencyCheckKeys: Set<EntityKey<
|
|
442
|
-
serializedPrimaryKey
|
|
494
|
+
versionProperty: EntityKey<Entity>;
|
|
495
|
+
concurrencyCheckKeys: Set<EntityKey<Entity>>;
|
|
496
|
+
serializedPrimaryKey?: EntityKey<Entity>;
|
|
443
497
|
properties: {
|
|
444
|
-
[K in EntityKey<
|
|
498
|
+
[K in EntityKey<Entity>]: EntityProperty<Entity>;
|
|
445
499
|
};
|
|
446
|
-
props: EntityProperty<
|
|
447
|
-
relations: EntityProperty<
|
|
448
|
-
bidirectionalRelations: EntityProperty<
|
|
500
|
+
props: EntityProperty<Entity>[];
|
|
501
|
+
relations: EntityProperty<Entity>[];
|
|
502
|
+
bidirectionalRelations: EntityProperty<Entity>[];
|
|
449
503
|
referencingProperties: {
|
|
450
|
-
meta: EntityMetadata<
|
|
451
|
-
prop: EntityProperty<
|
|
504
|
+
meta: EntityMetadata<Entity>;
|
|
505
|
+
prop: EntityProperty<Entity>;
|
|
452
506
|
}[];
|
|
453
|
-
comparableProps: EntityProperty<
|
|
454
|
-
trackingProps: EntityProperty<
|
|
455
|
-
hydrateProps: EntityProperty<
|
|
456
|
-
|
|
457
|
-
|
|
507
|
+
comparableProps: EntityProperty<Entity>[];
|
|
508
|
+
trackingProps: EntityProperty<Entity>[];
|
|
509
|
+
hydrateProps: EntityProperty<Entity>[];
|
|
510
|
+
validateProps: EntityProperty<Entity>[];
|
|
511
|
+
uniqueProps: EntityProperty<Entity>[];
|
|
512
|
+
getterProps: EntityProperty<Entity>[];
|
|
458
513
|
indexes: {
|
|
459
|
-
properties
|
|
514
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
460
515
|
name?: string;
|
|
461
516
|
type?: string;
|
|
462
517
|
options?: Dictionary;
|
|
463
|
-
expression?: string
|
|
518
|
+
expression?: string | IndexCallback<Entity>;
|
|
464
519
|
}[];
|
|
465
520
|
uniques: {
|
|
466
|
-
properties
|
|
521
|
+
properties?: EntityKey<Entity> | EntityKey<Entity>[];
|
|
467
522
|
name?: string;
|
|
468
523
|
options?: Dictionary;
|
|
469
|
-
expression?: string
|
|
470
|
-
deferMode?: DeferMode
|
|
524
|
+
expression?: string | IndexCallback<Entity>;
|
|
525
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
471
526
|
}[];
|
|
472
|
-
checks: CheckConstraint<
|
|
527
|
+
checks: CheckConstraint<Entity>[];
|
|
473
528
|
repositoryClass?: string;
|
|
474
529
|
repository: () => EntityClass<EntityRepository<any>>;
|
|
475
530
|
hooks: {
|
|
476
|
-
[K in EventType]?: (keyof
|
|
531
|
+
[K in EventType]?: (keyof Entity | EventSubscriber<Entity>[EventType])[];
|
|
477
532
|
};
|
|
478
|
-
prototype:
|
|
479
|
-
class:
|
|
533
|
+
prototype: Entity;
|
|
534
|
+
class: Class;
|
|
480
535
|
abstract: boolean;
|
|
481
536
|
filters: Dictionary<FilterDef>;
|
|
482
537
|
comment?: string;
|
|
@@ -484,8 +539,9 @@ export interface EntityMetadata<T = any> {
|
|
|
484
539
|
hasUniqueProps?: boolean;
|
|
485
540
|
readonly?: boolean;
|
|
486
541
|
polymorphs?: EntityMetadata[];
|
|
487
|
-
root: EntityMetadata<
|
|
542
|
+
root: EntityMetadata<Entity>;
|
|
488
543
|
definedProperties: Dictionary;
|
|
544
|
+
hasTriggers?: boolean;
|
|
489
545
|
/** @internal can be used for computed numeric cache keys */
|
|
490
546
|
readonly _id: number;
|
|
491
547
|
}
|
|
@@ -496,6 +552,7 @@ export interface CreateSchemaOptions {
|
|
|
496
552
|
export interface ClearDatabaseOptions {
|
|
497
553
|
schema?: string;
|
|
498
554
|
truncate?: boolean;
|
|
555
|
+
clearIdentityMap?: boolean;
|
|
499
556
|
}
|
|
500
557
|
export interface EnsureDatabaseOptions extends CreateSchemaOptions, ClearDatabaseOptions {
|
|
501
558
|
clear?: boolean;
|
|
@@ -523,25 +580,25 @@ export interface RefreshDatabaseOptions extends CreateSchemaOptions {
|
|
|
523
580
|
createSchema?: boolean;
|
|
524
581
|
}
|
|
525
582
|
export interface ISchemaGenerator {
|
|
526
|
-
|
|
527
|
-
|
|
583
|
+
create(options?: CreateSchemaOptions): Promise<void>;
|
|
584
|
+
update(options?: UpdateSchemaOptions): Promise<void>;
|
|
585
|
+
drop(options?: DropSchemaOptions): Promise<void>;
|
|
586
|
+
refresh(options?: RefreshDatabaseOptions): Promise<void>;
|
|
587
|
+
clear(options?: ClearDatabaseOptions): Promise<void>;
|
|
588
|
+
execute(sql: string, options?: {
|
|
589
|
+
wrap?: boolean;
|
|
590
|
+
}): Promise<void>;
|
|
528
591
|
getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
|
|
529
|
-
dropSchema(options?: DropSchemaOptions): Promise<void>;
|
|
530
592
|
getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
|
|
531
|
-
updateSchema(options?: UpdateSchemaOptions): Promise<void>;
|
|
532
593
|
getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
|
|
533
594
|
getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
|
|
534
595
|
up: string;
|
|
535
596
|
down: string;
|
|
536
597
|
}>;
|
|
598
|
+
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
537
599
|
createDatabase(name?: string): Promise<void>;
|
|
538
600
|
dropDatabase(name?: string): Promise<void>;
|
|
539
|
-
execute(sql: string, options?: {
|
|
540
|
-
wrap?: boolean;
|
|
541
|
-
}): Promise<void>;
|
|
542
601
|
ensureIndexes(): Promise<void>;
|
|
543
|
-
refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
|
|
544
|
-
clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
|
|
545
602
|
}
|
|
546
603
|
export type ImportsResolver = (alias: string, basePath: string, extension: '.js' | '', originFileName: string) => {
|
|
547
604
|
path: string;
|
|
@@ -558,7 +615,10 @@ export interface GenerateOptions {
|
|
|
558
615
|
undefinedDefaults?: boolean;
|
|
559
616
|
bidirectionalRelations?: boolean;
|
|
560
617
|
identifiedReferences?: boolean;
|
|
561
|
-
|
|
618
|
+
entityDefinition?: 'decorators' | 'defineEntity' | 'entitySchema';
|
|
619
|
+
decorators?: 'es' | 'legacy';
|
|
620
|
+
inferEntityType?: boolean;
|
|
621
|
+
enumMode?: 'ts-enum' | 'union-type' | 'dictionary';
|
|
562
622
|
esmImport?: boolean;
|
|
563
623
|
scalarTypeInDecorator?: boolean;
|
|
564
624
|
scalarPropertiesForRelations?: 'always' | 'never' | 'smart';
|
|
@@ -618,26 +678,26 @@ export interface IMigrator {
|
|
|
618
678
|
/**
|
|
619
679
|
* Checks current schema for changes, generates new migration if there are any.
|
|
620
680
|
*/
|
|
621
|
-
|
|
681
|
+
create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
|
|
622
682
|
/**
|
|
623
683
|
* Checks current schema for changes.
|
|
624
684
|
*/
|
|
625
|
-
|
|
685
|
+
checkSchema(): Promise<boolean>;
|
|
626
686
|
/**
|
|
627
687
|
* Creates initial migration. This generates the schema based on metadata, and checks whether all the tables
|
|
628
688
|
* are already present. If yes, it will also automatically log the migration as executed.
|
|
629
689
|
* Initial migration can be created only if the schema is already aligned with the metadata, or when no schema
|
|
630
690
|
* is present - in such case regular migration would have the same effect.
|
|
631
691
|
*/
|
|
632
|
-
|
|
692
|
+
createInitial(path?: string): Promise<MigrationResult>;
|
|
633
693
|
/**
|
|
634
694
|
* Returns list of already executed migrations.
|
|
635
695
|
*/
|
|
636
|
-
|
|
696
|
+
getExecuted(): Promise<MigrationRow[]>;
|
|
637
697
|
/**
|
|
638
698
|
* Returns list of pending (not yet executed) migrations found in the migration directory.
|
|
639
699
|
*/
|
|
640
|
-
|
|
700
|
+
getPending(): Promise<UmzugMigration[]>;
|
|
641
701
|
/**
|
|
642
702
|
* Executes specified migrations. Without parameter it will migrate up to the latest version.
|
|
643
703
|
*/
|
|
@@ -686,12 +746,17 @@ export interface MigrationObject {
|
|
|
686
746
|
name: string;
|
|
687
747
|
class: Constructor<Migration>;
|
|
688
748
|
}
|
|
689
|
-
|
|
749
|
+
type EntityFromInput<T> = T extends readonly EntityName<infer U>[] ? U : T extends EntityName<infer U> ? U : never;
|
|
750
|
+
type FilterDefResolved<T extends object = any> = {
|
|
690
751
|
name: string;
|
|
691
|
-
cond:
|
|
752
|
+
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
753
|
default?: boolean;
|
|
693
|
-
entity?:
|
|
754
|
+
entity?: EntityName<T> | EntityName<T>[];
|
|
694
755
|
args?: boolean;
|
|
756
|
+
strict?: boolean;
|
|
757
|
+
};
|
|
758
|
+
export type FilterDef<T extends EntityName | readonly EntityName[] = any> = FilterDefResolved<EntityFromInput<T>> & {
|
|
759
|
+
entity?: T;
|
|
695
760
|
};
|
|
696
761
|
export type Populate<T, P extends string = never> = readonly AutoPath<T, P, `${PopulatePath}`>[] | false;
|
|
697
762
|
export type PopulateOptions<T> = {
|
|
@@ -699,18 +764,21 @@ export type PopulateOptions<T> = {
|
|
|
699
764
|
strategy?: LoadStrategy;
|
|
700
765
|
all?: boolean;
|
|
701
766
|
filter?: boolean;
|
|
767
|
+
joinType?: 'inner join' | 'left join';
|
|
702
768
|
children?: PopulateOptions<T[keyof T]>[];
|
|
769
|
+
/** When true, ignores `mapToPk` on the property and returns full entity data instead of just PKs. */
|
|
770
|
+
dataOnly?: boolean;
|
|
703
771
|
};
|
|
704
772
|
type Loadable<T extends object> = Collection<T, any> | Reference<T> | Ref<T> | readonly T[];
|
|
705
773
|
type ExtractType<T> = T extends Loadable<infer U> ? U : T;
|
|
706
774
|
type ExtractStringKeys<T> = {
|
|
707
|
-
[K in keyof T]
|
|
775
|
+
[K in keyof T]-?: CleanKeys<T, K>;
|
|
708
776
|
}[keyof T] & {};
|
|
709
777
|
type StringKeys<T, E extends string = never> = T extends Collection<any, any> ? ExtractStringKeys<ExtractType<T>> | E : T extends Reference<any> ? ExtractStringKeys<ExtractType<T>> | E : T extends object ? ExtractStringKeys<ExtractType<T>> | E : never;
|
|
710
778
|
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
779
|
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
712
780
|
type CollectionKeys<T> = T extends object ? {
|
|
713
|
-
[K in keyof T]
|
|
781
|
+
[K in keyof T]-?: T[K] extends Collection<any> ? IsAny<T[K]> extends true ? never : K & string : never;
|
|
714
782
|
}[keyof T] & {} : never;
|
|
715
783
|
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 & `${string}.` extends never ? P : P & `${string}.`) extends infer Q ? Q extends `${infer A}.${infer B}` ? A extends StringKeys<O, E> ? `${A}.${AutoPath<NonNullable<GetStringKey<O, A, E>>, B, E, Prev[D]>}` : never : Q extends StringKeys<O, E> ? (NonNullable<GetStringKey<O, Q, E>> extends unknown ? Exclude<P, `${string}.`> : never) | (StringKeys<NonNullable<GetStringKey<O, Q, E>>, E> extends never ? never : `${Q & string}.`) : StringKeys<O, E> | `${CollectionKeys<O>}:ref` : never : never : never;
|
|
716
784
|
export type UnboxArray<T> = T extends any[] ? ArrayElement<T> : T;
|
|
@@ -723,7 +791,7 @@ type Prefix<T, K> = K extends `${infer S}.${string}` ? S : (K extends '*' ? keyo
|
|
|
723
791
|
type IsPrefixedExclude<T, K extends keyof T, E extends string> = K extends E ? never : K;
|
|
724
792
|
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 Loadable<any> ? K : never) : IsNever<StringLiteral<L>> extends true ? never : K extends Prefix<T, L> ? K : K extends PrimaryProperty<T> ? K : never;
|
|
725
793
|
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 ? {} :
|
|
794
|
+
export type IsSubset<T, U> = keyof U extends keyof T ? {} : string extends keyof U ? {} : {
|
|
727
795
|
[K in keyof U as K extends keyof T ? never : CleanKeys<U, K>]: never;
|
|
728
796
|
};
|
|
729
797
|
declare const __selectedType: unique symbol;
|
|
@@ -782,23 +850,23 @@ export interface Highlighter {
|
|
|
782
850
|
highlight(text: string): string;
|
|
783
851
|
}
|
|
784
852
|
export interface IMetadataStorage {
|
|
785
|
-
getAll():
|
|
786
|
-
get<T = any>(entity:
|
|
787
|
-
find<T = any>(entity:
|
|
788
|
-
has(entity:
|
|
789
|
-
set(entity:
|
|
790
|
-
reset(entity:
|
|
853
|
+
getAll(): Map<EntityName, EntityMetadata>;
|
|
854
|
+
get<T = any>(entity: EntityName<T>, init?: boolean, validate?: boolean): EntityMetadata<T>;
|
|
855
|
+
find<T = any>(entity: EntityName<T>): EntityMetadata<T> | undefined;
|
|
856
|
+
has<T>(entity: EntityName<T>): boolean;
|
|
857
|
+
set<T>(entity: EntityName<T>, meta: EntityMetadata): EntityMetadata;
|
|
858
|
+
reset<T>(entity: EntityName<T>): void;
|
|
791
859
|
}
|
|
792
860
|
export interface IHydrator {
|
|
793
861
|
/**
|
|
794
862
|
* Hydrates the whole entity. This process handles custom type conversions, creating missing Collection instances,
|
|
795
863
|
* mapping FKs to entity instances, as well as merging those entities.
|
|
796
864
|
*/
|
|
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;
|
|
865
|
+
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
866
|
/**
|
|
799
867
|
* Hydrates primary keys only
|
|
800
868
|
*/
|
|
801
|
-
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
|
|
869
|
+
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
|
|
802
870
|
isRunning(): boolean;
|
|
803
871
|
}
|
|
804
872
|
export interface HydratorConstructor {
|
|
@@ -808,17 +876,22 @@ export interface ISeedManager {
|
|
|
808
876
|
seed(...classNames: Constructor<Seeder>[]): Promise<void>;
|
|
809
877
|
/** @internal */
|
|
810
878
|
seedString(...classNames: string[]): Promise<void>;
|
|
811
|
-
|
|
879
|
+
create(className: string): Promise<string>;
|
|
812
880
|
}
|
|
813
881
|
export interface Seeder<T extends Dictionary = Dictionary> {
|
|
814
882
|
run(em: EntityManager, context?: T): void | Promise<void>;
|
|
815
883
|
}
|
|
816
884
|
export type ConnectionType = 'read' | 'write';
|
|
817
885
|
export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
886
|
+
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
887
|
+
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> {
|
|
888
|
+
readonly name: TName;
|
|
889
|
+
readonly properties: TProperties;
|
|
890
|
+
readonly tableName: TTableName;
|
|
891
|
+
/** @internal Direct entity type access - avoids expensive pattern matching */
|
|
892
|
+
readonly '~entity': TEntity;
|
|
893
|
+
}
|
|
894
|
+
export type InferEntity<Schema> = Schema extends {
|
|
895
|
+
'~entity': infer E;
|
|
896
|
+
} ? E : Schema extends EntitySchema<infer Entity> ? Entity : Schema extends EntityClass<infer Entity> ? Entity : Schema;
|
|
824
897
|
export {};
|