@mikro-orm/core 6.5.6-dev.4 → 6.5.6-dev.5
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.
|
|
3
|
+
"version": "6.5.6-dev.5",
|
|
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.
|
|
67
|
+
"mikro-orm": "6.5.6-dev.5",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -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;
|
|
@@ -423,6 +424,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
423
424
|
};
|
|
424
425
|
seeder: SeederOptions;
|
|
425
426
|
preferReadReplicas: boolean;
|
|
427
|
+
hashAlgorithm: 'md5' | 'sha256';
|
|
426
428
|
dynamicImportProvider: (id: string) => Promise<unknown>;
|
|
427
429
|
}
|
|
428
430
|
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>>;
|
package/utils/Configuration.js
CHANGED
|
@@ -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,
|
|
@@ -266,7 +267,7 @@ class Configuration {
|
|
|
266
267
|
* Gets instance of metadata CacheAdapter. (cached)
|
|
267
268
|
*/
|
|
268
269
|
getMetadataCacheAdapter() {
|
|
269
|
-
return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty);
|
|
270
|
+
return this.getCachedService(this.options.metadataCache.adapter, this.options.metadataCache.options, this.options.baseDir, this.options.metadataCache.pretty, this.options.hashAlgorithm);
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
272
273
|
* 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
|
|
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
|
}
|