typeorm 1.0.0 → 1.1.0-nightly.20260714
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/README.md +0 -2
- package/browser/cache/DbQueryResultCache.js +43 -39
- package/browser/cache/DbQueryResultCache.js.map +1 -1
- package/browser/common/PrimitiveCriteria.js.map +1 -1
- package/browser/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/browser/connection/ConnectionOptionsReader.js +2 -4
- package/browser/connection/ConnectionOptionsReader.js.map +1 -1
- package/browser/data-source/BaseDataSourceOptions.d.ts +16 -24
- package/browser/data-source/BaseDataSourceOptions.js.map +1 -1
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/decorator/ForeignKey.js.map +1 -1
- package/browser/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
- package/browser/decorator/options/RelationOptions.js.map +1 -1
- package/browser/decorator/tree/TreeChildren.js.map +1 -1
- package/browser/driver/capacitor/CapacitorDataSourceOptions.js.map +1 -1
- package/browser/driver/expo/ExpoDriver.d.ts +1 -13
- package/browser/driver/expo/ExpoDriver.js +10 -61
- package/browser/driver/expo/ExpoDriver.js.map +1 -1
- package/browser/driver/mongodb/typings.d.ts +1 -0
- package/browser/driver/mongodb/typings.js.map +1 -1
- package/browser/driver/mysql/MysqlDriver.js +19 -18
- package/browser/driver/mysql/MysqlDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.js +21 -32
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/react-native/ReactNativeDriver.d.ts +1 -1
- package/browser/driver/react-native/ReactNativeDriver.js +5 -3
- package/browser/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/browser/driver/sap/SapDriver.d.ts +0 -5
- package/browser/driver/sap/SapDriver.js +0 -5
- package/browser/driver/sap/SapDriver.js.map +1 -1
- package/browser/driver/spanner/SpannerDriver.d.ts +1 -8
- package/browser/driver/spanner/SpannerDriver.js +4 -25
- package/browser/driver/spanner/SpannerDriver.js.map +1 -1
- package/browser/driver/types/InvalidFindOptionsWhereBehavior.d.ts +15 -0
- package/browser/driver/types/InvalidFindOptionsWhereBehavior.js +3 -0
- package/browser/driver/types/InvalidFindOptionsWhereBehavior.js.map +1 -0
- package/browser/entity-manager/EntityManager.d.ts +23 -0
- package/browser/entity-manager/EntityManager.js +79 -106
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.js +30 -20
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/browser/error/AlreadyHasActiveConnectionError.js +1 -1
- package/browser/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/browser/find-options/FindOneOptions.js.map +1 -1
- package/browser/find-options/FindOptionsWhere.js.map +1 -1
- package/browser/logger/AbstractLogger.js.map +1 -1
- package/browser/logger/Logger.js.map +1 -1
- package/browser/metadata/IndexMetadata.js.map +1 -1
- package/browser/metadata/UniqueMetadata.js.map +1 -1
- package/browser/metadata/types/ClosureTreeOptions.d.ts +1 -0
- package/browser/metadata/types/ClosureTreeOptions.js.map +1 -1
- package/browser/metadata/types/OnDeleteType.js.map +1 -1
- package/browser/metadata/types/OnUpdateType.js.map +1 -1
- package/browser/metadata/types/RelationTypeInFunction.js.map +1 -1
- package/browser/metadata/types/RelationTypes.js.map +1 -1
- package/browser/metadata/types/TreeTypes.js.map +1 -1
- package/browser/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +6 -2
- package/browser/metadata-builder/ClosureJunctionEntityMetadataBuilder.js.map +1 -1
- package/browser/persistence/SubjectExecutor.js +0 -8
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/browser/platform/BrowserPlatformTools.d.ts +6 -1
- package/browser/platform/BrowserPlatformTools.js +27 -7
- package/browser/platform/BrowserPlatformTools.js.map +1 -1
- package/browser/platform/PlatformTools.d.ts +12 -11
- package/browser/platform/PlatformTools.js +62 -95
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/JoinAttribute.d.ts +6 -2
- package/browser/query-builder/JoinAttribute.js +3 -3
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/QueryBuilder.js +24 -6
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +30 -13
- package/browser/query-builder/SelectQueryBuilder.js +247 -224
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/query-builder/WhereClause.js.map +1 -1
- package/browser/query-builder/transformer/DocumentToEntityTransformer.d.ts +1 -2
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js +0 -3
- package/browser/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/browser/repository/BaseEntity.js.map +1 -1
- package/browser/repository/MongoRepository.js.map +1 -1
- package/browser/repository/Repository.js.map +1 -1
- package/browser/repository/TreeRepository.js +2 -2
- package/browser/repository/TreeRepository.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/util/OrmUtils.d.ts +15 -9
- package/browser/util/OrmUtils.js +32 -14
- package/browser/util/OrmUtils.js.map +1 -1
- package/browser/util/RandomGenerator.js +4 -3
- package/browser/util/RandomGenerator.js.map +1 -1
- package/browser/util/StringUtils.d.ts +0 -8
- package/browser/util/StringUtils.js +2 -37
- package/browser/util/StringUtils.js.map +1 -1
- package/cache/DbQueryResultCache.js +43 -39
- package/cache/DbQueryResultCache.js.map +1 -1
- package/commands/MigrationGenerateCommand.d.ts +8 -0
- package/commands/MigrationGenerateCommand.js +15 -2
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/common/PrimitiveCriteria.js.map +1 -1
- package/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/connection/ConnectionOptionsReader.js +2 -4
- package/connection/ConnectionOptionsReader.js.map +1 -1
- package/data-source/BaseDataSourceOptions.d.ts +16 -24
- package/data-source/BaseDataSourceOptions.js.map +1 -1
- package/data-source/DataSource.js.map +1 -1
- package/decorator/ForeignKey.js.map +1 -1
- package/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
- package/decorator/options/RelationOptions.js.map +1 -1
- package/decorator/tree/TreeChildren.js.map +1 -1
- package/driver/capacitor/CapacitorDataSourceOptions.js.map +1 -1
- package/driver/expo/ExpoDriver.d.ts +1 -13
- package/driver/expo/ExpoDriver.js +10 -61
- package/driver/expo/ExpoDriver.js.map +1 -1
- package/driver/mongodb/typings.d.ts +1 -0
- package/driver/mongodb/typings.js.map +1 -1
- package/driver/mysql/MysqlDriver.js +19 -18
- package/driver/mysql/MysqlDriver.js.map +1 -1
- package/driver/postgres/PostgresDriver.js +21 -32
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/react-native/ReactNativeDriver.d.ts +1 -1
- package/driver/react-native/ReactNativeDriver.js +5 -3
- package/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/driver/sap/SapDriver.d.ts +0 -5
- package/driver/sap/SapDriver.js +0 -5
- package/driver/sap/SapDriver.js.map +1 -1
- package/driver/spanner/SpannerDriver.d.ts +1 -8
- package/driver/spanner/SpannerDriver.js +4 -25
- package/driver/spanner/SpannerDriver.js.map +1 -1
- package/driver/types/InvalidFindOptionsWhereBehavior.d.ts +15 -0
- package/driver/types/InvalidFindOptionsWhereBehavior.js +3 -0
- package/driver/types/InvalidFindOptionsWhereBehavior.js.map +1 -0
- package/entity-manager/EntityManager.d.ts +23 -0
- package/entity-manager/EntityManager.js +79 -106
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.js +30 -20
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/error/AlreadyHasActiveConnectionError.js +1 -1
- package/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/find-options/FindOneOptions.js.map +1 -1
- package/find-options/FindOptionsWhere.js.map +1 -1
- package/logger/AbstractLogger.js.map +1 -1
- package/logger/Logger.js.map +1 -1
- package/metadata/IndexMetadata.js.map +1 -1
- package/metadata/UniqueMetadata.js.map +1 -1
- package/metadata/types/ClosureTreeOptions.d.ts +1 -0
- package/metadata/types/ClosureTreeOptions.js.map +1 -1
- package/metadata/types/OnDeleteType.js.map +1 -1
- package/metadata/types/OnUpdateType.js.map +1 -1
- package/metadata/types/RelationTypeInFunction.js.map +1 -1
- package/metadata/types/RelationTypes.js.map +1 -1
- package/metadata/types/TreeTypes.js.map +1 -1
- package/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +6 -2
- package/metadata-builder/ClosureJunctionEntityMetadataBuilder.js.map +1 -1
- package/package.json +7 -7
- package/persistence/SubjectExecutor.js +0 -8
- package/persistence/SubjectExecutor.js.map +1 -1
- package/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/platform/PlatformTools.d.ts +12 -11
- package/platform/PlatformTools.js +62 -95
- package/platform/PlatformTools.js.map +1 -1
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/JoinAttribute.d.ts +6 -2
- package/query-builder/JoinAttribute.js +3 -3
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/QueryBuilder.js +24 -6
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +30 -13
- package/query-builder/SelectQueryBuilder.js +247 -224
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/query-builder/WhereClause.js.map +1 -1
- package/query-builder/transformer/DocumentToEntityTransformer.d.ts +1 -2
- package/query-builder/transformer/DocumentToEntityTransformer.js +0 -3
- package/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/repository/BaseEntity.js.map +1 -1
- package/repository/MongoRepository.js.map +1 -1
- package/repository/Repository.js.map +1 -1
- package/repository/TreeRepository.js +2 -2
- package/repository/TreeRepository.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/util/OrmUtils.d.ts +15 -9
- package/util/OrmUtils.js +32 -14
- package/util/OrmUtils.js.map +1 -1
- package/util/RandomGenerator.js +4 -3
- package/util/RandomGenerator.js.map +1 -1
- package/util/StringUtils.d.ts +0 -8
- package/util/StringUtils.js +2 -37
- package/util/StringUtils.js.map +1 -1
package/README.md
CHANGED
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
<br>
|
|
11
11
|
<a href="https://www.npmjs.com/package/typeorm"><img src="https://img.shields.io/npm/v/typeorm" alt="NPM Version"/></a>
|
|
12
12
|
<a href="https://www.npmjs.com/package/typeorm"><img src="https://img.shields.io/npm/dm/typeorm" alt="NPM Downloads"/></a>
|
|
13
|
-
<a href="https://github.com/typeorm/typeorm/actions/workflows/tests.yml?query=branch%3Amaster"><img src="https://github.com/typeorm/typeorm/actions/workflows/tests.yml/badge.svg?branch=master" alt="Commit Validation"/></a>
|
|
14
13
|
<a href="https://sonarcloud.io/summary/overall?id=typeorm_typeorm"><img src="https://sonarcloud.io/api/project_badges/measure?project=typeorm_typeorm&metric=coverage" alt="Coverage"/></a>
|
|
15
|
-
<a href='https://dashboard.stryker-mutator.io/reports/github.com/typeorm/typeorm/master'><img src='https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Ftypeorm%2Ftypeorm%2Fmaster' alt='Mutation testing badge' /></a>
|
|
16
14
|
<a href=""><img src="https://img.shields.io/badge/License-MIT-teal.svg" alt="MIT License"/></a>
|
|
17
15
|
<br>
|
|
18
16
|
<br>
|
|
@@ -187,51 +187,55 @@ class DbQueryResultCache {
|
|
|
187
187
|
result: new MssqlParameter_1.MssqlParameter(options.result, "nvarchar"),
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
condition
|
|
198
|
-
|
|
199
|
-
await qb.execute();
|
|
200
|
-
}
|
|
201
|
-
else if (savedCache?.query) {
|
|
202
|
-
// if exist then update
|
|
203
|
-
const qb = queryRunner.manager
|
|
204
|
-
.createQueryBuilder()
|
|
205
|
-
.update(this.queryResultCacheTable)
|
|
206
|
-
.set(insertedValues);
|
|
207
|
-
if (this.dataSource.driver.options.type === "oracle") {
|
|
208
|
-
qb.where(`dbms_lob.compare("query", :condition) = 0`, {
|
|
209
|
-
condition: insertedValues.query,
|
|
190
|
+
try {
|
|
191
|
+
if (savedCache?.identifier) {
|
|
192
|
+
// if exist then update
|
|
193
|
+
const qb = queryRunner.manager
|
|
194
|
+
.createQueryBuilder()
|
|
195
|
+
.update(this.queryResultCacheTable)
|
|
196
|
+
.set(insertedValues);
|
|
197
|
+
qb.where(`${qb.escape("identifier")} = :condition`, {
|
|
198
|
+
condition: insertedValues.identifier,
|
|
210
199
|
});
|
|
200
|
+
await qb.execute();
|
|
201
|
+
}
|
|
202
|
+
else if (savedCache?.query) {
|
|
203
|
+
// if exist then update
|
|
204
|
+
const qb = queryRunner.manager
|
|
205
|
+
.createQueryBuilder()
|
|
206
|
+
.update(this.queryResultCacheTable)
|
|
207
|
+
.set(insertedValues);
|
|
208
|
+
if (this.dataSource.driver.options.type === "oracle") {
|
|
209
|
+
qb.where(`dbms_lob.compare("query", :condition) = 0`, {
|
|
210
|
+
condition: insertedValues.query,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
qb.where(`${qb.escape("query")} = :condition`, {
|
|
215
|
+
condition: insertedValues.query,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
await qb.execute();
|
|
211
219
|
}
|
|
212
220
|
else {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
221
|
+
// Spanner does not support auto-generated columns
|
|
222
|
+
if (this.dataSource.driver.options.type === "spanner" &&
|
|
223
|
+
!insertedValues.id) {
|
|
224
|
+
insertedValues.id = RandomGenerator_1.RandomGenerator.uuidv4();
|
|
225
|
+
}
|
|
226
|
+
// otherwise insert
|
|
227
|
+
await queryRunner.manager
|
|
228
|
+
.createQueryBuilder()
|
|
229
|
+
.insert()
|
|
230
|
+
.into(this.queryResultCacheTable)
|
|
231
|
+
.values(insertedValues)
|
|
232
|
+
.execute();
|
|
216
233
|
}
|
|
217
|
-
await qb.execute();
|
|
218
234
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
!insertedValues.id) {
|
|
223
|
-
insertedValues.id = RandomGenerator_1.RandomGenerator.uuidv4();
|
|
235
|
+
finally {
|
|
236
|
+
if (shouldCreateQueryRunner) {
|
|
237
|
+
await queryRunner.release();
|
|
224
238
|
}
|
|
225
|
-
// otherwise insert
|
|
226
|
-
await queryRunner.manager
|
|
227
|
-
.createQueryBuilder()
|
|
228
|
-
.insert()
|
|
229
|
-
.into(this.queryResultCacheTable)
|
|
230
|
-
.values(insertedValues)
|
|
231
|
-
.execute();
|
|
232
|
-
}
|
|
233
|
-
if (shouldCreateQueryRunner) {
|
|
234
|
-
await queryRunner.release();
|
|
235
239
|
}
|
|
236
240
|
}
|
|
237
241
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbQueryResultCache.js","sourceRoot":"../build/browser/src/","sources":["cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,uEAAmE;AAEnE,yDAAqD;AACrD,6DAAyD;AAIzD;;GAEG;AACH,MAAa,kBAAkB;IAW3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,CAAA;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QA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3B,MAAM,EAAE,GAAG,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAA;YACpD,OAAO,EAAE;iBACJ,MAAM,EAAE;iBACR,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC;iBAChC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;gBAC/C,UAAU;aACb,CAAC;iBACD,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CACL,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;QAChC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;OAIG;IACO,cAAc,CAAC,WAAyB;QAC9C,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;IAC9C,CAAC;CACJ;AAtVD,gDAsVC","sourcesContent":["import type { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport type { DataSource } from \"../data-source/DataSource\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport type { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { RandomGenerator } from \"../util/RandomGenerator\"\nimport type { QueryResultCache } from \"./QueryResultCache\"\nimport type { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string\n\n private queryResultCacheDatabase?: string\n\n private queryResultCacheSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected dataSource: DataSource) {\n const { schema } = this.dataSource.driver.options as any\n const database = this.dataSource.driver.database\n const cacheOptions =\n typeof this.dataSource.options.cache === \"object\"\n ? this.dataSource.options.cache\n : {}\n const tableName =\n cacheOptions.tableName === \"\" ? undefined : cacheOptions.tableName\n const cacheTableName = tableName ?? \"query-result-cache\"\n\n this.queryResultCacheDatabase = database\n this.queryResultCacheSchema = schema\n this.queryResultCacheTable = this.dataSource.driver.buildTableName(\n cacheTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {}\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {}\n\n /**\n * Creates table for storing cache if it does not exist yet.\n *\n * @param queryRunner\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner)\n const driver = this.dataSource.driver\n const tableExist = await queryRunner.hasTable(\n this.queryResultCacheTable,\n ) // todo: table name should be configurable\n if (tableExist) return\n\n await queryRunner.createTable(\n new Table({\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheId,\n }),\n generationStrategy:\n driver.options.type === \"spanner\"\n ? \"uuid\"\n : \"increment\",\n isGenerated: true,\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheIdentifier,\n }),\n isNullable: true,\n },\n {\n name: \"time\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheTime,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"duration\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheDuration,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"query\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheQuery,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"result\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheResult,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n\n /**\n * Get data from cache.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n *\n * @param options\n * @param queryRunner\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n queryRunner = this.getQueryRunner(queryRunner)\n const qb = this.dataSource\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\")\n\n if (options.identifier) {\n return qb\n .where(\n `${qb.escape(\"cache\")}.${qb.escape(\n \"identifier\",\n )} = :identifier`,\n )\n .setParameters({\n identifier:\n this.dataSource.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.identifier, \"nvarchar\")\n : options.identifier,\n })\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n } else if (options.query) {\n if (this.dataSource.driver.options.type === \"oracle\") {\n return qb\n .where(\n `dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\n \"query\",\n )}, :query) = 0`,\n { query: options.query },\n )\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({\n query:\n this.dataSource.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.query, \"nvarchar\")\n : options.query,\n })\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n }\n\n return Promise.resolve(undefined)\n }\n\n /**\n * Checks if cache is expired or not.\n *\n * @param savedCache\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration =\n typeof savedCache.duration === \"string\"\n ? parseInt(savedCache.duration)\n : savedCache.duration\n return (\n (typeof savedCache.time === \"string\"\n ? parseInt(savedCache.time as any)\n : savedCache.time)! +\n duration <\n Date.now()\n )\n }\n\n /**\n * Stores given query result in the cache.\n *\n * @param options\n * @param savedCache\n * @param queryRunner\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions | undefined,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const shouldCreateQueryRunner =\n queryRunner === undefined ||\n queryRunner?.getReplicationMode() === \"slave\"\n\n if (queryRunner === undefined || shouldCreateQueryRunner) {\n queryRunner = this.dataSource.createQueryRunner(\"master\")\n }\n\n let insertedValues: ObjectLiteral = options\n if (this.dataSource.driver.options.type === \"mssql\") {\n // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n }\n }\n\n if (savedCache?.identifier) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, {\n condition: insertedValues.identifier,\n })\n await qb.execute()\n } else if (savedCache?.query) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n if (this.dataSource.driver.options.type === \"oracle\") {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, {\n condition: insertedValues.query,\n })\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, {\n condition: insertedValues.query,\n })\n }\n\n await qb.execute()\n } else {\n // Spanner does not support auto-generated columns\n if (\n this.dataSource.driver.options.type === \"spanner\" &&\n !insertedValues.id\n ) {\n insertedValues.id = RandomGenerator.uuidv4()\n }\n\n // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute()\n }\n\n if (shouldCreateQueryRunner) {\n await queryRunner.release()\n }\n }\n\n /**\n * Clears everything stored in the cache.\n *\n * @param queryRunner\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(\n this.queryResultCacheTable,\n )\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n *\n * @param identifiers\n * @param queryRunner\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const _queryRunner: QueryRunner = queryRunner ?? this.getQueryRunner()\n await Promise.all(\n identifiers.map((identifier) => {\n const qb = _queryRunner.manager.createQueryBuilder()\n return qb\n .delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {\n identifier,\n })\n .execute()\n }),\n )\n\n if (!queryRunner) {\n await _queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n *\n * @param queryRunner\n */\n protected getQueryRunner(queryRunner?: QueryRunner): QueryRunner {\n if (queryRunner) return queryRunner\n\n return this.dataSource.createQueryRunner()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DbQueryResultCache.js","sourceRoot":"../build/browser/src/","sources":["cache/DbQueryResultCache.ts"],"names":[],"mappings":";;;AAEA,uEAAmE;AAEnE,yDAAqD;AACrD,6DAAyD;AAIzD;;GAEG;AACH,MAAa,kBAAkB;IAW3B,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;QACxC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAc,CAAA;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAA;QAChD,MAAM,YAAY,GACd,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ;YAC7C,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK;YAC/B,CAAC,CAAC,EAAE,CAAA;QACZ,MAAM,SAA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CAAC,IAAI,CAAC,qBAAqB,CAAC;iBAChC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;gBAC/C,UAAU;aACb,CAAC;iBACD,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CACL,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,YAAY,CAAC,OAAO,EAAE,CAAA;QAChC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;OAIG;IACO,cAAc,CAAC,WAAyB;QAC9C,IAAI,WAAW;YAAE,OAAO,WAAW,CAAA;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAA;IAC9C,CAAC;CACJ;AAxVD,gDAwVC","sourcesContent":["import type { ObjectLiteral } from \"../common/ObjectLiteral\"\nimport type { DataSource } from \"../data-source/DataSource\"\nimport { MssqlParameter } from \"../driver/sqlserver/MssqlParameter\"\nimport type { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { Table } from \"../schema-builder/table/Table\"\nimport { RandomGenerator } from \"../util/RandomGenerator\"\nimport type { QueryResultCache } from \"./QueryResultCache\"\nimport type { QueryResultCacheOptions } from \"./QueryResultCacheOptions\"\n\n/**\n * Caches query result into current database, into separate table called \"query-result-cache\".\n */\nexport class DbQueryResultCache implements QueryResultCache {\n // -------------------------------------------------------------------------\n // Private properties\n // -------------------------------------------------------------------------\n\n private queryResultCacheTable: string\n\n private queryResultCacheDatabase?: string\n\n private queryResultCacheSchema?: string\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected dataSource: DataSource) {\n const { schema } = this.dataSource.driver.options as any\n const database = this.dataSource.driver.database\n const cacheOptions =\n typeof this.dataSource.options.cache === \"object\"\n ? this.dataSource.options.cache\n : {}\n const tableName =\n cacheOptions.tableName === \"\" ? undefined : cacheOptions.tableName\n const cacheTableName = tableName ?? \"query-result-cache\"\n\n this.queryResultCacheDatabase = database\n this.queryResultCacheSchema = schema\n this.queryResultCacheTable = this.dataSource.driver.buildTableName(\n cacheTableName,\n schema,\n database,\n )\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Creates a connection with given cache provider.\n */\n async connect(): Promise<void> {}\n\n /**\n * Disconnects with given cache provider.\n */\n async disconnect(): Promise<void> {}\n\n /**\n * Creates table for storing cache if it does not exist yet.\n *\n * @param queryRunner\n */\n async synchronize(queryRunner?: QueryRunner): Promise<void> {\n queryRunner = this.getQueryRunner(queryRunner)\n const driver = this.dataSource.driver\n const tableExist = await queryRunner.hasTable(\n this.queryResultCacheTable,\n ) // todo: table name should be configurable\n if (tableExist) return\n\n await queryRunner.createTable(\n new Table({\n database: this.queryResultCacheDatabase,\n schema: this.queryResultCacheSchema,\n name: this.queryResultCacheTable,\n columns: [\n {\n name: \"id\",\n isPrimary: true,\n isNullable: false,\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheId,\n }),\n generationStrategy:\n driver.options.type === \"spanner\"\n ? \"uuid\"\n : \"increment\",\n isGenerated: true,\n },\n {\n name: \"identifier\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheIdentifier,\n }),\n isNullable: true,\n },\n {\n name: \"time\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheTime,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"duration\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheDuration,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"query\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheQuery,\n }),\n isPrimary: false,\n isNullable: false,\n },\n {\n name: \"result\",\n type: driver.normalizeType({\n type: driver.mappedDataTypes.cacheResult,\n }),\n isNullable: false,\n },\n ],\n }),\n )\n }\n\n /**\n * Get data from cache.\n * Returns cache result if found.\n * Returns undefined if result is not cached.\n *\n * @param options\n * @param queryRunner\n */\n getFromCache(\n options: QueryResultCacheOptions,\n queryRunner?: QueryRunner,\n ): Promise<QueryResultCacheOptions | undefined> {\n queryRunner = this.getQueryRunner(queryRunner)\n const qb = this.dataSource\n .createQueryBuilder(queryRunner)\n .select()\n .from(this.queryResultCacheTable, \"cache\")\n\n if (options.identifier) {\n return qb\n .where(\n `${qb.escape(\"cache\")}.${qb.escape(\n \"identifier\",\n )} = :identifier`,\n )\n .setParameters({\n identifier:\n this.dataSource.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.identifier, \"nvarchar\")\n : options.identifier,\n })\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n } else if (options.query) {\n if (this.dataSource.driver.options.type === \"oracle\") {\n return qb\n .where(\n `dbms_lob.compare(${qb.escape(\"cache\")}.${qb.escape(\n \"query\",\n )}, :query) = 0`,\n { query: options.query },\n )\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n }\n\n return qb\n .where(`${qb.escape(\"cache\")}.${qb.escape(\"query\")} = :query`)\n .setParameters({\n query:\n this.dataSource.driver.options.type === \"mssql\"\n ? new MssqlParameter(options.query, \"nvarchar\")\n : options.query,\n })\n .cache(false) // disable cache to avoid infinite loops when cache is alwaysEnable\n .getRawOne()\n }\n\n return Promise.resolve(undefined)\n }\n\n /**\n * Checks if cache is expired or not.\n *\n * @param savedCache\n */\n isExpired(savedCache: QueryResultCacheOptions): boolean {\n const duration =\n typeof savedCache.duration === \"string\"\n ? parseInt(savedCache.duration)\n : savedCache.duration\n return (\n (typeof savedCache.time === \"string\"\n ? parseInt(savedCache.time as any)\n : savedCache.time)! +\n duration <\n Date.now()\n )\n }\n\n /**\n * Stores given query result in the cache.\n *\n * @param options\n * @param savedCache\n * @param queryRunner\n */\n async storeInCache(\n options: QueryResultCacheOptions,\n savedCache: QueryResultCacheOptions | undefined,\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const shouldCreateQueryRunner =\n queryRunner === undefined ||\n queryRunner?.getReplicationMode() === \"slave\"\n\n if (queryRunner === undefined || shouldCreateQueryRunner) {\n queryRunner = this.dataSource.createQueryRunner(\"master\")\n }\n\n let insertedValues: ObjectLiteral = options\n if (this.dataSource.driver.options.type === \"mssql\") {\n // todo: bad abstraction, re-implement this part, probably better if we create an entity metadata for cache table\n insertedValues = {\n identifier: new MssqlParameter(options.identifier, \"nvarchar\"),\n time: new MssqlParameter(options.time, \"bigint\"),\n duration: new MssqlParameter(options.duration, \"int\"),\n query: new MssqlParameter(options.query, \"nvarchar\"),\n result: new MssqlParameter(options.result, \"nvarchar\"),\n }\n }\n\n try {\n if (savedCache?.identifier) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n qb.where(`${qb.escape(\"identifier\")} = :condition`, {\n condition: insertedValues.identifier,\n })\n await qb.execute()\n } else if (savedCache?.query) {\n // if exist then update\n const qb = queryRunner.manager\n .createQueryBuilder()\n .update(this.queryResultCacheTable)\n .set(insertedValues)\n\n if (this.dataSource.driver.options.type === \"oracle\") {\n qb.where(`dbms_lob.compare(\"query\", :condition) = 0`, {\n condition: insertedValues.query,\n })\n } else {\n qb.where(`${qb.escape(\"query\")} = :condition`, {\n condition: insertedValues.query,\n })\n }\n\n await qb.execute()\n } else {\n // Spanner does not support auto-generated columns\n if (\n this.dataSource.driver.options.type === \"spanner\" &&\n !insertedValues.id\n ) {\n insertedValues.id = RandomGenerator.uuidv4()\n }\n\n // otherwise insert\n await queryRunner.manager\n .createQueryBuilder()\n .insert()\n .into(this.queryResultCacheTable)\n .values(insertedValues)\n .execute()\n }\n } finally {\n if (shouldCreateQueryRunner) {\n await queryRunner.release()\n }\n }\n }\n\n /**\n * Clears everything stored in the cache.\n *\n * @param queryRunner\n */\n async clear(queryRunner: QueryRunner): Promise<void> {\n return this.getQueryRunner(queryRunner).clearTable(\n this.queryResultCacheTable,\n )\n }\n\n /**\n * Removes all cached results by given identifiers from cache.\n *\n * @param identifiers\n * @param queryRunner\n */\n async remove(\n identifiers: string[],\n queryRunner?: QueryRunner,\n ): Promise<void> {\n const _queryRunner: QueryRunner = queryRunner ?? this.getQueryRunner()\n await Promise.all(\n identifiers.map((identifier) => {\n const qb = _queryRunner.manager.createQueryBuilder()\n return qb\n .delete()\n .from(this.queryResultCacheTable)\n .where(`${qb.escape(\"identifier\")} = :identifier`, {\n identifier,\n })\n .execute()\n }),\n )\n\n if (!queryRunner) {\n await _queryRunner.release()\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets a query runner to work with.\n *\n * @param queryRunner\n */\n protected getQueryRunner(queryRunner?: QueryRunner): QueryRunner {\n if (queryRunner) return queryRunner\n\n return this.dataSource.createQueryRunner()\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimitiveCriteria.js","sourceRoot":"../build/browser/src/","sources":["common/PrimitiveCriteria.ts"],"names":[],"mappings":"","sourcesContent":["export type SinglePrimitiveCriteria = string | number | Date\n\nexport type PrimitiveCriteria =\n
|
|
1
|
+
{"version":3,"file":"PrimitiveCriteria.js","sourceRoot":"../build/browser/src/","sources":["common/PrimitiveCriteria.ts"],"names":[],"mappings":"","sourcesContent":["export type SinglePrimitiveCriteria = string | number | Date\n\nexport type PrimitiveCriteria =\n SinglePrimitiveCriteria | SinglePrimitiveCriteria[]\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionMetadataBuilder.js","sourceRoot":"../build/browser/src/","sources":["connection/ConnectionMetadataBuilder.ts"],"names":[],"mappings":";;;AAAA,2FAAqF;AACrF,+CAA2C;AAE3C,wCAAmD;AACnD,qFAAiF;AACjF,sFAAkF;AAKlF,6DAAyD;AAEzD;;GAEG;AACH,MAAa,yBAAyB;IAClC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEhD,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;;OAIG;IACH,KAAK,CAAC,eAAe,CACjB,UAAiC;QAEjC,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,GAC1C,mBAAQ,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;QAC/C,MAAM,mBAAmB,GAAG;YACxB,GAAG,gBAAgB;YACnB,GAAG,CAAC,MAAM,IAAA,6DAA4B,EAClC,IAAI,CAAC,UAAU,CAAC,MAAM,EACtB,oBAAoB,CACvB,CAAC;SACL,CAAA;QACD,OAAO,mBAAmB,CAAC,GAAG,CAC1B,CAAC,cAAc,EAAE,EAAE,CACf,IAAK,cAA+C,EAAE,CAC7D,CAAA;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB,CAClB,WAAkC;QAElC,MAAM,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,GAC5C,mBAAQ,CAAC,sBAAsB,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;QACtD,MAAM,oBAAoB,GAAG;YACzB,GAAG,iBAAiB;YACpB,GAAG,CAAC,MAAM,IAAA,6DAA4B,EAClC,IAAI,CAAC,UAAU,CAAC,MAAM,EACtB,qBAAqB,CACxB,CAAC;SACL,CAAA;QACD,OAAO,IAAA,gCAAsB,GAAE;aAC1B,iBAAiB,CAAC,oBAAoB,CAAC;aACvC,GAAG,CACA,CAAC,QAAQ,EAAE,EAAE,CACT,
|
|
1
|
+
{"version":3,"file":"ConnectionMetadataBuilder.js","sourceRoot":"../build/browser/src/","sources":["connection/ConnectionMetadataBuilder.ts"],"names":[],"mappings":";;;AAAA,2FAAqF;AACrF,+CAA2C;AAE3C,wCAAmD;AACnD,qFAAiF;AACjF,sFAAkF;AAKlF,6DAAyD;AAEzD;;GAEG;AACH,MAAa,yBAAyB;IAClC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YAAsB,UAAsB;QAAtB,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D,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,iCAAe,CAAC,cAAc,CAAC,WAAW,CAAC,CACzD,CAAA;QACR,MAAM,aAAa,GACf,sBAAsB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE,CAC1C,iCAAe,CAAC,cAAc,CAAC,WAAW,CAAC,CACvC,CAAA;QAEZ,MAAM,gBAAgB,GAAG;YACrB,GAAG,aAAa;YAChB,GAAG,CAAC,MAAM,IAAA,6DAA4B,EAClC,IAAI,CAAC,UAAU,CAAC,MAAM,EACtB,iBAAiB,CACpB,CAAC;SACL,CAAA;QACD,gBAAgB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YACrC,oDAAoD;YACpD,IAAI,iCAAe,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC9C,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YACnC,CAAC;QACL,CAAC,CAAC,CAAA;QACF,MAAM,wBAAwB,GAAG,IAAI,6CAAqB,CACtD,IAAI,CAAC,UAAU,EACf,IAAA,gCAAsB,GAAE,CAC3B,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAEzB,MAAM,6BAA6B,GAC/B,IAAI,iDAAuB,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;QAC1D,MAAM,qBAAqB,GAAG,IAAI,6CAAqB,CACnD,IAAI,CAAC,UAAU,EACf,6BAA6B,CAChC,CAAC,KAAK,EAAE,CAAA;QAET,OAAO,CAAC,GAAG,wBAAwB,EAAE,GAAG,qBAAqB,CAAC,CAAA;IAClE,CAAC;CACJ;AA5GD,8DA4GC","sourcesContent":["import { importClassesFromDirectories } from \"../util/DirectoryExportedClassesLoader\"\nimport { OrmUtils } from \"../util/OrmUtils\"\nimport type { MigrationInterface } from \"../migration/MigrationInterface\"\nimport { getMetadataArgsStorage } from \"../globals\"\nimport { EntityMetadataBuilder } from \"../metadata-builder/EntityMetadataBuilder\"\nimport { EntitySchemaTransformer } from \"../entity-schema/EntitySchemaTransformer\"\nimport type { DataSource } from \"../data-source/DataSource\"\nimport type { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport type { EntityMetadata } from \"../metadata/EntityMetadata\"\nimport type { EntitySubscriberInterface } from \"../subscriber/EntitySubscriberInterface\"\nimport { InstanceChecker } from \"../util/InstanceChecker\"\n\n/**\n * Builds migration instances, subscriber instances and entity metadatas for the given classes.\n */\nexport class ConnectionMetadataBuilder {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(protected dataSource: DataSource) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Builds migration instances for the given classes or directories.\n *\n * @param migrations\n */\n async buildMigrations(\n migrations: (Function | string)[],\n ): Promise<MigrationInterface[]> {\n const [migrationClasses, migrationDirectories] =\n OrmUtils.splitClassesAndStrings(migrations)\n const allMigrationClasses = [\n ...migrationClasses,\n ...(await importClassesFromDirectories(\n this.dataSource.logger,\n migrationDirectories,\n )),\n ]\n return allMigrationClasses.map(\n (migrationClass) =>\n new (migrationClass as new () => MigrationInterface)(),\n )\n }\n\n /**\n * Builds subscriber instances for the given classes or directories.\n *\n * @param subscribers\n */\n async buildSubscribers(\n subscribers: (Function | string)[],\n ): Promise<EntitySubscriberInterface<any>[]> {\n const [subscriberClasses, subscriberDirectories] =\n OrmUtils.splitClassesAndStrings(subscribers || [])\n const allSubscriberClasses = [\n ...subscriberClasses,\n ...(await importClassesFromDirectories(\n this.dataSource.logger,\n subscriberDirectories,\n )),\n ]\n return getMetadataArgsStorage()\n .filterSubscribers(allSubscriberClasses)\n .map(\n (metadata) =>\n new (\n metadata.target as new () => EntitySubscriberInterface<any>\n )(),\n )\n }\n\n /**\n * Builds entity metadatas for the given classes or directories.\n *\n * @param entities\n */\n async buildEntityMetadatas(\n entities: (Function | EntitySchema<any> | string)[],\n ): Promise<EntityMetadata[]> {\n // todo: instead we need to merge multiple metadata args storages\n\n const [entityClassesOrSchemas, entityDirectories] =\n OrmUtils.splitClassesAndStrings(entities || [])\n const entityClasses: Function[] = entityClassesOrSchemas.filter(\n (entityClass) => !InstanceChecker.isEntitySchema(entityClass),\n ) as any\n const entitySchemas: EntitySchema<any>[] =\n entityClassesOrSchemas.filter((entityClass) =>\n InstanceChecker.isEntitySchema(entityClass),\n ) as any\n\n const allEntityClasses = [\n ...entityClasses,\n ...(await importClassesFromDirectories(\n this.dataSource.logger,\n entityDirectories,\n )),\n ]\n allEntityClasses.forEach((entityClass) => {\n // if we have entity schemas loaded from directories\n if (InstanceChecker.isEntitySchema(entityClass)) {\n entitySchemas.push(entityClass)\n }\n })\n const decoratorEntityMetadatas = new EntityMetadataBuilder(\n this.dataSource,\n getMetadataArgsStorage(),\n ).build(allEntityClasses)\n\n const metadataArgsStorageFromSchema =\n new EntitySchemaTransformer().transform(entitySchemas)\n const schemaEntityMetadatas = new EntityMetadataBuilder(\n this.dataSource,\n metadataArgsStorageFromSchema,\n ).build()\n\n return [...decoratorEntityMetadatas, ...schemaEntityMetadatas]\n }\n}\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectionOptionsReader = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
4
|
const error_1 = require("../error");
|
|
7
5
|
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
8
6
|
const ImportUtils_1 = require("../util/ImportUtils");
|
|
@@ -41,7 +39,7 @@ class ConnectionOptionsReader {
|
|
|
41
39
|
let connectionOptions = undefined;
|
|
42
40
|
const fileFormats = ["js", "mjs", "cjs", "ts", "mts", "cts", "json"];
|
|
43
41
|
// Detect if baseFilePath contains file extension
|
|
44
|
-
const possibleExtension =
|
|
42
|
+
const possibleExtension = PlatformTools_1.PlatformTools.pathExtname(this.baseFilePath);
|
|
45
43
|
const fileExtension = fileFormats.find((extension) => `.${extension}` === possibleExtension);
|
|
46
44
|
// try to find any of following configuration formats
|
|
47
45
|
const foundFileFormat = fileExtension ??
|
|
@@ -148,7 +146,7 @@ class ConnectionOptionsReader {
|
|
|
148
146
|
* Gets directory where configuration file should be located and configuration file name.
|
|
149
147
|
*/
|
|
150
148
|
get baseFilePath() {
|
|
151
|
-
return
|
|
149
|
+
return PlatformTools_1.PlatformTools.pathResolve(this.baseDirectory, this.baseConfigName);
|
|
152
150
|
}
|
|
153
151
|
/**
|
|
154
152
|
* Gets directory where configuration file should be located.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionOptionsReader.js","sourceRoot":"../build/browser/src/","sources":["connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";;;;AAAA,kEAA4B;AAG5B,oCAAuC;AACvC,6DAAyD;AACzD,qDAAyD;AACzD,iDAA8C;AAE9C;;GAEG;AACH,MAAa,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,OAWT;QAXS,YAAO,GAAP,OAAO,CAWhB;IACF,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,oBAAY,CAClB,kEAAkE,CACrE,CAAA;QAEL,OAAO,OAAO,CAAA;IAClB,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;OAIG;IACO,KAAK,CAAC,IAAI;QAChB,IAAI,iBAAiB,GAGH,SAAS,CAAA;QAE3B,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAEpE,iDAAiD;QACjD,MAAM,iB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,GAAG,CAAC,IAAI,gBAAgB;oBACrD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,mBAAmB;oBAC7D,OAAO,CAAC,QAAQ,KAAK,UAAU,EACjC,CAAC;oBACC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;wBACnB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ;qBACxD,CAAC,CAAA;gBACN,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAc,YAAY;QACtB,OAAO,mBAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAChE,CAAC;IAED;;OAEG;IACH,IAAc,aAAa;QACvB,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IAC9C,CAAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,WAAW,CAAA;IAClD,CAAC;CACJ;AAtND,0DAsNC","sourcesContent":["import path from \"node:path\"\n\nimport type { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { TypeORMError } from \"../error\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\nimport { isAbsolute } from \"../util/PathUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory from where the `ormconfig` file should be read.\n * Default: `process.cwd()`.\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async get(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n | DataSourceOptions\n | DataSourceOptions[]\n | undefined = undefined\n\n const fileFormats = [\"js\", \"mjs\", \"cjs\", \"ts\", \"mts\", \"cts\", \"json\"]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = path.extname(this.baseFilePath)\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ??\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // try to find connection options from any of available sources of configuration\n if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n try {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } catch (err) {\n PlatformTools.logWarn(\n `Warning: Could not load ormconfig file at ${configFile}`,\n err instanceof Error ? err.message : String(err),\n )\n }\n } else if (foundFileFormat === \"json\") {\n try {\n connectionOptions = require(configFile)\n } catch (err) {\n PlatformTools.logWarn(\n `Warning: Could not load ormconfig file at ${configFile}`,\n err instanceof Error ? err.message : String(err),\n )\n }\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n *\n * @param connectionOptions\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (typeof entity === \"string\" && !entity.startsWith(\"/\")) {\n return this.baseDirectory + \"/\" + entity\n }\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n !subscriber.startsWith(\"/\")\n ) {\n return this.baseDirectory + \"/\" + subscriber\n }\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n !migration.startsWith(\"/\")\n ) {\n return this.baseDirectory + \"/\" + migration\n }\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (options.type === \"better-sqlite3\") {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n !options.database.startsWith(\"/\") && // unix absolute\n options.database.slice(1, 3) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName)\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n return this.options?.root ?? process.cwd()\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n return this.options?.configName ?? \"ormconfig\"\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConnectionOptionsReader.js","sourceRoot":"../build/browser/src/","sources":["connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";;;AACA,oCAAuC;AACvC,6DAAyD;AACzD,qDAAyD;AACzD,iDAA8C;AAE9C;;GAEG;AACH,MAAa,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,OAWT;QAXS,YAAO,GAAP,OAAO,CAWhB;IACF,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,oBAAY,CAClB,kEAAkE,CACrE,CAAA;QAEL,OAAO,OAAO,CAAA;IAClB,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;;;OAIG;IACO,KAAK,CAAC,IAAI;QAChB,IAAI,iBAAiB,GACqC,SAAS,CAAA;QAEnE,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAEpE,iDAAiD;QACjD,MAAM,iBAAiB,GAAG,6BAAa,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACtE,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAClC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,EAAE,KAAK,iBAAiB,CACvD,CAAA;QAED,qDAAqD;QACrD,MAAM,eAAe,GACjB,aAAa;YACb,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACxB,OAAO,6BAAa,CAAC,SAA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,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAc,YAAY;QACtB,OAAO,6BAAa,CAAC,WAAW,CAC5B,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,cAAc,CACtB,CAAA;IACL,CAAC;IAED;;OAEG;IACH,IAAc,aAAa;QACvB,OAAO,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IAC9C,CAAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI,WAAW,CAAA;IAClD,CAAC;CACJ;AAvND,0DAuNC","sourcesContent":["import type { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { TypeORMError } from \"../error\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\nimport { isAbsolute } from \"../util/PathUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory from where the `ormconfig` file should be read.\n * Default: `process.cwd()`.\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async get(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n DataSourceOptions | DataSourceOptions[] | undefined = undefined\n\n const fileFormats = [\"js\", \"mjs\", \"cjs\", \"ts\", \"mts\", \"cts\", \"json\"]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = PlatformTools.pathExtname(this.baseFilePath)\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ??\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // try to find connection options from any of available sources of configuration\n if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n try {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } catch (err) {\n PlatformTools.logWarn(\n `Warning: Could not load ormconfig file at ${configFile}`,\n err instanceof Error ? err.message : String(err),\n )\n }\n } else if (foundFileFormat === \"json\") {\n try {\n connectionOptions = require(configFile)\n } catch (err) {\n PlatformTools.logWarn(\n `Warning: Could not load ormconfig file at ${configFile}`,\n err instanceof Error ? err.message : String(err),\n )\n }\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n *\n * @param connectionOptions\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (typeof entity === \"string\" && !entity.startsWith(\"/\")) {\n return this.baseDirectory + \"/\" + entity\n }\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n !subscriber.startsWith(\"/\")\n ) {\n return this.baseDirectory + \"/\" + subscriber\n }\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n !migration.startsWith(\"/\")\n ) {\n return this.baseDirectory + \"/\" + migration\n }\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (options.type === \"better-sqlite3\") {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n !options.database.startsWith(\"/\") && // unix absolute\n options.database.slice(1, 3) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return PlatformTools.pathResolve(\n this.baseDirectory,\n this.baseConfigName,\n )\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n return this.options?.root ?? process.cwd()\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n return this.options?.configName ?? \"ormconfig\"\n }\n}\n"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { QueryResultCache } from "../cache/QueryResultCache";
|
|
2
|
+
import type { MixedList } from "../common/MixedList";
|
|
3
|
+
import type { DataSource } from "../data-source/DataSource";
|
|
4
4
|
import type { DatabaseType } from "../driver/types/DatabaseType";
|
|
5
|
+
import type { InvalidFindOptionsWhereBehavior } from "../driver/types/InvalidFindOptionsWhereBehavior";
|
|
5
6
|
import type { IsolationLevel } from "../driver/types/IsolationLevel";
|
|
7
|
+
import type { EntitySchema } from "../entity-schema/EntitySchema";
|
|
6
8
|
import type { Logger } from "../logger/Logger";
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type { MixedList } from "../common/MixedList";
|
|
9
|
+
import type { LoggerOptions } from "../logger/LoggerOptions";
|
|
10
|
+
import type { NamingStrategyInterface } from "../naming-strategy/NamingStrategyInterface";
|
|
10
11
|
/**
|
|
11
12
|
* BaseDataSourceOptions is set of DataSourceOptions shared by all database types.
|
|
12
13
|
*/
|
|
@@ -103,9 +104,13 @@ export interface BaseDataSourceOptions {
|
|
|
103
104
|
*/
|
|
104
105
|
readonly entitySkipConstructor?: boolean;
|
|
105
106
|
/**
|
|
106
|
-
* Extra connection options
|
|
107
|
+
* Extra connection options passed through to the underlying driver client
|
|
108
|
+
* (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).
|
|
107
109
|
*
|
|
108
|
-
*
|
|
110
|
+
* Use this for driver-native settings that are not modeled as typed
|
|
111
|
+
* options on the per-driver `DataSourceOptions`. Prefer the typed
|
|
112
|
+
* per-driver options when they exist; `extra` is the escape hatch for
|
|
113
|
+
* anything the driver supports but TypeORM does not expose directly.
|
|
109
114
|
*/
|
|
110
115
|
readonly extra?: any;
|
|
111
116
|
/**
|
|
@@ -168,21 +173,8 @@ export interface BaseDataSourceOptions {
|
|
|
168
173
|
*/
|
|
169
174
|
readonly isolateWhereStatements?: boolean;
|
|
170
175
|
/**
|
|
171
|
-
* Controls how null
|
|
176
|
+
* Controls how null/undefined values in where criteria are handled by find
|
|
177
|
+
* and write methods (update/delete/softDelete/restore). Defaults to "throw".
|
|
172
178
|
*/
|
|
173
|
-
readonly invalidWhereValuesBehavior?:
|
|
174
|
-
/**
|
|
175
|
-
* How to handle null values in where conditions.
|
|
176
|
-
* - 'ignore': Skip null properties
|
|
177
|
-
* - 'sql-null': Transform null to SQL NULL
|
|
178
|
-
* - 'throw': Throw an error when null is encountered (default)
|
|
179
|
-
*/
|
|
180
|
-
readonly null?: "ignore" | "sql-null" | "throw";
|
|
181
|
-
/**
|
|
182
|
-
* How to handle undefined values in where conditions.
|
|
183
|
-
* - 'ignore': Skip undefined properties
|
|
184
|
-
* - 'throw': Throw an error when undefined is encountered (default)
|
|
185
|
-
*/
|
|
186
|
-
readonly undefined?: "ignore" | "throw";
|
|
187
|
-
};
|
|
179
|
+
readonly invalidWhereValuesBehavior?: InvalidFindOptionsWhereBehavior;
|
|
188
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDataSourceOptions.js","sourceRoot":"../build/browser/src/","sources":["data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"BaseDataSourceOptions.js","sourceRoot":"../build/browser/src/","sources":["data-source/BaseDataSourceOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { QueryResultCache } from \"../cache/QueryResultCache\"\nimport type { MixedList } from \"../common/MixedList\"\nimport type { DataSource } from \"../data-source/DataSource\"\nimport type { DatabaseType } from \"../driver/types/DatabaseType\"\nimport type { InvalidFindOptionsWhereBehavior } from \"../driver/types/InvalidFindOptionsWhereBehavior\"\nimport type { IsolationLevel } from \"../driver/types/IsolationLevel\"\nimport type { EntitySchema } from \"../entity-schema/EntitySchema\"\nimport type { Logger } from \"../logger/Logger\"\nimport type { LoggerOptions } from \"../logger/LoggerOptions\"\nimport type { NamingStrategyInterface } from \"../naming-strategy/NamingStrategyInterface\"\n\n/**\n * BaseDataSourceOptions is set of DataSourceOptions shared by all database types.\n */\nexport interface BaseDataSourceOptions {\n /**\n * Database type. This value is required.\n */\n readonly type: DatabaseType\n\n /**\n * Entities to be loaded for this connection.\n * Accepts both entity classes and directories where from entities need to be loaded.\n * Directories support glob patterns.\n */\n readonly entities?: MixedList<Function | string | EntitySchema>\n\n /**\n * Subscribers to be loaded for this connection.\n * Accepts both subscriber classes and directories where from subscribers need to be loaded.\n * Directories support glob patterns.\n */\n readonly subscribers?: MixedList<Function | string>\n\n /**\n * Default isolation level for transactions. When set, all transactions started\n * without an explicit level will use this value. An explicit isolation level\n * passed to `transaction()` or `startTransaction()` overrides this default.\n * Must be a level supported by the driver.\n */\n readonly isolationLevel?: IsolationLevel\n\n /**\n * Migrations to be loaded for this connection.\n * Accepts both migration classes and glob patterns representing migration files.\n */\n readonly migrations?: MixedList<Function | string>\n\n /**\n * Migrations table name, in case of different name from \"migrations\".\n * Accepts single string name.\n */\n readonly migrationsTableName?: string\n\n /**\n * Transaction mode for migrations to run in\n */\n readonly migrationsTransactionMode?: \"all\" | \"none\" | \"each\"\n\n /**\n * Typeorm metadata table name, in case of different name from \"typeorm_metadata\".\n * Accepts single string name.\n */\n readonly metadataTableName?: string\n\n /**\n * Naming strategy to be used to name tables and columns in the database.\n */\n readonly namingStrategy?: NamingStrategyInterface\n\n /**\n * Logging options.\n */\n readonly logging?: LoggerOptions\n\n /**\n * Logger instance used to log queries and events in the ORM.\n */\n readonly logger?:\n | \"advanced-console\"\n | \"simple-console\"\n | \"formatted-console\"\n | \"file\"\n | \"debug\"\n | Logger\n\n /**\n * Maximum number of milliseconds query should be executed before logger log a warning.\n */\n readonly maxQueryExecutionTime?: number\n\n /**\n * Maximum number of clients the pool should contain.\n */\n readonly poolSize?: number\n\n /**\n * Indicates if database schema should be auto created on every application launch.\n * Be careful with this option and don't use this in production - otherwise you can lose production data.\n * This option is useful during debug and development.\n * Alternative to it, you can use CLI and run schema:sync command.\n *\n * Note that for MongoDB database it does not create schema, because MongoDB is schemaless.\n * Instead, it syncs just by creating indices.\n */\n readonly synchronize?: boolean\n\n /**\n * Indicates if migrations should be auto run on every application launch.\n * Alternative to it, you can use CLI and run migrations:run command.\n */\n readonly migrationsRun?: boolean\n\n /**\n * Drops the schema each time connection is being established.\n * Be careful with this option and don't use this in production - otherwise you'll lose all production data.\n * This option is useful during debug and development.\n */\n readonly dropSchema?: boolean\n\n /**\n * Prefix to use on all tables (collections) of this connection in the database.\n */\n readonly entityPrefix?: string\n\n /**\n * When creating new Entity instances, skip all constructors when true.\n */\n readonly entitySkipConstructor?: boolean\n\n /**\n * Extra connection options passed through to the underlying driver client\n * (e.g. `pg`, `mysql2`, `tedious`, `mongodb`).\n *\n * Use this for driver-native settings that are not modeled as typed\n * options on the per-driver `DataSourceOptions`. Prefer the typed\n * per-driver options when they exist; `extra` is the escape hatch for\n * anything the driver supports but TypeORM does not expose directly.\n */\n readonly extra?: any\n\n /**\n * Specifies how relations must be loaded - using \"joins\" or separate queries.\n * If you are loading too much data with nested joins it's better to load relations\n * using separate queries.\n *\n * Default strategy is \"join\", but this default can be changed here.\n * Also, strategy can be set per-query in FindOptions and QueryBuilder.\n */\n readonly relationLoadStrategy?: \"join\" | \"query\"\n\n /**\n * Optionally applied \"typename\" to the model.\n * If set, then each hydrated model will have this property with the target model / entity name inside.\n *\n * (works like a discriminator property).\n */\n readonly typename?: string\n\n /**\n * Holds reference to the baseDirectory where configuration file are expected.\n *\n * @internal\n */\n baseDirectory?: string\n\n /**\n * Allows to setup cache options.\n */\n readonly cache?:\n | boolean\n | {\n /**\n * Type of caching.\n *\n * - \"database\" means cached values will be stored in the separate table in database. This is default value.\n * - \"redis\" means cached values will be stored inside redis. You must provide redis connection options.\n */\n readonly type?:\n \"database\" | \"redis\" | \"ioredis\" | \"ioredis/cluster\" // todo: add mongodb and other cache providers as well in the future\n\n /**\n * Factory function for custom cache providers that implement QueryResultCache.\n */\n readonly provider?: (dataSource: DataSource) => QueryResultCache\n\n /**\n * Configurable table name for \"database\" type cache.\n * Default value is \"query-result-cache\"\n */\n readonly tableName?: string\n\n /**\n * Used to provide redis connection options.\n */\n readonly options?: any\n\n /**\n * If set to true then queries (using find methods and QueryBuilder's methods) will always be cached.\n */\n readonly alwaysEnabled?: boolean\n\n /**\n * Time in milliseconds in which cache will expire.\n * This can be setup per-query.\n * Default value is 1000 which is equivalent to 1 second.\n */\n readonly duration?: number\n\n /**\n * Used to specify if cache errors should be ignored, and pass through the call to the Database.\n */\n readonly ignoreErrors?: boolean\n }\n\n /**\n * Allows automatic isolation of where clauses\n */\n readonly isolateWhereStatements?: boolean\n\n /**\n * Controls how null/undefined values in where criteria are handled by find\n * and write methods (update/delete/softDelete/restore). Defaults to \"throw\".\n */\n readonly invalidWhereValuesBehavior?: InvalidFindOptionsWhereBehavior\n}\n"]}
|