@mikro-orm/core 7.0.0-dev.32 → 7.0.0-dev.34
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/package.json +2 -2
- package/utils/Configuration.d.ts +2 -0
- package/utils/Configuration.js +4 -0
- package/utils/Utils.d.ts +2 -0
- package/utils/Utils.js +13 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.34",
|
|
5
5
|
"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.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dataloader": "2.2.3",
|
|
55
55
|
"dotenv": "17.2.3",
|
|
56
56
|
"esprima": "4.0.1",
|
|
57
|
-
"mikro-orm": "7.0.0-dev.
|
|
57
|
+
"mikro-orm": "7.0.0-dev.34",
|
|
58
58
|
"reflect-metadata": "0.2.2",
|
|
59
59
|
"tinyglobby": "0.2.13"
|
|
60
60
|
}
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
146
146
|
fileName: (className: string) => string;
|
|
147
147
|
};
|
|
148
148
|
preferReadReplicas: true;
|
|
149
|
+
dynamicImportProvider: (id: string) => Promise<any>;
|
|
149
150
|
};
|
|
150
151
|
private readonly options;
|
|
151
152
|
private readonly logger;
|
|
@@ -412,6 +413,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
412
413
|
};
|
|
413
414
|
seeder: SeederOptions;
|
|
414
415
|
preferReadReplicas: boolean;
|
|
416
|
+
dynamicImportProvider: (id: string) => Promise<unknown>;
|
|
415
417
|
hashAlgorithm: 'md5' | 'sha256';
|
|
416
418
|
}
|
|
417
419
|
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
|
@@ -134,6 +134,7 @@ export class Configuration {
|
|
|
134
134
|
fileName: (className) => className,
|
|
135
135
|
},
|
|
136
136
|
preferReadReplicas: true,
|
|
137
|
+
dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
|
|
137
138
|
};
|
|
138
139
|
options;
|
|
139
140
|
logger;
|
|
@@ -142,6 +143,9 @@ export class Configuration {
|
|
|
142
143
|
cache = new Map();
|
|
143
144
|
extensions = new Map();
|
|
144
145
|
constructor(options, validate = true) {
|
|
146
|
+
if (options.dynamicImportProvider) {
|
|
147
|
+
Utils.setDynamicImportProvider(options.dynamicImportProvider);
|
|
148
|
+
}
|
|
145
149
|
this.options = Utils.mergeConfig({}, Configuration.DEFAULTS, options);
|
|
146
150
|
this.options.baseDir = Utils.absolutePath(this.options.baseDir);
|
|
147
151
|
this.options.preferTs ??= options.preferTs;
|
package/utils/Utils.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare function equals(a: any, b: any): boolean;
|
|
|
15
15
|
export declare function parseJsonSafe<T = unknown>(value: unknown): T;
|
|
16
16
|
export declare class Utils {
|
|
17
17
|
static readonly PK_SEPARATOR = "~~~";
|
|
18
|
+
static dynamicImportProvider: (id: string) => Promise<any>;
|
|
18
19
|
/**
|
|
19
20
|
* Checks if the argument is not undefined
|
|
20
21
|
*/
|
|
@@ -236,6 +237,7 @@ export declare class Utils {
|
|
|
236
237
|
*/
|
|
237
238
|
static resolveModulePath(id: string, from?: string): string;
|
|
238
239
|
static dynamicImport<T = any>(id: string): Promise<T>;
|
|
240
|
+
static setDynamicImportProvider(provider: (id: string) => Promise<unknown>): void;
|
|
239
241
|
static ensureDir(path: string): void;
|
|
240
242
|
static pathExistsSync(path: string): boolean;
|
|
241
243
|
static readJSONSync(path: string): Dictionary;
|
package/utils/Utils.js
CHANGED
|
@@ -131,6 +131,8 @@ export function parseJsonSafe(value) {
|
|
|
131
131
|
}
|
|
132
132
|
export class Utils {
|
|
133
133
|
static PK_SEPARATOR = '~~~';
|
|
134
|
+
/* v8 ignore next */
|
|
135
|
+
static dynamicImportProvider = (id) => import(id);
|
|
134
136
|
/**
|
|
135
137
|
* Checks if the argument is not undefined
|
|
136
138
|
*/
|
|
@@ -907,7 +909,11 @@ export class Utils {
|
|
|
907
909
|
static async dynamicImport(id) {
|
|
908
910
|
/* v8 ignore next */
|
|
909
911
|
const specifier = id.startsWith('file://') ? id : pathToFileURL(id).href;
|
|
910
|
-
return
|
|
912
|
+
return this.dynamicImportProvider(specifier);
|
|
913
|
+
}
|
|
914
|
+
/* v8 ignore next 3 */
|
|
915
|
+
static setDynamicImportProvider(provider) {
|
|
916
|
+
this.dynamicImportProvider = provider;
|
|
911
917
|
}
|
|
912
918
|
static ensureDir(path) {
|
|
913
919
|
if (!existsSync(path)) {
|
|
@@ -1081,9 +1087,12 @@ export class Utils {
|
|
|
1081
1087
|
return await import(module);
|
|
1082
1088
|
}
|
|
1083
1089
|
catch (err) {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1090
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND') {
|
|
1091
|
+
// eslint-disable-next-line no-console
|
|
1092
|
+
console.warn(warning);
|
|
1093
|
+
return undefined;
|
|
1094
|
+
}
|
|
1095
|
+
throw err;
|
|
1087
1096
|
}
|
|
1088
1097
|
}
|
|
1089
1098
|
static stripRelativePath(str) {
|