typeorm 0.3.21-dev.d106eed → 0.3.21-dev.d52ecf6
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 +10 -20
- package/browser/cache/QueryResultCache.d.ts +4 -2
- package/browser/cache/QueryResultCache.js.map +1 -1
- package/browser/connection/ConnectionOptionsReader.d.ts +4 -4
- package/browser/data-source/DataSource.d.ts +2 -0
- package/browser/data-source/DataSource.js +2 -0
- package/browser/data-source/DataSource.js.map +1 -1
- package/browser/decorator/relations/OneToOne.d.ts +4 -4
- package/browser/decorator/relations/OneToOne.js +2 -2
- package/browser/decorator/relations/OneToOne.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.d.ts +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +0 -1
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +2 -2
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js +4 -0
- package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachConnectionCredentialsOptions.d.ts +1 -2
- package/browser/driver/cockroachdb/CockroachConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachConnectionOptions.d.ts +1 -1
- package/browser/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.d.ts +0 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +5 -3
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoConnectionOptions.d.ts +1 -2
- package/browser/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/browser/driver/mongodb/MongoQueryRunner.d.ts +0 -1
- package/browser/driver/mongodb/typings.d.ts +0 -8
- package/browser/driver/mongodb/typings.js +0 -1
- package/browser/driver/mongodb/typings.js.map +1 -1
- package/browser/driver/mysql/MysqlConnectionCredentialsOptions.d.ts +1 -1
- package/browser/driver/mysql/MysqlConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/mysql/MysqlConnectionOptions.d.ts +1 -1
- package/browser/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.d.ts +0 -1
- package/browser/driver/oracle/OracleConnectionCredentialsOptions.d.ts +1 -1
- package/browser/driver/oracle/OracleConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/oracle/OracleConnectionOptions.d.ts +1 -1
- package/browser/driver/oracle/OracleConnectionOptions.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.d.ts +0 -1
- package/browser/driver/postgres/PostgresConnectionCredentialsOptions.d.ts +1 -2
- package/browser/driver/postgres/PostgresConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/postgres/PostgresConnectionOptions.d.ts +1 -1
- package/browser/driver/postgres/PostgresConnectionOptions.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.d.ts +0 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +5 -1
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.d.ts +0 -1
- package/browser/driver/spanner/SpannerConnectionCredentialsOptions.d.ts +1 -1
- package/browser/driver/spanner/SpannerConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/spanner/SpannerConnectionOptions.d.ts +1 -1
- package/browser/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/browser/driver/spanner/SpannerQueryRunner.d.ts +0 -1
- package/browser/driver/sqlite/SqliteDriver.js +2 -2
- package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +0 -1
- package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +1 -1
- package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -1
- package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.d.ts +0 -1
- package/browser/entity-manager/EntityManager.d.ts +2 -0
- package/browser/entity-manager/EntityManager.js +4 -2
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/find-options/FindOptionsOrder.d.ts +0 -1
- package/browser/find-options/FindOptionsRelations.d.ts +0 -1
- package/browser/find-options/FindOptionsSelect.d.ts +0 -1
- package/browser/find-options/FindOptionsWhere.d.ts +0 -1
- package/browser/persistence/SubjectExecutor.js +3 -3
- package/browser/persistence/SubjectExecutor.js.map +1 -1
- package/browser/persistence/{SubjectTopoligicalSorter.d.ts → SubjectTopologicalSorter.d.ts} +1 -1
- package/browser/persistence/{SubjectTopoligicalSorter.js → SubjectTopologicalSorter.js} +2 -2
- package/browser/persistence/{SubjectTopoligicalSorter.js.map → SubjectTopologicalSorter.js.map} +1 -1
- package/browser/platform/BrowserPlatformTools.d.ts +2 -6
- package/browser/platform/BrowserPlatformTools.js +2 -8
- package/browser/platform/BrowserPlatformTools.js.map +1 -1
- package/browser/platform/PlatformTools.d.ts +2 -10
- package/browser/platform/PlatformTools.js +28 -36
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/QueryBuilder.js +2 -3
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.d.ts +0 -1
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.d.ts +9 -0
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js +95 -61
- package/browser/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/browser/query-runner/QueryRunner.d.ts +0 -1
- package/browser/repository/Repository.d.ts +2 -0
- package/browser/repository/Repository.js +2 -0
- package/browser/repository/Repository.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/util/ImportUtils.js +22 -34
- package/browser/util/ImportUtils.js.map +1 -1
- package/cache/QueryResultCache.d.ts +4 -2
- package/cache/QueryResultCache.js.map +1 -1
- package/commands/CacheClearCommand.d.ts +1 -1
- package/commands/CacheClearCommand.js +3 -3
- package/commands/CacheClearCommand.js.map +1 -1
- package/commands/CommandUtils.d.ts +1 -1
- package/commands/CommandUtils.js +18 -16
- package/commands/CommandUtils.js.map +1 -1
- package/commands/EntityCreateCommand.d.ts +1 -1
- package/commands/EntityCreateCommand.js +7 -7
- package/commands/EntityCreateCommand.js.map +1 -1
- package/commands/InitCommand.d.ts +1 -1
- package/commands/InitCommand.js +9 -9
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationCreateCommand.d.ts +1 -1
- package/commands/MigrationCreateCommand.js +5 -5
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.d.ts +1 -1
- package/commands/MigrationGenerateCommand.js +17 -17
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/commands/QueryCommand.d.ts +1 -1
- package/commands/QueryCommand.js +10 -7
- package/commands/QueryCommand.js.map +1 -1
- package/commands/SchemaDropCommand.d.ts +1 -1
- package/commands/SchemaDropCommand.js +3 -3
- package/commands/SchemaDropCommand.js.map +1 -1
- package/commands/SchemaLogCommand.d.ts +1 -1
- package/commands/SchemaLogCommand.js +12 -18
- package/commands/SchemaLogCommand.js.map +1 -1
- package/commands/SchemaSyncCommand.d.ts +1 -1
- package/commands/SchemaSyncCommand.js +3 -3
- package/commands/SchemaSyncCommand.js.map +1 -1
- package/commands/SubscriberCreateCommand.d.ts +1 -1
- package/commands/SubscriberCreateCommand.js +5 -5
- package/commands/SubscriberCreateCommand.js.map +1 -1
- package/connection/ConnectionOptionsReader.d.ts +4 -4
- package/container.js +2 -3
- package/container.js.map +1 -1
- package/data-source/DataSource.d.ts +2 -0
- package/data-source/DataSource.js +2 -0
- package/data-source/DataSource.js.map +1 -1
- package/decorator/Check.js +1 -2
- package/decorator/Check.js.map +1 -1
- package/decorator/EntityRepository.js +1 -2
- package/decorator/EntityRepository.js.map +1 -1
- package/decorator/Exclusion.js +1 -2
- package/decorator/Exclusion.js.map +1 -1
- package/decorator/Generated.js +1 -2
- package/decorator/Generated.js.map +1 -1
- package/decorator/Index.js +1 -2
- package/decorator/Index.js.map +1 -1
- package/decorator/Unique.js +1 -2
- package/decorator/Unique.js.map +1 -1
- package/decorator/columns/Column.js +1 -2
- package/decorator/columns/Column.js.map +1 -1
- package/decorator/columns/CreateDateColumn.js +1 -2
- package/decorator/columns/CreateDateColumn.js.map +1 -1
- package/decorator/columns/DeleteDateColumn.js +1 -2
- package/decorator/columns/DeleteDateColumn.js.map +1 -1
- package/decorator/columns/ObjectIdColumn.js +1 -2
- package/decorator/columns/ObjectIdColumn.js.map +1 -1
- package/decorator/columns/PrimaryColumn.js +1 -2
- package/decorator/columns/PrimaryColumn.js.map +1 -1
- package/decorator/columns/PrimaryGeneratedColumn.js +1 -2
- package/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
- package/decorator/columns/UpdateDateColumn.js +1 -2
- package/decorator/columns/UpdateDateColumn.js.map +1 -1
- package/decorator/columns/VersionColumn.js +1 -2
- package/decorator/columns/VersionColumn.js.map +1 -1
- package/decorator/columns/ViewColumn.js +1 -2
- package/decorator/columns/ViewColumn.js.map +1 -1
- package/decorator/columns/VirtualColumn.js +1 -2
- package/decorator/columns/VirtualColumn.js.map +1 -1
- package/decorator/entity/ChildEntity.js +1 -2
- package/decorator/entity/ChildEntity.js.map +1 -1
- package/decorator/entity/Entity.js +1 -2
- package/decorator/entity/Entity.js.map +1 -1
- package/decorator/entity/TableInheritance.js +1 -2
- package/decorator/entity/TableInheritance.js.map +1 -1
- package/decorator/entity-view/ViewEntity.js +1 -2
- package/decorator/entity-view/ViewEntity.js.map +1 -1
- package/decorator/listeners/AfterInsert.js +1 -2
- package/decorator/listeners/AfterInsert.js.map +1 -1
- package/decorator/listeners/AfterLoad.js +1 -2
- package/decorator/listeners/AfterLoad.js.map +1 -1
- package/decorator/listeners/AfterRecover.js +1 -2
- package/decorator/listeners/AfterRecover.js.map +1 -1
- package/decorator/listeners/AfterRemove.js +1 -2
- package/decorator/listeners/AfterRemove.js.map +1 -1
- package/decorator/listeners/AfterSoftRemove.js +1 -2
- package/decorator/listeners/AfterSoftRemove.js.map +1 -1
- package/decorator/listeners/AfterUpdate.js +1 -2
- package/decorator/listeners/AfterUpdate.js.map +1 -1
- package/decorator/listeners/BeforeInsert.js +1 -2
- package/decorator/listeners/BeforeInsert.js.map +1 -1
- package/decorator/listeners/BeforeRecover.js +1 -2
- package/decorator/listeners/BeforeRecover.js.map +1 -1
- package/decorator/listeners/BeforeRemove.js +1 -2
- package/decorator/listeners/BeforeRemove.js.map +1 -1
- package/decorator/listeners/BeforeSoftRemove.js +1 -2
- package/decorator/listeners/BeforeSoftRemove.js.map +1 -1
- package/decorator/listeners/BeforeUpdate.js +1 -2
- package/decorator/listeners/BeforeUpdate.js.map +1 -1
- package/decorator/listeners/EventSubscriber.js +1 -2
- package/decorator/listeners/EventSubscriber.js.map +1 -1
- package/decorator/relations/JoinColumn.js +1 -2
- package/decorator/relations/JoinColumn.js.map +1 -1
- package/decorator/relations/JoinTable.js +1 -2
- package/decorator/relations/JoinTable.js.map +1 -1
- package/decorator/relations/ManyToMany.js +1 -2
- package/decorator/relations/ManyToMany.js.map +1 -1
- package/decorator/relations/ManyToOne.js +1 -2
- package/decorator/relations/ManyToOne.js.map +1 -1
- package/decorator/relations/OneToMany.js +1 -2
- package/decorator/relations/OneToMany.js.map +1 -1
- package/decorator/relations/OneToOne.d.ts +4 -4
- package/decorator/relations/OneToOne.js +3 -4
- package/decorator/relations/OneToOne.js.map +1 -1
- package/decorator/relations/RelationCount.js +1 -2
- package/decorator/relations/RelationCount.js.map +1 -1
- package/decorator/relations/RelationId.js +1 -2
- package/decorator/relations/RelationId.js.map +1 -1
- package/decorator/tree/Tree.js +1 -2
- package/decorator/tree/Tree.js.map +1 -1
- package/decorator/tree/TreeChildren.js +1 -2
- package/decorator/tree/TreeChildren.js.map +1 -1
- package/decorator/tree/TreeLevelColumn.js +1 -2
- package/decorator/tree/TreeLevelColumn.js.map +1 -1
- package/decorator/tree/TreeParent.js +1 -2
- package/decorator/tree/TreeParent.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.d.ts +1 -1
- package/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js.map +1 -1
- package/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +0 -1
- package/driver/better-sqlite3/BetterSqlite3Driver.js +2 -2
- package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/driver/better-sqlite3/BetterSqlite3QueryRunner.js +4 -0
- package/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachConnectionCredentialsOptions.d.ts +1 -2
- package/driver/cockroachdb/CockroachConnectionCredentialsOptions.js.map +1 -1
- package/driver/cockroachdb/CockroachConnectionOptions.d.ts +1 -1
- package/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.d.ts +0 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +5 -3
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoConnectionOptions.d.ts +1 -2
- package/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/driver/mongodb/MongoQueryRunner.d.ts +0 -1
- package/driver/mongodb/typings.d.ts +0 -8
- package/driver/mongodb/typings.js +0 -1
- package/driver/mongodb/typings.js.map +1 -1
- package/driver/mysql/MysqlConnectionCredentialsOptions.d.ts +1 -1
- package/driver/mysql/MysqlConnectionCredentialsOptions.js.map +1 -1
- package/driver/mysql/MysqlConnectionOptions.d.ts +1 -1
- package/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.d.ts +0 -1
- package/driver/oracle/OracleConnectionCredentialsOptions.d.ts +1 -1
- package/driver/oracle/OracleConnectionCredentialsOptions.js.map +1 -1
- package/driver/oracle/OracleConnectionOptions.d.ts +1 -1
- package/driver/oracle/OracleConnectionOptions.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.d.ts +0 -1
- package/driver/postgres/PostgresConnectionCredentialsOptions.d.ts +1 -2
- package/driver/postgres/PostgresConnectionCredentialsOptions.js.map +1 -1
- package/driver/postgres/PostgresConnectionOptions.d.ts +1 -1
- package/driver/postgres/PostgresConnectionOptions.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.d.ts +0 -1
- package/driver/postgres/PostgresQueryRunner.js +5 -1
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/sap/SapQueryRunner.d.ts +0 -1
- package/driver/spanner/SpannerConnectionCredentialsOptions.d.ts +1 -1
- package/driver/spanner/SpannerConnectionCredentialsOptions.js.map +1 -1
- package/driver/spanner/SpannerConnectionOptions.d.ts +1 -1
- package/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/driver/spanner/SpannerQueryRunner.d.ts +0 -1
- package/driver/sqlite/SqliteDriver.js +2 -2
- package/driver/sqlite/SqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +0 -1
- package/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +1 -1
- package/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
- package/driver/sqlserver/SqlServerConnectionOptions.d.ts +1 -1
- package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.d.ts +0 -1
- package/entity-manager/EntityManager.d.ts +2 -0
- package/entity-manager/EntityManager.js +4 -2
- package/entity-manager/EntityManager.js.map +1 -1
- package/find-options/FindOptionsOrder.d.ts +0 -1
- package/find-options/FindOptionsRelations.d.ts +0 -1
- package/find-options/FindOptionsSelect.d.ts +0 -1
- package/find-options/FindOptionsWhere.d.ts +0 -1
- package/find-options/operator/And.js +1 -2
- package/find-options/operator/And.js.map +1 -1
- package/find-options/operator/Any.js +1 -2
- package/find-options/operator/Any.js.map +1 -1
- package/find-options/operator/ArrayContainedBy.js +1 -2
- package/find-options/operator/ArrayContainedBy.js.map +1 -1
- package/find-options/operator/ArrayContains.js +1 -2
- package/find-options/operator/ArrayContains.js.map +1 -1
- package/find-options/operator/ArrayOverlap.js +1 -2
- package/find-options/operator/ArrayOverlap.js.map +1 -1
- package/find-options/operator/Between.js +1 -2
- package/find-options/operator/Between.js.map +1 -1
- package/find-options/operator/Equal.js +1 -2
- package/find-options/operator/Equal.js.map +1 -1
- package/find-options/operator/ILike.js +1 -2
- package/find-options/operator/ILike.js.map +1 -1
- package/find-options/operator/In.js +1 -2
- package/find-options/operator/In.js.map +1 -1
- package/find-options/operator/IsNull.js +1 -2
- package/find-options/operator/IsNull.js.map +1 -1
- package/find-options/operator/JsonContains.js +1 -2
- package/find-options/operator/JsonContains.js.map +1 -1
- package/find-options/operator/LessThan.js +1 -2
- package/find-options/operator/LessThan.js.map +1 -1
- package/find-options/operator/LessThanOrEqual.js +1 -2
- package/find-options/operator/LessThanOrEqual.js.map +1 -1
- package/find-options/operator/Like.js +1 -2
- package/find-options/operator/Like.js.map +1 -1
- package/find-options/operator/MoreThan.js +1 -2
- package/find-options/operator/MoreThan.js.map +1 -1
- package/find-options/operator/MoreThanOrEqual.js +1 -2
- package/find-options/operator/MoreThanOrEqual.js.map +1 -1
- package/find-options/operator/Not.js +1 -2
- package/find-options/operator/Not.js.map +1 -1
- package/find-options/operator/Or.js +1 -2
- package/find-options/operator/Or.js.map +1 -1
- package/find-options/operator/Raw.js +1 -2
- package/find-options/operator/Raw.js.map +1 -1
- package/globals.js +14 -15
- package/globals.js.map +1 -1
- package/package.json +1 -1
- package/persistence/SubjectExecutor.js +3 -3
- package/persistence/SubjectExecutor.js.map +1 -1
- package/persistence/{SubjectTopoligicalSorter.d.ts → SubjectTopologicalSorter.d.ts} +1 -1
- package/persistence/{SubjectTopoligicalSorter.js → SubjectTopologicalSorter.js} +4 -4
- package/persistence/{SubjectTopoligicalSorter.js.map → SubjectTopologicalSorter.js.map} +1 -1
- package/platform/PlatformTools.d.ts +2 -10
- package/platform/PlatformTools.js +37 -45
- package/platform/PlatformTools.js.map +1 -1
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/QueryBuilder.js +2 -3
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/SelectQueryBuilder.d.ts +0 -1
- package/query-builder/index.js +1 -2
- package/query-builder/index.js.map +1 -1
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.d.ts +9 -0
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js +95 -61
- package/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/query-runner/QueryRunner.d.ts +0 -1
- package/repository/Repository.d.ts +2 -0
- package/repository/Repository.js +2 -0
- package/repository/Repository.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/util/DirectoryExportedClassesLoader.js +2 -3
- package/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/util/ImportUtils.js +23 -36
- package/util/ImportUtils.js.map +1 -1
- package/util/PathUtils.js +3 -4
- package/util/PathUtils.js.map +1 -1
- package/util/StringUtils.js +6 -7
- package/util/StringUtils.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,qDAA+C;AAE/C,0DAAyB;AACzB,uEAA6D;AAC7D,6DAAyD;AAEzD,mDAA4B;AAC5B,8DAA6B;AAE7B;;GAEG;AACH,MAAa,wBAAwB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,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AA3RD,4DA2RC","file":"MigrationGenerateCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport { camelCase } from \"../util/StringUtils\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { DataSource } from \"../data-source\"\nimport * as path from \"path\"\nimport process from \"process\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n chalk.green(`No changes in database schema were found`),\n )\n process.exit(0)\n } else {\n console.log(\n chalk.yellow(\n `No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n ),\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(chalk.yellow(\"Please specify a migration path\"))\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n chalk.yellow(\n `Unexpected changes in database schema were found in check mode:\\n\\n${chalk.white(\n fileContent,\n )}`,\n ),\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n fullPath + extension,\n )} has content:\\n\\n${chalk.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n chalk.green(\n `Migration ${chalk.blue(\n migrationFileName,\n )} has been generated successfully.`,\n ),\n )\n if (args.exitProcess !== false) {\n process.exit(0)\n }\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,uEAA6D;AAC7D,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA;IAkRxF,CAAC;IAhRG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,QAAQ;YACf,IAAI,E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W,CAAC,UAA6B;QACtD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACpC,OAAO,EAAE,CAAA;QACb,CAAC;QAED,OAAO,KAAK,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAA;IAC5C,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,WAAW,CACxB,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;eAEA,aAAa;cACd,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;;CAID,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB;QAElB,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO;;yBAEU,aAAa;cACxB,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AArRD,4DAqRC","file":"MigrationGenerateCommand.js","sourcesContent":["import { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replace(new RegExp(\"`\", \"g\"), \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replace(\n new RegExp(\"`\", \"g\"),\n \"\\\\`\",\n ) +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n ansi.green`No changes in database schema were found`,\n )\n process.exit(0)\n } else {\n console.log(\n ansi.yellow`No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(ansi.yellow`Please specify a migration path`)\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n ansi.yellow`Unexpected changes in database schema were found in check mode:\\n\\n${ansi.white(\n fileContent,\n )}`,\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n ansi.green(\n `Migration ${ansi.blue(\n fullPath + extension,\n )} has content:\\n\\n${ansi.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n ansi.green`Migration ${ansi.blue(\n migrationFileName,\n )} has been generated successfully.`,\n )\n if (args.exitProcess !== false) {\n process.exit(0)\n }\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `const { MigrationInterface, QueryRunner } = require(\"typeorm\");\n\nmodule.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
package/commands/QueryCommand.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.QueryCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
7
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
7
|
const process_1 = tslib_1.__importDefault(require("process"));
|
|
8
|
+
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
9
9
|
const CommandUtils_1 = require("./CommandUtils");
|
|
10
10
|
/**
|
|
11
11
|
* Executes an SQL query on the given dataSource.
|
|
@@ -42,15 +42,18 @@ class QueryCommand {
|
|
|
42
42
|
// create a query runner and execute query using it
|
|
43
43
|
queryRunner = dataSource.createQueryRunner();
|
|
44
44
|
const query = args.query;
|
|
45
|
-
console.log(
|
|
46
|
-
PlatformTools_1.PlatformTools.highlightSql(query));
|
|
45
|
+
console.log(ansis_1.default.green `Running query: ` + PlatformTools_1.PlatformTools.highlightSql(query));
|
|
47
46
|
const queryResult = await queryRunner.query(query);
|
|
48
47
|
if (typeof queryResult === "undefined") {
|
|
49
|
-
console.log(
|
|
48
|
+
console.log(ansis_1.default.green `Query has been executed. No result was returned.`);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
|
-
console.log(
|
|
53
|
-
console.
|
|
51
|
+
console.log(ansis_1.default.green `Query has been executed. Result: `);
|
|
52
|
+
console.dir(queryResult, {
|
|
53
|
+
breakLength: Infinity,
|
|
54
|
+
compact: false,
|
|
55
|
+
depth: null,
|
|
56
|
+
});
|
|
54
57
|
}
|
|
55
58
|
await queryRunner.release();
|
|
56
59
|
await dataSource.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/QueryCommand.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/QueryCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AAEzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,YAAY;IAAzB;QACI,YAAO,GAAG,eAAe,CAAA;QACzB,aAAQ,GACJ,kHAAkH,CAAA;IAgE1H,CAAC;IA9DG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,OAAO,EAAE;YACjB,QAAQ,EAAE,sBAAsB;YAChC,IAAI,EAAE,QAAQ;SACjB,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACV,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI,WAAW,GAA4B,SAAS,CAAA;QACpD,IAAI,UAAU,GAA2B,SAAS,CAAA;QAClD,IAAI,CAAC;YACD,UAAU,GAAG,MAAM,2BAAY,CAAC,cAAc,CAC1C,cAAI,CAAC,OAAO,CAAC,iBAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,UAAoB,CAAC,CACzD,CAAA;YACD,UAAU,CAAC,UAAU,CAAC;gBAClB,WAAW,EAAE,KAAK;gBAClB,aAAa,EAAE,KAAK;gBACpB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,KAAK;aACjB,CAAC,CAAA;YACF,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;YAE7B,mDAAmD;YACnD,WAAW,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAA;YAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAe,CAAA;YAClC,OAAO,CAAC,GAAG,CACP,eAAI,CAAC,KAAK,CAAA,iBAAiB,GAAG,6BAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAClE,CAAA;YACD,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAElD,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;gBACrC,OAAO,CAAC,GAAG,CACP,eAAI,CAAC,KAAK,CAAA,kDAAkD,CAC/D,CAAA;YACL,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,KAAK,CAAA,mCAAmC,CAAC,CAAA;gBAC1D,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;oBACrB,WAAW,EAAE,QAAQ;oBACrB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,IAAI;iBACd,CAAC,CAAA;YACN,CAAC;YAED,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;YAC3B,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;YAE7D,IAAI,WAAW;gBAAE,MAAO,WAA2B,CAAC,OAAO,EAAE,CAAA;YAC7D,IAAI,UAAU,IAAI,UAAU,CAAC,aAAa;gBACtC,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;YAE9B,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;CACJ;AAnED,oCAmEC","file":"QueryCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { QueryRunner } from \"../query-runner/QueryRunner\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Executes an SQL query on the given dataSource.\n */\nexport class QueryCommand implements yargs.CommandModule {\n command = \"query [query]\"\n describe =\n \"Executes given SQL query on a default dataSource. Specify connection name to run query on a specific dataSource.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"query\", {\n describe: \"The SQL Query to run\",\n type: \"string\",\n })\n .option(\"dataSource\", {\n alias: \"d\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n let queryRunner: QueryRunner | undefined = undefined\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n // create a query runner and execute query using it\n queryRunner = dataSource.createQueryRunner()\n const query = args.query as string\n console.log(\n ansi.green`Running query: ` + PlatformTools.highlightSql(query),\n )\n const queryResult = await queryRunner.query(query)\n\n if (typeof queryResult === \"undefined\") {\n console.log(\n ansi.green`Query has been executed. No result was returned.`,\n )\n } else {\n console.log(ansi.green`Query has been executed. Result: `)\n console.dir(queryResult, {\n breakLength: Infinity,\n compact: false,\n depth: null,\n })\n }\n\n await queryRunner.release()\n await dataSource.destroy()\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during query execution:\", err)\n\n if (queryRunner) await (queryRunner as QueryRunner).release()\n if (dataSource && dataSource.isInitialized)\n await dataSource.destroy()\n\n process.exit(1)\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SchemaDropCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
7
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
7
|
const process_1 = tslib_1.__importDefault(require("process"));
|
|
8
|
+
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
9
9
|
const CommandUtils_1 = require("./CommandUtils");
|
|
10
10
|
/**
|
|
11
11
|
* Drops all tables of the database from the given dataSource.
|
|
@@ -36,7 +36,7 @@ class SchemaDropCommand {
|
|
|
36
36
|
await dataSource.initialize();
|
|
37
37
|
await dataSource.dropDatabase();
|
|
38
38
|
await dataSource.destroy();
|
|
39
|
-
console.log(
|
|
39
|
+
console.log(ansis_1.default.green `Database schema has been successfully dropped.`);
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
42
|
PlatformTools_1.PlatformTools.logCmdErr("Error during schema drop:", err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/SchemaDropCommand.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/SchemaDropCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,iBAAiB;IAA9B;QACI,YAAO,GAAG,aAAa,CAAA;QACvB,aAAQ,GACJ,+DAA+D;YAC/D,kEAAkE,CAAA;IAuC1E,CAAC;IArCG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;YAC7B,KAAK,EAAE,GAAG;YACV,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI,UAAU,GAA2B,SAAS,CAAA;QAClD,IAAI,CAAC;YACD,UAAU,GAAG,MAAM,2BAAY,CAAC,cAAc,CAC1C,cAAI,CAAC,OAAO,CAAC,iBAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,UAAoB,CAAC,CACzD,CAAA;YACD,UAAU,CAAC,UAAU,CAAC;gBAClB,WAAW,EAAE,KAAK;gBAClB,aAAa,EAAE,KAAK;gBACpB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;aAC/B,CAAC,CAAA;YACF,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;YAC7B,MAAM,UAAU,CAAC,YAAY,EAAE,CAAA;YAC/B,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;YAE1B,OAAO,CAAC,GAAG,CACP,eAAI,CAAC,KAAK,CAAA,gDAAgD,CAC7D,CAAA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;YAEzD,IAAI,UAAU,IAAI,UAAU,CAAC,aAAa;gBACtC,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;YAE9B,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;CACJ;AA3CD,8CA2CC","file":"SchemaDropCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Drops all tables of the database from the given dataSource.\n */\nexport class SchemaDropCommand implements yargs.CommandModule {\n command = \"schema:drop\"\n describe =\n \"Drops all tables in the database on your default dataSource. \" +\n \"To drop table of a concrete connection's database use -c option.\"\n\n builder(args: yargs.Argv) {\n return args.option(\"dataSource\", {\n alias: \"d\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: [\"query\", \"schema\"],\n })\n await dataSource.initialize()\n await dataSource.dropDatabase()\n await dataSource.destroy()\n\n console.log(\n ansi.green`Database schema has been successfully dropped.`,\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during schema drop:\", err)\n\n if (dataSource && dataSource.isInitialized)\n await dataSource.destroy()\n\n process.exit(1)\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SchemaLogCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
8
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
7
|
const process_1 = tslib_1.__importDefault(require("process"));
|
|
8
|
+
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
10
9
|
const CommandUtils_1 = require("./CommandUtils");
|
|
11
10
|
/**
|
|
12
11
|
* Shows sql to be executed by schema:sync command.
|
|
@@ -39,26 +38,21 @@ class SchemaLogCommand {
|
|
|
39
38
|
.createSchemaBuilder()
|
|
40
39
|
.log();
|
|
41
40
|
if (sqlInMemory.upQueries.length === 0) {
|
|
42
|
-
console.log(
|
|
41
|
+
console.log(ansis_1.default.yellow `Your schema is up to date - there are no queries to be executed by schema synchronization.`);
|
|
43
42
|
}
|
|
44
43
|
else {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.
|
|
49
|
-
console.log(
|
|
50
|
-
lengthSeparators));
|
|
51
|
-
console.log(chalk_1.default.yellow.bold(`-- Schema synchronization will execute following sql queries (${chalk_1.default.white(sqlInMemory.upQueries.length.toString())}):`));
|
|
52
|
-
console.log(chalk_1.default.yellow("---------------------------------------------------------------" +
|
|
53
|
-
lengthSeparators));
|
|
44
|
+
const lineSeparator = "".padStart(63 + String(sqlInMemory.upQueries.length).length, "-");
|
|
45
|
+
console.log(ansis_1.default.yellow(lineSeparator));
|
|
46
|
+
console.log(ansis_1.default.yellow
|
|
47
|
+
.bold `-- Schema synchronization will execute following sql queries (${ansis_1.default.white(sqlInMemory.upQueries.length.toString())}):`);
|
|
48
|
+
console.log(ansis_1.default.yellow(lineSeparator));
|
|
54
49
|
sqlInMemory.upQueries.forEach((upQuery) => {
|
|
55
50
|
let sqlString = upQuery.query;
|
|
56
51
|
sqlString = sqlString.trim();
|
|
57
|
-
sqlString =
|
|
58
|
-
sqlString
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log((0, cli_highlight_1.highlight)(sqlString));
|
|
52
|
+
sqlString = sqlString.endsWith(";")
|
|
53
|
+
? sqlString
|
|
54
|
+
: sqlString + ";";
|
|
55
|
+
console.log(PlatformTools_1.PlatformTools.highlightSql(sqlString));
|
|
62
56
|
});
|
|
63
57
|
}
|
|
64
58
|
await dataSource.destroy();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/SchemaLogCommand.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/SchemaLogCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,gBAAgB;IAA7B;QACI,YAAO,GAAG,YAAY,CAAA;QACtB,aAAQ,GACJ,sGAAsG;YACtG,+DAA+D,CAAA;IAkEvE,CAAC;IAhEG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;YAC7B,KAAK,EAAE,GAAG;YACV,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI,UAAU,GAA2B,SAAS,CAAA;QAClD,IAAI,CAAC;YACD,UAAU,GAAG,MAAM,2BAAY,CAAC,cAAc,C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,CAAC,GAAG,CAAC;wBAC/B,CAAC,CAAC,SAAS;wBACX,CAAC,CAAC,SAAS,GAAG,GAAG,CAAA;oBACrB,OAAO,CAAC,GAAG,CAAC,6BAAa,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAA;gBACtD,CAAC,CAAC,CAAA;YACN,CAAC;YACD,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,UAAU;gBACV,6BAAa,CAAC,SAAS,CACnB,sCAAsC,EACtC,GAAG,CACN,CAAA;YACL,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;CACJ;AAtED,4CAsEC","file":"SchemaLogCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Shows sql to be executed by schema:sync command.\n */\nexport class SchemaLogCommand implements yargs.CommandModule {\n command = \"schema:log\"\n describe =\n \"Shows sql to be executed by schema:sync command. It shows sql log only for your default dataSource. \" +\n \"To run update queries on a concrete connection use -c option.\"\n\n builder(args: yargs.Argv) {\n return args.option(\"dataSource\", {\n alias: \"d\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (sqlInMemory.upQueries.length === 0) {\n console.log(\n ansi.yellow`Your schema is up to date - there are no queries to be executed by schema synchronization.`,\n )\n } else {\n const lineSeparator = \"\".padStart(\n 63 + String(sqlInMemory.upQueries.length).length,\n \"-\",\n )\n console.log(ansi.yellow(lineSeparator))\n console.log(\n ansi.yellow\n .bold`-- Schema synchronization will execute following sql queries (${ansi.white(\n sqlInMemory.upQueries.length.toString(),\n )}):`,\n )\n console.log(ansi.yellow(lineSeparator))\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n let sqlString = upQuery.query\n sqlString = sqlString.trim()\n sqlString = sqlString.endsWith(\";\")\n ? sqlString\n : sqlString + \";\"\n console.log(PlatformTools.highlightSql(sqlString))\n })\n }\n await dataSource.destroy()\n } catch (err) {\n if (dataSource)\n PlatformTools.logCmdErr(\n \"Error during schema synchronization:\",\n err,\n )\n process.exit(1)\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SchemaSyncCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
7
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
7
|
const process_1 = tslib_1.__importDefault(require("process"));
|
|
8
|
+
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
9
9
|
const CommandUtils_1 = require("./CommandUtils");
|
|
10
10
|
/**
|
|
11
11
|
* Synchronizes database schema with entities.
|
|
@@ -36,7 +36,7 @@ class SchemaSyncCommand {
|
|
|
36
36
|
await dataSource.initialize();
|
|
37
37
|
await dataSource.synchronize();
|
|
38
38
|
await dataSource.destroy();
|
|
39
|
-
console.log(
|
|
39
|
+
console.log(ansis_1.default.green `Schema synchronization finished successfully.`);
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
42
|
PlatformTools_1.PlatformTools.logCmdErr("Error during schema synchronization:", err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/SchemaSyncCommand.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/SchemaSyncCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,iBAAiB;IAA9B;QACI,YAAO,GAAG,aAAa,CAAA;QACvB,aAAQ,GACJ,8GAA8G;YAC9G,+DAA+D,CAAA;IAuCvE,CAAC;IArCG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE;YAC7B,KAAK,EAAE,GAAG;YACV,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;IACN,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI,UAAU,GAA2B,SAAS,CAAA;QAClD,IAAI,CAAC;YACD,UAAU,GAAG,MAAM,2BAAY,CAAC,cAAc,CAC1C,cAAI,CAAC,OAAO,CAAC,iBAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,UAAoB,CAAC,CACzD,CAAA;YACD,UAAU,CAAC,UAAU,CAAC;gBAClB,WAAW,EAAE,KAAK;gBAClB,aAAa,EAAE,KAAK;gBACpB,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;aAC/B,CAAC,CAAA;YACF,MAAM,UAAU,CAAC,UAAU,EAAE,CAAA;YAC7B,MAAM,UAAU,CAAC,WAAW,EAAE,CAAA;YAC9B,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;YAE1B,OAAO,CAAC,GAAG,CACP,eAAI,CAAC,KAAK,CAAA,+CAA+C,CAC5D,CAAA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,sCAAsC,EAAE,GAAG,CAAC,CAAA;YAEpE,IAAI,UAAU,IAAI,UAAU,CAAC,aAAa;gBACtC,MAAM,UAAU,CAAC,OAAO,EAAE,CAAA;YAE9B,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;CACJ;AA3CD,8CA2CC","file":"SchemaSyncCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source/DataSource\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Synchronizes database schema with entities.\n */\nexport class SchemaSyncCommand implements yargs.CommandModule {\n command = \"schema:sync\"\n describe =\n \"Synchronizes your entities with database schema. It runs schema update queries on all connections you have. \" +\n \"To run update queries on a concrete connection use -c option.\"\n\n builder(args: yargs.Argv) {\n return args.option(\"dataSource\", {\n alias: \"d\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: [\"query\", \"schema\"],\n })\n await dataSource.initialize()\n await dataSource.synchronize()\n await dataSource.destroy()\n\n console.log(\n ansi.green`Schema synchronization finished successfully.`,\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during schema synchronization:\", err)\n\n if (dataSource && dataSource.isInitialized)\n await dataSource.destroy()\n\n process.exit(1)\n }\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubscriberCreateCommand = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const PlatformTools_1 = require("../platform/PlatformTools");
|
|
8
8
|
const CommandUtils_1 = require("./CommandUtils");
|
|
@@ -30,13 +30,13 @@ class SubscriberCreateCommand {
|
|
|
30
30
|
const fileContent = SubscriberCreateCommand.getTemplate(filename);
|
|
31
31
|
const fileExists = await CommandUtils_1.CommandUtils.fileExists(fullPath + ".ts");
|
|
32
32
|
if (fileExists) {
|
|
33
|
-
throw `File ${
|
|
33
|
+
throw new Error(`File "${fullPath}.ts" already exists`);
|
|
34
34
|
}
|
|
35
35
|
await CommandUtils_1.CommandUtils.createFile(fullPath + ".ts", fileContent);
|
|
36
|
-
console.log(
|
|
36
|
+
console.log(ansis_1.default.green(`Subscriber ${ansis_1.default.blue `${fullPath}.ts`} has been created successfully.`));
|
|
37
37
|
}
|
|
38
|
-
catch (
|
|
39
|
-
PlatformTools_1.PlatformTools.logCmdErr("Error during subscriber creation:");
|
|
38
|
+
catch (error) {
|
|
39
|
+
PlatformTools_1.PlatformTools.logCmdErr("Error during subscriber creation:", error);
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/SubscriberCreateCommand.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/SubscriberCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AAEvB,6DAAyD;AACzD,iDAA6C;AAE7C;;GAEG;AACH,MAAa,uBAAuB;IAApC;QACI,YAAO,GAAG,0BAA0B,CAAA;QACpC,aAAQ,GAAG,6BAA6B,CAAA;IAiD5C,CAAC;IA/CG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAC3B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,6BAA6B;YACvC,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;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\"yargs\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new subscriber.\n */\nexport class SubscriberCreateCommand implements yargs.CommandModule {\n command = \"subscriber:create <path>\"\n describe = \"Generates a new subscriber.\"\n\n builder(args: yargs.Argv) {\n return args.positional(\"path\", {\n type: \"string\",\n describe: \"Path of the subscriber file\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = path.basename(fullPath)\n const fileContent = SubscriberCreateCommand.getTemplate(filename)\n const fileExists = await CommandUtils.fileExists(fullPath + \".ts\")\n if (fileExists) {\n throw new Error(`File \"${fullPath}.ts\" already exists`)\n }\n await CommandUtils.createFile(fullPath + \".ts\", fileContent)\n console.log(\n ansi.green(\n `Subscriber ${ansi.blue`${fullPath}.ts`} has been created successfully.`,\n ),\n )\n } catch (error) {\n PlatformTools.logCmdErr(\"Error during subscriber creation:\", error)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the entity file.\n */\n protected static getTemplate(name: string): string {\n return `import { EventSubscriber, EntitySubscriberInterface } from \"typeorm\"\n\n@EventSubscriber()\nexport class ${name} implements EntitySubscriberInterface {\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -8,22 +8,22 @@ export declare class ConnectionOptionsReader {
|
|
|
8
8
|
* Directory where ormconfig should be read from.
|
|
9
9
|
* By default its your application root (where your app package.json is located).
|
|
10
10
|
*/
|
|
11
|
-
root?: string
|
|
11
|
+
root?: string;
|
|
12
12
|
/**
|
|
13
13
|
* Filename of the ormconfig configuration. By default its equal to "ormconfig".
|
|
14
14
|
*/
|
|
15
|
-
configName?: string
|
|
15
|
+
configName?: string;
|
|
16
16
|
} | undefined;
|
|
17
17
|
constructor(options?: {
|
|
18
18
|
/**
|
|
19
19
|
* Directory where ormconfig should be read from.
|
|
20
20
|
* By default its your application root (where your app package.json is located).
|
|
21
21
|
*/
|
|
22
|
-
root?: string
|
|
22
|
+
root?: string;
|
|
23
23
|
/**
|
|
24
24
|
* Filename of the ormconfig configuration. By default its equal to "ormconfig".
|
|
25
25
|
*/
|
|
26
|
-
configName?: string
|
|
26
|
+
configName?: string;
|
|
27
27
|
} | undefined);
|
|
28
28
|
/**
|
|
29
29
|
* Returns all connection options read from the ormconfig.
|
package/container.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useContainer = useContainer;
|
|
4
|
+
exports.getFromContainer = getFromContainer;
|
|
4
5
|
/**
|
|
5
6
|
* Container to be used by this library for inversion control. If container was not implicitly set then by default
|
|
6
7
|
* container simply creates a new instance of the given class.
|
|
@@ -34,7 +35,6 @@ function useContainer(iocContainer, options) {
|
|
|
34
35
|
userContainer = iocContainer;
|
|
35
36
|
userContainerOptions = options;
|
|
36
37
|
}
|
|
37
|
-
exports.useContainer = useContainer;
|
|
38
38
|
/**
|
|
39
39
|
* Gets the IOC container used by this library.
|
|
40
40
|
*
|
|
@@ -56,6 +56,5 @@ function getFromContainer(someClass) {
|
|
|
56
56
|
}
|
|
57
57
|
return defaultContainer.get(someClass);
|
|
58
58
|
}
|
|
59
|
-
exports.getFromContainer = getFromContainer;
|
|
60
59
|
|
|
61
60
|
//# sourceMappingURL=container.js.map
|
package/container.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/container.ts"],"names":[],"mappings":";;AA8DA,oCAMC;AAOD,4CAcC;AA5DD;;;;;GAKG;AACH,MAAM,gBAAgB,GAAuB,IAAI,CAAC;IAAA;QAGtC,cAAS,GAAsC,EAAE,CAA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\n * If set to true, then default container will be used in the case if given container haven't returned anything.\n */\n fallback?: boolean\n\n /**\n * If set to true, then default container will be used in the case if given container thrown an exception.\n */\n fallbackOnErrors?: boolean\n}\n\n/**\n * @deprecated\n */\nexport type ContainedType<T> = { new (...args: any[]): T } | Function\n\n/**\n * @deprecated\n */\nexport interface ContainerInterface {\n get<T>(someClass: ContainedType<T>): T\n}\n\n/**\n * Container to be used by this library for inversion control. If container was not implicitly set then by default\n * container simply creates a new instance of the given class.\n *\n * @deprecated\n */\nconst defaultContainer: ContainerInterface = new (class\n implements ContainerInterface\n{\n private instances: { type: Function; object: any }[] = []\n\n get<T>(someClass: ContainedType<T>): T {\n let instance = this.instances.find((i) => i.type === someClass)\n if (!instance) {\n instance = {\n type: someClass,\n object: new (someClass as new () => T)(),\n }\n this.instances.push(instance)\n }\n\n return instance.object\n }\n})()\n\nlet userContainer: ContainerInterface\nlet userContainerOptions: UseContainerOptions | undefined\n\n/**\n * Sets container to be used by this library.\n *\n * @deprecated\n */\nexport function useContainer(\n iocContainer: ContainerInterface,\n options?: UseContainerOptions,\n) {\n userContainer = iocContainer\n userContainerOptions = options\n}\n\n/**\n * Gets the IOC container used by this library.\n *\n * @deprecated\n */\nexport function getFromContainer<T>(someClass: ContainedType<T>): T {\n if (userContainer) {\n try {\n const instance = userContainer.get(someClass)\n if (instance) return instance\n\n if (!userContainerOptions || !userContainerOptions.fallback)\n return instance\n } catch (error) {\n if (!userContainerOptions || !userContainerOptions.fallbackOnErrors)\n throw error\n }\n }\n return defaultContainer.get<T>(someClass)\n}\n"],"sourceRoot":"."}
|
|
@@ -214,6 +214,8 @@ export declare class DataSource {
|
|
|
214
214
|
transaction<T>(isolationLevel: IsolationLevel, runInTransaction: (entityManager: EntityManager) => Promise<T>): Promise<T>;
|
|
215
215
|
/**
|
|
216
216
|
* Executes raw SQL query and returns raw database results.
|
|
217
|
+
*
|
|
218
|
+
* @see [Official docs](https://typeorm.io/data-source-api) for examples.
|
|
217
219
|
*/
|
|
218
220
|
query<T = any>(query: string, parameters?: any[], queryRunner?: QueryRunner): Promise<T>;
|
|
219
221
|
/**
|
|
@@ -339,6 +339,8 @@ class DataSource {
|
|
|
339
339
|
}
|
|
340
340
|
/**
|
|
341
341
|
* Executes raw SQL query and returns raw database results.
|
|
342
|
+
*
|
|
343
|
+
* @see [Official docs](https://typeorm.io/data-source-api) for examples.
|
|
342
344
|
*/
|
|
343
345
|
async query(query, parameters, queryRunner) {
|
|
344
346
|
if (InstanceChecker_1.InstanceChecker.isMongoEntityManager(this.manager))
|