@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,5 +1,5 @@
|
|
|
1
|
-
import type { EntityMetadata } from '../typings';
|
|
2
|
-
import type { Logger } from '../logging/Logger';
|
|
1
|
+
import type { EntityMetadata } from '../typings.js';
|
|
2
|
+
import type { Logger } from '../logging/Logger.js';
|
|
3
3
|
export interface IConfiguration {
|
|
4
4
|
get(key: string, defaultValue?: any): any;
|
|
5
5
|
getLogger(): Logger;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MetadataProvider = void 0;
|
|
4
|
-
const Utils_1 = require("../utils/Utils");
|
|
5
|
-
class MetadataProvider {
|
|
1
|
+
import { Utils } from '../utils/Utils.js';
|
|
2
|
+
export class MetadataProvider {
|
|
6
3
|
config;
|
|
7
4
|
constructor(config) {
|
|
8
5
|
this.config = config;
|
|
@@ -10,14 +7,14 @@ class MetadataProvider {
|
|
|
10
7
|
loadFromCache(meta, cache) {
|
|
11
8
|
Object.values(cache.properties).forEach(prop => {
|
|
12
9
|
const metaProp = meta.properties[prop.name];
|
|
10
|
+
/* v8 ignore next 3 */
|
|
13
11
|
if (metaProp?.enum && Array.isArray(metaProp.items)) {
|
|
14
12
|
delete prop.items;
|
|
15
13
|
}
|
|
16
14
|
});
|
|
17
|
-
|
|
15
|
+
Utils.mergeConfig(meta, cache);
|
|
18
16
|
}
|
|
19
17
|
useCache() {
|
|
20
18
|
return this.config.get('metadataCache').enabled ?? false;
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
exports.MetadataProvider = MetadataProvider;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EntityMetadata, type Dictionary, type EntityData, type EntityName } from '../typings';
|
|
2
|
-
import type { EntityManager } from '../EntityManager';
|
|
1
|
+
import { EntityMetadata, type Dictionary, type EntityData, type EntityName } from '../typings.js';
|
|
2
|
+
import type { EntityManager } from '../EntityManager.js';
|
|
3
3
|
export declare class MetadataStorage {
|
|
4
4
|
static readonly PATH_SYMBOL: unique symbol;
|
|
5
5
|
private static readonly metadata;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const errors_1 = require("../errors");
|
|
7
|
-
const EntityHelper_1 = require("../entity/EntityHelper");
|
|
8
|
-
class MetadataStorage {
|
|
1
|
+
import { EntityMetadata } from '../typings.js';
|
|
2
|
+
import { Utils } from '../utils/Utils.js';
|
|
3
|
+
import { MetadataError } from '../errors.js';
|
|
4
|
+
import { EntityHelper } from '../entity/EntityHelper.js';
|
|
5
|
+
export class MetadataStorage {
|
|
9
6
|
static PATH_SYMBOL = Symbol('MetadataStorage.PATH_SYMBOL');
|
|
10
|
-
static metadata =
|
|
7
|
+
static metadata = Utils.getGlobalStorage('metadata');
|
|
11
8
|
metadata;
|
|
12
9
|
constructor(metadata = {}) {
|
|
13
|
-
this.metadata =
|
|
10
|
+
this.metadata = Utils.copy(metadata, false);
|
|
14
11
|
}
|
|
15
12
|
static getMetadata(entity, path) {
|
|
16
|
-
const key = entity && path ? entity + '-' +
|
|
13
|
+
const key = entity && path ? entity + '-' + Utils.hash(path) : null;
|
|
17
14
|
if (key && !MetadataStorage.metadata[key]) {
|
|
18
|
-
MetadataStorage.metadata[key] = new
|
|
15
|
+
MetadataStorage.metadata[key] = new EntityMetadata({ className: entity, path });
|
|
19
16
|
}
|
|
20
17
|
if (key) {
|
|
21
18
|
return MetadataStorage.metadata[key];
|
|
@@ -27,7 +24,7 @@ class MetadataStorage {
|
|
|
27
24
|
}
|
|
28
25
|
static getMetadataFromDecorator(target) {
|
|
29
26
|
if (!Object.hasOwn(target, MetadataStorage.PATH_SYMBOL)) {
|
|
30
|
-
Object.defineProperty(target, MetadataStorage.PATH_SYMBOL, { value:
|
|
27
|
+
Object.defineProperty(target, MetadataStorage.PATH_SYMBOL, { value: Utils.lookupPathFromDecorator(target.name), writable: true });
|
|
31
28
|
}
|
|
32
29
|
return MetadataStorage.getMetadata(target.name, target[MetadataStorage.PATH_SYMBOL]);
|
|
33
30
|
}
|
|
@@ -49,12 +46,12 @@ class MetadataStorage {
|
|
|
49
46
|
return this.metadata[type];
|
|
50
47
|
}
|
|
51
48
|
get(entityName, init = false, validate = true) {
|
|
52
|
-
entityName =
|
|
49
|
+
entityName = Utils.className(entityName);
|
|
53
50
|
if (validate && !init && !this.has(entityName)) {
|
|
54
|
-
throw
|
|
51
|
+
throw MetadataError.missingMetadata(entityName);
|
|
55
52
|
}
|
|
56
53
|
if (init && !this.has(entityName)) {
|
|
57
|
-
this.metadata[entityName] = new
|
|
54
|
+
this.metadata[entityName] = new EntityMetadata();
|
|
58
55
|
}
|
|
59
56
|
return this.metadata[entityName];
|
|
60
57
|
}
|
|
@@ -62,7 +59,7 @@ class MetadataStorage {
|
|
|
62
59
|
if (!entityName) {
|
|
63
60
|
return;
|
|
64
61
|
}
|
|
65
|
-
entityName =
|
|
62
|
+
entityName = Utils.className(entityName);
|
|
66
63
|
return this.metadata[entityName];
|
|
67
64
|
}
|
|
68
65
|
has(entity) {
|
|
@@ -77,7 +74,7 @@ class MetadataStorage {
|
|
|
77
74
|
decorate(em) {
|
|
78
75
|
Object.values(this.metadata)
|
|
79
76
|
.filter(meta => meta.prototype)
|
|
80
|
-
.forEach(meta =>
|
|
77
|
+
.forEach(meta => EntityHelper.decorate(meta, em));
|
|
81
78
|
}
|
|
82
79
|
*[Symbol.iterator]() {
|
|
83
80
|
for (const meta of Object.values(this.metadata)) {
|
|
@@ -85,4 +82,3 @@ class MetadataStorage {
|
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
84
|
}
|
|
88
|
-
exports.MetadataStorage = MetadataStorage;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { EntityMetadata } from '../typings';
|
|
2
|
-
import { type MetadataDiscoveryOptions } from '../utils';
|
|
3
|
-
import { ReferenceKind } from '../enums';
|
|
4
|
-
import type { MetadataStorage } from './MetadataStorage';
|
|
1
|
+
import type { EntityMetadata } from '../typings.js';
|
|
2
|
+
import { type MetadataDiscoveryOptions } from '../utils/Configuration.js';
|
|
3
|
+
import { ReferenceKind } from '../enums.js';
|
|
4
|
+
import type { MetadataStorage } from './MetadataStorage.js';
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const errors_1 = require("../errors");
|
|
6
|
-
const enums_1 = require("../enums");
|
|
1
|
+
import { Utils } from '../utils/Utils.js';
|
|
2
|
+
import { MetadataError } from '../errors.js';
|
|
3
|
+
import { ReferenceKind } from '../enums.js';
|
|
7
4
|
/**
|
|
8
5
|
* @internal
|
|
9
6
|
*/
|
|
10
|
-
class MetadataValidator {
|
|
7
|
+
export class MetadataValidator {
|
|
11
8
|
/**
|
|
12
9
|
* Validate there is only one property decorator. This disallows using `@Property()` together with e.g. `@ManyToOne()`
|
|
13
10
|
* on the same property. One should use only `@ManyToOne()` in such case.
|
|
@@ -15,59 +12,59 @@ class MetadataValidator {
|
|
|
15
12
|
*/
|
|
16
13
|
static validateSingleDecorator(meta, propertyName, reference) {
|
|
17
14
|
if (meta.properties[propertyName] && meta.properties[propertyName].kind !== reference) {
|
|
18
|
-
throw
|
|
15
|
+
throw MetadataError.multipleDecorators(meta.className, propertyName);
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
18
|
validateEntityDefinition(metadata, name, options) {
|
|
22
19
|
const meta = metadata.get(name);
|
|
23
20
|
if (meta.virtual || meta.expression) {
|
|
24
|
-
for (const prop of
|
|
25
|
-
if (![
|
|
26
|
-
throw new
|
|
21
|
+
for (const prop of Utils.values(meta.properties)) {
|
|
22
|
+
if (![ReferenceKind.SCALAR, ReferenceKind.EMBEDDED, ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
|
|
23
|
+
throw new MetadataError(`Only scalars, embedded properties and to-many relations are allowed inside virtual entity. Found '${prop.kind}' in ${meta.className}.${prop.name}`);
|
|
27
24
|
}
|
|
28
25
|
if (prop.primary) {
|
|
29
|
-
throw new
|
|
26
|
+
throw new MetadataError(`Virtual entity ${meta.className} cannot have primary key ${meta.className}.${prop.name}`);
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
29
|
return;
|
|
33
30
|
}
|
|
34
31
|
// entities have PK
|
|
35
32
|
if (!meta.embeddable && (!meta.primaryKeys || meta.primaryKeys.length === 0)) {
|
|
36
|
-
throw
|
|
33
|
+
throw MetadataError.fromMissingPrimaryKey(meta);
|
|
37
34
|
}
|
|
38
35
|
this.validateVersionField(meta);
|
|
39
36
|
this.validateDuplicateFieldNames(meta, options);
|
|
40
37
|
this.validateIndexes(meta, meta.indexes ?? [], 'index');
|
|
41
38
|
this.validateIndexes(meta, meta.uniques ?? [], 'unique');
|
|
42
|
-
for (const prop of
|
|
43
|
-
if (prop.kind !==
|
|
39
|
+
for (const prop of Utils.values(meta.properties)) {
|
|
40
|
+
if (prop.kind !== ReferenceKind.SCALAR) {
|
|
44
41
|
this.validateReference(meta, prop, metadata, options);
|
|
45
42
|
this.validateBidirectional(meta, prop, metadata);
|
|
46
43
|
}
|
|
47
44
|
else if (metadata.has(prop.type)) {
|
|
48
|
-
throw
|
|
45
|
+
throw MetadataError.propertyTargetsEntityType(meta, prop, metadata.get(prop.type));
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
49
|
validateDiscovered(discovered, options) {
|
|
53
50
|
if (discovered.length === 0 && options.warnWhenNoEntities) {
|
|
54
|
-
throw
|
|
51
|
+
throw MetadataError.noEntityDiscovered();
|
|
55
52
|
}
|
|
56
|
-
const duplicates =
|
|
53
|
+
const duplicates = Utils.findDuplicates(discovered.map(meta => meta.className));
|
|
57
54
|
if (duplicates.length > 0 && options.checkDuplicateEntities) {
|
|
58
|
-
throw
|
|
55
|
+
throw MetadataError.duplicateEntityDiscovered(duplicates);
|
|
59
56
|
}
|
|
60
57
|
const tableNames = discovered.filter(meta => !meta.abstract && meta === meta.root && (meta.tableName || meta.collection) && meta.schema !== '*');
|
|
61
|
-
const duplicateTableNames =
|
|
58
|
+
const duplicateTableNames = Utils.findDuplicates(tableNames.map(meta => {
|
|
62
59
|
const tableName = meta.tableName || meta.collection;
|
|
63
60
|
return (meta.schema ? '.' + meta.schema : '') + tableName;
|
|
64
61
|
}));
|
|
65
62
|
if (duplicateTableNames.length > 0 && options.checkDuplicateTableNames && options.checkDuplicateEntities) {
|
|
66
|
-
throw
|
|
63
|
+
throw MetadataError.duplicateEntityDiscovered(duplicateTableNames, 'table names');
|
|
67
64
|
}
|
|
68
65
|
// validate we found at least one entity (not just abstract/base entities)
|
|
69
66
|
if (discovered.filter(meta => meta.name).length === 0 && options.warnWhenNoEntities) {
|
|
70
|
-
throw
|
|
67
|
+
throw MetadataError.onlyAbstractEntitiesDiscovered();
|
|
71
68
|
}
|
|
72
69
|
const unwrap = (type) => type
|
|
73
70
|
.replace(/Array<(.*)>/, '$1') // unwrap array
|
|
@@ -75,15 +72,15 @@ class MetadataValidator {
|
|
|
75
72
|
.replace(/\((.*)\)/, '$1'); // unwrap union types
|
|
76
73
|
const name = (p) => {
|
|
77
74
|
if (typeof p === 'function') {
|
|
78
|
-
return
|
|
75
|
+
return Utils.className(p());
|
|
79
76
|
}
|
|
80
|
-
return
|
|
77
|
+
return Utils.className(p);
|
|
81
78
|
};
|
|
82
79
|
const pivotProps = new Map();
|
|
83
80
|
// check for not discovered entities
|
|
84
81
|
discovered.forEach(meta => Object.values(meta.properties).forEach(prop => {
|
|
85
|
-
if (prop.kind !==
|
|
86
|
-
throw
|
|
82
|
+
if (prop.kind !== ReferenceKind.SCALAR && !unwrap(prop.type).split(/ ?\| ?/).every(type => discovered.find(m => m.className === type))) {
|
|
83
|
+
throw MetadataError.fromUnknownEntity(prop.type, `${meta.className}.${prop.name}`);
|
|
87
84
|
}
|
|
88
85
|
if (prop.pivotEntity) {
|
|
89
86
|
const props = pivotProps.get(name(prop.pivotEntity)) ?? [];
|
|
@@ -94,24 +91,24 @@ class MetadataValidator {
|
|
|
94
91
|
pivotProps.forEach(props => {
|
|
95
92
|
// if the pivot entity is used in more than one property, check if they are linked
|
|
96
93
|
if (props.length > 1 && props.every(p => !p.prop.mappedBy && !p.prop.inversedBy)) {
|
|
97
|
-
throw
|
|
94
|
+
throw MetadataError.invalidManyToManyWithPivotEntity(props[0].meta, props[0].prop, props[1].meta, props[1].prop);
|
|
98
95
|
}
|
|
99
96
|
});
|
|
100
97
|
}
|
|
101
98
|
validateReference(meta, prop, metadata, options) {
|
|
102
99
|
// references do have types
|
|
103
100
|
if (!prop.type) {
|
|
104
|
-
throw
|
|
101
|
+
throw MetadataError.fromWrongTypeDefinition(meta, prop);
|
|
105
102
|
}
|
|
106
103
|
// references do have type of known entity
|
|
107
104
|
if (!metadata.find(prop.type)) {
|
|
108
|
-
throw
|
|
105
|
+
throw MetadataError.fromWrongTypeDefinition(meta, prop);
|
|
109
106
|
}
|
|
110
107
|
if (metadata.find(prop.type).abstract && !metadata.find(prop.type).discriminatorColumn) {
|
|
111
|
-
throw
|
|
108
|
+
throw MetadataError.targetIsAbstract(meta, prop);
|
|
112
109
|
}
|
|
113
|
-
if ([
|
|
114
|
-
throw
|
|
110
|
+
if ([ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) && prop.persist === false && metadata.find(prop.type).compositePK && options.checkNonPersistentCompositeProps) {
|
|
111
|
+
throw MetadataError.nonPersistentCompositeProp(meta, prop);
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
validateBidirectional(meta, prop, metadata) {
|
|
@@ -125,67 +122,67 @@ class MetadataValidator {
|
|
|
125
122
|
}
|
|
126
123
|
else {
|
|
127
124
|
// 1:m property has `mappedBy`
|
|
128
|
-
if (prop.kind ===
|
|
129
|
-
throw
|
|
125
|
+
if (prop.kind === ReferenceKind.ONE_TO_MANY && !prop.mappedBy) {
|
|
126
|
+
throw MetadataError.fromMissingOption(meta, prop, 'mappedBy');
|
|
130
127
|
}
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
130
|
validateOwningSide(meta, prop, inverse, metadata) {
|
|
134
131
|
// has correct `inversedBy` on owning side
|
|
135
132
|
if (!inverse) {
|
|
136
|
-
throw
|
|
133
|
+
throw MetadataError.fromWrongReference(meta, prop, 'inversedBy');
|
|
137
134
|
}
|
|
138
135
|
const targetClassName = metadata.find(inverse.type)?.root.className;
|
|
139
136
|
// has correct `inversedBy` reference type
|
|
140
137
|
if (inverse.type !== meta.className && targetClassName !== meta.root.className) {
|
|
141
|
-
throw
|
|
138
|
+
throw MetadataError.fromWrongReference(meta, prop, 'inversedBy', inverse);
|
|
142
139
|
}
|
|
143
140
|
// inverse side is not defined as owner
|
|
144
141
|
if (inverse.inversedBy || inverse.owner) {
|
|
145
|
-
throw
|
|
142
|
+
throw MetadataError.fromWrongOwnership(meta, prop, 'inversedBy');
|
|
146
143
|
}
|
|
147
144
|
}
|
|
148
145
|
validateInverseSide(meta, prop, owner, metadata) {
|
|
149
146
|
// has correct `mappedBy` on inverse side
|
|
150
147
|
if (prop.mappedBy && !owner) {
|
|
151
|
-
throw
|
|
148
|
+
throw MetadataError.fromWrongReference(meta, prop, 'mappedBy');
|
|
152
149
|
}
|
|
153
150
|
// has correct `mappedBy` reference type
|
|
154
151
|
if (owner.type !== meta.className && metadata.find(owner.type)?.root.className !== meta.root.className) {
|
|
155
|
-
throw
|
|
152
|
+
throw MetadataError.fromWrongReference(meta, prop, 'mappedBy', owner);
|
|
156
153
|
}
|
|
157
154
|
// owning side is not defined as inverse
|
|
158
155
|
if (owner.mappedBy) {
|
|
159
|
-
throw
|
|
156
|
+
throw MetadataError.fromWrongOwnership(meta, prop, 'mappedBy');
|
|
160
157
|
}
|
|
161
158
|
// owning side is not defined as inverse
|
|
162
159
|
const valid = [
|
|
163
|
-
{ owner:
|
|
164
|
-
{ owner:
|
|
165
|
-
{ owner:
|
|
160
|
+
{ owner: ReferenceKind.MANY_TO_ONE, inverse: ReferenceKind.ONE_TO_MANY },
|
|
161
|
+
{ owner: ReferenceKind.MANY_TO_MANY, inverse: ReferenceKind.MANY_TO_MANY },
|
|
162
|
+
{ owner: ReferenceKind.ONE_TO_ONE, inverse: ReferenceKind.ONE_TO_ONE },
|
|
166
163
|
];
|
|
167
164
|
if (!valid.find(spec => spec.owner === owner.kind && spec.inverse === prop.kind)) {
|
|
168
|
-
throw
|
|
165
|
+
throw MetadataError.fromWrongReferenceKind(meta, owner, prop);
|
|
169
166
|
}
|
|
170
167
|
if (prop.primary) {
|
|
171
|
-
throw
|
|
168
|
+
throw MetadataError.fromInversideSidePrimary(meta, owner, prop);
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
validateIndexes(meta, indexes, type) {
|
|
175
172
|
for (const index of indexes) {
|
|
176
|
-
for (const propName of
|
|
173
|
+
for (const propName of Utils.asArray(index.properties)) {
|
|
177
174
|
const prop = meta.root.properties[propName];
|
|
178
175
|
if (!prop && !Object.values(meta.root.properties).some(p => propName.startsWith(p.name + '.'))) {
|
|
179
|
-
throw
|
|
176
|
+
throw MetadataError.unknownIndexProperty(meta, propName, type);
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
validateDuplicateFieldNames(meta, options) {
|
|
185
182
|
const candidates = Object.values(meta.properties)
|
|
186
|
-
.filter(prop => prop.persist !== false && !prop.inherited && prop.fieldNames?.length === 1 && (prop.kind !==
|
|
183
|
+
.filter(prop => prop.persist !== false && !prop.inherited && prop.fieldNames?.length === 1 && (prop.kind !== ReferenceKind.EMBEDDED || prop.object))
|
|
187
184
|
.map(prop => prop.fieldNames[0]);
|
|
188
|
-
const duplicates =
|
|
185
|
+
const duplicates = Utils.findDuplicates(candidates);
|
|
189
186
|
if (duplicates.length > 0 && options.checkDuplicateFieldNames) {
|
|
190
187
|
const pairs = duplicates.flatMap(name => {
|
|
191
188
|
return Object.values(meta.properties)
|
|
@@ -194,7 +191,7 @@ class MetadataValidator {
|
|
|
194
191
|
return [prop.embedded ? prop.embedded.join('.') : prop.name, prop.fieldNames[0]];
|
|
195
192
|
});
|
|
196
193
|
});
|
|
197
|
-
throw
|
|
194
|
+
throw MetadataError.duplicateFieldName(meta.className, pairs);
|
|
198
195
|
}
|
|
199
196
|
}
|
|
200
197
|
validateVersionField(meta) {
|
|
@@ -203,13 +200,12 @@ class MetadataValidator {
|
|
|
203
200
|
}
|
|
204
201
|
const props = Object.values(meta.properties).filter(p => p.version);
|
|
205
202
|
if (props.length > 1) {
|
|
206
|
-
throw
|
|
203
|
+
throw MetadataError.multipleVersionFields(meta, props.map(p => p.name));
|
|
207
204
|
}
|
|
208
205
|
const prop = meta.properties[meta.versionProperty];
|
|
209
206
|
const type = prop.runtimeType ?? prop.columnTypes?.[0] ?? prop.type;
|
|
210
207
|
if (type !== 'number' && type !== 'Date' && !type.startsWith('timestamp') && !type.startsWith('datetime')) {
|
|
211
|
-
throw
|
|
208
|
+
throw MetadataError.invalidVersionFieldType(meta);
|
|
212
209
|
}
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
|
-
exports.MetadataValidator = MetadataValidator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import type { EntityMetadata, EntityProperty } from '../typings';
|
|
3
|
-
import { MetadataProvider } from './MetadataProvider';
|
|
2
|
+
import type { EntityMetadata, EntityProperty } from '../typings.js';
|
|
3
|
+
import { MetadataProvider } from './MetadataProvider.js';
|
|
4
4
|
export declare class ReflectMetadataProvider extends MetadataProvider {
|
|
5
5
|
loadEntityMetadata(meta: EntityMetadata, name: string): void;
|
|
6
6
|
protected initProperties(meta: EntityMetadata): void;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const enums_1 = require("../enums");
|
|
7
|
-
const Utils_1 = require("../utils/Utils");
|
|
8
|
-
class ReflectMetadataProvider extends MetadataProvider_1.MetadataProvider {
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { MetadataProvider } from './MetadataProvider.js';
|
|
3
|
+
import { ReferenceKind } from '../enums.js';
|
|
4
|
+
import { Utils } from '../utils/Utils.js';
|
|
5
|
+
export class ReflectMetadataProvider extends MetadataProvider {
|
|
9
6
|
loadEntityMetadata(meta, name) {
|
|
10
7
|
this.initProperties(meta);
|
|
11
8
|
}
|
|
@@ -17,7 +14,7 @@ class ReflectMetadataProvider extends MetadataProvider_1.MetadataProvider {
|
|
|
17
14
|
}
|
|
18
15
|
else if (prop.entity) {
|
|
19
16
|
const tmp = prop.entity();
|
|
20
|
-
prop.type = Array.isArray(tmp) ? tmp.map(t =>
|
|
17
|
+
prop.type = Array.isArray(tmp) ? tmp.map(t => Utils.className(t)).sort().join(' | ') : Utils.className(tmp);
|
|
21
18
|
}
|
|
22
19
|
else {
|
|
23
20
|
this.initPropertyType(meta, prop);
|
|
@@ -26,14 +23,14 @@ class ReflectMetadataProvider extends MetadataProvider_1.MetadataProvider {
|
|
|
26
23
|
}
|
|
27
24
|
initPropertyType(meta, prop) {
|
|
28
25
|
const type = Reflect.getMetadata('design:type', meta.prototype, prop.name);
|
|
29
|
-
if (!prop.type && (!type || (type === Object && prop.kind !==
|
|
26
|
+
if (!prop.type && (!type || (type === Object && prop.kind !== ReferenceKind.SCALAR)) && !(prop.enum && (prop.items?.length ?? 0) > 0)) {
|
|
30
27
|
throw new Error(`Please provide either 'type' or 'entity' attribute in ${meta.className}.${prop.name}. If you are using decorators, ensure you have 'emitDecoratorMetadata' enabled in your tsconfig.json.`);
|
|
31
28
|
}
|
|
32
29
|
// Force mapping to UnknownType which is a string when we see just `Object`, as that often means failed inference.
|
|
33
30
|
// This is to prevent defaulting to JSON column type, which can often be hard to revert and cause hard to understand issues with PKs.
|
|
34
31
|
// If there are explicitly provided `columnTypes`, we use those instead for the inference, this way
|
|
35
32
|
// we can have things like `columnType: 'timestamp'` be respected as `type: 'Date'`.
|
|
36
|
-
if (prop.kind ===
|
|
33
|
+
if (prop.kind === ReferenceKind.SCALAR && type === Object && !prop.columnTypes) {
|
|
37
34
|
prop.type ??= 'any';
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
@@ -45,4 +42,3 @@ class ReflectMetadataProvider extends MetadataProvider_1.MetadataProvider {
|
|
|
45
42
|
prop.runtimeType ??= typeName;
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
exports.ReflectMetadataProvider = ReflectMetadataProvider;
|
package/metadata/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './EntitySchema';
|
|
2
|
-
export * from './MetadataDiscovery';
|
|
3
|
-
export * from './MetadataStorage';
|
|
4
|
-
export * from './MetadataProvider';
|
|
5
|
-
export * from './MetadataValidator';
|
|
6
|
-
export * from './ReflectMetadataProvider';
|
|
1
|
+
export * from './EntitySchema.js';
|
|
2
|
+
export * from './MetadataDiscovery.js';
|
|
3
|
+
export * from './MetadataStorage.js';
|
|
4
|
+
export * from './MetadataProvider.js';
|
|
5
|
+
export * from './MetadataValidator.js';
|
|
6
|
+
export * from './ReflectMetadataProvider.js';
|
package/metadata/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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("./EntitySchema"), exports);
|
|
18
|
-
__exportStar(require("./MetadataDiscovery"), exports);
|
|
19
|
-
__exportStar(require("./MetadataStorage"), exports);
|
|
20
|
-
__exportStar(require("./MetadataProvider"), exports);
|
|
21
|
-
__exportStar(require("./MetadataValidator"), exports);
|
|
22
|
-
__exportStar(require("./ReflectMetadataProvider"), exports);
|
|
1
|
+
export * from './EntitySchema.js';
|
|
2
|
+
export * from './MetadataDiscovery.js';
|
|
3
|
+
export * from './MetadataStorage.js';
|
|
4
|
+
export * from './MetadataProvider.js';
|
|
5
|
+
export * from './MetadataValidator.js';
|
|
6
|
+
export * from './ReflectMetadataProvider.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NamingStrategy } from './NamingStrategy';
|
|
2
|
-
import { type ReferenceKind } from '../enums';
|
|
1
|
+
import type { NamingStrategy } from './NamingStrategy.js';
|
|
2
|
+
import { type ReferenceKind } from '../enums.js';
|
|
3
3
|
export declare abstract class AbstractNamingStrategy implements NamingStrategy {
|
|
4
4
|
getClassName(file: string, separator?: string): string;
|
|
5
5
|
classToMigrationName(timestamp: string, customMigrationName?: string): string;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const populatePathMembers = Object.values(enums_1.PopulatePath);
|
|
6
|
-
class AbstractNamingStrategy {
|
|
1
|
+
import { PopulatePath } from '../enums.js';
|
|
2
|
+
const populatePathMembers = Object.values(PopulatePath);
|
|
3
|
+
export class AbstractNamingStrategy {
|
|
7
4
|
getClassName(file, separator = '-') {
|
|
8
5
|
const name = file.split('.')[0];
|
|
9
6
|
const ret = name.replace(new RegExp(`(?:${separator})+(\\w)`, 'ug'), (_, p1) => p1.toUpperCase());
|
|
@@ -17,7 +14,7 @@ class AbstractNamingStrategy {
|
|
|
17
14
|
return migrationName;
|
|
18
15
|
}
|
|
19
16
|
indexName(tableName, columns, type) {
|
|
20
|
-
/*
|
|
17
|
+
/* v8 ignore next 3 */
|
|
21
18
|
if (tableName.includes('.')) {
|
|
22
19
|
tableName = tableName.substring(tableName.indexOf('.') + 1);
|
|
23
20
|
}
|
|
@@ -77,4 +74,3 @@ class AbstractNamingStrategy {
|
|
|
77
74
|
return entityName[0].toLowerCase() + entityName.substring(1) + suffix;
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
|
-
exports.AbstractNamingStrategy = AbstractNamingStrategy;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityCaseNamingStrategy = void 0;
|
|
4
|
-
const AbstractNamingStrategy_1 = require("./AbstractNamingStrategy");
|
|
1
|
+
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
5
2
|
/**
|
|
6
3
|
* This strategy keeps original entity/property names for table/column.
|
|
7
4
|
*/
|
|
8
|
-
class EntityCaseNamingStrategy extends
|
|
5
|
+
export class EntityCaseNamingStrategy extends AbstractNamingStrategy {
|
|
9
6
|
classToTableName(entityName) {
|
|
10
7
|
return entityName;
|
|
11
8
|
}
|
|
@@ -29,4 +26,3 @@ class EntityCaseNamingStrategy extends AbstractNamingStrategy_1.AbstractNamingSt
|
|
|
29
26
|
return 'id';
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
exports.EntityCaseNamingStrategy = EntityCaseNamingStrategy;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractNamingStrategy } from './AbstractNamingStrategy';
|
|
1
|
+
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export declare class MongoNamingStrategy extends AbstractNamingStrategy {
|
|
3
3
|
classToTableName(entityName: string): string;
|
|
4
4
|
joinColumnName(propertyName: string): string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MongoNamingStrategy = void 0;
|
|
4
|
-
const AbstractNamingStrategy_1 = require("./AbstractNamingStrategy");
|
|
5
|
-
class MongoNamingStrategy extends AbstractNamingStrategy_1.AbstractNamingStrategy {
|
|
1
|
+
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
|
+
export class MongoNamingStrategy extends AbstractNamingStrategy {
|
|
6
3
|
classToTableName(entityName) {
|
|
7
4
|
return entityName.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
8
5
|
}
|
|
@@ -22,4 +19,3 @@ class MongoNamingStrategy extends AbstractNamingStrategy_1.AbstractNamingStrateg
|
|
|
22
19
|
return '_id';
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.MongoNamingStrategy = MongoNamingStrategy;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractNamingStrategy } from './AbstractNamingStrategy';
|
|
1
|
+
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
2
|
export declare class UnderscoreNamingStrategy extends AbstractNamingStrategy {
|
|
3
3
|
classToTableName(entityName: string): string;
|
|
4
4
|
joinColumnName(propertyName: string): string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.UnderscoreNamingStrategy = void 0;
|
|
4
|
-
const AbstractNamingStrategy_1 = require("./AbstractNamingStrategy");
|
|
5
|
-
class UnderscoreNamingStrategy extends AbstractNamingStrategy_1.AbstractNamingStrategy {
|
|
1
|
+
import { AbstractNamingStrategy } from './AbstractNamingStrategy.js';
|
|
2
|
+
export class UnderscoreNamingStrategy extends AbstractNamingStrategy {
|
|
6
3
|
classToTableName(entityName) {
|
|
7
4
|
return this.underscore(entityName);
|
|
8
5
|
}
|
|
@@ -25,4 +22,3 @@ class UnderscoreNamingStrategy extends AbstractNamingStrategy_1.AbstractNamingSt
|
|
|
25
22
|
return name.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.UnderscoreNamingStrategy = UnderscoreNamingStrategy;
|
|
@@ -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';
|