@mikro-orm/core 6.5.8-dev.14 → 6.5.8-dev.15

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.
@@ -6,7 +6,7 @@ import type { ManyToOneOptions } from '../decorators/ManyToOne';
6
6
  import type { OneToManyOptions } from '../decorators/OneToMany';
7
7
  import type { OneToOneOptions } from '../decorators/OneToOne';
8
8
  import type { ManyToManyOptions } from '../decorators/ManyToMany';
9
- import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, EntityClass } from '../typings';
9
+ import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass } from '../typings';
10
10
  import type { Reference, ScalarReference } from './Reference';
11
11
  import type { SerializeOptions } from '../serialization/EntitySerializer';
12
12
  import type { Cascade, DeferMode, LoadStrategy, QueryOrderMap } from '../enums';
@@ -390,7 +390,11 @@ export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends
390
390
  /** Point to the inverse side property name. */
391
391
  inversedBy(inversedBy: (string & keyof TargetValue) | ((e: TargetValue) => any)): this;
392
392
  /** Map this relation to the primary key value instead of an entity. */
393
- mapToPk(mapToPk?: boolean): this;
393
+ mapToPk<T extends boolean = true>(mapToPk?: T): this & {
394
+ '~options': {
395
+ mapToPk: T;
396
+ };
397
+ };
394
398
  /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
395
399
  joinColumn(joinColumn: string): this;
396
400
  /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
@@ -458,7 +462,11 @@ export declare class OneToOneOptionsBuilder<TargetValue extends object> extends
458
462
  /** Point to the inverse side property name. */
459
463
  inversedBy(inversedBy: (string & keyof TargetValue) | ((e: TargetValue) => any)): this;
460
464
  /** Map this relation to the primary key value instead of an entity. */
461
- mapToPk(mapToPk?: boolean): this;
465
+ mapToPk<T extends boolean = true>(mapToPk?: T): this & {
466
+ '~options': {
467
+ mapToPk: T;
468
+ };
469
+ };
462
470
  /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
463
471
  ownColumns(...ownColumns: string[]): this;
464
472
  /** What to do when the target entity gets deleted. */
@@ -582,27 +590,38 @@ type InferBuilderValue<Builder> = Builder extends {
582
590
  '~type'?: {
583
591
  value: infer Value;
584
592
  };
585
- } ? MaybeHidden<MaybeOpt<MaybeRef<MaybeNullable<MaybeArray<Value, Builder>, Builder>, Builder>, Builder>, Builder> : never;
593
+ } ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Builder>, Builder>, Builder>, Builder>, Builder>, Builder>, Builder> : never;
586
594
  type MaybeArray<Value, Builder> = Builder extends {
587
595
  '~options': {
588
596
  array: true;
589
597
  };
590
598
  } ? Value[] : Value;
599
+ type MaybeMapToPk<Value, Builder> = Builder extends {
600
+ '~options': {
601
+ mapToPk: true;
602
+ };
603
+ } ? Primary<Value> : Value;
591
604
  type MaybeNullable<Value, Builder> = Builder extends {
592
605
  '~options': {
593
606
  nullable: true;
594
607
  };
595
608
  } ? Value | null | undefined : Value;
596
- type MaybeRef<Value, Builder> = Builder extends {
609
+ type MaybeRelationRef<Value, Builder> = Builder extends {
610
+ '~options': {
611
+ mapToPk: true;
612
+ };
613
+ } ? Value : Builder extends {
597
614
  '~options': {
598
615
  ref: false;
599
616
  };
600
617
  } ? Value : Builder extends {
601
618
  '~options': {
619
+ ref: true;
602
620
  kind: '1:1';
603
621
  };
604
622
  } ? Value extends object ? Reference<Value> : never : Builder extends {
605
623
  '~options': {
624
+ ref: true;
606
625
  kind: 'm:1';
607
626
  };
608
627
  } ? Value extends object ? Reference<Value> : never : Builder extends {
@@ -613,12 +632,25 @@ type MaybeRef<Value, Builder> = Builder extends {
613
632
  '~options': {
614
633
  kind: 'm:n';
615
634
  };
616
- } ? Value extends object ? Collection<Value> : never : Builder extends {
635
+ } ? Value extends object ? Collection<Value> : never : Value;
636
+ type MaybeScalarRef<Value, Builder> = Builder extends {
637
+ '~options': {
638
+ ref: false;
639
+ };
640
+ } ? Value : Builder extends {
641
+ '~options': {
642
+ kind: '1:1' | 'm:1' | '1:m' | 'm:n';
643
+ };
644
+ } ? Value : Builder extends {
617
645
  '~options': {
618
646
  ref: true;
619
647
  };
620
648
  } ? ScalarReference<Value> : Value;
621
649
  type MaybeOpt<Value, Builder> = Builder extends {
650
+ '~options': {
651
+ mapToPk: true;
652
+ };
653
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Builder extends {
622
654
  '~options': {
623
655
  autoincrement: true;
624
656
  };
@@ -645,7 +645,6 @@ const propertyBuilders = {
645
645
  manyToOne: (target) => new ManyToOneOptionsBuilder({
646
646
  entity: () => target,
647
647
  kind: 'm:1',
648
- ref: true,
649
648
  }),
650
649
  oneToMany: (target) => new OneToManyOptionsBuilderOnlyMappedBy({
651
650
  entity: () => target,
@@ -654,7 +653,6 @@ const propertyBuilders = {
654
653
  oneToOne: (target) => new OneToOneOptionsBuilder({
655
654
  entity: () => target,
656
655
  kind: '1:1',
657
- ref: true,
658
656
  }),
659
657
  };
660
658
  function getBuilderOptions(builder) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.5.8-dev.14",
3
+ "version": "6.5.8-dev.15",
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.3.2",
66
66
  "globby": "11.1.0",
67
- "mikro-orm": "6.5.8-dev.14",
67
+ "mikro-orm": "6.5.8-dev.15",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }