@mikro-orm/core 6.5.8-dev.13 → 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 } 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. */
@@ -506,6 +514,11 @@ export declare function defineEntity<Properties extends Record<string, any>, con
506
514
  properties: Properties | ((properties: typeof propertyBuilders) => Properties);
507
515
  primaryKeys?: PK & InferPrimaryKey<Properties>[];
508
516
  }): EntitySchema<InferEntityFromProperties<Properties, PK>, never>;
517
+ export declare function defineEntity<Entity = any, Base = never>(meta: Omit<Partial<EntityMetadata<Entity>>, 'properties'> & {
518
+ class: EntityClass<Entity>;
519
+ extends?: string | EntitySchema<Base>;
520
+ properties: Record<string, any> | ((properties: typeof propertyBuilders) => Record<string, any>);
521
+ }): EntitySchema<Entity, Base>;
509
522
  export declare namespace defineEntity {
510
523
  var properties: {
511
524
  bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
@@ -577,27 +590,38 @@ type InferBuilderValue<Builder> = Builder extends {
577
590
  '~type'?: {
578
591
  value: infer Value;
579
592
  };
580
- } ? 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;
581
594
  type MaybeArray<Value, Builder> = Builder extends {
582
595
  '~options': {
583
596
  array: true;
584
597
  };
585
598
  } ? Value[] : Value;
599
+ type MaybeMapToPk<Value, Builder> = Builder extends {
600
+ '~options': {
601
+ mapToPk: true;
602
+ };
603
+ } ? Primary<Value> : Value;
586
604
  type MaybeNullable<Value, Builder> = Builder extends {
587
605
  '~options': {
588
606
  nullable: true;
589
607
  };
590
608
  } ? Value | null | undefined : Value;
591
- type MaybeRef<Value, Builder> = Builder extends {
609
+ type MaybeRelationRef<Value, Builder> = Builder extends {
610
+ '~options': {
611
+ mapToPk: true;
612
+ };
613
+ } ? Value : Builder extends {
592
614
  '~options': {
593
615
  ref: false;
594
616
  };
595
617
  } ? Value : Builder extends {
596
618
  '~options': {
619
+ ref: true;
597
620
  kind: '1:1';
598
621
  };
599
622
  } ? Value extends object ? Reference<Value> : never : Builder extends {
600
623
  '~options': {
624
+ ref: true;
601
625
  kind: 'm:1';
602
626
  };
603
627
  } ? Value extends object ? Reference<Value> : never : Builder extends {
@@ -608,12 +632,25 @@ type MaybeRef<Value, Builder> = Builder extends {
608
632
  '~options': {
609
633
  kind: 'm:n';
610
634
  };
611
- } ? 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 {
612
645
  '~options': {
613
646
  ref: true;
614
647
  };
615
648
  } ? ScalarReference<Value> : Value;
616
649
  type MaybeOpt<Value, Builder> = Builder extends {
650
+ '~options': {
651
+ mapToPk: true;
652
+ };
653
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Builder extends {
617
654
  '~options': {
618
655
  autoincrement: true;
619
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.13",
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.13",
67
+ "mikro-orm": "6.5.8-dev.15",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }