@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.100
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 +96 -58
- package/EntityManager.js +465 -395
- package/MikroORM.d.ts +45 -35
- package/MikroORM.js +109 -160
- package/README.md +3 -2
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +2 -2
- package/cache/FileCacheAdapter.js +20 -27
- package/cache/GeneratedCacheAdapter.d.ts +2 -3
- package/cache/GeneratedCacheAdapter.js +1 -7
- 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 +4 -5
- package/cache/index.js +4 -21
- package/connections/Connection.d.ts +22 -14
- package/connections/Connection.js +27 -23
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/drivers/DatabaseDriver.d.ts +25 -15
- package/drivers/DatabaseDriver.js +77 -64
- package/drivers/IDatabaseDriver.d.ts +40 -16
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/BaseEntity.d.ts +6 -7
- package/entity/BaseEntity.js +16 -23
- package/entity/Collection.d.ts +98 -34
- package/entity/Collection.js +466 -131
- package/entity/EntityAssigner.d.ts +3 -3
- package/entity/EntityAssigner.js +67 -64
- package/entity/EntityFactory.d.ts +10 -3
- package/entity/EntityFactory.js +112 -91
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +66 -53
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +8 -7
- package/entity/EntityLoader.js +161 -128
- package/entity/EntityRepository.d.ts +8 -8
- package/entity/EntityRepository.js +7 -11
- package/entity/Reference.d.ts +10 -13
- package/entity/Reference.js +64 -46
- package/entity/WrappedEntity.d.ts +12 -17
- package/entity/WrappedEntity.js +22 -31
- package/entity/defineEntity.d.ts +568 -0
- package/entity/defineEntity.js +529 -0
- package/entity/index.d.ts +14 -13
- package/entity/index.js +14 -29
- package/entity/utils.d.ts +8 -1
- package/entity/utils.js +22 -13
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +24 -9
- package/enums.js +50 -41
- package/errors.d.ts +11 -3
- package/errors.js +42 -32
- package/events/EventManager.d.ts +5 -4
- package/events/EventManager.js +26 -22
- package/events/EventSubscriber.d.ts +8 -5
- 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 +2 -6
- package/hydration/ObjectHydrator.d.ts +7 -7
- package/hydration/ObjectHydrator.js +58 -50
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +20 -46
- package/logging/DefaultLogger.d.ts +2 -2
- package/logging/DefaultLogger.js +10 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +3 -3
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +5 -4
- package/logging/index.js +5 -20
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +16 -0
- package/metadata/EntitySchema.d.ts +14 -10
- package/metadata/EntitySchema.js +78 -64
- package/metadata/MetadataDiscovery.d.ts +11 -14
- package/metadata/MetadataDiscovery.js +278 -317
- package/metadata/MetadataProvider.d.ts +13 -4
- package/metadata/MetadataProvider.js +47 -8
- package/metadata/MetadataStorage.d.ts +2 -7
- package/metadata/MetadataStorage.js +19 -35
- package/metadata/MetadataValidator.d.ts +3 -10
- package/metadata/MetadataValidator.js +51 -64
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/metadata/types.d.ts +480 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +7 -3
- package/naming-strategy/AbstractNamingStrategy.js +11 -9
- 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 +12 -2
- 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/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -20
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +15 -22
- package/platforms/Platform.js +58 -88
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +4 -2
- package/serialization/EntitySerializer.js +64 -51
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +48 -42
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +24 -25
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +6 -11
- package/types/BigIntType.d.ts +12 -9
- package/types/BigIntType.js +6 -6
- package/types/BlobType.d.ts +3 -4
- package/types/BlobType.js +2 -11
- package/types/BooleanType.d.ts +5 -4
- package/types/BooleanType.js +5 -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 +9 -7
- package/types/DecimalType.js +5 -8
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +4 -7
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +4 -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 +4 -4
- package/types/JsonType.js +9 -8
- 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 +4 -6
- package/types/Type.js +6 -10
- package/types/Uint8ArrayType.d.ts +3 -4
- package/types/Uint8ArrayType.js +3 -12
- 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 +134 -93
- package/typings.js +67 -65
- package/unit-of-work/ChangeSet.d.ts +1 -4
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -9
- package/unit-of-work/ChangeSetComputer.js +36 -38
- package/unit-of-work/ChangeSetPersister.d.ts +11 -9
- package/unit-of-work/ChangeSetPersister.js +100 -65
- 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 +16 -8
- package/unit-of-work/UnitOfWork.js +266 -209
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +11 -11
- package/utils/AbstractSchemaGenerator.js +21 -20
- package/utils/Configuration.d.ts +774 -224
- package/utils/Configuration.js +166 -216
- package/utils/ConfigurationLoader.d.ts +1 -53
- package/utils/ConfigurationLoader.js +1 -367
- package/utils/Cursor.d.ts +6 -9
- package/utils/Cursor.js +25 -25
- package/utils/DataloaderUtils.d.ts +18 -8
- package/utils/DataloaderUtils.js +63 -21
- package/utils/EntityComparator.d.ts +9 -5
- package/utils/EntityComparator.js +155 -108
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +12 -4
- package/utils/QueryHelper.js +110 -53
- package/utils/RawQueryFragment.d.ts +37 -14
- package/utils/RawQueryFragment.js +50 -33
- 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/TransactionManager.d.ts +65 -0
- package/utils/TransactionManager.js +223 -0
- package/utils/Utils.d.ts +16 -100
- package/utils/Utils.js +114 -332
- package/utils/clone.js +7 -11
- package/utils/env-vars.d.ts +3 -0
- package/utils/env-vars.js +87 -0
- package/utils/fs-utils.d.ts +12 -0
- package/utils/fs-utils.js +97 -0
- package/utils/index.d.ts +14 -13
- package/utils/index.js +14 -29
- package/utils/upsert-utils.d.ts +8 -3
- package/utils/upsert-utils.js +57 -10
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -16
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -33
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -14
- package/decorators/Embedded.d.ts +0 -18
- package/decorators/Embedded.js +0 -20
- package/decorators/Entity.d.ts +0 -18
- package/decorators/Entity.js +0 -16
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -19
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -11
- package/decorators/Formula.d.ts +0 -5
- package/decorators/Formula.js +0 -18
- package/decorators/Indexed.d.ts +0 -17
- package/decorators/Indexed.js +0 -24
- package/decorators/ManyToMany.d.ts +0 -40
- package/decorators/ManyToMany.js +0 -16
- package/decorators/ManyToOne.d.ts +0 -30
- package/decorators/ManyToOne.js +0 -16
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -20
- package/decorators/OneToOne.d.ts +0 -24
- package/decorators/OneToOne.js +0 -10
- package/decorators/PrimaryKey.d.ts +0 -9
- package/decorators/PrimaryKey.js +0 -23
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -34
- package/decorators/Transactional.d.ts +0 -13
- package/decorators/Transactional.js +0 -31
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -59
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -36
- package/entity/ArrayCollection.d.ts +0 -116
- package/entity/ArrayCollection.js +0 -399
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -154
- package/index.mjs +0 -199
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -48
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './NamingStrategy';
|
|
2
|
-
export * from './AbstractNamingStrategy';
|
|
3
|
-
export * from './MongoNamingStrategy';
|
|
4
|
-
export * from './UnderscoreNamingStrategy';
|
|
5
|
-
export * from './EntityCaseNamingStrategy';
|
|
1
|
+
export * from './NamingStrategy.js';
|
|
2
|
+
export * from './AbstractNamingStrategy.js';
|
|
3
|
+
export * from './MongoNamingStrategy.js';
|
|
4
|
+
export * from './UnderscoreNamingStrategy.js';
|
|
5
|
+
export * from './EntityCaseNamingStrategy.js';
|
package/naming-strategy/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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("./NamingStrategy"), exports);
|
|
18
|
-
__exportStar(require("./AbstractNamingStrategy"), exports);
|
|
19
|
-
__exportStar(require("./MongoNamingStrategy"), exports);
|
|
20
|
-
__exportStar(require("./UnderscoreNamingStrategy"), exports);
|
|
21
|
-
__exportStar(require("./EntityCaseNamingStrategy"), exports);
|
|
1
|
+
export * from './NamingStrategy.js';
|
|
2
|
+
export * from './AbstractNamingStrategy.js';
|
|
3
|
+
export * from './MongoNamingStrategy.js';
|
|
4
|
+
export * from './UnderscoreNamingStrategy.js';
|
|
5
|
+
export * from './EntityCaseNamingStrategy.js';
|
package/not-supported.js
ADDED
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "7.0.0-dev.100",
|
|
4
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.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"module": "index.mjs",
|
|
7
|
-
"typings": "index.d.ts",
|
|
8
6
|
"exports": {
|
|
9
7
|
"./package.json": "./package.json",
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./file-discovery": {
|
|
10
|
+
"node": "./metadata/discover-entities.js",
|
|
11
|
+
"browser": "./not-supported.js"
|
|
12
|
+
},
|
|
13
|
+
"./fs-utils": {
|
|
14
|
+
"node": "./utils/fs-utils.js",
|
|
15
|
+
"browser": "./not-supported.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://mikro-orm.io",
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": ">= 22.
|
|
50
|
+
"node": ">= 22.17.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
|
-
"build": "yarn clean && yarn compile && yarn copy
|
|
53
|
+
"build": "yarn clean && yarn compile && yarn copy",
|
|
54
54
|
"clean": "yarn run -T rimraf ./dist",
|
|
55
55
|
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
56
56
|
"copy": "node ../../scripts/copy.mjs"
|
|
@@ -58,13 +58,12 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"
|
|
62
|
-
"dataloader": "2.2.3"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"reflect-metadata": "0.2.2"
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"dataloader": "2.2.3"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"dataloader": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
69
68
|
}
|
|
70
69
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Dictionary } from '../typings';
|
|
2
|
-
import { DriverException } from '../exceptions';
|
|
1
|
+
import type { Dictionary } from '../typings.js';
|
|
2
|
+
import { DriverException } from '../exceptions.js';
|
|
3
3
|
export declare class ExceptionConverter {
|
|
4
4
|
convertException(exception: Error & Dictionary): DriverException;
|
|
5
5
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const exceptions_1 = require("../exceptions");
|
|
5
|
-
class ExceptionConverter {
|
|
6
|
-
/* istanbul ignore next */
|
|
1
|
+
import { DriverException } from '../exceptions.js';
|
|
2
|
+
export class ExceptionConverter {
|
|
3
|
+
/* v8 ignore next */
|
|
7
4
|
convertException(exception) {
|
|
8
|
-
return new
|
|
5
|
+
return new DriverException(exception);
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
exports.ExceptionConverter = ExceptionConverter;
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import type {
|
|
11
|
-
import type { TransformContext } from '../types/Type';
|
|
1
|
+
import { EntityRepository } from '../entity/EntityRepository.js';
|
|
2
|
+
import { type NamingStrategy } from '../naming-strategy/NamingStrategy.js';
|
|
3
|
+
import type { Constructor, EntityMetadata, EntityProperty, IPrimaryKey, ISchemaGenerator, PopulateOptions, Primary, SimpleColumnMeta } from '../typings.js';
|
|
4
|
+
import { ExceptionConverter } from './ExceptionConverter.js';
|
|
5
|
+
import type { EntityManager } from '../EntityManager.js';
|
|
6
|
+
import type { Configuration } from '../utils/Configuration.js';
|
|
7
|
+
import type { IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
8
|
+
import { Type } from '../types/index.js';
|
|
9
|
+
import type { MikroORM } from '../MikroORM.js';
|
|
10
|
+
import type { TransformContext } from '../types/Type.js';
|
|
12
11
|
export declare const JsonProperty: unique symbol;
|
|
13
12
|
export declare abstract class Platform {
|
|
14
13
|
protected readonly exceptionConverter: ExceptionConverter;
|
|
@@ -30,7 +29,6 @@ export declare abstract class Platform {
|
|
|
30
29
|
usesEnumCheckConstraints(): boolean;
|
|
31
30
|
getSchemaHelper(): unknown;
|
|
32
31
|
indexForeignKeys(): boolean;
|
|
33
|
-
allowsMultiInsert(): boolean;
|
|
34
32
|
/**
|
|
35
33
|
* Whether or not the driver supports retuning list of created PKs back when multi-inserting
|
|
36
34
|
*/
|
|
@@ -48,11 +46,6 @@ export declare abstract class Platform {
|
|
|
48
46
|
* Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)
|
|
49
47
|
*/
|
|
50
48
|
denormalizePrimaryKey(data: IPrimaryKey): IPrimaryKey;
|
|
51
|
-
/**
|
|
52
|
-
* Used when serializing via toObject and toJSON methods, allows to use different PK field name (like `id` instead of `_id`)
|
|
53
|
-
*/
|
|
54
|
-
getSerializedPrimaryKeyField(field: string): string;
|
|
55
|
-
usesDifferentSerializedPrimaryKey(): boolean;
|
|
56
49
|
/**
|
|
57
50
|
* Returns the SQL specific for the platform to get the current timestamp
|
|
58
51
|
*/
|
|
@@ -158,7 +151,7 @@ export declare abstract class Platform {
|
|
|
158
151
|
getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
|
|
159
152
|
convertsJsonAutomatically(): boolean;
|
|
160
153
|
convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
|
|
161
|
-
convertJsonToJSValue(value: unknown,
|
|
154
|
+
convertJsonToJSValue(value: unknown, context?: TransformContext): unknown;
|
|
162
155
|
convertDateToJSValue(value: string | Date): string;
|
|
163
156
|
convertIntervalToJSValue(value: string): unknown;
|
|
164
157
|
convertIntervalToDatabaseValue(value: unknown): unknown;
|
|
@@ -175,7 +168,9 @@ export declare abstract class Platform {
|
|
|
175
168
|
getExtension<T>(extensionName: string, extensionKey: string, moduleName: string, em: EntityManager): T;
|
|
176
169
|
getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): ISchemaGenerator;
|
|
177
170
|
processDateProperty(value: unknown): string | number | Date;
|
|
178
|
-
quoteIdentifier(id: string
|
|
171
|
+
quoteIdentifier(id: string | {
|
|
172
|
+
toString: () => string;
|
|
173
|
+
}, quote?: string): string;
|
|
179
174
|
quoteValue(value: any): string;
|
|
180
175
|
escape(value: any): string;
|
|
181
176
|
formatQuery(sql: string, params: readonly any[]): string;
|
|
@@ -193,7 +188,7 @@ export declare abstract class Platform {
|
|
|
193
188
|
getDefaultPrimaryName(tableName: string, columns: string[]): string;
|
|
194
189
|
supportsCustomPrimaryKeyNames(): boolean;
|
|
195
190
|
isPopulated<T>(key: string, populate: readonly PopulateOptions<T>[] | boolean): boolean;
|
|
196
|
-
shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean): boolean;
|
|
191
|
+
shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean, ignoreInlineEmbeddables?: boolean): boolean;
|
|
197
192
|
/**
|
|
198
193
|
* Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
|
|
199
194
|
*/
|
|
@@ -225,6 +220,4 @@ export declare abstract class Platform {
|
|
|
225
220
|
* @internal
|
|
226
221
|
*/
|
|
227
222
|
clone(): this;
|
|
228
|
-
/** @ignore */
|
|
229
|
-
[inspect.custom](): string;
|
|
230
223
|
}
|
package/platforms/Platform.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const RawQueryFragment_1 = require("../utils/RawQueryFragment");
|
|
13
|
-
exports.JsonProperty = Symbol('JsonProperty');
|
|
14
|
-
class Platform {
|
|
15
|
-
exceptionConverter = new ExceptionConverter_1.ExceptionConverter();
|
|
1
|
+
import { clone } from '../utils/clone.js';
|
|
2
|
+
import { EntityRepository } from '../entity/EntityRepository.js';
|
|
3
|
+
import { UnderscoreNamingStrategy } from '../naming-strategy/UnderscoreNamingStrategy.js';
|
|
4
|
+
import { ExceptionConverter } from './ExceptionConverter.js';
|
|
5
|
+
import { ArrayType, BigIntType, BlobType, BooleanType, CharacterType, DateTimeType, DateType, DecimalType, DoubleType, EnumType, FloatType, IntegerType, IntervalType, JsonType, MediumIntType, SmallIntType, StringType, TextType, TimeType, TinyIntType, Type, Uint8ArrayType, UnknownType, UuidType, } from '../types/index.js';
|
|
6
|
+
import { parseJsonSafe } from '../utils/Utils.js';
|
|
7
|
+
import { ReferenceKind } from '../enums.js';
|
|
8
|
+
import { RawQueryFragment } from '../utils/RawQueryFragment.js';
|
|
9
|
+
export const JsonProperty = Symbol('JsonProperty');
|
|
10
|
+
export class Platform {
|
|
11
|
+
exceptionConverter = new ExceptionConverter();
|
|
16
12
|
config;
|
|
17
13
|
namingStrategy;
|
|
18
14
|
timezone;
|
|
@@ -26,7 +22,7 @@ class Platform {
|
|
|
26
22
|
return true;
|
|
27
23
|
}
|
|
28
24
|
getNamingStrategy() {
|
|
29
|
-
return
|
|
25
|
+
return UnderscoreNamingStrategy;
|
|
30
26
|
}
|
|
31
27
|
usesReturningStatement() {
|
|
32
28
|
return false;
|
|
@@ -51,9 +47,6 @@ class Platform {
|
|
|
51
47
|
indexForeignKeys() {
|
|
52
48
|
return false;
|
|
53
49
|
}
|
|
54
|
-
allowsMultiInsert() {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
50
|
/**
|
|
58
51
|
* Whether or not the driver supports retuning list of created PKs back when multi-inserting
|
|
59
52
|
*/
|
|
@@ -81,15 +74,6 @@ class Platform {
|
|
|
81
74
|
denormalizePrimaryKey(data) {
|
|
82
75
|
return data;
|
|
83
76
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Used when serializing via toObject and toJSON methods, allows to use different PK field name (like `id` instead of `_id`)
|
|
86
|
-
*/
|
|
87
|
-
getSerializedPrimaryKeyField(field) {
|
|
88
|
-
return field;
|
|
89
|
-
}
|
|
90
|
-
usesDifferentSerializedPrimaryKey() {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
77
|
/**
|
|
94
78
|
* Returns the SQL specific for the platform to get the current timestamp
|
|
95
79
|
*/
|
|
@@ -136,7 +120,7 @@ class Platform {
|
|
|
136
120
|
return true;
|
|
137
121
|
}
|
|
138
122
|
isBigIntProperty(prop) {
|
|
139
|
-
return prop.columnTypes
|
|
123
|
+
return prop.columnTypes?.[0] === 'bigint';
|
|
140
124
|
}
|
|
141
125
|
getDefaultSchemaName() {
|
|
142
126
|
return undefined;
|
|
@@ -172,7 +156,7 @@ class Platform {
|
|
|
172
156
|
return `text`;
|
|
173
157
|
}
|
|
174
158
|
getEnumTypeDeclarationSQL(column) {
|
|
175
|
-
if (column.items?.every(item =>
|
|
159
|
+
if (column.items?.every(item => typeof item === 'string')) {
|
|
176
160
|
return `enum('${column.items.join("','")}')`;
|
|
177
161
|
}
|
|
178
162
|
return this.getTinyIntTypeDeclarationSQL(column);
|
|
@@ -207,39 +191,39 @@ class Platform {
|
|
|
207
191
|
}
|
|
208
192
|
getDefaultMappedType(type) {
|
|
209
193
|
if (type.endsWith('[]')) {
|
|
210
|
-
return
|
|
194
|
+
return Type.getType(ArrayType);
|
|
211
195
|
}
|
|
212
196
|
switch (this.extractSimpleType(type)) {
|
|
213
197
|
case 'character':
|
|
214
|
-
case 'char': return
|
|
198
|
+
case 'char': return Type.getType(CharacterType);
|
|
215
199
|
case 'string':
|
|
216
|
-
case 'varchar': return
|
|
217
|
-
case 'interval': return
|
|
218
|
-
case 'text': return
|
|
200
|
+
case 'varchar': return Type.getType(StringType);
|
|
201
|
+
case 'interval': return Type.getType(IntervalType);
|
|
202
|
+
case 'text': return Type.getType(TextType);
|
|
219
203
|
case 'int':
|
|
220
|
-
case 'number': return
|
|
221
|
-
case 'bigint': return
|
|
222
|
-
case 'smallint': return
|
|
223
|
-
case 'tinyint': return
|
|
224
|
-
case 'mediumint': return
|
|
225
|
-
case 'float': return
|
|
226
|
-
case 'double': return
|
|
227
|
-
case 'integer': return
|
|
204
|
+
case 'number': return Type.getType(IntegerType);
|
|
205
|
+
case 'bigint': return Type.getType(BigIntType);
|
|
206
|
+
case 'smallint': return Type.getType(SmallIntType);
|
|
207
|
+
case 'tinyint': return Type.getType(TinyIntType);
|
|
208
|
+
case 'mediumint': return Type.getType(MediumIntType);
|
|
209
|
+
case 'float': return Type.getType(FloatType);
|
|
210
|
+
case 'double': return Type.getType(DoubleType);
|
|
211
|
+
case 'integer': return Type.getType(IntegerType);
|
|
228
212
|
case 'decimal':
|
|
229
|
-
case 'numeric': return
|
|
230
|
-
case 'boolean': return
|
|
213
|
+
case 'numeric': return Type.getType(DecimalType);
|
|
214
|
+
case 'boolean': return Type.getType(BooleanType);
|
|
231
215
|
case 'blob':
|
|
232
|
-
case 'buffer': return
|
|
233
|
-
case 'uint8array': return
|
|
234
|
-
case 'uuid': return
|
|
235
|
-
case 'date': return
|
|
216
|
+
case 'buffer': return Type.getType(BlobType);
|
|
217
|
+
case 'uint8array': return Type.getType(Uint8ArrayType);
|
|
218
|
+
case 'uuid': return Type.getType(UuidType);
|
|
219
|
+
case 'date': return Type.getType(DateType);
|
|
236
220
|
case 'datetime':
|
|
237
|
-
case 'timestamp': return
|
|
238
|
-
case 'time': return
|
|
221
|
+
case 'timestamp': return Type.getType(DateTimeType);
|
|
222
|
+
case 'time': return Type.getType(TimeType);
|
|
239
223
|
case 'object':
|
|
240
|
-
case 'json': return
|
|
241
|
-
case 'enum': return
|
|
242
|
-
default: return
|
|
224
|
+
case 'json': return Type.getType(JsonType);
|
|
225
|
+
case 'enum': return Type.getType(EnumType);
|
|
226
|
+
default: return Type.getType(UnknownType);
|
|
243
227
|
}
|
|
244
228
|
}
|
|
245
229
|
supportsMultipleCascadePaths() {
|
|
@@ -272,7 +256,7 @@ class Platform {
|
|
|
272
256
|
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
273
257
|
return path.join('.');
|
|
274
258
|
}
|
|
275
|
-
/*
|
|
259
|
+
/* v8 ignore next */
|
|
276
260
|
getJsonIndexDefinition(index) {
|
|
277
261
|
return index.columnNames;
|
|
278
262
|
}
|
|
@@ -291,12 +275,8 @@ class Platform {
|
|
|
291
275
|
convertJsonToDatabaseValue(value, context) {
|
|
292
276
|
return JSON.stringify(value);
|
|
293
277
|
}
|
|
294
|
-
convertJsonToJSValue(value,
|
|
295
|
-
|
|
296
|
-
if ((this.convertsJsonAutomatically() || isObjectEmbedded) && ['json', 'jsonb', this.getJsonDeclarationSQL()].includes(prop.columnTypes[0])) {
|
|
297
|
-
return value;
|
|
298
|
-
}
|
|
299
|
-
return (0, Utils_1.parseJsonSafe)(value);
|
|
278
|
+
convertJsonToJSValue(value, context) {
|
|
279
|
+
return parseJsonSafe(value);
|
|
300
280
|
}
|
|
301
281
|
convertDateToJSValue(value) {
|
|
302
282
|
return value;
|
|
@@ -309,14 +289,14 @@ class Platform {
|
|
|
309
289
|
}
|
|
310
290
|
parseDate(value) {
|
|
311
291
|
const date = new Date(value);
|
|
312
|
-
/*
|
|
292
|
+
/* v8 ignore next */
|
|
313
293
|
if (isNaN(date.getTime())) {
|
|
314
294
|
return value;
|
|
315
295
|
}
|
|
316
296
|
return date;
|
|
317
297
|
}
|
|
318
298
|
getRepositoryClass() {
|
|
319
|
-
return
|
|
299
|
+
return EntityRepository;
|
|
320
300
|
}
|
|
321
301
|
getDefaultCharset() {
|
|
322
302
|
return 'utf8';
|
|
@@ -339,19 +319,10 @@ class Platform {
|
|
|
339
319
|
if (extension) {
|
|
340
320
|
return extension;
|
|
341
321
|
}
|
|
342
|
-
/*
|
|
343
|
-
|
|
344
|
-
module: moduleName,
|
|
345
|
-
warning: `Please install ${moduleName} package.`,
|
|
346
|
-
});
|
|
347
|
-
/* istanbul ignore next */
|
|
348
|
-
if (module) {
|
|
349
|
-
return this.config.getCachedService(module[extensionName], em);
|
|
350
|
-
}
|
|
351
|
-
/* istanbul ignore next */
|
|
352
|
-
throw new Error(`${extensionName} extension not registered.`);
|
|
322
|
+
/* v8 ignore next */
|
|
323
|
+
throw new Error(`${extensionName} extension not registered. Provide it in the ORM config, or use the async \`MikroORM.init()\` method to load extensions automatically.`);
|
|
353
324
|
}
|
|
354
|
-
/*
|
|
325
|
+
/* v8 ignore next: kept for type inference only */
|
|
355
326
|
getSchemaGenerator(driver, em) {
|
|
356
327
|
throw new Error(`${driver.constructor.name} does not support SchemaGenerator`);
|
|
357
328
|
}
|
|
@@ -359,7 +330,7 @@ class Platform {
|
|
|
359
330
|
return value;
|
|
360
331
|
}
|
|
361
332
|
quoteIdentifier(id, quote = '`') {
|
|
362
|
-
const raw =
|
|
333
|
+
const raw = RawQueryFragment.getKnownFragment(id);
|
|
363
334
|
if (raw) {
|
|
364
335
|
return this.formatQuery(raw.sql, raw.params);
|
|
365
336
|
}
|
|
@@ -368,7 +339,7 @@ class Platform {
|
|
|
368
339
|
quoteValue(value) {
|
|
369
340
|
return value;
|
|
370
341
|
}
|
|
371
|
-
/*
|
|
342
|
+
/* v8 ignore next */
|
|
372
343
|
escape(value) {
|
|
373
344
|
return value;
|
|
374
345
|
}
|
|
@@ -412,9 +383,9 @@ class Platform {
|
|
|
412
383
|
return ret;
|
|
413
384
|
}
|
|
414
385
|
cloneEmbeddable(data) {
|
|
415
|
-
const copy =
|
|
386
|
+
const copy = clone(data);
|
|
416
387
|
// tag the copy so we know it should be stringified when quoting (so we know how to treat JSON arrays)
|
|
417
|
-
Object.defineProperty(copy,
|
|
388
|
+
Object.defineProperty(copy, JsonProperty, { enumerable: false, value: true });
|
|
418
389
|
return copy;
|
|
419
390
|
}
|
|
420
391
|
setConfig(config) {
|
|
@@ -438,7 +409,7 @@ class Platform {
|
|
|
438
409
|
return numericMappedType || prop.type === 'number' || this.isBigIntProperty(prop);
|
|
439
410
|
}
|
|
440
411
|
isNumericColumn(mappedType) {
|
|
441
|
-
return [
|
|
412
|
+
return [IntegerType, SmallIntType, BigIntType, TinyIntType].some(t => mappedType instanceof t);
|
|
442
413
|
}
|
|
443
414
|
supportsUnsigned() {
|
|
444
415
|
return false;
|
|
@@ -458,7 +429,7 @@ class Platform {
|
|
|
458
429
|
isPopulated(key, populate) {
|
|
459
430
|
return populate === true || (populate !== false && populate.some(p => p.field === key || p.all));
|
|
460
431
|
}
|
|
461
|
-
shouldHaveColumn(prop, populate, exclude, includeFormulas = true) {
|
|
432
|
+
shouldHaveColumn(prop, populate, exclude, includeFormulas = true, ignoreInlineEmbeddables = true) {
|
|
462
433
|
if (exclude?.includes(prop.name)) {
|
|
463
434
|
return false;
|
|
464
435
|
}
|
|
@@ -474,13 +445,13 @@ class Platform {
|
|
|
474
445
|
if (prop.lazy && (populate === false || (populate !== true && !populate.some(p => p.field === prop.name)))) {
|
|
475
446
|
return false;
|
|
476
447
|
}
|
|
477
|
-
if ([
|
|
448
|
+
if ([ReferenceKind.SCALAR, ReferenceKind.MANY_TO_ONE].includes(prop.kind)) {
|
|
478
449
|
return true;
|
|
479
450
|
}
|
|
480
|
-
if (prop.kind ===
|
|
481
|
-
return
|
|
451
|
+
if (prop.kind === ReferenceKind.EMBEDDED) {
|
|
452
|
+
return prop.object || ignoreInlineEmbeddables;
|
|
482
453
|
}
|
|
483
|
-
return prop.kind ===
|
|
454
|
+
return prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner;
|
|
484
455
|
}
|
|
485
456
|
/**
|
|
486
457
|
* Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
|
|
@@ -525,10 +496,9 @@ class Platform {
|
|
|
525
496
|
clone() {
|
|
526
497
|
return this;
|
|
527
498
|
}
|
|
528
|
-
/* istanbul ignore next */
|
|
529
499
|
/** @ignore */
|
|
530
|
-
|
|
500
|
+
/* v8 ignore next */
|
|
501
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
531
502
|
return `[${this.constructor.name}]`;
|
|
532
503
|
}
|
|
533
504
|
}
|
|
534
|
-
exports.Platform = Platform;
|
package/platforms/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './Platform';
|
|
2
|
-
export * from './ExceptionConverter';
|
|
1
|
+
export * from './Platform.js';
|
|
2
|
+
export * from './ExceptionConverter.js';
|
package/platforms/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("./Platform"), exports);
|
|
18
|
-
__exportStar(require("./ExceptionConverter"), exports);
|
|
1
|
+
export * from './Platform.js';
|
|
2
|
+
export * from './ExceptionConverter.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ArrayElement, AutoPath, CleanTypeConfig, EntityDTO, FromEntityType, Loaded, TypeConfig, UnboxArray } from '../typings';
|
|
2
|
-
import { type PopulatePath } from '../enums';
|
|
1
|
+
import type { ArrayElement, AutoPath, CleanTypeConfig, EntityDTO, FromEntityType, Loaded, TypeConfig, UnboxArray } from '../typings.js';
|
|
2
|
+
import { type PopulatePath } from '../enums.js';
|
|
3
3
|
export declare class EntitySerializer {
|
|
4
4
|
static serialize<T extends object, P extends string = never, E extends string = never>(entity: T, options?: SerializeOptions<T, P, E>): EntityDTO<Loaded<T, P>>;
|
|
5
5
|
private static propertyName;
|
|
@@ -17,6 +17,8 @@ export interface SerializeOptions<T, P extends string = never, E extends string
|
|
|
17
17
|
forceObject?: boolean;
|
|
18
18
|
/** Ignore custom property serializers. */
|
|
19
19
|
ignoreSerializers?: boolean;
|
|
20
|
+
/** Include properties marked as `hidden`. */
|
|
21
|
+
includeHidden?: boolean;
|
|
20
22
|
/** Skip properties with `null` value. */
|
|
21
23
|
skipNull?: boolean;
|
|
22
24
|
/** Only include properties for a specific group. If a property does not specify any group, it will be included, otherwise only properties with a matching group are included. */
|