@depup/typeorm-extension 3.9.0-depup.0

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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.MD +674 -0
  3. package/README.md +34 -0
  4. package/bin/cli.cjs +275 -0
  5. package/bin/cli.mjs +273 -0
  6. package/changes.json +22 -0
  7. package/dist/cli/commands/database/create.d.ts +27 -0
  8. package/dist/cli/commands/database/drop.d.ts +23 -0
  9. package/dist/cli/commands/database/index.d.ts +2 -0
  10. package/dist/cli/commands/index.d.ts +2 -0
  11. package/dist/cli/commands/seed/create.d.ts +21 -0
  12. package/dist/cli/commands/seed/index.d.ts +2 -0
  13. package/dist/cli/commands/seed/run.d.ts +24 -0
  14. package/dist/cli/index.d.ts +2 -0
  15. package/dist/data-source/find/index.d.ts +2 -0
  16. package/dist/data-source/find/module.d.ts +3 -0
  17. package/dist/data-source/find/type.d.ts +22 -0
  18. package/dist/data-source/index.d.ts +4 -0
  19. package/dist/data-source/options/index.d.ts +4 -0
  20. package/dist/data-source/options/module.d.ts +8 -0
  21. package/dist/data-source/options/singleton.d.ts +4 -0
  22. package/dist/data-source/options/type.d.ts +26 -0
  23. package/dist/data-source/options/utils/env.d.ts +4 -0
  24. package/dist/data-source/options/utils/index.d.ts +2 -0
  25. package/dist/data-source/options/utils/merge.d.ts +2 -0
  26. package/dist/data-source/singleton.d.ts +5 -0
  27. package/dist/data-source/type.d.ts +2 -0
  28. package/dist/database/driver/cockroachdb.d.ts +4 -0
  29. package/dist/database/driver/index.d.ts +9 -0
  30. package/dist/database/driver/mongodb.d.ts +6 -0
  31. package/dist/database/driver/mssql.d.ts +6 -0
  32. package/dist/database/driver/mysql.d.ts +7 -0
  33. package/dist/database/driver/oracle.d.ts +6 -0
  34. package/dist/database/driver/postgres.d.ts +8 -0
  35. package/dist/database/driver/sqlite.d.ts +3 -0
  36. package/dist/database/driver/types.d.ts +20 -0
  37. package/dist/database/driver/utils/build.d.ts +3 -0
  38. package/dist/database/driver/utils/character-set.d.ts +2 -0
  39. package/dist/database/driver/utils/charset.d.ts +2 -0
  40. package/dist/database/driver/utils/create.d.ts +2 -0
  41. package/dist/database/driver/utils/index.d.ts +4 -0
  42. package/dist/database/index.d.ts +3 -0
  43. package/dist/database/methods/check/index.d.ts +2 -0
  44. package/dist/database/methods/check/module.d.ts +7 -0
  45. package/dist/database/methods/check/types.d.ts +51 -0
  46. package/dist/database/methods/create/index.d.ts +1 -0
  47. package/dist/database/methods/create/module.d.ts +10 -0
  48. package/dist/database/methods/drop/index.d.ts +1 -0
  49. package/dist/database/methods/drop/module.d.ts +10 -0
  50. package/dist/database/methods/index.d.ts +4 -0
  51. package/dist/database/methods/type.d.ts +43 -0
  52. package/dist/database/utils/context.d.ts +3 -0
  53. package/dist/database/utils/index.d.ts +5 -0
  54. package/dist/database/utils/migration.d.ts +2 -0
  55. package/dist/database/utils/query.d.ts +3 -0
  56. package/dist/database/utils/schema.d.ts +3 -0
  57. package/dist/database/utils/type.d.ts +32 -0
  58. package/dist/env/constants.d.ts +68 -0
  59. package/dist/env/index.d.ts +3 -0
  60. package/dist/env/module.d.ts +4 -0
  61. package/dist/env/type.d.ts +36 -0
  62. package/dist/env/utils.d.ts +3 -0
  63. package/dist/errors/base.d.ts +2 -0
  64. package/dist/errors/driver.d.ts +6 -0
  65. package/dist/errors/index.d.ts +3 -0
  66. package/dist/errors/options.d.ts +7 -0
  67. package/dist/helpers/entity/error.d.ts +20 -0
  68. package/dist/helpers/entity/index.d.ts +5 -0
  69. package/dist/helpers/entity/join-columns.d.ts +16 -0
  70. package/dist/helpers/entity/metadata.d.ts +10 -0
  71. package/dist/helpers/entity/property-names.d.ts +11 -0
  72. package/dist/helpers/entity/uniqueness.d.ts +28 -0
  73. package/dist/helpers/index.d.ts +1 -0
  74. package/dist/index.cjs +3258 -0
  75. package/dist/index.cjs.map +1 -0
  76. package/dist/index.d.ts +9 -0
  77. package/dist/index.mjs +3136 -0
  78. package/dist/index.mjs.map +1 -0
  79. package/dist/query/index.d.ts +4 -0
  80. package/dist/query/module.d.ts +5 -0
  81. package/dist/query/parameter/fields/index.d.ts +2 -0
  82. package/dist/query/parameter/fields/module.d.ts +25 -0
  83. package/dist/query/parameter/fields/type.d.ts +6 -0
  84. package/dist/query/parameter/filters/index.d.ts +2 -0
  85. package/dist/query/parameter/filters/module.d.ts +35 -0
  86. package/dist/query/parameter/filters/type.d.ts +12 -0
  87. package/dist/query/parameter/index.d.ts +5 -0
  88. package/dist/query/parameter/pagination/index.d.ts +2 -0
  89. package/dist/query/parameter/pagination/module.d.ts +26 -0
  90. package/dist/query/parameter/pagination/type.d.ts +3 -0
  91. package/dist/query/parameter/relations/index.d.ts +2 -0
  92. package/dist/query/parameter/relations/module.d.ts +27 -0
  93. package/dist/query/parameter/relations/type.d.ts +8 -0
  94. package/dist/query/parameter/sort/index.d.ts +2 -0
  95. package/dist/query/parameter/sort/module.d.ts +26 -0
  96. package/dist/query/parameter/sort/type.d.ts +6 -0
  97. package/dist/query/type.d.ts +16 -0
  98. package/dist/query/utils/alias.d.ts +2 -0
  99. package/dist/query/utils/index.d.ts +3 -0
  100. package/dist/query/utils/key.d.ts +1 -0
  101. package/dist/query/utils/option.d.ts +1 -0
  102. package/dist/seeder/entity.d.ts +42 -0
  103. package/dist/seeder/executor.d.ts +24 -0
  104. package/dist/seeder/factory/index.d.ts +4 -0
  105. package/dist/seeder/factory/manager.d.ts +8 -0
  106. package/dist/seeder/factory/module.d.ts +17 -0
  107. package/dist/seeder/factory/type.d.ts +12 -0
  108. package/dist/seeder/factory/utils.d.ts +7 -0
  109. package/dist/seeder/index.d.ts +6 -0
  110. package/dist/seeder/module.d.ts +5 -0
  111. package/dist/seeder/type.d.ts +44 -0
  112. package/dist/seeder/utils/file-path.d.ts +7 -0
  113. package/dist/seeder/utils/index.d.ts +3 -0
  114. package/dist/seeder/utils/prepare.d.ts +2 -0
  115. package/dist/seeder/utils/template.d.ts +1 -0
  116. package/dist/utils/code-transformation/constants.d.ts +4 -0
  117. package/dist/utils/code-transformation/index.d.ts +2 -0
  118. package/dist/utils/code-transformation/module.d.ts +3 -0
  119. package/dist/utils/entity.d.ts +2 -0
  120. package/dist/utils/file-path.d.ts +9 -0
  121. package/dist/utils/file-system.d.ts +1 -0
  122. package/dist/utils/has-property.d.ts +2 -0
  123. package/dist/utils/index.d.ts +10 -0
  124. package/dist/utils/object.d.ts +2 -0
  125. package/dist/utils/promise.d.ts +1 -0
  126. package/dist/utils/separator.d.ts +3 -0
  127. package/dist/utils/slash.d.ts +2 -0
  128. package/dist/utils/tsconfig/index.d.ts +2 -0
  129. package/dist/utils/tsconfig/module.d.ts +2 -0
  130. package/dist/utils/tsconfig/type.d.ts +13 -0
  131. package/package.json +134 -0
@@ -0,0 +1,24 @@
1
+ import type { Arguments, Argv, CommandModule } from 'yargs';
2
+ export interface SeedRunArguments extends Arguments {
3
+ preserveFilePaths: boolean;
4
+ root: string;
5
+ tsconfig: string;
6
+ dataSource: string;
7
+ name?: string;
8
+ }
9
+ export declare class SeedRunCommand implements CommandModule {
10
+ command: string;
11
+ describe: string;
12
+ builder(args: Argv): Argv<{
13
+ preserveFilePaths: boolean;
14
+ } & {
15
+ root: string;
16
+ } & {
17
+ tsconfig: string;
18
+ } & {
19
+ dataSource: string;
20
+ } & {
21
+ name: unknown;
22
+ }>;
23
+ handler(raw: Arguments): Promise<void>;
24
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'reflect-metadata';
@@ -0,0 +1,2 @@
1
+ export * from './module';
2
+ export * from './type';
@@ -0,0 +1,3 @@
1
+ import type { DataSource } from 'typeorm';
2
+ import type { DataSourceFindOptions } from './type';
3
+ export declare function findDataSource(context?: DataSourceFindOptions): Promise<DataSource | undefined>;
@@ -0,0 +1,22 @@
1
+ import type { TSConfig } from '../../utils/tsconfig';
2
+ export type DataSourceFindOptions = {
3
+ /**
4
+ * Directory where to look for DataSource files.
5
+ */
6
+ directory?: string;
7
+ /**
8
+ * DataSource file name.
9
+ */
10
+ fileName?: string;
11
+ /**
12
+ * This option indicates if file paths should be preserved,
13
+ * and treated as if the just-in-time compilation environment is detected.
14
+ */
15
+ preserveFilePaths?: boolean;
16
+ /**
17
+ * Directory path to the tsconfig.json file
18
+ *
19
+ * Default: process.cwd() + path.sep + tsconfig.json
20
+ */
21
+ tsconfig?: string | TSConfig;
22
+ };
@@ -0,0 +1,4 @@
1
+ export * from './find';
2
+ export * from './options';
3
+ export * from './singleton';
4
+ export * from './type';
@@ -0,0 +1,4 @@
1
+ export * from './module';
2
+ export * from './singleton';
3
+ export * from './type';
4
+ export * from './utils';
@@ -0,0 +1,8 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ import type { DataSourceOptionsBuildContext } from './type';
3
+ /**
4
+ * Build DataSourceOptions from DataSource or from configuration.
5
+ *
6
+ * @param context
7
+ */
8
+ export declare function buildDataSourceOptions(context?: DataSourceOptionsBuildContext): Promise<DataSourceOptions>;
@@ -0,0 +1,4 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function setDataSourceOptions(options: DataSourceOptions, alias?: string): void;
3
+ export declare function hasDataSourceOptions(alias?: string): boolean;
4
+ export declare function useDataSourceOptions(alias?: string): Promise<DataSourceOptions>;
@@ -0,0 +1,26 @@
1
+ import type { TSConfig } from '../../utils/tsconfig';
2
+ export type DataSourceOptionsBuildContext = {
3
+ /**
4
+ * Data source file name without extension
5
+ *
6
+ * Default: data-source
7
+ */
8
+ dataSourceName?: string;
9
+ /**
10
+ * Directory where to find dataSource + config
11
+ *
12
+ * Default: process.cwd()
13
+ */
14
+ directory?: string;
15
+ /**
16
+ * Directory path to the tsconfig.json file
17
+ *
18
+ * Default: process.cwd() + path.sep + tsconfig.json
19
+ */
20
+ tsconfig?: string | TSConfig;
21
+ /**
22
+ * This option indicates if file paths should be preserved,
23
+ * and treated as if the just-in-time compilation environment is detected.
24
+ */
25
+ preserveFilePaths?: boolean;
26
+ };
@@ -0,0 +1,4 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function hasEnvDataSourceOptions(): boolean;
3
+ export declare function readDataSourceOptionsFromEnv(): DataSourceOptions | undefined;
4
+ export declare function mergeDataSourceOptionsWithEnv(options: DataSourceOptions): DataSourceOptions;
@@ -0,0 +1,2 @@
1
+ export * from './env';
2
+ export * from './merge';
@@ -0,0 +1,2 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function mergeDataSourceOptions(target: DataSourceOptions, source: DataSourceOptions): DataSourceOptions;
@@ -0,0 +1,5 @@
1
+ import { DataSource } from 'typeorm';
2
+ export declare function setDataSource(dataSource: DataSource, alias?: string): void;
3
+ export declare function hasDataSource(alias?: string): boolean;
4
+ export declare function unsetDataSource(alias?: string): void;
5
+ export declare function useDataSource(alias?: string): Promise<DataSource>;
@@ -0,0 +1,2 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export type DataSourceCacheOption = DataSourceOptions['cache'];
@@ -0,0 +1,4 @@
1
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
2
+ export declare function executeSimpleCockroachDBQuery(connection: any, query: string, endConnection?: boolean): Promise<unknown>;
3
+ export declare function createCockroachDBDatabase(input?: DatabaseCreateContextInput): Promise<unknown>;
4
+ export declare function dropCockroachDBDatabase(input?: DatabaseDropContextInput): Promise<unknown>;
@@ -0,0 +1,9 @@
1
+ export * from './cockroachdb';
2
+ export * from './mongodb';
3
+ export * from './mssql';
4
+ export * from './mysql';
5
+ export * from './oracle';
6
+ export * from './postgres';
7
+ export * from './sqlite';
8
+ export * from './types';
9
+ export * from './utils';
@@ -0,0 +1,6 @@
1
+ import type { MongoDriver } from 'typeorm/driver/mongodb/MongoDriver';
2
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
3
+ import type { DriverOptions } from './types';
4
+ export declare function createSimpleMongoDBConnection(driver: MongoDriver, options: DriverOptions): Promise<any>;
5
+ export declare function createMongoDBDatabase(input?: DatabaseCreateContextInput): Promise<void>;
6
+ export declare function dropMongoDBDatabase(input?: DatabaseDropContextInput): Promise<any>;
@@ -0,0 +1,6 @@
1
+ import type { SqlServerDriver } from 'typeorm/driver/sqlserver/SqlServerDriver';
2
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
3
+ import type { DriverOptions } from './types';
4
+ export declare function createSimpleMsSQLConnection(driver: SqlServerDriver, options: DriverOptions): Promise<any>;
5
+ export declare function createMsSQLDatabase(input?: DatabaseCreateContextInput): Promise<any>;
6
+ export declare function dropMsSQLDatabase(input?: DatabaseDropContextInput): Promise<any>;
@@ -0,0 +1,7 @@
1
+ import type { MysqlDriver } from 'typeorm/driver/mysql/MysqlDriver';
2
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
3
+ import type { DriverOptions } from './types';
4
+ export declare function createSimpleMySQLConnection(driver: MysqlDriver, options: DriverOptions): Promise<any>;
5
+ export declare function executeSimpleMysqlQuery(connection: any, query: string, endConnection?: boolean): Promise<unknown>;
6
+ export declare function createMySQLDatabase(input?: DatabaseCreateContextInput): Promise<unknown>;
7
+ export declare function dropMySQLDatabase(input?: DatabaseDropContextInput): Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ import type { OracleDriver } from 'typeorm/driver/oracle/OracleDriver';
2
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
3
+ import type { DriverOptions } from './types';
4
+ export declare function createSimpleOracleConnection(driver: OracleDriver, options: DriverOptions): any;
5
+ export declare function createOracleDatabase(input?: DatabaseCreateContextInput): Promise<any>;
6
+ export declare function dropOracleDatabase(_context?: DatabaseDropContextInput): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import type { PostgresDriver } from 'typeorm/driver/postgres/PostgresDriver';
2
+ import type { CockroachDriver } from 'typeorm/driver/cockroachdb/CockroachDriver';
3
+ import type { DatabaseBaseContext, DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
4
+ import type { DriverOptions } from './types';
5
+ export declare function createSimplePostgresConnection(driver: PostgresDriver | CockroachDriver, options: DriverOptions, operationContext: DatabaseBaseContext): Promise<any>;
6
+ export declare function executeSimplePostgresQuery(connection: any, query: string, endConnection?: boolean): Promise<unknown>;
7
+ export declare function createPostgresDatabase(input?: DatabaseCreateContextInput): Promise<unknown>;
8
+ export declare function dropPostgresDatabase(input?: DatabaseDropContextInput): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ import type { DatabaseCreateContextInput, DatabaseDropContextInput } from '../methods';
2
+ export declare function createSQLiteDatabase(input?: DatabaseCreateContextInput): Promise<void>;
3
+ export declare function dropSQLiteDatabase(input?: DatabaseDropContextInput): Promise<void>;
@@ -0,0 +1,20 @@
1
+ export type DriverOptions = {
2
+ database?: string;
3
+ host?: string;
4
+ user?: string;
5
+ password?: string;
6
+ port?: number;
7
+ ssl?: any;
8
+ url?: string;
9
+ connectString?: string;
10
+ sid?: string | number;
11
+ serviceName?: string;
12
+ domain?: string;
13
+ charset?: string;
14
+ characterSet?: string;
15
+ schema?: string;
16
+ template?: string;
17
+ extra?: {
18
+ [key: string]: any;
19
+ };
20
+ };
@@ -0,0 +1,3 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ import type { DriverOptions } from '../types';
3
+ export declare function buildDriverOptions(options: DataSourceOptions): DriverOptions;
@@ -0,0 +1,2 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function getCharacterSetFromDataSourceOptions(options: DataSourceOptions): string | undefined;
@@ -0,0 +1,2 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function getCharsetFromDataSourceOptions(options: DataSourceOptions): string | undefined;
@@ -0,0 +1,2 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ export declare function createDriver(connectionOptions: DataSourceOptions): import("typeorm").Driver;
@@ -0,0 +1,4 @@
1
+ export * from './build';
2
+ export * from './character-set';
3
+ export * from './charset';
4
+ export * from './create';
@@ -0,0 +1,3 @@
1
+ export * from './methods';
2
+ export * from './driver';
3
+ export * from './utils';
@@ -0,0 +1,2 @@
1
+ export * from './module';
2
+ export * from './types';
@@ -0,0 +1,7 @@
1
+ import type { DatabaseCheckContext, DatabaseCheckResult } from './types';
2
+ /**
3
+ * Check database setup progress.
4
+ *
5
+ * @param context
6
+ */
7
+ export declare function checkDatabase(context?: DatabaseCheckContext): Promise<DatabaseCheckResult>;
@@ -0,0 +1,51 @@
1
+ import type { DataSource, DataSourceOptions, Migration } from 'typeorm';
2
+ export type DatabaseCheckContext = {
3
+ /**
4
+ * Options for finding the typeorm DataSource.
5
+ *
6
+ * Default: undefined
7
+ */
8
+ options?: DataSourceOptions;
9
+ /**
10
+ * Use alias to access already registered DataSource / DataSourceOptions.
11
+ *
12
+ * default: undefined
13
+ */
14
+ alias?: string;
15
+ /**
16
+ * Indicates whether to destroy the data-source
17
+ * afterward or not.
18
+ * If a datasource previously existed, this option will be ignored.
19
+ *
20
+ * default: true
21
+ */
22
+ dataSourceCleanup?: boolean;
23
+ /**
24
+ * Use predefined data-source for checks.
25
+ *
26
+ * default: undefined
27
+ */
28
+ dataSource?: DataSource;
29
+ };
30
+ export type DatabaseCheckResult = {
31
+ /**
32
+ * Indicates whether the database
33
+ * has already been created or not.
34
+ *
35
+ * default: false
36
+ */
37
+ exists: boolean;
38
+ /**
39
+ * Indicates whether the database's schema
40
+ * is up-to-date.
41
+ *
42
+ * default: false
43
+ */
44
+ schema: boolean;
45
+ /**
46
+ * Array of un applied migrations.
47
+ *
48
+ * default: []
49
+ */
50
+ migrationsPending: Migration[];
51
+ };
@@ -0,0 +1 @@
1
+ export * from './module';
@@ -0,0 +1,10 @@
1
+ import type { DatabaseCreateContextInput } from '../type';
2
+ /**
3
+ * Create database for specified driver in ConnectionOptions.
4
+ *
5
+ * @throws DriverError
6
+ * @throws OptionsError
7
+ *
8
+ * @param input
9
+ */
10
+ export declare function createDatabase(input?: DatabaseCreateContextInput): Promise<unknown>;
@@ -0,0 +1 @@
1
+ export * from './module';
@@ -0,0 +1,10 @@
1
+ import type { DatabaseDropContextInput } from '../type';
2
+ /**
3
+ * Drop database for specified driver in ConnectionOptions.
4
+ *
5
+ * @throws DriverError
6
+ * @throws OptionsError
7
+ *
8
+ * @param input
9
+ */
10
+ export declare function dropDatabase(input?: DatabaseDropContextInput): Promise<unknown>;
@@ -0,0 +1,4 @@
1
+ export * from './check';
2
+ export * from './create';
3
+ export * from './drop';
4
+ export * from './type';
@@ -0,0 +1,43 @@
1
+ import type { DataSourceOptions } from 'typeorm';
2
+ import type { DataSourceFindOptions } from '../../data-source';
3
+ export type DatabaseBaseContext = {
4
+ /**
5
+ * Options for finding the typeorm DataSource.
6
+ */
7
+ options: DataSourceOptions;
8
+ /**
9
+ * Options for the find method, where to look for the data-source file.
10
+ */
11
+ findOptions?: DataSourceFindOptions;
12
+ /**
13
+ * Initial database to connect.
14
+ *
15
+ * default: undefined
16
+ */
17
+ initialDatabase?: string;
18
+ };
19
+ export type DatabaseBaseContextInput = Partial<DatabaseBaseContext>;
20
+ export type DatabaseCreateContext = Omit<DatabaseBaseContext, 'findOptions'> & {
21
+ /**
22
+ * Only create database if not already exist.
23
+ *
24
+ * default: true
25
+ */
26
+ ifNotExist: boolean;
27
+ /**
28
+ * Synchronize or migrate the database scheme.
29
+ *
30
+ * default: true
31
+ */
32
+ synchronize: boolean;
33
+ };
34
+ export type DatabaseCreateContextInput = Partial<DatabaseCreateContext>;
35
+ export type DatabaseDropContext = Omit<DatabaseBaseContext, 'findOptions'> & {
36
+ /**
37
+ * Only drop database if existed.
38
+ *
39
+ * Default: true
40
+ */
41
+ ifExist?: boolean;
42
+ };
43
+ export type DatabaseDropContextInput = Partial<DatabaseDropContext>;
@@ -0,0 +1,3 @@
1
+ import type { DatabaseCreateContext, DatabaseCreateContextInput, DatabaseDropContext, DatabaseDropContextInput } from '../methods';
2
+ export declare function buildDatabaseCreateContext(input?: DatabaseCreateContextInput): Promise<DatabaseCreateContext>;
3
+ export declare function buildDatabaseDropContext(input?: DatabaseDropContextInput): Promise<DatabaseDropContext>;
@@ -0,0 +1,5 @@
1
+ export * from './context';
2
+ export * from './migration';
3
+ export * from './query';
4
+ export * from './schema';
5
+ export * from './type';
@@ -0,0 +1,2 @@
1
+ import type { MigrationGenerateCommandContext, MigrationGenerateResult } from './type';
2
+ export declare function generateMigration(context: MigrationGenerateCommandContext): Promise<MigrationGenerateResult>;
@@ -0,0 +1,3 @@
1
+ import type { ObjectLiteral } from 'rapiq';
2
+ import type { SelectQueryBuilder } from 'typeorm';
3
+ export declare function existsQuery<T extends ObjectLiteral = ObjectLiteral>(builder: SelectQueryBuilder<T>, inverse?: boolean): string;
@@ -0,0 +1,3 @@
1
+ import type { DataSourceOptions, Migration } from 'typeorm';
2
+ import { DataSource } from 'typeorm';
3
+ export declare function synchronizeDatabaseSchema(input: DataSource | DataSourceOptions): Promise<Migration[]>;
@@ -0,0 +1,32 @@
1
+ import type { DataSource } from 'typeorm';
2
+ export type MigrationGenerateResult = {
3
+ up: string[];
4
+ down: string[];
5
+ content?: string;
6
+ };
7
+ export type MigrationGenerateCommandContext = {
8
+ /**
9
+ * Directory where the migration(s) should be stored.
10
+ */
11
+ directoryPath?: string;
12
+ /**
13
+ * Name of the migration class.
14
+ */
15
+ name?: string;
16
+ /**
17
+ * DataSource used for reference of existing schema.
18
+ */
19
+ dataSource: DataSource;
20
+ /**
21
+ * Timestamp in milliseconds.
22
+ */
23
+ timestamp?: number;
24
+ /**
25
+ * Prettify sql statements.
26
+ */
27
+ prettify?: boolean;
28
+ /**
29
+ * Only return up- & down-statements instead of backing up the migration to the file system.
30
+ */
31
+ preview?: boolean;
32
+ };
@@ -0,0 +1,68 @@
1
+ export declare enum EnvironmentName {
2
+ DEVELOPMENT = "development",
3
+ PRODUCTION = "production",
4
+ TEST = "test"
5
+ }
6
+ export declare enum EnvironmentVariableName {
7
+ ENV = "NODE_ENV",
8
+ SEEDS = "DB_SEEDS",
9
+ SEEDS_ALT = "TYPEORM_SEEDING_SEEDS",
10
+ FACTORIES = "DB_FACTORIES",
11
+ FACTORIES_ALT = "TYPEORM_SEEDING_FACTORIES",
12
+ TYPE = "DB_TYPE",
13
+ TYPE_ALT = "TYPEORM_CONNECTION",
14
+ URL = "DB_URL",
15
+ URL_ALT = "TYPEORM_URL",
16
+ HOST = "DB_HOST",
17
+ HOST_ALT = "TYPEORM_HOST",
18
+ PORT = "DB_PORT",
19
+ PORT_ALT = "TYPEORM_PORT",
20
+ USERNAME = "DB_USERNAME",
21
+ USERNAME_ALT = "TYPEORM_USERNAME",
22
+ PASSWORD = "DB_PASSWORD",
23
+ PASSWORD_ALT = "TYPEORM_PASSWORD",
24
+ DATABASE = "DB_DATABASE",
25
+ DATABASE_ALT = "TYPEORM_DATABASE",
26
+ SID = "DB_SID",
27
+ SID_ALT = "TYPEORM_SID",
28
+ SCHEMA = "DB_SCHEMA",
29
+ SCHEMA_ALT = "TYPEORM_SCHEMA",
30
+ SCHEMA_DROP = "DB_DROP_SCHEMA",
31
+ SCHEMA_DROP_ALT = "TYPEORM_DROP_SCHEMA",
32
+ DRIVER_EXTRA = "DB_DRIVER_EXTRA",
33
+ DRIVER_EXTRA_ALT = "TYPEORM_DRIVER_EXTRA",
34
+ SYNCHRONIZE = "DB_SYNCHRONIZE",
35
+ SYNCHRONIZE_ALT = "TYPEORM_SYNCHRONIZE",
36
+ MIGRATIONS = "DB_MIGRATIONS",
37
+ MIGRATIONS_ALT = "TYPEORM_MIGRATIONS",
38
+ MIGRATIONS_RUN = "DB_MIGRATIONS_RUN",
39
+ MIGRATIONS_RUN_ALT = "TYPEORM_MIGRATIONS_RUN",
40
+ MIGRATIONS_TABLE_NAME = "DB_MIGRATIONS_TABLE_NAME",
41
+ MIGRATIONS_TABLE_NAME_ALT = "TYPEORM_MIGRATIONS_TABLE_NAME",
42
+ ENTITIES = "DB_ENTITIES",
43
+ ENTITIES_ALT = "TYPEORM_ENTITIES",
44
+ ENTITY_PREFIX = "DB_ENTITY_PREFIX",
45
+ ENTITY_PREFIX_ALT = "TYPEORM_ENTITY_PREFIX",
46
+ METADATA_TABLE_NAME = "DB_METADATA_TABLE_NAME",
47
+ METADATA_TABLE_NAME_ALT = "TYPEORM_METADATA_TABLE_NAME",
48
+ SUBSCRIBERS = "DB_SUBSCRIBERS",
49
+ SUBSCRIBERS_ALT = "TYPEORM_SUBSCRIBERS",
50
+ LOGGING = "DB_LOGGING",
51
+ LOGGING_ALT = "TYPEORM_LOGGING",
52
+ LOGGER = "DB_LOGGER",
53
+ LOGGER_ALT = "TYPEORM_LOGGER",
54
+ MAX_QUERY_EXECUTION_TIME = "DB_MAX_QUERY_EXECUTION_TIME",
55
+ MAX_QUERY_EXECUTION_TIME_ALT = "TYPEORM_MAX_QUERY_EXECUTION_TIME",
56
+ DEBUG = "DB_DEBUG",
57
+ DEBUG_ALT = "TYPEORM_DEBUG",
58
+ UUID_EXTENSION = "DB_UUID_EXTENSION",
59
+ UUID_EXTENSION_ALT = "TYPEORM_UUID_EXTENSION",
60
+ CACHE = "DB_CACHE",
61
+ CACHE_ALT = "TYPEORM_CACHE",
62
+ CACHE_ALWAYS_ENABLED = "DB_CACHE_ALWAYS_ENABLED",
63
+ CACHE_ALWAYS_ENABLED_ALT = "TYPEORM_CACHE_ALWAYS_ENABLED",
64
+ CACHE_OPTIONS = "DB_CACHE_OPTIONS",
65
+ CACHE_OPTIONS_ALT = "TYPEORM_CACHE_OPTIONS",
66
+ CACHE_DURATION = "DB_CACHE_DURATION",
67
+ CACHE_DURATION_ALT = "TYPEORM_CACHE_DURATION"
68
+ }
@@ -0,0 +1,3 @@
1
+ export * from './constants';
2
+ export * from './module';
3
+ export * from './type';
@@ -0,0 +1,4 @@
1
+ import type { Environment } from './type';
2
+ export declare function useEnv(): Environment;
3
+ export declare function useEnv<K extends keyof Environment>(key: K): Environment[K];
4
+ export declare function resetEnv(): void;
@@ -0,0 +1,36 @@
1
+ import type { DatabaseType } from 'typeorm/driver/types/DatabaseType';
2
+ import type { DataSourceCacheOption } from '../data-source';
3
+ import type { EnvironmentName } from './constants';
4
+ export interface Environment {
5
+ env: `${EnvironmentName}`;
6
+ seeds: string[];
7
+ factories: string[];
8
+ type?: DatabaseType;
9
+ url?: string;
10
+ host?: string;
11
+ port?: number;
12
+ username?: string;
13
+ password?: string;
14
+ database?: string;
15
+ sid?: string;
16
+ schema?: string;
17
+ /**
18
+ * dropSchema
19
+ */
20
+ schemaDrop?: boolean;
21
+ extra?: any;
22
+ synchronize?: boolean;
23
+ migrations: string[];
24
+ migrationsRun?: boolean;
25
+ migrationsTableName?: string;
26
+ entities: string[];
27
+ entityPrefix?: string;
28
+ metadataTableName?: string;
29
+ subscribers: string[];
30
+ logging: string[] | boolean | string;
31
+ logger?: string;
32
+ maxQueryExecutionTime?: number;
33
+ debug?: string;
34
+ cache?: DataSourceCacheOption;
35
+ uuidExtension?: string;
36
+ }
@@ -0,0 +1,3 @@
1
+ import type { DataSourceCacheOption } from '../data-source';
2
+ export declare function transformLogging(input?: string): boolean | string | string[];
3
+ export declare function transformCache(input?: string): DataSourceCacheOption | undefined;
@@ -0,0 +1,2 @@
1
+ export declare class TypeormExtensionError extends Error {
2
+ }
@@ -0,0 +1,6 @@
1
+ import { TypeormExtensionError } from './base';
2
+ export declare class DriverError extends TypeormExtensionError {
3
+ constructor(message?: string);
4
+ static undeterminable(): DriverError;
5
+ static notSupported(driverName: string): DriverError;
6
+ }
@@ -0,0 +1,3 @@
1
+ export * from './base';
2
+ export * from './driver';
3
+ export * from './options';
@@ -0,0 +1,7 @@
1
+ import { TypeormExtensionError } from './base';
2
+ export declare class OptionsError extends TypeormExtensionError {
3
+ constructor(message?: string);
4
+ static undeterminable(): OptionsError;
5
+ static notFound(): OptionsError;
6
+ static databaseNotDefined(): OptionsError;
7
+ }
@@ -0,0 +1,20 @@
1
+ import { TypeormExtensionError } from '../../errors';
2
+ type TypeormRelationLookupErrorOptions = {
3
+ message: string;
4
+ relation: string;
5
+ columns: string[];
6
+ };
7
+ export declare class EntityRelationLookupError extends TypeormExtensionError {
8
+ /**
9
+ * The property name of the relation.
10
+ */
11
+ relation: string;
12
+ /**
13
+ * The property names of the join columns.
14
+ */
15
+ columns: string[];
16
+ constructor(options: TypeormRelationLookupErrorOptions);
17
+ static notReferenced(relation: string, columns: string[]): EntityRelationLookupError;
18
+ static notFound(relation: string, columns: string[]): EntityRelationLookupError;
19
+ }
20
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './error';
2
+ export * from './property-names';
3
+ export * from './metadata';
4
+ export * from './join-columns';
5
+ export * from './uniqueness';