@codemastersolutions/db-utility 0.0.1
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/LICENSE +21 -0
- package/LICENSE.es +21 -0
- package/LICENSE.pt-BR +21 -0
- package/README.es.md +155 -0
- package/README.md +155 -0
- package/README.pt-BR.md +155 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +314 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/AppConfig.d.ts +19 -0
- package/dist/config/AppConfig.d.ts.map +1 -0
- package/dist/config/AppConfig.js +142 -0
- package/dist/config/AppConfig.js.map +1 -0
- package/dist/config/ConfigInitializer.d.ts +10 -0
- package/dist/config/ConfigInitializer.d.ts.map +1 -0
- package/dist/config/ConfigInitializer.js +37 -0
- package/dist/config/ConfigInitializer.js.map +1 -0
- package/dist/config/ConfigLoader.d.ts +7 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +94 -0
- package/dist/config/ConfigLoader.js.map +1 -0
- package/dist/database/ConnectionFactory.d.ts +5 -0
- package/dist/database/ConnectionFactory.d.ts.map +1 -0
- package/dist/database/ConnectionFactory.js +22 -0
- package/dist/database/ConnectionFactory.js.map +1 -0
- package/dist/database/SqlSafety.d.ts +7 -0
- package/dist/database/SqlSafety.d.ts.map +1 -0
- package/dist/database/SqlSafety.js +47 -0
- package/dist/database/SqlSafety.js.map +1 -0
- package/dist/database/connectors/MssqlConnector.d.ts +13 -0
- package/dist/database/connectors/MssqlConnector.d.ts.map +1 -0
- package/dist/database/connectors/MssqlConnector.js +72 -0
- package/dist/database/connectors/MssqlConnector.js.map +1 -0
- package/dist/database/connectors/MysqlConnector.d.ts +12 -0
- package/dist/database/connectors/MysqlConnector.d.ts.map +1 -0
- package/dist/database/connectors/MysqlConnector.js +70 -0
- package/dist/database/connectors/MysqlConnector.js.map +1 -0
- package/dist/database/connectors/PostgresConnector.d.ts +12 -0
- package/dist/database/connectors/PostgresConnector.d.ts.map +1 -0
- package/dist/database/connectors/PostgresConnector.js +65 -0
- package/dist/database/connectors/PostgresConnector.js.map +1 -0
- package/dist/errors/DbUtilityError.d.ts +7 -0
- package/dist/errors/DbUtilityError.d.ts.map +1 -0
- package/dist/errors/DbUtilityError.js +15 -0
- package/dist/errors/DbUtilityError.js.map +1 -0
- package/dist/generators/GeneratorTypes.d.ts +15 -0
- package/dist/generators/GeneratorTypes.d.ts.map +1 -0
- package/dist/generators/GeneratorTypes.js +3 -0
- package/dist/generators/GeneratorTypes.js.map +1 -0
- package/dist/generators/GeneratorWriter.d.ts +6 -0
- package/dist/generators/GeneratorWriter.d.ts.map +1 -0
- package/dist/generators/GeneratorWriter.js +25 -0
- package/dist/generators/GeneratorWriter.js.map +1 -0
- package/dist/generators/MongooseGenerator.d.ts +10 -0
- package/dist/generators/MongooseGenerator.d.ts.map +1 -0
- package/dist/generators/MongooseGenerator.js +75 -0
- package/dist/generators/MongooseGenerator.js.map +1 -0
- package/dist/generators/PrismaGenerator.d.ts +9 -0
- package/dist/generators/PrismaGenerator.d.ts.map +1 -0
- package/dist/generators/PrismaGenerator.js +87 -0
- package/dist/generators/PrismaGenerator.js.map +1 -0
- package/dist/generators/SequelizeGenerator.d.ts +12 -0
- package/dist/generators/SequelizeGenerator.d.ts.map +1 -0
- package/dist/generators/SequelizeGenerator.js +243 -0
- package/dist/generators/SequelizeGenerator.js.map +1 -0
- package/dist/generators/TypeORMGenerator.d.ts +12 -0
- package/dist/generators/TypeORMGenerator.d.ts.map +1 -0
- package/dist/generators/TypeORMGenerator.js +216 -0
- package/dist/generators/TypeORMGenerator.js.map +1 -0
- package/dist/i18n/messages.d.ts +49 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +149 -0
- package/dist/i18n/messages.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection/DataExtractor.d.ts +10 -0
- package/dist/introspection/DataExtractor.d.ts.map +1 -0
- package/dist/introspection/DataExtractor.js +52 -0
- package/dist/introspection/DataExtractor.js.map +1 -0
- package/dist/introspection/IntrospectionLogger.d.ts +7 -0
- package/dist/introspection/IntrospectionLogger.d.ts.map +1 -0
- package/dist/introspection/IntrospectionLogger.js +30 -0
- package/dist/introspection/IntrospectionLogger.js.map +1 -0
- package/dist/introspection/IntrospectionService.d.ts +10 -0
- package/dist/introspection/IntrospectionService.d.ts.map +1 -0
- package/dist/introspection/IntrospectionService.js +37 -0
- package/dist/introspection/IntrospectionService.js.map +1 -0
- package/dist/introspection/Introspector.d.ts +11 -0
- package/dist/introspection/Introspector.d.ts.map +1 -0
- package/dist/introspection/Introspector.js +11 -0
- package/dist/introspection/Introspector.js.map +1 -0
- package/dist/introspection/MssqlIntrospector.d.ts +11 -0
- package/dist/introspection/MssqlIntrospector.d.ts.map +1 -0
- package/dist/introspection/MssqlIntrospector.js +193 -0
- package/dist/introspection/MssqlIntrospector.js.map +1 -0
- package/dist/introspection/MysqlIntrospector.d.ts +10 -0
- package/dist/introspection/MysqlIntrospector.d.ts.map +1 -0
- package/dist/introspection/MysqlIntrospector.js +175 -0
- package/dist/introspection/MysqlIntrospector.js.map +1 -0
- package/dist/introspection/PostgresIntrospector.d.ts +11 -0
- package/dist/introspection/PostgresIntrospector.d.ts.map +1 -0
- package/dist/introspection/PostgresIntrospector.js +192 -0
- package/dist/introspection/PostgresIntrospector.js.map +1 -0
- package/dist/testing/ContainerManager.d.ts +7 -0
- package/dist/testing/ContainerManager.d.ts.map +1 -0
- package/dist/testing/ContainerManager.js +68 -0
- package/dist/testing/ContainerManager.js.map +1 -0
- package/dist/testing/MigrationTester.d.ts +18 -0
- package/dist/testing/MigrationTester.d.ts.map +1 -0
- package/dist/testing/MigrationTester.js +399 -0
- package/dist/testing/MigrationTester.js.map +1 -0
- package/dist/testing/runners/MigrationRunner.d.ts +5 -0
- package/dist/testing/runners/MigrationRunner.d.ts.map +1 -0
- package/dist/testing/runners/MigrationRunner.js +3 -0
- package/dist/testing/runners/MigrationRunner.js.map +1 -0
- package/dist/testing/runners/SequelizeRunner.d.ts +8 -0
- package/dist/testing/runners/SequelizeRunner.d.ts.map +1 -0
- package/dist/testing/runners/SequelizeRunner.js +71 -0
- package/dist/testing/runners/SequelizeRunner.js.map +1 -0
- package/dist/testing/runners/TypeORMRunner.d.ts +8 -0
- package/dist/testing/runners/TypeORMRunner.d.ts.map +1 -0
- package/dist/testing/runners/TypeORMRunner.js +91 -0
- package/dist/testing/runners/TypeORMRunner.js.map +1 -0
- package/dist/types/database.d.ts +22 -0
- package/dist/types/database.d.ts.map +1 -0
- package/dist/types/database.js +3 -0
- package/dist/types/database.js.map +1 -0
- package/dist/types/introspection.d.ts +43 -0
- package/dist/types/introspection.d.ts.map +1 -0
- package/dist/types/introspection.js +3 -0
- package/dist/types/introspection.js.map +1 -0
- package/dist/utils/PackageManager.d.ts +13 -0
- package/dist/utils/PackageManager.d.ts.map +1 -0
- package/dist/utils/PackageManager.js +114 -0
- package/dist/utils/PackageManager.js.map +1 -0
- package/dist/utils/topologicalSort.d.ts +3 -0
- package/dist/utils/topologicalSort.d.ts.map +1 -0
- package/dist/utils/topologicalSort.js +37 -0
- package/dist/utils/topologicalSort.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeORMGenerator = void 0;
|
|
4
|
+
const topologicalSort_1 = require("../utils/topologicalSort");
|
|
5
|
+
class TypeORMGenerator {
|
|
6
|
+
async generate(schema) {
|
|
7
|
+
const files = [];
|
|
8
|
+
for (const table of schema.tables) {
|
|
9
|
+
const className = this.formatModelName(table.name);
|
|
10
|
+
const content = `import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
|
|
11
|
+
|
|
12
|
+
@Entity('${table.name}')
|
|
13
|
+
${table.indexes
|
|
14
|
+
.filter((idx) => !idx.isPrimary)
|
|
15
|
+
.map((idx) => `@Index('${idx.name}', ['${idx.columns.join("', '")}']${idx.isUnique ? ', { unique: true }' : ''})`)
|
|
16
|
+
.join('\n')}
|
|
17
|
+
export class ${className} {
|
|
18
|
+
${table.columns.map((c) => this.generateColumnDefinition(c)).join('\n')}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
files.push({
|
|
22
|
+
fileName: `${className}.ts`,
|
|
23
|
+
content,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return files;
|
|
27
|
+
}
|
|
28
|
+
async generateMigrations(schema, data) {
|
|
29
|
+
const sortedTables = (0, topologicalSort_1.topologicalSort)(schema);
|
|
30
|
+
const files = [];
|
|
31
|
+
const timestamp = Date.now();
|
|
32
|
+
let counter = 0;
|
|
33
|
+
for (const table of sortedTables) {
|
|
34
|
+
counter++;
|
|
35
|
+
const migrationName = `Create${this.formatModelName(table.name)}${timestamp + counter}`;
|
|
36
|
+
const fileName = `${timestamp + counter}-${migrationName}.ts`;
|
|
37
|
+
const pkIndex = table.indexes.find((idx) => idx.isPrimary);
|
|
38
|
+
const pkName = pkIndex ? pkIndex.name : undefined;
|
|
39
|
+
const content = `import { MigrationInterface, QueryRunner, Table, TableIndex, TableForeignKey } from 'typeorm';
|
|
40
|
+
|
|
41
|
+
export class ${migrationName} implements MigrationInterface {
|
|
42
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
43
|
+
await queryRunner.createTable(new Table({
|
|
44
|
+
name: '${table.name}',
|
|
45
|
+
columns: [
|
|
46
|
+
${table.columns.map((c) => this.generateMigrationColumn(c)).join(',\n')}
|
|
47
|
+
],
|
|
48
|
+
foreignKeys: [
|
|
49
|
+
${table.foreignKeys
|
|
50
|
+
.map((fk) => ` {
|
|
51
|
+
name: '${fk.name}',
|
|
52
|
+
columnNames: ['${fk.columns.join("', '")}'],
|
|
53
|
+
referencedTableName: '${fk.referencedTable}',
|
|
54
|
+
referencedColumnNames: ['${fk.referencedColumns.join("', '")}'],
|
|
55
|
+
onDelete: '${fk.deleteRule || 'NO ACTION'}',
|
|
56
|
+
onUpdate: '${fk.updateRule || 'NO ACTION'}',
|
|
57
|
+
}`)
|
|
58
|
+
.join(',\n')}
|
|
59
|
+
],
|
|
60
|
+
}), true);
|
|
61
|
+
|
|
62
|
+
${table.indexes
|
|
63
|
+
.filter((idx) => !idx.isPrimary)
|
|
64
|
+
.map((idx) => ` await queryRunner.createIndex('${table.name}', new TableIndex({
|
|
65
|
+
name: '${idx.name}',
|
|
66
|
+
columnNames: ['${idx.columns.join("', '")}'],
|
|
67
|
+
isUnique: ${idx.isUnique}
|
|
68
|
+
}));`)
|
|
69
|
+
.join('\n')}
|
|
70
|
+
${pkName && pkName !== 'PRIMARY'
|
|
71
|
+
? `
|
|
72
|
+
// Attempt to rename PK if needed, though TypeORM creates it with table creation.
|
|
73
|
+
// Explicit named PK support in TypeORM migrations via createTable is limited in older versions.
|
|
74
|
+
// If you need specific PK name, you might need to drop and recreate or use raw SQL.
|
|
75
|
+
`
|
|
76
|
+
: ''}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
80
|
+
await queryRunner.dropTable('${table.name}');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
files.push({
|
|
85
|
+
fileName,
|
|
86
|
+
content,
|
|
87
|
+
});
|
|
88
|
+
if (data) {
|
|
89
|
+
const tableData = data.find((d) => d.tableName.toLowerCase() === table.name.toLowerCase());
|
|
90
|
+
if (tableData) {
|
|
91
|
+
counter++;
|
|
92
|
+
const seedMigrationName = `Seed${this.formatModelName(tableData.tableName)}${timestamp + counter}`;
|
|
93
|
+
const seedFileName = `${timestamp + counter}-${seedMigrationName}.ts`;
|
|
94
|
+
const rowsContent = JSON.stringify(tableData.rows, null, 2);
|
|
95
|
+
const seedContent = `import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
96
|
+
|
|
97
|
+
export class ${seedMigrationName} implements MigrationInterface {
|
|
98
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
99
|
+
if (${tableData.rows.length} > 0) {
|
|
100
|
+
await queryRunner.manager.createQueryBuilder()
|
|
101
|
+
.insert()
|
|
102
|
+
.into('${tableData.tableName}')
|
|
103
|
+
.values(${rowsContent})
|
|
104
|
+
.execute();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
109
|
+
await queryRunner.query(\`DELETE FROM "${tableData.tableName}"\`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
files.push({
|
|
114
|
+
fileName: seedFileName,
|
|
115
|
+
content: seedContent,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return files;
|
|
121
|
+
}
|
|
122
|
+
async generateDataMigrations(data) {
|
|
123
|
+
const files = [];
|
|
124
|
+
const timestamp = Date.now() + 10000;
|
|
125
|
+
let counter = 0;
|
|
126
|
+
for (const tableData of data) {
|
|
127
|
+
counter++;
|
|
128
|
+
const migrationName = `Seed${this.formatModelName(tableData.tableName)}${timestamp + counter}`;
|
|
129
|
+
const fileName = `${timestamp + counter}-${migrationName}.ts`;
|
|
130
|
+
const rowsContent = JSON.stringify(tableData.rows, null, 2);
|
|
131
|
+
const content = `import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
132
|
+
|
|
133
|
+
export class ${migrationName} implements MigrationInterface {
|
|
134
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
135
|
+
if (${tableData.rows.length} > 0) {
|
|
136
|
+
await queryRunner.manager.createQueryBuilder()
|
|
137
|
+
.insert()
|
|
138
|
+
.into('${tableData.tableName}')
|
|
139
|
+
.values(${rowsContent})
|
|
140
|
+
.execute();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
145
|
+
await queryRunner.query(\`DELETE FROM "${tableData.tableName}"\`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
files.push({
|
|
150
|
+
fileName,
|
|
151
|
+
content,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return files;
|
|
155
|
+
}
|
|
156
|
+
formatModelName(name) {
|
|
157
|
+
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
158
|
+
}
|
|
159
|
+
mapType(dataType) {
|
|
160
|
+
const lower = dataType.toLowerCase();
|
|
161
|
+
if (lower.includes('int'))
|
|
162
|
+
return 'int';
|
|
163
|
+
if (lower.includes('char') || lower.includes('text'))
|
|
164
|
+
return 'varchar';
|
|
165
|
+
if (lower.includes('bool'))
|
|
166
|
+
return 'boolean';
|
|
167
|
+
if (lower.includes('date') || lower.includes('time'))
|
|
168
|
+
return 'timestamp';
|
|
169
|
+
if (lower.includes('float') || lower.includes('double'))
|
|
170
|
+
return 'float';
|
|
171
|
+
return 'varchar';
|
|
172
|
+
}
|
|
173
|
+
generateColumnDefinition(col) {
|
|
174
|
+
const type = this.mapType(col.dataType);
|
|
175
|
+
const decorator = col.isPrimaryKey ? '@PrimaryColumn' : '@Column';
|
|
176
|
+
const options = [];
|
|
177
|
+
if (type)
|
|
178
|
+
options.push(`type: '${type}'`);
|
|
179
|
+
if (col.isNullable)
|
|
180
|
+
options.push('nullable: true');
|
|
181
|
+
if (col.isUnique)
|
|
182
|
+
options.push('unique: true');
|
|
183
|
+
if (col.hasDefault && col.defaultValue) {
|
|
184
|
+
options.push(`default: () => "${col.defaultValue.replace(/"/g, '\\"')}"`);
|
|
185
|
+
}
|
|
186
|
+
let tsType = 'string';
|
|
187
|
+
if (type === 'int' || type === 'float')
|
|
188
|
+
tsType = 'number';
|
|
189
|
+
if (type === 'boolean')
|
|
190
|
+
tsType = 'boolean';
|
|
191
|
+
if (type === 'timestamp')
|
|
192
|
+
tsType = 'Date';
|
|
193
|
+
return ` ${decorator}({ ${options.join(', ')} })
|
|
194
|
+
${col.name}${col.isNullable ? '?' : ''}: ${tsType};`;
|
|
195
|
+
}
|
|
196
|
+
generateMigrationColumn(col) {
|
|
197
|
+
const type = this.mapType(col.dataType);
|
|
198
|
+
const parts = [` name: '${col.name}'`, ` type: '${type}'`];
|
|
199
|
+
if (col.isPrimaryKey)
|
|
200
|
+
parts.push(' isPrimary: true');
|
|
201
|
+
if (col.isAutoIncrement)
|
|
202
|
+
parts.push(' isGenerated: true', " generationStrategy: 'increment'");
|
|
203
|
+
if (col.isNullable)
|
|
204
|
+
parts.push(' isNullable: true');
|
|
205
|
+
if (col.isUnique)
|
|
206
|
+
parts.push(' isUnique: true');
|
|
207
|
+
if (col.hasDefault && col.defaultValue) {
|
|
208
|
+
parts.push(` default: "${col.defaultValue.replace(/"/g, '\\"')}"`);
|
|
209
|
+
}
|
|
210
|
+
return ` {
|
|
211
|
+
${parts.join(',\n')}
|
|
212
|
+
}`;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.TypeORMGenerator = TypeORMGenerator;
|
|
216
|
+
//# sourceMappingURL=TypeORMGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeORMGenerator.js","sourceRoot":"","sources":["../../src/generators/TypeORMGenerator.ts"],"names":[],"mappings":";;;AACA,8DAA2D;AAQ3D,MAAa,gBAAgB;IAG3B,KAAK,CAAC,QAAQ,CAAC,MAAsB;QACnC,MAAM,KAAK,GAAoB,EAAE,CAAC;QAElC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,MAAM,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG;;WAEX,KAAK,CAAC,IAAI;EACnB,KAAK,CAAC,OAAO;iBACZ,MAAM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C,MAAM,KAAK,GAAG,CAAC,gBAAgB,GAAG,CAAC,IAAI,GAAG,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC;QAErE,IAAI,GAAG,CAAC,YAAY;YAAE,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1D,IAAI,GAAG,CAAC,eAAe;YACrB,KAAK,CAAC,IAAI,CAAC,yBAAyB,EAAE,uCAAuC,CAAC,CAAC;QACjF,IAAI,GAAG,CAAC,UAAU;YAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACzD,IAAI,GAAG,CAAC,QAAQ;YAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACrD,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO;EACT,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;QACX,CAAC;IACP,CAAC;CACF;AA/OD,4CA+OC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { AppLanguage } from '../config/AppConfig';
|
|
2
|
+
export interface CliMessages {
|
|
3
|
+
appDescription: string;
|
|
4
|
+
connectDescription: string;
|
|
5
|
+
introspectDescription: string;
|
|
6
|
+
exportDescription: string;
|
|
7
|
+
migrateDescription: string;
|
|
8
|
+
initOptionDescription: string;
|
|
9
|
+
forceOptionDescription: string;
|
|
10
|
+
optionConfigPath: string;
|
|
11
|
+
optionType: string;
|
|
12
|
+
optionHost: string;
|
|
13
|
+
optionPort: string;
|
|
14
|
+
optionUsername: string;
|
|
15
|
+
optionPassword: string;
|
|
16
|
+
optionDatabase: string;
|
|
17
|
+
optionSsl: string;
|
|
18
|
+
loadingConfig: string;
|
|
19
|
+
connecting: (dbType: string) => string;
|
|
20
|
+
connectSuccess: string;
|
|
21
|
+
connectionClosed: string;
|
|
22
|
+
connectError: string;
|
|
23
|
+
genericError: string;
|
|
24
|
+
introspectConnecting: (database?: string) => string;
|
|
25
|
+
introspectDone: (tables: number) => string;
|
|
26
|
+
introspectSavedAt: (dir: string) => string;
|
|
27
|
+
exportDevMessage: string;
|
|
28
|
+
migrateDevMessage: string;
|
|
29
|
+
initAlreadyExists: (path: string) => string;
|
|
30
|
+
initCreated: (path: string) => string;
|
|
31
|
+
initRecreated: (path: string) => string;
|
|
32
|
+
securityError: string;
|
|
33
|
+
securitySqlUnsafeOperation: string;
|
|
34
|
+
securitySqlUnsafeDataSelect: string;
|
|
35
|
+
introspectionDbTypeRequired: string;
|
|
36
|
+
introspectionDbTypeUnsupported: string;
|
|
37
|
+
appConfigFileNotFound: (path: string) => string;
|
|
38
|
+
appConfigFileFormatUnsupported: (ext: string) => string;
|
|
39
|
+
configFileNotFound: (path: string) => string;
|
|
40
|
+
configFileFormatUnsupported: (ext: string) => string;
|
|
41
|
+
configDbTypeOrConnectionStringRequired: string;
|
|
42
|
+
configDbTypeRequired: string;
|
|
43
|
+
connectionFailed: string;
|
|
44
|
+
}
|
|
45
|
+
export interface Messages {
|
|
46
|
+
cli: CliMessages;
|
|
47
|
+
}
|
|
48
|
+
export declare const getMessages: (language: AppLanguage) => Messages;
|
|
49
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/i18n/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,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;IACxD,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7C,2BAA2B,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACrD,sCAAsC,EAAE,MAAM,CAAC;IAC/C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,WAAW,CAAC;CAClB;AAyKD,eAAO,MAAM,WAAW,GAAI,UAAU,WAAW,KAAG,QAUnD,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMessages = void 0;
|
|
4
|
+
const ptBrMessages = {
|
|
5
|
+
cli: {
|
|
6
|
+
appDescription: 'O mais poderoso utilitário de banco de dados.',
|
|
7
|
+
connectDescription: 'Conectar ao banco de dados',
|
|
8
|
+
introspectDescription: 'Realizar introspecção no banco de dados',
|
|
9
|
+
exportDescription: 'Exportar models (Sequelize, TypeORM, Prisma)',
|
|
10
|
+
migrateDescription: 'Gerar migrations a partir do banco de dados',
|
|
11
|
+
initOptionDescription: 'Inicializar arquivo de configuração dbutility.config.json',
|
|
12
|
+
forceOptionDescription: 'Forçar recriação do arquivo de configuração',
|
|
13
|
+
optionConfigPath: 'Caminho para o arquivo de configuração',
|
|
14
|
+
optionType: 'Tipo de banco de dados (mysql, postgres, mssql)',
|
|
15
|
+
optionHost: 'Host do banco de dados',
|
|
16
|
+
optionPort: 'Porta do banco de dados',
|
|
17
|
+
optionUsername: 'Usuário do banco de dados',
|
|
18
|
+
optionPassword: 'Senha do banco de dados',
|
|
19
|
+
optionDatabase: 'Nome do banco de dados',
|
|
20
|
+
optionSsl: 'Habilitar SSL',
|
|
21
|
+
loadingConfig: 'Carregando configuração...',
|
|
22
|
+
connecting: (dbType) => `Tentando conectar ao banco de dados ${dbType}...`,
|
|
23
|
+
connectSuccess: '✅ Conexão estabelecida com sucesso!',
|
|
24
|
+
connectionClosed: 'Conexão encerrada.',
|
|
25
|
+
connectError: '❌ Erro ao conectar:',
|
|
26
|
+
genericError: '❌ Erro:',
|
|
27
|
+
introspectConnecting: (database) => `Conectando para introspecção em ${database || '(sem nome)'}...`,
|
|
28
|
+
introspectDone: (tables) => `Introspecção concluída. ${tables} tabelas encontradas.`,
|
|
29
|
+
introspectSavedAt: (dir) => `Arquivos de introspecção salvos em: ${dir}`,
|
|
30
|
+
exportDevMessage: 'Funcionalidade de exportação em desenvolvimento.',
|
|
31
|
+
migrateDevMessage: 'Funcionalidade de migration em desenvolvimento.',
|
|
32
|
+
initAlreadyExists: (path) => `Arquivo de configuração já existe em ${path}. Use --init -f para recriar.`,
|
|
33
|
+
initCreated: (path) => `Arquivo de configuração criado com valores padrão em ${path}.`,
|
|
34
|
+
initRecreated: (path) => `Arquivo de configuração recriado com valores padrão em ${path}.`,
|
|
35
|
+
securityError: '⚠️ Operação bloqueada por política de segurança:',
|
|
36
|
+
securitySqlUnsafeOperation: 'Operação SQL não permitida. A DbUtility só executa consultas de metadados.',
|
|
37
|
+
securitySqlUnsafeDataSelect: 'Leitura de dados de tabelas de negócio não é permitida pela DbUtility.',
|
|
38
|
+
introspectionDbTypeRequired: 'Tipo de banco de dados é obrigatório para executar a introspecção.',
|
|
39
|
+
introspectionDbTypeUnsupported: 'Tipo de banco de dados não suportado para introspecção com a DbUtility.',
|
|
40
|
+
appConfigFileNotFound: (path) => `Arquivo de configuração da aplicação não encontrado: ${path}`,
|
|
41
|
+
appConfigFileFormatUnsupported: (ext) => `Formato de arquivo de configuração da aplicação não suportado: ${ext}`,
|
|
42
|
+
configFileNotFound: (path) => `Arquivo de configuração não encontrado: ${path}`,
|
|
43
|
+
configFileFormatUnsupported: (ext) => `Formato de arquivo não suportado: ${ext}`,
|
|
44
|
+
configDbTypeOrConnectionStringRequired: 'Tipo de banco de dados (type) ou connectionString é obrigatório.',
|
|
45
|
+
configDbTypeRequired: 'Configuração de banco de dados não encontrada. Defina as variáveis de ambiente ou crie um arquivo de configuração.',
|
|
46
|
+
connectionFailed: 'Conexão não estabelecida',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const enMessages = {
|
|
50
|
+
cli: {
|
|
51
|
+
appDescription: 'The most powerful database utility.',
|
|
52
|
+
connectDescription: 'Connect to the database',
|
|
53
|
+
introspectDescription: 'Run database introspection',
|
|
54
|
+
exportDescription: 'Export models (Sequelize, TypeORM, Prisma)',
|
|
55
|
+
migrateDescription: 'Generate migrations from the database',
|
|
56
|
+
initOptionDescription: 'Initialize dbutility.config.json configuration file',
|
|
57
|
+
forceOptionDescription: 'Force recreation of the configuration file',
|
|
58
|
+
optionConfigPath: 'Path to the configuration file',
|
|
59
|
+
optionType: 'Database type (mysql, postgres, mssql)',
|
|
60
|
+
optionHost: 'Database host',
|
|
61
|
+
optionPort: 'Database port',
|
|
62
|
+
optionUsername: 'Database user',
|
|
63
|
+
optionPassword: 'Database password',
|
|
64
|
+
optionDatabase: 'Database name',
|
|
65
|
+
optionSsl: 'Enable SSL',
|
|
66
|
+
loadingConfig: 'Loading configuration...',
|
|
67
|
+
connecting: (dbType) => `Trying to connect to ${dbType} database...`,
|
|
68
|
+
connectSuccess: '✅ Connection established successfully!',
|
|
69
|
+
connectionClosed: 'Connection closed.',
|
|
70
|
+
connectError: '❌ Error while connecting:',
|
|
71
|
+
genericError: '❌ Error:',
|
|
72
|
+
introspectConnecting: (database) => `Connecting for introspection on ${database || '(no name)'}...`,
|
|
73
|
+
introspectDone: (tables) => `Introspection finished. ${tables} tables found.`,
|
|
74
|
+
introspectSavedAt: (dir) => `Introspection files saved at: ${dir}`,
|
|
75
|
+
exportDevMessage: 'Export feature under development.',
|
|
76
|
+
migrateDevMessage: 'Migration feature under development.',
|
|
77
|
+
initAlreadyExists: (path) => `Configuration file already exists at ${path}. Use --init -f to recreate it.`,
|
|
78
|
+
initCreated: (path) => `Configuration file created with default values at ${path}.`,
|
|
79
|
+
initRecreated: (path) => `Configuration file recreated with default values at ${path}.`,
|
|
80
|
+
securityError: '⚠️ Operation blocked by security policy:',
|
|
81
|
+
securitySqlUnsafeOperation: 'SQL operation not allowed. DbUtility only executes metadata queries.',
|
|
82
|
+
securitySqlUnsafeDataSelect: 'Reading business table data is not allowed by DbUtility.',
|
|
83
|
+
introspectionDbTypeRequired: 'Database type is required to run introspection.',
|
|
84
|
+
introspectionDbTypeUnsupported: 'Database type is not supported for introspection with DbUtility.',
|
|
85
|
+
appConfigFileNotFound: (path) => `Application configuration file not found: ${path}`,
|
|
86
|
+
appConfigFileFormatUnsupported: (ext) => `Application configuration file format not supported: ${ext}`,
|
|
87
|
+
configFileNotFound: (path) => `Configuration file not found: ${path}`,
|
|
88
|
+
configFileFormatUnsupported: (ext) => `File format not supported: ${ext}`,
|
|
89
|
+
configDbTypeOrConnectionStringRequired: 'Database type (type) or connectionString is required.',
|
|
90
|
+
configDbTypeRequired: 'Database configuration not found. Set environment variables or create a configuration file.',
|
|
91
|
+
connectionFailed: 'Connection not established',
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const esMessages = {
|
|
95
|
+
cli: {
|
|
96
|
+
appDescription: 'La utilidad de base de datos más poderosa.',
|
|
97
|
+
connectDescription: 'Conectar a la base de datos',
|
|
98
|
+
introspectDescription: 'Realizar introspección en la base de datos',
|
|
99
|
+
exportDescription: 'Exportar modelos (Sequelize, TypeORM, Prisma)',
|
|
100
|
+
migrateDescription: 'Generar migraciones desde la base de datos',
|
|
101
|
+
initOptionDescription: 'Inicializar el archivo de configuración dbutility.config.json',
|
|
102
|
+
forceOptionDescription: 'Forzar la recreación del archivo de configuración',
|
|
103
|
+
optionConfigPath: 'Ruta al archivo de configuración',
|
|
104
|
+
optionType: 'Tipo de base de datos (mysql, postgres, mssql)',
|
|
105
|
+
optionHost: 'Host de la base de datos',
|
|
106
|
+
optionPort: 'Puerto de la base de datos',
|
|
107
|
+
optionUsername: 'Usuario de la base de datos',
|
|
108
|
+
optionPassword: 'Contraseña de la base de datos',
|
|
109
|
+
optionDatabase: 'Nombre de la base de datos',
|
|
110
|
+
optionSsl: 'Habilitar SSL',
|
|
111
|
+
loadingConfig: 'Cargando configuración...',
|
|
112
|
+
connecting: (dbType) => `Intentando conectar a la base de datos ${dbType}...`,
|
|
113
|
+
connectSuccess: '✅ Conexión establecida con éxito.',
|
|
114
|
+
connectionClosed: 'Conexión cerrada.',
|
|
115
|
+
connectError: '❌ Error al conectar:',
|
|
116
|
+
genericError: '❌ Error:',
|
|
117
|
+
introspectConnecting: (database) => `Conectando para introspección en ${database || '(sin nombre)'}...`,
|
|
118
|
+
introspectDone: (tables) => `Introspección finalizada. ${tables} tablas encontradas.`,
|
|
119
|
+
introspectSavedAt: (dir) => `Archivos de introspección guardados en: ${dir}`,
|
|
120
|
+
exportDevMessage: 'Funcionalidad de exportación en desarrollo.',
|
|
121
|
+
migrateDevMessage: 'Funcionalidad de migraciones en desarrollo.',
|
|
122
|
+
initAlreadyExists: (path) => `El archivo de configuración ya existe en ${path}. Usa --init -f para recrearlo.`,
|
|
123
|
+
initCreated: (path) => `Archivo de configuración creado con valores predeterminados en ${path}.`,
|
|
124
|
+
initRecreated: (path) => `Archivo de configuración recreado con valores predeterminados en ${path}.`,
|
|
125
|
+
securityError: '⚠️ Operación bloqueada por política de seguridad:',
|
|
126
|
+
securitySqlUnsafeOperation: 'Operación SQL no permitida. DbUtility solo ejecuta consultas de metadatos.',
|
|
127
|
+
securitySqlUnsafeDataSelect: 'No se permite la lectura de datos de tablas de negocio en DbUtility.',
|
|
128
|
+
introspectionDbTypeRequired: 'El tipo de base de datos es obligatorio para ejecutar la introspección.',
|
|
129
|
+
introspectionDbTypeUnsupported: 'Tipo de base de datos no soportado para introspección con DbUtility.',
|
|
130
|
+
appConfigFileNotFound: (path) => `Archivo de configuración de la aplicación no encontrado: ${path}`,
|
|
131
|
+
appConfigFileFormatUnsupported: (ext) => `Formato de archivo de configuración de la aplicación no soportado: ${ext}`,
|
|
132
|
+
configFileNotFound: (path) => `Archivo de configuración no encontrado: ${path}`,
|
|
133
|
+
configFileFormatUnsupported: (ext) => `Formato de archivo no soportado: ${ext}`,
|
|
134
|
+
configDbTypeOrConnectionStringRequired: 'El tipo de base de datos (type) o connectionString es obligatorio.',
|
|
135
|
+
configDbTypeRequired: 'Configuración de base de datos no encontrada. Defina las variables de entorno o cree un archivo de configuración.',
|
|
136
|
+
connectionFailed: 'Conexión no establecida',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
const getMessages = (language) => {
|
|
140
|
+
if (language === 'en') {
|
|
141
|
+
return enMessages;
|
|
142
|
+
}
|
|
143
|
+
if (language === 'es') {
|
|
144
|
+
return esMessages;
|
|
145
|
+
}
|
|
146
|
+
return ptBrMessages;
|
|
147
|
+
};
|
|
148
|
+
exports.getMessages = getMessages;
|
|
149
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/i18n/messages.ts"],"names":[],"mappings":";;;AAkDA,MAAM,YAAY,GAAa;IAC7B,GAAG,EAAE;QACH,cAAc,EAAE,+CAA+C;QAC/D,kBAAkB,EAAE,4BAA4B;QAChD,qBAAqB,EAAE,yCAAyC;QAChE,iBAAiB,EAAE,8CAA8C;QACjE,kBAAkB,EAAE,6CAA6C;QACjE,qBAAqB,EAAE,2DAA2D;QAClF,sBAAsB,EAAE,6CAA6C;QACrE,gBAAgB,EAAE,wCAAwC;QAC1D,UAAU,EAAE,iDAAiD;QAC7D,UAAU,EAAE,wBAAwB;QACpC,UAAU,EAAE,yBAAyB;QACrC,cAAc,EAAE,2BAA2B;QAC3C,cAAc,EAAE,yBAAyB;QACzC,cAAc,EAAE,wBAAwB;QACxC,SAAS,EAAE,eAAe;QAC1B,aAAa,EAAE,4BAA4B;QAC3C,UAAU,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,uCA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ources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,cAEjB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAGO,MAAM,KAAK,GAAG,GAAG,EAAE;IACxB,OAAO,sBAAsB,CAAC;AAChC,CAAC,CAAC;AAFW,QAAA,KAAK,SAEhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDatabaseConnector, DatabaseType } from '../types/database';
|
|
2
|
+
import { DatabaseSchema, TableData } from '../types/introspection';
|
|
3
|
+
export declare class DataExtractor {
|
|
4
|
+
private connector;
|
|
5
|
+
private type;
|
|
6
|
+
constructor(connector: IDatabaseConnector, type: DatabaseType);
|
|
7
|
+
extract(schema: DatabaseSchema, tableNames: string[]): Promise<TableData[]>;
|
|
8
|
+
private quoteIdentifier;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DataExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataExtractor.d.ts","sourceRoot":"","sources":["../../src/introspection/DataExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnE,qBAAa,aAAa;IAEtB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,IAAI;gBADJ,SAAS,EAAE,kBAAkB,EAC7B,IAAI,EAAE,YAAY;IAGtB,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAgCjF,OAAO,CAAC,eAAe;CAYxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataExtractor = void 0;
|
|
4
|
+
class DataExtractor {
|
|
5
|
+
connector;
|
|
6
|
+
type;
|
|
7
|
+
constructor(connector, type) {
|
|
8
|
+
this.connector = connector;
|
|
9
|
+
this.type = type;
|
|
10
|
+
}
|
|
11
|
+
async extract(schema, tableNames) {
|
|
12
|
+
const result = [];
|
|
13
|
+
for (const tableName of tableNames) {
|
|
14
|
+
const targetName = tableName.toLowerCase();
|
|
15
|
+
const table = schema.tables.find((t) => t.name.toLowerCase() === targetName);
|
|
16
|
+
if (!table) {
|
|
17
|
+
console.warn(`Table ${tableName} not found in schema, skipping.`);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const quotedName = this.quoteIdentifier(table.name);
|
|
21
|
+
const sql = `SELECT * FROM ${quotedName}`;
|
|
22
|
+
try {
|
|
23
|
+
const rows = await this.connector.query(sql, [], {
|
|
24
|
+
bypassSafety: true,
|
|
25
|
+
});
|
|
26
|
+
result.push({
|
|
27
|
+
tableName: table.name,
|
|
28
|
+
columns: table.columns,
|
|
29
|
+
rows,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(`Error extracting data from ${table.name}:`, error);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
quoteIdentifier(name) {
|
|
39
|
+
switch (this.type) {
|
|
40
|
+
case 'postgres':
|
|
41
|
+
return `"${name}"`;
|
|
42
|
+
case 'mysql':
|
|
43
|
+
return `\`${name}\``;
|
|
44
|
+
case 'mssql':
|
|
45
|
+
return `[${name}]`;
|
|
46
|
+
default:
|
|
47
|
+
return `"${name}"`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.DataExtractor = DataExtractor;
|
|
52
|
+
//# sourceMappingURL=DataExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataExtractor.js","sourceR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,MAAM,CAAC;IAChB,CAAC;IAEO,eAAe,CAAC,IAAY;QAClC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,UAAU;gBACb,OAAO,IAAI,IAAI,GAAG,CAAC;YACrB,KAAK,OAAO;gBACV,OAAO,KAAK,IAAI,IAAI,CAAC;YACvB,KAAK,OAAO;gBACV,OAAO,IAAI,IAAI,GAAG,CAAC;YACrB;gBACE,OAAO,IAAI,IAAI,GAAG,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AAlDD,sCAkDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppConfig } from '../config/AppConfig';
|
|
2
|
+
import { DatabaseConfig } from '../types/database';
|
|
3
|
+
import { DatabaseSchema } from '../types/introspection';
|
|
4
|
+
export declare class IntrospectionLogger {
|
|
5
|
+
static logSchema(dbConfig: DatabaseConfig, schema: DatabaseSchema, baseDir: string, appConfig?: AppConfig): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=IntrospectionLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntrospectionLogger.d.ts","sourceRoot":"","sources":["../../src/introspection/IntrospectionLogger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,qBAAa,mBAAmB;IAC9B,MAAM,CAAC,SAAS,CACd,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GACpB,MAAM;CA0BV"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntrospectionLogger = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class IntrospectionLogger {
|
|
7
|
+
static logSchema(dbConfig, schema, baseDir, appConfig) {
|
|
8
|
+
const rootDirName = appConfig ? appConfig.introspection.outputDir : 'db-utility-introspect';
|
|
9
|
+
const rootDir = (0, path_1.join)(baseDir, rootDirName);
|
|
10
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
11
|
+
const dirName = `run-${timestamp}`;
|
|
12
|
+
const runDir = (0, path_1.join)(rootDir, dirName);
|
|
13
|
+
(0, fs_1.mkdirSync)(runDir, { recursive: true });
|
|
14
|
+
const schemaPath = (0, path_1.join)(runDir, 'schema.json');
|
|
15
|
+
const metadataPath = (0, path_1.join)(runDir, 'metadata.json');
|
|
16
|
+
const metadata = {
|
|
17
|
+
type: dbConfig.type,
|
|
18
|
+
host: dbConfig.host,
|
|
19
|
+
port: dbConfig.port,
|
|
20
|
+
database: dbConfig.database,
|
|
21
|
+
executedAt: new Date().toISOString(),
|
|
22
|
+
tablesCount: schema.tables.length,
|
|
23
|
+
};
|
|
24
|
+
(0, fs_1.writeFileSync)(schemaPath, JSON.stringify(schema, null, 2), 'utf-8');
|
|
25
|
+
(0, fs_1.writeFileSync)(metadataPath, JSON.stringify(metadata, null, 2), 'utf-8');
|
|
26
|
+
return runDir;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.IntrospectionLogger = IntrospectionLogger;
|
|
30
|
+
//# sourceMappingURL=IntrospectionLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntrospectionLogger.js","sourceRoot":"","sources":["../../src/introspection/IntrospectionLogger.ts"],"names":[],"mappings":";;;AAAA,2BAA8C;AAC9C,+BAA4B;AAK5B,MAAa,mBAAmB;IAC9B,MAAM,CAAC,SAAS,CACd,QAAwB,EACxB,MAAsB,EACtB,OAAe,EACf,SAAqB;QAErB,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,SAA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fig, IDatabaseConnector } from '../types/database';
|
|
2
|
+
import { DatabaseSchema } from '../types/introspection';
|
|
3
|
+
export declare class IntrospectionService {
|
|
4
|
+
private connector;
|
|
5
|
+
private config;
|
|
6
|
+
constructor(connector: IDatabaseConnector, config: DatabaseConfig);
|
|
7
|
+
introspect(): Promise<DatabaseSchema>;
|
|
8
|
+
private createIntrospector;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=IntrospectionService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntrospectionService.d.ts","sourceRoot":"","sources":["../../src/introspection/IntrospectionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAMxD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAAqB;IACtC,OAAO,CAAC,MAAM,CAAiB;gBAEnB,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc;IAS3D,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC;IAM3C,OAAO,CAAC,kBAAkB;CAY3B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntrospectionService = void 0;
|
|
4
|
+
const DbUtilityError_1 = require("../errors/DbUtilityError");
|
|
5
|
+
const MssqlIntrospector_1 = require("./MssqlIntrospector");
|
|
6
|
+
const MysqlIntrospector_1 = require("./MysqlIntrospector");
|
|
7
|
+
const PostgresIntrospector_1 = require("./PostgresIntrospector");
|
|
8
|
+
class IntrospectionService {
|
|
9
|
+
connector;
|
|
10
|
+
config;
|
|
11
|
+
constructor(connector, config) {
|
|
12
|
+
if (!config.type) {
|
|
13
|
+
throw new DbUtilityError_1.DbUtilityError('INTROSPECTION_DB_TYPE_REQUIRED');
|
|
14
|
+
}
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.connector = connector;
|
|
17
|
+
}
|
|
18
|
+
async introspect() {
|
|
19
|
+
const introspector = this.createIntrospector();
|
|
20
|
+
const schema = await introspector.introspectSchema();
|
|
21
|
+
return schema;
|
|
22
|
+
}
|
|
23
|
+
createIntrospector() {
|
|
24
|
+
switch (this.config.type) {
|
|
25
|
+
case 'postgres':
|
|
26
|
+
return new PostgresIntrospector_1.PostgresIntrospector(this.connector);
|
|
27
|
+
case 'mysql':
|
|
28
|
+
return new MysqlIntrospector_1.MysqlIntrospector(this.connector);
|
|
29
|
+
case 'mssql':
|
|
30
|
+
return new MssqlIntrospector_1.MssqlIntrospector(this.connector);
|
|
31
|
+
default:
|
|
32
|
+
throw new DbUtilityError_1.DbUtilityError('INTROSPECTION_DB_TYPE_UNSUPPORTED');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.IntrospectionService = IntrospectionService;
|
|
37
|
+
//# sourceMappingURL=IntrospectionService.js.map
|