@mikro-orm/core 7.2.0-dev.2 → 7.2.0-dev.21
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 +42 -8
- package/EntityManager.js +256 -70
- package/MikroORM.d.ts +4 -0
- package/MikroORM.js +9 -0
- package/cache/CacheAdapter.d.ts +6 -4
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +7 -2
- package/connections/Connection.d.ts +10 -1
- package/connections/Connection.js +9 -0
- package/drivers/DatabaseDriver.d.ts +17 -1
- package/drivers/DatabaseDriver.js +203 -41
- package/drivers/IDatabaseDriver.d.ts +1 -0
- package/entity/Collection.js +4 -2
- package/entity/EntityFactory.js +6 -0
- package/entity/EntityLoader.d.ts +7 -1
- package/entity/EntityLoader.js +46 -11
- package/entity/EntityRepository.d.ts +4 -5
- package/entity/EntityRepository.js +7 -2
- package/entity/defineEntity.d.ts +48 -14
- package/entity/defineEntity.js +32 -1
- package/enums.d.ts +5 -1
- package/enums.js +2 -0
- package/errors.d.ts +36 -0
- package/errors.js +90 -0
- package/events/EventManager.js +6 -3
- package/exceptions.d.ts +5 -0
- package/exceptions.js +5 -0
- package/hydration/ObjectHydrator.d.ts +2 -0
- package/hydration/ObjectHydrator.js +15 -8
- package/index.d.ts +1 -1
- package/metadata/EntitySchema.js +5 -2
- package/metadata/MetadataDiscovery.d.ts +3 -0
- package/metadata/MetadataDiscovery.js +161 -28
- package/metadata/MetadataProvider.js +1 -1
- package/metadata/MetadataStorage.d.ts +4 -3
- package/metadata/MetadataStorage.js +32 -2
- package/metadata/Routine.js +4 -1
- package/metadata/types.d.ts +19 -3
- package/naming-strategy/AbstractNamingStrategy.js +2 -1
- package/naming-strategy/NamingStrategy.d.ts +2 -1
- package/package.json +1 -1
- package/platforms/Platform.d.ts +24 -3
- package/platforms/Platform.js +63 -1
- package/types/BigIntType.d.ts +1 -0
- package/types/BigIntType.js +23 -0
- package/types/DateTimeType.d.ts +1 -0
- package/types/DateTimeType.js +8 -0
- package/types/StringType.d.ts +14 -3
- package/types/StringType.js +34 -4
- package/types/TextType.d.ts +2 -4
- package/types/TextType.js +2 -8
- package/types/Type.d.ts +11 -0
- package/types/Type.js +4 -4
- package/types/index.d.ts +2 -2
- package/typings.d.ts +58 -2
- package/typings.js +24 -1
- package/unit-of-work/ChangeSet.js +10 -7
- package/unit-of-work/ChangeSetPersister.js +32 -20
- package/unit-of-work/UnitOfWork.js +11 -4
- package/utils/AbstractMigrator.d.ts +1 -1
- package/utils/AbstractMigrator.js +3 -2
- package/utils/Configuration.d.ts +15 -1
- package/utils/Configuration.js +13 -2
- package/utils/Cursor.d.ts +2 -0
- package/utils/Cursor.js +44 -39
- package/utils/DataloaderUtils.js +2 -1
- package/utils/EntityComparator.d.ts +2 -0
- package/utils/EntityComparator.js +11 -4
- package/utils/QueryHelper.d.ts +17 -0
- package/utils/QueryHelper.js +100 -4
- package/utils/RawQueryFragment.d.ts +6 -0
- package/utils/RawQueryFragment.js +15 -6
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +11 -2
- package/utils/TransactionManager.d.ts +6 -0
- package/utils/TransactionManager.js +36 -3
- package/utils/Utils.d.ts +14 -2
- package/utils/Utils.js +36 -6
- package/utils/clone.js +6 -0
- package/utils/env-vars.js +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/rls-utils.d.ts +35 -0
- package/utils/rls-utils.js +97 -0
- package/utils/upsert-utils.d.ts +9 -1
- package/utils/upsert-utils.js +26 -3
package/EntityManager.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { EntityLoader, type EntityLoaderOptions } from './entity/EntityLoader.js
|
|
|
7
7
|
import { Reference } from './entity/Reference.js';
|
|
8
8
|
import { UnitOfWork } from './unit-of-work/UnitOfWork.js';
|
|
9
9
|
import type { CountByOptions, CountOptions, DeleteOptions, FilterOptions, FindAllOptions, FindByCursorOptions, FindOneOptions, FindOneOrFailOptions, FindOptions, GetReferenceOptions, IDatabaseDriver, LockOptions, NativeInsertUpdateOptions, StreamOptions, UpdateOptions, UpsertManyOptions, UpsertOptions } from './drivers/IDatabaseDriver.js';
|
|
10
|
-
import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityClass, EntityData, EntityDictionary, EntityDTO, EntityKey, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, ObjectQuery, PopulateOptions, Primary, Ref, RequiredEntityData, RoutineArgs, RoutineReturn, UnboxArray, IndexFilterQuery, WithUsingOptions } from './typings.js';
|
|
10
|
+
import type { AnyString, ArrayElement, AutoPath, ConnectionType, Dictionary, EntityClass, EntityData, EntityDictionary, EntityDTO, EntityKey, EntityMetadata, EntityName, FilterDef, FilterQuery, FromEntityType, GetRepository, IHydrator, IsSubset, Loaded, MergeLoaded, MergeSelected, ObjectQuery, PopulateOptions, Primary, Ref, RequiredEntityData, RoutineArgs, RoutineReturn, SessionContext, UnboxArray, IndexFilterQuery, WithUsingOptions } from './typings.js';
|
|
11
11
|
import type { Routine } from './metadata/Routine.js';
|
|
12
12
|
import { FlushMode, LockMode, PopulatePath, type TransactionOptions } from './enums.js';
|
|
13
13
|
import type { MetadataStorage } from './metadata/MetadataStorage.js';
|
|
@@ -95,7 +95,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
95
95
|
/**
|
|
96
96
|
* Registers global filter to this entity manager. Global filters are enabled by default (unless disabled via last parameter).
|
|
97
97
|
*/
|
|
98
|
-
addFilter<T extends EntityName | readonly EntityName[]>(options: FilterDef<T>): void;
|
|
98
|
+
addFilter<T extends EntityName | readonly EntityName[]>(options: Omit<FilterDef<T>, 'rls'>): void;
|
|
99
99
|
/**
|
|
100
100
|
* Sets filter parameter values globally inside context defined by this entity manager.
|
|
101
101
|
* If you want to set shared value for all contexts, be sure to use the root entity manager.
|
|
@@ -105,6 +105,32 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
105
105
|
* Returns filter parameters for given filter set in this context.
|
|
106
106
|
*/
|
|
107
107
|
getFilterParams<T extends Dictionary = Dictionary>(name: string): T;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the database session context (row level security) for this entity manager. Session variables are merged
|
|
110
|
+
* with any previously set ones, while the role is replaced when one is provided. The variables are applied via `set_config()` and are
|
|
111
|
+
* typically referenced by RLS policies through `current_setting()`.
|
|
112
|
+
*/
|
|
113
|
+
setSessionContext(context: SessionContext): void;
|
|
114
|
+
private validateSessionContextStaging;
|
|
115
|
+
/** Merges into this exact instance — `fork()` must bypass context resolution to target the new fork. */
|
|
116
|
+
private mergeSessionContext;
|
|
117
|
+
/**
|
|
118
|
+
* Returns the database session context (row level security) set for this entity manager, or `undefined` if none.
|
|
119
|
+
*/
|
|
120
|
+
getSessionContext(): SessionContext | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Clears the database session context, since `setSessionContext()` only ever merges variables and updates the role.
|
|
123
|
+
*/
|
|
124
|
+
clearSessionContext(): void;
|
|
125
|
+
/** @internal session context to apply on `begin()` under the `'transaction'` strategy (`undefined` otherwise). */
|
|
126
|
+
getTransactionSessionContext(): SessionContext | undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Wraps a driver call in a short implicit transaction when the session context needs to apply, so `set local`
|
|
129
|
+
* takes effect. Resolves to a plain call when already inside a transaction or when no session context is set.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
withSessionContext<T>(ctx: Transaction | undefined, cb: (ctx?: Transaction) => Promise<T>): Promise<T>;
|
|
108
134
|
/**
|
|
109
135
|
* Sets logger context for this entity manager.
|
|
110
136
|
*/
|
|
@@ -375,12 +401,10 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
375
401
|
*/
|
|
376
402
|
nativeDelete<Entity extends object>(entityName: EntityName<Entity>, where: FilterQuery<NoInfer<Entity>>, options?: DeleteOptions<Entity>): Promise<number>;
|
|
377
403
|
/**
|
|
378
|
-
* Maps raw database result to an entity and merges it to this EntityManager.
|
|
404
|
+
* Maps raw database result to an entity and merges it to this EntityManager by default.
|
|
405
|
+
* Use `disableIdentityMap` to return an isolated entity without affecting the current context.
|
|
379
406
|
*/
|
|
380
|
-
map<Entity extends object>(entityName: EntityName<Entity>, result: EntityDictionary<Entity>, options?:
|
|
381
|
-
schema?: string;
|
|
382
|
-
mapped?: boolean;
|
|
383
|
-
}): Entity;
|
|
407
|
+
map<Entity extends object>(entityName: EntityName<Entity>, result: EntityDictionary<Entity>, options?: MapOptions): Entity;
|
|
384
408
|
/**
|
|
385
409
|
* Merges given entity to this EntityManager so it becomes managed. You can force refreshing of existing entities
|
|
386
410
|
* via second parameter. By default, it will return already loaded entities without modifying them.
|
|
@@ -601,7 +625,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
|
|
|
601
625
|
* some additional lazy properties, if so, we reload and merge the data from database
|
|
602
626
|
*/
|
|
603
627
|
protected shouldRefresh<T extends object, P extends string = never, F extends string = never, E extends string = never>(meta: EntityMetadata<T>, entity: T, options: FindOneOptions<T, P, F, E>): boolean;
|
|
604
|
-
protected prepareOptions
|
|
628
|
+
protected prepareOptions<Options extends (FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any> | CountByOptions<any>) & AbortQueryOptions>(options: Options): Options;
|
|
605
629
|
/**
|
|
606
630
|
* @internal
|
|
607
631
|
*/
|
|
@@ -667,6 +691,14 @@ export interface CreateOptions<Convert extends boolean> {
|
|
|
667
691
|
*/
|
|
668
692
|
processOnCreateHooksEarly?: boolean;
|
|
669
693
|
}
|
|
694
|
+
export interface MapOptions {
|
|
695
|
+
/** schema to use when mapping the entity */
|
|
696
|
+
schema?: string;
|
|
697
|
+
/** set to true when the result is already mapped to entity property names */
|
|
698
|
+
mapped?: boolean;
|
|
699
|
+
/** map the entity in an isolated context without adding it to the identity map */
|
|
700
|
+
disableIdentityMap?: boolean;
|
|
701
|
+
}
|
|
670
702
|
export interface MergeOptions {
|
|
671
703
|
refresh?: boolean;
|
|
672
704
|
convertCustomTypes?: boolean;
|
|
@@ -694,6 +726,8 @@ export interface ForkOptions {
|
|
|
694
726
|
keepTransactionContext?: boolean;
|
|
695
727
|
/** default schema to use for this fork */
|
|
696
728
|
schema?: string;
|
|
729
|
+
/** database session context (row level security) for this fork; inherited from the parent when not set */
|
|
730
|
+
session?: SessionContext;
|
|
697
731
|
/** default logger context, can be overridden via {@apilink FindOptions} */
|
|
698
732
|
loggerContext?: Dictionary;
|
|
699
733
|
/**
|