@mikro-orm/core 6.3.10-dev.15 → 6.3.10-dev.17

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.
@@ -11,15 +11,9 @@ function CreateRequestContext(getContext, respectExistingContext = false) {
11
11
  return function (target, propertyKey, descriptor) {
12
12
  const originalMethod = descriptor.value;
13
13
  descriptor.value = async function (...args) {
14
- // reuse existing context if available
15
- if (respectExistingContext && RequestContext_1.RequestContext.currentRequestContext()) {
16
- return originalMethod.apply(this, args);
17
- }
18
- // If we are inside explicit transaction context, we need to create another tx context.
19
14
  // Otherwise, the outer tx context would be preferred.
20
15
  const txContext = TransactionContext_1.TransactionContext.currentTransactionContext();
21
16
  const provider = txContext ? TransactionContext_1.TransactionContext : RequestContext_1.RequestContext;
22
- /* istanbul ignore next */
23
17
  let orm;
24
18
  let em;
25
19
  if (typeof getContext === 'function') {
@@ -35,6 +29,10 @@ function CreateRequestContext(getContext, respectExistingContext = false) {
35
29
  em = await this.em;
36
30
  }
37
31
  const create = async (em) => {
32
+ // reuse existing context if available for given respect `contextName`
33
+ if (respectExistingContext && RequestContext_1.RequestContext.getEntityManager(em.name)) {
34
+ return originalMethod.apply(this, args);
35
+ }
38
36
  if (txContext) {
39
37
  em = em.fork({ useContext: true });
40
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.3.10-dev.15",
3
+ "version": "6.3.10-dev.17",
4
4
  "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.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -64,7 +64,7 @@
64
64
  "esprima": "4.0.1",
65
65
  "fs-extra": "11.2.0",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.3.10-dev.15",
67
+ "mikro-orm": "6.3.10-dev.17",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
package/typings.d.ts CHANGED
@@ -683,7 +683,7 @@ export type AutoPath<O, P extends string | boolean, E extends string = never, D
683
683
  export type UnboxArray<T> = T extends any[] ? ArrayElement<T> : T;
684
684
  export type ArrayElement<ArrayType extends unknown[]> = ArrayType extends (infer ElementType)[] ? ElementType : never;
685
685
  export type ExpandProperty<T> = T extends Reference<infer U> ? NonNullable<U> : T extends Collection<infer U, any> ? NonNullable<U> : T extends (infer U)[] ? NonNullable<U> : NonNullable<T>;
686
- type LoadedLoadable<T, E extends object> = T extends Collection<any, any> ? LoadedCollection<E> : T extends Reference<any> ? LoadedReference<E> : T extends ScalarReference<infer U> ? LoadedScalarReference<U> : T extends Scalar | any[] ? T : E;
686
+ type LoadedLoadable<T, E extends object> = T extends Collection<any, any> ? LoadedCollection<E> : T extends Reference<any> ? T & LoadedReference<E> : T extends ScalarReference<infer U> ? LoadedScalarReference<U> : T extends Scalar | any[] ? T : E;
687
687
  type IsTrue<T> = IsNever<T> extends true ? false : T extends boolean ? T extends true ? true : false : false;
688
688
  type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
689
689
  type Prefix<T, K> = K extends `${infer S}.${string}` ? S : (K extends '*' ? keyof T : K);