@mikro-orm/core 7.0.0-dev.323 → 7.0.0-dev.325

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/MikroORM.d.ts CHANGED
@@ -5,7 +5,7 @@ import { Configuration, type Options } from './utils/Configuration.js';
5
5
  import type { EntityManager } from './EntityManager.js';
6
6
  import type { AnyEntity, Constructor, EntityClass, EntityMetadata, EntityName, IEntityGenerator, IMigrator, ISeedManager } from './typings.js';
7
7
  /** @internal */
8
- export declare function loadOptionalDependencies(options: Options): Promise<void>;
8
+ export declare function loadOptionalDependencies(options: Partial<Options>): Promise<void>;
9
9
  /**
10
10
  * The main class used to configure and bootstrap the ORM.
11
11
  *
@@ -46,14 +46,14 @@ export declare class MikroORM<Driver extends IDatabaseDriver = IDatabaseDriver,
46
46
  * Initialize the ORM, load entity metadata, create EntityManager and connect to the database.
47
47
  * If you omit the `options` parameter, your CLI config will be used.
48
48
  */
49
- static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Promise<MikroORM<D, EM, Entities>>;
49
+ static init<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
50
50
  /**
51
51
  * Synchronous variant of the `init` method with some limitations:
52
52
  * - folder-based discovery not supported
53
53
  * - ORM extensions are not autoloaded
54
54
  * - when metadata cache is enabled, `FileCacheAdapter` needs to be explicitly set in the config
55
55
  */
56
- constructor(options: Options<Driver, EM, Entities>);
56
+ constructor(options: Partial<Options<Driver, EM, Entities>>);
57
57
  /**
58
58
  * Connects to the database.
59
59
  */
@@ -8,6 +8,8 @@ import type { EntityIdentifier } from './EntityIdentifier.js';
8
8
  import type { SerializationContext } from '../serialization/SerializationContext.js';
9
9
  import { type SerializeOptions } from '../serialization/EntitySerializer.js';
10
10
  import type { FindOneOptions, LoadHint } from '../drivers/IDatabaseDriver.js';
11
+ import type { Platform } from '../platforms/Platform.js';
12
+ import type { Configuration } from '../utils/Configuration.js';
11
13
  export declare class WrappedEntity<Entity extends object> {
12
14
  __initialized: boolean;
13
15
  __populated?: boolean;
@@ -58,7 +60,7 @@ export declare class WrappedEntity<Entity extends object> {
58
60
  setPrimaryKey(id: Primary<Entity> | null): void;
59
61
  getSerializedPrimaryKey(): string;
60
62
  get __meta(): EntityMetadata<Entity>;
61
- get __platform(): import("../index.js").Platform;
62
- get __config(): import("../index.js").Configuration<import("../drivers/IDatabaseDriver.js").IDatabaseDriver<import("../index.js").Connection>, EntityManager<import("../drivers/IDatabaseDriver.js").IDatabaseDriver<import("../index.js").Connection>>>;
63
+ get __platform(): Platform;
64
+ get __config(): Configuration;
63
65
  get __primaryKeys(): Primary<Entity>[];
64
66
  }
@@ -508,48 +508,35 @@ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> e
508
508
  type EntityTarget = {
509
509
  '~entity': any;
510
510
  } | EntityClass;
511
- declare const propertyBuilders: {
512
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
513
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
514
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
511
+ declare const propertyBuilders: PropertyBuilders;
512
+ type PropertyBuildersOverrideKeys = 'bigint' | 'array' | 'decimal' | 'json' | 'datetime' | 'time' | 'enum';
513
+ export type PropertyBuilders = {
514
+ [K in Exclude<keyof typeof types, PropertyBuildersOverrideKeys>]: () => UniversalPropertyOptionsBuilder<InferPropertyValueType<(typeof types)[K]>, EmptyOptions, IncludeKeysForProperty>;
515
+ } & {
516
+ bigint: <Mode extends 'bigint' | 'number' | 'string' = 'bigint'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.bigint<Mode>>, EmptyOptions, IncludeKeysForProperty>;
517
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.array<T>>, EmptyOptions, IncludeKeysForProperty>;
518
+ decimal: <Mode extends 'number' | 'string' = 'string'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.decimal<Mode>>, EmptyOptions, IncludeKeysForProperty>;
515
519
  json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
516
520
  formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
517
- datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
518
- time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
521
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.datetime>, EmptyOptions, IncludeKeysForProperty>;
522
+ time: (length?: number) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.time>, EmptyOptions, IncludeKeysForProperty>;
519
523
  type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
520
524
  enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
521
525
  embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
522
- kind: "embedded";
526
+ kind: 'embedded';
523
527
  }>;
524
528
  manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
525
- kind: "m:n";
529
+ kind: 'm:n';
526
530
  }>;
527
531
  manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
528
- kind: "m:1";
532
+ kind: 'm:1';
529
533
  }>;
530
534
  oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
531
- kind: "1:m";
535
+ kind: '1:m';
532
536
  }>;
533
537
  oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
534
- kind: "1:1";
538
+ kind: '1:1';
535
539
  }>;
536
- date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
537
- blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
538
- uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
539
- enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
540
- integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
541
- smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
542
- tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
543
- mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
544
- float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
545
- double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
546
- boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
547
- character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
548
- string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
549
- uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
550
- text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
551
- interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
552
- unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
553
540
  };
554
541
  /** Own keys + base entity keys (when TBase is not `never`). Guards against `keyof never = string | number | symbol`. */
555
542
  type AllKeys<TProperties, TBase> = keyof TProperties | (IsNever<TBase> extends true ? never : keyof TBase);
@@ -559,7 +546,7 @@ export interface EntityMetadataWithProperties<TName extends string, TTableName e
559
546
  extends?: {
560
547
  '~entity': TBase;
561
548
  } | EntityCtor<TBase>;
562
- properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
549
+ properties: TProperties | ((properties: PropertyBuilders) => TProperties);
563
550
  primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
564
551
  hooks?: DefineEntityHooks;
565
552
  repository?: () => TRepository;
@@ -595,53 +582,11 @@ export declare function defineEntity<const TEntity = any, const TProperties exte
595
582
  className?: TClassName;
596
583
  tableName?: TTableName;
597
584
  extends?: TBase;
598
- properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
585
+ properties: TProperties | ((properties: PropertyBuilders) => TProperties);
599
586
  hooks?: DefineEntityHooks<TEntity>;
600
587
  }): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
601
588
  export declare namespace defineEntity {
602
- var properties: {
603
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
604
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
605
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
606
- json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
607
- formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
608
- datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
609
- time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
610
- type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
611
- enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
612
- embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
613
- kind: "embedded";
614
- }>;
615
- manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
616
- kind: "m:n";
617
- }>;
618
- manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
619
- kind: "m:1";
620
- }>;
621
- oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
622
- kind: "1:m";
623
- }>;
624
- oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
625
- kind: "1:1";
626
- }>;
627
- date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
628
- blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
629
- uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
630
- enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
631
- integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
632
- smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
633
- tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
634
- mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
635
- float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
636
- double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
637
- boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
638
- character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
639
- string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
640
- uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
641
- text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
642
- interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
643
- unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
644
- };
589
+ var properties: PropertyBuilders;
645
590
  }
646
591
  export { propertyBuilders as p };
647
592
  type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
package/errors.d.ts CHANGED
@@ -56,17 +56,17 @@ export declare class MetadataError<T extends AnyEntity = AnyEntity> extends Vali
56
56
  static duplicateFieldName(entityName: EntityName, names: [string, string][]): MetadataError;
57
57
  static multipleDecorators(entityName: string, propertyName: string): MetadataError;
58
58
  static missingMetadata(entity: string): MetadataError;
59
- static invalidPrimaryKey(meta: EntityMetadata, prop: EntityProperty, requiredName: string): MetadataError<Partial<any>>;
60
- static invalidManyToManyWithPivotEntity(meta1: EntityMetadata, prop1: EntityProperty, meta2: EntityMetadata, prop2: EntityProperty): MetadataError<Partial<any>>;
61
- static targetIsAbstract(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
62
- static nonPersistentCompositeProp(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
63
- static propertyTargetsEntityType(meta: EntityMetadata, prop: EntityProperty, target: EntityMetadata): MetadataError<Partial<any>>;
64
- static fromMissingOption(meta: EntityMetadata, prop: EntityProperty, option: string): MetadataError<Partial<any>>;
65
- static targetKeyOnManyToMany(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
66
- static targetKeyNotUnique(meta: EntityMetadata, prop: EntityProperty, target?: EntityMetadata): MetadataError<Partial<any>>;
67
- static targetKeyNotFound(meta: EntityMetadata, prop: EntityProperty, target?: EntityMetadata): MetadataError<Partial<any>>;
68
- static incompatiblePolymorphicTargets(meta: EntityMetadata, prop: EntityProperty, target1: EntityMetadata, target2: EntityMetadata, reason: string): MetadataError<Partial<any>>;
69
- static dangerousPropertyName(meta: EntityMetadata, prop: EntityProperty): MetadataError<Partial<any>>;
59
+ static invalidPrimaryKey(meta: EntityMetadata, prop: EntityProperty, requiredName: string): MetadataError;
60
+ static invalidManyToManyWithPivotEntity(meta1: EntityMetadata, prop1: EntityProperty, meta2: EntityMetadata, prop2: EntityProperty): MetadataError;
61
+ static targetIsAbstract(meta: EntityMetadata, prop: EntityProperty): MetadataError;
62
+ static nonPersistentCompositeProp(meta: EntityMetadata, prop: EntityProperty): MetadataError;
63
+ static propertyTargetsEntityType(meta: EntityMetadata, prop: EntityProperty, target: EntityMetadata): MetadataError;
64
+ static fromMissingOption(meta: EntityMetadata, prop: EntityProperty, option: string): MetadataError;
65
+ static targetKeyOnManyToMany(meta: EntityMetadata, prop: EntityProperty): MetadataError;
66
+ static targetKeyNotUnique(meta: EntityMetadata, prop: EntityProperty, target?: EntityMetadata): MetadataError;
67
+ static targetKeyNotFound(meta: EntityMetadata, prop: EntityProperty, target?: EntityMetadata): MetadataError;
68
+ static incompatiblePolymorphicTargets(meta: EntityMetadata, prop: EntityProperty, target1: EntityMetadata, target2: EntityMetadata, reason: string): MetadataError;
69
+ static dangerousPropertyName(meta: EntityMetadata, prop: EntityProperty): MetadataError;
70
70
  static viewEntityWithoutExpression(meta: EntityMetadata): MetadataError;
71
71
  static mixedInheritanceStrategies(root: EntityMetadata, child: EntityMetadata): MetadataError;
72
72
  static tptNotSupportedByDriver(meta: EntityMetadata): MetadataError;
package/logging/colors.js CHANGED
@@ -2,7 +2,7 @@ import { getEnv } from '../utils/env-vars.js';
2
2
  const bool = (k) => ['true', 't', '1'].includes(getEnv(k)?.toLowerCase() ?? '');
3
3
  const boolIfDefined = (k) => (getEnv(k) != null ? bool(k) : true);
4
4
  const enabled = () => !bool('NO_COLOR') && !bool('MIKRO_ORM_NO_COLOR') && boolIfDefined('FORCE_COLOR') && boolIfDefined('MIKRO_ORM_COLORS');
5
- const wrap = (fn) => (text) => (enabled() ? fn(text) : text);
5
+ const wrap = (fn) => (text) => enabled() ? fn(text) : text;
6
6
  /** @internal */
7
7
  export const colors = {
8
8
  red: wrap((text) => `\x1B[31m${text}\x1B[39m`),
@@ -47,7 +47,7 @@ export declare class EntitySchema<Entity = any, Base = never, Class extends Enti
47
47
  * When schema links the entity class via `class` option, this registry allows the lookup from opposite side,
48
48
  * so we can use the class in `entities` option just like the EntitySchema instance.
49
49
  */
50
- static REGISTRY: Map<Partial<any>, EntitySchema<any, never, EntityCtor<any>>>;
50
+ static REGISTRY: Map<AnyEntity, EntitySchema>;
51
51
  /** @internal Type-level marker for fast entity type inference */
52
52
  readonly '~entity': Entity;
53
53
  private readonly _meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.0-dev.323",
3
+ "version": "7.0.0-dev.325",
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",
@@ -7,7 +7,7 @@ import type { AnyEntity, EntityMetadata, EntityName, PopulateOptions } from '../
7
7
  export declare class SerializationContext<T extends object> {
8
8
  #private;
9
9
  readonly path: [EntityName, string][];
10
- readonly visited: Set<Partial<any>>;
10
+ readonly visited: Set<AnyEntity>;
11
11
  constructor(populate?: PopulateOptions<T>[], fields?: Set<string>, exclude?: readonly string[]);
12
12
  /**
13
13
  * Returns true when there is a cycle detected.
@@ -2,8 +2,6 @@ import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
2
2
  import { type CacheAdapter, type SyncCacheAdapter } from '../cache/CacheAdapter.js';
3
3
  import type { EntityRepository } from '../entity/EntityRepository.js';
4
4
  import type { AnyEntity, CompiledFunctions, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject, Seeder, SeederObject } from '../typings.js';
5
- import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
6
- import { NullHighlighter } from '../utils/NullHighlighter.js';
7
5
  import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
8
6
  import type { EntityManager } from '../EntityManager.js';
9
7
  import type { Platform } from '../platforms/Platform.js';
@@ -13,143 +11,27 @@ import type { MetadataStorage } from '../metadata/MetadataStorage.js';
13
11
  import type { EventSubscriber } from '../events/EventSubscriber.js';
14
12
  import type { AssignOptions } from '../entity/EntityAssigner.js';
15
13
  import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
16
- import { NotFoundError } from '../errors.js';
17
14
  import { DataloaderType, FlushMode, LoadStrategy, PopulateHint, type EmbeddedPrefixMode } from '../enums.js';
18
- import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
19
15
  import { EntityComparator } from './EntityComparator.js';
20
16
  import type { Type } from '../types/Type.js';
21
17
  import type { MikroORM } from '../MikroORM.js';
22
- declare const DEFAULTS: {
23
- readonly pool: {};
24
- readonly entities: readonly [];
25
- readonly entitiesTs: readonly [];
26
- readonly extensions: readonly [];
27
- readonly subscribers: readonly [];
28
- readonly filters: {};
29
- readonly discovery: {
30
- readonly warnWhenNoEntities: true;
31
- readonly checkDuplicateTableNames: true;
32
- readonly checkDuplicateFieldNames: true;
33
- readonly checkDuplicateEntities: true;
34
- readonly checkNonPersistentCompositeProps: true;
35
- readonly inferDefaultValues: true;
36
- };
37
- readonly validateRequired: true;
38
- readonly context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
39
- readonly contextName: "default";
40
- readonly allowGlobalContext: false;
41
- readonly logger: (message?: any, ...optionalParams: any[]) => void;
42
- readonly colors: true;
43
- readonly findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
44
- readonly findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
45
- readonly baseDir: string;
46
- readonly hydrator: typeof ObjectHydrator;
47
- readonly flushMode: FlushMode.AUTO;
48
- readonly loadStrategy: LoadStrategy.BALANCED;
49
- readonly dataloader: DataloaderType.NONE;
50
- readonly populateWhere: PopulateHint.ALL;
51
- readonly ignoreUndefinedInQuery: false;
52
- readonly onQuery: (sql: string) => string;
53
- readonly autoJoinOneToOneOwner: true;
54
- readonly autoJoinRefsForFilters: true;
55
- readonly filtersOnRelations: true;
56
- readonly propagationOnPrototype: true;
57
- readonly populateAfterFlush: true;
58
- readonly serialization: {
59
- readonly includePrimaryKeys: true;
60
- };
61
- readonly assign: {
62
- readonly updateNestedEntities: true;
63
- readonly updateByPrimaryKey: true;
64
- readonly mergeObjectProperties: false;
65
- readonly mergeEmbeddedProperties: true;
66
- readonly ignoreUndefined: false;
67
- };
68
- readonly persistOnCreate: true;
69
- readonly upsertManaged: true;
70
- readonly forceEntityConstructor: false;
71
- readonly forceUndefined: false;
72
- readonly forceUtcTimezone: true;
73
- readonly processOnCreateHooksEarly: true;
74
- readonly ensureDatabase: true;
75
- readonly ensureIndexes: false;
76
- readonly batchSize: 300;
77
- readonly debug: false;
78
- readonly ignoreDeprecations: false;
79
- readonly verbose: false;
80
- readonly driverOptions: {};
81
- readonly migrations: {
82
- readonly tableName: "mikro_orm_migrations";
83
- readonly glob: "!(*.d).{js,ts,cjs}";
84
- readonly silent: false;
85
- readonly transactional: true;
86
- readonly allOrNothing: true;
87
- readonly dropTables: true;
88
- readonly safe: false;
89
- readonly snapshot: true;
90
- readonly emit: "ts";
91
- readonly fileName: (timestamp: string, name?: string) => string;
92
- };
93
- readonly schemaGenerator: {
94
- readonly createForeignKeyConstraints: true;
95
- readonly ignoreSchema: readonly [];
96
- readonly skipTables: readonly [];
97
- readonly skipViews: readonly [];
98
- readonly skipColumns: {};
99
- };
100
- readonly embeddables: {
101
- readonly prefixMode: "relative";
102
- };
103
- readonly entityGenerator: {
104
- readonly forceUndefined: true;
105
- readonly undefinedDefaults: false;
106
- readonly scalarTypeInDecorator: false;
107
- readonly bidirectionalRelations: true;
108
- readonly identifiedReferences: true;
109
- readonly scalarPropertiesForRelations: "never";
110
- readonly entityDefinition: "defineEntity";
111
- readonly decorators: "legacy";
112
- readonly enumMode: "dictionary";
113
- readonly fileName: (className: string) => string;
114
- readonly onlyPurePivotTables: false;
115
- readonly outputPurePivotTables: false;
116
- readonly readOnlyPivotTables: false;
117
- readonly useCoreBaseEntity: false;
118
- };
119
- readonly metadataCache: {};
120
- readonly resultCache: {
121
- readonly adapter: typeof MemoryCacheAdapter;
122
- readonly expiration: 1000;
123
- readonly options: {};
124
- };
125
- readonly metadataProvider: typeof MetadataProvider;
126
- readonly highlighter: NullHighlighter;
127
- readonly seeder: {
128
- readonly defaultSeeder: "DatabaseSeeder";
129
- readonly glob: "!(*.d).{js,ts}";
130
- readonly emit: "ts";
131
- readonly fileName: (className: string) => string;
132
- };
133
- readonly preferReadReplicas: true;
134
- readonly dynamicImportProvider: (id: string) => Promise<any>;
135
- };
136
18
  export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
137
19
  #private;
138
- constructor(options: Options, validate?: boolean);
20
+ constructor(options: Partial<Options>, validate?: boolean);
139
21
  getPlatform(): ReturnType<D['getPlatform']>;
140
22
  /**
141
23
  * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
142
24
  */
143
- get<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
144
- getAll(): RequiredOptions<D, EM>;
25
+ get<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, defaultValue?: U): U;
26
+ getAll(): Options<D, EM>;
145
27
  /**
146
28
  * Overrides specified configuration value.
147
29
  */
148
- set<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, value: U): void;
30
+ set<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, value: U): void;
149
31
  /**
150
32
  * Resets the configuration to its default value
151
33
  */
152
- reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
34
+ reset<T extends keyof Options<D, EM>>(key: T): void;
153
35
  /**
154
36
  * Gets Logger instance.
155
37
  */
@@ -204,7 +86,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
204
86
  /**
205
87
  * Type helper to make it easier to use `mikro-orm.config.js`.
206
88
  */
207
- export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Options<D, EM, Entities>;
89
+ export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Partial<Options<D, EM, Entities>>;
208
90
  /**
209
91
  * Connection configuration options for database connections.
210
92
  * @see https://mikro-orm.io/docs/configuration#connection
@@ -458,6 +340,13 @@ export interface MetadataDiscoveryOptions {
458
340
  * @see https://mikro-orm.io/docs/configuration
459
341
  */
460
342
  export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> & Driver[typeof EntityManagerType], Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends ConnectionOptions {
343
+ /** Connection pool configuration. */
344
+ pool: PoolConfig;
345
+ /**
346
+ * Additional driver-specific options.
347
+ * The object will be deeply merged with internal driver options.
348
+ */
349
+ driverOptions: Dictionary;
461
350
  /**
462
351
  * Array of entity classes or paths to entity modules.
463
352
  * Paths support glob patterns for automatic discovery.
@@ -465,7 +354,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
465
354
  * entities: [Author, Book, Publisher] // class references
466
355
  * entities: ['./dist/entities'] // folder paths
467
356
  */
468
- entities?: Entities;
357
+ entities: Entities;
469
358
  /**
470
359
  * Array of TypeScript entity source paths.
471
360
  * Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
@@ -473,34 +362,34 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
473
362
  * @example
474
363
  * entitiesTs: ['./src/entities']
475
364
  */
476
- entitiesTs?: Entities;
365
+ entitiesTs: Entities;
477
366
  /**
478
367
  * ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
479
368
  * Extensions registered here are available via shortcuts like `orm.migrator`.
480
369
  * @example
481
370
  * extensions: [Migrator, EntityGenerator, SeedManager]
482
371
  */
483
- extensions?: {
372
+ extensions: {
484
373
  register: (orm: MikroORM) => void;
485
374
  }[];
486
375
  /**
487
376
  * Event subscribers to register.
488
377
  * Can be class references or instances.
489
378
  */
490
- subscribers?: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
379
+ subscribers: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
491
380
  /**
492
381
  * Global entity filters to apply.
493
382
  * Filters are applied by default unless explicitly disabled.
494
383
  * @see https://mikro-orm.io/docs/filters
495
384
  */
496
- filters?: Dictionary<{
385
+ filters: Dictionary<{
497
386
  name?: string;
498
387
  } & Omit<FilterDef, 'name'>>;
499
388
  /**
500
389
  * Metadata discovery configuration options.
501
390
  * Controls how entities are discovered and validated.
502
391
  */
503
- discovery?: MetadataDiscoveryOptions;
392
+ discovery: MetadataDiscoveryOptions;
504
393
  /**
505
394
  * Database driver class to use.
506
395
  * Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
@@ -540,7 +429,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
540
429
  * Enable verbose logging of internal operations.
541
430
  * @default false
542
431
  */
543
- verbose?: boolean;
432
+ verbose: boolean;
544
433
  /**
545
434
  * Ignore `undefined` values in find queries instead of treating them as `null`.
546
435
  * @default false
@@ -548,7 +437,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
548
437
  * // With ignoreUndefinedInQuery: true
549
438
  * em.find(User, { email: undefined }) // resolves to em.find(User, {})
550
439
  */
551
- ignoreUndefinedInQuery?: boolean;
440
+ ignoreUndefinedInQuery: boolean;
552
441
  /**
553
442
  * Hook to modify SQL queries before execution.
554
443
  * Useful for adding observability hints or query modifications.
@@ -556,38 +445,38 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
556
445
  * @param params - Query parameters
557
446
  * @returns Modified SQL query
558
447
  */
559
- onQuery?: (sql: string, params: readonly unknown[]) => string;
448
+ onQuery: (sql: string, params: readonly unknown[]) => string;
560
449
  /**
561
450
  * Automatically join the owning side of 1:1 relations when querying the inverse side.
562
451
  * @default true
563
452
  */
564
- autoJoinOneToOneOwner?: boolean;
453
+ autoJoinOneToOneOwner: boolean;
565
454
  /**
566
455
  * Automatically join M:1 and 1:1 relations when filters are defined on them.
567
456
  * Important for implementing soft deletes via filters.
568
457
  * @default true
569
458
  */
570
- autoJoinRefsForFilters?: boolean;
459
+ autoJoinRefsForFilters: boolean;
571
460
  /**
572
461
  * Apply filters to relations in queries.
573
462
  * @default true
574
463
  */
575
- filtersOnRelations?: boolean;
464
+ filtersOnRelations: boolean;
576
465
  /**
577
466
  * Enable propagation of changes on entity prototypes.
578
467
  * @default true
579
468
  */
580
- propagationOnPrototype?: boolean;
469
+ propagationOnPrototype: boolean;
581
470
  /**
582
471
  * Mark all relations as populated after flush for new entities.
583
472
  * This aligns serialized output of loaded entities and just-inserted ones.
584
473
  * @default true
585
474
  */
586
- populateAfterFlush?: boolean;
475
+ populateAfterFlush: boolean;
587
476
  /**
588
477
  * Serialization options for `toJSON()` and `serialize()` methods.
589
478
  */
590
- serialization?: {
479
+ serialization: {
591
480
  /**
592
481
  * Include primary keys in serialized output.
593
482
  * @default true
@@ -604,42 +493,42 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
604
493
  * Default options for entity assignment via `em.assign()`.
605
494
  * @see https://mikro-orm.io/docs/entity-helper
606
495
  */
607
- assign?: AssignOptions<boolean>;
496
+ assign: AssignOptions<boolean>;
608
497
  /**
609
498
  * Automatically call `em.persist()` on entities created via `em.create()`.
610
499
  * @default true
611
500
  */
612
- persistOnCreate?: boolean;
501
+ persistOnCreate: boolean;
613
502
  /**
614
503
  * When upsert creates a new entity, mark it as managed in the identity map.
615
504
  * @default true
616
505
  */
617
- upsertManaged?: boolean;
506
+ upsertManaged: boolean;
618
507
  /**
619
508
  * Force use of entity constructors when creating entity instances.
620
509
  * Required when using native private properties inside entities.
621
510
  * Can be `true` for all entities or an array of specific entity classes/names.
622
511
  * @default false
623
512
  */
624
- forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
513
+ forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
625
514
  /**
626
515
  * Convert `null` values from database to `undefined` when hydrating entities.
627
516
  * @default false
628
517
  */
629
- forceUndefined?: boolean;
518
+ forceUndefined: boolean;
630
519
  /**
631
520
  * Property `onCreate` hooks are normally executed during `flush` operation.
632
521
  * With this option, they will be processed early inside `em.create()` method.
633
522
  * @default true
634
523
  */
635
- processOnCreateHooksEarly?: boolean;
524
+ processOnCreateHooksEarly: boolean;
636
525
  /**
637
526
  * Force `Date` values to be stored in UTC for datetime columns without timezone.
638
527
  * Works for MySQL (`datetime` type), PostgreSQL (`timestamp` type), and MSSQL (`datetime`/`datetime2` types).
639
528
  * SQLite does this by default.
640
529
  * @default true
641
530
  */
642
- forceUtcTimezone?: boolean;
531
+ forceUtcTimezone: boolean;
643
532
  /**
644
533
  * Timezone to use for date operations.
645
534
  * @example '+02:00'
@@ -650,13 +539,13 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
650
539
  * When `true`, will create the database if it doesn't exist.
651
540
  * @default true
652
541
  */
653
- ensureDatabase?: boolean | EnsureDatabaseOptions;
542
+ ensureDatabase: boolean | EnsureDatabaseOptions;
654
543
  /**
655
544
  * Ensure database indexes exist on startup. This option works only with the MongoDB driver.
656
545
  * When enabled, indexes will be created based on entity metadata.
657
546
  * @default false
658
547
  */
659
- ensureIndexes?: boolean;
548
+ ensureIndexes: boolean;
660
549
  /**
661
550
  * Use batch insert queries for better performance.
662
551
  * @default true
@@ -671,12 +560,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
671
560
  * Number of entities to process in each batch for batch inserts/updates.
672
561
  * @default 300
673
562
  */
674
- batchSize?: number;
563
+ batchSize: number;
675
564
  /**
676
565
  * Custom hydrator class for assigning database values to entities.
677
566
  * @default ObjectHydrator
678
567
  */
679
- hydrator?: HydratorConstructor;
568
+ hydrator: HydratorConstructor;
680
569
  /**
681
570
  * Pre-generated compiled functions for hydration and comparison.
682
571
  * Use the `compile` CLI command to create these functions.
@@ -690,7 +579,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
690
579
  * - `'balanced'`: Decides based on relation type and context.
691
580
  * @default 'balanced'
692
581
  */
693
- loadStrategy?: LoadStrategy | `${LoadStrategy}`;
582
+ loadStrategy: LoadStrategy | `${LoadStrategy}`;
694
583
  /**
695
584
  * Enable dataloader for batching reference loading.
696
585
  * - `true` or `DataloaderType.ALL`: Enable for all relation types
@@ -699,14 +588,14 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
699
588
  * - `DataloaderType.COLLECTION`: Enable only for collections
700
589
  * @default DataloaderType.NONE
701
590
  */
702
- dataloader?: DataloaderType | boolean;
591
+ dataloader: DataloaderType | boolean;
703
592
  /**
704
593
  * Determines how where conditions are applied during population.
705
594
  * - `'all'`: Populate all matching relations (default in v5+)
706
595
  * - `'infer'`: Infer conditions from the original query (v4 behavior)
707
596
  * @default 'all'
708
597
  */
709
- populateWhere?: PopulateHint | `${PopulateHint}`;
598
+ populateWhere: PopulateHint | `${PopulateHint}`;
710
599
  /**
711
600
  * Default flush mode for the entity manager.
712
601
  * - `'commit'`: Flush only on explicit commit
@@ -714,7 +603,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
714
603
  * - `'always'`: Always flush before queries
715
604
  * @default 'auto'
716
605
  */
717
- flushMode?: FlushMode | `${FlushMode}`;
606
+ flushMode: FlushMode | `${FlushMode}`;
718
607
  /**
719
608
  * Custom base repository class for all entities.
720
609
  * Entity-specific repositories can still be defined and will take precedence.
@@ -735,25 +624,25 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
735
624
  * Validate that required properties are set on new entities before insert.
736
625
  * @default true
737
626
  */
738
- validateRequired?: boolean;
627
+ validateRequired: boolean;
739
628
  /**
740
629
  * Callback to get the current request context's EntityManager.
741
630
  * Used for automatic context propagation in web frameworks.
742
631
  * @default RequestContext.getEntityManager
743
632
  */
744
- context?: (name: string) => EntityManager | undefined;
633
+ context: (name: string) => EntityManager | undefined;
745
634
  /**
746
635
  * Name of the context for multi-ORM setups.
747
636
  * @default 'default'
748
637
  */
749
- contextName?: string;
638
+ contextName: string;
750
639
  /**
751
640
  * Allow using the global EntityManager without a request context.
752
641
  * Not recommended for production - each request should have its own context.
753
642
  * Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
754
643
  * @default false
755
644
  */
756
- allowGlobalContext?: boolean;
645
+ allowGlobalContext: boolean;
757
646
  /**
758
647
  * When enabled, environment variables take precedence over explicitly provided config options.
759
648
  * By default, explicit options win over env vars.
@@ -771,12 +660,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
771
660
  * Custom logger function for ORM output.
772
661
  * @default console.log
773
662
  */
774
- logger?: (message: string) => void;
663
+ logger: (message: string) => void;
775
664
  /**
776
665
  * Enable colored output in logs.
777
666
  * @default true
778
667
  */
779
- colors?: boolean;
668
+ colors: boolean;
780
669
  /**
781
670
  * Factory function to create a custom logger instance.
782
671
  * @default DefaultLogger.create
@@ -788,7 +677,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
788
677
  * @param where - Query conditions
789
678
  * @returns Error instance to throw
790
679
  */
791
- findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
680
+ findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
792
681
  /**
793
682
  * Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
794
683
  * Used when strict mode is enabled.
@@ -796,7 +685,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
796
685
  * @param where - Query conditions
797
686
  * @returns Error instance to throw
798
687
  */
799
- findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
688
+ findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
800
689
  /**
801
690
  * Enable debug logging.
802
691
  * Can be `true` for all namespaces or an array of specific namespaces.
@@ -804,19 +693,19 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
804
693
  * @default false
805
694
  * @see https://mikro-orm.io/docs/logging
806
695
  */
807
- debug?: boolean | LoggerNamespace[];
696
+ debug: boolean | LoggerNamespace[];
808
697
  /**
809
698
  * Ignore deprecation warnings.
810
699
  * Can be `true` to ignore all or an array of specific deprecation labels.
811
700
  * @default false
812
701
  * @see https://mikro-orm.io/docs/logging#deprecation-warnings
813
702
  */
814
- ignoreDeprecations?: boolean | string[];
703
+ ignoreDeprecations: boolean | string[];
815
704
  /**
816
705
  * Syntax highlighter for SQL queries in logs.
817
706
  * @default NullHighlighter
818
707
  */
819
- highlighter?: Highlighter;
708
+ highlighter: Highlighter;
820
709
  /**
821
710
  * Force the ORM to use TypeScript options regardless of detection.
822
711
  * Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
@@ -828,16 +717,16 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
828
717
  * Base directory for resolving relative paths.
829
718
  * @default process.cwd()
830
719
  */
831
- baseDir?: string;
720
+ baseDir: string;
832
721
  /**
833
722
  * Migration configuration options.
834
723
  * @see https://mikro-orm.io/docs/migrations
835
724
  */
836
- migrations?: MigrationsOptions;
725
+ migrations: MigrationsOptions;
837
726
  /**
838
727
  * Schema generator configuration options.
839
728
  */
840
- schemaGenerator?: {
729
+ schemaGenerator: {
841
730
  /**
842
731
  * Try to disable foreign key checks during schema operations.
843
732
  * @default false
@@ -891,7 +780,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
891
780
  /**
892
781
  * Embeddable entity configuration options.
893
782
  */
894
- embeddables?: {
783
+ embeddables: {
895
784
  /**
896
785
  * Mode for generating column prefixes for embedded properties.
897
786
  * @default 'relative'
@@ -902,12 +791,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
902
791
  * Entity generator (code generation) configuration options.
903
792
  * @see https://mikro-orm.io/docs/entity-generator
904
793
  */
905
- entityGenerator?: GenerateOptions;
794
+ entityGenerator: GenerateOptions;
906
795
  /**
907
796
  * Metadata cache configuration for improved startup performance.
908
797
  * @see https://mikro-orm.io/docs/metadata-cache
909
798
  */
910
- metadataCache?: {
799
+ metadataCache: {
911
800
  /**
912
801
  * Enable metadata caching.
913
802
  * Defaults based on the metadata provider's `useCache()` method.
@@ -938,7 +827,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
938
827
  /**
939
828
  * Result cache configuration for query result caching.
940
829
  */
941
- resultCache?: {
830
+ resultCache: {
942
831
  /**
943
832
  * Default cache expiration time in milliseconds.
944
833
  * @default 1000
@@ -968,7 +857,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
968
857
  * @default ReflectMetadataProvider
969
858
  * @see https://mikro-orm.io/docs/metadata-providers
970
859
  */
971
- metadataProvider?: {
860
+ metadataProvider: {
972
861
  new (config: Configuration): MetadataProvider;
973
862
  useCache?: MetadataProvider['useCache'];
974
863
  };
@@ -976,22 +865,15 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
976
865
  * Seeder configuration options.
977
866
  * @see https://mikro-orm.io/docs/seeding
978
867
  */
979
- seeder?: SeederOptions;
868
+ seeder: SeederOptions;
980
869
  /**
981
870
  * Prefer read replicas for read operations when available.
982
871
  * @default true
983
872
  */
984
- preferReadReplicas?: boolean;
873
+ preferReadReplicas: boolean;
985
874
  /**
986
875
  * Custom dynamic import provider for loading modules.
987
876
  * @default (id) => import(id)
988
877
  */
989
- dynamicImportProvider?: (id: string) => Promise<unknown>;
878
+ dynamicImportProvider: (id: string) => Promise<unknown>;
990
879
  }
991
- type MarkRequired<T, D> = {
992
- [K in keyof T as Extract<K, keyof D>]-?: T[K];
993
- } & {
994
- [K in keyof T as Exclude<K, keyof D>]?: T[K];
995
- };
996
- export type RequiredOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = MarkRequired<Options<D, EM, Entities>, typeof DEFAULTS>;
997
- export {};
package/utils/Cursor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EntityMetadata, FilterObject, Loaded } from '../typings.js';
1
+ import type { EntityKey, EntityMetadata, FilterObject, Loaded } from '../typings.js';
2
2
  import type { FindByCursorOptions, OrderDefinition } from '../drivers/IDatabaseDriver.js';
3
3
  import { type QueryOrder } from '../enums.js';
4
4
  /**
@@ -69,5 +69,5 @@ export declare class Cursor<Entity extends object, Hint extends string = never,
69
69
  static for<Entity extends object>(meta: EntityMetadata<Entity>, entity: FilterObject<Entity>, orderBy: OrderDefinition<Entity>): string;
70
70
  static encode(value: unknown[]): string;
71
71
  static decode(value: string): unknown[];
72
- static getDefinition<Entity extends object>(meta: EntityMetadata<Entity>, orderBy: OrderDefinition<Entity>): [never, QueryOrder][];
72
+ static getDefinition<Entity extends object>(meta: EntityMetadata<Entity>, orderBy: OrderDefinition<Entity>): [EntityKey, QueryOrder][];
73
73
  }
@@ -1,4 +1,4 @@
1
- import type { EntityData, EntityDictionary, EntityMetadata, EntityName, EntityProperty, IMetadataStorage } from '../typings.js';
1
+ import type { EntityData, EntityDictionary, EntityMetadata, EntityName, EntityProperty, IMetadataStorage, Primary } from '../typings.js';
2
2
  import type { Platform } from '../platforms/Platform.js';
3
3
  import type { Configuration } from './Configuration.js';
4
4
  type Comparator<T> = (a: T, b: T, options?: {
@@ -6,6 +6,8 @@ type Comparator<T> = (a: T, b: T, options?: {
6
6
  }) => EntityData<T>;
7
7
  type ResultMapper<T> = (result: EntityData<T>) => EntityData<T> | null;
8
8
  type SnapshotGenerator<T> = (entity: T) => EntityData<T>;
9
+ type PkGetter<T> = (entity: T) => Primary<T>;
10
+ type PkSerializer<T> = (entity: T) => string;
9
11
  type CompositeKeyPart = string | CompositeKeyPart[];
10
12
  export declare class EntityComparator {
11
13
  #private;
@@ -29,15 +31,15 @@ export declare class EntityComparator {
29
31
  /**
30
32
  * @internal Highly performance-sensitive method.
31
33
  */
32
- getPkGetter<T>(meta: EntityMetadata<T>): any;
34
+ getPkGetter<T>(meta: EntityMetadata<T>): PkGetter<T>;
33
35
  /**
34
36
  * @internal Highly performance-sensitive method.
35
37
  */
36
- getPkGetterConverted<T>(meta: EntityMetadata<T>): any;
38
+ getPkGetterConverted<T>(meta: EntityMetadata<T>): PkGetter<T>;
37
39
  /**
38
40
  * @internal Highly performance-sensitive method.
39
41
  */
40
- getPkSerializer<T>(meta: EntityMetadata<T>): any;
42
+ getPkSerializer<T>(meta: EntityMetadata<T>): PkSerializer<T>;
41
43
  /**
42
44
  * @internal Highly performance-sensitive method.
43
45
  */
@@ -19,7 +19,7 @@ export declare class RawQueryFragment<Alias extends string = string> {
19
19
  static isKnownFragmentSymbol(key: unknown): key is RawQueryFragmentSymbol;
20
20
  static hasObjectFragments(object: unknown): boolean;
21
21
  static isKnownFragment(key: unknown): key is RawQueryFragment | symbol;
22
- static getKnownFragment(key: unknown): RawQueryFragment<any> | undefined;
22
+ static getKnownFragment(key: unknown): RawQueryFragment | undefined;
23
23
  }
24
24
  export { RawQueryFragment as Raw };
25
25
  export declare function isRaw(value: unknown): value is RawQueryFragment;
@@ -102,8 +102,8 @@ export declare function raw<R = RawQueryFragment & symbol, T extends object = an
102
102
  */
103
103
  export declare function sql<R = RawQueryFragment & symbol>(sql: readonly string[], ...values: unknown[]): R;
104
104
  export declare namespace sql {
105
- var ref: <T extends object = any>(...keys: string[]) => RawQueryFragment<string> & symbol;
106
- var now: (length?: number) => RawQueryFragment<string> & symbol;
105
+ var ref: <T extends object = any>(...keys: string[]) => RawQueryFragment & symbol;
106
+ var now: (length?: number) => RawQueryFragment & symbol;
107
107
  var lower: <R = RawQueryFragment<string> & symbol, T extends object = any>(key: string | ((alias: string) => string)) => R;
108
108
  var upper: <R = RawQueryFragment<string> & symbol, T extends object = any>(key: string | ((alias: string) => string)) => R;
109
109
  }
@@ -123,4 +123,4 @@ export declare function createSqlFunction<R = RawQueryFragment & symbol, T exten
123
123
  */
124
124
  export declare function quote(expParts: readonly string[], ...values: (string | {
125
125
  toString(): string;
126
- })[]): RawQueryFragment<string> & symbol;
126
+ })[]): RawQueryFragment & symbol;
package/utils/Utils.js CHANGED
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
123
123
  }
124
124
  export class Utils {
125
125
  static PK_SEPARATOR = '~~~';
126
- static #ORM_VERSION = '7.0.0-dev.323';
126
+ static #ORM_VERSION = '7.0.0-dev.325';
127
127
  /**
128
128
  * Checks if the argument is instance of `Object`. Returns false for arrays.
129
129
  */
@@ -1,5 +1,5 @@
1
1
  import { type Dictionary } from '../typings.js';
2
- export declare const fs: {
2
+ export interface FsUtils {
3
3
  init(): Promise<void>;
4
4
  pathExists(path: string): boolean;
5
5
  ensureDir(path: string): void;
@@ -10,25 +10,11 @@ export declare const fs: {
10
10
  getORMPackages(): Set<string>;
11
11
  getORMPackageVersion(name: string): string | undefined;
12
12
  checkPackageVersion(): void;
13
- /**
14
- * Resolves and normalizes a series of path parts relative to each preceding part.
15
- * If any part is a `file:` URL, it is converted to a local path. If any part is an
16
- * absolute path, it replaces preceding paths (similar to `path.resolve` in NodeJS).
17
- * Trailing directory separators are removed, and all directory separators are converted
18
- * to POSIX-style separators (`/`).
19
- */
20
13
  normalizePath(...parts: string[]): string;
21
- /**
22
- * Determines the relative path between two paths. If either path is a `file:` URL,
23
- * it is converted to a local path.
24
- */
25
14
  relativePath(path: string, relativeTo: string): string;
26
- /**
27
- * Computes the absolute path to for the given path relative to the provided base directory.
28
- * If either `path` or `baseDir` are `file:` URLs, they are converted to local paths.
29
- */
30
15
  absolutePath(path: string, baseDir?: string): string;
31
16
  writeFile(path: string, data: string, options?: Record<string, any>): Promise<void>;
32
17
  dynamicImport<T = any>(id: string): Promise<T>;
33
- };
18
+ }
19
+ export declare const fs: FsUtils;
34
20
  export * from '../cache/FileCacheAdapter.js';