@sqlml/ui 0.3.4
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/README.md +36 -0
- package/client/dist/assets/index-CpRgSqWF.js +672 -0
- package/client/dist/assets/index-DMcl7wPy.css +1 -0
- package/client/dist/favicon.svg +17 -0
- package/client/dist/index.html +14 -0
- package/package.json +66 -0
- package/server/dist/app.module.d.ts +2 -0
- package/server/dist/app.module.js +55 -0
- package/server/dist/app.module.js.map +1 -0
- package/server/dist/common/entities/workspace.entity.d.ts +42 -0
- package/server/dist/common/entities/workspace.entity.js +48 -0
- package/server/dist/common/entities/workspace.entity.js.map +1 -0
- package/server/dist/core/core.module.d.ts +2 -0
- package/server/dist/core/core.module.js +31 -0
- package/server/dist/core/core.module.js.map +1 -0
- package/server/dist/core/health.controller.d.ts +7 -0
- package/server/dist/core/health.controller.js +37 -0
- package/server/dist/core/health.controller.js.map +1 -0
- package/server/dist/core/root.controller.d.ts +4 -0
- package/server/dist/core/root.controller.js +95 -0
- package/server/dist/core/root.controller.js.map +1 -0
- package/server/dist/core/sqlml.service.d.ts +80 -0
- package/server/dist/core/sqlml.service.js +237 -0
- package/server/dist/core/sqlml.service.js.map +1 -0
- package/server/dist/main.d.ts +1 -0
- package/server/dist/main.js +45 -0
- package/server/dist/main.js.map +1 -0
- package/server/dist/modules/config/config.controller.d.ts +18 -0
- package/server/dist/modules/config/config.controller.js +76 -0
- package/server/dist/modules/config/config.controller.js.map +1 -0
- package/server/dist/modules/config/config.module.d.ts +2 -0
- package/server/dist/modules/config/config.module.js +27 -0
- package/server/dist/modules/config/config.module.js.map +1 -0
- package/server/dist/modules/config/config.service.d.ts +31 -0
- package/server/dist/modules/config/config.service.js +376 -0
- package/server/dist/modules/config/config.service.js.map +1 -0
- package/server/dist/modules/database/database-connection.entity.d.ts +17 -0
- package/server/dist/modules/database/database-connection.entity.js +78 -0
- package/server/dist/modules/database/database-connection.entity.js.map +1 -0
- package/server/dist/modules/database/database.controller.d.ts +103 -0
- package/server/dist/modules/database/database.controller.js +236 -0
- package/server/dist/modules/database/database.controller.js.map +1 -0
- package/server/dist/modules/database/database.module.d.ts +2 -0
- package/server/dist/modules/database/database.module.js +26 -0
- package/server/dist/modules/database/database.module.js.map +1 -0
- package/server/dist/modules/database/database.service.d.ts +102 -0
- package/server/dist/modules/database/database.service.js +415 -0
- package/server/dist/modules/database/database.service.js.map +1 -0
- package/server/dist/modules/migration/migration-history.entity.d.ts +14 -0
- package/server/dist/modules/migration/migration-history.entity.js +66 -0
- package/server/dist/modules/migration/migration-history.entity.js.map +1 -0
- package/server/dist/modules/migration/migration-template.entity.d.ts +10 -0
- package/server/dist/modules/migration/migration-template.entity.js +52 -0
- package/server/dist/modules/migration/migration-template.entity.js.map +1 -0
- package/server/dist/modules/migration/migration.controller.d.ts +60 -0
- package/server/dist/modules/migration/migration.controller.js +159 -0
- package/server/dist/modules/migration/migration.controller.js.map +1 -0
- package/server/dist/modules/migration/migration.module.d.ts +2 -0
- package/server/dist/modules/migration/migration.module.js +27 -0
- package/server/dist/modules/migration/migration.module.js.map +1 -0
- package/server/dist/modules/migration/migration.service.d.ts +65 -0
- package/server/dist/modules/migration/migration.service.js +195 -0
- package/server/dist/modules/migration/migration.service.js.map +1 -0
- package/server/dist/modules/schema/dbml-diff.util.d.ts +42 -0
- package/server/dist/modules/schema/dbml-diff.util.js +193 -0
- package/server/dist/modules/schema/dbml-diff.util.js.map +1 -0
- package/server/dist/modules/schema/schema-snapshot.entity.d.ts +13 -0
- package/server/dist/modules/schema/schema-snapshot.entity.js +62 -0
- package/server/dist/modules/schema/schema-snapshot.entity.js.map +1 -0
- package/server/dist/modules/schema/schema.controller.d.ts +62 -0
- package/server/dist/modules/schema/schema.controller.js +188 -0
- package/server/dist/modules/schema/schema.controller.js.map +1 -0
- package/server/dist/modules/schema/schema.module.d.ts +2 -0
- package/server/dist/modules/schema/schema.module.js +30 -0
- package/server/dist/modules/schema/schema.module.js.map +1 -0
- package/server/dist/modules/schema/schema.service.d.ts +53 -0
- package/server/dist/modules/schema/schema.service.js +276 -0
- package/server/dist/modules/schema/schema.service.js.map +1 -0
- package/server/dist/modules/system/process-info.entity.d.ts +8 -0
- package/server/dist/modules/system/process-info.entity.js +44 -0
- package/server/dist/modules/system/process-info.entity.js.map +1 -0
- package/server/dist/modules/system/system.controller.d.ts +25 -0
- package/server/dist/modules/system/system.controller.js +64 -0
- package/server/dist/modules/system/system.controller.js.map +1 -0
- package/server/dist/modules/system/system.module.d.ts +2 -0
- package/server/dist/modules/system/system.module.js +26 -0
- package/server/dist/modules/system/system.module.js.map +1 -0
- package/server/dist/modules/system/system.service.d.ts +25 -0
- package/server/dist/modules/system/system.service.js +100 -0
- package/server/dist/modules/system/system.service.js.map +1 -0
- package/server/dist/modules/workspace/workspace.controller.d.ts +35 -0
- package/server/dist/modules/workspace/workspace.controller.js +132 -0
- package/server/dist/modules/workspace/workspace.controller.js.map +1 -0
- package/server/dist/modules/workspace/workspace.dto.d.ts +9 -0
- package/server/dist/modules/workspace/workspace.dto.js +39 -0
- package/server/dist/modules/workspace/workspace.dto.js.map +1 -0
- package/server/dist/modules/workspace/workspace.module.d.ts +2 -0
- package/server/dist/modules/workspace/workspace.module.js +26 -0
- package/server/dist/modules/workspace/workspace.module.js.map +1 -0
- package/server/dist/modules/workspace/workspace.service.d.ts +44 -0
- package/server/dist/modules/workspace/workspace.service.js +93 -0
- package/server/dist/modules/workspace/workspace.service.js.map +1 -0
- package/server/dist/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DatabaseService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const database_connection_entity_1 = require("./database-connection.entity");
|
|
20
|
+
const config_service_1 = require("../config/config.service");
|
|
21
|
+
let DatabaseService = class DatabaseService {
|
|
22
|
+
constructor(connectionRepository, configService) {
|
|
23
|
+
this.connectionRepository = connectionRepository;
|
|
24
|
+
this.configService = configService;
|
|
25
|
+
this.connections = new Map();
|
|
26
|
+
}
|
|
27
|
+
async listConnections(workspaceId) {
|
|
28
|
+
const where = workspaceId ? { workspaceId } : {};
|
|
29
|
+
let results = await this.connectionRepository.find({
|
|
30
|
+
where,
|
|
31
|
+
order: { name: 'ASC' },
|
|
32
|
+
});
|
|
33
|
+
if (results.length === 0 && workspaceId) {
|
|
34
|
+
const autoConn = await this.autoCreateFromConfig(workspaceId);
|
|
35
|
+
if (autoConn) {
|
|
36
|
+
results = [autoConn];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
async autoCreateFromConfig(workspaceId) {
|
|
42
|
+
try {
|
|
43
|
+
const config = await this.configService.getConfig();
|
|
44
|
+
if (!config.database?.host || !config.database?.name)
|
|
45
|
+
return null;
|
|
46
|
+
const connection = this.connectionRepository.create({
|
|
47
|
+
workspaceId,
|
|
48
|
+
name: 'Config Database',
|
|
49
|
+
type: config.database.type || 'postgres',
|
|
50
|
+
host: config.database.host,
|
|
51
|
+
port: config.database.port || 5432,
|
|
52
|
+
databaseName: config.database.name,
|
|
53
|
+
username: config.database.user || 'postgres',
|
|
54
|
+
password: config.database.password || '',
|
|
55
|
+
ssl: config.database.ssl || false,
|
|
56
|
+
isDefault: true,
|
|
57
|
+
});
|
|
58
|
+
return await this.connectionRepository.save(connection);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async getConnection(id) {
|
|
65
|
+
return this.connectionRepository.findOne({ where: { id } });
|
|
66
|
+
}
|
|
67
|
+
async createConnection(data) {
|
|
68
|
+
const connection = this.connectionRepository.create(data);
|
|
69
|
+
return this.connectionRepository.save(connection);
|
|
70
|
+
}
|
|
71
|
+
async updateConnection(id, data) {
|
|
72
|
+
await this.connectionRepository.update(id, data);
|
|
73
|
+
return this.getConnection(id);
|
|
74
|
+
}
|
|
75
|
+
async deleteConnection(id) {
|
|
76
|
+
if (this.connections.has(id)) {
|
|
77
|
+
const ds = this.connections.get(id);
|
|
78
|
+
if (ds?.isInitialized) {
|
|
79
|
+
await ds.destroy();
|
|
80
|
+
}
|
|
81
|
+
this.connections.delete(id);
|
|
82
|
+
}
|
|
83
|
+
await this.connectionRepository.delete(id);
|
|
84
|
+
}
|
|
85
|
+
async setDefault(id, workspaceId) {
|
|
86
|
+
await this.connectionRepository.update({ workspaceId }, { isDefault: false });
|
|
87
|
+
await this.connectionRepository.update(id, { isDefault: true });
|
|
88
|
+
}
|
|
89
|
+
async testConnection(connectionId) {
|
|
90
|
+
const connection = await this.getConnection(connectionId);
|
|
91
|
+
if (!connection) {
|
|
92
|
+
return { success: false, error: 'Connection not found' };
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const ds = await this.createDataSource(connection);
|
|
96
|
+
await ds.initialize();
|
|
97
|
+
await ds.destroy();
|
|
98
|
+
return { success: true };
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return {
|
|
102
|
+
success: false,
|
|
103
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async executeQuery(connectionId, query, schema) {
|
|
108
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
109
|
+
const connection = await this.getConnection(connectionId);
|
|
110
|
+
try {
|
|
111
|
+
if (connection?.type === 'postgres') {
|
|
112
|
+
const searchPath = schema ? `"${schema.replace(/"/g, '""')}", public` : 'public';
|
|
113
|
+
await ds.query(`SET search_path TO ${searchPath}`);
|
|
114
|
+
}
|
|
115
|
+
const result = await ds.query(query);
|
|
116
|
+
const rows = Array.isArray(result) ? result : [];
|
|
117
|
+
const fields = rows.length > 0 ? Object.keys(rows[0]) : [];
|
|
118
|
+
return {
|
|
119
|
+
rows,
|
|
120
|
+
rowCount: rows.length,
|
|
121
|
+
fields,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new common_1.BadRequestException(error instanceof Error ? error.message : 'Query execution failed');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async getSchema(connectionId) {
|
|
129
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
130
|
+
const connection = await this.getConnection(connectionId);
|
|
131
|
+
if (!connection) {
|
|
132
|
+
throw new common_1.BadRequestException('Connection not found');
|
|
133
|
+
}
|
|
134
|
+
if (connection.type === 'postgres') {
|
|
135
|
+
const tables = await ds.query(`
|
|
136
|
+
SELECT table_name
|
|
137
|
+
FROM information_schema.tables
|
|
138
|
+
WHERE table_schema = 'public'
|
|
139
|
+
ORDER BY table_name
|
|
140
|
+
`);
|
|
141
|
+
const result = [];
|
|
142
|
+
for (const table of tables) {
|
|
143
|
+
const columns = await ds.query(`
|
|
144
|
+
SELECT column_name, data_type, is_nullable
|
|
145
|
+
FROM information_schema.columns
|
|
146
|
+
WHERE table_schema = 'public' AND table_name = $1
|
|
147
|
+
ORDER BY ordinal_position
|
|
148
|
+
`, [table.table_name]);
|
|
149
|
+
result.push({
|
|
150
|
+
name: table.table_name,
|
|
151
|
+
columns: columns.map((col) => ({
|
|
152
|
+
name: col.column_name,
|
|
153
|
+
type: col.data_type,
|
|
154
|
+
nullable: col.is_nullable === 'YES',
|
|
155
|
+
})),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return { tables: result };
|
|
159
|
+
}
|
|
160
|
+
if (connection.type === 'mysql') {
|
|
161
|
+
const tables = await ds.query(`
|
|
162
|
+
SELECT table_name
|
|
163
|
+
FROM information_schema.tables
|
|
164
|
+
WHERE table_schema = DATABASE()
|
|
165
|
+
ORDER BY table_name
|
|
166
|
+
`);
|
|
167
|
+
const result = [];
|
|
168
|
+
for (const table of tables) {
|
|
169
|
+
const columns = await ds.query(`
|
|
170
|
+
SELECT column_name, data_type, is_nullable
|
|
171
|
+
FROM information_schema.columns
|
|
172
|
+
WHERE table_schema = DATABASE() AND table_name = ?
|
|
173
|
+
ORDER BY ordinal_position
|
|
174
|
+
`, [table.TABLE_NAME || table.table_name]);
|
|
175
|
+
result.push({
|
|
176
|
+
name: table.TABLE_NAME || table.table_name,
|
|
177
|
+
columns: columns.map((col) => ({
|
|
178
|
+
name: col.COLUMN_NAME || col.column_name,
|
|
179
|
+
type: col.DATA_TYPE || col.data_type,
|
|
180
|
+
nullable: (col.IS_NULLABLE || col.is_nullable) === 'YES',
|
|
181
|
+
})),
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return { tables: result };
|
|
185
|
+
}
|
|
186
|
+
return { tables: [] };
|
|
187
|
+
}
|
|
188
|
+
async getSchemas(connectionId) {
|
|
189
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
190
|
+
const connection = await this.getConnection(connectionId);
|
|
191
|
+
if (!connection)
|
|
192
|
+
throw new common_1.BadRequestException('Connection not found');
|
|
193
|
+
if (connection.type === 'postgres') {
|
|
194
|
+
const schemaRows = await ds.query(`
|
|
195
|
+
SELECT schema_name FROM information_schema.schemata
|
|
196
|
+
WHERE schema_name NOT IN ('pg_catalog', 'information_schema', 'pg_toast')
|
|
197
|
+
ORDER BY schema_name
|
|
198
|
+
`);
|
|
199
|
+
const schemas = [];
|
|
200
|
+
for (const sr of schemaRows) {
|
|
201
|
+
const schemaName = sr.schema_name;
|
|
202
|
+
const tableRows = await ds.query(`
|
|
203
|
+
SELECT t.table_name,
|
|
204
|
+
(SELECT reltuples::bigint FROM pg_class c
|
|
205
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
206
|
+
WHERE c.relname = t.table_name AND n.nspname = t.table_schema) as row_estimate
|
|
207
|
+
FROM information_schema.tables t
|
|
208
|
+
WHERE t.table_schema = $1 AND t.table_type = 'BASE TABLE'
|
|
209
|
+
ORDER BY t.table_name
|
|
210
|
+
`, [schemaName]);
|
|
211
|
+
const tables = [];
|
|
212
|
+
for (const tr of tableRows) {
|
|
213
|
+
const colRows = await ds.query(`
|
|
214
|
+
SELECT c.column_name, c.data_type, c.udt_name, c.is_nullable, c.column_default,
|
|
215
|
+
CASE WHEN pk.column_name IS NOT NULL THEN true ELSE false END as is_primary_key
|
|
216
|
+
FROM information_schema.columns c
|
|
217
|
+
LEFT JOIN (
|
|
218
|
+
SELECT kcu.column_name
|
|
219
|
+
FROM information_schema.table_constraints tc
|
|
220
|
+
JOIN information_schema.key_column_usage kcu
|
|
221
|
+
ON tc.constraint_name = kcu.constraint_name AND tc.table_schema = kcu.table_schema
|
|
222
|
+
WHERE tc.table_schema = $1 AND tc.table_name = $2 AND tc.constraint_type = 'PRIMARY KEY'
|
|
223
|
+
) pk ON pk.column_name = c.column_name
|
|
224
|
+
WHERE c.table_schema = $1 AND c.table_name = $2
|
|
225
|
+
ORDER BY c.ordinal_position
|
|
226
|
+
`, [schemaName, tr.table_name]);
|
|
227
|
+
tables.push({
|
|
228
|
+
name: tr.table_name,
|
|
229
|
+
rowCount: parseInt(tr.row_estimate) || 0,
|
|
230
|
+
columns: colRows.map((col) => ({
|
|
231
|
+
name: col.column_name,
|
|
232
|
+
type: col.udt_name || col.data_type,
|
|
233
|
+
nullable: col.is_nullable === 'YES',
|
|
234
|
+
primaryKey: col.is_primary_key === true || col.is_primary_key === 'true',
|
|
235
|
+
defaultValue: col.column_default || undefined,
|
|
236
|
+
})),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (tables.length > 0) {
|
|
240
|
+
schemas.push({ name: schemaName, tables });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return { schemas };
|
|
244
|
+
}
|
|
245
|
+
if (connection.type === 'mysql' || connection.type === 'mariadb') {
|
|
246
|
+
const tableRows = await ds.query(`
|
|
247
|
+
SELECT table_name, table_rows
|
|
248
|
+
FROM information_schema.tables
|
|
249
|
+
WHERE table_schema = DATABASE() AND table_type = 'BASE TABLE'
|
|
250
|
+
ORDER BY table_name
|
|
251
|
+
`);
|
|
252
|
+
const tables = [];
|
|
253
|
+
for (const tr of tableRows) {
|
|
254
|
+
const tableName = tr.TABLE_NAME || tr.table_name;
|
|
255
|
+
const colRows = await ds.query(`
|
|
256
|
+
SELECT column_name, data_type, is_nullable, column_default, column_key
|
|
257
|
+
FROM information_schema.columns
|
|
258
|
+
WHERE table_schema = DATABASE() AND table_name = ?
|
|
259
|
+
ORDER BY ordinal_position
|
|
260
|
+
`, [tableName]);
|
|
261
|
+
tables.push({
|
|
262
|
+
name: tableName,
|
|
263
|
+
rowCount: parseInt(tr.TABLE_ROWS || tr.table_rows) || 0,
|
|
264
|
+
columns: colRows.map((col) => ({
|
|
265
|
+
name: col.COLUMN_NAME || col.column_name,
|
|
266
|
+
type: col.DATA_TYPE || col.data_type,
|
|
267
|
+
nullable: (col.IS_NULLABLE || col.is_nullable) === 'YES',
|
|
268
|
+
primaryKey: (col.COLUMN_KEY || col.column_key) === 'PRI',
|
|
269
|
+
defaultValue: col.COLUMN_DEFAULT || col.column_default || undefined,
|
|
270
|
+
})),
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return { schemas: [{ name: connection.databaseName, tables }] };
|
|
274
|
+
}
|
|
275
|
+
return { schemas: [] };
|
|
276
|
+
}
|
|
277
|
+
async getTableData(connectionId, params) {
|
|
278
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
279
|
+
const { schema, table, page, pageSize, orderBy, orderDir } = params;
|
|
280
|
+
const schemaIdent = `"${schema.replace(/"/g, '""')}"`;
|
|
281
|
+
const tableIdent = `"${table.replace(/"/g, '""')}"`;
|
|
282
|
+
const fullTable = `${schemaIdent}.${tableIdent}`;
|
|
283
|
+
const countResult = await ds.query(`SELECT COUNT(*) as count FROM ${fullTable}`);
|
|
284
|
+
const totalCount = parseInt(countResult[0]?.count) || 0;
|
|
285
|
+
const colInfo = await ds.query(`
|
|
286
|
+
SELECT c.column_name, c.udt_name, c.data_type,
|
|
287
|
+
CASE WHEN pk.column_name IS NOT NULL THEN true ELSE false END as is_primary_key
|
|
288
|
+
FROM information_schema.columns c
|
|
289
|
+
LEFT JOIN (
|
|
290
|
+
SELECT kcu.column_name
|
|
291
|
+
FROM information_schema.table_constraints tc
|
|
292
|
+
JOIN information_schema.key_column_usage kcu
|
|
293
|
+
ON tc.constraint_name = kcu.constraint_name AND tc.table_schema = kcu.table_schema
|
|
294
|
+
WHERE tc.table_schema = $1 AND tc.table_name = $2 AND tc.constraint_type = 'PRIMARY KEY'
|
|
295
|
+
) pk ON pk.column_name = c.column_name
|
|
296
|
+
WHERE c.table_schema = $1 AND c.table_name = $2
|
|
297
|
+
ORDER BY c.ordinal_position
|
|
298
|
+
`, [schema, table]);
|
|
299
|
+
const fields = colInfo.map((col) => ({
|
|
300
|
+
name: col.column_name,
|
|
301
|
+
type: col.udt_name || col.data_type,
|
|
302
|
+
primaryKey: col.is_primary_key === true || col.is_primary_key === 'true',
|
|
303
|
+
}));
|
|
304
|
+
let orderClause = '';
|
|
305
|
+
if (orderBy) {
|
|
306
|
+
const orderIdent = `"${orderBy.replace(/"/g, '""')}"`;
|
|
307
|
+
orderClause = `ORDER BY ${orderIdent} ${orderDir === 'DESC' ? 'DESC' : 'ASC'}`;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
const pkCol = fields.find((f) => f.primaryKey);
|
|
311
|
+
if (pkCol) {
|
|
312
|
+
orderClause = `ORDER BY "${pkCol.name}" ASC`;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const offset = (page - 1) * pageSize;
|
|
316
|
+
const rows = await ds.query(`SELECT * FROM ${fullTable} ${orderClause} LIMIT ${pageSize} OFFSET ${offset}`);
|
|
317
|
+
return { rows, totalCount, fields, page, pageSize };
|
|
318
|
+
}
|
|
319
|
+
async insertRow(connectionId, schema, table, row) {
|
|
320
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
321
|
+
const schemaIdent = `"${schema.replace(/"/g, '""')}"`;
|
|
322
|
+
const tableIdent = `"${table.replace(/"/g, '""')}"`;
|
|
323
|
+
const fullTable = `${schemaIdent}.${tableIdent}`;
|
|
324
|
+
const keys = Object.keys(row);
|
|
325
|
+
const cols = keys.map(k => `"${k.replace(/"/g, '""')}"`).join(', ');
|
|
326
|
+
const placeholders = keys.map((_, i) => `$${i + 1}`).join(', ');
|
|
327
|
+
const values = keys.map(k => row[k]);
|
|
328
|
+
try {
|
|
329
|
+
const result = await ds.query(`INSERT INTO ${fullTable} (${cols}) VALUES (${placeholders}) RETURNING *`, values);
|
|
330
|
+
return { success: true, row: result[0] };
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
throw new common_1.BadRequestException(error instanceof Error ? error.message : 'Insert failed');
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async updateRow(connectionId, schema, table, where, set) {
|
|
337
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
338
|
+
const schemaIdent = `"${schema.replace(/"/g, '""')}"`;
|
|
339
|
+
const tableIdent = `"${table.replace(/"/g, '""')}"`;
|
|
340
|
+
const fullTable = `${schemaIdent}.${tableIdent}`;
|
|
341
|
+
const setKeys = Object.keys(set);
|
|
342
|
+
const whereKeys = Object.keys(where);
|
|
343
|
+
let paramIdx = 1;
|
|
344
|
+
const setClauses = setKeys.map(k => `"${k.replace(/"/g, '""')}" = $${paramIdx++}`).join(', ');
|
|
345
|
+
const whereClauses = whereKeys.map(k => `"${k.replace(/"/g, '""')}" = $${paramIdx++}`).join(' AND ');
|
|
346
|
+
const values = [...setKeys.map(k => set[k]), ...whereKeys.map(k => where[k])];
|
|
347
|
+
try {
|
|
348
|
+
const result = await ds.query(`UPDATE ${fullTable} SET ${setClauses} WHERE ${whereClauses}`, values);
|
|
349
|
+
return { success: true, rowCount: result[1] || 1 };
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
throw new common_1.BadRequestException(error instanceof Error ? error.message : 'Update failed');
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async deleteRow(connectionId, schema, table, where) {
|
|
356
|
+
const ds = await this.getOrCreateDataSource(connectionId);
|
|
357
|
+
const schemaIdent = `"${schema.replace(/"/g, '""')}"`;
|
|
358
|
+
const tableIdent = `"${table.replace(/"/g, '""')}"`;
|
|
359
|
+
const fullTable = `${schemaIdent}.${tableIdent}`;
|
|
360
|
+
const whereKeys = Object.keys(where);
|
|
361
|
+
const whereClauses = whereKeys.map((k, i) => `"${k.replace(/"/g, '""')}" = $${i + 1}`).join(' AND ');
|
|
362
|
+
const values = whereKeys.map(k => where[k]);
|
|
363
|
+
try {
|
|
364
|
+
const result = await ds.query(`DELETE FROM ${fullTable} WHERE ${whereClauses}`, values);
|
|
365
|
+
return { success: true, rowCount: result[1] || 1 };
|
|
366
|
+
}
|
|
367
|
+
catch (error) {
|
|
368
|
+
throw new common_1.BadRequestException(error instanceof Error ? error.message : 'Delete failed');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async getOrCreateDataSource(connectionId) {
|
|
372
|
+
if (this.connections.has(connectionId)) {
|
|
373
|
+
const ds = this.connections.get(connectionId);
|
|
374
|
+
if (ds.isInitialized) {
|
|
375
|
+
return ds;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const connection = await this.getConnection(connectionId);
|
|
379
|
+
if (!connection) {
|
|
380
|
+
throw new common_1.BadRequestException('Connection not found');
|
|
381
|
+
}
|
|
382
|
+
const ds = await this.createDataSource(connection);
|
|
383
|
+
await ds.initialize();
|
|
384
|
+
this.connections.set(connectionId, ds);
|
|
385
|
+
return ds;
|
|
386
|
+
}
|
|
387
|
+
async createDataSource(connection) {
|
|
388
|
+
const options = {
|
|
389
|
+
type: connection.type,
|
|
390
|
+
host: connection.host,
|
|
391
|
+
port: connection.port,
|
|
392
|
+
database: connection.databaseName,
|
|
393
|
+
username: connection.username,
|
|
394
|
+
password: connection.password || undefined,
|
|
395
|
+
ssl: connection.ssl ? { rejectUnauthorized: false } : false,
|
|
396
|
+
};
|
|
397
|
+
return new typeorm_2.DataSource(options);
|
|
398
|
+
}
|
|
399
|
+
async closeAll() {
|
|
400
|
+
for (const [id, ds] of this.connections) {
|
|
401
|
+
if (ds.isInitialized) {
|
|
402
|
+
await ds.destroy();
|
|
403
|
+
}
|
|
404
|
+
this.connections.delete(id);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
exports.DatabaseService = DatabaseService;
|
|
409
|
+
exports.DatabaseService = DatabaseService = __decorate([
|
|
410
|
+
(0, common_1.Injectable)(),
|
|
411
|
+
__param(0, (0, typeorm_1.InjectRepository)(database_connection_entity_1.DatabaseConnection)),
|
|
412
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
413
|
+
config_service_1.ConfigService])
|
|
414
|
+
], DatabaseService);
|
|
415
|
+
//# sourceMappingURL=database.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.service.js","sourceRoot":"","sources":["../../../src/modules/database/database.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,6CAAmD;AACnD,qCAAoE;AACpE,6EAAkE;AAClE,6DAAyD;AAGlD,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B,YAEE,oBAA4D,EACpD,aAA4B;QAD5B,yBAAoB,GAApB,oBAAoB,CAAgC;QACpD,kBAAa,GAAb,aAAa,CAAe;QAL9B,gBAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;IAMtD,CAAC;IAKJ,KAAK,CAAC,eAAe,CAAC,WAAoB;QACxC,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;YACjD,KAAK;YACL,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;SACvB,CAAC,CAAC;QAGH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;YAC9D,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAKO,KAAK,CAAC,oBAAoB,CAAC,WAAmB;QACpD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI;gBAAE,OAAO,IAAI,CAAC;YAElE,MAAM,UAAU,GAAG,IA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AC;QAC9B,CAAC;IACH,CAAC;CACF,CAAA;AAjlBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,+CAAkB,CAAC,CAAA;qCACP,oBAAU;QACjB,8BAAa;GAN3B,eAAe,CAilB3B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Workspace } from '../../common/entities/workspace.entity';
|
|
2
|
+
export declare class MigrationHistory {
|
|
3
|
+
id: string;
|
|
4
|
+
workspaceId: string;
|
|
5
|
+
workspace: Workspace;
|
|
6
|
+
version: string;
|
|
7
|
+
name: string;
|
|
8
|
+
direction: 'up' | 'down';
|
|
9
|
+
status: 'pending' | 'running' | 'success' | 'failed';
|
|
10
|
+
durationMs: number;
|
|
11
|
+
sqlContent: string;
|
|
12
|
+
errorMessage: string;
|
|
13
|
+
executedAt: Date;
|
|
14
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrationHistory = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const workspace_entity_1 = require("../../common/entities/workspace.entity");
|
|
15
|
+
let MigrationHistory = class MigrationHistory {
|
|
16
|
+
};
|
|
17
|
+
exports.MigrationHistory = MigrationHistory;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], MigrationHistory.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'workspace_id' }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], MigrationHistory.prototype, "workspaceId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.ManyToOne)(() => workspace_entity_1.Workspace, { onDelete: 'CASCADE' }),
|
|
28
|
+
(0, typeorm_1.JoinColumn)({ name: 'workspace_id' }),
|
|
29
|
+
__metadata("design:type", workspace_entity_1.Workspace)
|
|
30
|
+
], MigrationHistory.prototype, "workspace", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typeorm_1.Column)({ length: 20 }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], MigrationHistory.prototype, "version", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ length: 255 }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], MigrationHistory.prototype, "name", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typeorm_1.Column)({ length: 10 }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], MigrationHistory.prototype, "direction", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ length: 20 }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], MigrationHistory.prototype, "status", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ name: 'duration_ms', type: 'int', nullable: true }),
|
|
49
|
+
__metadata("design:type", Number)
|
|
50
|
+
], MigrationHistory.prototype, "durationMs", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typeorm_1.Column)({ name: 'sql_content', type: 'text', nullable: true }),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], MigrationHistory.prototype, "sqlContent", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typeorm_1.Column)({ name: 'error_message', type: 'text', nullable: true }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], MigrationHistory.prototype, "errorMessage", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'executed_at' }),
|
|
61
|
+
__metadata("design:type", Date)
|
|
62
|
+
], MigrationHistory.prototype, "executedAt", void 0);
|
|
63
|
+
exports.MigrationHistory = MigrationHistory = __decorate([
|
|
64
|
+
(0, typeorm_1.Entity)('migration_history')
|
|
65
|
+
], MigrationHistory);
|
|
66
|
+
//# sourceMappingURL=migration-history.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-history.entity.js","sourceRoot":"","sources":["../../../src/modules/migration/migration-history.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAOiB;AACjB,6EAAmE;AAG5D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAkC5B,CAAA;AAlCY,4CAAgB;AAE3B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;4CACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;;qDACb;AAIpB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,4BAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACnD,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;8BAC1B,4BAAS;mDAAC;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;iDACP;AAGhB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;;8CACX;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;mDACE;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;;gDAC8B;AAGrD;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDAC1C;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDAC3C;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDAC3C;AAGrB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;8BAC9B,IAAI;oDAAC;2BAjCN,gBAAgB;IAD5B,IAAA,gBAAM,EAAC,mBAAmB,CAAC;GACf,gBAAgB,CAkC5B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrationTemplate = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let MigrationTemplate = class MigrationTemplate {
|
|
15
|
+
};
|
|
16
|
+
exports.MigrationTemplate = MigrationTemplate;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], MigrationTemplate.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ length: 255, unique: true }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], MigrationTemplate.prototype, "name", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], MigrationTemplate.prototype, "description", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ name: 'up_template', type: 'text' }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], MigrationTemplate.prototype, "upTemplate", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ name: 'down_template', type: 'text', nullable: true }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], MigrationTemplate.prototype, "downTemplate", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'simple-json', default: '[]' }),
|
|
39
|
+
__metadata("design:type", Array)
|
|
40
|
+
], MigrationTemplate.prototype, "variables", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ name: 'is_builtin', default: false }),
|
|
43
|
+
__metadata("design:type", Boolean)
|
|
44
|
+
], MigrationTemplate.prototype, "isBuiltin", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.CreateDateColumn)({ name: 'created_at' }),
|
|
47
|
+
__metadata("design:type", Date)
|
|
48
|
+
], MigrationTemplate.prototype, "createdAt", void 0);
|
|
49
|
+
exports.MigrationTemplate = MigrationTemplate = __decorate([
|
|
50
|
+
(0, typeorm_1.Entity)('migration_templates')
|
|
51
|
+
], MigrationTemplate);
|
|
52
|
+
//# sourceMappingURL=migration-template.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-template.entity.js","sourceRoot":"","sources":["../../../src/modules/migration/migration-template.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAKiB;AAGV,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAwB7B,CAAA;AAxBY,8CAAiB;AAE5B;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;6CACpB;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;+CACzB;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACrB;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qDAC3B;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDAC3C;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;oDAC3B;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDAC5B;AAGnB;IADC,IAAA,0BAAgB,EAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;8BAC9B,IAAI;oDAAC;4BAvBL,iBAAiB;IAD7B,IAAA,gBAAM,EAAC,qBAAqB,CAAC;GACjB,iBAAiB,CAwB7B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MigrationService } from './migration.service';
|
|
2
|
+
export declare class MigrationController {
|
|
3
|
+
private readonly migrationService;
|
|
4
|
+
constructor(migrationService: MigrationService);
|
|
5
|
+
listMigrations(): Promise<import("./migration.service").MigrationFile[]>;
|
|
6
|
+
getHistory(workspaceId?: string): Promise<import("./migration-history.entity").MigrationHistory[]>;
|
|
7
|
+
getTemplates(): Promise<import("./migration-template.entity").MigrationTemplate[]>;
|
|
8
|
+
getMigrationContent(version: string, direction: 'up' | 'down'): Promise<{
|
|
9
|
+
content: null;
|
|
10
|
+
version?: undefined;
|
|
11
|
+
direction?: undefined;
|
|
12
|
+
filename?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
version: string;
|
|
15
|
+
direction: "up" | "down";
|
|
16
|
+
filename: string;
|
|
17
|
+
content: string | null;
|
|
18
|
+
}>;
|
|
19
|
+
createTemplate(data: {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
upTemplate: string;
|
|
23
|
+
downTemplate?: string;
|
|
24
|
+
variables?: string[];
|
|
25
|
+
}): Promise<import("./migration-template.entity").MigrationTemplate>;
|
|
26
|
+
deleteTemplate(name: string): Promise<void>;
|
|
27
|
+
generateMigration(data: {
|
|
28
|
+
name: string;
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
output: string;
|
|
33
|
+
error?: string;
|
|
34
|
+
}>;
|
|
35
|
+
runMigrations(data: {
|
|
36
|
+
force?: boolean;
|
|
37
|
+
dryRun?: boolean;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
success: boolean;
|
|
40
|
+
output: string;
|
|
41
|
+
migrations: string[];
|
|
42
|
+
error?: string;
|
|
43
|
+
}>;
|
|
44
|
+
revertMigrations(data: {
|
|
45
|
+
steps?: number;
|
|
46
|
+
dryRun?: boolean;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
output: string;
|
|
50
|
+
migrations: string[];
|
|
51
|
+
error?: string;
|
|
52
|
+
}>;
|
|
53
|
+
getMigrationStatus(): Promise<{
|
|
54
|
+
success: boolean;
|
|
55
|
+
output: string;
|
|
56
|
+
pending: string[];
|
|
57
|
+
applied: string[];
|
|
58
|
+
error?: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|