datapeek 0.1.14 → 0.1.16

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.
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ connect,
5
+ detectDbType,
6
+ disconnect,
7
+ executeQuery,
8
+ executeQueryMultiple,
9
+ getConnection,
10
+ getConnectionConfig,
11
+ getDbType,
12
+ getDialect,
13
+ parseConnectionString,
14
+ setDbType,
15
+ testConnection
16
+ } from "./chunk-B5ENJPHN.js";
17
+ import {
18
+ cancelQuery,
19
+ generateQueryId
20
+ } from "./chunk-4MIQHH6K.js";
21
+ export {
22
+ cancelQuery,
23
+ connect,
24
+ detectDbType,
25
+ disconnect,
26
+ executeQuery,
27
+ executeQueryMultiple,
28
+ generateQueryId,
29
+ getConnection,
30
+ getConnectionConfig,
31
+ getDbType,
32
+ getDialect,
33
+ parseConnectionString,
34
+ setDbType,
35
+ testConnection
36
+ };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ connect,
5
+ detectDbType,
6
+ disconnect,
7
+ executeQuery,
8
+ executeQueryMultiple,
9
+ getConnection,
10
+ getConnectionConfig,
11
+ getDbType,
12
+ getDialect,
13
+ parseConnectionString,
14
+ setDbType,
15
+ testConnection
16
+ } from "./chunk-TYOF4OPP.js";
17
+ import {
18
+ cancelQuery,
19
+ generateQueryId
20
+ } from "./chunk-4MIQHH6K.js";
21
+ export {
22
+ cancelQuery,
23
+ connect,
24
+ detectDbType,
25
+ disconnect,
26
+ executeQuery,
27
+ executeQueryMultiple,
28
+ generateQueryId,
29
+ getConnection,
30
+ getConnectionConfig,
31
+ getDbType,
32
+ getDialect,
33
+ parseConnectionString,
34
+ setDbType,
35
+ testConnection
36
+ };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ connect,
5
+ detectDbType,
6
+ disconnect,
7
+ executeQuery,
8
+ executeQueryMultiple,
9
+ getConnection,
10
+ getConnectionConfig,
11
+ getDbType,
12
+ getDialect,
13
+ parseConnectionString,
14
+ setDbType,
15
+ testConnection
16
+ } from "./chunk-D6TUHXVK.js";
17
+ import {
18
+ cancelQuery,
19
+ generateQueryId
20
+ } from "./chunk-4MIQHH6K.js";
21
+ export {
22
+ cancelQuery,
23
+ connect,
24
+ detectDbType,
25
+ disconnect,
26
+ executeQuery,
27
+ executeQueryMultiple,
28
+ generateQueryId,
29
+ getConnection,
30
+ getConnectionConfig,
31
+ getDbType,
32
+ getDialect,
33
+ parseConnectionString,
34
+ setDbType,
35
+ testConnection
36
+ };
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ connect,
5
+ detectDbType,
6
+ disconnect,
7
+ executeQuery,
8
+ executeQueryMultiple,
9
+ getConnection,
10
+ getDbType,
11
+ getDialect,
12
+ parseConnectionString,
13
+ setDbType,
14
+ testConnection
15
+ } from "./chunk-Q3ZM5P6B.js";
16
+ import {
17
+ cancelQuery,
18
+ generateQueryId
19
+ } from "./chunk-4MIQHH6K.js";
20
+ export {
21
+ cancelQuery,
22
+ connect,
23
+ detectDbType,
24
+ disconnect,
25
+ executeQuery,
26
+ executeQueryMultiple,
27
+ generateQueryId,
28
+ getConnection,
29
+ getDbType,
30
+ getDialect,
31
+ parseConnectionString,
32
+ setDbType,
33
+ testConnection
34
+ };
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ connect,
5
+ detectDbType,
6
+ disconnect,
7
+ executeQuery,
8
+ executeQueryMultiple,
9
+ getConnection,
10
+ getConnectionConfig,
11
+ getDbType,
12
+ getDialect,
13
+ parseConnectionString,
14
+ setDbType,
15
+ testConnection
16
+ } from "./chunk-ACJCJE4M.js";
17
+ import {
18
+ cancelQuery,
19
+ generateQueryId
20
+ } from "./chunk-4MIQHH6K.js";
21
+ export {
22
+ cancelQuery,
23
+ connect,
24
+ detectDbType,
25
+ disconnect,
26
+ executeQuery,
27
+ executeQueryMultiple,
28
+ generateQueryId,
29
+ getConnection,
30
+ getConnectionConfig,
31
+ getDbType,
32
+ getDialect,
33
+ parseConnectionString,
34
+ setDbType,
35
+ testConnection
36
+ };
package/dist/cli/dev.js CHANGED
@@ -6,11 +6,13 @@ import {
6
6
  executeQuery,
7
7
  executeQueryMultiple,
8
8
  getConnection,
9
+ getConnectionConfig,
9
10
  getDbType,
10
11
  getDialect,
12
+ parseConnectionString,
11
13
  setDbType,
12
14
  testConnection
13
- } from "./chunk-CK2O76SG.js";
15
+ } from "./chunk-B5ENJPHN.js";
14
16
  import {
15
17
  cancelQuery,
16
18
  generateQueryId
@@ -121,7 +123,25 @@ connectionRoutes.get("/status", async (req, res) => {
121
123
  const dialect = getDialect();
122
124
  const result = await executeQuery(dialect.currentDbQuery());
123
125
  const databaseName = result[0]?.databaseName || null;
124
- res.json({ connected: true, databaseName });
126
+ let connConfig = getConnectionConfig();
127
+ if (!connConfig && databaseName) {
128
+ const connString = getProvidedConnectionString();
129
+ if (connString) {
130
+ try {
131
+ const parsed = parseConnectionString(connString);
132
+ if (parsed.server && parsed.database && parsed.database.toLowerCase() === databaseName.toLowerCase()) {
133
+ const dbType = connString.trim().startsWith("postgresql://") || connString.trim().startsWith("postgres://") ? "postgres" : "mssql";
134
+ connConfig = { server: parsed.server, database: parsed.database, dbType };
135
+ }
136
+ } catch {
137
+ }
138
+ }
139
+ }
140
+ res.json({
141
+ connected: true,
142
+ databaseName,
143
+ ...connConfig && { server: connConfig.server, database: connConfig.database, dbType: connConfig.dbType }
144
+ });
125
145
  } catch (error) {
126
146
  const errorMessage = error.message || "";
127
147
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
@@ -170,7 +190,7 @@ tableRoutes.get("/", async (req, res) => {
170
190
  console.error("Error fetching tables:", error);
171
191
  const errorMessage = error.message || "";
172
192
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
173
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
193
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
174
194
  await disconnect2();
175
195
  }
176
196
  const errorDetails = error.originalError?.message || error.originalError?.info?.message || error.message || "Failed to fetch tables";
@@ -246,7 +266,7 @@ tableRoutes.get("/:schema/:table", async (req, res) => {
246
266
  } catch (error) {
247
267
  const errorMessage = error.message || "";
248
268
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
249
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
269
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
250
270
  await disconnect2();
251
271
  }
252
272
  res.status(500).json({ error: error.message || "Failed to fetch table structure" });
@@ -802,7 +822,7 @@ ${limitOffsetClause}`;
802
822
  console.error("Error fetching table data:", error);
803
823
  const errorMessage = error.message || "";
804
824
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
805
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
825
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
806
826
  await disconnect2();
807
827
  }
808
828
  const isTimeout = error.code === "ETIMEOUT" || error.code === "ESOCKET" || error.message?.includes("timeout") || error.message?.includes("ETIMEDOUT") || error.originalError?.code === "ETIMEOUT" || error.originalError?.code === "ESOCKET";
@@ -903,7 +923,7 @@ tableRoutes.post("/:schema/:table/related-data", async (req, res) => {
903
923
  console.error("Error fetching related data:", error);
904
924
  const errorMessage = error.message || "";
905
925
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
906
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
926
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
907
927
  await disconnect2();
908
928
  }
909
929
  res.status(500).json({ error: error.message || "Failed to fetch related data" });
@@ -1080,7 +1100,7 @@ tableRoutes.get("/:schema/:table/distinct-values/:column", async (req, res) => {
1080
1100
  console.error("Error fetching distinct values:", error);
1081
1101
  const errorMessage = error.message || "";
1082
1102
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1083
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1103
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1084
1104
  await disconnect2();
1085
1105
  }
1086
1106
  res.status(500).json({ error: error.message || "Failed to fetch distinct values" });
@@ -1146,7 +1166,7 @@ tableRoutes.get("/:schema/:table/reverse-foreign-keys", async (req, res) => {
1146
1166
  console.error("Error fetching reverse foreign keys:", error);
1147
1167
  const errorMessage = error.message || "";
1148
1168
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1149
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1169
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1150
1170
  await disconnect2();
1151
1171
  }
1152
1172
  res.status(500).json({ error: error.message || "Failed to fetch reverse foreign keys" });
@@ -1205,7 +1225,7 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
1205
1225
  console.error("Error counting related rows:", error);
1206
1226
  const errorMessage = error.message || "";
1207
1227
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1208
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1228
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1209
1229
  await disconnect2();
1210
1230
  }
1211
1231
  res.status(500).json({ error: error.message || "Failed to count related rows" });
@@ -1243,7 +1263,7 @@ queryRoutes.post("/", async (req, res) => {
1243
1263
  }
1244
1264
  const errorMessage = error.message || "";
1245
1265
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1246
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1266
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1247
1267
  await disconnect2();
1248
1268
  }
1249
1269
  res.status(500).json({
package/dist/cli/index.js CHANGED
@@ -6,11 +6,13 @@ import {
6
6
  executeQuery,
7
7
  executeQueryMultiple,
8
8
  getConnection,
9
+ getConnectionConfig,
9
10
  getDbType,
10
11
  getDialect,
12
+ parseConnectionString,
11
13
  setDbType,
12
14
  testConnection
13
- } from "./chunk-CK2O76SG.js";
15
+ } from "./chunk-B5ENJPHN.js";
14
16
  import {
15
17
  cancelQuery,
16
18
  generateQueryId
@@ -124,7 +126,25 @@ connectionRoutes.get("/status", async (req, res) => {
124
126
  const dialect = getDialect();
125
127
  const result = await executeQuery(dialect.currentDbQuery());
126
128
  const databaseName = result[0]?.databaseName || null;
127
- res.json({ connected: true, databaseName });
129
+ let connConfig = getConnectionConfig();
130
+ if (!connConfig && databaseName) {
131
+ const connString = getProvidedConnectionString();
132
+ if (connString) {
133
+ try {
134
+ const parsed = parseConnectionString(connString);
135
+ if (parsed.server && parsed.database && parsed.database.toLowerCase() === databaseName.toLowerCase()) {
136
+ const dbType = connString.trim().startsWith("postgresql://") || connString.trim().startsWith("postgres://") ? "postgres" : "mssql";
137
+ connConfig = { server: parsed.server, database: parsed.database, dbType };
138
+ }
139
+ } catch {
140
+ }
141
+ }
142
+ }
143
+ res.json({
144
+ connected: true,
145
+ databaseName,
146
+ ...connConfig && { server: connConfig.server, database: connConfig.database, dbType: connConfig.dbType }
147
+ });
128
148
  } catch (error) {
129
149
  const errorMessage = error.message || "";
130
150
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
@@ -173,7 +193,7 @@ tableRoutes.get("/", async (req, res) => {
173
193
  console.error("Error fetching tables:", error);
174
194
  const errorMessage = error.message || "";
175
195
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
176
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
196
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
177
197
  await disconnect2();
178
198
  }
179
199
  const errorDetails = error.originalError?.message || error.originalError?.info?.message || error.message || "Failed to fetch tables";
@@ -249,7 +269,7 @@ tableRoutes.get("/:schema/:table", async (req, res) => {
249
269
  } catch (error) {
250
270
  const errorMessage = error.message || "";
251
271
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
252
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
272
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
253
273
  await disconnect2();
254
274
  }
255
275
  res.status(500).json({ error: error.message || "Failed to fetch table structure" });
@@ -805,7 +825,7 @@ ${limitOffsetClause}`;
805
825
  console.error("Error fetching table data:", error);
806
826
  const errorMessage = error.message || "";
807
827
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
808
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
828
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
809
829
  await disconnect2();
810
830
  }
811
831
  const isTimeout = error.code === "ETIMEOUT" || error.code === "ESOCKET" || error.message?.includes("timeout") || error.message?.includes("ETIMEDOUT") || error.originalError?.code === "ETIMEOUT" || error.originalError?.code === "ESOCKET";
@@ -906,7 +926,7 @@ tableRoutes.post("/:schema/:table/related-data", async (req, res) => {
906
926
  console.error("Error fetching related data:", error);
907
927
  const errorMessage = error.message || "";
908
928
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
909
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
929
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
910
930
  await disconnect2();
911
931
  }
912
932
  res.status(500).json({ error: error.message || "Failed to fetch related data" });
@@ -1083,7 +1103,7 @@ tableRoutes.get("/:schema/:table/distinct-values/:column", async (req, res) => {
1083
1103
  console.error("Error fetching distinct values:", error);
1084
1104
  const errorMessage = error.message || "";
1085
1105
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1086
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1106
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1087
1107
  await disconnect2();
1088
1108
  }
1089
1109
  res.status(500).json({ error: error.message || "Failed to fetch distinct values" });
@@ -1149,7 +1169,7 @@ tableRoutes.get("/:schema/:table/reverse-foreign-keys", async (req, res) => {
1149
1169
  console.error("Error fetching reverse foreign keys:", error);
1150
1170
  const errorMessage = error.message || "";
1151
1171
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1152
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1172
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1153
1173
  await disconnect2();
1154
1174
  }
1155
1175
  res.status(500).json({ error: error.message || "Failed to fetch reverse foreign keys" });
@@ -1208,7 +1228,7 @@ tableRoutes.post("/:schema/:table/count-related", async (req, res) => {
1208
1228
  console.error("Error counting related rows:", error);
1209
1229
  const errorMessage = error.message || "";
1210
1230
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1211
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1231
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1212
1232
  await disconnect2();
1213
1233
  }
1214
1234
  res.status(500).json({ error: error.message || "Failed to count related rows" });
@@ -1246,7 +1266,7 @@ queryRoutes.post("/", async (req, res) => {
1246
1266
  }
1247
1267
  const errorMessage = error.message || "";
1248
1268
  if (errorMessage.includes("Login failed") || errorMessage.includes("authentication") || errorMessage.includes("password authentication")) {
1249
- const { disconnect: disconnect2 } = await import("./db-OIJ2PJK6.js");
1269
+ const { disconnect: disconnect2 } = await import("./db-2XNNFT6D.js");
1250
1270
  await disconnect2();
1251
1271
  }
1252
1272
  res.status(500).json({