@mikro-orm/core 7.0.0-dev.30 → 7.0.0-dev.300
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 +68 -60
- package/EntityManager.js +290 -259
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +109 -142
- package/README.md +2 -0
- package/cache/FileCacheAdapter.d.ts +1 -2
- package/cache/FileCacheAdapter.js +18 -11
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +0 -1
- package/cache/index.js +0 -1
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +21 -12
- package/drivers/DatabaseDriver.d.ts +25 -16
- package/drivers/DatabaseDriver.js +119 -36
- package/drivers/IDatabaseDriver.d.ts +118 -23
- package/entity/BaseEntity.d.ts +63 -4
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +101 -29
- package/entity/Collection.js +436 -104
- package/entity/EntityAssigner.js +17 -17
- package/entity/EntityFactory.d.ts +7 -1
- package/entity/EntityFactory.js +87 -55
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +57 -19
- package/entity/EntityLoader.d.ts +11 -10
- package/entity/EntityLoader.js +213 -82
- package/entity/EntityRepository.d.ts +28 -8
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +1 -5
- package/entity/Reference.js +15 -11
- package/entity/WrappedEntity.d.ts +3 -8
- package/entity/WrappedEntity.js +2 -7
- package/entity/defineEntity.d.ts +526 -310
- package/entity/defineEntity.js +134 -290
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.d.ts +6 -1
- package/entity/utils.js +34 -1
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/enums.d.ts +8 -6
- package/enums.js +2 -1
- package/errors.d.ts +20 -10
- package/errors.js +55 -23
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +19 -11
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +79 -34
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +1 -0
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +7 -6
- package/logging/index.d.ts +1 -0
- package/logging/index.js +1 -0
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +92 -33
- package/metadata/MetadataDiscovery.d.ts +64 -9
- package/metadata/MetadataDiscovery.js +782 -325
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +66 -2
- package/metadata/MetadataStorage.d.ts +13 -11
- package/metadata/MetadataStorage.js +72 -39
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +196 -41
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +1 -1
- package/metadata/types.d.ts +577 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +20 -2
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +28 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +22 -11
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +11 -15
- package/platforms/Platform.js +24 -44
- package/serialization/EntitySerializer.d.ts +6 -3
- package/serialization/EntitySerializer.js +46 -26
- package/serialization/EntityTransformer.js +33 -21
- package/serialization/SerializationContext.d.ts +6 -6
- package/serialization/SerializationContext.js +3 -3
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.js +2 -2
- package/types/DoubleType.js +1 -1
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/index.d.ts +1 -1
- package/typings.d.ts +412 -155
- package/typings.js +99 -44
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +4 -5
- package/unit-of-work/ChangeSetComputer.d.ts +3 -8
- package/unit-of-work/ChangeSetComputer.js +41 -20
- package/unit-of-work/ChangeSetPersister.d.ts +13 -12
- package/unit-of-work/ChangeSetPersister.js +94 -36
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +13 -13
- package/unit-of-work/IdentityMap.d.ts +12 -0
- package/unit-of-work/IdentityMap.js +39 -1
- package/unit-of-work/UnitOfWork.d.ts +27 -3
- package/unit-of-work/UnitOfWork.js +248 -90
- package/utils/AbstractMigrator.d.ts +101 -0
- package/utils/AbstractMigrator.js +305 -0
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +28 -17
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +795 -211
- package/utils/Configuration.js +153 -194
- package/utils/ConfigurationLoader.d.ts +1 -52
- package/utils/ConfigurationLoader.js +1 -330
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +24 -11
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +29 -12
- package/utils/EntityComparator.d.ts +16 -9
- package/utils/EntityComparator.js +154 -56
- package/utils/QueryHelper.d.ts +18 -6
- package/utils/QueryHelper.js +76 -23
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +35 -71
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +9 -6
- package/utils/Utils.d.ts +15 -126
- package/utils/Utils.js +80 -382
- package/utils/clone.js +8 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +97 -0
- package/utils/fs-utils.d.ts +34 -0
- package/utils/fs-utils.js +196 -0
- package/utils/index.d.ts +1 -3
- package/utils/index.js +1 -3
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +46 -3
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -33
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -42
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -34
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -28
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -14
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -118
- package/entity/ArrayCollection.js +0 -407
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
|
@@ -3,10 +3,10 @@ import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
|
3
3
|
* This strategy keeps original entity/property names for table/column.
|
|
4
4
|
*/
|
|
5
5
|
export declare class EntityCaseNamingStrategy extends AbstractNamingStrategy {
|
|
6
|
-
classToTableName(entityName: string): string;
|
|
6
|
+
classToTableName(entityName: string, tableName?: string): string;
|
|
7
7
|
joinColumnName(propertyName: string): string;
|
|
8
|
-
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
|
|
9
|
-
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
|
|
8
|
+
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
|
|
9
|
+
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
|
|
10
10
|
propertyToColumnName(propertyName: string): string;
|
|
11
11
|
referenceColumnName(): string;
|
|
12
12
|
}
|
|
@@ -3,21 +3,22 @@ import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
|
3
3
|
* This strategy keeps original entity/property names for table/column.
|
|
4
4
|
*/
|
|
5
5
|
export class EntityCaseNamingStrategy extends AbstractNamingStrategy {
|
|
6
|
-
classToTableName(entityName) {
|
|
7
|
-
return entityName;
|
|
6
|
+
classToTableName(entityName, tableName) {
|
|
7
|
+
return tableName ?? entityName;
|
|
8
8
|
}
|
|
9
9
|
joinColumnName(propertyName) {
|
|
10
10
|
return propertyName;
|
|
11
11
|
}
|
|
12
|
-
joinKeyColumnName(entityName, referencedColumnName, composite
|
|
12
|
+
joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
|
|
13
|
+
entityName = this.classToTableName(entityName, tableName);
|
|
13
14
|
const name = entityName.substr(0, 1).toLowerCase() + entityName.substr(1);
|
|
14
15
|
if (composite && referencedColumnName) {
|
|
15
16
|
return name + '_' + referencedColumnName;
|
|
16
17
|
}
|
|
17
18
|
return name;
|
|
18
19
|
}
|
|
19
|
-
joinTableName(sourceEntity, targetEntity, propertyName) {
|
|
20
|
-
return this.classToTableName(sourceEntity) + '_' + this.propertyToColumnName(propertyName);
|
|
20
|
+
joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
|
|
21
|
+
return this.classToTableName(sourceEntity, tableName) + '_' + this.propertyToColumnName(propertyName);
|
|
21
22
|
}
|
|
22
23
|
propertyToColumnName(propertyName) {
|
|
23
24
|
return propertyName;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export declare class MongoNamingStrategy extends AbstractNamingStrategy {
|
|
3
|
-
classToTableName(entityName: string): string;
|
|
3
|
+
classToTableName(entityName: string, tableName?: string): string;
|
|
4
4
|
joinColumnName(propertyName: string): string;
|
|
5
|
-
joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
|
|
6
|
-
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
|
|
5
|
+
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
|
|
6
|
+
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
|
|
7
7
|
propertyToColumnName(propertyName: string): string;
|
|
8
8
|
referenceColumnName(): string;
|
|
9
9
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export class MongoNamingStrategy extends AbstractNamingStrategy {
|
|
3
|
-
classToTableName(entityName) {
|
|
4
|
-
return entityName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
3
|
+
classToTableName(entityName, tableName) {
|
|
4
|
+
return tableName ?? entityName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
5
5
|
}
|
|
6
6
|
joinColumnName(propertyName) {
|
|
7
7
|
return propertyName;
|
|
8
8
|
}
|
|
9
|
-
joinKeyColumnName(entityName, referencedColumnName) {
|
|
10
|
-
return entityName;
|
|
9
|
+
joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
|
|
10
|
+
return tableName ?? entityName;
|
|
11
11
|
}
|
|
12
|
-
joinTableName(sourceEntity, targetEntity, propertyName) {
|
|
13
|
-
return this.classToTableName(sourceEntity) + '_' + this.propertyToColumnName(propertyName);
|
|
12
|
+
joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
|
|
13
|
+
return this.classToTableName(sourceEntity, tableName) + '_' + this.propertyToColumnName(propertyName);
|
|
14
14
|
}
|
|
15
15
|
propertyToColumnName(propertyName) {
|
|
16
16
|
return propertyName;
|
|
@@ -7,7 +7,7 @@ export interface NamingStrategy {
|
|
|
7
7
|
/**
|
|
8
8
|
* Return a table name for an entity class
|
|
9
9
|
*/
|
|
10
|
-
classToTableName(entityName: string): string;
|
|
10
|
+
classToTableName(entityName: string, tableName?: string): string;
|
|
11
11
|
/**
|
|
12
12
|
* Return a migration name. This name should allow ordering.
|
|
13
13
|
*/
|
|
@@ -25,7 +25,17 @@ export interface NamingStrategy {
|
|
|
25
25
|
*
|
|
26
26
|
* @return A new class name that will be used for the enum.
|
|
27
27
|
*/
|
|
28
|
-
getEnumClassName(columnName: string, tableName: string, schemaName?: string): string;
|
|
28
|
+
getEnumClassName(columnName: string, tableName: string | undefined, schemaName?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get an enum type name. Used with `enumType: 'dictionary'` and `enumType: 'union-type'` entity generator option.
|
|
31
|
+
*
|
|
32
|
+
* @param columnName The column name which has the enum.
|
|
33
|
+
* @param tableName The table name of the column.
|
|
34
|
+
* @param schemaName The schema name of the column.
|
|
35
|
+
*
|
|
36
|
+
* @return A new type name that will be used for the enum.
|
|
37
|
+
*/
|
|
38
|
+
getEnumTypeName(columnName: string, tableName: string | undefined, schemaName?: string): string;
|
|
29
39
|
/**
|
|
30
40
|
* Get an enum option name for a given enum value.
|
|
31
41
|
*
|
|
@@ -57,11 +67,11 @@ export interface NamingStrategy {
|
|
|
57
67
|
/**
|
|
58
68
|
* Return a join table name
|
|
59
69
|
*/
|
|
60
|
-
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
|
|
70
|
+
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
|
|
61
71
|
/**
|
|
62
72
|
* Return the foreign key column name for the given parameters
|
|
63
73
|
*/
|
|
64
|
-
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean): string;
|
|
74
|
+
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
|
|
65
75
|
/**
|
|
66
76
|
* Returns key/constraint name for the given type. Some drivers might not support all the types (e.g. mysql and sqlite enforce the PK name).
|
|
67
77
|
*/
|
|
@@ -75,4 +85,18 @@ export interface NamingStrategy {
|
|
|
75
85
|
* Returns the name of the inverse side property. Used in the `EntityGenerator` with `bidirectionalRelations` option.
|
|
76
86
|
*/
|
|
77
87
|
inverseSideName(entityName: string, propertyName: string, kind: ReferenceKind): string;
|
|
88
|
+
/**
|
|
89
|
+
* Return a property name for a many-to-many relation (used in `EntityGenerator`).
|
|
90
|
+
*
|
|
91
|
+
* @param ownerEntityName - The owner entity class name
|
|
92
|
+
* @param targetEntityName - The target entity class name
|
|
93
|
+
* @param pivotTableName - The pivot table name
|
|
94
|
+
* @param ownerTableName - The owner table name
|
|
95
|
+
* @param schemaName - The schema name (if any)
|
|
96
|
+
*/
|
|
97
|
+
manyToManyPropertyName(ownerEntityName: string, targetEntityName: string, pivotTableName: string, ownerTableName: string, schemaName?: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the discriminator column name for polymorphic relations.
|
|
100
|
+
*/
|
|
101
|
+
discriminatorColumnName(baseName: string): string;
|
|
78
102
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export declare class UnderscoreNamingStrategy extends AbstractNamingStrategy {
|
|
3
|
-
classToTableName(entityName: string): string;
|
|
3
|
+
classToTableName(entityName: string, tableName?: string): string;
|
|
4
4
|
joinColumnName(propertyName: string): string;
|
|
5
|
-
joinKeyColumnName(entityName: string, referencedColumnName?: string): string;
|
|
6
|
-
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string): string;
|
|
5
|
+
joinKeyColumnName(entityName: string, referencedColumnName?: string, composite?: boolean, tableName?: string): string;
|
|
6
|
+
joinTableName(sourceEntity: string, targetEntity: string, propertyName: string, tableName?: string): string;
|
|
7
7
|
propertyToColumnName(propertyName: string, object?: boolean): string;
|
|
8
8
|
referenceColumnName(): string;
|
|
9
9
|
private underscore;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export class UnderscoreNamingStrategy extends AbstractNamingStrategy {
|
|
3
|
-
classToTableName(entityName) {
|
|
4
|
-
return this.underscore(entityName);
|
|
3
|
+
classToTableName(entityName, tableName) {
|
|
4
|
+
return tableName ?? this.underscore(entityName);
|
|
5
5
|
}
|
|
6
6
|
joinColumnName(propertyName) {
|
|
7
7
|
return this.underscore(propertyName) + '_' + this.referenceColumnName();
|
|
8
8
|
}
|
|
9
|
-
joinKeyColumnName(entityName, referencedColumnName) {
|
|
10
|
-
return this.classToTableName(entityName) + '_' + (referencedColumnName || this.referenceColumnName());
|
|
9
|
+
joinKeyColumnName(entityName, referencedColumnName, composite, tableName) {
|
|
10
|
+
return this.classToTableName(entityName, tableName) + '_' + (referencedColumnName || this.referenceColumnName());
|
|
11
11
|
}
|
|
12
|
-
joinTableName(sourceEntity, targetEntity, propertyName) {
|
|
13
|
-
return this.classToTableName(sourceEntity) + '_' + this.classToTableName(propertyName);
|
|
12
|
+
joinTableName(sourceEntity, targetEntity, propertyName, tableName) {
|
|
13
|
+
return this.classToTableName(sourceEntity, tableName) + '_' + this.classToTableName(propertyName);
|
|
14
14
|
}
|
|
15
15
|
propertyToColumnName(propertyName, object) {
|
|
16
16
|
return this.underscore(propertyName);
|
package/not-supported.js
ADDED
package/package.json
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.300",
|
|
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",
|
|
8
|
-
".": "./index.js"
|
|
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
|
+
},
|
|
17
|
+
"./migrations": "./utils/AbstractMigrator.js",
|
|
18
|
+
"./schema": "./utils/AbstractSchemaGenerator.js",
|
|
19
|
+
"./dataloader": "./utils/DataloaderUtils.js"
|
|
9
20
|
},
|
|
10
21
|
"repository": {
|
|
11
22
|
"type": "git",
|
|
@@ -39,10 +50,10 @@
|
|
|
39
50
|
},
|
|
40
51
|
"homepage": "https://mikro-orm.io",
|
|
41
52
|
"engines": {
|
|
42
|
-
"node": ">= 22.
|
|
53
|
+
"node": ">= 22.17.0"
|
|
43
54
|
},
|
|
44
55
|
"scripts": {
|
|
45
|
-
"build": "yarn
|
|
56
|
+
"build": "yarn compile && yarn copy",
|
|
46
57
|
"clean": "yarn run -T rimraf ./dist",
|
|
47
58
|
"compile": "yarn run -T tsc -p tsconfig.build.json",
|
|
48
59
|
"copy": "node ../../scripts/copy.mjs"
|
|
@@ -50,12 +61,12 @@
|
|
|
50
61
|
"publishConfig": {
|
|
51
62
|
"access": "public"
|
|
52
63
|
},
|
|
53
|
-
"
|
|
54
|
-
"dataloader": "2.2.3"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"dataloader": "2.2.3"
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
"dataloader": {
|
|
69
|
+
"optional": true
|
|
70
|
+
}
|
|
60
71
|
}
|
|
61
72
|
}
|
package/platforms/Platform.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
1
|
import { EntityRepository } from '../entity/EntityRepository.js';
|
|
3
2
|
import { type NamingStrategy } from '../naming-strategy/NamingStrategy.js';
|
|
4
|
-
import type { Constructor, EntityProperty, IPrimaryKey, ISchemaGenerator, PopulateOptions, Primary,
|
|
3
|
+
import type { Constructor, EntityMetadata, EntityProperty, IPrimaryKey, ISchemaGenerator, PopulateOptions, Primary, SimpleColumnMeta } from '../typings.js';
|
|
5
4
|
import { ExceptionConverter } from './ExceptionConverter.js';
|
|
6
5
|
import type { EntityManager } from '../EntityManager.js';
|
|
7
6
|
import type { Configuration } from '../utils/Configuration.js';
|
|
@@ -9,6 +8,7 @@ import type { IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
|
9
8
|
import { Type } from '../types/index.js';
|
|
10
9
|
import type { MikroORM } from '../MikroORM.js';
|
|
11
10
|
import type { TransformContext } from '../types/Type.js';
|
|
11
|
+
import { Raw } from '../utils/RawQueryFragment.js';
|
|
12
12
|
export declare const JsonProperty: unique symbol;
|
|
13
13
|
export declare abstract class Platform {
|
|
14
14
|
protected readonly exceptionConverter: ExceptionConverter;
|
|
@@ -28,9 +28,9 @@ export declare abstract class Platform {
|
|
|
28
28
|
supportsNativeEnums(): boolean;
|
|
29
29
|
/** for postgres text enums (default) */
|
|
30
30
|
usesEnumCheckConstraints(): boolean;
|
|
31
|
+
supportsMaterializedViews(): boolean;
|
|
31
32
|
getSchemaHelper(): unknown;
|
|
32
33
|
indexForeignKeys(): boolean;
|
|
33
|
-
allowsMultiInsert(): boolean;
|
|
34
34
|
/**
|
|
35
35
|
* Whether or not the driver supports retuning list of created PKs back when multi-inserting
|
|
36
36
|
*/
|
|
@@ -48,11 +48,6 @@ export declare abstract class Platform {
|
|
|
48
48
|
* Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)
|
|
49
49
|
*/
|
|
50
50
|
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
51
|
/**
|
|
57
52
|
* Returns the SQL specific for the platform to get the current timestamp
|
|
58
53
|
*/
|
|
@@ -71,7 +66,9 @@ export declare abstract class Platform {
|
|
|
71
66
|
$flags?: string;
|
|
72
67
|
};
|
|
73
68
|
isAllowedTopLevelOperator(operator: string): boolean;
|
|
74
|
-
|
|
69
|
+
convertVersionValue(value: Date | number, prop: EntityProperty): Date | string | number | {
|
|
70
|
+
$in: (string | number)[];
|
|
71
|
+
};
|
|
75
72
|
getDefaultVersionLength(): number;
|
|
76
73
|
allowsComparingTuples(): boolean;
|
|
77
74
|
isBigIntProperty(prop: EntityProperty): boolean;
|
|
@@ -143,13 +140,14 @@ export declare abstract class Platform {
|
|
|
143
140
|
getDefaultMappedType(type: string): Type<unknown>;
|
|
144
141
|
supportsMultipleCascadePaths(): boolean;
|
|
145
142
|
supportsMultipleStatements(): boolean;
|
|
143
|
+
supportsUnionWhere(): boolean;
|
|
146
144
|
getArrayDeclarationSQL(): string;
|
|
147
145
|
marshallArray(values: string[]): string;
|
|
148
146
|
unmarshallArray(value: string): string[];
|
|
149
147
|
getBlobDeclarationSQL(): string;
|
|
150
148
|
getJsonDeclarationSQL(): string;
|
|
151
|
-
getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string;
|
|
152
|
-
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string;
|
|
149
|
+
getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string | Raw;
|
|
150
|
+
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | Raw;
|
|
153
151
|
getJsonIndexDefinition(index: {
|
|
154
152
|
columnNames: string[];
|
|
155
153
|
}): string[];
|
|
@@ -158,7 +156,7 @@ export declare abstract class Platform {
|
|
|
158
156
|
getFullTextIndexExpression(indexName: string, schemaName: string | undefined, tableName: string, columns: SimpleColumnMeta[]): string;
|
|
159
157
|
convertsJsonAutomatically(): boolean;
|
|
160
158
|
convertJsonToDatabaseValue(value: unknown, context?: TransformContext): unknown;
|
|
161
|
-
convertJsonToJSValue(value: unknown,
|
|
159
|
+
convertJsonToJSValue(value: unknown, context?: TransformContext): unknown;
|
|
162
160
|
convertDateToJSValue(value: string | Date): string;
|
|
163
161
|
convertIntervalToJSValue(value: string): unknown;
|
|
164
162
|
convertIntervalToDatabaseValue(value: unknown): unknown;
|
|
@@ -195,7 +193,7 @@ export declare abstract class Platform {
|
|
|
195
193
|
getDefaultPrimaryName(tableName: string, columns: string[]): string;
|
|
196
194
|
supportsCustomPrimaryKeyNames(): boolean;
|
|
197
195
|
isPopulated<T>(key: string, populate: readonly PopulateOptions<T>[] | boolean): boolean;
|
|
198
|
-
shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean): boolean;
|
|
196
|
+
shouldHaveColumn<T>(prop: EntityProperty<T>, populate: readonly PopulateOptions<T>[] | boolean, exclude?: string[], includeFormulas?: boolean, ignoreInlineEmbeddables?: boolean): boolean;
|
|
199
197
|
/**
|
|
200
198
|
* Currently not supported due to how knex does complex sqlite diffing (always based on current schema)
|
|
201
199
|
*/
|
|
@@ -227,6 +225,4 @@ export declare abstract class Platform {
|
|
|
227
225
|
* @internal
|
|
228
226
|
*/
|
|
229
227
|
clone(): this;
|
|
230
|
-
/** @ignore */
|
|
231
|
-
[inspect.custom](): string;
|
|
232
228
|
}
|
package/platforms/Platform.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
1
|
import { clone } from '../utils/clone.js';
|
|
3
2
|
import { EntityRepository } from '../entity/EntityRepository.js';
|
|
4
3
|
import { UnderscoreNamingStrategy } from '../naming-strategy/UnderscoreNamingStrategy.js';
|
|
5
4
|
import { ExceptionConverter } from './ExceptionConverter.js';
|
|
6
|
-
import { ArrayType, BigIntType, BlobType,
|
|
7
|
-
import { parseJsonSafe
|
|
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';
|
|
8
7
|
import { ReferenceKind } from '../enums.js';
|
|
9
|
-
import {
|
|
8
|
+
import { Raw } from '../utils/RawQueryFragment.js';
|
|
10
9
|
export const JsonProperty = Symbol('JsonProperty');
|
|
11
10
|
export class Platform {
|
|
12
11
|
exceptionConverter = new ExceptionConverter();
|
|
@@ -42,15 +41,15 @@ export class Platform {
|
|
|
42
41
|
usesEnumCheckConstraints() {
|
|
43
42
|
return false;
|
|
44
43
|
}
|
|
44
|
+
supportsMaterializedViews() {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
45
47
|
getSchemaHelper() {
|
|
46
48
|
return undefined;
|
|
47
49
|
}
|
|
48
50
|
indexForeignKeys() {
|
|
49
51
|
return false;
|
|
50
52
|
}
|
|
51
|
-
allowsMultiInsert() {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
53
|
/**
|
|
55
54
|
* Whether or not the driver supports retuning list of created PKs back when multi-inserting
|
|
56
55
|
*/
|
|
@@ -78,15 +77,6 @@ export class Platform {
|
|
|
78
77
|
denormalizePrimaryKey(data) {
|
|
79
78
|
return data;
|
|
80
79
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Used when serializing via toObject and toJSON methods, allows to use different PK field name (like `id` instead of `_id`)
|
|
83
|
-
*/
|
|
84
|
-
getSerializedPrimaryKeyField(field) {
|
|
85
|
-
return field;
|
|
86
|
-
}
|
|
87
|
-
usesDifferentSerializedPrimaryKey() {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
80
|
/**
|
|
91
81
|
* Returns the SQL specific for the platform to get the current timestamp
|
|
92
82
|
*/
|
|
@@ -123,7 +113,7 @@ export class Platform {
|
|
|
123
113
|
isAllowedTopLevelOperator(operator) {
|
|
124
114
|
return operator === '$not';
|
|
125
115
|
}
|
|
126
|
-
|
|
116
|
+
convertVersionValue(value, prop) {
|
|
127
117
|
return value;
|
|
128
118
|
}
|
|
129
119
|
getDefaultVersionLength() {
|
|
@@ -133,7 +123,7 @@ export class Platform {
|
|
|
133
123
|
return true;
|
|
134
124
|
}
|
|
135
125
|
isBigIntProperty(prop) {
|
|
136
|
-
return prop.columnTypes
|
|
126
|
+
return prop.columnTypes?.[0] === 'bigint';
|
|
137
127
|
}
|
|
138
128
|
getDefaultSchemaName() {
|
|
139
129
|
return undefined;
|
|
@@ -169,7 +159,7 @@ export class Platform {
|
|
|
169
159
|
return `text`;
|
|
170
160
|
}
|
|
171
161
|
getEnumTypeDeclarationSQL(column) {
|
|
172
|
-
if (column.items?.every(item =>
|
|
162
|
+
if (column.items?.every(item => typeof item === 'string')) {
|
|
173
163
|
return `enum('${column.items.join("','")}')`;
|
|
174
164
|
}
|
|
175
165
|
return this.getTinyIntTypeDeclarationSQL(column);
|
|
@@ -245,6 +235,9 @@ export class Platform {
|
|
|
245
235
|
supportsMultipleStatements() {
|
|
246
236
|
return this.config.get('multipleStatements');
|
|
247
237
|
}
|
|
238
|
+
supportsUnionWhere() {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
248
241
|
getArrayDeclarationSQL() {
|
|
249
242
|
return 'text';
|
|
250
243
|
}
|
|
@@ -269,7 +262,7 @@ export class Platform {
|
|
|
269
262
|
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
270
263
|
return path.join('.');
|
|
271
264
|
}
|
|
272
|
-
/* v8 ignore next
|
|
265
|
+
/* v8 ignore next */
|
|
273
266
|
getJsonIndexDefinition(index) {
|
|
274
267
|
return index.columnNames;
|
|
275
268
|
}
|
|
@@ -288,11 +281,7 @@ export class Platform {
|
|
|
288
281
|
convertJsonToDatabaseValue(value, context) {
|
|
289
282
|
return JSON.stringify(value);
|
|
290
283
|
}
|
|
291
|
-
convertJsonToJSValue(value,
|
|
292
|
-
const isObjectEmbedded = prop.embedded && prop.object;
|
|
293
|
-
if ((this.convertsJsonAutomatically() || isObjectEmbedded) && ['json', 'jsonb', this.getJsonDeclarationSQL()].includes(prop.columnTypes[0])) {
|
|
294
|
-
return value;
|
|
295
|
-
}
|
|
284
|
+
convertJsonToJSValue(value, context) {
|
|
296
285
|
return parseJsonSafe(value);
|
|
297
286
|
}
|
|
298
287
|
convertDateToJSValue(value) {
|
|
@@ -306,7 +295,7 @@ export class Platform {
|
|
|
306
295
|
}
|
|
307
296
|
parseDate(value) {
|
|
308
297
|
const date = new Date(value);
|
|
309
|
-
/* v8 ignore next
|
|
298
|
+
/* v8 ignore next */
|
|
310
299
|
if (isNaN(date.getTime())) {
|
|
311
300
|
return value;
|
|
312
301
|
}
|
|
@@ -336,19 +325,10 @@ export class Platform {
|
|
|
336
325
|
if (extension) {
|
|
337
326
|
return extension;
|
|
338
327
|
}
|
|
339
|
-
/* v8 ignore next
|
|
340
|
-
|
|
341
|
-
module: moduleName,
|
|
342
|
-
warning: `Please install ${moduleName} package.`,
|
|
343
|
-
});
|
|
344
|
-
/* v8 ignore next 3 */
|
|
345
|
-
if (module) {
|
|
346
|
-
return this.config.getCachedService(module[extensionName], em);
|
|
347
|
-
}
|
|
348
|
-
/* v8 ignore next 2 */
|
|
349
|
-
throw new Error(`${extensionName} extension not registered.`);
|
|
328
|
+
/* v8 ignore next */
|
|
329
|
+
throw new Error(`${extensionName} extension not registered. Provide it in the ORM config, or use the async \`MikroORM.init()\` method to load extensions automatically.`);
|
|
350
330
|
}
|
|
351
|
-
/* v8 ignore next
|
|
331
|
+
/* v8 ignore next: kept for type inference only */
|
|
352
332
|
getSchemaGenerator(driver, em) {
|
|
353
333
|
throw new Error(`${driver.constructor.name} does not support SchemaGenerator`);
|
|
354
334
|
}
|
|
@@ -356,7 +336,7 @@ export class Platform {
|
|
|
356
336
|
return value;
|
|
357
337
|
}
|
|
358
338
|
quoteIdentifier(id, quote = '`') {
|
|
359
|
-
const raw =
|
|
339
|
+
const raw = Raw.getKnownFragment(id);
|
|
360
340
|
if (raw) {
|
|
361
341
|
return this.formatQuery(raw.sql, raw.params);
|
|
362
342
|
}
|
|
@@ -365,7 +345,7 @@ export class Platform {
|
|
|
365
345
|
quoteValue(value) {
|
|
366
346
|
return value;
|
|
367
347
|
}
|
|
368
|
-
/* v8 ignore next
|
|
348
|
+
/* v8 ignore next */
|
|
369
349
|
escape(value) {
|
|
370
350
|
return value;
|
|
371
351
|
}
|
|
@@ -455,7 +435,7 @@ export class Platform {
|
|
|
455
435
|
isPopulated(key, populate) {
|
|
456
436
|
return populate === true || (populate !== false && populate.some(p => p.field === key || p.all));
|
|
457
437
|
}
|
|
458
|
-
shouldHaveColumn(prop, populate, exclude, includeFormulas = true) {
|
|
438
|
+
shouldHaveColumn(prop, populate, exclude, includeFormulas = true, ignoreInlineEmbeddables = true) {
|
|
459
439
|
if (exclude?.includes(prop.name)) {
|
|
460
440
|
return false;
|
|
461
441
|
}
|
|
@@ -475,7 +455,7 @@ export class Platform {
|
|
|
475
455
|
return true;
|
|
476
456
|
}
|
|
477
457
|
if (prop.kind === ReferenceKind.EMBEDDED) {
|
|
478
|
-
return
|
|
458
|
+
return prop.object || ignoreInlineEmbeddables;
|
|
479
459
|
}
|
|
480
460
|
return prop.kind === ReferenceKind.ONE_TO_ONE && prop.owner;
|
|
481
461
|
}
|
|
@@ -522,9 +502,9 @@ export class Platform {
|
|
|
522
502
|
clone() {
|
|
523
503
|
return this;
|
|
524
504
|
}
|
|
525
|
-
/* v8 ignore next 4 */
|
|
526
505
|
/** @ignore */
|
|
527
|
-
|
|
506
|
+
/* v8 ignore next */
|
|
507
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
528
508
|
return `[${this.constructor.name}]`;
|
|
529
509
|
}
|
|
530
510
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ArrayElement, AutoPath, CleanTypeConfig,
|
|
1
|
+
import type { ArrayElement, AutoPath, CleanTypeConfig, SerializeDTO, FromEntityType, TypeConfig, UnboxArray } from '../typings.js';
|
|
2
2
|
import { type PopulatePath } from '../enums.js';
|
|
3
3
|
export declare class EntitySerializer {
|
|
4
|
-
static serialize<T extends object, P extends string = never, E extends string = never>(entity: T, options?: SerializeOptions<T, P, E>):
|
|
4
|
+
static serialize<T extends object, P extends string = never, E extends string = never>(entity: T, options?: SerializeOptions<T, P, E>): SerializeDTO<T, P, E>;
|
|
5
5
|
private static propertyName;
|
|
6
6
|
private static processProperty;
|
|
7
|
+
private static processCustomType;
|
|
7
8
|
private static extractChildOptions;
|
|
8
9
|
private static processEntity;
|
|
9
10
|
private static processCollection;
|
|
@@ -23,6 +24,8 @@ export interface SerializeOptions<T, P extends string = never, E extends string
|
|
|
23
24
|
skipNull?: boolean;
|
|
24
25
|
/** 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. */
|
|
25
26
|
groups?: string[];
|
|
27
|
+
/** Convert custom types to their database representation. By default, the `Type.toJSON` method is invoked instead. */
|
|
28
|
+
convertCustomTypes?: boolean;
|
|
26
29
|
}
|
|
27
30
|
/**
|
|
28
31
|
* Converts entity instance to POJO, converting the `Collection`s to arrays and unwrapping the `Reference` wrapper, while respecting the serialization options.
|
|
@@ -36,4 +39,4 @@ export interface SerializeOptions<T, P extends string = never, E extends string
|
|
|
36
39
|
* const dto2 = wrap(user).serialize({ exclude: ['id', 'email'], forceObject: true });
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
|
-
export declare function serialize<Entity extends object, Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Populate extends string = never, Exclude extends string = never, Config extends TypeConfig = never>(entity: Entity, options?: Config & SerializeOptions<UnboxArray<Entity>, Populate, Exclude>): Naked extends object[] ?
|
|
42
|
+
export declare function serialize<Entity extends object, Naked extends FromEntityType<Entity> = FromEntityType<Entity>, Populate extends string = never, Exclude extends string = never, Config extends TypeConfig = never>(entity: Entity, options?: Config & SerializeOptions<UnboxArray<Entity>, Populate, Exclude>): Naked extends object[] ? SerializeDTO<ArrayElement<Naked>, Populate, Exclude, CleanTypeConfig<Config>>[] : SerializeDTO<Naked, Populate, Exclude, CleanTypeConfig<Config>>;
|