@mikro-orm/core 7.0.0-dev.215 → 7.0.0-dev.216
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 +1 -1
- package/MikroORM.js +17 -13
- package/entity/WrappedEntity.d.ts +2 -2
- package/package.json +1 -1
- package/utils/Configuration.d.ts +1 -1
- package/utils/Utils.js +1 -1
- package/utils/fs-utils.d.ts +1 -0
- package/utils/fs-utils.js +19 -5
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
|
|
8
|
+
export declare function loadOptionalDependencies(options: Options): Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* The main class used to configure and bootstrap the ORM.
|
|
11
11
|
*
|
package/MikroORM.js
CHANGED
|
@@ -4,31 +4,35 @@ import { Configuration } from './utils/Configuration.js';
|
|
|
4
4
|
import { loadEnvironmentVars } from './utils/env-vars.js';
|
|
5
5
|
import { Utils } from './utils/Utils.js';
|
|
6
6
|
import { colors } from './logging/colors.js';
|
|
7
|
-
async function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
async function tryRegisterExtension(name, pkg, extensions) {
|
|
8
|
+
try {
|
|
9
|
+
const url = import.meta.resolve(pkg);
|
|
10
|
+
const mod = await import(url);
|
|
11
|
+
if (mod[name]) {
|
|
12
|
+
extensions.push(mod[name]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
// not installed
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
/** @internal */
|
|
17
|
-
export async function
|
|
20
|
+
export async function loadOptionalDependencies(options) {
|
|
21
|
+
await import('@mikro-orm/core/fs-utils').then(m => m.fs.init()).catch(() => null);
|
|
18
22
|
const extensions = options.extensions ?? [];
|
|
19
23
|
const exists = (name) => extensions.some(ext => ext.name === name);
|
|
20
24
|
if (!exists('SeedManager')) {
|
|
21
|
-
await
|
|
25
|
+
await tryRegisterExtension('SeedManager', '@mikro-orm/seeder', extensions);
|
|
22
26
|
}
|
|
23
27
|
if (!exists('Migrator')) {
|
|
24
|
-
await
|
|
28
|
+
await tryRegisterExtension('Migrator', '@mikro-orm/migrations', extensions);
|
|
25
29
|
}
|
|
26
30
|
/* v8 ignore if */
|
|
27
31
|
if (!exists('Migrator')) {
|
|
28
|
-
await
|
|
32
|
+
await tryRegisterExtension('Migrator', '@mikro-orm/migrations-mongodb', extensions);
|
|
29
33
|
}
|
|
30
34
|
if (!exists('EntityGenerator')) {
|
|
31
|
-
await
|
|
35
|
+
await tryRegisterExtension('EntityGenerator', '@mikro-orm/entity-generator', extensions);
|
|
32
36
|
}
|
|
33
37
|
options.extensions = extensions;
|
|
34
38
|
const metadataCacheEnabled = options.metadataCache?.enabled || options.metadataProvider?.useCache?.();
|
|
@@ -85,7 +89,7 @@ export class MikroORM {
|
|
|
85
89
|
options = { ...options };
|
|
86
90
|
options.discovery ??= {};
|
|
87
91
|
options.discovery.skipSyncDiscovery ??= true;
|
|
88
|
-
await
|
|
92
|
+
await loadOptionalDependencies(options);
|
|
89
93
|
const orm = new this(options);
|
|
90
94
|
const preferTs = orm.config.get('preferTs', Utils.detectTypeScriptSupport());
|
|
91
95
|
orm.metadata = await orm.discovery.discover(preferTs);
|
|
@@ -58,7 +58,7 @@ export declare class WrappedEntity<Entity extends object> {
|
|
|
58
58
|
setPrimaryKey(id: Primary<Entity> | null): void;
|
|
59
59
|
getSerializedPrimaryKey(): string;
|
|
60
60
|
get __meta(): EntityMetadata<Entity>;
|
|
61
|
-
get __platform(): import("
|
|
62
|
-
get __config(): import("
|
|
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
63
|
get __primaryKeys(): Primary<Entity>[];
|
|
64
64
|
}
|
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.216",
|
|
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",
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ declare const DEFAULTS: {
|
|
|
35
35
|
readonly inferDefaultValues: true;
|
|
36
36
|
};
|
|
37
37
|
readonly validateRequired: true;
|
|
38
|
-
readonly context: (name: string) => EntityManager<IDatabaseDriver<import("
|
|
38
|
+
readonly context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
|
|
39
39
|
readonly contextName: "default";
|
|
40
40
|
readonly allowGlobalContext: false;
|
|
41
41
|
readonly logger: (message?: any, ...optionalParams: any[]) => void;
|
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.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.216';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|
package/utils/fs-utils.d.ts
CHANGED
package/utils/fs-utils.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import { existsSync, globSync, mkdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
1
|
+
import { existsSync, globSync as nodeGlobSync, mkdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
2
|
import { isAbsolute, join, normalize, relative } from 'node:path';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import { Utils } from './Utils.js';
|
|
5
5
|
import { colors } from '../logging/colors.js';
|
|
6
|
+
let globSync = (patterns, options) => {
|
|
7
|
+
const files = nodeGlobSync(patterns, { ...options, withFileTypes: true });
|
|
8
|
+
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
9
|
+
};
|
|
6
10
|
export const fs = {
|
|
11
|
+
async init() {
|
|
12
|
+
const tinyGlobby = await import('tinyglobby').catch(() => null);
|
|
13
|
+
if (tinyGlobby) {
|
|
14
|
+
globSync = (patterns, options) => {
|
|
15
|
+
patterns = Utils.asArray(patterns).map(p => p.replace(/\\/g, '/'));
|
|
16
|
+
if (options?.cwd) {
|
|
17
|
+
options = { ...options, cwd: options.cwd.replace(/\\/g, '/') };
|
|
18
|
+
}
|
|
19
|
+
return tinyGlobby.globSync(patterns, { ...options, expandDirectories: false });
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
},
|
|
7
23
|
pathExists(path) {
|
|
8
24
|
if (/[*?[\]]/.test(path)) {
|
|
9
25
|
return globSync(path).length > 0;
|
|
@@ -49,16 +65,14 @@ export const fs = {
|
|
|
49
65
|
try {
|
|
50
66
|
const s = statSync(cwd ? this.normalizePath(cwd, input) : input);
|
|
51
67
|
if (s.isDirectory()) {
|
|
52
|
-
|
|
53
|
-
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
68
|
+
return globSync(join(input, '**'), { cwd });
|
|
54
69
|
}
|
|
55
70
|
}
|
|
56
71
|
catch {
|
|
57
72
|
// ignore
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
|
-
|
|
61
|
-
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
75
|
+
return globSync(input, { cwd });
|
|
62
76
|
},
|
|
63
77
|
getPackageConfig(basePath = process.cwd()) {
|
|
64
78
|
if (this.pathExists(`${basePath}/package.json`)) {
|