@mikro-orm/core 7.0.0-dev.55 → 7.0.0-dev.56

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.
@@ -129,7 +129,7 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
129
129
  getLoggerContext<T extends Dictionary = Dictionary>(options?: {
130
130
  disableContextResolution?: boolean;
131
131
  }): T;
132
- setFlushMode(flushMode?: FlushMode): void;
132
+ setFlushMode(flushMode?: FlushMode | `${FlushMode}`): void;
133
133
  protected processWhere<Entity extends object, Hint extends string = never, Fields extends string = '*', Excludes extends string = never>(entityName: string, where: FilterQuery<Entity>, options: FindOptions<Entity, Hint, Fields, Excludes> | FindOneOptions<Entity, Hint, Fields, Excludes>, type: 'read' | 'update' | 'delete'): Promise<FilterQuery<Entity>>;
134
134
  protected applyDiscriminatorCondition<Entity extends object>(entityName: string, where: FilterQuery<Entity>): FilterQuery<Entity>;
135
135
  protected createPopulateWhere<Entity extends object>(cond: ObjectQuery<Entity>, options: FindOptions<Entity, any, any, any> | FindOneOptions<Entity, any, any, any> | CountOptions<Entity, any>): ObjectQuery<Entity>;
@@ -611,7 +611,7 @@ export interface ForkOptions {
611
611
  /** use this flag to ignore the current async context - this is required if we want to call `em.fork()` inside the `getContext` handler */
612
612
  disableContextResolution?: boolean;
613
613
  /** set flush mode for this fork, overrides the global option can be overridden locally via FindOptions */
614
- flushMode?: FlushMode;
614
+ flushMode?: FlushMode | `${FlushMode}`;
615
615
  /** disable transactions for this fork */
616
616
  disableTransactions?: boolean;
617
617
  /** should we keep the transaction context of the parent EM? */
@@ -44,14 +44,14 @@ export declare abstract class Connection {
44
44
  ensureConnection(): Promise<void>;
45
45
  protected onConnect(): Promise<void>;
46
46
  transactional<T>(cb: (trx: Transaction) => Promise<T>, options?: {
47
- isolationLevel?: IsolationLevel;
47
+ isolationLevel?: IsolationLevel | `${IsolationLevel}`;
48
48
  readOnly?: boolean;
49
49
  ctx?: Transaction;
50
50
  eventBroadcaster?: TransactionEventBroadcaster;
51
51
  loggerContext?: LogContext;
52
52
  }): Promise<T>;
53
53
  begin(options?: {
54
- isolationLevel?: IsolationLevel;
54
+ isolationLevel?: IsolationLevel | `${IsolationLevel}`;
55
55
  readOnly?: boolean;
56
56
  ctx?: Transaction;
57
57
  eventBroadcaster?: TransactionEventBroadcaster;
@@ -1,4 +1,4 @@
1
- import type { TransactionOptions } from '../enums.js';
1
+ import { type TransactionOptions } from '../enums.js';
2
2
  import type { ContextProvider } from '../typings.js';
3
3
  type TransactionalOptions<T> = TransactionOptions & {
4
4
  context?: ContextProvider<T>;
@@ -9,6 +9,7 @@ type TransactionalOptions<T> = TransactionOptions & {
9
9
  * The difference is that you can specify the context in which the transaction begins by providing `context` option,
10
10
  * and if omitted, the transaction will begin in the current context implicitly.
11
11
  * It works on async functions and can be nested with `em.transactional()`.
12
+ * Unlike `em.transactional()`, this decorator uses `REQUIRED` propagation by default, which means it will join existing transactions.
12
13
  */
13
14
  export declare function Transactional<T extends object>(options?: TransactionalOptions<T>): MethodDecorator;
14
15
  export {};
@@ -1,3 +1,4 @@
1
+ import { TransactionPropagation } from '../enums.js';
1
2
  import { RequestContext } from '../utils/RequestContext.js';
2
3
  import { resolveContextProvider } from '../utils/resolveContextProvider.js';
3
4
  import { TransactionContext } from '../utils/TransactionContext.js';
@@ -6,6 +7,7 @@ import { TransactionContext } from '../utils/TransactionContext.js';
6
7
  * The difference is that you can specify the context in which the transaction begins by providing `context` option,
7
8
  * and if omitted, the transaction will begin in the current context implicitly.
8
9
  * It works on async functions and can be nested with `em.transactional()`.
10
+ * Unlike `em.transactional()`, this decorator uses `REQUIRED` propagation by default, which means it will join existing transactions.
9
11
  */
10
12
  export function Transactional(options = {}) {
11
13
  return function (target, propertyKey, descriptor) {
@@ -15,6 +17,7 @@ export function Transactional(options = {}) {
15
17
  }
16
18
  descriptor.value = async function (...args) {
17
19
  const { context, contextName, ...txOptions } = options;
20
+ txOptions.propagation ??= TransactionPropagation.REQUIRED;
18
21
  const em = (await resolveContextProvider(this, context))
19
22
  || TransactionContext.getEntityManager(contextName)
20
23
  || RequestContext.getEntityManager(contextName);
package/enums.d.ts CHANGED
@@ -170,11 +170,11 @@ export declare enum TransactionPropagation {
170
170
  }
171
171
  export interface TransactionOptions {
172
172
  ctx?: Transaction;
173
- propagation?: TransactionPropagation;
174
- isolationLevel?: IsolationLevel;
173
+ propagation?: TransactionPropagation | `${TransactionPropagation}`;
174
+ isolationLevel?: IsolationLevel | `${IsolationLevel}`;
175
175
  readOnly?: boolean;
176
176
  clear?: boolean;
177
- flushMode?: FlushMode;
177
+ flushMode?: FlushMode | `${FlushMode}`;
178
178
  ignoreNestedTransactions?: boolean;
179
179
  loggerContext?: LogContext;
180
180
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.55",
4
+ "version": "7.0.0-dev.56",
5
5
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -55,7 +55,7 @@
55
55
  "dataloader": "2.2.3",
56
56
  "dotenv": "17.2.3",
57
57
  "esprima": "4.0.1",
58
- "mikro-orm": "7.0.0-dev.55",
58
+ "mikro-orm": "7.0.0-dev.56",
59
59
  "reflect-metadata": "0.2.2",
60
60
  "tinyglobby": "0.2.13"
61
61
  }