@mikro-orm/core 6.5.6-dev.4 → 6.5.6-dev.6

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.
@@ -3,12 +3,13 @@ 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;
6
7
  private readonly VERSION;
7
8
  private cache;
8
9
  constructor(options: {
9
10
  cacheDir: string;
10
11
  combined?: boolean | string;
11
- }, baseDir: string, pretty?: boolean);
12
+ }, baseDir: string, pretty?: boolean, hashAlgorithm?: 'md5' | 'sha256');
12
13
  /**
13
14
  * @inheritDoc
14
15
  */
@@ -11,12 +11,14 @@ class FileCacheAdapter {
11
11
  options;
12
12
  baseDir;
13
13
  pretty;
14
+ hashAlgorithm;
14
15
  VERSION = Utils_1.Utils.getORMVersion();
15
16
  cache = {};
16
- constructor(options, baseDir, pretty = false) {
17
+ constructor(options, baseDir, pretty = false, hashAlgorithm = 'md5') {
17
18
  this.options = options;
18
19
  this.baseDir = baseDir;
19
20
  this.pretty = pretty;
21
+ this.hashAlgorithm = hashAlgorithm;
20
22
  }
21
23
  /**
22
24
  * @inheritDoc
@@ -84,7 +86,7 @@ class FileCacheAdapter {
84
86
  return null;
85
87
  }
86
88
  const contents = (0, fs_extra_1.readFileSync)(origin);
87
- return Utils_1.Utils.hash(contents.toString() + this.VERSION);
89
+ return Utils_1.Utils.hash(contents.toString() + this.VERSION, undefined, this.hashAlgorithm);
88
90
  }
89
91
  }
90
92
  exports.FileCacheAdapter = FileCacheAdapter;
@@ -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) : null;
16
+ const key = entity && path ? entity + '-' + Utils_1.Utils.hash(path, undefined, 'sha256') : 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.4",
3
+ "version": "6.5.6-dev.6",
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.4",
67
+ "mikro-orm": "6.5.6-dev.6",
68
68
  "reflect-metadata": "0.2.2"
69
69
  }
70
70
  }
@@ -81,6 +81,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
81
81
  ensureDatabase: true;
82
82
  ensureIndexes: false;
83
83
  batchSize: number;
84
+ hashAlgorithm: "md5";
84
85
  debug: false;
85
86
  ignoreDeprecations: false;
86
87
  verbose: false;
@@ -103,6 +104,8 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
103
104
  disableForeignKeys: false;
104
105
  createForeignKeyConstraints: true;
105
106
  ignoreSchema: never[];
107
+ skipTables: never[];
108
+ skipColumns: {};
106
109
  };
107
110
  embeddables: {
108
111
  prefixMode: "absolute";
@@ -395,6 +398,8 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
395
398
  disableForeignKeys?: boolean;
396
399
  createForeignKeyConstraints?: boolean;
397
400
  ignoreSchema?: string[];
401
+ skipTables?: (string | RegExp)[];
402
+ skipColumns?: Dictionary<(string | RegExp)[]>;
398
403
  managementDbName?: string;
399
404
  };
400
405
  embeddables: {
@@ -423,6 +428,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
423
428
  };
424
429
  seeder: SeederOptions;
425
430
  preferReadReplicas: boolean;
431
+ hashAlgorithm: 'md5' | 'sha256';
426
432
  dynamicImportProvider: (id: string) => Promise<unknown>;
427
433
  }
428
434
  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,6 +75,7 @@ class Configuration {
75
75
  ensureDatabase: true,
76
76
  ensureIndexes: false,
77
77
  batchSize: 300,
78
+ hashAlgorithm: 'md5',
78
79
  debug: false,
79
80
  ignoreDeprecations: false,
80
81
  verbose: false,
@@ -97,6 +98,8 @@ class Configuration {
97
98
  disableForeignKeys: false,
98
99
  createForeignKeyConstraints: true,
99
100
  ignoreSchema: [],
101
+ skipTables: [],
102
+ skipColumns: {},
100
103
  },
101
104
  embeddables: {
102
105
  prefixMode: 'absolute',
@@ -266,7 +269,7 @@ class Configuration {
266
269
  * Gets instance of metadata CacheAdapter. (cached)
267
270
  */
268
271
  getMetadataCacheAdapter() {
269
- return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty);
272
+ return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty, this.options.hashAlgorithm);
270
273
  }
271
274
  /**
272
275
  * 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): string;
207
+ static hash(data: string, length?: number, algorithm?: 'md5' | 'sha256'): 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,8 +805,9 @@ class Utils {
805
805
  }
806
806
  return Utils.normalizePath(path);
807
807
  }
808
- static hash(data, length) {
809
- const hash = (0, node_crypto_1.createHash)('md5').update(data).digest('hex');
808
+ static hash(data, length, algorithm) {
809
+ const hashAlgorithm = algorithm || 'sha256';
810
+ const hash = (0, node_crypto_1.createHash)(hashAlgorithm).update(data).digest('hex');
810
811
  if (length) {
811
812
  return hash.substring(0, length);
812
813
  }