@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.100
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 +96 -58
- package/EntityManager.js +465 -395
- package/MikroORM.d.ts +45 -35
- package/MikroORM.js +109 -160
- package/README.md +3 -2
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +2 -2
- package/cache/FileCacheAdapter.js +20 -27
- package/cache/GeneratedCacheAdapter.d.ts +2 -3
- package/cache/GeneratedCacheAdapter.js +1 -7
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +4 -5
- package/cache/index.js +4 -21
- package/connections/Connection.d.ts +22 -14
- package/connections/Connection.js +27 -23
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/drivers/DatabaseDriver.d.ts +25 -15
- package/drivers/DatabaseDriver.js +77 -64
- package/drivers/IDatabaseDriver.d.ts +40 -16
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/BaseEntity.d.ts +6 -7
- package/entity/BaseEntity.js +16 -23
- package/entity/Collection.d.ts +98 -34
- package/entity/Collection.js +466 -131
- package/entity/EntityAssigner.d.ts +3 -3
- package/entity/EntityAssigner.js +67 -64
- package/entity/EntityFactory.d.ts +10 -3
- package/entity/EntityFactory.js +112 -91
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +66 -53
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +8 -7
- package/entity/EntityLoader.js +161 -128
- package/entity/EntityRepository.d.ts +8 -8
- package/entity/EntityRepository.js +7 -11
- package/entity/Reference.d.ts +10 -13
- package/entity/Reference.js +64 -46
- package/entity/WrappedEntity.d.ts +12 -17
- package/entity/WrappedEntity.js +22 -31
- package/entity/defineEntity.d.ts +568 -0
- package/entity/defineEntity.js +529 -0
- package/entity/index.d.ts +14 -13
- package/entity/index.js +14 -29
- package/entity/utils.d.ts +8 -1
- package/entity/utils.js +22 -13
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +24 -9
- package/enums.js +50 -41
- package/errors.d.ts +11 -3
- package/errors.js +42 -32
- package/events/EventManager.d.ts +5 -4
- package/events/EventManager.js +26 -22
- package/events/EventSubscriber.d.ts +8 -5
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +2 -6
- package/hydration/ObjectHydrator.d.ts +7 -7
- package/hydration/ObjectHydrator.js +58 -50
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +20 -46
- package/logging/DefaultLogger.d.ts +2 -2
- package/logging/DefaultLogger.js +10 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +3 -3
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +5 -4
- package/logging/index.js +5 -20
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +16 -0
- package/metadata/EntitySchema.d.ts +14 -10
- package/metadata/EntitySchema.js +78 -64
- package/metadata/MetadataDiscovery.d.ts +11 -14
- package/metadata/MetadataDiscovery.js +278 -317
- package/metadata/MetadataProvider.d.ts +13 -4
- package/metadata/MetadataProvider.js +47 -8
- package/metadata/MetadataStorage.d.ts +2 -7
- package/metadata/MetadataStorage.js +19 -35
- package/metadata/MetadataValidator.d.ts +3 -10
- package/metadata/MetadataValidator.js +51 -64
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/metadata/types.d.ts +480 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +7 -3
- package/naming-strategy/AbstractNamingStrategy.js +11 -9
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +12 -2
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -20
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +15 -22
- package/platforms/Platform.js +58 -88
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +4 -2
- package/serialization/EntitySerializer.js +64 -51
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +48 -42
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +24 -25
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +6 -11
- package/types/BigIntType.d.ts +12 -9
- package/types/BigIntType.js +6 -6
- package/types/BlobType.d.ts +3 -4
- package/types/BlobType.js +2 -11
- package/types/BooleanType.d.ts +5 -4
- package/types/BooleanType.js +5 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +9 -7
- package/types/DecimalType.js +5 -8
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +4 -7
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +4 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +4 -4
- package/types/JsonType.js +9 -8
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +4 -6
- package/types/Type.js +6 -10
- package/types/Uint8ArrayType.d.ts +3 -4
- package/types/Uint8ArrayType.js +3 -12
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +134 -93
- package/typings.js +67 -65
- package/unit-of-work/ChangeSet.d.ts +1 -4
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -9
- package/unit-of-work/ChangeSetComputer.js +36 -38
- package/unit-of-work/ChangeSetPersister.d.ts +11 -9
- package/unit-of-work/ChangeSetPersister.js +100 -65
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +16 -8
- package/unit-of-work/UnitOfWork.js +266 -209
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +11 -11
- package/utils/AbstractSchemaGenerator.js +21 -20
- package/utils/Configuration.d.ts +774 -224
- package/utils/Configuration.js +166 -216
- package/utils/ConfigurationLoader.d.ts +1 -53
- package/utils/ConfigurationLoader.js +1 -367
- package/utils/Cursor.d.ts +6 -9
- package/utils/Cursor.js +25 -25
- package/utils/DataloaderUtils.d.ts +18 -8
- package/utils/DataloaderUtils.js +63 -21
- package/utils/EntityComparator.d.ts +9 -5
- package/utils/EntityComparator.js +155 -108
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +12 -4
- package/utils/QueryHelper.js +110 -53
- package/utils/RawQueryFragment.d.ts +37 -14
- package/utils/RawQueryFragment.js +50 -33
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +16 -100
- package/utils/Utils.js +114 -332
- package/utils/clone.js +7 -11
- package/utils/env-vars.d.ts +3 -0
- package/utils/env-vars.js +87 -0
- package/utils/fs-utils.d.ts +12 -0
- package/utils/fs-utils.js +97 -0
- package/utils/index.d.ts +14 -13
- package/utils/index.js +14 -29
- package/utils/upsert-utils.d.ts +8 -3
- package/utils/upsert-utils.js +57 -10
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -16
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -33
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -14
- package/decorators/Embedded.d.ts +0 -18
- package/decorators/Embedded.js +0 -20
- package/decorators/Entity.d.ts +0 -18
- package/decorators/Entity.js +0 -16
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -19
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -11
- package/decorators/Formula.d.ts +0 -5
- package/decorators/Formula.js +0 -18
- package/decorators/Indexed.d.ts +0 -17
- package/decorators/Indexed.js +0 -24
- package/decorators/ManyToMany.d.ts +0 -40
- package/decorators/ManyToMany.js +0 -16
- package/decorators/ManyToOne.d.ts +0 -30
- package/decorators/ManyToOne.js +0 -16
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -20
- package/decorators/OneToOne.d.ts +0 -24
- package/decorators/OneToOne.js +0 -10
- package/decorators/PrimaryKey.d.ts +0 -9
- package/decorators/PrimaryKey.js +0 -23
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -34
- package/decorators/Transactional.d.ts +0 -13
- package/decorators/Transactional.js +0 -31
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -59
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -36
- package/entity/ArrayCollection.d.ts +0 -116
- package/entity/ArrayCollection.js +0 -399
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -154
- package/index.mjs +0 -199
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -48
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -31
package/typings.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import type { Transaction } from './connections';
|
|
2
|
-
import { type Cascade, type DeferMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums';
|
|
3
|
-
import { type AssignOptions } from './entity/EntityAssigner';
|
|
4
|
-
import { type EntityIdentifier } from './entity/EntityIdentifier';
|
|
5
|
-
import { type EntityLoaderOptions } from './entity/EntityLoader';
|
|
6
|
-
import { type Collection } from './entity/Collection';
|
|
7
|
-
import { type EntityFactory } from './entity/EntityFactory';
|
|
8
|
-
import { type EntityRepository } from './entity/EntityRepository';
|
|
9
|
-
import { Reference, type ScalarReference } from './entity/Reference';
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
1
|
+
import type { Transaction } from './connections/Connection.js';
|
|
2
|
+
import { type Cascade, type DeferMode, type EmbeddedPrefixMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums.js';
|
|
3
|
+
import { type AssignOptions } from './entity/EntityAssigner.js';
|
|
4
|
+
import { type EntityIdentifier } from './entity/EntityIdentifier.js';
|
|
5
|
+
import { type EntityLoaderOptions } from './entity/EntityLoader.js';
|
|
6
|
+
import { type Collection } from './entity/Collection.js';
|
|
7
|
+
import { type EntityFactory } from './entity/EntityFactory.js';
|
|
8
|
+
import { type EntityRepository } from './entity/EntityRepository.js';
|
|
9
|
+
import { Reference, type ScalarReference } from './entity/Reference.js';
|
|
10
|
+
import type { SerializationContext } from './serialization/SerializationContext.js';
|
|
11
|
+
import type { SerializeOptions } from './serialization/EntitySerializer.js';
|
|
12
|
+
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
13
|
+
import type { EntitySchema } from './metadata/EntitySchema.js';
|
|
14
|
+
import type { Type, types } from './types/index.js';
|
|
15
|
+
import type { Platform } from './platforms/Platform.js';
|
|
16
|
+
import type { Configuration } from './utils/Configuration.js';
|
|
17
|
+
import type { RawQueryFragment } from './utils/RawQueryFragment.js';
|
|
18
|
+
import type { EntityManager } from './EntityManager.js';
|
|
19
|
+
import type { EventSubscriber } from './events/EventSubscriber.js';
|
|
20
|
+
import type { FilterOptions, FindOneOptions, FindOptions, LoadHint } from './drivers/IDatabaseDriver.js';
|
|
20
21
|
export type Constructor<T = unknown> = new (...args: any[]) => T;
|
|
21
22
|
export type Dictionary<T = any> = {
|
|
22
23
|
[k: string]: T;
|
|
@@ -25,6 +26,7 @@ export type EntityKey<T = unknown, B extends boolean = false> = string & {
|
|
|
25
26
|
[K in keyof T]-?: CleanKeys<T, K, B> extends never ? never : K;
|
|
26
27
|
}[keyof T];
|
|
27
28
|
export type EntityValue<T> = T[EntityKey<T>];
|
|
29
|
+
export type EntityDataValue<T> = EntityData<T>[EntityKey<T>];
|
|
28
30
|
export type FilterKey<T> = keyof FilterQuery<T>;
|
|
29
31
|
export type AsyncFunction<R = any, T = Dictionary> = (args: T) => Promise<T>;
|
|
30
32
|
export type Compute<T> = {
|
|
@@ -48,18 +50,34 @@ export declare const OptionalProps: unique symbol;
|
|
|
48
50
|
export declare const EagerProps: unique symbol;
|
|
49
51
|
export declare const HiddenProps: unique symbol;
|
|
50
52
|
export declare const Config: unique symbol;
|
|
51
|
-
|
|
52
|
-
declare
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
export type Opt<T = unknown> = T & Opt.Brand;
|
|
54
|
+
export declare namespace Opt {
|
|
55
|
+
const __optional: unique symbol;
|
|
56
|
+
interface Brand {
|
|
57
|
+
[__optional]?: 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export type RequiredNullable<T = never> = (T & RequiredNullable.Brand) | null;
|
|
61
|
+
export declare namespace RequiredNullable {
|
|
62
|
+
const __requiredNullable: unique symbol;
|
|
63
|
+
interface Brand {
|
|
64
|
+
[__requiredNullable]?: 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export type Hidden<T = unknown> = T & Hidden.Brand;
|
|
68
|
+
export declare namespace Hidden {
|
|
69
|
+
const __hidden: unique symbol;
|
|
70
|
+
interface Brand {
|
|
71
|
+
[__hidden]?: 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export type DefineConfig<T extends TypeConfig> = T & DefineConfig.Brand;
|
|
75
|
+
export declare namespace DefineConfig {
|
|
76
|
+
const __config: unique symbol;
|
|
77
|
+
interface Brand {
|
|
78
|
+
[__config]?: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
63
81
|
export type CleanTypeConfig<T> = Compute<Pick<T, Extract<keyof T, keyof TypeConfig>>>;
|
|
64
82
|
export interface TypeConfig {
|
|
65
83
|
forceObject?: boolean;
|
|
@@ -71,13 +89,14 @@ type PrimaryPropToType<T, Keys extends (keyof T)[]> = {
|
|
|
71
89
|
type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
|
|
72
90
|
export type Primary<T> = IsAny<T> extends true ? any : T extends {
|
|
73
91
|
[PrimaryKeyProp]?: infer PK;
|
|
74
|
-
} ?
|
|
92
|
+
} ? 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 {
|
|
75
93
|
_id?: infer PK;
|
|
76
94
|
} ? ReadonlyPrimary<PK> | string : T extends {
|
|
77
|
-
uuid?: infer PK;
|
|
78
|
-
} ? ReadonlyPrimary<PK> : T extends {
|
|
79
95
|
id?: infer PK;
|
|
96
|
+
} ? ReadonlyPrimary<PK> : T extends {
|
|
97
|
+
uuid?: infer PK;
|
|
80
98
|
} ? ReadonlyPrimary<PK> : T;
|
|
99
|
+
/** @internal */
|
|
81
100
|
export type PrimaryProperty<T> = T extends {
|
|
82
101
|
[PrimaryKeyProp]?: infer PK;
|
|
83
102
|
} ? (PK extends keyof T ? PK : (PK extends any[] ? PK[number] : never)) : T extends {
|
|
@@ -85,10 +104,10 @@ export type PrimaryProperty<T> = T extends {
|
|
|
85
104
|
} ? (T extends {
|
|
86
105
|
id?: any;
|
|
87
106
|
} ? 'id' | '_id' : '_id') : T extends {
|
|
88
|
-
uuid?: any;
|
|
89
|
-
} ? 'uuid' : T extends {
|
|
90
107
|
id?: any;
|
|
91
|
-
} ? 'id' :
|
|
108
|
+
} ? 'id' : T extends {
|
|
109
|
+
uuid?: any;
|
|
110
|
+
} ? 'uuid' : never;
|
|
92
111
|
export type IPrimaryKeyValue = number | string | bigint | Date | {
|
|
93
112
|
toHexString(): string;
|
|
94
113
|
};
|
|
@@ -129,7 +148,6 @@ export type FilterValue<T> = OperatorMap<FilterItemValue<T>> | FilterItemValue<T
|
|
|
129
148
|
export type FilterObject<T> = {
|
|
130
149
|
-readonly [K in EntityKey<T>]?: ExpandQuery<ExpandProperty<T[K]>> | FilterValue<ExpandProperty<T[K]>> | null;
|
|
131
150
|
};
|
|
132
|
-
export type ExpandObject<T> = T extends object ? T extends Scalar ? never : FilterObject<T> : never;
|
|
133
151
|
export type ExpandQuery<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
|
|
134
152
|
export type EntityProps<T> = {
|
|
135
153
|
-readonly [K in EntityKey<T>]?: T[K];
|
|
@@ -139,7 +157,6 @@ export type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T
|
|
|
139
157
|
export type QBFilterQuery<T = any> = ObjectQuery<T> | Dictionary;
|
|
140
158
|
export interface IWrappedEntity<Entity extends object> {
|
|
141
159
|
isInitialized(): boolean;
|
|
142
|
-
isTouched(): boolean;
|
|
143
160
|
isManaged(): boolean;
|
|
144
161
|
populated(populated?: boolean): void;
|
|
145
162
|
populate<Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
|
|
@@ -170,10 +187,9 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
|
|
|
170
187
|
__factory: EntityFactory;
|
|
171
188
|
__hydrator: IHydrator;
|
|
172
189
|
__initialized: boolean;
|
|
173
|
-
__touched: boolean;
|
|
174
190
|
__originalEntityData?: EntityData<Entity>;
|
|
175
191
|
__loadedProperties: Set<string>;
|
|
176
|
-
__identifier?: EntityIdentifier;
|
|
192
|
+
__identifier?: EntityIdentifier | EntityIdentifier[];
|
|
177
193
|
__managed: boolean;
|
|
178
194
|
__processing: boolean;
|
|
179
195
|
__schema?: string;
|
|
@@ -193,16 +209,12 @@ export type AnyEntity<T = any> = Partial<T>;
|
|
|
193
209
|
export type EntityClass<T> = Function & {
|
|
194
210
|
prototype: T;
|
|
195
211
|
};
|
|
196
|
-
export type EntityClassGroup<T> = {
|
|
197
|
-
entity: EntityClass<T>;
|
|
198
|
-
schema: EntityMetadata<T> | EntitySchema<T>;
|
|
199
|
-
};
|
|
200
212
|
export type EntityName<T> = string | EntityClass<T> | EntitySchema<T, any> | {
|
|
201
213
|
name: string;
|
|
202
214
|
};
|
|
203
215
|
export type GetRepository<Entity extends {
|
|
204
216
|
[k: PropertyKey]: any;
|
|
205
|
-
}, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<
|
|
217
|
+
}, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<any> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback;
|
|
206
218
|
export type EntityDataPropValue<T> = T | Primary<T>;
|
|
207
219
|
type ExpandEntityProp<T, C extends boolean = false> = T extends Record<string, any> ? {
|
|
208
220
|
[K in keyof T as CleanKeys<T, K>]?: EntityDataProp<ExpandProperty<T[K]>, C> | EntityDataPropValue<ExpandProperty<T[K]>> | null;
|
|
@@ -213,14 +225,17 @@ type ExpandRequiredEntityPropObject<T, I = never, C extends boolean = false> = {
|
|
|
213
225
|
} & {
|
|
214
226
|
[K in keyof T as OptionalKeys<T, K, I>]?: RequiredEntityDataProp<ExpandProperty<T[K]>, T, C> | EntityDataPropValue<ExpandProperty<T[K]>> | null | undefined;
|
|
215
227
|
};
|
|
228
|
+
type NonArrayObject = object & {
|
|
229
|
+
[Symbol.iterator]?: never;
|
|
230
|
+
};
|
|
216
231
|
export type EntityDataProp<T, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
217
232
|
__runtime?: infer Runtime;
|
|
218
233
|
__raw?: infer Raw;
|
|
219
|
-
} ? (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 | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
|
|
220
|
-
export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
|
|
234
|
+
} ? (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>;
|
|
235
|
+
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 {
|
|
221
236
|
__runtime?: infer Runtime;
|
|
222
237
|
__raw?: infer Raw;
|
|
223
|
-
} ? (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 | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
|
|
238
|
+
} ? (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>;
|
|
224
239
|
export type EntityDataNested<T, C extends boolean = false> = T extends undefined ? never : T extends any[] ? Readonly<T> : EntityData<T, C> | ExpandEntityProp<T, C>;
|
|
225
240
|
type EntityDataItem<T, C extends boolean> = C extends false ? T | EntityDataProp<T, C> | null : EntityDataProp<T, C> | null;
|
|
226
241
|
export type RequiredEntityDataNested<T, O, C extends boolean> = T extends any[] ? Readonly<T> : RequiredEntityData<T, O> | ExpandRequiredEntityProp<T, O, C>;
|
|
@@ -232,12 +247,15 @@ type ExplicitlyOptionalProps<T> = (T extends {
|
|
|
232
247
|
type NullableKeys<T, V = null> = {
|
|
233
248
|
[K in keyof T]: V extends T[K] ? K : never;
|
|
234
249
|
}[keyof T];
|
|
235
|
-
type
|
|
250
|
+
type RequiredNullableKeys<T> = {
|
|
251
|
+
[K in keyof T]: Exclude<T[K], null> extends RequiredNullable.Brand ? K : never;
|
|
252
|
+
}[keyof T];
|
|
253
|
+
type ProbablyOptionalProps<T> = PrimaryProperty<T> | ExplicitlyOptionalProps<T> | Exclude<NonNullable<NullableKeys<T, null | undefined>>, RequiredNullableKeys<T>>;
|
|
236
254
|
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;
|
|
237
255
|
type RequiredKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? CleanKeys<T, K> : never;
|
|
238
256
|
type OptionalKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? never : CleanKeys<T, K>;
|
|
239
257
|
export type EntityData<T, C extends boolean = false> = {
|
|
240
|
-
[K in EntityKey<T>]?: EntityDataItem<T[K], C>;
|
|
258
|
+
[K in EntityKey<T>]?: EntityDataItem<T[K] & {}, C>;
|
|
241
259
|
};
|
|
242
260
|
export type RequiredEntityData<T, I = never, C extends boolean = false> = {
|
|
243
261
|
[K in keyof T as RequiredKeys<T, K, I>]: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]>;
|
|
@@ -279,7 +297,7 @@ type PrimaryOrObject<T, U, C extends TypeConfig> = PreferExplicitConfig<C, Extra
|
|
|
279
297
|
} : Primary<U>;
|
|
280
298
|
export type EntityDTOProp<E, T, C extends TypeConfig = never> = T extends Scalar ? T : T extends {
|
|
281
299
|
__serialized?: infer U;
|
|
282
|
-
} ? U : T extends LoadedReference<infer U> ? EntityDTO<U, C> : T extends Reference<infer U> ? PrimaryOrObject<E, U, C> : T extends ScalarReference<infer U> ? U : T extends LoadedCollection<infer U> ? EntityDTO<U, C>[] : T extends Collection<infer U> ? PrimaryOrObject<E, U, C>[] : T extends readonly (infer U)[] ? (T extends readonly any[] ? T : U[]) : T extends Relation<T> ? EntityDTO<T, C> : T;
|
|
300
|
+
} ? (IsUnknown<U> extends false ? U : T) : T extends LoadedReference<infer U> ? EntityDTO<U, C> : T extends Reference<infer U> ? PrimaryOrObject<E, U, C> : T extends ScalarReference<infer U> ? U : T extends LoadedCollection<infer U> ? EntityDTO<U, C>[] : T extends Collection<infer U> ? PrimaryOrObject<E, U, C>[] : T extends readonly (infer U)[] ? (T extends readonly any[] ? T : U[]) : T extends Relation<T> ? EntityDTO<T, C> : T;
|
|
283
301
|
type DTOProbablyOptionalProps<T> = NonNullable<NullableKeys<T, undefined>>;
|
|
284
302
|
type DTOIsOptional<T, K extends keyof T> = T[K] extends LoadedCollection<any> ? false : K extends PrimaryProperty<T> ? false : K extends DTOProbablyOptionalProps<T> ? true : false;
|
|
285
303
|
type DTORequiredKeys<T, K extends keyof T> = DTOIsOptional<T, K> extends false ? ExcludeHidden<T, K> & CleanKeys<T, K> : never;
|
|
@@ -289,7 +307,15 @@ export type EntityDTO<T, C extends TypeConfig = never> = {
|
|
|
289
307
|
} & {
|
|
290
308
|
[K in keyof T as DTOOptionalKeys<T, K>]?: EntityDTOProp<T, T[K], C> | AddOptional<T[K]>;
|
|
291
309
|
};
|
|
292
|
-
|
|
310
|
+
type TargetKeys<T> = T extends EntityClass<infer P> ? keyof P : keyof T;
|
|
311
|
+
type PropertyName<T> = IsUnknown<T> extends false ? TargetKeys<T> : string;
|
|
312
|
+
type TableName = {
|
|
313
|
+
name: string;
|
|
314
|
+
schema?: string;
|
|
315
|
+
toString: () => string;
|
|
316
|
+
};
|
|
317
|
+
export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | RawQueryFragment;
|
|
318
|
+
export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string;
|
|
293
319
|
export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
|
|
294
320
|
export interface CheckConstraint<T = any> {
|
|
295
321
|
name?: string;
|
|
@@ -326,6 +352,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
326
352
|
default?: string | number | boolean | null;
|
|
327
353
|
defaultRaw?: string;
|
|
328
354
|
formula?: (alias: string) => string;
|
|
355
|
+
filters?: FilterOptions;
|
|
329
356
|
prefix?: string | boolean;
|
|
330
357
|
prefixMode?: EmbeddedPrefixMode;
|
|
331
358
|
embedded?: [EntityKey<Owner>, EntityKey<Owner>];
|
|
@@ -342,7 +369,6 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
342
369
|
mapToPk?: boolean;
|
|
343
370
|
persist?: boolean;
|
|
344
371
|
hydrate?: boolean;
|
|
345
|
-
trackChanges?: boolean;
|
|
346
372
|
hidden?: boolean;
|
|
347
373
|
enum?: boolean;
|
|
348
374
|
items?: (number | string)[];
|
|
@@ -353,6 +379,7 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
353
379
|
setter?: boolean;
|
|
354
380
|
getter?: boolean;
|
|
355
381
|
getterName?: keyof Owner;
|
|
382
|
+
accessor?: EntityKey<Owner>;
|
|
356
383
|
cascade: Cascade[];
|
|
357
384
|
orphanRemoval?: boolean;
|
|
358
385
|
onCreate?: (entity: Owner, em: EntityManager) => any;
|
|
@@ -385,6 +412,8 @@ export interface EntityProperty<Owner = any, Target = any> {
|
|
|
385
412
|
optional?: boolean;
|
|
386
413
|
ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
|
|
387
414
|
deferMode?: DeferMode;
|
|
415
|
+
createForeignKeyConstraint: boolean;
|
|
416
|
+
foreignKeyName?: string;
|
|
388
417
|
}
|
|
389
418
|
export declare class EntityMetadata<T = any> {
|
|
390
419
|
private static counter;
|
|
@@ -393,8 +422,9 @@ export declare class EntityMetadata<T = any> {
|
|
|
393
422
|
constructor(meta?: Partial<EntityMetadata>);
|
|
394
423
|
addProperty(prop: Partial<EntityProperty<T>>, sync?: boolean): void;
|
|
395
424
|
removeProperty(name: string, sync?: boolean): void;
|
|
396
|
-
getPrimaryProps(): EntityProperty<T>[];
|
|
425
|
+
getPrimaryProps(flatten?: boolean): EntityProperty<T>[];
|
|
397
426
|
getPrimaryProp(): EntityProperty<T>;
|
|
427
|
+
createColumnMappingObject(): Dictionary<any>;
|
|
398
428
|
get tableName(): string;
|
|
399
429
|
set tableName(name: string);
|
|
400
430
|
sync(initIndexes?: boolean, config?: Configuration): void;
|
|
@@ -413,14 +443,13 @@ export interface EntityMetadata<T = any> {
|
|
|
413
443
|
schema?: string;
|
|
414
444
|
pivotTable?: boolean;
|
|
415
445
|
virtual?: boolean;
|
|
416
|
-
expression?: string | ((em: any, where:
|
|
446
|
+
expression?: string | ((em: any, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>, stream?: boolean) => MaybePromise<RawQueryFragment | object | string>);
|
|
417
447
|
discriminatorColumn?: EntityKey<T> | AnyString;
|
|
418
448
|
discriminatorValue?: number | string;
|
|
419
449
|
discriminatorMap?: Dictionary<string>;
|
|
420
450
|
embeddable: boolean;
|
|
421
|
-
constructorParams
|
|
451
|
+
constructorParams?: (keyof T)[];
|
|
422
452
|
forceConstructor: boolean;
|
|
423
|
-
toJsonParams: string[];
|
|
424
453
|
extends: string;
|
|
425
454
|
collection: string;
|
|
426
455
|
path: string;
|
|
@@ -429,7 +458,7 @@ export interface EntityMetadata<T = any> {
|
|
|
429
458
|
compositePK: boolean;
|
|
430
459
|
versionProperty: EntityKey<T>;
|
|
431
460
|
concurrencyCheckKeys: Set<EntityKey<T>>;
|
|
432
|
-
serializedPrimaryKey
|
|
461
|
+
serializedPrimaryKey?: EntityKey<T>;
|
|
433
462
|
properties: {
|
|
434
463
|
[K in EntityKey<T>]: EntityProperty<T>;
|
|
435
464
|
};
|
|
@@ -443,21 +472,22 @@ export interface EntityMetadata<T = any> {
|
|
|
443
472
|
comparableProps: EntityProperty<T>[];
|
|
444
473
|
trackingProps: EntityProperty<T>[];
|
|
445
474
|
hydrateProps: EntityProperty<T>[];
|
|
475
|
+
validateProps: EntityProperty<T>[];
|
|
446
476
|
uniqueProps: EntityProperty<T>[];
|
|
447
477
|
getterProps: EntityProperty<T>[];
|
|
448
478
|
indexes: {
|
|
449
|
-
properties
|
|
479
|
+
properties?: EntityKey<T> | EntityKey<T>[];
|
|
450
480
|
name?: string;
|
|
451
481
|
type?: string;
|
|
452
482
|
options?: Dictionary;
|
|
453
|
-
expression?: string
|
|
483
|
+
expression?: string | IndexCallback<T>;
|
|
454
484
|
}[];
|
|
455
485
|
uniques: {
|
|
456
|
-
properties
|
|
486
|
+
properties?: EntityKey<T> | EntityKey<T>[];
|
|
457
487
|
name?: string;
|
|
458
488
|
options?: Dictionary;
|
|
459
|
-
expression?: string
|
|
460
|
-
deferMode?: DeferMode
|
|
489
|
+
expression?: string | IndexCallback<T>;
|
|
490
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
461
491
|
}[];
|
|
462
492
|
checks: CheckConstraint<T>[];
|
|
463
493
|
repositoryClass?: string;
|
|
@@ -468,7 +498,6 @@ export interface EntityMetadata<T = any> {
|
|
|
468
498
|
prototype: T;
|
|
469
499
|
class: EntityClass<T>;
|
|
470
500
|
abstract: boolean;
|
|
471
|
-
useCache: boolean;
|
|
472
501
|
filters: Dictionary<FilterDef>;
|
|
473
502
|
comment?: string;
|
|
474
503
|
selfReferencing?: boolean;
|
|
@@ -477,6 +506,7 @@ export interface EntityMetadata<T = any> {
|
|
|
477
506
|
polymorphs?: EntityMetadata[];
|
|
478
507
|
root: EntityMetadata<T>;
|
|
479
508
|
definedProperties: Dictionary;
|
|
509
|
+
hasTriggers?: boolean;
|
|
480
510
|
/** @internal can be used for computed numeric cache keys */
|
|
481
511
|
readonly _id: number;
|
|
482
512
|
}
|
|
@@ -487,6 +517,7 @@ export interface CreateSchemaOptions {
|
|
|
487
517
|
export interface ClearDatabaseOptions {
|
|
488
518
|
schema?: string;
|
|
489
519
|
truncate?: boolean;
|
|
520
|
+
clearIdentityMap?: boolean;
|
|
490
521
|
}
|
|
491
522
|
export interface EnsureDatabaseOptions extends CreateSchemaOptions, ClearDatabaseOptions {
|
|
492
523
|
clear?: boolean;
|
|
@@ -514,25 +545,25 @@ export interface RefreshDatabaseOptions extends CreateSchemaOptions {
|
|
|
514
545
|
createSchema?: boolean;
|
|
515
546
|
}
|
|
516
547
|
export interface ISchemaGenerator {
|
|
517
|
-
|
|
518
|
-
|
|
548
|
+
create(options?: CreateSchemaOptions): Promise<void>;
|
|
549
|
+
update(options?: UpdateSchemaOptions): Promise<void>;
|
|
550
|
+
drop(options?: DropSchemaOptions): Promise<void>;
|
|
551
|
+
refresh(options?: RefreshDatabaseOptions): Promise<void>;
|
|
552
|
+
clear(options?: ClearDatabaseOptions): Promise<void>;
|
|
553
|
+
execute(sql: string, options?: {
|
|
554
|
+
wrap?: boolean;
|
|
555
|
+
}): Promise<void>;
|
|
519
556
|
getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
|
|
520
|
-
dropSchema(options?: DropSchemaOptions): Promise<void>;
|
|
521
557
|
getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
|
|
522
|
-
updateSchema(options?: UpdateSchemaOptions): Promise<void>;
|
|
523
558
|
getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
|
|
524
559
|
getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
|
|
525
560
|
up: string;
|
|
526
561
|
down: string;
|
|
527
562
|
}>;
|
|
563
|
+
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
528
564
|
createDatabase(name?: string): Promise<void>;
|
|
529
565
|
dropDatabase(name?: string): Promise<void>;
|
|
530
|
-
execute(sql: string, options?: {
|
|
531
|
-
wrap?: boolean;
|
|
532
|
-
}): Promise<void>;
|
|
533
566
|
ensureIndexes(): Promise<void>;
|
|
534
|
-
refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
|
|
535
|
-
clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
|
|
536
567
|
}
|
|
537
568
|
export type ImportsResolver = (alias: string, basePath: string, extension: '.js' | '', originFileName: string) => {
|
|
538
569
|
path: string;
|
|
@@ -549,7 +580,10 @@ export interface GenerateOptions {
|
|
|
549
580
|
undefinedDefaults?: boolean;
|
|
550
581
|
bidirectionalRelations?: boolean;
|
|
551
582
|
identifiedReferences?: boolean;
|
|
552
|
-
|
|
583
|
+
entityDefinition?: 'decorators' | 'defineEntity' | 'entitySchema';
|
|
584
|
+
decorators?: 'es' | 'legacy';
|
|
585
|
+
inferEntityType?: boolean;
|
|
586
|
+
enumMode?: 'ts-enum' | 'union-type' | 'dictionary';
|
|
553
587
|
esmImport?: boolean;
|
|
554
588
|
scalarTypeInDecorator?: boolean;
|
|
555
589
|
scalarPropertiesForRelations?: 'always' | 'never' | 'smart';
|
|
@@ -609,26 +643,26 @@ export interface IMigrator {
|
|
|
609
643
|
/**
|
|
610
644
|
* Checks current schema for changes, generates new migration if there are any.
|
|
611
645
|
*/
|
|
612
|
-
|
|
646
|
+
create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
|
|
613
647
|
/**
|
|
614
648
|
* Checks current schema for changes.
|
|
615
649
|
*/
|
|
616
|
-
|
|
650
|
+
checkSchema(): Promise<boolean>;
|
|
617
651
|
/**
|
|
618
652
|
* Creates initial migration. This generates the schema based on metadata, and checks whether all the tables
|
|
619
653
|
* are already present. If yes, it will also automatically log the migration as executed.
|
|
620
654
|
* Initial migration can be created only if the schema is already aligned with the metadata, or when no schema
|
|
621
655
|
* is present - in such case regular migration would have the same effect.
|
|
622
656
|
*/
|
|
623
|
-
|
|
657
|
+
createInitial(path?: string): Promise<MigrationResult>;
|
|
624
658
|
/**
|
|
625
659
|
* Returns list of already executed migrations.
|
|
626
660
|
*/
|
|
627
|
-
|
|
661
|
+
getExecuted(): Promise<MigrationRow[]>;
|
|
628
662
|
/**
|
|
629
663
|
* Returns list of pending (not yet executed) migrations found in the migration directory.
|
|
630
664
|
*/
|
|
631
|
-
|
|
665
|
+
getPending(): Promise<UmzugMigration[]>;
|
|
632
666
|
/**
|
|
633
667
|
* Executes specified migrations. Without parameter it will migrate up to the latest version.
|
|
634
668
|
*/
|
|
@@ -677,12 +711,17 @@ export interface MigrationObject {
|
|
|
677
711
|
name: string;
|
|
678
712
|
class: Constructor<Migration>;
|
|
679
713
|
}
|
|
680
|
-
|
|
714
|
+
type EntityFromInput<T> = T extends readonly EntityName<infer U>[] ? U : T extends EntityName<infer U> ? U : never;
|
|
715
|
+
type FilterDefResolved<T extends object = any> = {
|
|
681
716
|
name: string;
|
|
682
|
-
cond:
|
|
717
|
+
cond: FilterQuery<T> | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, entityName?: EntityName<T>) => MaybePromise<FilterQuery<T>>);
|
|
683
718
|
default?: boolean;
|
|
684
|
-
entity?:
|
|
719
|
+
entity?: EntityName<T> | EntityName<T>[];
|
|
685
720
|
args?: boolean;
|
|
721
|
+
strict?: boolean;
|
|
722
|
+
};
|
|
723
|
+
export type FilterDef<T extends EntityName<any> | readonly EntityName<any>[] = any> = FilterDefResolved<EntityFromInput<T>> & {
|
|
724
|
+
entity?: T;
|
|
686
725
|
};
|
|
687
726
|
export type Populate<T, P extends string = never> = readonly AutoPath<T, P, `${PopulatePath}`>[] | false;
|
|
688
727
|
export type PopulateOptions<T> = {
|
|
@@ -690,6 +729,7 @@ export type PopulateOptions<T> = {
|
|
|
690
729
|
strategy?: LoadStrategy;
|
|
691
730
|
all?: boolean;
|
|
692
731
|
filter?: boolean;
|
|
732
|
+
joinType?: 'inner join' | 'left join';
|
|
693
733
|
children?: PopulateOptions<T[keyof T]>[];
|
|
694
734
|
};
|
|
695
735
|
type Loadable<T extends object> = Collection<T, any> | Reference<T> | Ref<T> | readonly T[];
|
|
@@ -724,7 +764,7 @@ export type MergeSelected<T, U, F extends string> = T extends Loaded<infer TT, i
|
|
|
724
764
|
type MergeFields<F1 extends string, F2 extends string, P1, P2> = P1 | P2 extends '*' ? '*' : F1 | F2;
|
|
725
765
|
type MergeExcludes<F extends string, E extends string> = F extends E ? never : Exclude<E, F>;
|
|
726
766
|
export type MergeLoaded<T, U, P extends string, F extends string, E extends string, R extends boolean = false> = T extends Loaded<U, infer PP, infer FF, infer EE> ? string extends FF ? Loaded<T, P, F, AnyStringToNever<EE> | E> : string extends P ? Loaded<U, never, F | (FF & string), MergeExcludes<F | (FF & string), EE | E>> : Loaded<U, P | AnyStringToNever<PP>, MergeFields<F, AnyStringToNever<FF>, P, PP>, MergeExcludes<MergeFields<F, AnyStringToNever<FF>, P, PP>, (R extends true ? never : EE) | E>> : Loaded<T, P, F>;
|
|
727
|
-
type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
|
|
767
|
+
export type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
|
|
728
768
|
type LoadedProp<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedLoadable<T, Loaded<ExtractType<T>, L, F, E>>;
|
|
729
769
|
export type AddEager<T> = ExtractEagerProps<T> & string;
|
|
730
770
|
export type ExpandHint<T, L extends string> = L | AddEager<T>;
|
|
@@ -785,11 +825,11 @@ export interface IHydrator {
|
|
|
785
825
|
* Hydrates the whole entity. This process handles custom type conversions, creating missing Collection instances,
|
|
786
826
|
* mapping FKs to entity instances, as well as merging those entities.
|
|
787
827
|
*/
|
|
788
|
-
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;
|
|
828
|
+
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;
|
|
789
829
|
/**
|
|
790
830
|
* Hydrates primary keys only
|
|
791
831
|
*/
|
|
792
|
-
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
|
|
832
|
+
hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
|
|
793
833
|
isRunning(): boolean;
|
|
794
834
|
}
|
|
795
835
|
export interface HydratorConstructor {
|
|
@@ -799,17 +839,18 @@ export interface ISeedManager {
|
|
|
799
839
|
seed(...classNames: Constructor<Seeder>[]): Promise<void>;
|
|
800
840
|
/** @internal */
|
|
801
841
|
seedString(...classNames: string[]): Promise<void>;
|
|
802
|
-
|
|
842
|
+
create(className: string): Promise<string>;
|
|
803
843
|
}
|
|
804
844
|
export interface Seeder<T extends Dictionary = Dictionary> {
|
|
805
845
|
run(em: EntityManager, context?: T): void | Promise<void>;
|
|
806
846
|
}
|
|
807
847
|
export type ConnectionType = 'read' | 'write';
|
|
808
848
|
export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
}
|
|
849
|
+
export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
850
|
+
export interface EntitySchemaWithMeta<TName extends string = string, TTableName extends string = string, TEntity = any, TBase = never, TProperties extends Record<string, any> = Record<string, any>> extends EntitySchema<TEntity, TBase> {
|
|
851
|
+
readonly name: TName;
|
|
852
|
+
readonly properties: TProperties;
|
|
853
|
+
readonly tableName: TTableName;
|
|
854
|
+
}
|
|
855
|
+
export type InferEntity<Schema> = Schema extends EntitySchemaWithMeta<any, any, infer Entity, any, any> ? Entity : Schema extends EntitySchema<infer Entity> ? Entity : Schema extends EntityClass<infer Entity> ? Entity : Schema;
|
|
815
856
|
export {};
|