datapeek 0.1.16 → 0.1.17
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/dist/cli/chunk-25W7DLJU.js +763 -0
- package/dist/cli/chunk-4ZTTGN4K.js +772 -0
- package/dist/cli/chunk-AZZM4KI4.js +748 -0
- package/dist/cli/chunk-N4ZN35TN.js +753 -0
- package/dist/cli/chunk-NT7RKOGB.js +736 -0
- package/dist/cli/db-DUN4MAAS.js +36 -0
- package/dist/cli/db-G3OUYANY.js +36 -0
- package/dist/cli/db-GII5HVII.js +36 -0
- package/dist/cli/db-PLHJBMIE.js +36 -0
- package/dist/cli/db-UXHWQZEH.js +36 -0
- package/dist/cli/dev.js +40 -12
- package/dist/cli/index.js +40 -12
- package/dist/client/assets/index-BvCSgDQI.css +1 -0
- package/dist/client/assets/index-k-JqbRd3.js +395 -0
- package/dist/client/index.html +2 -2
- package/dist/server/chunk-FUD3HYYO.js +750 -0
- package/dist/server/chunk-ICJJTM6H.js +745 -0
- package/dist/server/chunk-IFTGVLYX.js +760 -0
- package/dist/server/chunk-J4S2WZCU.js +733 -0
- package/dist/server/chunk-VTBMBBQX.js +769 -0
- package/dist/server/db-P6KUHD2Z.js +34 -0
- package/dist/server/db-QCCVQUMG.js +34 -0
- package/dist/server/db-SHAIVNT5.js +34 -0
- package/dist/server/db-T5GG3OX4.js +34 -0
- package/dist/server/db-TN4IWAPG.js +34 -0
- package/dist/server/dev.js +40 -12
- package/dist/server/index.js +40 -12
- package/package.json +1 -1
- package/dist/client/assets/index-Bc0Vjyhl.js +0 -390
- package/dist/client/assets/index-DEccnksW.css +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect,
|
|
3
|
+
detectDbType,
|
|
4
|
+
disconnect,
|
|
5
|
+
executeQuery,
|
|
6
|
+
executeQueryMultiple,
|
|
7
|
+
getConnection,
|
|
8
|
+
getConnectionConfig,
|
|
9
|
+
getDbType,
|
|
10
|
+
getDialect,
|
|
11
|
+
parseConnectionString,
|
|
12
|
+
setDbType,
|
|
13
|
+
testConnection
|
|
14
|
+
} from "./chunk-VTBMBBQX.js";
|
|
15
|
+
import {
|
|
16
|
+
cancelQuery,
|
|
17
|
+
generateQueryId
|
|
18
|
+
} from "./chunk-3DAIYH42.js";
|
|
19
|
+
export {
|
|
20
|
+
cancelQuery,
|
|
21
|
+
connect,
|
|
22
|
+
detectDbType,
|
|
23
|
+
disconnect,
|
|
24
|
+
executeQuery,
|
|
25
|
+
executeQueryMultiple,
|
|
26
|
+
generateQueryId,
|
|
27
|
+
getConnection,
|
|
28
|
+
getConnectionConfig,
|
|
29
|
+
getDbType,
|
|
30
|
+
getDialect,
|
|
31
|
+
parseConnectionString,
|
|
32
|
+
setDbType,
|
|
33
|
+
testConnection
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect,
|
|
3
|
+
detectDbType,
|
|
4
|
+
disconnect,
|
|
5
|
+
executeQuery,
|
|
6
|
+
executeQueryMultiple,
|
|
7
|
+
getConnection,
|
|
8
|
+
getConnectionConfig,
|
|
9
|
+
getDbType,
|
|
10
|
+
getDialect,
|
|
11
|
+
parseConnectionString,
|
|
12
|
+
setDbType,
|
|
13
|
+
testConnection
|
|
14
|
+
} from "./chunk-J4S2WZCU.js";
|
|
15
|
+
import {
|
|
16
|
+
cancelQuery,
|
|
17
|
+
generateQueryId
|
|
18
|
+
} from "./chunk-3DAIYH42.js";
|
|
19
|
+
export {
|
|
20
|
+
cancelQuery,
|
|
21
|
+
connect,
|
|
22
|
+
detectDbType,
|
|
23
|
+
disconnect,
|
|
24
|
+
executeQuery,
|
|
25
|
+
executeQueryMultiple,
|
|
26
|
+
generateQueryId,
|
|
27
|
+
getConnection,
|
|
28
|
+
getConnectionConfig,
|
|
29
|
+
getDbType,
|
|
30
|
+
getDialect,
|
|
31
|
+
parseConnectionString,
|
|
32
|
+
setDbType,
|
|
33
|
+
testConnection
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect,
|
|
3
|
+
detectDbType,
|
|
4
|
+
disconnect,
|
|
5
|
+
executeQuery,
|
|
6
|
+
executeQueryMultiple,
|
|
7
|
+
getConnection,
|
|
8
|
+
getConnectionConfig,
|
|
9
|
+
getDbType,
|
|
10
|
+
getDialect,
|
|
11
|
+
parseConnectionString,
|
|
12
|
+
setDbType,
|
|
13
|
+
testConnection
|
|
14
|
+
} from "./chunk-FUD3HYYO.js";
|
|
15
|
+
import {
|
|
16
|
+
cancelQuery,
|
|
17
|
+
generateQueryId
|
|
18
|
+
} from "./chunk-3DAIYH42.js";
|
|
19
|
+
export {
|
|
20
|
+
cancelQuery,
|
|
21
|
+
connect,
|
|
22
|
+
detectDbType,
|
|
23
|
+
disconnect,
|
|
24
|
+
executeQuery,
|
|
25
|
+
executeQueryMultiple,
|
|
26
|
+
generateQueryId,
|
|
27
|
+
getConnection,
|
|
28
|
+
getConnectionConfig,
|
|
29
|
+
getDbType,
|
|
30
|
+
getDialect,
|
|
31
|
+
parseConnectionString,
|
|
32
|
+
setDbType,
|
|
33
|
+
testConnection
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect,
|
|
3
|
+
detectDbType,
|
|
4
|
+
disconnect,
|
|
5
|
+
executeQuery,
|
|
6
|
+
executeQueryMultiple,
|
|
7
|
+
getConnection,
|
|
8
|
+
getConnectionConfig,
|
|
9
|
+
getDbType,
|
|
10
|
+
getDialect,
|
|
11
|
+
parseConnectionString,
|
|
12
|
+
setDbType,
|
|
13
|
+
testConnection
|
|
14
|
+
} from "./chunk-IFTGVLYX.js";
|
|
15
|
+
import {
|
|
16
|
+
cancelQuery,
|
|
17
|
+
generateQueryId
|
|
18
|
+
} from "./chunk-3DAIYH42.js";
|
|
19
|
+
export {
|
|
20
|
+
cancelQuery,
|
|
21
|
+
connect,
|
|
22
|
+
detectDbType,
|
|
23
|
+
disconnect,
|
|
24
|
+
executeQuery,
|
|
25
|
+
executeQueryMultiple,
|
|
26
|
+
generateQueryId,
|
|
27
|
+
getConnection,
|
|
28
|
+
getConnectionConfig,
|
|
29
|
+
getDbType,
|
|
30
|
+
getDialect,
|
|
31
|
+
parseConnectionString,
|
|
32
|
+
setDbType,
|
|
33
|
+
testConnection
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connect,
|
|
3
|
+
detectDbType,
|
|
4
|
+
disconnect,
|
|
5
|
+
executeQuery,
|
|
6
|
+
executeQueryMultiple,
|
|
7
|
+
getConnection,
|
|
8
|
+
getConnectionConfig,
|
|
9
|
+
getDbType,
|
|
10
|
+
getDialect,
|
|
11
|
+
parseConnectionString,
|
|
12
|
+
setDbType,
|
|
13
|
+
testConnection
|
|
14
|
+
} from "./chunk-ICJJTM6H.js";
|
|
15
|
+
import {
|
|
16
|
+
cancelQuery,
|
|
17
|
+
generateQueryId
|
|
18
|
+
} from "./chunk-3DAIYH42.js";
|
|
19
|
+
export {
|
|
20
|
+
cancelQuery,
|
|
21
|
+
connect,
|
|
22
|
+
detectDbType,
|
|
23
|
+
disconnect,
|
|
24
|
+
executeQuery,
|
|
25
|
+
executeQueryMultiple,
|
|
26
|
+
generateQueryId,
|
|
27
|
+
getConnection,
|
|
28
|
+
getConnectionConfig,
|
|
29
|
+
getDbType,
|
|
30
|
+
getDialect,
|
|
31
|
+
parseConnectionString,
|
|
32
|
+
setDbType,
|
|
33
|
+
testConnection
|
|
34
|
+
};
|
package/dist/server/dev.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
parseConnectionString,
|
|
11
11
|
setDbType,
|
|
12
12
|
testConnection
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VTBMBBQX.js";
|
|
14
14
|
import {
|
|
15
15
|
cancelQuery,
|
|
16
16
|
generateQueryId
|
|
@@ -188,7 +188,7 @@ tableRoutes.get("/", async (req, res) => {
|
|
|
188
188
|
console.error("Error fetching tables:", error);
|
|
189
189
|
const errorMessage = error.message || "";
|
|
190
190
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
191
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
191
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
192
192
|
await disconnect2();
|
|
193
193
|
}
|
|
194
194
|
const errorDetails = error.originalError?.message || error.originalError?.info?.message || error.message || "Failed to fetch tables";
|
|
@@ -264,7 +264,7 @@ tableRoutes.get("/:schema/:table", async (req, res) => {
|
|
|
264
264
|
} catch (error) {
|
|
265
265
|
const errorMessage = error.message || "";
|
|
266
266
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
267
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
267
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
268
268
|
await disconnect2();
|
|
269
269
|
}
|
|
270
270
|
res.status(500).json({ error: error.message || "Failed to fetch table structure" });
|
|
@@ -820,7 +820,7 @@ ${limitOffsetClause}`;
|
|
|
820
820
|
console.error("Error fetching table data:", error);
|
|
821
821
|
const errorMessage = error.message || "";
|
|
822
822
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
823
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
823
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
824
824
|
await disconnect2();
|
|
825
825
|
}
|
|
826
826
|
const isTimeout = error.code === "ETIMEOUT" || error.code === "ESOCKET" || error.message?.includes("timeout") || error.message?.includes("ETIMEDOUT") || error.originalError?.code === "ETIMEOUT" || error.originalError?.code === "ESOCKET";
|
|
@@ -921,7 +921,7 @@ tableRoutes.post("/:schema/:table/related-data", async (req, res) => {
|
|
|
921
921
|
console.error("Error fetching related data:", error);
|
|
922
922
|
const errorMessage = error.message || "";
|
|
923
923
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
924
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
924
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
925
925
|
await disconnect2();
|
|
926
926
|
}
|
|
927
927
|
res.status(500).json({ error: error.message || "Failed to fetch related data" });
|
|
@@ -1098,7 +1098,7 @@ tableRoutes.get("/:schema/:table/distinct-values/:column", async (req, res) => {
|
|
|
1098
1098
|
console.error("Error fetching distinct values:", error);
|
|
1099
1099
|
const errorMessage = error.message || "";
|
|
1100
1100
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1101
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1101
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1102
1102
|
await disconnect2();
|
|
1103
1103
|
}
|
|
1104
1104
|
res.status(500).json({ error: error.message || "Failed to fetch distinct values" });
|
|
@@ -1164,7 +1164,7 @@ tableRoutes.get("/:schema/:table/reverse-foreign-keys", async (req, res) => {
|
|
|
1164
1164
|
console.error("Error fetching reverse foreign keys:", error);
|
|
1165
1165
|
const errorMessage = error.message || "";
|
|
1166
1166
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1167
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1167
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1168
1168
|
await disconnect2();
|
|
1169
1169
|
}
|
|
1170
1170
|
res.status(500).json({ error: error.message || "Failed to fetch reverse foreign keys" });
|
|
@@ -1223,7 +1223,7 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
|
|
|
1223
1223
|
console.error("Error counting related rows:", error);
|
|
1224
1224
|
const errorMessage = error.message || "";
|
|
1225
1225
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1226
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1226
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1227
1227
|
await disconnect2();
|
|
1228
1228
|
}
|
|
1229
1229
|
res.status(500).json({ error: error.message || "Failed to count related rows" });
|
|
@@ -1233,6 +1233,31 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
|
|
|
1233
1233
|
// src/server/routes/query.ts
|
|
1234
1234
|
import { Router as Router3 } from "express";
|
|
1235
1235
|
var queryRoutes = Router3();
|
|
1236
|
+
function extractErrorMessages(error) {
|
|
1237
|
+
const out = [];
|
|
1238
|
+
if (Array.isArray(error?.messages)) {
|
|
1239
|
+
for (const msg of error.messages) {
|
|
1240
|
+
const text = typeof msg?.message === "string" ? msg.message : String(msg ?? "");
|
|
1241
|
+
if (!text.trim()) continue;
|
|
1242
|
+
const type = msg?.type === "warning" ? "warning" : msg?.type === "error" ? "error" : "info";
|
|
1243
|
+
out.push({ type, message: text });
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (Array.isArray(error?.precedingErrors)) {
|
|
1247
|
+
for (const err of error.precedingErrors) {
|
|
1248
|
+
const text = typeof err?.message === "string" ? err.message : String(err ?? "");
|
|
1249
|
+
if (!text.trim()) continue;
|
|
1250
|
+
out.push({ type: "error", message: text });
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (error?.message) {
|
|
1254
|
+
const hasPrimary = out.some((msg) => msg.message === error.message);
|
|
1255
|
+
if (!hasPrimary) {
|
|
1256
|
+
out.push({ type: "error", message: error.message });
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return out.length > 0 ? out : void 0;
|
|
1260
|
+
}
|
|
1236
1261
|
queryRoutes.post("/", async (req, res) => {
|
|
1237
1262
|
try {
|
|
1238
1263
|
const { query: sqlQuery, queryId } = req.body;
|
|
@@ -1241,7 +1266,7 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1241
1266
|
}
|
|
1242
1267
|
const activeQueryId = queryId || generateQueryId();
|
|
1243
1268
|
const startTime = Date.now();
|
|
1244
|
-
const { recordsets: resultSets, columnMetadata } = await executeQueryMultiple(sqlQuery, void 0, activeQueryId);
|
|
1269
|
+
const { recordsets: resultSets, columnMetadata, messages } = await executeQueryMultiple(sqlQuery, void 0, activeQueryId);
|
|
1245
1270
|
const executionTime = Date.now() - startTime;
|
|
1246
1271
|
res.json({
|
|
1247
1272
|
data: resultSets[0] || [],
|
|
@@ -1249,6 +1274,7 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1249
1274
|
executionTime,
|
|
1250
1275
|
columnMetadata,
|
|
1251
1276
|
// Include column metadata for empty result sets
|
|
1277
|
+
messages,
|
|
1252
1278
|
queryId: activeQueryId
|
|
1253
1279
|
// Return queryId so client can track it
|
|
1254
1280
|
});
|
|
@@ -1256,17 +1282,19 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1256
1282
|
if (error.cancelled || error.code === "ECANCEL") {
|
|
1257
1283
|
return res.status(499).json({
|
|
1258
1284
|
error: "Query was cancelled",
|
|
1259
|
-
cancelled: true
|
|
1285
|
+
cancelled: true,
|
|
1286
|
+
messages: extractErrorMessages(error)
|
|
1260
1287
|
});
|
|
1261
1288
|
}
|
|
1262
1289
|
const errorMessage = error.message || "";
|
|
1263
1290
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1264
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1291
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1265
1292
|
await disconnect2();
|
|
1266
1293
|
}
|
|
1267
1294
|
res.status(500).json({
|
|
1268
1295
|
error: error.message || "Query execution failed",
|
|
1269
|
-
details: error.originalError?.message
|
|
1296
|
+
details: error.originalError?.message,
|
|
1297
|
+
messages: extractErrorMessages(error)
|
|
1270
1298
|
});
|
|
1271
1299
|
}
|
|
1272
1300
|
});
|
package/dist/server/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
parseConnectionString,
|
|
11
11
|
setDbType,
|
|
12
12
|
testConnection
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VTBMBBQX.js";
|
|
14
14
|
import {
|
|
15
15
|
cancelQuery,
|
|
16
16
|
generateQueryId
|
|
@@ -188,7 +188,7 @@ tableRoutes.get("/", async (req, res) => {
|
|
|
188
188
|
console.error("Error fetching tables:", error);
|
|
189
189
|
const errorMessage = error.message || "";
|
|
190
190
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
191
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
191
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
192
192
|
await disconnect2();
|
|
193
193
|
}
|
|
194
194
|
const errorDetails = error.originalError?.message || error.originalError?.info?.message || error.message || "Failed to fetch tables";
|
|
@@ -264,7 +264,7 @@ tableRoutes.get("/:schema/:table", async (req, res) => {
|
|
|
264
264
|
} catch (error) {
|
|
265
265
|
const errorMessage = error.message || "";
|
|
266
266
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
267
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
267
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
268
268
|
await disconnect2();
|
|
269
269
|
}
|
|
270
270
|
res.status(500).json({ error: error.message || "Failed to fetch table structure" });
|
|
@@ -820,7 +820,7 @@ ${limitOffsetClause}`;
|
|
|
820
820
|
console.error("Error fetching table data:", error);
|
|
821
821
|
const errorMessage = error.message || "";
|
|
822
822
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
823
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
823
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
824
824
|
await disconnect2();
|
|
825
825
|
}
|
|
826
826
|
const isTimeout = error.code === "ETIMEOUT" || error.code === "ESOCKET" || error.message?.includes("timeout") || error.message?.includes("ETIMEDOUT") || error.originalError?.code === "ETIMEOUT" || error.originalError?.code === "ESOCKET";
|
|
@@ -921,7 +921,7 @@ tableRoutes.post("/:schema/:table/related-data", async (req, res) => {
|
|
|
921
921
|
console.error("Error fetching related data:", error);
|
|
922
922
|
const errorMessage = error.message || "";
|
|
923
923
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
924
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
924
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
925
925
|
await disconnect2();
|
|
926
926
|
}
|
|
927
927
|
res.status(500).json({ error: error.message || "Failed to fetch related data" });
|
|
@@ -1098,7 +1098,7 @@ tableRoutes.get("/:schema/:table/distinct-values/:column", async (req, res) => {
|
|
|
1098
1098
|
console.error("Error fetching distinct values:", error);
|
|
1099
1099
|
const errorMessage = error.message || "";
|
|
1100
1100
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1101
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1101
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1102
1102
|
await disconnect2();
|
|
1103
1103
|
}
|
|
1104
1104
|
res.status(500).json({ error: error.message || "Failed to fetch distinct values" });
|
|
@@ -1164,7 +1164,7 @@ tableRoutes.get("/:schema/:table/reverse-foreign-keys", async (req, res) => {
|
|
|
1164
1164
|
console.error("Error fetching reverse foreign keys:", error);
|
|
1165
1165
|
const errorMessage = error.message || "";
|
|
1166
1166
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1167
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1167
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1168
1168
|
await disconnect2();
|
|
1169
1169
|
}
|
|
1170
1170
|
res.status(500).json({ error: error.message || "Failed to fetch reverse foreign keys" });
|
|
@@ -1223,7 +1223,7 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
|
|
|
1223
1223
|
console.error("Error counting related rows:", error);
|
|
1224
1224
|
const errorMessage = error.message || "";
|
|
1225
1225
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1226
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1226
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1227
1227
|
await disconnect2();
|
|
1228
1228
|
}
|
|
1229
1229
|
res.status(500).json({ error: error.message || "Failed to count related rows" });
|
|
@@ -1233,6 +1233,31 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
|
|
|
1233
1233
|
// src/server/routes/query.ts
|
|
1234
1234
|
import { Router as Router3 } from "express";
|
|
1235
1235
|
var queryRoutes = Router3();
|
|
1236
|
+
function extractErrorMessages(error) {
|
|
1237
|
+
const out = [];
|
|
1238
|
+
if (Array.isArray(error?.messages)) {
|
|
1239
|
+
for (const msg of error.messages) {
|
|
1240
|
+
const text = typeof msg?.message === "string" ? msg.message : String(msg ?? "");
|
|
1241
|
+
if (!text.trim()) continue;
|
|
1242
|
+
const type = msg?.type === "warning" ? "warning" : msg?.type === "error" ? "error" : "info";
|
|
1243
|
+
out.push({ type, message: text });
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (Array.isArray(error?.precedingErrors)) {
|
|
1247
|
+
for (const err of error.precedingErrors) {
|
|
1248
|
+
const text = typeof err?.message === "string" ? err.message : String(err ?? "");
|
|
1249
|
+
if (!text.trim()) continue;
|
|
1250
|
+
out.push({ type: "error", message: text });
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
if (error?.message) {
|
|
1254
|
+
const hasPrimary = out.some((msg) => msg.message === error.message);
|
|
1255
|
+
if (!hasPrimary) {
|
|
1256
|
+
out.push({ type: "error", message: error.message });
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return out.length > 0 ? out : void 0;
|
|
1260
|
+
}
|
|
1236
1261
|
queryRoutes.post("/", async (req, res) => {
|
|
1237
1262
|
try {
|
|
1238
1263
|
const { query: sqlQuery, queryId } = req.body;
|
|
@@ -1241,7 +1266,7 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1241
1266
|
}
|
|
1242
1267
|
const activeQueryId = queryId || generateQueryId();
|
|
1243
1268
|
const startTime = Date.now();
|
|
1244
|
-
const { recordsets: resultSets, columnMetadata } = await executeQueryMultiple(sqlQuery, void 0, activeQueryId);
|
|
1269
|
+
const { recordsets: resultSets, columnMetadata, messages } = await executeQueryMultiple(sqlQuery, void 0, activeQueryId);
|
|
1245
1270
|
const executionTime = Date.now() - startTime;
|
|
1246
1271
|
res.json({
|
|
1247
1272
|
data: resultSets[0] || [],
|
|
@@ -1249,6 +1274,7 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1249
1274
|
executionTime,
|
|
1250
1275
|
columnMetadata,
|
|
1251
1276
|
// Include column metadata for empty result sets
|
|
1277
|
+
messages,
|
|
1252
1278
|
queryId: activeQueryId
|
|
1253
1279
|
// Return queryId so client can track it
|
|
1254
1280
|
});
|
|
@@ -1256,17 +1282,19 @@ queryRoutes.post("/", async (req, res) => {
|
|
|
1256
1282
|
if (error.cancelled || error.code === "ECANCEL") {
|
|
1257
1283
|
return res.status(499).json({
|
|
1258
1284
|
error: "Query was cancelled",
|
|
1259
|
-
cancelled: true
|
|
1285
|
+
cancelled: true,
|
|
1286
|
+
messages: extractErrorMessages(error)
|
|
1260
1287
|
});
|
|
1261
1288
|
}
|
|
1262
1289
|
const errorMessage = error.message || "";
|
|
1263
1290
|
if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
|
|
1264
|
-
const { disconnect: disconnect2 } = await import("./db-
|
|
1291
|
+
const { disconnect: disconnect2 } = await import("./db-P6KUHD2Z.js");
|
|
1265
1292
|
await disconnect2();
|
|
1266
1293
|
}
|
|
1267
1294
|
res.status(500).json({
|
|
1268
1295
|
error: error.message || "Query execution failed",
|
|
1269
|
-
details: error.originalError?.message
|
|
1296
|
+
details: error.originalError?.message,
|
|
1297
|
+
messages: extractErrorMessages(error)
|
|
1270
1298
|
});
|
|
1271
1299
|
}
|
|
1272
1300
|
});
|