@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.3
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/EntityManager.d.ts +18 -13
- package/EntityManager.js +203 -203
- package/MikroORM.d.ts +7 -6
- package/MikroORM.js +33 -45
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +18 -26
- package/cache/GeneratedCacheAdapter.d.ts +2 -2
- package/cache/GeneratedCacheAdapter.js +1 -5
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +5 -5
- package/cache/index.js +5 -21
- package/connections/Connection.d.ts +7 -7
- package/connections/Connection.js +8 -12
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/decorators/Check.d.ts +1 -1
- package/decorators/Check.js +5 -8
- package/decorators/CreateRequestContext.d.ts +1 -1
- package/decorators/CreateRequestContext.js +13 -14
- package/decorators/Embeddable.d.ts +1 -1
- package/decorators/Embeddable.js +3 -6
- package/decorators/Embedded.d.ts +1 -1
- package/decorators/Embedded.js +10 -12
- package/decorators/Entity.d.ts +2 -2
- package/decorators/Entity.js +5 -8
- package/decorators/Enum.d.ts +2 -2
- package/decorators/Enum.js +7 -10
- package/decorators/Filter.d.ts +1 -1
- package/decorators/Filter.js +3 -6
- package/decorators/Formula.d.ts +2 -2
- package/decorators/Formula.js +7 -10
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/Indexed.js +6 -10
- package/decorators/ManyToMany.d.ts +3 -3
- package/decorators/ManyToMany.js +10 -12
- package/decorators/ManyToOne.d.ts +3 -3
- package/decorators/ManyToOne.js +10 -12
- package/decorators/OneToMany.d.ts +3 -3
- package/decorators/OneToMany.js +11 -14
- package/decorators/OneToOne.d.ts +4 -4
- package/decorators/OneToOne.js +4 -7
- package/decorators/PrimaryKey.d.ts +2 -2
- package/decorators/PrimaryKey.js +10 -13
- package/decorators/Property.d.ts +5 -5
- package/decorators/Property.js +10 -12
- package/decorators/Transactional.d.ts +2 -2
- package/decorators/Transactional.js +7 -10
- package/decorators/hooks.js +23 -35
- package/decorators/index.d.ts +17 -17
- package/decorators/index.js +17 -36
- package/drivers/DatabaseDriver.d.ts +13 -12
- package/drivers/DatabaseDriver.js +60 -64
- package/drivers/IDatabaseDriver.d.ts +12 -12
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/ArrayCollection.d.ts +2 -2
- package/entity/ArrayCollection.js +29 -33
- package/entity/BaseEntity.d.ts +6 -6
- package/entity/BaseEntity.js +17 -21
- package/entity/Collection.d.ts +6 -6
- package/entity/Collection.js +40 -44
- package/entity/EntityAssigner.d.ts +2 -2
- package/entity/EntityAssigner.js +58 -63
- package/entity/EntityFactory.d.ts +3 -3
- package/entity/EntityFactory.js +58 -62
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +41 -45
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +5 -5
- package/entity/EntityLoader.js +92 -96
- package/entity/EntityRepository.d.ts +7 -7
- package/entity/EntityRepository.js +7 -11
- package/entity/EntityValidator.d.ts +1 -1
- package/entity/EntityValidator.js +25 -29
- package/entity/Reference.d.ts +2 -2
- package/entity/Reference.js +35 -42
- package/entity/WrappedEntity.d.ts +12 -12
- package/entity/WrappedEntity.js +23 -27
- package/entity/index.d.ts +13 -13
- package/entity/index.js +13 -29
- package/entity/utils.d.ts +1 -1
- package/entity/utils.js +9 -12
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +3 -3
- package/enums.js +37 -41
- package/errors.d.ts +1 -1
- package/errors.js +15 -24
- package/events/EventManager.d.ts +3 -3
- package/events/EventManager.js +8 -12
- package/events/EventSubscriber.d.ts +5 -4
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +3 -6
- package/hydration/ObjectHydrator.d.ts +3 -3
- package/hydration/ObjectHydrator.js +25 -28
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +21 -46
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +9 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +2 -2
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +4 -4
- package/logging/index.js +4 -20
- package/metadata/EntitySchema.d.ts +12 -4
- package/metadata/EntitySchema.js +41 -45
- package/metadata/MetadataDiscovery.d.ts +7 -7
- package/metadata/MetadataDiscovery.js +174 -177
- package/metadata/MetadataProvider.d.ts +2 -2
- package/metadata/MetadataProvider.js +4 -7
- package/metadata/MetadataStorage.d.ts +2 -2
- package/metadata/MetadataStorage.js +15 -19
- package/metadata/MetadataValidator.d.ts +4 -4
- package/metadata/MetadataValidator.js +49 -53
- package/metadata/ReflectMetadataProvider.d.ts +2 -2
- package/metadata/ReflectMetadataProvider.js +8 -12
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/naming-strategy/AbstractNamingStrategy.d.ts +2 -2
- package/naming-strategy/AbstractNamingStrategy.js +4 -8
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +1 -1
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/package.json +5 -14
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +10 -10
- package/platforms/Platform.js +57 -61
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +2 -2
- package/serialization/EntitySerializer.js +36 -41
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +27 -31
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +10 -14
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +7 -11
- package/types/BigIntType.d.ts +3 -3
- package/types/BigIntType.js +3 -6
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +2 -8
- package/types/BooleanType.d.ts +3 -3
- package/types/BooleanType.js +2 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +3 -3
- package/types/DecimalType.js +4 -7
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +3 -6
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +5 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +3 -3
- package/types/JsonType.js +2 -6
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +2 -2
- package/types/Type.js +5 -9
- package/types/Uint8ArrayType.d.ts +3 -3
- package/types/Uint8ArrayType.js +3 -9
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +22 -20
- package/typings.js +34 -38
- package/unit-of-work/ChangeSet.d.ts +1 -1
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -7
- package/unit-of-work/ChangeSetComputer.js +26 -30
- package/unit-of-work/ChangeSetPersister.d.ts +7 -6
- package/unit-of-work/ChangeSetPersister.js +44 -47
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +8 -7
- package/unit-of-work/UnitOfWork.js +171 -172
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +6 -6
- package/utils/AbstractSchemaGenerator.js +7 -11
- package/utils/Configuration.d.ts +26 -27
- package/utils/Configuration.js +50 -55
- package/utils/ConfigurationLoader.d.ts +9 -8
- package/utils/ConfigurationLoader.js +71 -86
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +22 -25
- package/utils/DataloaderUtils.d.ts +4 -4
- package/utils/DataloaderUtils.js +12 -16
- package/utils/EntityComparator.d.ts +2 -2
- package/utils/EntityComparator.js +48 -52
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +3 -3
- package/utils/QueryHelper.js +47 -51
- package/utils/RawQueryFragment.d.ts +1 -1
- package/utils/RawQueryFragment.js +16 -24
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/Utils.d.ts +16 -12
- package/utils/Utils.js +89 -93
- package/utils/clone.js +8 -11
- package/utils/index.d.ts +13 -13
- package/utils/index.js +13 -29
- package/utils/resolveContextProvider.d.ts +3 -3
- package/utils/resolveContextProvider.js +9 -12
- package/utils/upsert-utils.d.ts +3 -3
- package/utils/upsert-utils.js +5 -9
- package/index.mjs +0 -199
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EntityData, EntityMetadata } from '../typings';
|
|
2
|
-
import { Hydrator } from './Hydrator';
|
|
3
|
-
import type { EntityFactory } from '../entity/EntityFactory';
|
|
1
|
+
import type { EntityData, EntityMetadata } from '../typings.js';
|
|
2
|
+
import { Hydrator } from './Hydrator.js';
|
|
3
|
+
import type { EntityFactory } from '../entity/EntityFactory.js';
|
|
4
4
|
type EntityHydrator<T extends object> = (entity: T, data: EntityData<T>, factory: EntityFactory, newEntity: boolean, convertCustomTypes: boolean, schema?: string, parentSchema?: string) => void;
|
|
5
5
|
export declare class ObjectHydrator extends Hydrator {
|
|
6
6
|
private readonly hydrators;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const enums_1 = require("../enums");
|
|
9
|
-
const RawQueryFragment_1 = require("../utils/RawQueryFragment");
|
|
10
|
-
class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
1
|
+
import { Hydrator } from './Hydrator.js';
|
|
2
|
+
import { Collection } from '../entity/Collection.js';
|
|
3
|
+
import { Reference, ScalarReference } from '../entity/Reference.js';
|
|
4
|
+
import { parseJsonSafe, Utils } from '../utils/Utils.js';
|
|
5
|
+
import { ReferenceKind } from '../enums.js';
|
|
6
|
+
import { RawQueryFragment } from '../utils/RawQueryFragment.js';
|
|
7
|
+
export class ObjectHydrator extends Hydrator {
|
|
11
8
|
hydrators = {
|
|
12
9
|
full: new Map(),
|
|
13
10
|
reference: new Map(),
|
|
@@ -22,7 +19,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
22
19
|
// the running state is used to consider propagation as hydration, saving the values directly to the entity data,
|
|
23
20
|
// but we don't want that for new entities, their propagation should result in entity updates when flushing
|
|
24
21
|
this.running = !newEntity;
|
|
25
|
-
|
|
22
|
+
Utils.callCompiledFunction(hydrate, entity, data, factory, newEntity, convertCustomTypes, schema, parentSchema);
|
|
26
23
|
this.running = running;
|
|
27
24
|
}
|
|
28
25
|
/**
|
|
@@ -32,7 +29,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
32
29
|
const hydrate = this.getEntityHydrator(meta, 'reference');
|
|
33
30
|
const running = this.running;
|
|
34
31
|
this.running = true;
|
|
35
|
-
|
|
32
|
+
Utils.callCompiledFunction(hydrate, entity, data, factory, false, convertCustomTypes, schema, parentSchema);
|
|
36
33
|
this.running = running;
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
@@ -46,12 +43,13 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
46
43
|
const lines = [];
|
|
47
44
|
const context = new Map();
|
|
48
45
|
const props = this.getProperties(meta, type);
|
|
49
|
-
context.set('isPrimaryKey',
|
|
50
|
-
context.set('Collection',
|
|
51
|
-
context.set('Reference',
|
|
46
|
+
context.set('isPrimaryKey', Utils.isPrimaryKey);
|
|
47
|
+
context.set('Collection', Collection);
|
|
48
|
+
context.set('Reference', Reference);
|
|
52
49
|
const registerCustomType = (prop, convertorKey, method, context) => {
|
|
53
50
|
context.set(`${method}_${convertorKey}`, (val) => {
|
|
54
|
-
|
|
51
|
+
/* v8 ignore next 3 */
|
|
52
|
+
if (RawQueryFragment.isKnownFragment(val)) {
|
|
55
53
|
return val;
|
|
56
54
|
}
|
|
57
55
|
return prop.customType[method](val, this.platform, { mode: 'serialization' });
|
|
@@ -69,7 +67,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
69
67
|
return [];
|
|
70
68
|
}
|
|
71
69
|
if (prop.ref) {
|
|
72
|
-
context.set('ScalarReference',
|
|
70
|
+
context.set('ScalarReference', ScalarReference);
|
|
73
71
|
ret.push(` const oldValue_${idx} = entity${entityKey};`);
|
|
74
72
|
}
|
|
75
73
|
ret.push(` if (data${dataKey} === null) {`);
|
|
@@ -142,7 +140,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
142
140
|
}
|
|
143
141
|
ret.push(` }`);
|
|
144
142
|
ret.push(` }`);
|
|
145
|
-
if (prop.kind ===
|
|
143
|
+
if (prop.kind === ReferenceKind.ONE_TO_ONE) {
|
|
146
144
|
const meta2 = this.metadata.get(prop.type);
|
|
147
145
|
const prop2 = meta2.properties[prop.inversedBy || prop.mappedBy];
|
|
148
146
|
if (prop2 && !prop2.mapToPk) {
|
|
@@ -175,7 +173,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
175
173
|
ret.push(` }`);
|
|
176
174
|
ret.push(` } else if (!entity${entityKey} && data${dataKey} instanceof Collection) {`);
|
|
177
175
|
ret.push(` entity${entityKey} = data${dataKey};`);
|
|
178
|
-
if (!this.platform.usesPivotTable() && prop.owner && prop.kind ===
|
|
176
|
+
if (!this.platform.usesPivotTable() && prop.owner && prop.kind === ReferenceKind.MANY_TO_MANY) {
|
|
179
177
|
ret.push(` } else if (!entity${entityKey} && Array.isArray(data${dataKey})) {`);
|
|
180
178
|
const items = this.platform.usesPivotTable() || !prop.owner ? 'undefined' : '[]';
|
|
181
179
|
ret.push(` const coll = Collection.create(entity, '${prop.name}', ${items}, !!data${dataKey} || newEntity);`);
|
|
@@ -200,7 +198,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
200
198
|
};
|
|
201
199
|
const parseObjectEmbeddable = (prop, dataKey, ret) => {
|
|
202
200
|
if (!this.platform.convertsJsonAutomatically() && (prop.object || prop.array)) {
|
|
203
|
-
context.set('parseJsonSafe',
|
|
201
|
+
context.set('parseJsonSafe', parseJsonSafe);
|
|
204
202
|
ret.push(` if (typeof data${dataKey} === 'string') {`, ` data${dataKey} = parseJsonSafe(data${dataKey});`, ` }`);
|
|
205
203
|
}
|
|
206
204
|
};
|
|
@@ -214,7 +212,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
214
212
|
meta.props
|
|
215
213
|
.filter(p => p.embedded?.[0] === prop.name)
|
|
216
214
|
.forEach(p => {
|
|
217
|
-
if (p.kind ===
|
|
215
|
+
if (p.kind === ReferenceKind.EMBEDDED && !p.object && !p.array) {
|
|
218
216
|
conds.push(...createCond(p, dataKey + this.wrap(p.embedded[1]), cond));
|
|
219
217
|
return;
|
|
220
218
|
}
|
|
@@ -277,7 +275,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
277
275
|
ret.push(...hydrateProperty(childProp, prop.object, [...path, childProp.embedded[1]], childDataKey).map(l => ' ' + l));
|
|
278
276
|
});
|
|
279
277
|
}
|
|
280
|
-
/*
|
|
278
|
+
/* v8 ignore next */
|
|
281
279
|
const nullVal = this.config.get('forceUndefined') ? 'undefined' : 'null';
|
|
282
280
|
if (prop.object) {
|
|
283
281
|
ret.push(` } else if (data${dataKey} === null) {`);
|
|
@@ -307,13 +305,13 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
307
305
|
const entityKey = path.map(k => this.wrap(k)).join('');
|
|
308
306
|
dataKey = dataKey ?? (object ? entityKey : this.wrap(prop.name));
|
|
309
307
|
const ret = [];
|
|
310
|
-
if ([
|
|
308
|
+
if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && !prop.mapToPk) {
|
|
311
309
|
ret.push(...hydrateToOne(prop, dataKey, entityKey));
|
|
312
310
|
}
|
|
313
|
-
else if (prop.kind ===
|
|
311
|
+
else if (prop.kind === ReferenceKind.ONE_TO_MANY || prop.kind === ReferenceKind.MANY_TO_MANY) {
|
|
314
312
|
ret.push(...hydrateToMany(prop, dataKey, entityKey));
|
|
315
313
|
}
|
|
316
|
-
else if (prop.kind ===
|
|
314
|
+
else if (prop.kind === ReferenceKind.EMBEDDED) {
|
|
317
315
|
if (prop.array) {
|
|
318
316
|
ret.push(...hydrateEmbeddedArray(prop, path, dataKey));
|
|
319
317
|
}
|
|
@@ -338,7 +336,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
338
336
|
const code = `// compiled hydrator for entity ${meta.className} (${type})\n`
|
|
339
337
|
+ `return function(entity, data, factory, newEntity, convertCustomTypes, schema) {\n`
|
|
340
338
|
+ `${lines.join('\n')}\n}`;
|
|
341
|
-
const hydrator =
|
|
339
|
+
const hydrator = Utils.createFunction(context, code);
|
|
342
340
|
this.hydrators[type].set(meta.className, hydrator);
|
|
343
341
|
return hydrator;
|
|
344
342
|
}
|
|
@@ -347,7 +345,7 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
347
345
|
const lines = [];
|
|
348
346
|
lines.push(` const createCollectionItem_${this.safeKey(prop.name)} = (value, entity) => {`);
|
|
349
347
|
const prop2 = prop.targetMeta.properties[prop.mappedBy];
|
|
350
|
-
if (prop.kind ===
|
|
348
|
+
if (prop.kind === ReferenceKind.ONE_TO_MANY && prop2.primary) {
|
|
351
349
|
lines.push(` if (typeof value === 'object' && value?.['${prop2.name}'] == null) {`);
|
|
352
350
|
lines.push(` value = { ...value, ['${prop2.name}']: Reference.wrapReference(entity, { ref: ${prop2.ref} }) };`);
|
|
353
351
|
lines.push(` }`);
|
|
@@ -368,4 +366,3 @@ class ObjectHydrator extends Hydrator_1.Hydrator {
|
|
|
368
366
|
return key.replace(/\W/g, '_');
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
|
-
exports.ObjectHydrator = ObjectHydrator;
|
package/hydration/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Hydrator';
|
|
2
|
-
export * from './ObjectHydrator';
|
|
1
|
+
export * from './Hydrator.js';
|
|
2
|
+
export * from './ObjectHydrator.js';
|
package/hydration/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Hydrator"), exports);
|
|
18
|
-
__exportStar(require("./ObjectHydrator"), exports);
|
|
1
|
+
export * from './Hydrator.js';
|
|
2
|
+
export * from './ObjectHydrator.js';
|
package/index.d.ts
CHANGED
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
* @module core
|
|
4
4
|
*/
|
|
5
|
-
export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings';
|
|
6
|
-
export * from './enums';
|
|
7
|
-
export * from './errors';
|
|
8
|
-
export * from './exceptions';
|
|
9
|
-
export * from './MikroORM';
|
|
10
|
-
export * from './entity';
|
|
11
|
-
export * from './serialization';
|
|
12
|
-
export * from './events';
|
|
13
|
-
export * from './EntityManager';
|
|
14
|
-
export * from './unit-of-work';
|
|
15
|
-
export * from './utils';
|
|
16
|
-
export * from './logging';
|
|
17
|
-
export * from './hydration';
|
|
18
|
-
export * from './drivers';
|
|
19
|
-
export * from './connections';
|
|
20
|
-
export * from './platforms';
|
|
21
|
-
export * from './types';
|
|
22
|
-
export * from './naming-strategy';
|
|
23
|
-
export * from './metadata';
|
|
24
|
-
export * from './cache';
|
|
25
|
-
export * from './decorators';
|
|
5
|
+
export { Constructor, ConnectionType, Dictionary, PrimaryKeyProp, Primary, IPrimaryKey, ObjectQuery, FilterQuery, IWrappedEntity, EntityName, EntityData, Highlighter, MaybePromise, AnyEntity, EntityClass, EntityProperty, EntityMetadata, QBFilterQuery, PopulateOptions, Populate, Loaded, New, LoadedReference, LoadedCollection, IMigrator, IMigrationGenerator, MigratorEvent, GetRepository, EntityRepositoryType, MigrationObject, DeepPartial, PrimaryProperty, Cast, IsUnknown, EntityDictionary, EntityDTO, MigrationDiff, GenerateOptions, FilterObject, IEntityGenerator, ISeedManager, EntityClassGroup, OptionalProps, EagerProps, HiddenProps, RequiredEntityData, CheckCallback, SimpleColumnMeta, Rel, Ref, ScalarRef, EntityRef, ISchemaGenerator, UmzugMigration, MigrateOptions, MigrationResult, MigrationRow, EntityKey, EntityValue, FilterKey, Opt, EntityType, FromEntityType, Selected, IsSubset, NoInfer, EntityProps, ExpandProperty, ExpandScalar, FilterItemValue, ExpandQuery, Scalar, ExpandHint, Hidden, FilterValue, MergeLoaded, MergeSelected, Config, DefineConfig, TypeConfig, ClearDatabaseOptions, CreateSchemaOptions, EnsureDatabaseOptions, UpdateSchemaOptions, DropSchemaOptions, RefreshDatabaseOptions, AutoPath, UnboxArray, MetadataProcessor, ImportsResolver, } from './typings.js';
|
|
6
|
+
export * from './enums.js';
|
|
7
|
+
export * from './errors.js';
|
|
8
|
+
export * from './exceptions.js';
|
|
9
|
+
export * from './MikroORM.js';
|
|
10
|
+
export * from './entity/index.js';
|
|
11
|
+
export * from './serialization/index.js';
|
|
12
|
+
export * from './events/index.js';
|
|
13
|
+
export * from './EntityManager.js';
|
|
14
|
+
export * from './unit-of-work/index.js';
|
|
15
|
+
export * from './utils/index.js';
|
|
16
|
+
export * from './logging/index.js';
|
|
17
|
+
export * from './hydration/index.js';
|
|
18
|
+
export * from './drivers/index.js';
|
|
19
|
+
export * from './connections/index.js';
|
|
20
|
+
export * from './platforms/index.js';
|
|
21
|
+
export * from './types/index.js';
|
|
22
|
+
export * from './naming-strategy/index.js';
|
|
23
|
+
export * from './metadata/index.js';
|
|
24
|
+
export * from './cache/index.js';
|
|
25
|
+
export * from './decorators/index.js';
|
package/index.js
CHANGED
|
@@ -1,50 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Config = exports.HiddenProps = exports.EagerProps = exports.OptionalProps = exports.EntityRepositoryType = exports.EntityMetadata = exports.PrimaryKeyProp = void 0;
|
|
18
1
|
/**
|
|
19
2
|
* @packageDocumentation
|
|
20
3
|
* @module core
|
|
21
4
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
__exportStar(require("./drivers"), exports);
|
|
44
|
-
__exportStar(require("./connections"), exports);
|
|
45
|
-
__exportStar(require("./platforms"), exports);
|
|
46
|
-
__exportStar(require("./types"), exports);
|
|
47
|
-
__exportStar(require("./naming-strategy"), exports);
|
|
48
|
-
__exportStar(require("./metadata"), exports);
|
|
49
|
-
__exportStar(require("./cache"), exports);
|
|
50
|
-
__exportStar(require("./decorators"), exports);
|
|
5
|
+
export { PrimaryKeyProp, EntityMetadata, EntityRepositoryType, OptionalProps, EagerProps, HiddenProps, Config, } from './typings.js';
|
|
6
|
+
export * from './enums.js';
|
|
7
|
+
export * from './errors.js';
|
|
8
|
+
export * from './exceptions.js';
|
|
9
|
+
export * from './MikroORM.js';
|
|
10
|
+
export * from './entity/index.js';
|
|
11
|
+
export * from './serialization/index.js';
|
|
12
|
+
export * from './events/index.js';
|
|
13
|
+
export * from './EntityManager.js';
|
|
14
|
+
export * from './unit-of-work/index.js';
|
|
15
|
+
export * from './utils/index.js';
|
|
16
|
+
export * from './logging/index.js';
|
|
17
|
+
export * from './hydration/index.js';
|
|
18
|
+
export * from './drivers/index.js';
|
|
19
|
+
export * from './connections/index.js';
|
|
20
|
+
export * from './platforms/index.js';
|
|
21
|
+
export * from './types/index.js';
|
|
22
|
+
export * from './naming-strategy/index.js';
|
|
23
|
+
export * from './metadata/index.js';
|
|
24
|
+
export * from './cache/index.js';
|
|
25
|
+
export * from './decorators/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Logger, LoggerNamespace, LogContext, LoggerOptions } from './Logger';
|
|
1
|
+
import type { Logger, LoggerNamespace, LogContext, LoggerOptions } from './Logger.js';
|
|
2
2
|
export declare class DefaultLogger implements Logger {
|
|
3
3
|
private readonly options;
|
|
4
4
|
debugMode: boolean | LoggerNamespace[];
|
package/logging/DefaultLogger.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DefaultLogger = void 0;
|
|
4
|
-
const colors_1 = require("./colors");
|
|
5
|
-
class DefaultLogger {
|
|
1
|
+
import { colors } from './colors.js';
|
|
2
|
+
export class DefaultLogger {
|
|
6
3
|
options;
|
|
7
4
|
debugMode;
|
|
8
5
|
writer;
|
|
@@ -26,16 +23,16 @@ class DefaultLogger {
|
|
|
26
23
|
message = message.replace(/\n/g, '').replace(/ +/g, ' ').trim();
|
|
27
24
|
// use red for error levels
|
|
28
25
|
if (context?.level === 'error') {
|
|
29
|
-
message =
|
|
26
|
+
message = colors.red(message);
|
|
30
27
|
}
|
|
31
28
|
// use yellow for warning levels
|
|
32
29
|
if (context?.level === 'warning') {
|
|
33
|
-
message =
|
|
30
|
+
message = colors.yellow(message);
|
|
34
31
|
}
|
|
35
32
|
const label = context?.label
|
|
36
|
-
?
|
|
33
|
+
? colors.cyan(`(${context.label}) `)
|
|
37
34
|
: '';
|
|
38
|
-
this.writer(
|
|
35
|
+
this.writer(colors.grey(`[${namespace}] `) + label + message);
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
41
38
|
* @inheritDoc
|
|
@@ -75,7 +72,7 @@ class DefaultLogger {
|
|
|
75
72
|
if (!this.isEnabled('query', context)) {
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
|
-
/*
|
|
75
|
+
/* v8 ignore next */
|
|
79
76
|
let msg = this.highlighter?.highlight(context.query) ?? context.query;
|
|
80
77
|
if (context.took != null) {
|
|
81
78
|
const meta = [`took ${context.took} ms`];
|
|
@@ -85,10 +82,10 @@ class DefaultLogger {
|
|
|
85
82
|
if (context.affected != null) {
|
|
86
83
|
meta.push(`${context.affected} row${context.affected === 0 || context.affected > 1 ? 's' : ''} affected`);
|
|
87
84
|
}
|
|
88
|
-
msg +=
|
|
85
|
+
msg += colors.grey(` [${meta.join(', ')}]`);
|
|
89
86
|
}
|
|
90
87
|
if (this.usesReplicas && context.connection) {
|
|
91
|
-
msg +=
|
|
88
|
+
msg += colors.cyan(` (via ${context.connection.type} connection '${context.connection.name}')`);
|
|
92
89
|
}
|
|
93
90
|
return this.log('query', msg, context);
|
|
94
91
|
}
|
|
@@ -96,4 +93,3 @@ class DefaultLogger {
|
|
|
96
93
|
return new DefaultLogger(options);
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
|
-
exports.DefaultLogger = DefaultLogger;
|
package/logging/Logger.d.ts
CHANGED
package/logging/Logger.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LogContext, LoggerNamespace, LoggerOptions } from './Logger';
|
|
2
|
-
import { DefaultLogger } from './DefaultLogger';
|
|
1
|
+
import type { LogContext, LoggerNamespace, LoggerOptions } from './Logger.js';
|
|
2
|
+
import { DefaultLogger } from './DefaultLogger.js';
|
|
3
3
|
/**
|
|
4
4
|
* A basic logger that provides fully formatted output without color
|
|
5
5
|
*/
|
package/logging/SimpleLogger.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleLogger = void 0;
|
|
4
|
-
const DefaultLogger_1 = require("./DefaultLogger");
|
|
1
|
+
import { DefaultLogger } from './DefaultLogger.js';
|
|
5
2
|
/**
|
|
6
3
|
* A basic logger that provides fully formatted output without color
|
|
7
4
|
*/
|
|
8
|
-
class SimpleLogger extends
|
|
5
|
+
export class SimpleLogger extends DefaultLogger {
|
|
9
6
|
/**
|
|
10
7
|
* @inheritDoc
|
|
11
8
|
*/
|
|
@@ -31,4 +28,3 @@ class SimpleLogger extends DefaultLogger_1.DefaultLogger {
|
|
|
31
28
|
return new SimpleLogger(options);
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
|
-
exports.SimpleLogger = SimpleLogger;
|
package/logging/colors.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* istanbul ignore file */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.colors = void 0;
|
|
5
1
|
const bool = (v) => v && ['true', 't', '1'].includes(v.toLowerCase());
|
|
6
2
|
const boolIfDefined = (v) => v != null ? bool(v) : true;
|
|
7
3
|
const enabled = () => !bool(process.env.NO_COLOR)
|
|
@@ -10,7 +6,7 @@ const enabled = () => !bool(process.env.NO_COLOR)
|
|
|
10
6
|
&& boolIfDefined(process.env.MIKRO_ORM_COLORS);
|
|
11
7
|
const wrap = (fn) => (text) => enabled() ? fn(text) : text;
|
|
12
8
|
/** @internal */
|
|
13
|
-
|
|
9
|
+
export const colors = {
|
|
14
10
|
red: wrap((text) => `\x1B[31m${text}\x1B[39m`),
|
|
15
11
|
green: wrap((text) => `\x1B[32m${text}\x1B[39m`),
|
|
16
12
|
yellow: wrap((text) => `\x1B[33m${text}\x1B[39m`),
|
package/logging/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './colors';
|
|
2
|
-
export * from './Logger';
|
|
3
|
-
export * from './DefaultLogger';
|
|
4
|
-
export * from './SimpleLogger';
|
|
1
|
+
export * from './colors.js';
|
|
2
|
+
export * from './Logger.js';
|
|
3
|
+
export * from './DefaultLogger.js';
|
|
4
|
+
export * from './SimpleLogger.js';
|
package/logging/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./colors"), exports);
|
|
18
|
-
__exportStar(require("./Logger"), exports);
|
|
19
|
-
__exportStar(require("./DefaultLogger"), exports);
|
|
20
|
-
__exportStar(require("./SimpleLogger"), exports);
|
|
1
|
+
export * from './colors.js';
|
|
2
|
+
export * from './Logger.js';
|
|
3
|
+
export * from './DefaultLogger.js';
|
|
4
|
+
export * from './SimpleLogger.js';
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { EntityMetadata, type AnyEntity, type EntityKey, type Constructor, type DeepPartial, type EntityName, type EntityProperty, type CleanKeys, type ExpandProperty, type IsNever, type EntityClass } from '../typings';
|
|
2
|
-
import type { EmbeddedOptions
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { EntityMetadata, type AnyEntity, type EntityKey, type Constructor, type DeepPartial, type EntityName, type EntityProperty, type CleanKeys, type ExpandProperty, type IsNever, type EntityClass } from '../typings.js';
|
|
2
|
+
import type { EmbeddedOptions } from '../decorators/Embedded.js';
|
|
3
|
+
import type { EnumOptions } from '../decorators/Enum.js';
|
|
4
|
+
import type { IndexOptions, UniqueOptions } from '../decorators/Indexed.js';
|
|
5
|
+
import type { ManyToManyOptions } from '../decorators/ManyToMany.js';
|
|
6
|
+
import type { ManyToOneOptions } from '../decorators/ManyToOne.js';
|
|
7
|
+
import type { OneToManyOptions } from '../decorators/OneToMany.js';
|
|
8
|
+
import type { OneToOneOptions } from '../decorators/OneToOne.js';
|
|
9
|
+
import type { PrimaryKeyOptions, SerializedPrimaryKeyOptions } from '../decorators/PrimaryKey.js';
|
|
10
|
+
import type { PropertyOptions } from '../decorators/Property.js';
|
|
11
|
+
import { ReferenceKind } from '../enums.js';
|
|
12
|
+
import { Type } from '../types/Type.js';
|
|
5
13
|
type TypeType = string | NumberConstructor | StringConstructor | BooleanConstructor | DateConstructor | ArrayConstructor | Constructor<Type<any>> | Type<any>;
|
|
6
14
|
type TypeDef<Target> = {
|
|
7
15
|
type: TypeType;
|