@squadbase/vite-server 0.1.10-dev.d23e546 → 0.1.11-dev.0c78963
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/index.js +275 -134
- package/dist/connectors/cosmosdb.js +2 -2
- package/dist/connectors/mongodb.d.ts +5 -0
- package/dist/connectors/mongodb.js +879 -0
- package/dist/connectors/oracle.js +1 -1
- package/dist/index.js +275 -134
- package/dist/main.js +275 -134
- package/dist/vite-plugin.js +275 -134
- package/package.json +5 -1
package/dist/main.js
CHANGED
|
@@ -363,6 +363,37 @@ import { z } from "zod";
|
|
|
363
363
|
|
|
364
364
|
// ../connectors/src/connectors/snowflake/utils.ts
|
|
365
365
|
import crypto from "crypto";
|
|
366
|
+
|
|
367
|
+
// ../connectors/src/lib/approx-bytes.ts
|
|
368
|
+
function approxBytes(value, acc, limit) {
|
|
369
|
+
if (acc > limit) return acc;
|
|
370
|
+
if (value == null) return acc;
|
|
371
|
+
const t = typeof value;
|
|
372
|
+
if (t === "string") return acc + value.length;
|
|
373
|
+
if (t === "number" || t === "boolean") return acc + 8;
|
|
374
|
+
if (t === "bigint") return acc + 16;
|
|
375
|
+
if (value instanceof Date) return acc + 8;
|
|
376
|
+
if (Buffer.isBuffer(value)) return acc + value.byteLength;
|
|
377
|
+
if (Array.isArray(value)) {
|
|
378
|
+
for (const item of value) {
|
|
379
|
+
acc = approxBytes(item, acc, limit);
|
|
380
|
+
if (acc > limit) return acc;
|
|
381
|
+
}
|
|
382
|
+
return acc;
|
|
383
|
+
}
|
|
384
|
+
if (t === "object") {
|
|
385
|
+
const obj = value;
|
|
386
|
+
for (const k in obj) {
|
|
387
|
+
acc += k.length;
|
|
388
|
+
acc = approxBytes(obj[k], acc, limit);
|
|
389
|
+
if (acc > limit) return acc;
|
|
390
|
+
}
|
|
391
|
+
return acc;
|
|
392
|
+
}
|
|
393
|
+
return acc;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// ../connectors/src/connectors/snowflake/utils.ts
|
|
366
397
|
function decryptPrivateKey(pem, passphrase) {
|
|
367
398
|
if (!passphrase) return pem;
|
|
368
399
|
return crypto.createPrivateKey({
|
|
@@ -371,10 +402,46 @@ function decryptPrivateKey(pem, passphrase) {
|
|
|
371
402
|
passphrase
|
|
372
403
|
}).export({ type: "pkcs8", format: "pem" });
|
|
373
404
|
}
|
|
405
|
+
async function executeWithSizeLimit(conn, sql, options) {
|
|
406
|
+
const rows = [];
|
|
407
|
+
let acc = 0;
|
|
408
|
+
let exceeded = false;
|
|
409
|
+
await new Promise((resolve, reject) => {
|
|
410
|
+
const stmt = conn.execute({
|
|
411
|
+
sqlText: sql,
|
|
412
|
+
streamResult: true
|
|
413
|
+
});
|
|
414
|
+
const stream = stmt.streamRows();
|
|
415
|
+
stream.on("data", (row) => {
|
|
416
|
+
if (exceeded) return;
|
|
417
|
+
acc = approxBytes(row, acc, options.maxBytes);
|
|
418
|
+
if (acc > options.maxBytes) {
|
|
419
|
+
exceeded = true;
|
|
420
|
+
stream.destroy();
|
|
421
|
+
stmt.cancel(() => {
|
|
422
|
+
});
|
|
423
|
+
resolve();
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
rows.push(row);
|
|
427
|
+
});
|
|
428
|
+
stream.on("end", () => {
|
|
429
|
+
resolve();
|
|
430
|
+
});
|
|
431
|
+
stream.on("error", (err) => {
|
|
432
|
+
if (exceeded) return;
|
|
433
|
+
reject(new Error(`Snowflake query failed: ${err.message}`));
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
if (exceeded) {
|
|
437
|
+
return { exceeded: true };
|
|
438
|
+
}
|
|
439
|
+
return { exceeded: false, rows };
|
|
440
|
+
}
|
|
374
441
|
|
|
375
442
|
// ../connectors/src/connectors/snowflake/tools/execute-query.ts
|
|
376
|
-
var
|
|
377
|
-
var
|
|
443
|
+
var MAX_RESULT_BYTES = 5 * 1024 * 1024;
|
|
444
|
+
var STATEMENT_TIMEOUT_SECONDS = 60;
|
|
378
445
|
var inputSchema = z.object({
|
|
379
446
|
toolUseIntent: z.string().optional().describe(
|
|
380
447
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -388,7 +455,6 @@ var outputSchema = z.discriminatedUnion("success", [
|
|
|
388
455
|
z.object({
|
|
389
456
|
success: z.literal(true),
|
|
390
457
|
rowCount: z.number(),
|
|
391
|
-
truncated: z.boolean(),
|
|
392
458
|
rows: z.array(z.record(z.string(), z.unknown()))
|
|
393
459
|
}),
|
|
394
460
|
z.object({
|
|
@@ -398,9 +464,12 @@ var outputSchema = z.discriminatedUnion("success", [
|
|
|
398
464
|
]);
|
|
399
465
|
var executeQueryTool = new ConnectorTool({
|
|
400
466
|
name: "executeQuery",
|
|
401
|
-
description: `Execute SQL against Snowflake.
|
|
402
|
-
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA),
|
|
403
|
-
|
|
467
|
+
description: `Execute SQL against Snowflake. Results are streamed; if the approximate result size exceeds 5MB the call fails with an explicit error and you must retry with a smaller query (add LIMIT, wrap wide text columns with SUBSTR, or aggregate inside Snowflake).
|
|
468
|
+
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), sampling (LIMIT, SAMPLE), and analytical queries.
|
|
469
|
+
Memory guidance:
|
|
470
|
+
- Avoid SELECT * on tables with long text columns (logs, JSON, concatenated text). Project only the columns you need; truncate wide text with SUBSTR(col, 1, N).
|
|
471
|
+
- For full-dataset analysis, do the aggregation inside Snowflake (COUNT, SUM, GROUP BY, APPROX_TOP_K, HISTOGRAM) instead of returning raw rows.
|
|
472
|
+
- Exploration is iterative: start with a small LIMIT to inspect shape, then refine.`,
|
|
404
473
|
inputSchema,
|
|
405
474
|
outputSchema,
|
|
406
475
|
async execute({ connectionId, sql }, connections) {
|
|
@@ -442,39 +511,43 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
442
511
|
else resolve();
|
|
443
512
|
});
|
|
444
513
|
});
|
|
445
|
-
|
|
446
|
-
(resolve, reject) => {
|
|
447
|
-
const timeoutId = setTimeout(() => {
|
|
448
|
-
reject(
|
|
449
|
-
new Error(
|
|
450
|
-
"Snowflake query timeout: query exceeded 60 seconds"
|
|
451
|
-
)
|
|
452
|
-
);
|
|
453
|
-
}, QUERY_TIMEOUT_MS);
|
|
514
|
+
try {
|
|
515
|
+
await new Promise((resolve, reject) => {
|
|
454
516
|
conn.execute({
|
|
455
|
-
sqlText:
|
|
456
|
-
complete: (err
|
|
457
|
-
clearTimeout(timeoutId);
|
|
517
|
+
sqlText: `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${STATEMENT_TIMEOUT_SECONDS}`,
|
|
518
|
+
complete: (err) => {
|
|
458
519
|
if (err)
|
|
459
|
-
reject(
|
|
460
|
-
|
|
520
|
+
reject(
|
|
521
|
+
new Error(
|
|
522
|
+
`Failed to set Snowflake statement timeout: ${err.message}`
|
|
523
|
+
)
|
|
524
|
+
);
|
|
525
|
+
else resolve();
|
|
461
526
|
}
|
|
462
527
|
});
|
|
528
|
+
});
|
|
529
|
+
const result = await executeWithSizeLimit(conn, sql, {
|
|
530
|
+
maxBytes: MAX_RESULT_BYTES
|
|
531
|
+
});
|
|
532
|
+
if (result.exceeded) {
|
|
533
|
+
return {
|
|
534
|
+
success: false,
|
|
535
|
+
error: "Result size exceeded 5MB. Reduce the query: add LIMIT, wrap wide text columns with SUBSTR(col, 1, N), or aggregate inside Snowflake (COUNT/SUM/GROUP BY)."
|
|
536
|
+
};
|
|
463
537
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
};
|
|
538
|
+
return {
|
|
539
|
+
success: true,
|
|
540
|
+
rowCount: result.rows.length,
|
|
541
|
+
rows: result.rows
|
|
542
|
+
};
|
|
543
|
+
} finally {
|
|
544
|
+
conn.destroy((err) => {
|
|
545
|
+
if (err)
|
|
546
|
+
console.warn(
|
|
547
|
+
`[connector-query] Snowflake destroy error: ${err.message}`
|
|
548
|
+
);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
478
551
|
} catch (err) {
|
|
479
552
|
const msg = err instanceof Error ? err.message : String(err);
|
|
480
553
|
return { success: false, error: msg };
|
|
@@ -663,8 +736,8 @@ var parameters2 = {
|
|
|
663
736
|
|
|
664
737
|
// ../connectors/src/connectors/snowflake-pat/tools/execute-query.ts
|
|
665
738
|
import { z as z2 } from "zod";
|
|
666
|
-
var
|
|
667
|
-
var
|
|
739
|
+
var MAX_ROWS = 500;
|
|
740
|
+
var QUERY_TIMEOUT_MS = 6e4;
|
|
668
741
|
var inputSchema2 = z2.object({
|
|
669
742
|
toolUseIntent: z2.string().optional().describe(
|
|
670
743
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -688,7 +761,7 @@ var outputSchema2 = z2.discriminatedUnion("success", [
|
|
|
688
761
|
]);
|
|
689
762
|
var executeQueryTool2 = new ConnectorTool({
|
|
690
763
|
name: "executeQuery",
|
|
691
|
-
description: `Execute SQL against Snowflake. Returns up to ${
|
|
764
|
+
description: `Execute SQL against Snowflake. Returns up to ${MAX_ROWS} rows.
|
|
692
765
|
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
693
766
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
694
767
|
inputSchema: inputSchema2,
|
|
@@ -734,7 +807,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
734
807
|
"Snowflake query timeout: query exceeded 60 seconds"
|
|
735
808
|
)
|
|
736
809
|
);
|
|
737
|
-
},
|
|
810
|
+
}, QUERY_TIMEOUT_MS);
|
|
738
811
|
conn.execute({
|
|
739
812
|
sqlText: sql,
|
|
740
813
|
complete: (err, _stmt, rows) => {
|
|
@@ -752,12 +825,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
752
825
|
`[connector-query] Snowflake destroy error: ${err.message}`
|
|
753
826
|
);
|
|
754
827
|
});
|
|
755
|
-
const truncated = allRows.length >
|
|
828
|
+
const truncated = allRows.length > MAX_ROWS;
|
|
756
829
|
return {
|
|
757
830
|
success: true,
|
|
758
|
-
rowCount: Math.min(allRows.length,
|
|
831
|
+
rowCount: Math.min(allRows.length, MAX_ROWS),
|
|
759
832
|
truncated,
|
|
760
|
-
rows: allRows.slice(0,
|
|
833
|
+
rows: allRows.slice(0, MAX_ROWS)
|
|
761
834
|
};
|
|
762
835
|
} catch (err) {
|
|
763
836
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -1091,7 +1164,7 @@ var POSTGRES_DEFAULT_PORT = 5432;
|
|
|
1091
1164
|
|
|
1092
1165
|
// ../connectors/src/connectors/postgresql/tools/execute-query.ts
|
|
1093
1166
|
import { z as z3 } from "zod";
|
|
1094
|
-
var
|
|
1167
|
+
var MAX_ROWS2 = 500;
|
|
1095
1168
|
var CONNECT_TIMEOUT_MS = 1e4;
|
|
1096
1169
|
var STATEMENT_TIMEOUT_MS = 6e4;
|
|
1097
1170
|
var inputSchema3 = z3.object({
|
|
@@ -1115,7 +1188,7 @@ var outputSchema3 = z3.discriminatedUnion("success", [
|
|
|
1115
1188
|
]);
|
|
1116
1189
|
var executeQueryTool3 = new ConnectorTool({
|
|
1117
1190
|
name: "executeQuery",
|
|
1118
|
-
description: `Execute SQL against PostgreSQL. Returns up to ${
|
|
1191
|
+
description: `Execute SQL against PostgreSQL. Returns up to ${MAX_ROWS2} rows.
|
|
1119
1192
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
1120
1193
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1121
1194
|
inputSchema: inputSchema3,
|
|
@@ -1153,12 +1226,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1153
1226
|
STATEMENT_TIMEOUT_MS
|
|
1154
1227
|
);
|
|
1155
1228
|
const rows = result.rows;
|
|
1156
|
-
const truncated = rows.length >
|
|
1229
|
+
const truncated = rows.length > MAX_ROWS2;
|
|
1157
1230
|
return {
|
|
1158
1231
|
success: true,
|
|
1159
|
-
rowCount: Math.min(rows.length,
|
|
1232
|
+
rowCount: Math.min(rows.length, MAX_ROWS2),
|
|
1160
1233
|
truncated,
|
|
1161
|
-
rows: rows.slice(0,
|
|
1234
|
+
rows: rows.slice(0, MAX_ROWS2)
|
|
1162
1235
|
};
|
|
1163
1236
|
} finally {
|
|
1164
1237
|
await pool.end();
|
|
@@ -1295,9 +1368,9 @@ var MYSQL_DEFAULT_PORT = 3306;
|
|
|
1295
1368
|
|
|
1296
1369
|
// ../connectors/src/connectors/mysql/tools/execute-query.ts
|
|
1297
1370
|
import { z as z4 } from "zod";
|
|
1298
|
-
var
|
|
1371
|
+
var MAX_ROWS3 = 500;
|
|
1299
1372
|
var CONNECT_TIMEOUT_MS2 = 1e4;
|
|
1300
|
-
var
|
|
1373
|
+
var QUERY_TIMEOUT_MS2 = 6e4;
|
|
1301
1374
|
var inputSchema4 = z4.object({
|
|
1302
1375
|
toolUseIntent: z4.string().optional().describe(
|
|
1303
1376
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -1319,7 +1392,7 @@ var outputSchema4 = z4.discriminatedUnion("success", [
|
|
|
1319
1392
|
]);
|
|
1320
1393
|
var executeQueryTool4 = new ConnectorTool({
|
|
1321
1394
|
name: "executeQuery",
|
|
1322
|
-
description: `Execute SQL against MySQL. Returns up to ${
|
|
1395
|
+
description: `Execute SQL against MySQL. Returns up to ${MAX_ROWS3} rows.
|
|
1323
1396
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
1324
1397
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1325
1398
|
inputSchema: inputSchema4,
|
|
@@ -1352,16 +1425,16 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1352
1425
|
try {
|
|
1353
1426
|
const queryPromise = pool.query(sql);
|
|
1354
1427
|
const timeoutPromise = new Promise(
|
|
1355
|
-
(_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")),
|
|
1428
|
+
(_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")), QUERY_TIMEOUT_MS2)
|
|
1356
1429
|
);
|
|
1357
1430
|
const [rows] = await Promise.race([queryPromise, timeoutPromise]);
|
|
1358
1431
|
const resultRows = Array.isArray(rows) ? rows : [];
|
|
1359
|
-
const truncated = resultRows.length >
|
|
1432
|
+
const truncated = resultRows.length > MAX_ROWS3;
|
|
1360
1433
|
return {
|
|
1361
1434
|
success: true,
|
|
1362
|
-
rowCount: Math.min(resultRows.length,
|
|
1435
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS3),
|
|
1363
1436
|
truncated,
|
|
1364
|
-
rows: resultRows.slice(0,
|
|
1437
|
+
rows: resultRows.slice(0, MAX_ROWS3)
|
|
1365
1438
|
};
|
|
1366
1439
|
} finally {
|
|
1367
1440
|
await pool.end();
|
|
@@ -1688,7 +1761,7 @@ var bigqueryOnboarding = new ConnectorOnboarding({
|
|
|
1688
1761
|
|
|
1689
1762
|
// ../connectors/src/connectors/bigquery/tools/execute-query.ts
|
|
1690
1763
|
import { z as z7 } from "zod";
|
|
1691
|
-
var
|
|
1764
|
+
var MAX_ROWS4 = 500;
|
|
1692
1765
|
var inputSchema7 = z7.object({
|
|
1693
1766
|
toolUseIntent: z7.string().optional().describe(
|
|
1694
1767
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -1712,7 +1785,7 @@ var outputSchema7 = z7.discriminatedUnion("success", [
|
|
|
1712
1785
|
]);
|
|
1713
1786
|
var executeQueryTool5 = new ConnectorTool({
|
|
1714
1787
|
name: "executeQuery",
|
|
1715
|
-
description: `Execute SQL against BigQuery. Returns up to ${
|
|
1788
|
+
description: `Execute SQL against BigQuery. Returns up to ${MAX_ROWS4} rows.
|
|
1716
1789
|
Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
1717
1790
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1718
1791
|
inputSchema: inputSchema7,
|
|
@@ -1739,12 +1812,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1739
1812
|
const [job] = await bq.createQueryJob({ query: sql });
|
|
1740
1813
|
const [rows] = await job.getQueryResults();
|
|
1741
1814
|
const allRows = rows;
|
|
1742
|
-
const truncated = allRows.length >
|
|
1815
|
+
const truncated = allRows.length > MAX_ROWS4;
|
|
1743
1816
|
return {
|
|
1744
1817
|
success: true,
|
|
1745
|
-
rowCount: Math.min(allRows.length,
|
|
1818
|
+
rowCount: Math.min(allRows.length, MAX_ROWS4),
|
|
1746
1819
|
truncated,
|
|
1747
|
-
rows: allRows.slice(0,
|
|
1820
|
+
rows: allRows.slice(0, MAX_ROWS4)
|
|
1748
1821
|
};
|
|
1749
1822
|
} catch (err) {
|
|
1750
1823
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -2145,7 +2218,7 @@ var bigqueryOnboarding2 = new ConnectorOnboarding({
|
|
|
2145
2218
|
|
|
2146
2219
|
// ../connectors/src/connectors/bigquery-oauth/tools/execute-query.ts
|
|
2147
2220
|
import { z as z10 } from "zod";
|
|
2148
|
-
var
|
|
2221
|
+
var MAX_ROWS5 = 500;
|
|
2149
2222
|
var REQUEST_TIMEOUT_MS3 = 6e4;
|
|
2150
2223
|
var cachedToken3 = null;
|
|
2151
2224
|
async function getProxyToken3(config) {
|
|
@@ -2212,7 +2285,7 @@ function parseQueryResponse(data) {
|
|
|
2212
2285
|
}
|
|
2213
2286
|
var executeQueryTool6 = new ConnectorTool({
|
|
2214
2287
|
name: "executeQuery",
|
|
2215
|
-
description: `Execute SQL against BigQuery via OAuth. Returns up to ${
|
|
2288
|
+
description: `Execute SQL against BigQuery via OAuth. Returns up to ${MAX_ROWS5} rows.
|
|
2216
2289
|
Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
2217
2290
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
2218
2291
|
inputSchema: inputSchema10,
|
|
@@ -2245,7 +2318,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2245
2318
|
body: JSON.stringify({
|
|
2246
2319
|
url: queryUrl,
|
|
2247
2320
|
method: "POST",
|
|
2248
|
-
body: { query: sql, useLegacySql: false, maxResults:
|
|
2321
|
+
body: { query: sql, useLegacySql: false, maxResults: MAX_ROWS5 }
|
|
2249
2322
|
}),
|
|
2250
2323
|
signal: controller.signal
|
|
2251
2324
|
});
|
|
@@ -2255,12 +2328,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2255
2328
|
return { success: false, error: errorMessage };
|
|
2256
2329
|
}
|
|
2257
2330
|
const rows = parseQueryResponse(data);
|
|
2258
|
-
const truncated = rows.length >
|
|
2331
|
+
const truncated = rows.length > MAX_ROWS5;
|
|
2259
2332
|
return {
|
|
2260
2333
|
success: true,
|
|
2261
|
-
rowCount: Math.min(rows.length,
|
|
2334
|
+
rowCount: Math.min(rows.length, MAX_ROWS5),
|
|
2262
2335
|
truncated,
|
|
2263
|
-
rows: rows.slice(0,
|
|
2336
|
+
rows: rows.slice(0, MAX_ROWS5)
|
|
2264
2337
|
};
|
|
2265
2338
|
} finally {
|
|
2266
2339
|
clearTimeout(timeout);
|
|
@@ -2440,7 +2513,7 @@ var parameters7 = {
|
|
|
2440
2513
|
|
|
2441
2514
|
// ../connectors/src/connectors/aws-athena/tools/execute-query.ts
|
|
2442
2515
|
import { z as z11 } from "zod";
|
|
2443
|
-
var
|
|
2516
|
+
var MAX_ROWS6 = 500;
|
|
2444
2517
|
var POLL_INTERVAL_MS = 1e3;
|
|
2445
2518
|
var POLL_TIMEOUT_MS = 12e4;
|
|
2446
2519
|
var inputSchema11 = z11.object({
|
|
@@ -2464,7 +2537,7 @@ var outputSchema11 = z11.discriminatedUnion("success", [
|
|
|
2464
2537
|
]);
|
|
2465
2538
|
var executeQueryTool7 = new ConnectorTool({
|
|
2466
2539
|
name: "executeQuery",
|
|
2467
|
-
description: `Execute SQL against AWS Athena. Returns up to ${
|
|
2540
|
+
description: `Execute SQL against AWS Athena. Returns up to ${MAX_ROWS6} rows.
|
|
2468
2541
|
Use for: schema exploration (SHOW DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries on S3 data.
|
|
2469
2542
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
2470
2543
|
inputSchema: inputSchema11,
|
|
@@ -2541,12 +2614,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2541
2614
|
});
|
|
2542
2615
|
return obj;
|
|
2543
2616
|
});
|
|
2544
|
-
const truncated = dataRows.length >
|
|
2617
|
+
const truncated = dataRows.length > MAX_ROWS6;
|
|
2545
2618
|
return {
|
|
2546
2619
|
success: true,
|
|
2547
|
-
rowCount: Math.min(dataRows.length,
|
|
2620
|
+
rowCount: Math.min(dataRows.length, MAX_ROWS6),
|
|
2548
2621
|
truncated,
|
|
2549
|
-
rows: dataRows.slice(0,
|
|
2622
|
+
rows: dataRows.slice(0, MAX_ROWS6)
|
|
2550
2623
|
};
|
|
2551
2624
|
} catch (err) {
|
|
2552
2625
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -3461,7 +3534,7 @@ var parameters9 = {
|
|
|
3461
3534
|
|
|
3462
3535
|
// ../connectors/src/connectors/redshift/tools/execute-query.ts
|
|
3463
3536
|
import { z as z15 } from "zod";
|
|
3464
|
-
var
|
|
3537
|
+
var MAX_ROWS7 = 500;
|
|
3465
3538
|
var POLL_INTERVAL_MS2 = 1e3;
|
|
3466
3539
|
var POLL_TIMEOUT_MS2 = 12e4;
|
|
3467
3540
|
var inputSchema15 = z15.object({
|
|
@@ -3487,7 +3560,7 @@ var outputSchema15 = z15.discriminatedUnion("success", [
|
|
|
3487
3560
|
]);
|
|
3488
3561
|
var executeQueryTool8 = new ConnectorTool({
|
|
3489
3562
|
name: "executeQuery",
|
|
3490
|
-
description: `Execute SQL against Amazon Redshift. Returns up to ${
|
|
3563
|
+
description: `Execute SQL against Amazon Redshift. Returns up to ${MAX_ROWS7} rows.
|
|
3491
3564
|
Use for: schema exploration, data sampling, analytical queries.
|
|
3492
3565
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
3493
3566
|
inputSchema: inputSchema15,
|
|
@@ -3566,12 +3639,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
3566
3639
|
});
|
|
3567
3640
|
return row;
|
|
3568
3641
|
});
|
|
3569
|
-
const truncated = allRows.length >
|
|
3642
|
+
const truncated = allRows.length > MAX_ROWS7;
|
|
3570
3643
|
return {
|
|
3571
3644
|
success: true,
|
|
3572
|
-
rowCount: Math.min(allRows.length,
|
|
3645
|
+
rowCount: Math.min(allRows.length, MAX_ROWS7),
|
|
3573
3646
|
truncated,
|
|
3574
|
-
rows: allRows.slice(0,
|
|
3647
|
+
rows: allRows.slice(0, MAX_ROWS7)
|
|
3575
3648
|
};
|
|
3576
3649
|
} catch (err) {
|
|
3577
3650
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -3792,7 +3865,7 @@ var parameters10 = {
|
|
|
3792
3865
|
|
|
3793
3866
|
// ../connectors/src/connectors/databricks/tools/execute-query.ts
|
|
3794
3867
|
import { z as z16 } from "zod";
|
|
3795
|
-
var
|
|
3868
|
+
var MAX_ROWS8 = 500;
|
|
3796
3869
|
var inputSchema16 = z16.object({
|
|
3797
3870
|
toolUseIntent: z16.string().optional().describe(
|
|
3798
3871
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -3814,7 +3887,7 @@ var outputSchema16 = z16.discriminatedUnion("success", [
|
|
|
3814
3887
|
]);
|
|
3815
3888
|
var executeQueryTool9 = new ConnectorTool({
|
|
3816
3889
|
name: "executeQuery",
|
|
3817
|
-
description: `Execute SQL against Databricks. Returns up to ${
|
|
3890
|
+
description: `Execute SQL against Databricks. Returns up to ${MAX_ROWS8} rows.
|
|
3818
3891
|
Use for: schema exploration (SHOW CATALOGS/DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries.
|
|
3819
3892
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
3820
3893
|
inputSchema: inputSchema16,
|
|
@@ -3845,12 +3918,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
3845
3918
|
runAsync: true
|
|
3846
3919
|
});
|
|
3847
3920
|
const allRows = await operation.fetchAll();
|
|
3848
|
-
const truncated = allRows.length >
|
|
3921
|
+
const truncated = allRows.length > MAX_ROWS8;
|
|
3849
3922
|
return {
|
|
3850
3923
|
success: true,
|
|
3851
|
-
rowCount: Math.min(allRows.length,
|
|
3924
|
+
rowCount: Math.min(allRows.length, MAX_ROWS8),
|
|
3852
3925
|
truncated,
|
|
3853
|
-
rows: allRows.slice(0,
|
|
3926
|
+
rows: allRows.slice(0, MAX_ROWS8)
|
|
3854
3927
|
};
|
|
3855
3928
|
} finally {
|
|
3856
3929
|
if (operation) await operation.close().catch(() => {
|
|
@@ -10795,7 +10868,7 @@ var parameters29 = {
|
|
|
10795
10868
|
|
|
10796
10869
|
// ../connectors/src/connectors/squadbase-db/tools/execute-query.ts
|
|
10797
10870
|
import { z as z40 } from "zod";
|
|
10798
|
-
var
|
|
10871
|
+
var MAX_ROWS9 = 500;
|
|
10799
10872
|
var CONNECT_TIMEOUT_MS3 = 1e4;
|
|
10800
10873
|
var STATEMENT_TIMEOUT_MS2 = 6e4;
|
|
10801
10874
|
var inputSchema40 = z40.object({
|
|
@@ -10819,7 +10892,7 @@ var outputSchema40 = z40.discriminatedUnion("success", [
|
|
|
10819
10892
|
]);
|
|
10820
10893
|
var executeQueryTool10 = new ConnectorTool({
|
|
10821
10894
|
name: "executeQuery",
|
|
10822
|
-
description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${
|
|
10895
|
+
description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${MAX_ROWS9} rows.
|
|
10823
10896
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
10824
10897
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
10825
10898
|
inputSchema: inputSchema40,
|
|
@@ -10848,12 +10921,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
10848
10921
|
try {
|
|
10849
10922
|
const result = await pool.query(sql);
|
|
10850
10923
|
const rows = result.rows;
|
|
10851
|
-
const truncated = rows.length >
|
|
10924
|
+
const truncated = rows.length > MAX_ROWS9;
|
|
10852
10925
|
return {
|
|
10853
10926
|
success: true,
|
|
10854
|
-
rowCount: Math.min(rows.length,
|
|
10927
|
+
rowCount: Math.min(rows.length, MAX_ROWS9),
|
|
10855
10928
|
truncated,
|
|
10856
|
-
rows: rows.slice(0,
|
|
10929
|
+
rows: rows.slice(0, MAX_ROWS9)
|
|
10857
10930
|
};
|
|
10858
10931
|
} finally {
|
|
10859
10932
|
await pool.end();
|
|
@@ -13627,8 +13700,8 @@ var parameters41 = {
|
|
|
13627
13700
|
|
|
13628
13701
|
// ../connectors/src/connectors/clickhouse/tools/execute-query.ts
|
|
13629
13702
|
import { z as z49 } from "zod";
|
|
13630
|
-
var
|
|
13631
|
-
var
|
|
13703
|
+
var MAX_ROWS10 = 500;
|
|
13704
|
+
var QUERY_TIMEOUT_MS3 = 6e4;
|
|
13632
13705
|
var inputSchema49 = z49.object({
|
|
13633
13706
|
toolUseIntent: z49.string().optional().describe(
|
|
13634
13707
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -13650,7 +13723,7 @@ var outputSchema49 = z49.discriminatedUnion("success", [
|
|
|
13650
13723
|
]);
|
|
13651
13724
|
var executeQueryTool11 = new ConnectorTool({
|
|
13652
13725
|
name: "executeQuery",
|
|
13653
|
-
description: `Execute SQL against ClickHouse. Returns up to ${
|
|
13726
|
+
description: `Execute SQL against ClickHouse. Returns up to ${MAX_ROWS10} rows.
|
|
13654
13727
|
Use for: schema exploration (SHOW DATABASES, SHOW TABLES, DESCRIBE TABLE), data sampling, analytical queries on large-scale columnar data.
|
|
13655
13728
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
13656
13729
|
inputSchema: inputSchema49,
|
|
@@ -13678,7 +13751,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
13678
13751
|
username,
|
|
13679
13752
|
password: password || "",
|
|
13680
13753
|
database: database || "default",
|
|
13681
|
-
request_timeout:
|
|
13754
|
+
request_timeout: QUERY_TIMEOUT_MS3
|
|
13682
13755
|
});
|
|
13683
13756
|
try {
|
|
13684
13757
|
const resultSet = await client.query({
|
|
@@ -13686,12 +13759,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
13686
13759
|
format: "JSONEachRow"
|
|
13687
13760
|
});
|
|
13688
13761
|
const allRows = await resultSet.json();
|
|
13689
|
-
const truncated = allRows.length >
|
|
13762
|
+
const truncated = allRows.length > MAX_ROWS10;
|
|
13690
13763
|
return {
|
|
13691
13764
|
success: true,
|
|
13692
|
-
rowCount: Math.min(allRows.length,
|
|
13765
|
+
rowCount: Math.min(allRows.length, MAX_ROWS10),
|
|
13693
13766
|
truncated,
|
|
13694
|
-
rows: allRows.slice(0,
|
|
13767
|
+
rows: allRows.slice(0, MAX_ROWS10)
|
|
13695
13768
|
};
|
|
13696
13769
|
} finally {
|
|
13697
13770
|
await client.close();
|
|
@@ -13847,7 +13920,7 @@ var parameters42 = {
|
|
|
13847
13920
|
import { z as z50 } from "zod";
|
|
13848
13921
|
var MAX_DOCUMENTS = 500;
|
|
13849
13922
|
var CONNECT_TIMEOUT_MS4 = 1e4;
|
|
13850
|
-
var
|
|
13923
|
+
var QUERY_TIMEOUT_MS4 = 6e4;
|
|
13851
13924
|
var inputSchema50 = z50.object({
|
|
13852
13925
|
toolUseIntent: z50.string().optional().describe(
|
|
13853
13926
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -13906,7 +13979,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
|
|
|
13906
13979
|
const client = new MongoClient(connectionUrl, {
|
|
13907
13980
|
connectTimeoutMS: CONNECT_TIMEOUT_MS4,
|
|
13908
13981
|
serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS4,
|
|
13909
|
-
socketTimeoutMS:
|
|
13982
|
+
socketTimeoutMS: QUERY_TIMEOUT_MS4
|
|
13910
13983
|
});
|
|
13911
13984
|
try {
|
|
13912
13985
|
await client.connect();
|
|
@@ -13952,7 +14025,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
|
|
|
13952
14025
|
import { z as z51 } from "zod";
|
|
13953
14026
|
var MAX_DOCUMENTS2 = 500;
|
|
13954
14027
|
var CONNECT_TIMEOUT_MS5 = 1e4;
|
|
13955
|
-
var
|
|
14028
|
+
var QUERY_TIMEOUT_MS5 = 6e4;
|
|
13956
14029
|
var inputSchema51 = z51.object({
|
|
13957
14030
|
toolUseIntent: z51.string().optional().describe(
|
|
13958
14031
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -14003,7 +14076,7 @@ Common stages: $match (filter), $group (aggregate), $sort (order), $project (res
|
|
|
14003
14076
|
const client = new MongoClient(connectionUrl, {
|
|
14004
14077
|
connectTimeoutMS: CONNECT_TIMEOUT_MS5,
|
|
14005
14078
|
serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS5,
|
|
14006
|
-
socketTimeoutMS:
|
|
14079
|
+
socketTimeoutMS: QUERY_TIMEOUT_MS5
|
|
14007
14080
|
});
|
|
14008
14081
|
try {
|
|
14009
14082
|
await client.connect();
|
|
@@ -14136,7 +14209,41 @@ var mongodbConnector = new ConnectorPlugin({
|
|
|
14136
14209
|
|
|
14137
14210
|
### Business Logic
|
|
14138
14211
|
|
|
14139
|
-
The business logic type for this connector is "typescript".
|
|
14212
|
+
The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables, and do NOT \`import { MongoClient } from "mongodb"\` in handler code \u2014 the \`mongodb\` driver is not part of the user dashboard's runtime, only of the connector SDK.
|
|
14213
|
+
|
|
14214
|
+
\u26A0\uFE0F **The client returned by \`connection(connectionId)\` is NOT a raw \`mongodb\` \`MongoClient\`.** It is a thin wrapper that opens a fresh connection per call, runs the requested operation against the database configured on the connection, and converts BSON \`ObjectId\` values to their hex string for JSON-safe responses. The methods are:
|
|
14215
|
+
|
|
14216
|
+
- \`client.aggregate<T>(collection, pipeline, options?) => Promise<T[]>\` \u2014 runs an aggregation pipeline and returns the document array. Always include a \`$limit\` stage.
|
|
14217
|
+
- \`client.find<T>(collection, filter?, options?) => Promise<T[]>\` \u2014 \`options\` accepts \`{ projection?, sort?, limit?, skip? }\`. Always pass \`limit\`.
|
|
14218
|
+
- \`client.findOne<T>(collection, filter?, options?) => Promise<T | null>\` \u2014 convenience wrapper around \`find\` with \`limit: 1\`.
|
|
14219
|
+
- \`client.countDocuments(collection, filter?) => Promise<number>\` \u2014 accurate count (not \`estimatedDocumentCount\`).
|
|
14220
|
+
- \`client.listCollections() => Promise<{ name: string; type: string }[]>\` \u2014 collections in the configured database.
|
|
14221
|
+
|
|
14222
|
+
There is **no** \`client.db(...)\`, \`client.connect()\`, or raw cursor / \`MongoClient\` API exposed through this client \u2014 those calls fail with \`X is not a function\`.
|
|
14223
|
+
|
|
14224
|
+
\`\`\`ts
|
|
14225
|
+
import type { Context } from "hono";
|
|
14226
|
+
import { connection } from "@squadbase/vite-server/connectors/mongodb";
|
|
14227
|
+
|
|
14228
|
+
const mongo = connection("<connectionId>");
|
|
14229
|
+
|
|
14230
|
+
export default async function handler(_c: Context) {
|
|
14231
|
+
const rows = await mongo.aggregate<{ country: string; count: number }>(
|
|
14232
|
+
"<collectionName>",
|
|
14233
|
+
[
|
|
14234
|
+
{ $match: { country: { $nin: [null, ""] } } },
|
|
14235
|
+
{ $group: { _id: "$country", count: { $sum: 1 } } },
|
|
14236
|
+
{ $sort: { count: -1 } },
|
|
14237
|
+
{ $limit: 20 },
|
|
14238
|
+
{ $project: { _id: 0, country: "$_id", count: 1 } },
|
|
14239
|
+
],
|
|
14240
|
+
);
|
|
14241
|
+
|
|
14242
|
+
return new Response(JSON.stringify(rows), {
|
|
14243
|
+
headers: { "Content-Type": "application/json" },
|
|
14244
|
+
});
|
|
14245
|
+
}
|
|
14246
|
+
\`\`\`
|
|
14140
14247
|
|
|
14141
14248
|
### MongoDB Reference
|
|
14142
14249
|
- MongoDB stores data as flexible JSON-like documents (BSON)
|
|
@@ -14157,7 +14264,41 @@ The business logic type for this connector is "typescript".
|
|
|
14157
14264
|
|
|
14158
14265
|
### Business Logic
|
|
14159
14266
|
|
|
14160
|
-
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002
|
|
14267
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u305F\u308A\u3001\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3067 \`import { MongoClient } from "mongodb"\` \u3092\u884C\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 \`mongodb\` \u30C9\u30E9\u30A4\u30D0\u306F\u30E6\u30FC\u30B6\u30FC\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9\u306E\u30E9\u30F3\u30BF\u30A4\u30E0\u306B\u306F\u542B\u307E\u308C\u305A\u3001\u30B3\u30CD\u30AF\u30BFSDK\u5185\u90E8\u306B\u306E\u307F\u5B58\u5728\u3057\u307E\u3059\u3002
|
|
14268
|
+
|
|
14269
|
+
\u26A0\uFE0F **\`connection(connectionId)\` \u304C\u8FD4\u3059\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u306F \`mongodb\` \u306E \`MongoClient\` \u305D\u306E\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002** \u547C\u3073\u51FA\u3057\u3054\u3068\u306B\u65B0\u3057\u3044\u63A5\u7D9A\u3092\u958B\u304D\u3001\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u8A2D\u5B9A\u3055\u308C\u305F\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306B\u5BFE\u3057\u3066\u64CD\u4F5C\u3092\u5B9F\u884C\u3057\u3001BSON \u306E \`ObjectId\` \u3092 JSON \u5316\u306B\u5B89\u5168\u306A hex \u6587\u5B57\u5217\u306B\u5909\u63DB\u3059\u308B\u8584\u3044\u30E9\u30C3\u30D1\u30FC\u3067\u3059\u3002\u516C\u958B\u30E1\u30BD\u30C3\u30C9\u306F\u6B21\u306E\u3068\u304A\u308A\u3067\u3059\uFF1A
|
|
14270
|
+
|
|
14271
|
+
- \`client.aggregate<T>(collection, pipeline, options?) => Promise<T[]>\` \u2014 \u96C6\u7D04\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3\u3092\u5B9F\u884C\u3057\u3066\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u914D\u5217\u3092\u8FD4\u3059\u3002\`$limit\` \u30B9\u30C6\u30FC\u30B8\u3092\u5FC5\u305A\u542B\u3081\u308B\u3053\u3068\u3002
|
|
14272
|
+
- \`client.find<T>(collection, filter?, options?) => Promise<T[]>\` \u2014 \`options\` \u306F \`{ projection?, sort?, limit?, skip? }\`\u3002\`limit\` \u3092\u5FC5\u305A\u6307\u5B9A\u3059\u308B\u3053\u3068\u3002
|
|
14273
|
+
- \`client.findOne<T>(collection, filter?, options?) => Promise<T | null>\` \u2014 \`limit: 1\` \u3067\u306E \`find\` \u306E\u30E9\u30C3\u30D1\u30FC\u3002
|
|
14274
|
+
- \`client.countDocuments(collection, filter?) => Promise<number>\` \u2014 \u6B63\u78BA\u306A\u30AB\u30A6\u30F3\u30C8\uFF08\`estimatedDocumentCount\` \u3067\u306F\u306A\u3044\uFF09\u3002
|
|
14275
|
+
- \`client.listCollections() => Promise<{ name: string; type: string }[]>\` \u2014 \u8A2D\u5B9A\u3055\u308C\u305F\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u5185\u306E\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7\u3002
|
|
14276
|
+
|
|
14277
|
+
\`client.db(...)\`\u3001\`client.connect()\`\u3001\u751F\u306E\u30AB\u30FC\u30BD\u30EB\u3084 \`MongoClient\` API \u306F **\u5B58\u5728\u3057\u306A\u3044** \u2014 \`X is not a function\` \u3067\u5931\u6557\u3059\u308B\u3002
|
|
14278
|
+
|
|
14279
|
+
\`\`\`ts
|
|
14280
|
+
import type { Context } from "hono";
|
|
14281
|
+
import { connection } from "@squadbase/vite-server/connectors/mongodb";
|
|
14282
|
+
|
|
14283
|
+
const mongo = connection("<connectionId>");
|
|
14284
|
+
|
|
14285
|
+
export default async function handler(_c: Context) {
|
|
14286
|
+
const rows = await mongo.aggregate<{ country: string; count: number }>(
|
|
14287
|
+
"<collectionName>",
|
|
14288
|
+
[
|
|
14289
|
+
{ $match: { country: { $nin: [null, ""] } } },
|
|
14290
|
+
{ $group: { _id: "$country", count: { $sum: 1 } } },
|
|
14291
|
+
{ $sort: { count: -1 } },
|
|
14292
|
+
{ $limit: 20 },
|
|
14293
|
+
{ $project: { _id: 0, country: "$_id", count: 1 } },
|
|
14294
|
+
],
|
|
14295
|
+
);
|
|
14296
|
+
|
|
14297
|
+
return new Response(JSON.stringify(rows), {
|
|
14298
|
+
headers: { "Content-Type": "application/json" },
|
|
14299
|
+
});
|
|
14300
|
+
}
|
|
14301
|
+
\`\`\`
|
|
14161
14302
|
|
|
14162
14303
|
### MongoDB \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
14163
14304
|
- MongoDB\u306F\u30D5\u30EC\u30AD\u30B7\u30D6\u30EB\u306AJSON\u5F62\u5F0F\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\uFF08BSON\uFF09\u3068\u3057\u3066\u30C7\u30FC\u30BF\u3092\u683C\u7D0D\u3057\u307E\u3059
|
|
@@ -23164,7 +23305,7 @@ function redactJdbcUrl(jdbcUrl) {
|
|
|
23164
23305
|
}
|
|
23165
23306
|
|
|
23166
23307
|
// ../connectors/src/connectors/jdbc/tools/execute-query.ts
|
|
23167
|
-
var
|
|
23308
|
+
var MAX_ROWS11 = 500;
|
|
23168
23309
|
var CONNECT_TIMEOUT_MS7 = 1e4;
|
|
23169
23310
|
var STATEMENT_TIMEOUT_MS3 = 6e4;
|
|
23170
23311
|
var inputSchema82 = z82.object({
|
|
@@ -23190,7 +23331,7 @@ var outputSchema82 = z82.discriminatedUnion("success", [
|
|
|
23190
23331
|
]);
|
|
23191
23332
|
var executeQueryTool12 = new ConnectorTool({
|
|
23192
23333
|
name: "executeQuery",
|
|
23193
|
-
description: `Execute a SQL query through the JDBC connector. Returns up to ${
|
|
23334
|
+
description: `Execute a SQL query through the JDBC connector. Returns up to ${MAX_ROWS11} rows.
|
|
23194
23335
|
Use for: schema exploration via \`information_schema\` (or USER_TABLES on Oracle), data sampling, analytical queries.
|
|
23195
23336
|
The connector dispatches by JDBC URL prefix to the matching driver
|
|
23196
23337
|
(PostgreSQL / Redshift / MySQL / MariaDB / SQL Server / Oracle), so use the dialect that matches the connection.
|
|
@@ -23231,9 +23372,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23231
23372
|
const rows = result.rows;
|
|
23232
23373
|
return {
|
|
23233
23374
|
success: true,
|
|
23234
|
-
rowCount: Math.min(rows.length,
|
|
23235
|
-
truncated: rows.length >
|
|
23236
|
-
rows: rows.slice(0,
|
|
23375
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23376
|
+
truncated: rows.length > MAX_ROWS11,
|
|
23377
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23237
23378
|
};
|
|
23238
23379
|
}
|
|
23239
23380
|
if (parsed.driver === "oracle") {
|
|
@@ -23248,9 +23389,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23248
23389
|
const rows = result.rows;
|
|
23249
23390
|
return {
|
|
23250
23391
|
success: true,
|
|
23251
|
-
rowCount: Math.min(rows.length,
|
|
23252
|
-
truncated: rows.length >
|
|
23253
|
-
rows: rows.slice(0,
|
|
23392
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23393
|
+
truncated: rows.length > MAX_ROWS11,
|
|
23394
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23254
23395
|
};
|
|
23255
23396
|
}
|
|
23256
23397
|
let tunnel;
|
|
@@ -23274,12 +23415,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23274
23415
|
STATEMENT_TIMEOUT_MS3
|
|
23275
23416
|
);
|
|
23276
23417
|
const rows = result.rows;
|
|
23277
|
-
const truncated = rows.length >
|
|
23418
|
+
const truncated = rows.length > MAX_ROWS11;
|
|
23278
23419
|
return {
|
|
23279
23420
|
success: true,
|
|
23280
|
-
rowCount: Math.min(rows.length,
|
|
23421
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23281
23422
|
truncated,
|
|
23282
|
-
rows: rows.slice(0,
|
|
23423
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23283
23424
|
};
|
|
23284
23425
|
} finally {
|
|
23285
23426
|
await pool2.end();
|
|
@@ -23300,12 +23441,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23300
23441
|
);
|
|
23301
23442
|
const [rows] = await Promise.race([queryPromise, timeoutPromise]);
|
|
23302
23443
|
const resultRows = Array.isArray(rows) ? rows : [];
|
|
23303
|
-
const truncated = resultRows.length >
|
|
23444
|
+
const truncated = resultRows.length > MAX_ROWS11;
|
|
23304
23445
|
return {
|
|
23305
23446
|
success: true,
|
|
23306
|
-
rowCount: Math.min(resultRows.length,
|
|
23447
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS11),
|
|
23307
23448
|
truncated,
|
|
23308
|
-
rows: resultRows.slice(0,
|
|
23449
|
+
rows: resultRows.slice(0, MAX_ROWS11)
|
|
23309
23450
|
};
|
|
23310
23451
|
} finally {
|
|
23311
23452
|
await pool.end();
|
|
@@ -24574,7 +24715,7 @@ var parameters70 = {
|
|
|
24574
24715
|
|
|
24575
24716
|
// ../connectors/src/connectors/supabase/tools/execute-query.ts
|
|
24576
24717
|
import { z as z86 } from "zod";
|
|
24577
|
-
var
|
|
24718
|
+
var MAX_ROWS12 = 500;
|
|
24578
24719
|
var CONNECT_TIMEOUT_MS8 = 1e4;
|
|
24579
24720
|
var STATEMENT_TIMEOUT_MS4 = 6e4;
|
|
24580
24721
|
var inputSchema86 = z86.object({
|
|
@@ -24600,7 +24741,7 @@ var outputSchema86 = z86.discriminatedUnion("success", [
|
|
|
24600
24741
|
]);
|
|
24601
24742
|
var executeQueryTool13 = new ConnectorTool({
|
|
24602
24743
|
name: "executeQuery",
|
|
24603
|
-
description: `Execute SQL against a Supabase Postgres database. Returns up to ${
|
|
24744
|
+
description: `Execute SQL against a Supabase Postgres database. Returns up to ${MAX_ROWS12} rows.
|
|
24604
24745
|
Use for: schema exploration (information_schema), data sampling, and analytical queries against Supabase tables.
|
|
24605
24746
|
User tables live in the \`public\` schema by default; Supabase-managed metadata lives in \`auth\` and \`storage\`.
|
|
24606
24747
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
@@ -24630,12 +24771,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
24630
24771
|
try {
|
|
24631
24772
|
const result = await pool.query(sql);
|
|
24632
24773
|
const rows = result.rows;
|
|
24633
|
-
const truncated = rows.length >
|
|
24774
|
+
const truncated = rows.length > MAX_ROWS12;
|
|
24634
24775
|
return {
|
|
24635
24776
|
success: true,
|
|
24636
|
-
rowCount: Math.min(rows.length,
|
|
24777
|
+
rowCount: Math.min(rows.length, MAX_ROWS12),
|
|
24637
24778
|
truncated,
|
|
24638
|
-
rows: rows.slice(0,
|
|
24779
|
+
rows: rows.slice(0, MAX_ROWS12)
|
|
24639
24780
|
};
|
|
24640
24781
|
} finally {
|
|
24641
24782
|
await pool.end();
|
|
@@ -25114,7 +25255,7 @@ var parameters72 = {
|
|
|
25114
25255
|
|
|
25115
25256
|
// ../connectors/src/connectors/sqlserver/tools/execute-query.ts
|
|
25116
25257
|
import { z as z88 } from "zod";
|
|
25117
|
-
var
|
|
25258
|
+
var MAX_ROWS13 = 500;
|
|
25118
25259
|
var inputSchema88 = z88.object({
|
|
25119
25260
|
toolUseIntent: z88.string().optional().describe(
|
|
25120
25261
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25138,7 +25279,7 @@ var outputSchema88 = z88.discriminatedUnion("success", [
|
|
|
25138
25279
|
]);
|
|
25139
25280
|
var executeQueryTool14 = new ConnectorTool({
|
|
25140
25281
|
name: "executeQuery",
|
|
25141
|
-
description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${
|
|
25282
|
+
description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${MAX_ROWS13} rows.
|
|
25142
25283
|
Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
|
|
25143
25284
|
SQL Server uses \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets (\`[schema].[table]\`).
|
|
25144
25285
|
Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
@@ -25171,12 +25312,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
|
25171
25312
|
const { rows } = await runMssqlQuery(parsed, sql, {
|
|
25172
25313
|
tunnelParams: connectionParamsToRecord(connection2)
|
|
25173
25314
|
});
|
|
25174
|
-
const truncated = rows.length >
|
|
25315
|
+
const truncated = rows.length > MAX_ROWS13;
|
|
25175
25316
|
return {
|
|
25176
25317
|
success: true,
|
|
25177
|
-
rowCount: Math.min(rows.length,
|
|
25318
|
+
rowCount: Math.min(rows.length, MAX_ROWS13),
|
|
25178
25319
|
truncated,
|
|
25179
|
-
rows: rows.slice(0,
|
|
25320
|
+
rows: rows.slice(0, MAX_ROWS13)
|
|
25180
25321
|
};
|
|
25181
25322
|
} catch (err) {
|
|
25182
25323
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -25309,7 +25450,7 @@ var parameters73 = {
|
|
|
25309
25450
|
|
|
25310
25451
|
// ../connectors/src/connectors/azure-sql/tools/execute-query.ts
|
|
25311
25452
|
import { z as z89 } from "zod";
|
|
25312
|
-
var
|
|
25453
|
+
var MAX_ROWS14 = 500;
|
|
25313
25454
|
var inputSchema89 = z89.object({
|
|
25314
25455
|
toolUseIntent: z89.string().optional().describe(
|
|
25315
25456
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25333,7 +25474,7 @@ var outputSchema89 = z89.discriminatedUnion("success", [
|
|
|
25333
25474
|
]);
|
|
25334
25475
|
var executeQueryTool15 = new ConnectorTool({
|
|
25335
25476
|
name: "executeQuery",
|
|
25336
|
-
description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${
|
|
25477
|
+
description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${MAX_ROWS14} rows.
|
|
25337
25478
|
Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
|
|
25338
25479
|
Azure SQL is T-SQL: use \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets.
|
|
25339
25480
|
Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
@@ -25367,12 +25508,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
|
25367
25508
|
forceEncrypt: true,
|
|
25368
25509
|
tunnelParams: connectionParamsToRecord(connection2)
|
|
25369
25510
|
});
|
|
25370
|
-
const truncated = rows.length >
|
|
25511
|
+
const truncated = rows.length > MAX_ROWS14;
|
|
25371
25512
|
return {
|
|
25372
25513
|
success: true,
|
|
25373
|
-
rowCount: Math.min(rows.length,
|
|
25514
|
+
rowCount: Math.min(rows.length, MAX_ROWS14),
|
|
25374
25515
|
truncated,
|
|
25375
|
-
rows: rows.slice(0,
|
|
25516
|
+
rows: rows.slice(0, MAX_ROWS14)
|
|
25376
25517
|
};
|
|
25377
25518
|
} catch (err) {
|
|
25378
25519
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -25691,7 +25832,7 @@ var cosmosdbConnector = new ConnectorPlugin({
|
|
|
25691
25832
|
|
|
25692
25833
|
### Business Logic
|
|
25693
25834
|
|
|
25694
|
-
The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables.
|
|
25835
|
+
The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables, and do NOT \`import { CosmosClient } from "@azure/cosmos"\` in handler code \u2014 the \`@azure/cosmos\` driver is not part of the user dashboard's runtime, only of the connector SDK.
|
|
25695
25836
|
|
|
25696
25837
|
\u26A0\uFE0F **The client returned by \`connection(connectionId)\` is NOT the raw \`@azure/cosmos\` \`CosmosClient\`.** It is a thin wrapper exposing only two methods:
|
|
25697
25838
|
- \`client.query<T>(container, sql, options?) => Promise<T[]>\` \u2014 runs a Cosmos SQL query against the named container and returns the **already-unwrapped** items array (no \`{ resources }\` wrapper). \`options\` accepts \`{ maxItemCount?: number; partitionKey?: unknown }\`.
|
|
@@ -25737,7 +25878,7 @@ export default async function handler(_c: Context) {
|
|
|
25737
25878
|
|
|
25738
25879
|
### Business Logic
|
|
25739
25880
|
|
|
25740
|
-
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
25881
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u305F\u308A\u3001\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3067 \`import { CosmosClient } from "@azure/cosmos"\` \u3092\u884C\u3063\u305F\u308A\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 \`@azure/cosmos\` \u30C9\u30E9\u30A4\u30D0\u306F\u30E6\u30FC\u30B6\u30FC\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9\u306E\u30E9\u30F3\u30BF\u30A4\u30E0\u306B\u306F\u542B\u307E\u308C\u305A\u3001\u30B3\u30CD\u30AF\u30BFSDK\u5185\u90E8\u306B\u306E\u307F\u5B58\u5728\u3057\u307E\u3059\u3002
|
|
25741
25882
|
|
|
25742
25883
|
\u26A0\uFE0F **\`connection(connectionId)\` \u304C\u8FD4\u3059\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\u306F \`@azure/cosmos\` \u306E \`CosmosClient\` \u305D\u306E\u3082\u306E\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002** \u4EE5\u4E0B\u306E2\u30E1\u30BD\u30C3\u30C9\u306E\u307F\u3092\u516C\u958B\u3059\u308B\u8584\u3044\u30E9\u30C3\u30D1\u30FC\u3067\u3059\uFF1A
|
|
25743
25884
|
- \`client.query<T>(container, sql, options?) => Promise<T[]>\` \u2014 \u6307\u5B9A\u30B3\u30F3\u30C6\u30CA\u306B\u5BFE\u3057\u3066 Cosmos SQL \u3092\u5B9F\u884C\u3057\u3001**\u3059\u3067\u306B\u5C55\u958B\u6E08\u307F\u306E\u30A2\u30A4\u30C6\u30E0\u914D\u5217**\u3092\u8FD4\u3059\uFF08\`{ resources }\` \u3067\u30E9\u30C3\u30D7\u3055\u308C\u3066\u3044\u306A\u3044\uFF09\u3002\`options\` \u306F \`{ maxItemCount?: number; partitionKey?: unknown }\`\u3002
|
|
@@ -25849,7 +25990,7 @@ var parameters75 = {
|
|
|
25849
25990
|
|
|
25850
25991
|
// ../connectors/src/connectors/oracle/tools/execute-query.ts
|
|
25851
25992
|
import { z as z92 } from "zod";
|
|
25852
|
-
var
|
|
25993
|
+
var MAX_ROWS15 = 500;
|
|
25853
25994
|
var inputSchema92 = z92.object({
|
|
25854
25995
|
toolUseIntent: z92.string().optional().describe(
|
|
25855
25996
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25873,7 +26014,7 @@ var outputSchema92 = z92.discriminatedUnion("success", [
|
|
|
25873
26014
|
]);
|
|
25874
26015
|
var executeQueryTool16 = new ConnectorTool({
|
|
25875
26016
|
name: "executeQuery",
|
|
25876
|
-
description: `Execute a query against an Oracle Database. Returns up to ${
|
|
26017
|
+
description: `Execute a query against an Oracle Database. Returns up to ${MAX_ROWS15} rows.
|
|
25877
26018
|
Use for: schema exploration via \`USER_TABLES\` / \`USER_TAB_COLUMNS\` / \`ALL_TABLES\`, data sampling, and analytical queries.
|
|
25878
26019
|
Oracle uses \`FETCH FIRST n ROWS ONLY\` (12c+) or \`ROWNUM\` for row limiting \u2014 there is no \`LIMIT\` keyword.
|
|
25879
26020
|
Unquoted identifiers are stored upper-case (\`SELECT * FROM employees\` resolves to \`EMPLOYEES\`).
|
|
@@ -25908,12 +26049,12 @@ Do NOT terminate statements with a semicolon; the driver rejects trailing termin
|
|
|
25908
26049
|
const { rows } = await runOracleQuery(parsed, cleanSql, {
|
|
25909
26050
|
tunnelParams: connectionParamsToRecord(connection2)
|
|
25910
26051
|
});
|
|
25911
|
-
const truncated = rows.length >
|
|
26052
|
+
const truncated = rows.length > MAX_ROWS15;
|
|
25912
26053
|
return {
|
|
25913
26054
|
success: true,
|
|
25914
|
-
rowCount: Math.min(rows.length,
|
|
26055
|
+
rowCount: Math.min(rows.length, MAX_ROWS15),
|
|
25915
26056
|
truncated,
|
|
25916
|
-
rows: rows.slice(0,
|
|
26057
|
+
rows: rows.slice(0, MAX_ROWS15)
|
|
25917
26058
|
};
|
|
25918
26059
|
} catch (err) {
|
|
25919
26060
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -25932,7 +26073,7 @@ var oracleConnector = new ConnectorPlugin({
|
|
|
25932
26073
|
description: "Connect to Oracle Database using a JDBC-style URL via the pure-JS Thin driver (no Oracle Instant Client required).",
|
|
25933
26074
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3iGEdzvGHncU5bYqFOROiV/9e7bdda7230d7ca6b34e7f6a862de876/oracle-icon.webp",
|
|
25934
26075
|
parameters: parameters75,
|
|
25935
|
-
releaseFlag: { dev1: true, dev2:
|
|
26076
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
25936
26077
|
categories: ["database"],
|
|
25937
26078
|
onboarding: oracleOnboarding,
|
|
25938
26079
|
systemPrompt: {
|