@mikro-orm/core 7.2.7-dev.7 → 7.2.7-dev.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.7-dev.7",
3
+ "version": "7.2.7-dev.9",
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
  "keywords": [
6
6
  "data-mapper",
package/typings.d.ts CHANGED
@@ -565,6 +565,13 @@ export declare namespace LazyRef {
565
565
  [__lazyRef]?: (arg: T) => T;
566
566
  }
567
567
  }
568
+ /**
569
+ * The brand's only key is optional, so an object type without named properties (like `Record<string, number>`)
570
+ * extends `LazyRef.Brand<infer U>` too, with `U` inferred as `unknown`. `LazyRef<T>` needs `T extends object`,
571
+ * so an `unknown` target means the type is not a `LazyRef` and resolves to `Fallback`. `any` stays `any`.
572
+ * Only checked once `unknown extends U` holds, so a real `LazyRef` skips it.
573
+ */
574
+ type NotLazyRef<U, Fallback> = IsAny<U> extends true ? U : Fallback;
568
575
  /** Alias for `Reference<T> & { id: number }` (see {@apilink Ref}). */
569
576
  export type EntityRef<T extends object> = true extends IsUnknown<PrimaryProperty<T>> ? Reference<T> : IsAny<T> extends true ? Reference<T> : {
570
577
  [K in PrimaryProperty<T> & keyof T]: T[K];
@@ -1618,7 +1625,7 @@ export type UnboxArray<T> = T extends any[] ? ArrayElement<T> : T;
1618
1625
  /** Extracts the element type from an array type. */
1619
1626
  export type ArrayElement<ArrayType extends unknown[]> = ArrayType extends (infer ElementType)[] ? ElementType : never;
1620
1627
  /** Unwraps a property type from its wrapper (Reference, Collection, or array) to the inner entity type. */
1621
- export type ExpandProperty<T> = T extends LazyRef.Brand<infer U> ? NonNullable<U> : T extends ReferenceShape<infer U> ? NonNullable<U> : T extends CollectionShape<infer U> ? NonNullable<U> : T extends (infer U)[] ? NonNullable<U> : NonNullable<T>;
1628
+ export type ExpandProperty<T> = T extends LazyRef.Brand<infer U> ? unknown extends U ? NotLazyRef<U, NonNullable<T>> : NonNullable<U> : T extends ReferenceShape<infer U> ? NonNullable<U> : T extends CollectionShape<infer U> ? NonNullable<U> : T extends (infer U)[] ? NonNullable<U> : NonNullable<T>;
1622
1629
  type LoadedLoadable<T, E extends object> = T extends CollectionShape ? LoadedCollection<E> : T extends ScalarReference<infer U> ? LoadedScalarReference<U> : T extends LazyRef.Brand<any> ? E : T extends ReferenceShape ? T & LoadedReference<E> : T extends Scalar ? T : T extends (infer U)[] ? U extends Scalar ? T : E[] : E;
1623
1630
  type IsTrue<T> = IsNever<T> extends true ? false : T extends boolean ? (T extends true ? true : false) : false;
1624
1631
  type StringLiteral<T> = T extends string ? (string extends T ? never : T) : never;
@@ -1653,7 +1660,12 @@ export type MergeSelected<T, U, F extends string> = IsLoadedType<T> extends true
1653
1660
  export type MergeLoaded<T, U, P extends string, F extends string, E extends string, R extends boolean = false> = IsLoadedType<T> extends true ? T & Loaded<U, P, F, E> : Loaded<T, P, F, E>;
1654
1661
  /** Extracts the nullability modifiers (`null`, `undefined`, or both) from a type `T`. */
1655
1662
  export type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
1656
- type LoadedProp<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedLoadable<T, Loaded<ExtractTypeWithLazyRef<T>, L, F, E>>;
1663
+ /**
1664
+ * Like {@link ExtractTypeWithLazyRef}, but a record type that matched `LazyRef.Brand` resolves to itself (see
1665
+ * {@link NotLazyRef}). `AutoPath` keeps the unguarded version, as it is on its hot path.
1666
+ */
1667
+ type ExtractLoadedType<T> = T extends LazyRef.Brand<infer U> ? (unknown extends U ? NotLazyRef<U, ExtractType<T>> : U) : ExtractType<T>;
1668
+ type LoadedProp<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedLoadable<T, Loaded<ExtractLoadedType<T>, L, F, E>>;
1657
1669
  /** Extracts the eager-loaded property names declared via `[EagerProps]` as a string union. */
1658
1670
  export type AddEager<T> = ExtractEagerProps<T> & string;
1659
1671
  /** Combines an explicit populate hint `L` with the entity's eagerly loaded properties. */
package/utils/Utils.js CHANGED
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.2.7-dev.7';
156
+ static #ORM_VERSION = '7.2.7-dev.9';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;