@mikro-orm/core 6.5.6-dev.12 → 6.5.6-dev.3

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.
@@ -264,29 +264,6 @@ export declare class EntityManager<Driver extends IDatabaseDriver = IDatabaseDri
264
264
  upsertMany<Entity extends object, Fields extends string = any>(entityNameOrEntity: EntityName<Entity> | Entity[], data?: (EntityData<Entity> | NoInfer<Entity>)[], options?: UpsertManyOptions<Entity, Fields>): Promise<Entity[]>;
265
265
  /**
266
266
  * Runs your callback wrapped inside a database transaction.
267
- *
268
- * If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
269
- * can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
270
- * should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
271
- * method automatically creates an async context for the transaction.
272
- *
273
- * **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
274
- * `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
275
- * between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
276
- * the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
277
- *
278
- * **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
279
- * parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
280
- * and then call this method on the fork.
281
- *
282
- * **Example:**
283
- * ```ts
284
- * await em.transactional(async (em) => {
285
- * const author = new Author('Jon');
286
- * em.persist(author);
287
- * // flush is called automatically at the end of the callback
288
- * });
289
- * ```
290
267
  */
291
268
  transactional<T>(cb: (em: this) => T | Promise<T>, options?: TransactionOptions): Promise<T>;
292
269
  /**
package/EntityManager.js CHANGED
@@ -971,29 +971,6 @@ class EntityManager {
971
971
  }
972
972
  /**
973
973
  * Runs your callback wrapped inside a database transaction.
974
- *
975
- * If a transaction is already active, a new savepoint (nested transaction) will be created by default. This behavior
976
- * can be controlled via the `propagation` option. Use the provided EntityManager instance for all operations that
977
- * should be part of the transaction. You can safely use a global EntityManager instance from a DI container, as this
978
- * method automatically creates an async context for the transaction.
979
- *
980
- * **Concurrency note:** When running multiple transactions concurrently (e.g. in parallel requests or jobs), use the
981
- * `clear: true` option. This ensures the callback runs in a clear fork of the EntityManager, providing full isolation
982
- * between concurrent transactional handlers. Using `clear: true` is an alternative to forking explicitly and calling
983
- * the method on the new fork – it already provides the necessary isolation for safe concurrent usage.
984
- *
985
- * **Propagation note:** Changes made within a transaction (whether top-level or nested) are always propagated to the
986
- * parent context, unless the parent context is a global one. If you want to avoid that, fork the EntityManager first
987
- * and then call this method on the fork.
988
- *
989
- * **Example:**
990
- * ```ts
991
- * await em.transactional(async (em) => {
992
- * const author = new Author('Jon');
993
- * em.persist(author);
994
- * // flush is called automatically at the end of the callback
995
- * });
996
- * ```
997
974
  */
998
975
  async transactional(cb, options = {}) {
999
976
  const em = this.getContext(false);
@@ -3,13 +3,12 @@ export declare class FileCacheAdapter implements SyncCacheAdapter {
3
3
  private readonly options;
4
4
  private readonly baseDir;
5
5
  private readonly pretty;
6
- private readonly hashAlgorithm;
7
6
  private readonly VERSION;
8
7
  private cache;
9
8
  constructor(options: {
10
9
  cacheDir: string;
11
10
  combined?: boolean | string;
12
- }, baseDir: string, pretty?: boolean, hashAlgorithm?: 'md5' | 'sha256');
11
+ }, baseDir: string, pretty?: boolean);
13
12
  /**
14
13
  * @inheritDoc
15
14
  */
@@ -11,14 +11,12 @@ class FileCacheAdapter {
11
11
  options;
12
12
  baseDir;
13
13
  pretty;
14
- hashAlgorithm;
15
14
  VERSION = Utils_1.Utils.getORMVersion();
16
15
  cache = {};
17
- constructor(options, baseDir, pretty = false, hashAlgorithm = 'md5') {
16
+ constructor(options, baseDir, pretty = false) {
18
17
  this.options = options;
19
18
  this.baseDir = baseDir;
20
19
  this.pretty = pretty;
21
- this.hashAlgorithm = hashAlgorithm;
22
20
  }
23
21
  /**
24
22
  * @inheritDoc
@@ -86,7 +84,7 @@ class FileCacheAdapter {
86
84
  return null;
87
85
  }
88
86
  const contents = (0, fs_extra_1.readFileSync)(origin);
89
- return Utils_1.Utils.hash(contents.toString() + this.VERSION, undefined, this.hashAlgorithm);
87
+ return Utils_1.Utils.hash(contents.toString() + this.VERSION);
90
88
  }
91
89
  }
92
90
  exports.FileCacheAdapter = FileCacheAdapter;
@@ -465,20 +465,23 @@ class EntityLoader {
465
465
  }
466
466
  getChildReferences(entities, prop, options, ref) {
467
467
  const filtered = this.filterCollections(entities, prop.name, options, ref);
468
+ const children = [];
468
469
  if (prop.kind === enums_1.ReferenceKind.ONE_TO_MANY) {
469
- return filtered.map(e => e[prop.name].owner);
470
+ children.push(...filtered.map(e => e[prop.name].owner));
470
471
  }
471
- if (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY && prop.owner) {
472
- return filtered.reduce((a, b) => {
472
+ else if (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY && prop.owner) {
473
+ children.push(...filtered.reduce((a, b) => {
473
474
  a.push(...b[prop.name].getItems());
474
475
  return a;
475
- }, []);
476
+ }, []));
477
+ }
478
+ else if (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY) { // inverse side
479
+ children.push(...filtered);
476
480
  }
477
- if (prop.kind === enums_1.ReferenceKind.MANY_TO_MANY) { // inverse side
478
- return filtered;
481
+ else { // MANY_TO_ONE or ONE_TO_ONE
482
+ children.push(...this.filterReferences(entities, prop.name, options, ref));
479
483
  }
480
- // MANY_TO_ONE or ONE_TO_ONE
481
- return this.filterReferences(entities, prop.name, options, ref);
484
+ return children;
482
485
  }
483
486
  filterCollections(entities, field, options, ref) {
484
487
  if (options.refresh) {
@@ -443,9 +443,6 @@ export declare class OneToOneOptionsBuilder<TargetValue extends object> extends
443
443
  deferMode(deferMode: DeferMode | `${DeferMode}`): OneToOneOptionsBuilder<TargetValue>;
444
444
  }
445
445
  declare const propertyBuilders: {
446
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
447
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
448
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
449
446
  json: <T>() => PropertyOptionsBuilder<T>;
450
447
  formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
451
448
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
@@ -458,8 +455,10 @@ declare const propertyBuilders: {
458
455
  date: () => PropertyOptionsBuilder<string>;
459
456
  time: () => PropertyOptionsBuilder<any>;
460
457
  datetime: () => PropertyOptionsBuilder<Date>;
458
+ bigint: () => PropertyOptionsBuilder<NonNullable<string | number | bigint | null | undefined>>;
461
459
  blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
462
460
  uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
461
+ array: () => PropertyOptionsBuilder<unknown[]>;
463
462
  enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
464
463
  integer: () => PropertyOptionsBuilder<number>;
465
464
  smallint: () => PropertyOptionsBuilder<number>;
@@ -468,6 +467,7 @@ declare const propertyBuilders: {
468
467
  float: () => PropertyOptionsBuilder<number>;
469
468
  double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
470
469
  boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
470
+ decimal: () => PropertyOptionsBuilder<NonNullable<string | number>>;
471
471
  character: () => PropertyOptionsBuilder<string>;
472
472
  string: () => PropertyOptionsBuilder<string>;
473
473
  uuid: () => PropertyOptionsBuilder<string>;
@@ -481,9 +481,6 @@ export declare function defineEntity<Properties extends Record<string, any>>(met
481
481
  }): EntitySchema<InferEntityFromProperties<Properties>, never>;
482
482
  export declare namespace defineEntity {
483
483
  var properties: {
484
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
485
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
486
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
487
484
  json: <T>() => PropertyOptionsBuilder<T>;
488
485
  formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
489
486
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
@@ -496,8 +493,10 @@ export declare namespace defineEntity {
496
493
  date: () => PropertyOptionsBuilder<string>;
497
494
  time: () => PropertyOptionsBuilder<any>;
498
495
  datetime: () => PropertyOptionsBuilder<Date>;
496
+ bigint: () => PropertyOptionsBuilder<NonNullable<string | number | bigint | null | undefined>>;
499
497
  blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
500
498
  uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
499
+ array: () => PropertyOptionsBuilder<unknown[]>;
501
500
  enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
502
501
  integer: () => PropertyOptionsBuilder<number>;
503
502
  smallint: () => PropertyOptionsBuilder<number>;
@@ -506,6 +505,7 @@ export declare namespace defineEntity {
506
505
  float: () => PropertyOptionsBuilder<number>;
507
506
  double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
508
507
  boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
508
+ decimal: () => PropertyOptionsBuilder<NonNullable<string | number>>;
509
509
  character: () => PropertyOptionsBuilder<string>;
510
510
  string: () => PropertyOptionsBuilder<string>;
511
511
  uuid: () => PropertyOptionsBuilder<string>;
@@ -635,9 +635,6 @@ function createPropertyBuilders(options) {
635
635
  }
636
636
  const propertyBuilders = {
637
637
  ...createPropertyBuilders(types_1.types),
638
- bigint: (mode) => new PropertyOptionsBuilder({ type: new types_1.types.bigint(mode) }),
639
- array: (toJsValue = i => i, toDbValue = i => i) => new PropertyOptionsBuilder({ type: new types_1.types.array(toJsValue, toDbValue) }),
640
- decimal: (mode) => new PropertyOptionsBuilder({ type: new types_1.types.decimal(mode) }),
641
638
  json: () => new PropertyOptionsBuilder({ type: types_1.types.json }),
642
639
  formula: (formula) => new PropertyOptionsBuilder({ formula }),
643
640
  type: (type) => new PropertyOptionsBuilder({ type }),
@@ -1136,7 +1136,7 @@ class MetadataDiscovery {
1136
1136
  if (prop.fieldNames?.length === 1 && !prop.customType) {
1137
1137
  [types_1.BigIntType, types_1.DoubleType, types_1.DecimalType, types_1.IntervalType, types_1.DateType]
1138
1138
  .filter(type => mappedType instanceof type)
1139
- .forEach((type) => prop.customType = new type());
1139
+ .forEach(type => prop.customType = new type());
1140
1140
  }
1141
1141
  if (prop.customType && !prop.columnTypes) {
1142
1142
  const mappedType = this.getMappedType({ columnTypes: [prop.customType.getColumnType(prop, this.platform)] });
@@ -13,7 +13,7 @@ class MetadataStorage {
13
13
  this.metadata = Utils_1.Utils.copy(metadata, false);
14
14
  }
15
15
  static getMetadata(entity, path) {
16
- const key = entity && path ? entity + '-' + Utils_1.Utils.hash(path, undefined, 'sha256') : null;
16
+ const key = entity && path ? entity + '-' + Utils_1.Utils.hash(path) : null;
17
17
  if (key && !MetadataStorage.metadata[key]) {
18
18
  MetadataStorage.metadata[key] = new typings_1.EntityMetadata({ className: entity, path });
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "6.5.6-dev.12",
3
+ "version": "6.5.6-dev.3",
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.6-dev.12",
67
+ "mikro-orm": "6.5.6-dev.3",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -5,15 +5,13 @@ import type { EntityProperty } from '../typings';
5
5
  * This type will automatically convert string values returned from the database to native JS bigints (default)
6
6
  * or numbers (safe only for values up to `Number.MAX_SAFE_INTEGER`), or strings, depending on the `mode`.
7
7
  */
8
- export declare class BigIntType<Mode extends 'bigint' | 'number' | 'string' = 'bigint'> extends Type<JSTypeByMode<Mode> | null | undefined, string | null | undefined> {
9
- mode?: Mode | undefined;
10
- constructor(mode?: Mode | undefined);
11
- convertToDatabaseValue(value: JSTypeByMode<Mode> | null | undefined): string | null | undefined;
12
- convertToJSValue(value: string | bigint | null | undefined): JSTypeByMode<Mode> | null | undefined;
13
- toJSON(value: JSTypeByMode<Mode> | null | undefined): JSTypeByMode<Mode> | null | undefined;
8
+ export declare class BigIntType extends Type<string | bigint | number | null | undefined, string | null | undefined> {
9
+ mode?: "bigint" | "number" | "string" | undefined;
10
+ constructor(mode?: "bigint" | "number" | "string" | undefined);
11
+ convertToDatabaseValue(value: string | bigint | null | undefined): string | null | undefined;
12
+ convertToJSValue(value: string | bigint | null | undefined): bigint | number | string | null | undefined;
13
+ toJSON(value: string | bigint | null | undefined): string | bigint | null | undefined;
14
14
  getColumnType(prop: EntityProperty, platform: Platform): string;
15
15
  compareAsType(): string;
16
16
  compareValues(a: string, b: string): boolean;
17
17
  }
18
- type JSTypeByMode<Mode extends 'bigint' | 'number' | 'string'> = Mode extends 'bigint' ? bigint : Mode extends 'number' ? number : string;
19
- export {};
@@ -4,14 +4,12 @@ import type { EntityProperty } from '../typings';
4
4
  /**
5
5
  * Type that maps an SQL DECIMAL to a JS string or number.
6
6
  */
7
- export declare class DecimalType<Mode extends 'number' | 'string' = 'string'> extends Type<JSTypeByMode<Mode>, string> {
8
- mode?: Mode | undefined;
9
- constructor(mode?: Mode | undefined);
10
- convertToJSValue(value: string): JSTypeByMode<Mode>;
7
+ export declare class DecimalType extends Type<string | number, string> {
8
+ mode?: "number" | "string" | undefined;
9
+ constructor(mode?: "number" | "string" | undefined);
10
+ convertToJSValue(value: string): number | string;
11
11
  compareValues(a: string, b: string): boolean;
12
12
  private format;
13
13
  getColumnType(prop: EntityProperty, platform: Platform): string;
14
14
  compareAsType(): string;
15
15
  }
16
- type JSTypeByMode<Mode extends 'number' | 'string'> = Mode extends 'number' ? number : string;
17
- export {};
@@ -81,7 +81,6 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
81
81
  ensureDatabase: true;
82
82
  ensureIndexes: false;
83
83
  batchSize: number;
84
- hashAlgorithm: "md5";
85
84
  debug: false;
86
85
  ignoreDeprecations: false;
87
86
  verbose: false;
@@ -104,8 +103,6 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
104
103
  disableForeignKeys: false;
105
104
  createForeignKeyConstraints: true;
106
105
  ignoreSchema: never[];
107
- skipTables: never[];
108
- skipColumns: {};
109
106
  };
110
107
  embeddables: {
111
108
  prefixMode: "absolute";
@@ -398,8 +395,6 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
398
395
  disableForeignKeys?: boolean;
399
396
  createForeignKeyConstraints?: boolean;
400
397
  ignoreSchema?: string[];
401
- skipTables?: (string | RegExp)[];
402
- skipColumns?: Dictionary<(string | RegExp)[]>;
403
398
  managementDbName?: string;
404
399
  };
405
400
  embeddables: {
@@ -428,7 +423,6 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
428
423
  };
429
424
  seeder: SeederOptions;
430
425
  preferReadReplicas: boolean;
431
- hashAlgorithm: 'md5' | 'sha256';
432
426
  dynamicImportProvider: (id: string) => Promise<unknown>;
433
427
  }
434
428
  export type Options<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = D[typeof EntityManagerType] & EntityManager> = Pick<MikroORMOptions<D, EM>, Exclude<keyof MikroORMOptions<D, EM>, keyof typeof Configuration.DEFAULTS>> & Partial<MikroORMOptions<D, EM>>;
@@ -75,7 +75,6 @@ class Configuration {
75
75
  ensureDatabase: true,
76
76
  ensureIndexes: false,
77
77
  batchSize: 300,
78
- hashAlgorithm: 'md5',
79
78
  debug: false,
80
79
  ignoreDeprecations: false,
81
80
  verbose: false,
@@ -98,8 +97,6 @@ class Configuration {
98
97
  disableForeignKeys: false,
99
98
  createForeignKeyConstraints: true,
100
99
  ignoreSchema: [],
101
- skipTables: [],
102
- skipColumns: {},
103
100
  },
104
101
  embeddables: {
105
102
  prefixMode: 'absolute',
@@ -269,7 +266,7 @@ class Configuration {
269
266
  * Gets instance of metadata CacheAdapter. (cached)
270
267
  */
271
268
  getMetadataCacheAdapter() {
272
- return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty, this.options.hashAlgorithm);
269
+ return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty);
273
270
  }
274
271
  /**
275
272
  * Gets instance of CacheAdapter for result cache. (cached)
package/utils/Utils.d.ts CHANGED
@@ -204,7 +204,7 @@ export declare class Utils {
204
204
  * If either `path` or `baseDir` are `file:` URLs, they are converted to local paths.
205
205
  */
206
206
  static absolutePath(path: string, baseDir?: string): string;
207
- static hash(data: string, length?: number, algorithm?: 'md5' | 'sha256'): string;
207
+ static hash(data: string, length?: number): string;
208
208
  static runIfNotEmpty(clause: () => any, data: any): void;
209
209
  static defaultValue<T extends Dictionary>(prop: T, option: keyof T, defaultValue: any): void;
210
210
  static findDuplicates<T>(items: T[]): T[];
package/utils/Utils.js CHANGED
@@ -805,9 +805,8 @@ class Utils {
805
805
  }
806
806
  return Utils.normalizePath(path);
807
807
  }
808
- static hash(data, length, algorithm) {
809
- const hashAlgorithm = algorithm || 'sha256';
810
- const hash = (0, node_crypto_1.createHash)(hashAlgorithm).update(data).digest('hex');
808
+ static hash(data, length) {
809
+ const hash = (0, node_crypto_1.createHash)('md5').update(data).digest('hex');
811
810
  if (length) {
812
811
  return hash.substring(0, length);
813
812
  }