@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/cli/index.js
CHANGED
|
@@ -438,6 +438,37 @@ import { z } from "zod";
|
|
|
438
438
|
|
|
439
439
|
// ../connectors/src/connectors/snowflake/utils.ts
|
|
440
440
|
import crypto from "crypto";
|
|
441
|
+
|
|
442
|
+
// ../connectors/src/lib/approx-bytes.ts
|
|
443
|
+
function approxBytes(value, acc, limit) {
|
|
444
|
+
if (acc > limit) return acc;
|
|
445
|
+
if (value == null) return acc;
|
|
446
|
+
const t = typeof value;
|
|
447
|
+
if (t === "string") return acc + value.length;
|
|
448
|
+
if (t === "number" || t === "boolean") return acc + 8;
|
|
449
|
+
if (t === "bigint") return acc + 16;
|
|
450
|
+
if (value instanceof Date) return acc + 8;
|
|
451
|
+
if (Buffer.isBuffer(value)) return acc + value.byteLength;
|
|
452
|
+
if (Array.isArray(value)) {
|
|
453
|
+
for (const item of value) {
|
|
454
|
+
acc = approxBytes(item, acc, limit);
|
|
455
|
+
if (acc > limit) return acc;
|
|
456
|
+
}
|
|
457
|
+
return acc;
|
|
458
|
+
}
|
|
459
|
+
if (t === "object") {
|
|
460
|
+
const obj = value;
|
|
461
|
+
for (const k in obj) {
|
|
462
|
+
acc += k.length;
|
|
463
|
+
acc = approxBytes(obj[k], acc, limit);
|
|
464
|
+
if (acc > limit) return acc;
|
|
465
|
+
}
|
|
466
|
+
return acc;
|
|
467
|
+
}
|
|
468
|
+
return acc;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// ../connectors/src/connectors/snowflake/utils.ts
|
|
441
472
|
function decryptPrivateKey(pem, passphrase) {
|
|
442
473
|
if (!passphrase) return pem;
|
|
443
474
|
return crypto.createPrivateKey({
|
|
@@ -446,10 +477,46 @@ function decryptPrivateKey(pem, passphrase) {
|
|
|
446
477
|
passphrase
|
|
447
478
|
}).export({ type: "pkcs8", format: "pem" });
|
|
448
479
|
}
|
|
480
|
+
async function executeWithSizeLimit(conn, sql, options) {
|
|
481
|
+
const rows = [];
|
|
482
|
+
let acc = 0;
|
|
483
|
+
let exceeded = false;
|
|
484
|
+
await new Promise((resolve, reject) => {
|
|
485
|
+
const stmt = conn.execute({
|
|
486
|
+
sqlText: sql,
|
|
487
|
+
streamResult: true
|
|
488
|
+
});
|
|
489
|
+
const stream = stmt.streamRows();
|
|
490
|
+
stream.on("data", (row) => {
|
|
491
|
+
if (exceeded) return;
|
|
492
|
+
acc = approxBytes(row, acc, options.maxBytes);
|
|
493
|
+
if (acc > options.maxBytes) {
|
|
494
|
+
exceeded = true;
|
|
495
|
+
stream.destroy();
|
|
496
|
+
stmt.cancel(() => {
|
|
497
|
+
});
|
|
498
|
+
resolve();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
rows.push(row);
|
|
502
|
+
});
|
|
503
|
+
stream.on("end", () => {
|
|
504
|
+
resolve();
|
|
505
|
+
});
|
|
506
|
+
stream.on("error", (err) => {
|
|
507
|
+
if (exceeded) return;
|
|
508
|
+
reject(new Error(`Snowflake query failed: ${err.message}`));
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
if (exceeded) {
|
|
512
|
+
return { exceeded: true };
|
|
513
|
+
}
|
|
514
|
+
return { exceeded: false, rows };
|
|
515
|
+
}
|
|
449
516
|
|
|
450
517
|
// ../connectors/src/connectors/snowflake/tools/execute-query.ts
|
|
451
|
-
var
|
|
452
|
-
var
|
|
518
|
+
var MAX_RESULT_BYTES = 5 * 1024 * 1024;
|
|
519
|
+
var STATEMENT_TIMEOUT_SECONDS = 60;
|
|
453
520
|
var inputSchema = z.object({
|
|
454
521
|
toolUseIntent: z.string().optional().describe(
|
|
455
522
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -463,7 +530,6 @@ var outputSchema = z.discriminatedUnion("success", [
|
|
|
463
530
|
z.object({
|
|
464
531
|
success: z.literal(true),
|
|
465
532
|
rowCount: z.number(),
|
|
466
|
-
truncated: z.boolean(),
|
|
467
533
|
rows: z.array(z.record(z.string(), z.unknown()))
|
|
468
534
|
}),
|
|
469
535
|
z.object({
|
|
@@ -473,9 +539,12 @@ var outputSchema = z.discriminatedUnion("success", [
|
|
|
473
539
|
]);
|
|
474
540
|
var executeQueryTool = new ConnectorTool({
|
|
475
541
|
name: "executeQuery",
|
|
476
|
-
description: `Execute SQL against Snowflake.
|
|
477
|
-
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA),
|
|
478
|
-
|
|
542
|
+
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).
|
|
543
|
+
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), sampling (LIMIT, SAMPLE), and analytical queries.
|
|
544
|
+
Memory guidance:
|
|
545
|
+
- 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).
|
|
546
|
+
- For full-dataset analysis, do the aggregation inside Snowflake (COUNT, SUM, GROUP BY, APPROX_TOP_K, HISTOGRAM) instead of returning raw rows.
|
|
547
|
+
- Exploration is iterative: start with a small LIMIT to inspect shape, then refine.`,
|
|
479
548
|
inputSchema,
|
|
480
549
|
outputSchema,
|
|
481
550
|
async execute({ connectionId, sql }, connections) {
|
|
@@ -517,39 +586,43 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
517
586
|
else resolve();
|
|
518
587
|
});
|
|
519
588
|
});
|
|
520
|
-
|
|
521
|
-
(resolve, reject) => {
|
|
522
|
-
const timeoutId = setTimeout(() => {
|
|
523
|
-
reject(
|
|
524
|
-
new Error(
|
|
525
|
-
"Snowflake query timeout: query exceeded 60 seconds"
|
|
526
|
-
)
|
|
527
|
-
);
|
|
528
|
-
}, QUERY_TIMEOUT_MS);
|
|
589
|
+
try {
|
|
590
|
+
await new Promise((resolve, reject) => {
|
|
529
591
|
conn.execute({
|
|
530
|
-
sqlText:
|
|
531
|
-
complete: (err
|
|
532
|
-
clearTimeout(timeoutId);
|
|
592
|
+
sqlText: `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${STATEMENT_TIMEOUT_SECONDS}`,
|
|
593
|
+
complete: (err) => {
|
|
533
594
|
if (err)
|
|
534
|
-
reject(
|
|
535
|
-
|
|
595
|
+
reject(
|
|
596
|
+
new Error(
|
|
597
|
+
`Failed to set Snowflake statement timeout: ${err.message}`
|
|
598
|
+
)
|
|
599
|
+
);
|
|
600
|
+
else resolve();
|
|
536
601
|
}
|
|
537
602
|
});
|
|
603
|
+
});
|
|
604
|
+
const result = await executeWithSizeLimit(conn, sql, {
|
|
605
|
+
maxBytes: MAX_RESULT_BYTES
|
|
606
|
+
});
|
|
607
|
+
if (result.exceeded) {
|
|
608
|
+
return {
|
|
609
|
+
success: false,
|
|
610
|
+
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)."
|
|
611
|
+
};
|
|
538
612
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
};
|
|
613
|
+
return {
|
|
614
|
+
success: true,
|
|
615
|
+
rowCount: result.rows.length,
|
|
616
|
+
rows: result.rows
|
|
617
|
+
};
|
|
618
|
+
} finally {
|
|
619
|
+
conn.destroy((err) => {
|
|
620
|
+
if (err)
|
|
621
|
+
console.warn(
|
|
622
|
+
`[connector-query] Snowflake destroy error: ${err.message}`
|
|
623
|
+
);
|
|
624
|
+
});
|
|
625
|
+
}
|
|
553
626
|
} catch (err) {
|
|
554
627
|
const msg = err instanceof Error ? err.message : String(err);
|
|
555
628
|
return { success: false, error: msg };
|
|
@@ -738,8 +811,8 @@ var parameters2 = {
|
|
|
738
811
|
|
|
739
812
|
// ../connectors/src/connectors/snowflake-pat/tools/execute-query.ts
|
|
740
813
|
import { z as z2 } from "zod";
|
|
741
|
-
var
|
|
742
|
-
var
|
|
814
|
+
var MAX_ROWS = 500;
|
|
815
|
+
var QUERY_TIMEOUT_MS = 6e4;
|
|
743
816
|
var inputSchema2 = z2.object({
|
|
744
817
|
toolUseIntent: z2.string().optional().describe(
|
|
745
818
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -763,7 +836,7 @@ var outputSchema2 = z2.discriminatedUnion("success", [
|
|
|
763
836
|
]);
|
|
764
837
|
var executeQueryTool2 = new ConnectorTool({
|
|
765
838
|
name: "executeQuery",
|
|
766
|
-
description: `Execute SQL against Snowflake. Returns up to ${
|
|
839
|
+
description: `Execute SQL against Snowflake. Returns up to ${MAX_ROWS} rows.
|
|
767
840
|
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
768
841
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
769
842
|
inputSchema: inputSchema2,
|
|
@@ -809,7 +882,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
809
882
|
"Snowflake query timeout: query exceeded 60 seconds"
|
|
810
883
|
)
|
|
811
884
|
);
|
|
812
|
-
},
|
|
885
|
+
}, QUERY_TIMEOUT_MS);
|
|
813
886
|
conn.execute({
|
|
814
887
|
sqlText: sql,
|
|
815
888
|
complete: (err, _stmt, rows) => {
|
|
@@ -827,12 +900,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
827
900
|
`[connector-query] Snowflake destroy error: ${err.message}`
|
|
828
901
|
);
|
|
829
902
|
});
|
|
830
|
-
const truncated = allRows.length >
|
|
903
|
+
const truncated = allRows.length > MAX_ROWS;
|
|
831
904
|
return {
|
|
832
905
|
success: true,
|
|
833
|
-
rowCount: Math.min(allRows.length,
|
|
906
|
+
rowCount: Math.min(allRows.length, MAX_ROWS),
|
|
834
907
|
truncated,
|
|
835
|
-
rows: allRows.slice(0,
|
|
908
|
+
rows: allRows.slice(0, MAX_ROWS)
|
|
836
909
|
};
|
|
837
910
|
} catch (err) {
|
|
838
911
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -1166,7 +1239,7 @@ var POSTGRES_DEFAULT_PORT = 5432;
|
|
|
1166
1239
|
|
|
1167
1240
|
// ../connectors/src/connectors/postgresql/tools/execute-query.ts
|
|
1168
1241
|
import { z as z3 } from "zod";
|
|
1169
|
-
var
|
|
1242
|
+
var MAX_ROWS2 = 500;
|
|
1170
1243
|
var CONNECT_TIMEOUT_MS = 1e4;
|
|
1171
1244
|
var STATEMENT_TIMEOUT_MS = 6e4;
|
|
1172
1245
|
var inputSchema3 = z3.object({
|
|
@@ -1190,7 +1263,7 @@ var outputSchema3 = z3.discriminatedUnion("success", [
|
|
|
1190
1263
|
]);
|
|
1191
1264
|
var executeQueryTool3 = new ConnectorTool({
|
|
1192
1265
|
name: "executeQuery",
|
|
1193
|
-
description: `Execute SQL against PostgreSQL. Returns up to ${
|
|
1266
|
+
description: `Execute SQL against PostgreSQL. Returns up to ${MAX_ROWS2} rows.
|
|
1194
1267
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
1195
1268
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1196
1269
|
inputSchema: inputSchema3,
|
|
@@ -1228,12 +1301,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1228
1301
|
STATEMENT_TIMEOUT_MS
|
|
1229
1302
|
);
|
|
1230
1303
|
const rows = result.rows;
|
|
1231
|
-
const truncated = rows.length >
|
|
1304
|
+
const truncated = rows.length > MAX_ROWS2;
|
|
1232
1305
|
return {
|
|
1233
1306
|
success: true,
|
|
1234
|
-
rowCount: Math.min(rows.length,
|
|
1307
|
+
rowCount: Math.min(rows.length, MAX_ROWS2),
|
|
1235
1308
|
truncated,
|
|
1236
|
-
rows: rows.slice(0,
|
|
1309
|
+
rows: rows.slice(0, MAX_ROWS2)
|
|
1237
1310
|
};
|
|
1238
1311
|
} finally {
|
|
1239
1312
|
await pool.end();
|
|
@@ -1370,9 +1443,9 @@ var MYSQL_DEFAULT_PORT = 3306;
|
|
|
1370
1443
|
|
|
1371
1444
|
// ../connectors/src/connectors/mysql/tools/execute-query.ts
|
|
1372
1445
|
import { z as z4 } from "zod";
|
|
1373
|
-
var
|
|
1446
|
+
var MAX_ROWS3 = 500;
|
|
1374
1447
|
var CONNECT_TIMEOUT_MS2 = 1e4;
|
|
1375
|
-
var
|
|
1448
|
+
var QUERY_TIMEOUT_MS2 = 6e4;
|
|
1376
1449
|
var inputSchema4 = z4.object({
|
|
1377
1450
|
toolUseIntent: z4.string().optional().describe(
|
|
1378
1451
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -1394,7 +1467,7 @@ var outputSchema4 = z4.discriminatedUnion("success", [
|
|
|
1394
1467
|
]);
|
|
1395
1468
|
var executeQueryTool4 = new ConnectorTool({
|
|
1396
1469
|
name: "executeQuery",
|
|
1397
|
-
description: `Execute SQL against MySQL. Returns up to ${
|
|
1470
|
+
description: `Execute SQL against MySQL. Returns up to ${MAX_ROWS3} rows.
|
|
1398
1471
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
1399
1472
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1400
1473
|
inputSchema: inputSchema4,
|
|
@@ -1427,16 +1500,16 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1427
1500
|
try {
|
|
1428
1501
|
const queryPromise = pool.query(sql);
|
|
1429
1502
|
const timeoutPromise = new Promise(
|
|
1430
|
-
(_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")),
|
|
1503
|
+
(_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")), QUERY_TIMEOUT_MS2)
|
|
1431
1504
|
);
|
|
1432
1505
|
const [rows] = await Promise.race([queryPromise, timeoutPromise]);
|
|
1433
1506
|
const resultRows = Array.isArray(rows) ? rows : [];
|
|
1434
|
-
const truncated = resultRows.length >
|
|
1507
|
+
const truncated = resultRows.length > MAX_ROWS3;
|
|
1435
1508
|
return {
|
|
1436
1509
|
success: true,
|
|
1437
|
-
rowCount: Math.min(resultRows.length,
|
|
1510
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS3),
|
|
1438
1511
|
truncated,
|
|
1439
|
-
rows: resultRows.slice(0,
|
|
1512
|
+
rows: resultRows.slice(0, MAX_ROWS3)
|
|
1440
1513
|
};
|
|
1441
1514
|
} finally {
|
|
1442
1515
|
await pool.end();
|
|
@@ -1763,7 +1836,7 @@ var bigqueryOnboarding = new ConnectorOnboarding({
|
|
|
1763
1836
|
|
|
1764
1837
|
// ../connectors/src/connectors/bigquery/tools/execute-query.ts
|
|
1765
1838
|
import { z as z7 } from "zod";
|
|
1766
|
-
var
|
|
1839
|
+
var MAX_ROWS4 = 500;
|
|
1767
1840
|
var inputSchema7 = z7.object({
|
|
1768
1841
|
toolUseIntent: z7.string().optional().describe(
|
|
1769
1842
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -1787,7 +1860,7 @@ var outputSchema7 = z7.discriminatedUnion("success", [
|
|
|
1787
1860
|
]);
|
|
1788
1861
|
var executeQueryTool5 = new ConnectorTool({
|
|
1789
1862
|
name: "executeQuery",
|
|
1790
|
-
description: `Execute SQL against BigQuery. Returns up to ${
|
|
1863
|
+
description: `Execute SQL against BigQuery. Returns up to ${MAX_ROWS4} rows.
|
|
1791
1864
|
Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
1792
1865
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
1793
1866
|
inputSchema: inputSchema7,
|
|
@@ -1814,12 +1887,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
1814
1887
|
const [job] = await bq.createQueryJob({ query: sql });
|
|
1815
1888
|
const [rows] = await job.getQueryResults();
|
|
1816
1889
|
const allRows = rows;
|
|
1817
|
-
const truncated = allRows.length >
|
|
1890
|
+
const truncated = allRows.length > MAX_ROWS4;
|
|
1818
1891
|
return {
|
|
1819
1892
|
success: true,
|
|
1820
|
-
rowCount: Math.min(allRows.length,
|
|
1893
|
+
rowCount: Math.min(allRows.length, MAX_ROWS4),
|
|
1821
1894
|
truncated,
|
|
1822
|
-
rows: allRows.slice(0,
|
|
1895
|
+
rows: allRows.slice(0, MAX_ROWS4)
|
|
1823
1896
|
};
|
|
1824
1897
|
} catch (err) {
|
|
1825
1898
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -2220,7 +2293,7 @@ var bigqueryOnboarding2 = new ConnectorOnboarding({
|
|
|
2220
2293
|
|
|
2221
2294
|
// ../connectors/src/connectors/bigquery-oauth/tools/execute-query.ts
|
|
2222
2295
|
import { z as z10 } from "zod";
|
|
2223
|
-
var
|
|
2296
|
+
var MAX_ROWS5 = 500;
|
|
2224
2297
|
var REQUEST_TIMEOUT_MS3 = 6e4;
|
|
2225
2298
|
var cachedToken3 = null;
|
|
2226
2299
|
async function getProxyToken3(config) {
|
|
@@ -2287,7 +2360,7 @@ function parseQueryResponse(data) {
|
|
|
2287
2360
|
}
|
|
2288
2361
|
var executeQueryTool6 = new ConnectorTool({
|
|
2289
2362
|
name: "executeQuery",
|
|
2290
|
-
description: `Execute SQL against BigQuery via OAuth. Returns up to ${
|
|
2363
|
+
description: `Execute SQL against BigQuery via OAuth. Returns up to ${MAX_ROWS5} rows.
|
|
2291
2364
|
Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
|
|
2292
2365
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
2293
2366
|
inputSchema: inputSchema10,
|
|
@@ -2320,7 +2393,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2320
2393
|
body: JSON.stringify({
|
|
2321
2394
|
url: queryUrl,
|
|
2322
2395
|
method: "POST",
|
|
2323
|
-
body: { query: sql, useLegacySql: false, maxResults:
|
|
2396
|
+
body: { query: sql, useLegacySql: false, maxResults: MAX_ROWS5 }
|
|
2324
2397
|
}),
|
|
2325
2398
|
signal: controller.signal
|
|
2326
2399
|
});
|
|
@@ -2330,12 +2403,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2330
2403
|
return { success: false, error: errorMessage };
|
|
2331
2404
|
}
|
|
2332
2405
|
const rows = parseQueryResponse(data);
|
|
2333
|
-
const truncated = rows.length >
|
|
2406
|
+
const truncated = rows.length > MAX_ROWS5;
|
|
2334
2407
|
return {
|
|
2335
2408
|
success: true,
|
|
2336
|
-
rowCount: Math.min(rows.length,
|
|
2409
|
+
rowCount: Math.min(rows.length, MAX_ROWS5),
|
|
2337
2410
|
truncated,
|
|
2338
|
-
rows: rows.slice(0,
|
|
2411
|
+
rows: rows.slice(0, MAX_ROWS5)
|
|
2339
2412
|
};
|
|
2340
2413
|
} finally {
|
|
2341
2414
|
clearTimeout(timeout);
|
|
@@ -2515,7 +2588,7 @@ var parameters7 = {
|
|
|
2515
2588
|
|
|
2516
2589
|
// ../connectors/src/connectors/aws-athena/tools/execute-query.ts
|
|
2517
2590
|
import { z as z11 } from "zod";
|
|
2518
|
-
var
|
|
2591
|
+
var MAX_ROWS6 = 500;
|
|
2519
2592
|
var POLL_INTERVAL_MS = 1e3;
|
|
2520
2593
|
var POLL_TIMEOUT_MS = 12e4;
|
|
2521
2594
|
var inputSchema11 = z11.object({
|
|
@@ -2539,7 +2612,7 @@ var outputSchema11 = z11.discriminatedUnion("success", [
|
|
|
2539
2612
|
]);
|
|
2540
2613
|
var executeQueryTool7 = new ConnectorTool({
|
|
2541
2614
|
name: "executeQuery",
|
|
2542
|
-
description: `Execute SQL against AWS Athena. Returns up to ${
|
|
2615
|
+
description: `Execute SQL against AWS Athena. Returns up to ${MAX_ROWS6} rows.
|
|
2543
2616
|
Use for: schema exploration (SHOW DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries on S3 data.
|
|
2544
2617
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
2545
2618
|
inputSchema: inputSchema11,
|
|
@@ -2616,12 +2689,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
2616
2689
|
});
|
|
2617
2690
|
return obj;
|
|
2618
2691
|
});
|
|
2619
|
-
const truncated = dataRows.length >
|
|
2692
|
+
const truncated = dataRows.length > MAX_ROWS6;
|
|
2620
2693
|
return {
|
|
2621
2694
|
success: true,
|
|
2622
|
-
rowCount: Math.min(dataRows.length,
|
|
2695
|
+
rowCount: Math.min(dataRows.length, MAX_ROWS6),
|
|
2623
2696
|
truncated,
|
|
2624
|
-
rows: dataRows.slice(0,
|
|
2697
|
+
rows: dataRows.slice(0, MAX_ROWS6)
|
|
2625
2698
|
};
|
|
2626
2699
|
} catch (err) {
|
|
2627
2700
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -3536,7 +3609,7 @@ var parameters9 = {
|
|
|
3536
3609
|
|
|
3537
3610
|
// ../connectors/src/connectors/redshift/tools/execute-query.ts
|
|
3538
3611
|
import { z as z15 } from "zod";
|
|
3539
|
-
var
|
|
3612
|
+
var MAX_ROWS7 = 500;
|
|
3540
3613
|
var POLL_INTERVAL_MS2 = 1e3;
|
|
3541
3614
|
var POLL_TIMEOUT_MS2 = 12e4;
|
|
3542
3615
|
var inputSchema15 = z15.object({
|
|
@@ -3562,7 +3635,7 @@ var outputSchema15 = z15.discriminatedUnion("success", [
|
|
|
3562
3635
|
]);
|
|
3563
3636
|
var executeQueryTool8 = new ConnectorTool({
|
|
3564
3637
|
name: "executeQuery",
|
|
3565
|
-
description: `Execute SQL against Amazon Redshift. Returns up to ${
|
|
3638
|
+
description: `Execute SQL against Amazon Redshift. Returns up to ${MAX_ROWS7} rows.
|
|
3566
3639
|
Use for: schema exploration, data sampling, analytical queries.
|
|
3567
3640
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
3568
3641
|
inputSchema: inputSchema15,
|
|
@@ -3641,12 +3714,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
3641
3714
|
});
|
|
3642
3715
|
return row;
|
|
3643
3716
|
});
|
|
3644
|
-
const truncated = allRows.length >
|
|
3717
|
+
const truncated = allRows.length > MAX_ROWS7;
|
|
3645
3718
|
return {
|
|
3646
3719
|
success: true,
|
|
3647
|
-
rowCount: Math.min(allRows.length,
|
|
3720
|
+
rowCount: Math.min(allRows.length, MAX_ROWS7),
|
|
3648
3721
|
truncated,
|
|
3649
|
-
rows: allRows.slice(0,
|
|
3722
|
+
rows: allRows.slice(0, MAX_ROWS7)
|
|
3650
3723
|
};
|
|
3651
3724
|
} catch (err) {
|
|
3652
3725
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -3867,7 +3940,7 @@ var parameters10 = {
|
|
|
3867
3940
|
|
|
3868
3941
|
// ../connectors/src/connectors/databricks/tools/execute-query.ts
|
|
3869
3942
|
import { z as z16 } from "zod";
|
|
3870
|
-
var
|
|
3943
|
+
var MAX_ROWS8 = 500;
|
|
3871
3944
|
var inputSchema16 = z16.object({
|
|
3872
3945
|
toolUseIntent: z16.string().optional().describe(
|
|
3873
3946
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -3889,7 +3962,7 @@ var outputSchema16 = z16.discriminatedUnion("success", [
|
|
|
3889
3962
|
]);
|
|
3890
3963
|
var executeQueryTool9 = new ConnectorTool({
|
|
3891
3964
|
name: "executeQuery",
|
|
3892
|
-
description: `Execute SQL against Databricks. Returns up to ${
|
|
3965
|
+
description: `Execute SQL against Databricks. Returns up to ${MAX_ROWS8} rows.
|
|
3893
3966
|
Use for: schema exploration (SHOW CATALOGS/DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries.
|
|
3894
3967
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
3895
3968
|
inputSchema: inputSchema16,
|
|
@@ -3920,12 +3993,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
3920
3993
|
runAsync: true
|
|
3921
3994
|
});
|
|
3922
3995
|
const allRows = await operation.fetchAll();
|
|
3923
|
-
const truncated = allRows.length >
|
|
3996
|
+
const truncated = allRows.length > MAX_ROWS8;
|
|
3924
3997
|
return {
|
|
3925
3998
|
success: true,
|
|
3926
|
-
rowCount: Math.min(allRows.length,
|
|
3999
|
+
rowCount: Math.min(allRows.length, MAX_ROWS8),
|
|
3927
4000
|
truncated,
|
|
3928
|
-
rows: allRows.slice(0,
|
|
4001
|
+
rows: allRows.slice(0, MAX_ROWS8)
|
|
3929
4002
|
};
|
|
3930
4003
|
} finally {
|
|
3931
4004
|
if (operation) await operation.close().catch(() => {
|
|
@@ -10870,7 +10943,7 @@ var parameters29 = {
|
|
|
10870
10943
|
|
|
10871
10944
|
// ../connectors/src/connectors/squadbase-db/tools/execute-query.ts
|
|
10872
10945
|
import { z as z40 } from "zod";
|
|
10873
|
-
var
|
|
10946
|
+
var MAX_ROWS9 = 500;
|
|
10874
10947
|
var CONNECT_TIMEOUT_MS3 = 1e4;
|
|
10875
10948
|
var STATEMENT_TIMEOUT_MS2 = 6e4;
|
|
10876
10949
|
var inputSchema40 = z40.object({
|
|
@@ -10894,7 +10967,7 @@ var outputSchema40 = z40.discriminatedUnion("success", [
|
|
|
10894
10967
|
]);
|
|
10895
10968
|
var executeQueryTool10 = new ConnectorTool({
|
|
10896
10969
|
name: "executeQuery",
|
|
10897
|
-
description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${
|
|
10970
|
+
description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${MAX_ROWS9} rows.
|
|
10898
10971
|
Use for: schema exploration (information_schema), data sampling, analytical queries.
|
|
10899
10972
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
10900
10973
|
inputSchema: inputSchema40,
|
|
@@ -10923,12 +10996,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
10923
10996
|
try {
|
|
10924
10997
|
const result = await pool.query(sql);
|
|
10925
10998
|
const rows = result.rows;
|
|
10926
|
-
const truncated = rows.length >
|
|
10999
|
+
const truncated = rows.length > MAX_ROWS9;
|
|
10927
11000
|
return {
|
|
10928
11001
|
success: true,
|
|
10929
|
-
rowCount: Math.min(rows.length,
|
|
11002
|
+
rowCount: Math.min(rows.length, MAX_ROWS9),
|
|
10930
11003
|
truncated,
|
|
10931
|
-
rows: rows.slice(0,
|
|
11004
|
+
rows: rows.slice(0, MAX_ROWS9)
|
|
10932
11005
|
};
|
|
10933
11006
|
} finally {
|
|
10934
11007
|
await pool.end();
|
|
@@ -13702,8 +13775,8 @@ var parameters41 = {
|
|
|
13702
13775
|
|
|
13703
13776
|
// ../connectors/src/connectors/clickhouse/tools/execute-query.ts
|
|
13704
13777
|
import { z as z49 } from "zod";
|
|
13705
|
-
var
|
|
13706
|
-
var
|
|
13778
|
+
var MAX_ROWS10 = 500;
|
|
13779
|
+
var QUERY_TIMEOUT_MS3 = 6e4;
|
|
13707
13780
|
var inputSchema49 = z49.object({
|
|
13708
13781
|
toolUseIntent: z49.string().optional().describe(
|
|
13709
13782
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -13725,7 +13798,7 @@ var outputSchema49 = z49.discriminatedUnion("success", [
|
|
|
13725
13798
|
]);
|
|
13726
13799
|
var executeQueryTool11 = new ConnectorTool({
|
|
13727
13800
|
name: "executeQuery",
|
|
13728
|
-
description: `Execute SQL against ClickHouse. Returns up to ${
|
|
13801
|
+
description: `Execute SQL against ClickHouse. Returns up to ${MAX_ROWS10} rows.
|
|
13729
13802
|
Use for: schema exploration (SHOW DATABASES, SHOW TABLES, DESCRIBE TABLE), data sampling, analytical queries on large-scale columnar data.
|
|
13730
13803
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
13731
13804
|
inputSchema: inputSchema49,
|
|
@@ -13753,7 +13826,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
13753
13826
|
username,
|
|
13754
13827
|
password: password || "",
|
|
13755
13828
|
database: database || "default",
|
|
13756
|
-
request_timeout:
|
|
13829
|
+
request_timeout: QUERY_TIMEOUT_MS3
|
|
13757
13830
|
});
|
|
13758
13831
|
try {
|
|
13759
13832
|
const resultSet = await client.query({
|
|
@@ -13761,12 +13834,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
13761
13834
|
format: "JSONEachRow"
|
|
13762
13835
|
});
|
|
13763
13836
|
const allRows = await resultSet.json();
|
|
13764
|
-
const truncated = allRows.length >
|
|
13837
|
+
const truncated = allRows.length > MAX_ROWS10;
|
|
13765
13838
|
return {
|
|
13766
13839
|
success: true,
|
|
13767
|
-
rowCount: Math.min(allRows.length,
|
|
13840
|
+
rowCount: Math.min(allRows.length, MAX_ROWS10),
|
|
13768
13841
|
truncated,
|
|
13769
|
-
rows: allRows.slice(0,
|
|
13842
|
+
rows: allRows.slice(0, MAX_ROWS10)
|
|
13770
13843
|
};
|
|
13771
13844
|
} finally {
|
|
13772
13845
|
await client.close();
|
|
@@ -13922,7 +13995,7 @@ var parameters42 = {
|
|
|
13922
13995
|
import { z as z50 } from "zod";
|
|
13923
13996
|
var MAX_DOCUMENTS = 500;
|
|
13924
13997
|
var CONNECT_TIMEOUT_MS4 = 1e4;
|
|
13925
|
-
var
|
|
13998
|
+
var QUERY_TIMEOUT_MS4 = 6e4;
|
|
13926
13999
|
var inputSchema50 = z50.object({
|
|
13927
14000
|
toolUseIntent: z50.string().optional().describe(
|
|
13928
14001
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -13981,7 +14054,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
|
|
|
13981
14054
|
const client = new MongoClient(connectionUrl, {
|
|
13982
14055
|
connectTimeoutMS: CONNECT_TIMEOUT_MS4,
|
|
13983
14056
|
serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS4,
|
|
13984
|
-
socketTimeoutMS:
|
|
14057
|
+
socketTimeoutMS: QUERY_TIMEOUT_MS4
|
|
13985
14058
|
});
|
|
13986
14059
|
try {
|
|
13987
14060
|
await client.connect();
|
|
@@ -14027,7 +14100,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
|
|
|
14027
14100
|
import { z as z51 } from "zod";
|
|
14028
14101
|
var MAX_DOCUMENTS2 = 500;
|
|
14029
14102
|
var CONNECT_TIMEOUT_MS5 = 1e4;
|
|
14030
|
-
var
|
|
14103
|
+
var QUERY_TIMEOUT_MS5 = 6e4;
|
|
14031
14104
|
var inputSchema51 = z51.object({
|
|
14032
14105
|
toolUseIntent: z51.string().optional().describe(
|
|
14033
14106
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -14078,7 +14151,7 @@ Common stages: $match (filter), $group (aggregate), $sort (order), $project (res
|
|
|
14078
14151
|
const client = new MongoClient(connectionUrl, {
|
|
14079
14152
|
connectTimeoutMS: CONNECT_TIMEOUT_MS5,
|
|
14080
14153
|
serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS5,
|
|
14081
|
-
socketTimeoutMS:
|
|
14154
|
+
socketTimeoutMS: QUERY_TIMEOUT_MS5
|
|
14082
14155
|
});
|
|
14083
14156
|
try {
|
|
14084
14157
|
await client.connect();
|
|
@@ -14211,7 +14284,41 @@ var mongodbConnector = new ConnectorPlugin({
|
|
|
14211
14284
|
|
|
14212
14285
|
### Business Logic
|
|
14213
14286
|
|
|
14214
|
-
The business logic type for this connector is "typescript".
|
|
14287
|
+
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.
|
|
14288
|
+
|
|
14289
|
+
\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:
|
|
14290
|
+
|
|
14291
|
+
- \`client.aggregate<T>(collection, pipeline, options?) => Promise<T[]>\` \u2014 runs an aggregation pipeline and returns the document array. Always include a \`$limit\` stage.
|
|
14292
|
+
- \`client.find<T>(collection, filter?, options?) => Promise<T[]>\` \u2014 \`options\` accepts \`{ projection?, sort?, limit?, skip? }\`. Always pass \`limit\`.
|
|
14293
|
+
- \`client.findOne<T>(collection, filter?, options?) => Promise<T | null>\` \u2014 convenience wrapper around \`find\` with \`limit: 1\`.
|
|
14294
|
+
- \`client.countDocuments(collection, filter?) => Promise<number>\` \u2014 accurate count (not \`estimatedDocumentCount\`).
|
|
14295
|
+
- \`client.listCollections() => Promise<{ name: string; type: string }[]>\` \u2014 collections in the configured database.
|
|
14296
|
+
|
|
14297
|
+
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\`.
|
|
14298
|
+
|
|
14299
|
+
\`\`\`ts
|
|
14300
|
+
import type { Context } from "hono";
|
|
14301
|
+
import { connection } from "@squadbase/vite-server/connectors/mongodb";
|
|
14302
|
+
|
|
14303
|
+
const mongo = connection("<connectionId>");
|
|
14304
|
+
|
|
14305
|
+
export default async function handler(_c: Context) {
|
|
14306
|
+
const rows = await mongo.aggregate<{ country: string; count: number }>(
|
|
14307
|
+
"<collectionName>",
|
|
14308
|
+
[
|
|
14309
|
+
{ $match: { country: { $nin: [null, ""] } } },
|
|
14310
|
+
{ $group: { _id: "$country", count: { $sum: 1 } } },
|
|
14311
|
+
{ $sort: { count: -1 } },
|
|
14312
|
+
{ $limit: 20 },
|
|
14313
|
+
{ $project: { _id: 0, country: "$_id", count: 1 } },
|
|
14314
|
+
],
|
|
14315
|
+
);
|
|
14316
|
+
|
|
14317
|
+
return new Response(JSON.stringify(rows), {
|
|
14318
|
+
headers: { "Content-Type": "application/json" },
|
|
14319
|
+
});
|
|
14320
|
+
}
|
|
14321
|
+
\`\`\`
|
|
14215
14322
|
|
|
14216
14323
|
### MongoDB Reference
|
|
14217
14324
|
- MongoDB stores data as flexible JSON-like documents (BSON)
|
|
@@ -14232,7 +14339,41 @@ The business logic type for this connector is "typescript".
|
|
|
14232
14339
|
|
|
14233
14340
|
### Business Logic
|
|
14234
14341
|
|
|
14235
|
-
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002
|
|
14342
|
+
\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
|
|
14343
|
+
|
|
14344
|
+
\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
|
|
14345
|
+
|
|
14346
|
+
- \`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
|
|
14347
|
+
- \`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
|
|
14348
|
+
- \`client.findOne<T>(collection, filter?, options?) => Promise<T | null>\` \u2014 \`limit: 1\` \u3067\u306E \`find\` \u306E\u30E9\u30C3\u30D1\u30FC\u3002
|
|
14349
|
+
- \`client.countDocuments(collection, filter?) => Promise<number>\` \u2014 \u6B63\u78BA\u306A\u30AB\u30A6\u30F3\u30C8\uFF08\`estimatedDocumentCount\` \u3067\u306F\u306A\u3044\uFF09\u3002
|
|
14350
|
+
- \`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
|
|
14351
|
+
|
|
14352
|
+
\`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
|
|
14353
|
+
|
|
14354
|
+
\`\`\`ts
|
|
14355
|
+
import type { Context } from "hono";
|
|
14356
|
+
import { connection } from "@squadbase/vite-server/connectors/mongodb";
|
|
14357
|
+
|
|
14358
|
+
const mongo = connection("<connectionId>");
|
|
14359
|
+
|
|
14360
|
+
export default async function handler(_c: Context) {
|
|
14361
|
+
const rows = await mongo.aggregate<{ country: string; count: number }>(
|
|
14362
|
+
"<collectionName>",
|
|
14363
|
+
[
|
|
14364
|
+
{ $match: { country: { $nin: [null, ""] } } },
|
|
14365
|
+
{ $group: { _id: "$country", count: { $sum: 1 } } },
|
|
14366
|
+
{ $sort: { count: -1 } },
|
|
14367
|
+
{ $limit: 20 },
|
|
14368
|
+
{ $project: { _id: 0, country: "$_id", count: 1 } },
|
|
14369
|
+
],
|
|
14370
|
+
);
|
|
14371
|
+
|
|
14372
|
+
return new Response(JSON.stringify(rows), {
|
|
14373
|
+
headers: { "Content-Type": "application/json" },
|
|
14374
|
+
});
|
|
14375
|
+
}
|
|
14376
|
+
\`\`\`
|
|
14236
14377
|
|
|
14237
14378
|
### MongoDB \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
14238
14379
|
- 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
|
|
@@ -23239,7 +23380,7 @@ function redactJdbcUrl(jdbcUrl) {
|
|
|
23239
23380
|
}
|
|
23240
23381
|
|
|
23241
23382
|
// ../connectors/src/connectors/jdbc/tools/execute-query.ts
|
|
23242
|
-
var
|
|
23383
|
+
var MAX_ROWS11 = 500;
|
|
23243
23384
|
var CONNECT_TIMEOUT_MS7 = 1e4;
|
|
23244
23385
|
var STATEMENT_TIMEOUT_MS3 = 6e4;
|
|
23245
23386
|
var inputSchema82 = z82.object({
|
|
@@ -23265,7 +23406,7 @@ var outputSchema82 = z82.discriminatedUnion("success", [
|
|
|
23265
23406
|
]);
|
|
23266
23407
|
var executeQueryTool12 = new ConnectorTool({
|
|
23267
23408
|
name: "executeQuery",
|
|
23268
|
-
description: `Execute a SQL query through the JDBC connector. Returns up to ${
|
|
23409
|
+
description: `Execute a SQL query through the JDBC connector. Returns up to ${MAX_ROWS11} rows.
|
|
23269
23410
|
Use for: schema exploration via \`information_schema\` (or USER_TABLES on Oracle), data sampling, analytical queries.
|
|
23270
23411
|
The connector dispatches by JDBC URL prefix to the matching driver
|
|
23271
23412
|
(PostgreSQL / Redshift / MySQL / MariaDB / SQL Server / Oracle), so use the dialect that matches the connection.
|
|
@@ -23306,9 +23447,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23306
23447
|
const rows = result.rows;
|
|
23307
23448
|
return {
|
|
23308
23449
|
success: true,
|
|
23309
|
-
rowCount: Math.min(rows.length,
|
|
23310
|
-
truncated: rows.length >
|
|
23311
|
-
rows: rows.slice(0,
|
|
23450
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23451
|
+
truncated: rows.length > MAX_ROWS11,
|
|
23452
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23312
23453
|
};
|
|
23313
23454
|
}
|
|
23314
23455
|
if (parsed.driver === "oracle") {
|
|
@@ -23323,9 +23464,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23323
23464
|
const rows = result.rows;
|
|
23324
23465
|
return {
|
|
23325
23466
|
success: true,
|
|
23326
|
-
rowCount: Math.min(rows.length,
|
|
23327
|
-
truncated: rows.length >
|
|
23328
|
-
rows: rows.slice(0,
|
|
23467
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23468
|
+
truncated: rows.length > MAX_ROWS11,
|
|
23469
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23329
23470
|
};
|
|
23330
23471
|
}
|
|
23331
23472
|
let tunnel;
|
|
@@ -23349,12 +23490,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23349
23490
|
STATEMENT_TIMEOUT_MS3
|
|
23350
23491
|
);
|
|
23351
23492
|
const rows = result.rows;
|
|
23352
|
-
const truncated = rows.length >
|
|
23493
|
+
const truncated = rows.length > MAX_ROWS11;
|
|
23353
23494
|
return {
|
|
23354
23495
|
success: true,
|
|
23355
|
-
rowCount: Math.min(rows.length,
|
|
23496
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23356
23497
|
truncated,
|
|
23357
|
-
rows: rows.slice(0,
|
|
23498
|
+
rows: rows.slice(0, MAX_ROWS11)
|
|
23358
23499
|
};
|
|
23359
23500
|
} finally {
|
|
23360
23501
|
await pool2.end();
|
|
@@ -23375,12 +23516,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
|
|
|
23375
23516
|
);
|
|
23376
23517
|
const [rows] = await Promise.race([queryPromise, timeoutPromise]);
|
|
23377
23518
|
const resultRows = Array.isArray(rows) ? rows : [];
|
|
23378
|
-
const truncated = resultRows.length >
|
|
23519
|
+
const truncated = resultRows.length > MAX_ROWS11;
|
|
23379
23520
|
return {
|
|
23380
23521
|
success: true,
|
|
23381
|
-
rowCount: Math.min(resultRows.length,
|
|
23522
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS11),
|
|
23382
23523
|
truncated,
|
|
23383
|
-
rows: resultRows.slice(0,
|
|
23524
|
+
rows: resultRows.slice(0, MAX_ROWS11)
|
|
23384
23525
|
};
|
|
23385
23526
|
} finally {
|
|
23386
23527
|
await pool.end();
|
|
@@ -24649,7 +24790,7 @@ var parameters70 = {
|
|
|
24649
24790
|
|
|
24650
24791
|
// ../connectors/src/connectors/supabase/tools/execute-query.ts
|
|
24651
24792
|
import { z as z86 } from "zod";
|
|
24652
|
-
var
|
|
24793
|
+
var MAX_ROWS12 = 500;
|
|
24653
24794
|
var CONNECT_TIMEOUT_MS8 = 1e4;
|
|
24654
24795
|
var STATEMENT_TIMEOUT_MS4 = 6e4;
|
|
24655
24796
|
var inputSchema86 = z86.object({
|
|
@@ -24675,7 +24816,7 @@ var outputSchema86 = z86.discriminatedUnion("success", [
|
|
|
24675
24816
|
]);
|
|
24676
24817
|
var executeQueryTool13 = new ConnectorTool({
|
|
24677
24818
|
name: "executeQuery",
|
|
24678
|
-
description: `Execute SQL against a Supabase Postgres database. Returns up to ${
|
|
24819
|
+
description: `Execute SQL against a Supabase Postgres database. Returns up to ${MAX_ROWS12} rows.
|
|
24679
24820
|
Use for: schema exploration (information_schema), data sampling, and analytical queries against Supabase tables.
|
|
24680
24821
|
User tables live in the \`public\` schema by default; Supabase-managed metadata lives in \`auth\` and \`storage\`.
|
|
24681
24822
|
Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
@@ -24705,12 +24846,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
|
|
|
24705
24846
|
try {
|
|
24706
24847
|
const result = await pool.query(sql);
|
|
24707
24848
|
const rows = result.rows;
|
|
24708
|
-
const truncated = rows.length >
|
|
24849
|
+
const truncated = rows.length > MAX_ROWS12;
|
|
24709
24850
|
return {
|
|
24710
24851
|
success: true,
|
|
24711
|
-
rowCount: Math.min(rows.length,
|
|
24852
|
+
rowCount: Math.min(rows.length, MAX_ROWS12),
|
|
24712
24853
|
truncated,
|
|
24713
|
-
rows: rows.slice(0,
|
|
24854
|
+
rows: rows.slice(0, MAX_ROWS12)
|
|
24714
24855
|
};
|
|
24715
24856
|
} finally {
|
|
24716
24857
|
await pool.end();
|
|
@@ -25189,7 +25330,7 @@ var parameters72 = {
|
|
|
25189
25330
|
|
|
25190
25331
|
// ../connectors/src/connectors/sqlserver/tools/execute-query.ts
|
|
25191
25332
|
import { z as z88 } from "zod";
|
|
25192
|
-
var
|
|
25333
|
+
var MAX_ROWS13 = 500;
|
|
25193
25334
|
var inputSchema88 = z88.object({
|
|
25194
25335
|
toolUseIntent: z88.string().optional().describe(
|
|
25195
25336
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25213,7 +25354,7 @@ var outputSchema88 = z88.discriminatedUnion("success", [
|
|
|
25213
25354
|
]);
|
|
25214
25355
|
var executeQueryTool14 = new ConnectorTool({
|
|
25215
25356
|
name: "executeQuery",
|
|
25216
|
-
description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${
|
|
25357
|
+
description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${MAX_ROWS13} rows.
|
|
25217
25358
|
Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
|
|
25218
25359
|
SQL Server uses \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets (\`[schema].[table]\`).
|
|
25219
25360
|
Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
@@ -25246,12 +25387,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
|
25246
25387
|
const { rows } = await runMssqlQuery(parsed, sql, {
|
|
25247
25388
|
tunnelParams: connectionParamsToRecord(connection)
|
|
25248
25389
|
});
|
|
25249
|
-
const truncated = rows.length >
|
|
25390
|
+
const truncated = rows.length > MAX_ROWS13;
|
|
25250
25391
|
return {
|
|
25251
25392
|
success: true,
|
|
25252
|
-
rowCount: Math.min(rows.length,
|
|
25393
|
+
rowCount: Math.min(rows.length, MAX_ROWS13),
|
|
25253
25394
|
truncated,
|
|
25254
|
-
rows: rows.slice(0,
|
|
25395
|
+
rows: rows.slice(0, MAX_ROWS13)
|
|
25255
25396
|
};
|
|
25256
25397
|
} catch (err) {
|
|
25257
25398
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -25384,7 +25525,7 @@ var parameters73 = {
|
|
|
25384
25525
|
|
|
25385
25526
|
// ../connectors/src/connectors/azure-sql/tools/execute-query.ts
|
|
25386
25527
|
import { z as z89 } from "zod";
|
|
25387
|
-
var
|
|
25528
|
+
var MAX_ROWS14 = 500;
|
|
25388
25529
|
var inputSchema89 = z89.object({
|
|
25389
25530
|
toolUseIntent: z89.string().optional().describe(
|
|
25390
25531
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25408,7 +25549,7 @@ var outputSchema89 = z89.discriminatedUnion("success", [
|
|
|
25408
25549
|
]);
|
|
25409
25550
|
var executeQueryTool15 = new ConnectorTool({
|
|
25410
25551
|
name: "executeQuery",
|
|
25411
|
-
description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${
|
|
25552
|
+
description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${MAX_ROWS14} rows.
|
|
25412
25553
|
Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
|
|
25413
25554
|
Azure SQL is T-SQL: use \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets.
|
|
25414
25555
|
Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
@@ -25442,12 +25583,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
|
|
|
25442
25583
|
forceEncrypt: true,
|
|
25443
25584
|
tunnelParams: connectionParamsToRecord(connection)
|
|
25444
25585
|
});
|
|
25445
|
-
const truncated = rows.length >
|
|
25586
|
+
const truncated = rows.length > MAX_ROWS14;
|
|
25446
25587
|
return {
|
|
25447
25588
|
success: true,
|
|
25448
|
-
rowCount: Math.min(rows.length,
|
|
25589
|
+
rowCount: Math.min(rows.length, MAX_ROWS14),
|
|
25449
25590
|
truncated,
|
|
25450
|
-
rows: rows.slice(0,
|
|
25591
|
+
rows: rows.slice(0, MAX_ROWS14)
|
|
25451
25592
|
};
|
|
25452
25593
|
} catch (err) {
|
|
25453
25594
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -25766,7 +25907,7 @@ var cosmosdbConnector = new ConnectorPlugin({
|
|
|
25766
25907
|
|
|
25767
25908
|
### Business Logic
|
|
25768
25909
|
|
|
25769
|
-
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.
|
|
25910
|
+
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.
|
|
25770
25911
|
|
|
25771
25912
|
\u26A0\uFE0F **The client returned by \`connection(connectionId)\` is NOT the raw \`@azure/cosmos\` \`CosmosClient\`.** It is a thin wrapper exposing only two methods:
|
|
25772
25913
|
- \`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 }\`.
|
|
@@ -25812,7 +25953,7 @@ export default async function handler(_c: Context) {
|
|
|
25812
25953
|
|
|
25813
25954
|
### Business Logic
|
|
25814
25955
|
|
|
25815
|
-
\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
|
|
25956
|
+
\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
|
|
25816
25957
|
|
|
25817
25958
|
\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
|
|
25818
25959
|
- \`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
|
|
@@ -25924,7 +26065,7 @@ var parameters75 = {
|
|
|
25924
26065
|
|
|
25925
26066
|
// ../connectors/src/connectors/oracle/tools/execute-query.ts
|
|
25926
26067
|
import { z as z92 } from "zod";
|
|
25927
|
-
var
|
|
26068
|
+
var MAX_ROWS15 = 500;
|
|
25928
26069
|
var inputSchema92 = z92.object({
|
|
25929
26070
|
toolUseIntent: z92.string().optional().describe(
|
|
25930
26071
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -25948,7 +26089,7 @@ var outputSchema92 = z92.discriminatedUnion("success", [
|
|
|
25948
26089
|
]);
|
|
25949
26090
|
var executeQueryTool16 = new ConnectorTool({
|
|
25950
26091
|
name: "executeQuery",
|
|
25951
|
-
description: `Execute a query against an Oracle Database. Returns up to ${
|
|
26092
|
+
description: `Execute a query against an Oracle Database. Returns up to ${MAX_ROWS15} rows.
|
|
25952
26093
|
Use for: schema exploration via \`USER_TABLES\` / \`USER_TAB_COLUMNS\` / \`ALL_TABLES\`, data sampling, and analytical queries.
|
|
25953
26094
|
Oracle uses \`FETCH FIRST n ROWS ONLY\` (12c+) or \`ROWNUM\` for row limiting \u2014 there is no \`LIMIT\` keyword.
|
|
25954
26095
|
Unquoted identifiers are stored upper-case (\`SELECT * FROM employees\` resolves to \`EMPLOYEES\`).
|
|
@@ -25983,12 +26124,12 @@ Do NOT terminate statements with a semicolon; the driver rejects trailing termin
|
|
|
25983
26124
|
const { rows } = await runOracleQuery(parsed, cleanSql, {
|
|
25984
26125
|
tunnelParams: connectionParamsToRecord(connection)
|
|
25985
26126
|
});
|
|
25986
|
-
const truncated = rows.length >
|
|
26127
|
+
const truncated = rows.length > MAX_ROWS15;
|
|
25987
26128
|
return {
|
|
25988
26129
|
success: true,
|
|
25989
|
-
rowCount: Math.min(rows.length,
|
|
26130
|
+
rowCount: Math.min(rows.length, MAX_ROWS15),
|
|
25990
26131
|
truncated,
|
|
25991
|
-
rows: rows.slice(0,
|
|
26132
|
+
rows: rows.slice(0, MAX_ROWS15)
|
|
25992
26133
|
};
|
|
25993
26134
|
} catch (err) {
|
|
25994
26135
|
let msg = err instanceof Error ? err.message : String(err);
|
|
@@ -26007,7 +26148,7 @@ var oracleConnector = new ConnectorPlugin({
|
|
|
26007
26148
|
description: "Connect to Oracle Database using a JDBC-style URL via the pure-JS Thin driver (no Oracle Instant Client required).",
|
|
26008
26149
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3iGEdzvGHncU5bYqFOROiV/9e7bdda7230d7ca6b34e7f6a862de876/oracle-icon.webp",
|
|
26009
26150
|
parameters: parameters75,
|
|
26010
|
-
releaseFlag: { dev1: true, dev2:
|
|
26151
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
26011
26152
|
categories: ["database"],
|
|
26012
26153
|
onboarding: oracleOnboarding,
|
|
26013
26154
|
systemPrompt: {
|