@mikro-orm/core 7.0.2-dev.7 → 7.0.2-dev.9
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.
|
@@ -54,6 +54,12 @@ export declare class EntitySchema<Entity = any, Base = never, Class extends Enti
|
|
|
54
54
|
private internal;
|
|
55
55
|
private initialized;
|
|
56
56
|
constructor(meta: EntitySchemaMetadata<Entity, Base, Class>);
|
|
57
|
+
/**
|
|
58
|
+
* Checks if the given value is an EntitySchema instance, using duck-typing
|
|
59
|
+
* as a fallback when `instanceof` fails due to CJS/ESM dual-package hazard
|
|
60
|
+
* (e.g. when using `tsx` or `@swc-node/register` with `"type": "commonjs"` projects).
|
|
61
|
+
*/
|
|
62
|
+
static is(item: unknown): item is EntitySchema;
|
|
57
63
|
static fromMetadata<T = AnyEntity, U = never>(meta: EntityMetadata<T> | DeepPartial<EntityMetadata<T>>): EntitySchema<T, U>;
|
|
58
64
|
addProperty(name: EntityKey<Entity>, type?: TypeType, options?: PropertyOptions<Entity> | EntityProperty<Entity>): void;
|
|
59
65
|
addEnum(name: EntityKey<Entity>, type?: TypeType, options?: EnumOptions<Entity>): void;
|
package/metadata/EntitySchema.js
CHANGED
|
@@ -27,6 +27,17 @@ export class EntitySchema {
|
|
|
27
27
|
EntitySchema.REGISTRY.set(meta.class, this);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks if the given value is an EntitySchema instance, using duck-typing
|
|
32
|
+
* as a fallback when `instanceof` fails due to CJS/ESM dual-package hazard
|
|
33
|
+
* (e.g. when using `tsx` or `@swc-node/register` with `"type": "commonjs"` projects).
|
|
34
|
+
*/
|
|
35
|
+
static is(item) {
|
|
36
|
+
if (item instanceof EntitySchema) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return item != null && typeof item === 'object' && item.constructor?.name === 'EntitySchema' && 'meta' in item;
|
|
40
|
+
}
|
|
30
41
|
static fromMetadata(meta) {
|
|
31
42
|
const schema = new EntitySchema({ ...meta, internal: true });
|
|
32
43
|
schema.internal = true;
|
|
@@ -9,7 +9,7 @@ async function getEntityClassOrSchema(filepath, allTargets, baseDir) {
|
|
|
9
9
|
const targets = Object.values(exports);
|
|
10
10
|
// ignore class implementations that are linked from an EntitySchema
|
|
11
11
|
for (const item of targets) {
|
|
12
|
-
if (item
|
|
12
|
+
if (EntitySchema.is(item)) {
|
|
13
13
|
for (const item2 of targets) {
|
|
14
14
|
if (item.meta.class === item2) {
|
|
15
15
|
targets.splice(targets.indexOf(item2), 1);
|
|
@@ -18,7 +18,7 @@ async function getEntityClassOrSchema(filepath, allTargets, baseDir) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
for (const item of targets) {
|
|
21
|
-
const validTarget = item
|
|
21
|
+
const validTarget = EntitySchema.is(item) || (item instanceof Function && MetadataStorage.isKnownEntity(item.name));
|
|
22
22
|
if (validTarget && !allTargets.has(item)) {
|
|
23
23
|
allTargets.set(item, path);
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "7.0.2-dev.
|
|
3
|
+
"version": "7.0.2-dev.9",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
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.2-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.2-dev.9';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|