@mikro-orm/core 7.0.0-dev.85 → 7.0.0-dev.87
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.js +6 -6
- package/entity/defineEntity.d.ts +22 -3
- package/package.json +1 -1
- package/utils/DataloaderUtils.js +1 -1
- package/utils/fs-utils.d.ts +3 -3
- package/utils/fs-utils.js +7 -6
package/MikroORM.js
CHANGED
|
@@ -18,17 +18,17 @@ export async function lookupExtensions(options) {
|
|
|
18
18
|
const extensions = options.extensions ?? [];
|
|
19
19
|
const exists = (name) => extensions.some(ext => ext.name === name);
|
|
20
20
|
if (!exists('SeedManager')) {
|
|
21
|
-
await registerExtension('SeedManager', import('@mikro-orm/seeder'
|
|
21
|
+
await registerExtension('SeedManager', import((() => '@mikro-orm/seeder')()), extensions);
|
|
22
22
|
}
|
|
23
23
|
if (!exists('Migrator')) {
|
|
24
|
-
await registerExtension('Migrator', import('@mikro-orm/migrations'
|
|
24
|
+
await registerExtension('Migrator', import((() => '@mikro-orm/migrations')()), extensions);
|
|
25
25
|
}
|
|
26
26
|
/* v8 ignore if */
|
|
27
27
|
if (!exists('Migrator')) {
|
|
28
|
-
await registerExtension('Migrator', import('@mikro-orm/migrations-mongodb'
|
|
28
|
+
await registerExtension('Migrator', import((() => '@mikro-orm/migrations-mongodb')()), extensions);
|
|
29
29
|
}
|
|
30
30
|
if (!exists('EntityGenerator')) {
|
|
31
|
-
await registerExtension('EntityGenerator', import('@mikro-orm/entity-generator'
|
|
31
|
+
await registerExtension('EntityGenerator', import((() => '@mikro-orm/entity-generator')()), extensions);
|
|
32
32
|
}
|
|
33
33
|
options.extensions = extensions;
|
|
34
34
|
const metadataCacheEnabled = options.metadataCache?.enabled || options.metadataProvider?.useCache?.();
|
|
@@ -150,8 +150,8 @@ export class MikroORM {
|
|
|
150
150
|
*/
|
|
151
151
|
async close(force = false) {
|
|
152
152
|
await this.driver.close(force);
|
|
153
|
-
await this.config.getMetadataCacheAdapter()
|
|
154
|
-
await this.config.getResultCacheAdapter()
|
|
153
|
+
await this.config.getMetadataCacheAdapter()?.close?.();
|
|
154
|
+
await this.config.getResultCacheAdapter()?.close?.();
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Gets the `MetadataStorage` (without parameters) or `EntityMetadata` instance when provided with the `entityName` parameter.
|
package/entity/defineEntity.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
2
|
import type { ColumnType, PropertyOptions, ReferenceOptions, EnumOptions, EmbeddedOptions, ManyToOneOptions, OneToManyOptions, OneToOneOptions, ManyToManyOptions } from '../metadata/types.js';
|
|
3
|
-
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref } from '../typings.js';
|
|
3
|
+
import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback } from '../typings.js';
|
|
4
4
|
import type { ScalarReference } from './Reference.js';
|
|
5
5
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
6
6
|
import type { Cascade, DeferMode, EmbeddedPrefixMode, EventType, LoadStrategy, QueryOrderMap } from '../enums.js';
|
|
@@ -409,14 +409,33 @@ declare const propertyBuilders: {
|
|
|
409
409
|
interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
410
410
|
unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
|
|
411
411
|
};
|
|
412
|
-
export
|
|
412
|
+
export interface EntityMetadataWithProperties<TName extends string, TTableName extends string, TProperties extends Record<string, any>, TPK extends (keyof TProperties)[] | undefined = undefined, TBase = never> extends Omit<Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks' | 'discriminatorColumn' | 'versionProperty' | 'concurrencyCheckKeys' | 'serializedPrimaryKey' | 'indexes' | 'uniques'> {
|
|
413
413
|
name: TName;
|
|
414
414
|
tableName?: TTableName;
|
|
415
415
|
extends?: EntityName<TBase>;
|
|
416
416
|
properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
|
|
417
417
|
primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
|
|
418
418
|
hooks?: DefineEntityHooks<InferEntityFromProperties<TProperties, TPK>>;
|
|
419
|
-
|
|
419
|
+
discriminatorColumn?: keyof TProperties;
|
|
420
|
+
versionProperty?: keyof TProperties;
|
|
421
|
+
concurrencyCheckKeys?: Set<keyof TProperties>;
|
|
422
|
+
serializedPrimaryKey?: keyof TProperties;
|
|
423
|
+
indexes?: {
|
|
424
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
425
|
+
name?: string;
|
|
426
|
+
type?: string;
|
|
427
|
+
options?: Dictionary;
|
|
428
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK>>;
|
|
429
|
+
}[];
|
|
430
|
+
uniques?: {
|
|
431
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
432
|
+
name?: string;
|
|
433
|
+
options?: Dictionary;
|
|
434
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK>>;
|
|
435
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
436
|
+
}[];
|
|
437
|
+
}
|
|
438
|
+
export declare function defineEntity<const TName extends string, const TTableName extends string, const TProperties extends Record<string, any>, const TPK extends (keyof TProperties)[] | undefined = undefined, const TBase = never>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase>): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK>, TBase, TProperties>;
|
|
420
439
|
export declare function defineEntity<const TEntity = any, const TProperties extends Record<string, any> = Record<string, any>, const TClassName extends string = string, const TTableName extends string = string, const TBase = never>(meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName'> & {
|
|
421
440
|
class: EntityClass<TEntity>;
|
|
422
441
|
className?: TClassName;
|
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.87",
|
|
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/DataloaderUtils.js
CHANGED
|
@@ -216,7 +216,7 @@ export class DataloaderUtils {
|
|
|
216
216
|
return this.DataLoader;
|
|
217
217
|
}
|
|
218
218
|
try {
|
|
219
|
-
const mod = await import('dataloader'
|
|
219
|
+
const mod = await import('dataloader');
|
|
220
220
|
const DataLoader = mod.default;
|
|
221
221
|
return (this.DataLoader ??= DataLoader);
|
|
222
222
|
}
|
package/utils/fs-utils.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export declare const fs: {
|
|
|
4
4
|
ensureDir(path: string): void;
|
|
5
5
|
readJSONSync<T = Dictionary>(path: string): T;
|
|
6
6
|
glob(input: string | string[], cwd?: string): string[];
|
|
7
|
-
getPackageConfig<T extends Dictionary>(basePath?: string):
|
|
8
|
-
getORMPackages():
|
|
7
|
+
getPackageConfig<T extends Dictionary>(basePath?: string): T;
|
|
8
|
+
getORMPackages(): Set<string>;
|
|
9
9
|
getORMPackageVersion(name: string): string | undefined;
|
|
10
|
-
checkPackageVersion():
|
|
10
|
+
checkPackageVersion(): void;
|
|
11
11
|
};
|
|
12
12
|
export * from '../cache/FileCacheAdapter.js';
|
package/utils/fs-utils.js
CHANGED
|
@@ -39,10 +39,11 @@ export const fs = {
|
|
|
39
39
|
const files = globSync(input, { cwd, withFileTypes: true });
|
|
40
40
|
return files.filter(f => f.isFile()).map(f => join(f.parentPath, f.name));
|
|
41
41
|
},
|
|
42
|
-
|
|
42
|
+
getPackageConfig(basePath = process.cwd()) {
|
|
43
43
|
if (this.pathExists(`${basePath}/package.json`)) {
|
|
44
44
|
try {
|
|
45
|
-
|
|
45
|
+
const path = import.meta.resolve(`${basePath}/package.json`);
|
|
46
|
+
return this.readJSONSync(fileURLToPath(path));
|
|
46
47
|
}
|
|
47
48
|
catch (e) {
|
|
48
49
|
/* v8 ignore next */
|
|
@@ -56,8 +57,8 @@ export const fs = {
|
|
|
56
57
|
}
|
|
57
58
|
return this.getPackageConfig(parentFolder);
|
|
58
59
|
},
|
|
59
|
-
|
|
60
|
-
const pkg =
|
|
60
|
+
getORMPackages() {
|
|
61
|
+
const pkg = this.getPackageConfig();
|
|
61
62
|
return new Set([
|
|
62
63
|
...Object.keys(pkg.dependencies ?? {}),
|
|
63
64
|
...Object.keys(pkg.devDependencies ?? {}),
|
|
@@ -74,12 +75,12 @@ export const fs = {
|
|
|
74
75
|
}
|
|
75
76
|
},
|
|
76
77
|
// inspired by https://github.com/facebook/docusaurus/pull/3386
|
|
77
|
-
|
|
78
|
+
checkPackageVersion() {
|
|
78
79
|
const coreVersion = Utils.getORMVersion();
|
|
79
80
|
if (process.env.MIKRO_ORM_ALLOW_VERSION_MISMATCH || coreVersion === '[[MIKRO_ORM_VERSION]]') {
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
|
-
const deps =
|
|
83
|
+
const deps = this.getORMPackages();
|
|
83
84
|
const exceptions = new Set(['nestjs', 'sql-highlighter', 'mongo-highlighter']);
|
|
84
85
|
const ormPackages = [...deps].filter(d => d.startsWith('@mikro-orm/') && d !== '@mikro-orm/core' && !exceptions.has(d.substring('@mikro-orm/'.length)));
|
|
85
86
|
for (const ormPackage of ormPackages) {
|