@squadbase/vite-server 0.1.10 → 0.1.12-dev.822582a

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.
@@ -364,6 +364,37 @@ import { z } from "zod";
364
364
 
365
365
  // ../connectors/src/connectors/snowflake/utils.ts
366
366
  import crypto from "crypto";
367
+
368
+ // ../connectors/src/lib/approx-bytes.ts
369
+ function approxBytes(value, acc, limit) {
370
+ if (acc > limit) return acc;
371
+ if (value == null) return acc;
372
+ const t = typeof value;
373
+ if (t === "string") return acc + value.length;
374
+ if (t === "number" || t === "boolean") return acc + 8;
375
+ if (t === "bigint") return acc + 16;
376
+ if (value instanceof Date) return acc + 8;
377
+ if (Buffer.isBuffer(value)) return acc + value.byteLength;
378
+ if (Array.isArray(value)) {
379
+ for (const item of value) {
380
+ acc = approxBytes(item, acc, limit);
381
+ if (acc > limit) return acc;
382
+ }
383
+ return acc;
384
+ }
385
+ if (t === "object") {
386
+ const obj = value;
387
+ for (const k in obj) {
388
+ acc += k.length;
389
+ acc = approxBytes(obj[k], acc, limit);
390
+ if (acc > limit) return acc;
391
+ }
392
+ return acc;
393
+ }
394
+ return acc;
395
+ }
396
+
397
+ // ../connectors/src/connectors/snowflake/utils.ts
367
398
  function decryptPrivateKey(pem, passphrase) {
368
399
  if (!passphrase) return pem;
369
400
  return crypto.createPrivateKey({
@@ -372,10 +403,46 @@ function decryptPrivateKey(pem, passphrase) {
372
403
  passphrase
373
404
  }).export({ type: "pkcs8", format: "pem" });
374
405
  }
406
+ async function executeWithSizeLimit(conn, sql, options) {
407
+ const rows = [];
408
+ let acc = 0;
409
+ let exceeded = false;
410
+ await new Promise((resolve, reject) => {
411
+ const stmt = conn.execute({
412
+ sqlText: sql,
413
+ streamResult: true
414
+ });
415
+ const stream = stmt.streamRows();
416
+ stream.on("data", (row) => {
417
+ if (exceeded) return;
418
+ acc = approxBytes(row, acc, options.maxBytes);
419
+ if (acc > options.maxBytes) {
420
+ exceeded = true;
421
+ stream.destroy();
422
+ stmt.cancel(() => {
423
+ });
424
+ resolve();
425
+ return;
426
+ }
427
+ rows.push(row);
428
+ });
429
+ stream.on("end", () => {
430
+ resolve();
431
+ });
432
+ stream.on("error", (err) => {
433
+ if (exceeded) return;
434
+ reject(new Error(`Snowflake query failed: ${err.message}`));
435
+ });
436
+ });
437
+ if (exceeded) {
438
+ return { exceeded: true };
439
+ }
440
+ return { exceeded: false, rows };
441
+ }
375
442
 
376
443
  // ../connectors/src/connectors/snowflake/tools/execute-query.ts
377
- var MAX_ROWS = 500;
378
- var QUERY_TIMEOUT_MS = 6e4;
444
+ var MAX_RESULT_BYTES = 5 * 1024 * 1024;
445
+ var STATEMENT_TIMEOUT_SECONDS = 60;
379
446
  var inputSchema = z.object({
380
447
  toolUseIntent: z.string().optional().describe(
381
448
  "Brief description of what you intend to accomplish with this tool call"
@@ -389,7 +456,6 @@ var outputSchema = z.discriminatedUnion("success", [
389
456
  z.object({
390
457
  success: z.literal(true),
391
458
  rowCount: z.number(),
392
- truncated: z.boolean(),
393
459
  rows: z.array(z.record(z.string(), z.unknown()))
394
460
  }),
395
461
  z.object({
@@ -399,9 +465,12 @@ var outputSchema = z.discriminatedUnion("success", [
399
465
  ]);
400
466
  var executeQueryTool = new ConnectorTool({
401
467
  name: "executeQuery",
402
- description: `Execute SQL against Snowflake. Returns up to ${MAX_ROWS} rows.
403
- Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), data sampling, analytical queries.
404
- Avoid loading large amounts of data; always include LIMIT in queries.`,
468
+ 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).
469
+ Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), sampling (LIMIT, SAMPLE), and analytical queries.
470
+ Memory guidance:
471
+ - 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).
472
+ - For full-dataset analysis, do the aggregation inside Snowflake (COUNT, SUM, GROUP BY, APPROX_TOP_K, HISTOGRAM) instead of returning raw rows.
473
+ - Exploration is iterative: start with a small LIMIT to inspect shape, then refine.`,
405
474
  inputSchema,
406
475
  outputSchema,
407
476
  async execute({ connectionId, sql }, connections) {
@@ -443,39 +512,43 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
443
512
  else resolve();
444
513
  });
445
514
  });
446
- const allRows = await new Promise(
447
- (resolve, reject) => {
448
- const timeoutId = setTimeout(() => {
449
- reject(
450
- new Error(
451
- "Snowflake query timeout: query exceeded 60 seconds"
452
- )
453
- );
454
- }, QUERY_TIMEOUT_MS);
515
+ try {
516
+ await new Promise((resolve, reject) => {
455
517
  conn.execute({
456
- sqlText: sql,
457
- complete: (err, _stmt, rows) => {
458
- clearTimeout(timeoutId);
518
+ sqlText: `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${STATEMENT_TIMEOUT_SECONDS}`,
519
+ complete: (err) => {
459
520
  if (err)
460
- reject(new Error(`Snowflake query failed: ${err.message}`));
461
- else resolve(rows ?? []);
521
+ reject(
522
+ new Error(
523
+ `Failed to set Snowflake statement timeout: ${err.message}`
524
+ )
525
+ );
526
+ else resolve();
462
527
  }
463
528
  });
529
+ });
530
+ const result = await executeWithSizeLimit(conn, sql, {
531
+ maxBytes: MAX_RESULT_BYTES
532
+ });
533
+ if (result.exceeded) {
534
+ return {
535
+ success: false,
536
+ 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)."
537
+ };
464
538
  }
465
- );
466
- conn.destroy((err) => {
467
- if (err)
468
- console.warn(
469
- `[connector-query] Snowflake destroy error: ${err.message}`
470
- );
471
- });
472
- const truncated = allRows.length > MAX_ROWS;
473
- return {
474
- success: true,
475
- rowCount: Math.min(allRows.length, MAX_ROWS),
476
- truncated,
477
- rows: allRows.slice(0, MAX_ROWS)
478
- };
539
+ return {
540
+ success: true,
541
+ rowCount: result.rows.length,
542
+ rows: result.rows
543
+ };
544
+ } finally {
545
+ conn.destroy((err) => {
546
+ if (err)
547
+ console.warn(
548
+ `[connector-query] Snowflake destroy error: ${err.message}`
549
+ );
550
+ });
551
+ }
479
552
  } catch (err) {
480
553
  const msg = err instanceof Error ? err.message : String(err);
481
554
  return { success: false, error: msg };
@@ -664,8 +737,8 @@ var parameters2 = {
664
737
 
665
738
  // ../connectors/src/connectors/snowflake-pat/tools/execute-query.ts
666
739
  import { z as z2 } from "zod";
667
- var MAX_ROWS2 = 500;
668
- var QUERY_TIMEOUT_MS2 = 6e4;
740
+ var MAX_ROWS = 500;
741
+ var QUERY_TIMEOUT_MS = 6e4;
669
742
  var inputSchema2 = z2.object({
670
743
  toolUseIntent: z2.string().optional().describe(
671
744
  "Brief description of what you intend to accomplish with this tool call"
@@ -689,7 +762,7 @@ var outputSchema2 = z2.discriminatedUnion("success", [
689
762
  ]);
690
763
  var executeQueryTool2 = new ConnectorTool({
691
764
  name: "executeQuery",
692
- description: `Execute SQL against Snowflake. Returns up to ${MAX_ROWS2} rows.
765
+ description: `Execute SQL against Snowflake. Returns up to ${MAX_ROWS} rows.
693
766
  Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA), data sampling, analytical queries.
694
767
  Avoid loading large amounts of data; always include LIMIT in queries.`,
695
768
  inputSchema: inputSchema2,
@@ -735,7 +808,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
735
808
  "Snowflake query timeout: query exceeded 60 seconds"
736
809
  )
737
810
  );
738
- }, QUERY_TIMEOUT_MS2);
811
+ }, QUERY_TIMEOUT_MS);
739
812
  conn.execute({
740
813
  sqlText: sql,
741
814
  complete: (err, _stmt, rows) => {
@@ -753,12 +826,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
753
826
  `[connector-query] Snowflake destroy error: ${err.message}`
754
827
  );
755
828
  });
756
- const truncated = allRows.length > MAX_ROWS2;
829
+ const truncated = allRows.length > MAX_ROWS;
757
830
  return {
758
831
  success: true,
759
- rowCount: Math.min(allRows.length, MAX_ROWS2),
832
+ rowCount: Math.min(allRows.length, MAX_ROWS),
760
833
  truncated,
761
- rows: allRows.slice(0, MAX_ROWS2)
834
+ rows: allRows.slice(0, MAX_ROWS)
762
835
  };
763
836
  } catch (err) {
764
837
  const msg = err instanceof Error ? err.message : String(err);
@@ -1092,7 +1165,7 @@ var POSTGRES_DEFAULT_PORT = 5432;
1092
1165
 
1093
1166
  // ../connectors/src/connectors/postgresql/tools/execute-query.ts
1094
1167
  import { z as z3 } from "zod";
1095
- var MAX_ROWS3 = 500;
1168
+ var MAX_ROWS2 = 500;
1096
1169
  var CONNECT_TIMEOUT_MS = 1e4;
1097
1170
  var STATEMENT_TIMEOUT_MS = 6e4;
1098
1171
  var inputSchema3 = z3.object({
@@ -1116,7 +1189,7 @@ var outputSchema3 = z3.discriminatedUnion("success", [
1116
1189
  ]);
1117
1190
  var executeQueryTool3 = new ConnectorTool({
1118
1191
  name: "executeQuery",
1119
- description: `Execute SQL against PostgreSQL. Returns up to ${MAX_ROWS3} rows.
1192
+ description: `Execute SQL against PostgreSQL. Returns up to ${MAX_ROWS2} rows.
1120
1193
  Use for: schema exploration (information_schema), data sampling, analytical queries.
1121
1194
  Avoid loading large amounts of data; always include LIMIT in queries.`,
1122
1195
  inputSchema: inputSchema3,
@@ -1154,12 +1227,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1154
1227
  STATEMENT_TIMEOUT_MS
1155
1228
  );
1156
1229
  const rows = result.rows;
1157
- const truncated = rows.length > MAX_ROWS3;
1230
+ const truncated = rows.length > MAX_ROWS2;
1158
1231
  return {
1159
1232
  success: true,
1160
- rowCount: Math.min(rows.length, MAX_ROWS3),
1233
+ rowCount: Math.min(rows.length, MAX_ROWS2),
1161
1234
  truncated,
1162
- rows: rows.slice(0, MAX_ROWS3)
1235
+ rows: rows.slice(0, MAX_ROWS2)
1163
1236
  };
1164
1237
  } finally {
1165
1238
  await pool.end();
@@ -1296,9 +1369,9 @@ var MYSQL_DEFAULT_PORT = 3306;
1296
1369
 
1297
1370
  // ../connectors/src/connectors/mysql/tools/execute-query.ts
1298
1371
  import { z as z4 } from "zod";
1299
- var MAX_ROWS4 = 500;
1372
+ var MAX_ROWS3 = 500;
1300
1373
  var CONNECT_TIMEOUT_MS2 = 1e4;
1301
- var QUERY_TIMEOUT_MS3 = 6e4;
1374
+ var QUERY_TIMEOUT_MS2 = 6e4;
1302
1375
  var inputSchema4 = z4.object({
1303
1376
  toolUseIntent: z4.string().optional().describe(
1304
1377
  "Brief description of what you intend to accomplish with this tool call"
@@ -1320,7 +1393,7 @@ var outputSchema4 = z4.discriminatedUnion("success", [
1320
1393
  ]);
1321
1394
  var executeQueryTool4 = new ConnectorTool({
1322
1395
  name: "executeQuery",
1323
- description: `Execute SQL against MySQL. Returns up to ${MAX_ROWS4} rows.
1396
+ description: `Execute SQL against MySQL. Returns up to ${MAX_ROWS3} rows.
1324
1397
  Use for: schema exploration (information_schema), data sampling, analytical queries.
1325
1398
  Avoid loading large amounts of data; always include LIMIT in queries.`,
1326
1399
  inputSchema: inputSchema4,
@@ -1353,16 +1426,16 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1353
1426
  try {
1354
1427
  const queryPromise = pool.query(sql);
1355
1428
  const timeoutPromise = new Promise(
1356
- (_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")), QUERY_TIMEOUT_MS3)
1429
+ (_, reject) => setTimeout(() => reject(new Error("Query timed out after 60 seconds")), QUERY_TIMEOUT_MS2)
1357
1430
  );
1358
1431
  const [rows] = await Promise.race([queryPromise, timeoutPromise]);
1359
1432
  const resultRows = Array.isArray(rows) ? rows : [];
1360
- const truncated = resultRows.length > MAX_ROWS4;
1433
+ const truncated = resultRows.length > MAX_ROWS3;
1361
1434
  return {
1362
1435
  success: true,
1363
- rowCount: Math.min(resultRows.length, MAX_ROWS4),
1436
+ rowCount: Math.min(resultRows.length, MAX_ROWS3),
1364
1437
  truncated,
1365
- rows: resultRows.slice(0, MAX_ROWS4)
1438
+ rows: resultRows.slice(0, MAX_ROWS3)
1366
1439
  };
1367
1440
  } finally {
1368
1441
  await pool.end();
@@ -1689,7 +1762,7 @@ var bigqueryOnboarding = new ConnectorOnboarding({
1689
1762
 
1690
1763
  // ../connectors/src/connectors/bigquery/tools/execute-query.ts
1691
1764
  import { z as z7 } from "zod";
1692
- var MAX_ROWS5 = 500;
1765
+ var MAX_ROWS4 = 500;
1693
1766
  var inputSchema7 = z7.object({
1694
1767
  toolUseIntent: z7.string().optional().describe(
1695
1768
  "Brief description of what you intend to accomplish with this tool call"
@@ -1713,7 +1786,7 @@ var outputSchema7 = z7.discriminatedUnion("success", [
1713
1786
  ]);
1714
1787
  var executeQueryTool5 = new ConnectorTool({
1715
1788
  name: "executeQuery",
1716
- description: `Execute SQL against BigQuery. Returns up to ${MAX_ROWS5} rows.
1789
+ description: `Execute SQL against BigQuery. Returns up to ${MAX_ROWS4} rows.
1717
1790
  Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
1718
1791
  Avoid loading large amounts of data; always include LIMIT in queries.`,
1719
1792
  inputSchema: inputSchema7,
@@ -1740,12 +1813,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
1740
1813
  const [job] = await bq.createQueryJob({ query: sql });
1741
1814
  const [rows] = await job.getQueryResults();
1742
1815
  const allRows = rows;
1743
- const truncated = allRows.length > MAX_ROWS5;
1816
+ const truncated = allRows.length > MAX_ROWS4;
1744
1817
  return {
1745
1818
  success: true,
1746
- rowCount: Math.min(allRows.length, MAX_ROWS5),
1819
+ rowCount: Math.min(allRows.length, MAX_ROWS4),
1747
1820
  truncated,
1748
- rows: allRows.slice(0, MAX_ROWS5)
1821
+ rows: allRows.slice(0, MAX_ROWS4)
1749
1822
  };
1750
1823
  } catch (err) {
1751
1824
  const msg = err instanceof Error ? err.message : String(err);
@@ -2146,7 +2219,7 @@ var bigqueryOnboarding2 = new ConnectorOnboarding({
2146
2219
 
2147
2220
  // ../connectors/src/connectors/bigquery-oauth/tools/execute-query.ts
2148
2221
  import { z as z10 } from "zod";
2149
- var MAX_ROWS6 = 500;
2222
+ var MAX_ROWS5 = 500;
2150
2223
  var REQUEST_TIMEOUT_MS3 = 6e4;
2151
2224
  var cachedToken3 = null;
2152
2225
  async function getProxyToken3(config) {
@@ -2213,7 +2286,7 @@ function parseQueryResponse(data) {
2213
2286
  }
2214
2287
  var executeQueryTool6 = new ConnectorTool({
2215
2288
  name: "executeQuery",
2216
- description: `Execute SQL against BigQuery via OAuth. Returns up to ${MAX_ROWS6} rows.
2289
+ description: `Execute SQL against BigQuery via OAuth. Returns up to ${MAX_ROWS5} rows.
2217
2290
  Use for: schema exploration (INFORMATION_SCHEMA), data sampling, analytical queries.
2218
2291
  Avoid loading large amounts of data; always include LIMIT in queries.`,
2219
2292
  inputSchema: inputSchema10,
@@ -2246,7 +2319,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
2246
2319
  body: JSON.stringify({
2247
2320
  url: queryUrl,
2248
2321
  method: "POST",
2249
- body: { query: sql, useLegacySql: false, maxResults: MAX_ROWS6 }
2322
+ body: { query: sql, useLegacySql: false, maxResults: MAX_ROWS5 }
2250
2323
  }),
2251
2324
  signal: controller.signal
2252
2325
  });
@@ -2256,12 +2329,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
2256
2329
  return { success: false, error: errorMessage };
2257
2330
  }
2258
2331
  const rows = parseQueryResponse(data);
2259
- const truncated = rows.length > MAX_ROWS6;
2332
+ const truncated = rows.length > MAX_ROWS5;
2260
2333
  return {
2261
2334
  success: true,
2262
- rowCount: Math.min(rows.length, MAX_ROWS6),
2335
+ rowCount: Math.min(rows.length, MAX_ROWS5),
2263
2336
  truncated,
2264
- rows: rows.slice(0, MAX_ROWS6)
2337
+ rows: rows.slice(0, MAX_ROWS5)
2265
2338
  };
2266
2339
  } finally {
2267
2340
  clearTimeout(timeout);
@@ -2441,7 +2514,7 @@ var parameters7 = {
2441
2514
 
2442
2515
  // ../connectors/src/connectors/aws-athena/tools/execute-query.ts
2443
2516
  import { z as z11 } from "zod";
2444
- var MAX_ROWS7 = 500;
2517
+ var MAX_ROWS6 = 500;
2445
2518
  var POLL_INTERVAL_MS = 1e3;
2446
2519
  var POLL_TIMEOUT_MS = 12e4;
2447
2520
  var inputSchema11 = z11.object({
@@ -2465,7 +2538,7 @@ var outputSchema11 = z11.discriminatedUnion("success", [
2465
2538
  ]);
2466
2539
  var executeQueryTool7 = new ConnectorTool({
2467
2540
  name: "executeQuery",
2468
- description: `Execute SQL against AWS Athena. Returns up to ${MAX_ROWS7} rows.
2541
+ description: `Execute SQL against AWS Athena. Returns up to ${MAX_ROWS6} rows.
2469
2542
  Use for: schema exploration (SHOW DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries on S3 data.
2470
2543
  Avoid loading large amounts of data; always include LIMIT in queries.`,
2471
2544
  inputSchema: inputSchema11,
@@ -2542,12 +2615,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
2542
2615
  });
2543
2616
  return obj;
2544
2617
  });
2545
- const truncated = dataRows.length > MAX_ROWS7;
2618
+ const truncated = dataRows.length > MAX_ROWS6;
2546
2619
  return {
2547
2620
  success: true,
2548
- rowCount: Math.min(dataRows.length, MAX_ROWS7),
2621
+ rowCount: Math.min(dataRows.length, MAX_ROWS6),
2549
2622
  truncated,
2550
- rows: dataRows.slice(0, MAX_ROWS7)
2623
+ rows: dataRows.slice(0, MAX_ROWS6)
2551
2624
  };
2552
2625
  } catch (err) {
2553
2626
  const msg = err instanceof Error ? err.message : String(err);
@@ -3462,7 +3535,7 @@ var parameters9 = {
3462
3535
 
3463
3536
  // ../connectors/src/connectors/redshift/tools/execute-query.ts
3464
3537
  import { z as z15 } from "zod";
3465
- var MAX_ROWS8 = 500;
3538
+ var MAX_ROWS7 = 500;
3466
3539
  var POLL_INTERVAL_MS2 = 1e3;
3467
3540
  var POLL_TIMEOUT_MS2 = 12e4;
3468
3541
  var inputSchema15 = z15.object({
@@ -3488,7 +3561,7 @@ var outputSchema15 = z15.discriminatedUnion("success", [
3488
3561
  ]);
3489
3562
  var executeQueryTool8 = new ConnectorTool({
3490
3563
  name: "executeQuery",
3491
- description: `Execute SQL against Amazon Redshift. Returns up to ${MAX_ROWS8} rows.
3564
+ description: `Execute SQL against Amazon Redshift. Returns up to ${MAX_ROWS7} rows.
3492
3565
  Use for: schema exploration, data sampling, analytical queries.
3493
3566
  Avoid loading large amounts of data; always include LIMIT in queries.`,
3494
3567
  inputSchema: inputSchema15,
@@ -3567,12 +3640,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
3567
3640
  });
3568
3641
  return row;
3569
3642
  });
3570
- const truncated = allRows.length > MAX_ROWS8;
3643
+ const truncated = allRows.length > MAX_ROWS7;
3571
3644
  return {
3572
3645
  success: true,
3573
- rowCount: Math.min(allRows.length, MAX_ROWS8),
3646
+ rowCount: Math.min(allRows.length, MAX_ROWS7),
3574
3647
  truncated,
3575
- rows: allRows.slice(0, MAX_ROWS8)
3648
+ rows: allRows.slice(0, MAX_ROWS7)
3576
3649
  };
3577
3650
  } catch (err) {
3578
3651
  const msg = err instanceof Error ? err.message : String(err);
@@ -3793,7 +3866,7 @@ var parameters10 = {
3793
3866
 
3794
3867
  // ../connectors/src/connectors/databricks/tools/execute-query.ts
3795
3868
  import { z as z16 } from "zod";
3796
- var MAX_ROWS9 = 500;
3869
+ var MAX_ROWS8 = 500;
3797
3870
  var inputSchema16 = z16.object({
3798
3871
  toolUseIntent: z16.string().optional().describe(
3799
3872
  "Brief description of what you intend to accomplish with this tool call"
@@ -3815,7 +3888,7 @@ var outputSchema16 = z16.discriminatedUnion("success", [
3815
3888
  ]);
3816
3889
  var executeQueryTool9 = new ConnectorTool({
3817
3890
  name: "executeQuery",
3818
- description: `Execute SQL against Databricks. Returns up to ${MAX_ROWS9} rows.
3891
+ description: `Execute SQL against Databricks. Returns up to ${MAX_ROWS8} rows.
3819
3892
  Use for: schema exploration (SHOW CATALOGS/DATABASES/TABLES, DESCRIBE TABLE), data sampling, analytical queries.
3820
3893
  Avoid loading large amounts of data; always include LIMIT in queries.`,
3821
3894
  inputSchema: inputSchema16,
@@ -3846,12 +3919,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
3846
3919
  runAsync: true
3847
3920
  });
3848
3921
  const allRows = await operation.fetchAll();
3849
- const truncated = allRows.length > MAX_ROWS9;
3922
+ const truncated = allRows.length > MAX_ROWS8;
3850
3923
  return {
3851
3924
  success: true,
3852
- rowCount: Math.min(allRows.length, MAX_ROWS9),
3925
+ rowCount: Math.min(allRows.length, MAX_ROWS8),
3853
3926
  truncated,
3854
- rows: allRows.slice(0, MAX_ROWS9)
3927
+ rows: allRows.slice(0, MAX_ROWS8)
3855
3928
  };
3856
3929
  } finally {
3857
3930
  if (operation) await operation.close().catch(() => {
@@ -10796,7 +10869,7 @@ var parameters29 = {
10796
10869
 
10797
10870
  // ../connectors/src/connectors/squadbase-db/tools/execute-query.ts
10798
10871
  import { z as z40 } from "zod";
10799
- var MAX_ROWS10 = 500;
10872
+ var MAX_ROWS9 = 500;
10800
10873
  var CONNECT_TIMEOUT_MS3 = 1e4;
10801
10874
  var STATEMENT_TIMEOUT_MS2 = 6e4;
10802
10875
  var inputSchema40 = z40.object({
@@ -10820,7 +10893,7 @@ var outputSchema40 = z40.discriminatedUnion("success", [
10820
10893
  ]);
10821
10894
  var executeQueryTool10 = new ConnectorTool({
10822
10895
  name: "executeQuery",
10823
- description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${MAX_ROWS10} rows.
10896
+ description: `Execute SQL against Squadbase DB (PostgreSQL). Returns up to ${MAX_ROWS9} rows.
10824
10897
  Use for: schema exploration (information_schema), data sampling, analytical queries.
10825
10898
  Avoid loading large amounts of data; always include LIMIT in queries.`,
10826
10899
  inputSchema: inputSchema40,
@@ -10849,12 +10922,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
10849
10922
  try {
10850
10923
  const result = await pool.query(sql);
10851
10924
  const rows = result.rows;
10852
- const truncated = rows.length > MAX_ROWS10;
10925
+ const truncated = rows.length > MAX_ROWS9;
10853
10926
  return {
10854
10927
  success: true,
10855
- rowCount: Math.min(rows.length, MAX_ROWS10),
10928
+ rowCount: Math.min(rows.length, MAX_ROWS9),
10856
10929
  truncated,
10857
- rows: rows.slice(0, MAX_ROWS10)
10930
+ rows: rows.slice(0, MAX_ROWS9)
10858
10931
  };
10859
10932
  } finally {
10860
10933
  await pool.end();
@@ -13628,8 +13701,8 @@ var parameters41 = {
13628
13701
 
13629
13702
  // ../connectors/src/connectors/clickhouse/tools/execute-query.ts
13630
13703
  import { z as z49 } from "zod";
13631
- var MAX_ROWS11 = 500;
13632
- var QUERY_TIMEOUT_MS4 = 6e4;
13704
+ var MAX_ROWS10 = 500;
13705
+ var QUERY_TIMEOUT_MS3 = 6e4;
13633
13706
  var inputSchema49 = z49.object({
13634
13707
  toolUseIntent: z49.string().optional().describe(
13635
13708
  "Brief description of what you intend to accomplish with this tool call"
@@ -13651,7 +13724,7 @@ var outputSchema49 = z49.discriminatedUnion("success", [
13651
13724
  ]);
13652
13725
  var executeQueryTool11 = new ConnectorTool({
13653
13726
  name: "executeQuery",
13654
- description: `Execute SQL against ClickHouse. Returns up to ${MAX_ROWS11} rows.
13727
+ description: `Execute SQL against ClickHouse. Returns up to ${MAX_ROWS10} rows.
13655
13728
  Use for: schema exploration (SHOW DATABASES, SHOW TABLES, DESCRIBE TABLE), data sampling, analytical queries on large-scale columnar data.
13656
13729
  Avoid loading large amounts of data; always include LIMIT in queries.`,
13657
13730
  inputSchema: inputSchema49,
@@ -13679,7 +13752,7 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
13679
13752
  username,
13680
13753
  password: password || "",
13681
13754
  database: database || "default",
13682
- request_timeout: QUERY_TIMEOUT_MS4
13755
+ request_timeout: QUERY_TIMEOUT_MS3
13683
13756
  });
13684
13757
  try {
13685
13758
  const resultSet = await client.query({
@@ -13687,12 +13760,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
13687
13760
  format: "JSONEachRow"
13688
13761
  });
13689
13762
  const allRows = await resultSet.json();
13690
- const truncated = allRows.length > MAX_ROWS11;
13763
+ const truncated = allRows.length > MAX_ROWS10;
13691
13764
  return {
13692
13765
  success: true,
13693
- rowCount: Math.min(allRows.length, MAX_ROWS11),
13766
+ rowCount: Math.min(allRows.length, MAX_ROWS10),
13694
13767
  truncated,
13695
- rows: allRows.slice(0, MAX_ROWS11)
13768
+ rows: allRows.slice(0, MAX_ROWS10)
13696
13769
  };
13697
13770
  } finally {
13698
13771
  await client.close();
@@ -13848,7 +13921,7 @@ var parameters42 = {
13848
13921
  import { z as z50 } from "zod";
13849
13922
  var MAX_DOCUMENTS = 500;
13850
13923
  var CONNECT_TIMEOUT_MS4 = 1e4;
13851
- var QUERY_TIMEOUT_MS5 = 6e4;
13924
+ var QUERY_TIMEOUT_MS4 = 6e4;
13852
13925
  var inputSchema50 = z50.object({
13853
13926
  toolUseIntent: z50.string().optional().describe(
13854
13927
  "Brief description of what you intend to accomplish with this tool call"
@@ -13907,7 +13980,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
13907
13980
  const client = new MongoClient(connectionUrl, {
13908
13981
  connectTimeoutMS: CONNECT_TIMEOUT_MS4,
13909
13982
  serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS4,
13910
- socketTimeoutMS: QUERY_TIMEOUT_MS5
13983
+ socketTimeoutMS: QUERY_TIMEOUT_MS4
13911
13984
  });
13912
13985
  try {
13913
13986
  await client.connect();
@@ -13953,7 +14026,7 @@ For listing collections, use the aggregate tool with an empty pipeline on the sp
13953
14026
  import { z as z51 } from "zod";
13954
14027
  var MAX_DOCUMENTS2 = 500;
13955
14028
  var CONNECT_TIMEOUT_MS5 = 1e4;
13956
- var QUERY_TIMEOUT_MS6 = 6e4;
14029
+ var QUERY_TIMEOUT_MS5 = 6e4;
13957
14030
  var inputSchema51 = z51.object({
13958
14031
  toolUseIntent: z51.string().optional().describe(
13959
14032
  "Brief description of what you intend to accomplish with this tool call"
@@ -14004,7 +14077,7 @@ Common stages: $match (filter), $group (aggregate), $sort (order), $project (res
14004
14077
  const client = new MongoClient(connectionUrl, {
14005
14078
  connectTimeoutMS: CONNECT_TIMEOUT_MS5,
14006
14079
  serverSelectionTimeoutMS: CONNECT_TIMEOUT_MS5,
14007
- socketTimeoutMS: QUERY_TIMEOUT_MS6
14080
+ socketTimeoutMS: QUERY_TIMEOUT_MS5
14008
14081
  });
14009
14082
  try {
14010
14083
  await client.connect();
@@ -23233,7 +23306,7 @@ function redactJdbcUrl(jdbcUrl) {
23233
23306
  }
23234
23307
 
23235
23308
  // ../connectors/src/connectors/jdbc/tools/execute-query.ts
23236
- var MAX_ROWS12 = 500;
23309
+ var MAX_ROWS11 = 500;
23237
23310
  var CONNECT_TIMEOUT_MS7 = 1e4;
23238
23311
  var STATEMENT_TIMEOUT_MS3 = 6e4;
23239
23312
  var inputSchema82 = z82.object({
@@ -23259,7 +23332,7 @@ var outputSchema82 = z82.discriminatedUnion("success", [
23259
23332
  ]);
23260
23333
  var executeQueryTool12 = new ConnectorTool({
23261
23334
  name: "executeQuery",
23262
- description: `Execute a SQL query through the JDBC connector. Returns up to ${MAX_ROWS12} rows.
23335
+ description: `Execute a SQL query through the JDBC connector. Returns up to ${MAX_ROWS11} rows.
23263
23336
  Use for: schema exploration via \`information_schema\` (or USER_TABLES on Oracle), data sampling, analytical queries.
23264
23337
  The connector dispatches by JDBC URL prefix to the matching driver
23265
23338
  (PostgreSQL / Redshift / MySQL / MariaDB / SQL Server / Oracle), so use the dialect that matches the connection.
@@ -23300,9 +23373,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
23300
23373
  const rows = result.rows;
23301
23374
  return {
23302
23375
  success: true,
23303
- rowCount: Math.min(rows.length, MAX_ROWS12),
23304
- truncated: rows.length > MAX_ROWS12,
23305
- rows: rows.slice(0, MAX_ROWS12)
23376
+ rowCount: Math.min(rows.length, MAX_ROWS11),
23377
+ truncated: rows.length > MAX_ROWS11,
23378
+ rows: rows.slice(0, MAX_ROWS11)
23306
23379
  };
23307
23380
  }
23308
23381
  if (parsed.driver === "oracle") {
@@ -23317,9 +23390,9 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
23317
23390
  const rows = result.rows;
23318
23391
  return {
23319
23392
  success: true,
23320
- rowCount: Math.min(rows.length, MAX_ROWS12),
23321
- truncated: rows.length > MAX_ROWS12,
23322
- rows: rows.slice(0, MAX_ROWS12)
23393
+ rowCount: Math.min(rows.length, MAX_ROWS11),
23394
+ truncated: rows.length > MAX_ROWS11,
23395
+ rows: rows.slice(0, MAX_ROWS11)
23323
23396
  };
23324
23397
  }
23325
23398
  let tunnel;
@@ -23343,12 +23416,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
23343
23416
  STATEMENT_TIMEOUT_MS3
23344
23417
  );
23345
23418
  const rows = result.rows;
23346
- const truncated = rows.length > MAX_ROWS12;
23419
+ const truncated = rows.length > MAX_ROWS11;
23347
23420
  return {
23348
23421
  success: true,
23349
- rowCount: Math.min(rows.length, MAX_ROWS12),
23422
+ rowCount: Math.min(rows.length, MAX_ROWS11),
23350
23423
  truncated,
23351
- rows: rows.slice(0, MAX_ROWS12)
23424
+ rows: rows.slice(0, MAX_ROWS11)
23352
23425
  };
23353
23426
  } finally {
23354
23427
  await pool2.end();
@@ -23369,12 +23442,12 @@ Always bound results: LIMIT for PG/MySQL/Redshift, TOP for SQL Server, FETCH FIR
23369
23442
  );
23370
23443
  const [rows] = await Promise.race([queryPromise, timeoutPromise]);
23371
23444
  const resultRows = Array.isArray(rows) ? rows : [];
23372
- const truncated = resultRows.length > MAX_ROWS12;
23445
+ const truncated = resultRows.length > MAX_ROWS11;
23373
23446
  return {
23374
23447
  success: true,
23375
- rowCount: Math.min(resultRows.length, MAX_ROWS12),
23448
+ rowCount: Math.min(resultRows.length, MAX_ROWS11),
23376
23449
  truncated,
23377
- rows: resultRows.slice(0, MAX_ROWS12)
23450
+ rows: resultRows.slice(0, MAX_ROWS11)
23378
23451
  };
23379
23452
  } finally {
23380
23453
  await pool.end();
@@ -24643,7 +24716,7 @@ var parameters70 = {
24643
24716
 
24644
24717
  // ../connectors/src/connectors/supabase/tools/execute-query.ts
24645
24718
  import { z as z86 } from "zod";
24646
- var MAX_ROWS13 = 500;
24719
+ var MAX_ROWS12 = 500;
24647
24720
  var CONNECT_TIMEOUT_MS8 = 1e4;
24648
24721
  var STATEMENT_TIMEOUT_MS4 = 6e4;
24649
24722
  var inputSchema86 = z86.object({
@@ -24669,7 +24742,7 @@ var outputSchema86 = z86.discriminatedUnion("success", [
24669
24742
  ]);
24670
24743
  var executeQueryTool13 = new ConnectorTool({
24671
24744
  name: "executeQuery",
24672
- description: `Execute SQL against a Supabase Postgres database. Returns up to ${MAX_ROWS13} rows.
24745
+ description: `Execute SQL against a Supabase Postgres database. Returns up to ${MAX_ROWS12} rows.
24673
24746
  Use for: schema exploration (information_schema), data sampling, and analytical queries against Supabase tables.
24674
24747
  User tables live in the \`public\` schema by default; Supabase-managed metadata lives in \`auth\` and \`storage\`.
24675
24748
  Avoid loading large amounts of data; always include LIMIT in queries.`,
@@ -24699,12 +24772,12 @@ Avoid loading large amounts of data; always include LIMIT in queries.`,
24699
24772
  try {
24700
24773
  const result = await pool.query(sql);
24701
24774
  const rows = result.rows;
24702
- const truncated = rows.length > MAX_ROWS13;
24775
+ const truncated = rows.length > MAX_ROWS12;
24703
24776
  return {
24704
24777
  success: true,
24705
- rowCount: Math.min(rows.length, MAX_ROWS13),
24778
+ rowCount: Math.min(rows.length, MAX_ROWS12),
24706
24779
  truncated,
24707
- rows: rows.slice(0, MAX_ROWS13)
24780
+ rows: rows.slice(0, MAX_ROWS12)
24708
24781
  };
24709
24782
  } finally {
24710
24783
  await pool.end();
@@ -25183,7 +25256,7 @@ var parameters72 = {
25183
25256
 
25184
25257
  // ../connectors/src/connectors/sqlserver/tools/execute-query.ts
25185
25258
  import { z as z88 } from "zod";
25186
- var MAX_ROWS14 = 500;
25259
+ var MAX_ROWS13 = 500;
25187
25260
  var inputSchema88 = z88.object({
25188
25261
  toolUseIntent: z88.string().optional().describe(
25189
25262
  "Brief description of what you intend to accomplish with this tool call"
@@ -25207,7 +25280,7 @@ var outputSchema88 = z88.discriminatedUnion("success", [
25207
25280
  ]);
25208
25281
  var executeQueryTool14 = new ConnectorTool({
25209
25282
  name: "executeQuery",
25210
- description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${MAX_ROWS14} rows.
25283
+ description: `Execute a T-SQL query against Microsoft SQL Server. Returns up to ${MAX_ROWS13} rows.
25211
25284
  Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
25212
25285
  SQL Server uses \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets (\`[schema].[table]\`).
25213
25286
  Avoid loading large amounts of data; always include \`TOP\` in queries.`,
@@ -25240,12 +25313,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
25240
25313
  const { rows } = await runMssqlQuery(parsed, sql, {
25241
25314
  tunnelParams: connectionParamsToRecord(connection)
25242
25315
  });
25243
- const truncated = rows.length > MAX_ROWS14;
25316
+ const truncated = rows.length > MAX_ROWS13;
25244
25317
  return {
25245
25318
  success: true,
25246
- rowCount: Math.min(rows.length, MAX_ROWS14),
25319
+ rowCount: Math.min(rows.length, MAX_ROWS13),
25247
25320
  truncated,
25248
- rows: rows.slice(0, MAX_ROWS14)
25321
+ rows: rows.slice(0, MAX_ROWS13)
25249
25322
  };
25250
25323
  } catch (err) {
25251
25324
  let msg = err instanceof Error ? err.message : String(err);
@@ -25378,7 +25451,7 @@ var parameters73 = {
25378
25451
 
25379
25452
  // ../connectors/src/connectors/azure-sql/tools/execute-query.ts
25380
25453
  import { z as z89 } from "zod";
25381
- var MAX_ROWS15 = 500;
25454
+ var MAX_ROWS14 = 500;
25382
25455
  var inputSchema89 = z89.object({
25383
25456
  toolUseIntent: z89.string().optional().describe(
25384
25457
  "Brief description of what you intend to accomplish with this tool call"
@@ -25402,7 +25475,7 @@ var outputSchema89 = z89.discriminatedUnion("success", [
25402
25475
  ]);
25403
25476
  var executeQueryTool15 = new ConnectorTool({
25404
25477
  name: "executeQuery",
25405
- description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${MAX_ROWS15} rows.
25478
+ description: `Execute a T-SQL query against Azure SQL Database. Returns up to ${MAX_ROWS14} rows.
25406
25479
  Use for: schema exploration via \`INFORMATION_SCHEMA\`, data sampling, and analytical queries.
25407
25480
  Azure SQL is T-SQL: use \`TOP n\` instead of \`LIMIT n\`. Identifiers can be wrapped in square brackets.
25408
25481
  Avoid loading large amounts of data; always include \`TOP\` in queries.`,
@@ -25436,12 +25509,12 @@ Avoid loading large amounts of data; always include \`TOP\` in queries.`,
25436
25509
  forceEncrypt: true,
25437
25510
  tunnelParams: connectionParamsToRecord(connection)
25438
25511
  });
25439
- const truncated = rows.length > MAX_ROWS15;
25512
+ const truncated = rows.length > MAX_ROWS14;
25440
25513
  return {
25441
25514
  success: true,
25442
- rowCount: Math.min(rows.length, MAX_ROWS15),
25515
+ rowCount: Math.min(rows.length, MAX_ROWS14),
25443
25516
  truncated,
25444
- rows: rows.slice(0, MAX_ROWS15)
25517
+ rows: rows.slice(0, MAX_ROWS14)
25445
25518
  };
25446
25519
  } catch (err) {
25447
25520
  let msg = err instanceof Error ? err.message : String(err);
@@ -25918,7 +25991,7 @@ var parameters75 = {
25918
25991
 
25919
25992
  // ../connectors/src/connectors/oracle/tools/execute-query.ts
25920
25993
  import { z as z92 } from "zod";
25921
- var MAX_ROWS16 = 500;
25994
+ var MAX_ROWS15 = 500;
25922
25995
  var inputSchema92 = z92.object({
25923
25996
  toolUseIntent: z92.string().optional().describe(
25924
25997
  "Brief description of what you intend to accomplish with this tool call"
@@ -25942,7 +26015,7 @@ var outputSchema92 = z92.discriminatedUnion("success", [
25942
26015
  ]);
25943
26016
  var executeQueryTool16 = new ConnectorTool({
25944
26017
  name: "executeQuery",
25945
- description: `Execute a query against an Oracle Database. Returns up to ${MAX_ROWS16} rows.
26018
+ description: `Execute a query against an Oracle Database. Returns up to ${MAX_ROWS15} rows.
25946
26019
  Use for: schema exploration via \`USER_TABLES\` / \`USER_TAB_COLUMNS\` / \`ALL_TABLES\`, data sampling, and analytical queries.
25947
26020
  Oracle uses \`FETCH FIRST n ROWS ONLY\` (12c+) or \`ROWNUM\` for row limiting \u2014 there is no \`LIMIT\` keyword.
25948
26021
  Unquoted identifiers are stored upper-case (\`SELECT * FROM employees\` resolves to \`EMPLOYEES\`).
@@ -25977,12 +26050,12 @@ Do NOT terminate statements with a semicolon; the driver rejects trailing termin
25977
26050
  const { rows } = await runOracleQuery(parsed, cleanSql, {
25978
26051
  tunnelParams: connectionParamsToRecord(connection)
25979
26052
  });
25980
- const truncated = rows.length > MAX_ROWS16;
26053
+ const truncated = rows.length > MAX_ROWS15;
25981
26054
  return {
25982
26055
  success: true,
25983
- rowCount: Math.min(rows.length, MAX_ROWS16),
26056
+ rowCount: Math.min(rows.length, MAX_ROWS15),
25984
26057
  truncated,
25985
- rows: rows.slice(0, MAX_ROWS16)
26058
+ rows: rows.slice(0, MAX_ROWS15)
25986
26059
  };
25987
26060
  } catch (err) {
25988
26061
  let msg = err instanceof Error ? err.message : String(err);
@@ -26001,7 +26074,7 @@ var oracleConnector = new ConnectorPlugin({
26001
26074
  description: "Connect to Oracle Database using a JDBC-style URL via the pure-JS Thin driver (no Oracle Instant Client required).",
26002
26075
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3iGEdzvGHncU5bYqFOROiV/9e7bdda7230d7ca6b34e7f6a862de876/oracle-icon.webp",
26003
26076
  parameters: parameters75,
26004
- releaseFlag: { dev1: true, dev2: false, prod: false },
26077
+ releaseFlag: { dev1: true, dev2: true, prod: true },
26005
26078
  categories: ["database"],
26006
26079
  onboarding: oracleOnboarding,
26007
26080
  systemPrompt: {
@@ -27478,119 +27551,1357 @@ export default async function handler(c: Context) {
27478
27551
  tools: tools79
27479
27552
  });
27480
27553
 
27481
- // ../connectors/src/connectors/registry.ts
27482
- var plugins = {
27483
- snowflake: snowflakeConnector,
27484
- snowflakePat: snowflakePatConnector,
27485
- bigquery: bigqueryConnector,
27486
- bigqueryOauth: bigqueryOauthConnector,
27487
- databricks: databricksConnector,
27488
- redshift: redshiftConnector,
27489
- dbt: dbtConnector,
27490
- awsAthena: awsAthenaConnector,
27491
- awsBilling: awsBillingConnector,
27492
- postgresql: postgresqlConnector,
27493
- mysql: mysqlConnector,
27494
- googleAds: googleAdsConnector,
27495
- googleAnalytics: googleAnalyticsConnector,
27496
- googleAnalyticsOauth: googleAnalyticsOauthConnector,
27497
- googleCalendar: googleCalendarConnector,
27498
- googleCalendarOauth: googleCalendarOauthConnector,
27499
- googleDocs: googleDocsConnector,
27500
- googleDrive: googleDriveConnector,
27501
- googleSheets: googleSheetsConnector,
27502
- googleSlides: googleSlidesConnector,
27503
- hubspotOauth: hubspotOauthConnector,
27504
- stripeOauth: stripeOauthConnector,
27505
- stripeApiKey: stripeApiKeyConnector,
27506
- airtable: airtableConnector,
27507
- airtableOauth: airtableOauthConnector,
27508
- squadbaseDb: squadbaseDbConnector,
27509
- kintone: kintoneConnector,
27510
- kintoneApiToken: kintoneApiTokenConnector,
27511
- wixStore: wixStoreConnector,
27512
- openai: openaiConnector,
27513
- gemini: geminiConnector,
27514
- anthropic: anthropicConnector,
27515
- amplitude: amplitudeConnector,
27516
- attio: attioConnector,
27517
- shopify: shopifyConnector,
27518
- shopifyOauth: shopifyOauthConnector,
27519
- hubspot: hubspotConnector,
27520
- jira: jiraConnector,
27521
- linear: linearConnector,
27522
- asana: asanaConnector,
27523
- clickhouse: clickhouseConnector,
27524
- mongodb: mongodbConnector,
27525
- notion: notionConnector,
27526
- notionOauth: notionOauthConnector,
27527
- metaAds: metaAdsConnector,
27528
- metaAdsOauth: metaAdsOauthConnector,
27529
- tiktokAds: tiktokAdsConnector,
27530
- mailchimp: mailchimpConnector,
27531
- mailchimpOauth: mailchimpOauthConnector,
27532
- customerio: customerioConnector,
27533
- gmail: gmailConnector,
27534
- gmailOauth: gmailOauthConnector,
27535
- googleAuditLog: googleAuditLogConnector,
27536
- linkedinAds: linkedinAdsConnector,
27537
- zendesk: zendeskConnector,
27538
- zendeskOauth: zendeskOauthConnector,
27539
- intercom: intercomConnector,
27540
- intercomOauth: intercomOauthConnector,
27541
- mixpanel: mixpanelConnector,
27542
- grafana: grafanaConnector,
27543
- backlog: backlogConnector,
27544
- gamma: gammaConnector,
27545
- sentry: sentryConnector,
27546
- salesforce: salesforceConnector,
27547
- influxdb: influxdbConnector,
27548
- monday: mondayConnector,
27549
- jdbc: jdbcConnector,
27550
- semrush: semrushConnector,
27551
- googleSearchConsoleOauth: googleSearchConsoleOauthConnector,
27552
- supabase: supabaseConnector,
27553
- clickup: clickupConnector,
27554
- sqlserver: sqlserverConnector,
27555
- azureSql: azureSqlConnector,
27556
- cosmosdb: cosmosdbConnector,
27557
- oracle: oracleConnector,
27558
- freshservice: freshserviceConnector,
27559
- freshdesk: freshdeskConnector,
27560
- freshsales: freshsalesConnector,
27561
- github: githubConnector
27562
- };
27563
- var connectors = {
27564
- ...plugins,
27565
- /**
27566
- * Return plugins that have at least one matching connection.
27567
- */
27568
- pluginsFor(connections) {
27569
- const keys = new Set(
27570
- connections.map(
27571
- (c) => ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType)
27572
- )
27573
- );
27574
- return Object.values(plugins).filter((p) => keys.has(p.connectorKey));
27575
- },
27576
- /**
27577
- * Find a plugin by slug and authType.
27578
- */
27579
- findByKey(slug, authType) {
27580
- const key = ConnectorPlugin.deriveKey(slug, authType);
27581
- return Object.values(plugins).find((p) => p.connectorKey === key);
27582
- }
27583
- };
27584
-
27585
- // src/connector-client/env.ts
27586
- function resolveEnvVar(entry, key, connectionId) {
27587
- const envVarName = entry.envVars[key];
27588
- if (!envVarName) {
27589
- throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
27554
+ // ../connectors/src/connectors/powerbi-oauth/tools/request.ts
27555
+ import { z as z97 } from "zod";
27556
+ var BASE_HOST12 = "https://api.powerbi.com";
27557
+ var BASE_PATH_SEGMENT15 = "/v1.0/myorg";
27558
+ var BASE_URL41 = `${BASE_HOST12}${BASE_PATH_SEGMENT15}`;
27559
+ var REQUEST_TIMEOUT_MS74 = 6e4;
27560
+ var cachedToken32 = null;
27561
+ async function getProxyToken32(config) {
27562
+ if (cachedToken32 && cachedToken32.expiresAt > Date.now() + 6e4) {
27563
+ return cachedToken32.token;
27590
27564
  }
27591
- const value = process.env[envVarName];
27592
- if (!value) {
27593
- throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
27565
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
27566
+ const res = await fetch(url, {
27567
+ method: "POST",
27568
+ headers: {
27569
+ "Content-Type": "application/json",
27570
+ "x-api-key": config.appApiKey,
27571
+ "project-id": config.projectId
27572
+ },
27573
+ body: JSON.stringify({
27574
+ sandboxId: config.sandboxId,
27575
+ issuedBy: "coding-agent"
27576
+ })
27577
+ });
27578
+ if (!res.ok) {
27579
+ const errorText = await res.text().catch(() => res.statusText);
27580
+ throw new Error(
27581
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
27582
+ );
27583
+ }
27584
+ const data = await res.json();
27585
+ cachedToken32 = {
27586
+ token: data.token,
27587
+ expiresAt: new Date(data.expiresAt).getTime()
27588
+ };
27589
+ return data.token;
27590
+ }
27591
+ var inputSchema97 = z97.object({
27592
+ toolUseIntent: z97.string().optional().describe(
27593
+ "Brief description of what you intend to accomplish with this tool call"
27594
+ ),
27595
+ connectionId: z97.string().describe("ID of the Power BI OAuth connection to use"),
27596
+ method: z97.enum(["GET", "POST", "PATCH", "PUT", "DELETE"]).describe(
27597
+ "HTTP method. GET for reading workspaces/datasets/reports, POST for executeQueries / refresh, PATCH/PUT for updates, DELETE for removal."
27598
+ ),
27599
+ path: z97.string().describe(
27600
+ "API path appended to https://api.powerbi.com/v1.0/myorg (e.g., '/groups', '/groups/{groupId}/datasets'). The authenticated user must have access to the workspace."
27601
+ ),
27602
+ queryParams: z97.record(z97.string(), z97.string()).optional().describe(
27603
+ `Query parameters to append (e.g., { $top: '50', $filter: "name eq 'Sales'" }).`
27604
+ ),
27605
+ body: z97.record(z97.string(), z97.unknown()).optional().describe(
27606
+ "JSON request body for POST/PATCH/PUT/DELETE. Example executeQueries body: { queries: [{ query: 'EVALUATE TOPN(10, Sales)' }], serializerSettings: { includeNulls: true } }."
27607
+ )
27608
+ });
27609
+ var outputSchema97 = z97.discriminatedUnion("success", [
27610
+ z97.object({
27611
+ success: z97.literal(true),
27612
+ status: z97.number(),
27613
+ data: z97.unknown()
27614
+ }),
27615
+ z97.object({
27616
+ success: z97.literal(false),
27617
+ error: z97.string()
27618
+ })
27619
+ ]);
27620
+ var requestTool56 = new ConnectorTool({
27621
+ name: "request",
27622
+ description: `Send authenticated requests to the Power BI REST API v1.0 using the user's Microsoft Entra OAuth token (proxied automatically).
27623
+ All paths are relative to https://api.powerbi.com/v1.0/myorg. Use the executeQueries endpoint to run DAX against a dataset.
27624
+ The signed-in user must have access to the workspace; unlike Service Principals, OAuth users can also access "My workspace" via the \`/datasets\` (without \`/groups/\`) endpoints.`,
27625
+ inputSchema: inputSchema97,
27626
+ outputSchema: outputSchema97,
27627
+ async execute({ connectionId, method, path: path4, queryParams, body }, connections, config) {
27628
+ const connection = connections.find((c) => c.id === connectionId);
27629
+ if (!connection) {
27630
+ return {
27631
+ success: false,
27632
+ error: `Connection ${connectionId} not found`
27633
+ };
27634
+ }
27635
+ console.log(
27636
+ `[connector-request] powerbi-oauth/${connection.name}: ${method} ${path4}`
27637
+ );
27638
+ try {
27639
+ const normalizedPath = normalizeRequestPath(path4, BASE_PATH_SEGMENT15);
27640
+ let url = `${BASE_URL41}${normalizedPath}`;
27641
+ if (queryParams) {
27642
+ const searchParams = new URLSearchParams(queryParams);
27643
+ url += `?${searchParams.toString()}`;
27644
+ }
27645
+ const token = await getProxyToken32(config.oauthProxy);
27646
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
27647
+ const controller = new AbortController();
27648
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS74);
27649
+ try {
27650
+ const response = await fetch(proxyUrl, {
27651
+ method: "POST",
27652
+ headers: {
27653
+ "Content-Type": "application/json",
27654
+ Authorization: `Bearer ${token}`
27655
+ },
27656
+ body: JSON.stringify({
27657
+ url,
27658
+ method,
27659
+ ...body !== void 0 ? { body } : {}
27660
+ }),
27661
+ signal: controller.signal
27662
+ });
27663
+ const text = await response.text();
27664
+ const data = text ? (() => {
27665
+ try {
27666
+ return JSON.parse(text);
27667
+ } catch {
27668
+ return text;
27669
+ }
27670
+ })() : null;
27671
+ if (!response.ok) {
27672
+ const errorMessage = data && typeof data === "object" && "error" in data ? JSON.stringify(data.error) : typeof data === "string" && data ? data : `HTTP ${response.status} ${response.statusText}`;
27673
+ return { success: false, error: errorMessage };
27674
+ }
27675
+ return { success: true, status: response.status, data };
27676
+ } finally {
27677
+ clearTimeout(timeout);
27678
+ }
27679
+ } catch (err) {
27680
+ const msg = err instanceof Error ? err.message : String(err);
27681
+ return { success: false, error: msg };
27682
+ }
27683
+ }
27684
+ });
27685
+
27686
+ // ../connectors/src/connectors/powerbi-oauth/setup.ts
27687
+ var requestToolName13 = `powerbi-oauth_${requestTool56.name}`;
27688
+ var powerbiOauthOnboarding = new ConnectorOnboarding({
27689
+ connectionSetupInstructions: {
27690
+ ja: `Power BI OAuth \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u306F\u4EE5\u4E0B\u306E\u624B\u9806\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
27691
+
27692
+ 1. \`${requestToolName13}\` \u3092 \`method: "GET"\`\u3001\`path: "/groups"\` \u3067\u547C\u3073\u51FA\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
27693
+ 2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001OAuth \u8A8D\u8A3C\u304C\u6B63\u3057\u304F\u5B8C\u4E86\u3057\u3066\u3044\u308B\u304B\u78BA\u8A8D\u3059\u308B\u3088\u3046\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u308B
27694
+
27695
+ #### \u5236\u7D04
27696
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B DAX \u30AF\u30A8\u30EA\u306E\u5B9F\u884C\u3084\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u306E\u66F4\u65B0\u3092\u884C\u308F\u306A\u3044\u3053\u3068**\u3002\u4E0A\u8A18\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u53D6\u5F97\u306E\u307F\u8A31\u53EF
27697
+ - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
27698
+ en: `Follow these steps to set up the Power BI OAuth connection.
27699
+
27700
+ 1. Call \`${requestToolName13}\` with \`method: "GET"\` and \`path: "/groups"\` to list the workspaces the user has access to
27701
+ 2. If an error is returned, ask the user to verify that OAuth authentication completed correctly
27702
+
27703
+ #### Constraints
27704
+ - **Do NOT execute DAX queries or refresh datasets during setup**. Only the workspace listing above is allowed
27705
+ - Write only 1 sentence between tool calls, then immediately call the next tool`
27706
+ },
27707
+ dataOverviewInstructions: {
27708
+ en: `1. Call powerbi-oauth_request with GET /groups to list accessible workspaces
27709
+ 2. For a target workspace, call powerbi-oauth_request with GET /groups/{groupId}/datasets to list datasets
27710
+ 3. Call powerbi-oauth_request with GET /groups/{groupId}/reports to list reports
27711
+ 4. For each interesting dataset call powerbi-oauth_request with GET /groups/{groupId}/datasets/{datasetId}/tables to inspect tables`,
27712
+ ja: `1. powerbi-oauth_request \u3067 GET /groups \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97
27713
+ 2. \u5BFE\u8C61\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B\u5BFE\u3057\u3066 powerbi-oauth_request \u3067 GET /groups/{groupId}/datasets \u3092\u547C\u3073\u51FA\u3057\u3001\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
27714
+ 3. powerbi-oauth_request \u3067 GET /groups/{groupId}/reports \u3092\u547C\u3073\u51FA\u3057\u3001\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
27715
+ 4. \u8208\u5473\u306E\u3042\u308B\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u306B\u3064\u3044\u3066 powerbi-oauth_request \u3067 GET /groups/{groupId}/datasets/{datasetId}/tables \u3092\u547C\u3073\u51FA\u3057\u3001\u30C6\u30FC\u30D6\u30EB\u69CB\u9020\u3092\u78BA\u8A8D`
27716
+ }
27717
+ });
27718
+
27719
+ // ../connectors/src/connectors/powerbi-oauth/parameters.ts
27720
+ var parameters80 = {};
27721
+
27722
+ // ../connectors/src/connectors/powerbi-oauth/index.ts
27723
+ var tools80 = { request: requestTool56 };
27724
+ var powerbiOauthConnector = new ConnectorPlugin({
27725
+ slug: "powerbi",
27726
+ authType: AUTH_TYPES.OAUTH,
27727
+ name: "Power BI",
27728
+ description: "Connect to Microsoft Power BI using OAuth (Microsoft Entra ID). Use it to enumerate workspaces, datasets, and reports the signed-in user has access to, and to run DAX queries.",
27729
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2vXQCKGpMJ9kGSaqkZl9IS/cc5669c267fc5d11e7b1f8c01723e461/power-bi-icon.png",
27730
+ parameters: parameters80,
27731
+ releaseFlag: { dev1: true, dev2: false, prod: false },
27732
+ categories: ["bi"],
27733
+ onboarding: powerbiOauthOnboarding,
27734
+ proxyPolicy: {
27735
+ allowlist: [
27736
+ {
27737
+ host: "api.powerbi.com",
27738
+ methods: ["GET", "POST", "PATCH", "PUT", "DELETE"]
27739
+ }
27740
+ ]
27741
+ },
27742
+ systemPrompt: {
27743
+ en: `### Tools
27744
+
27745
+ - \`powerbi-oauth_request\`: The only way to call the Power BI REST API v1.0. Use it to list workspaces (\`/groups\`), datasets, reports, and to run DAX via the \`executeQueries\` endpoint. Authentication is configured automatically via OAuth (Microsoft Entra ID).
27746
+
27747
+ ### Business Logic
27748
+
27749
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT access credentials directly from environment variables and do NOT read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
27750
+
27751
+ SDK surface (client created via \`connection(connectionId)\`):
27752
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path appended to \`https://api.powerbi.com/v1.0/myorg\`)
27753
+ - \`client.listGroups(options?)\` \u2014 list workspaces (\`$top\`, \`$skip\`, \`$filter\`)
27754
+ - \`client.listDatasets(groupId)\` / \`client.listReports(groupId)\` \u2014 list datasets / reports in a workspace
27755
+ - \`client.getDataset(groupId, datasetId)\` \u2014 fetch a single dataset
27756
+ - \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 run DAX queries
27757
+ - \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 trigger an async refresh
27758
+
27759
+ If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
27760
+
27761
+ \`\`\`ts
27762
+ import type { Context } from "hono";
27763
+ import { connection } from "@squadbase/vite-server/connectors/powerbi-oauth";
27764
+
27765
+ const powerbi = connection("<connectionId>");
27766
+
27767
+ export default async function handler(c: Context) {
27768
+ const { groupId, datasetId, dax } = await c.req.json<{
27769
+ groupId: string;
27770
+ datasetId: string;
27771
+ dax: string;
27772
+ }>();
27773
+
27774
+ const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
27775
+ const rows = result.results[0]?.tables[0]?.rows ?? [];
27776
+ return c.json({ rows });
27777
+ }
27778
+ \`\`\`
27779
+
27780
+ ### Power BI REST API Reference
27781
+
27782
+ - Base URL: \`https://api.powerbi.com/v1.0/myorg\`
27783
+ - Authentication: Microsoft Entra OAuth (delegated; handled automatically)
27784
+ - Unlike Service Principals, OAuth users can also access "My workspace" via the \`/datasets\` (without \`/groups/\`) endpoints
27785
+
27786
+ #### Common Endpoints
27787
+ - GET \`/groups\` \u2014 List workspaces the signed-in user has access to
27788
+ - GET \`/groups/{groupId}/datasets\` \u2014 List datasets in a workspace
27789
+ - GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 Get dataset metadata
27790
+ - GET \`/groups/{groupId}/reports\` \u2014 List reports
27791
+ - POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 Run DAX (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
27792
+ - POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 Trigger a dataset refresh
27793
+ - GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 List recent refresh history
27794
+
27795
+ #### DAX Tips
27796
+ - \`EVALUATE TOPN(10, 'TableName')\` \u2014 sample 10 rows from a table
27797
+ - \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 aggregate
27798
+ - Each \`executeQueries\` call accepts one query in the \`queries\` array (per current Power BI API limits)`,
27799
+ ja: `### \u30C4\u30FC\u30EB
27800
+
27801
+ - \`powerbi-oauth_request\`: Power BI REST API v1.0 \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9 (\`/groups\`)\u3001\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u3001\u30EC\u30DD\u30FC\u30C8\u306E\u4E00\u89A7\u53D6\u5F97\u3084\u3001\`executeQueries\` \u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306B\u3088\u308B DAX \u306E\u5B9F\u884C\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth (Microsoft Entra ID) \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
27802
+
27803
+ ### Business Logic
27804
+
27805
+ \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\u30BF SDK \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\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
27806
+
27807
+ SDK (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
27808
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u8A8D\u8A3C\u4ED8\u304D fetch (path \u306F \`https://api.powerbi.com/v1.0/myorg\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059)
27809
+ - \`client.listGroups(options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7 (\`$top\`, \`$skip\`, \`$filter\`)
27810
+ - \`client.listDatasets(groupId)\` / \`client.listReports(groupId)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8/\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
27811
+ - \`client.getDataset(groupId, datasetId)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u5358\u4F53\u53D6\u5F97
27812
+ - \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 DAX \u30AF\u30A8\u30EA\u5B9F\u884C
27813
+ - \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u3092\u975E\u540C\u671F\u30C8\u30EA\u30AC\u30FC
27814
+
27815
+ \u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
27816
+
27817
+ \`\`\`ts
27818
+ import type { Context } from "hono";
27819
+ import { connection } from "@squadbase/vite-server/connectors/powerbi-oauth";
27820
+
27821
+ const powerbi = connection("<connectionId>");
27822
+
27823
+ export default async function handler(c: Context) {
27824
+ const { groupId, datasetId, dax } = await c.req.json<{
27825
+ groupId: string;
27826
+ datasetId: string;
27827
+ dax: string;
27828
+ }>();
27829
+
27830
+ const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
27831
+ const rows = result.results[0]?.tables[0]?.rows ?? [];
27832
+ return c.json({ rows });
27833
+ }
27834
+ \`\`\`
27835
+
27836
+ ### Power BI REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
27837
+
27838
+ - \u30D9\u30FC\u30B9 URL: \`https://api.powerbi.com/v1.0/myorg\`
27839
+ - \u8A8D\u8A3C: Microsoft Entra OAuth (\u59D4\u4EFB\u578B\u3001\u81EA\u52D5\u8A2D\u5B9A)
27840
+ - Service Principal \u3068\u7570\u306A\u308A\u3001OAuth \u30E6\u30FC\u30B6\u30FC\u306F \`/datasets\` (\`/groups/\` \u7121\u3057) \u3067\u300C\u30DE\u30A4 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u300D\u306B\u3082\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD
27841
+
27842
+ #### \u4E3B\u8981\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
27843
+ - GET \`/groups\` \u2014 \u30E6\u30FC\u30B6\u30FC\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
27844
+ - GET \`/groups/{groupId}/datasets\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7
27845
+ - GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8 \u30E1\u30BF\u30C7\u30FC\u30BF
27846
+ - GET \`/groups/{groupId}/reports\` \u2014 \u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
27847
+ - POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 DAX \u5B9F\u884C (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
27848
+ - POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u30C8\u30EA\u30AC\u30FC
27849
+ - GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u76F4\u8FD1\u306E\u66F4\u65B0\u5C65\u6B74
27850
+
27851
+ #### DAX Tips
27852
+ - \`EVALUATE TOPN(10, 'TableName')\` \u2014 \u30C6\u30FC\u30D6\u30EB\u304B\u3089 10 \u884C\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
27853
+ - \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 \u96C6\u8A08
27854
+ - \`executeQueries\` \u306F\u73FE\u72B6 1 \u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u3064\u304D 1 \u30AF\u30A8\u30EA\u306E\u307F`
27855
+ },
27856
+ tools: tools80,
27857
+ async checkConnection(_params, config) {
27858
+ const { proxyFetch } = config;
27859
+ const url = "https://api.powerbi.com/v1.0/myorg/groups?$top=1";
27860
+ try {
27861
+ const res = await proxyFetch(url, { method: "GET" });
27862
+ if (!res.ok) {
27863
+ const errorText = await res.text().catch(() => res.statusText);
27864
+ return {
27865
+ success: false,
27866
+ error: `Power BI API failed: HTTP ${res.status} ${errorText}`
27867
+ };
27868
+ }
27869
+ return { success: true };
27870
+ } catch (error) {
27871
+ return {
27872
+ success: false,
27873
+ error: error instanceof Error ? error.message : String(error)
27874
+ };
27875
+ }
27876
+ }
27877
+ });
27878
+
27879
+ // ../connectors/src/connectors/tableau/setup.ts
27880
+ var tableauOnboarding = new ConnectorOnboarding({
27881
+ connectionSetupInstructions: {
27882
+ en: `Follow these steps to verify the Tableau PAT connection.
27883
+
27884
+ 1. Call \`tableau_request\` with \`method: "GET"\` and \`path: "/sites/{siteId}/projects?pageSize=5"\` to list a few projects on the signed-in site
27885
+ 2. If the call fails with HTTP 401, ask the user to confirm the PAT name/secret and that the Site Content URL matches the site where the PAT was issued (Tableau Cloud sites are case-sensitive)
27886
+
27887
+ #### Constraints
27888
+ - **Do NOT mutate Tableau resources during setup** (no publish/update/delete). Only the project listing above is allowed
27889
+ - The literal placeholder \`{siteId}\` in the path is automatically replaced with the session's site ID \u2014 do NOT hardcode the ID`,
27890
+ ja: `Tableau PAT \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u306F\u4EE5\u4E0B\u306E\u624B\u9806\u3067\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
27891
+
27892
+ 1. \`tableau_request\` \u3092 \`method: "GET"\`\u3001\`path: "/sites/{siteId}/projects?pageSize=5"\` \u3067\u547C\u3073\u51FA\u3057\u3001\u30B5\u30A4\u30F3\u30A4\u30F3\u5148\u30B5\u30A4\u30C8\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u3044\u304F\u3064\u304B\u53D6\u5F97\u3059\u308B
27893
+ 2. HTTP 401 \u3067\u5931\u6557\u3057\u305F\u5834\u5408\u306F\u3001PAT \u540D/\u30B7\u30FC\u30AF\u30EC\u30C3\u30C8\u304A\u3088\u3073 Site Content URL \u304C PAT \u767A\u884C\u30B5\u30A4\u30C8\u3068\u4E00\u81F4\u3057\u3066\u3044\u308B\u304B\u3092\u30E6\u30FC\u30B6\u30FC\u306B\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B\uFF08Tableau Cloud \u306E\u30B5\u30A4\u30C8\u540D\u306F\u5927\u6587\u5B57\u5C0F\u6587\u5B57\u3092\u533A\u5225\uFF09
27894
+
27895
+ #### \u5236\u7D04
27896
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B Tableau \u30EA\u30BD\u30FC\u30B9\u3092\u5909\u66F4\u3057\u306A\u3044\u3053\u3068**\uFF08publish/update/delete \u4E0D\u53EF\uFF09\u3002\u4E0A\u8A18\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u53D6\u5F97\u306E\u307F\u8A31\u53EF
27897
+ - \u30D1\u30B9\u5185\u306E\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC \`{siteId}\` \u306F\u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u30B5\u30A4\u30C8 ID \u3067\u81EA\u52D5\u7F6E\u63DB\u3055\u308C\u307E\u3059 \u2014 ID \u3092\u30CF\u30FC\u30C9\u30B3\u30FC\u30C9\u3057\u306A\u3044\u3053\u3068`
27898
+ },
27899
+ dataOverviewInstructions: {
27900
+ en: `1. Call tableau_request with GET /sites/{siteId}/projects to list projects
27901
+ 2. Call tableau_request with GET /sites/{siteId}/workbooks?pageSize=20 to list workbooks
27902
+ 3. For a target workbook, call tableau_request with GET /sites/{siteId}/workbooks/{workbookId}/views to list its views
27903
+ 4. Call tableau_request with GET /sites/{siteId}/datasources?pageSize=20 to list published data sources`,
27904
+ ja: `1. tableau_request \u3067 GET /sites/{siteId}/projects \u3092\u547C\u3073\u51FA\u3057\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
27905
+ 2. tableau_request \u3067 GET /sites/{siteId}/workbooks?pageSize=20 \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u4E00\u89A7\u3092\u53D6\u5F97
27906
+ 3. \u5BFE\u8C61\u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u306B\u3064\u3044\u3066 tableau_request \u3067 GET /sites/{siteId}/workbooks/{workbookId}/views \u3092\u547C\u3073\u51FA\u3057\u3001\u30D3\u30E5\u30FC\u4E00\u89A7\u3092\u53D6\u5F97
27907
+ 4. tableau_request \u3067 GET /sites/{siteId}/datasources?pageSize=20 \u3092\u547C\u3073\u51FA\u3057\u3001\u516C\u958B\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97`
27908
+ }
27909
+ });
27910
+
27911
+ // ../connectors/src/connectors/tableau/parameters.ts
27912
+ var parameters81 = {
27913
+ serverUrl: new ParameterDefinition({
27914
+ slug: "server-url",
27915
+ name: "Tableau Server URL",
27916
+ description: "Base URL of your Tableau Cloud / Server instance (no trailing slash). Examples: https://us-east-1.online.tableau.com, https://prod-useast-a.online.tableau.com, https://tableau.example.com.",
27917
+ envVarBaseKey: "TABLEAU_SERVER_URL",
27918
+ type: "text",
27919
+ secret: false,
27920
+ required: true
27921
+ }),
27922
+ siteContentUrl: new ParameterDefinition({
27923
+ slug: "site-content-url",
27924
+ name: "Site Content URL",
27925
+ description: "The site's content URL (the value after '/site/' in the Tableau URL). On Tableau Cloud this is required (e.g. 'mycompany'). On Tableau Server the Default site uses an empty string \u2014 pass an empty string explicitly.",
27926
+ envVarBaseKey: "TABLEAU_SITE_CONTENT_URL",
27927
+ type: "text",
27928
+ secret: false,
27929
+ required: true
27930
+ }),
27931
+ patName: new ParameterDefinition({
27932
+ slug: "pat-name",
27933
+ name: "Personal Access Token Name",
27934
+ description: "Name of the Personal Access Token (PAT) generated under Account Settings > Personal Access Tokens. The owning user's site role determines the API permissions.",
27935
+ envVarBaseKey: "TABLEAU_PAT_NAME",
27936
+ type: "text",
27937
+ secret: false,
27938
+ required: true
27939
+ }),
27940
+ patSecret: new ParameterDefinition({
27941
+ slug: "pat-secret",
27942
+ name: "Personal Access Token Secret",
27943
+ description: "Secret value shown once when the PAT is created. Tokens expire after 15 days of inactivity (default) and must be rotated regularly.",
27944
+ envVarBaseKey: "TABLEAU_PAT_SECRET",
27945
+ type: "text",
27946
+ secret: true,
27947
+ required: true
27948
+ }),
27949
+ apiVersion: new ParameterDefinition({
27950
+ slug: "api-version",
27951
+ name: "REST API Version",
27952
+ description: "Optional Tableau REST API version (e.g., '3.28'). Defaults to '3.28' which works with current Tableau Cloud and recent Tableau Server releases. Use the version listed at https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm if you need to pin.",
27953
+ envVarBaseKey: "TABLEAU_API_VERSION",
27954
+ type: "text",
27955
+ secret: false,
27956
+ required: false
27957
+ })
27958
+ };
27959
+
27960
+ // ../connectors/src/connectors/tableau/tools/request.ts
27961
+ import { z as z98 } from "zod";
27962
+ var DEFAULT_API_VERSION = "3.28";
27963
+ var REQUEST_TIMEOUT_MS75 = 6e4;
27964
+ var sessionCache = /* @__PURE__ */ new Map();
27965
+ function buildBaseUrl4(serverUrl, apiVersion) {
27966
+ return `${serverUrl.replace(/\/$/, "")}/api/${apiVersion}`;
27967
+ }
27968
+ async function signIn(serverUrl, apiVersion, siteContentUrl, patName, patSecret) {
27969
+ const url = `${buildBaseUrl4(serverUrl, apiVersion)}/auth/signin`;
27970
+ const body = {
27971
+ credentials: {
27972
+ personalAccessTokenName: patName,
27973
+ personalAccessTokenSecret: patSecret,
27974
+ site: { contentUrl: siteContentUrl }
27975
+ }
27976
+ };
27977
+ const res = await fetch(url, {
27978
+ method: "POST",
27979
+ headers: {
27980
+ "Content-Type": "application/json",
27981
+ Accept: "application/json"
27982
+ },
27983
+ body: JSON.stringify(body)
27984
+ });
27985
+ if (!res.ok) {
27986
+ const errorText = await res.text().catch(() => res.statusText);
27987
+ throw new Error(
27988
+ `Tableau sign-in failed: HTTP ${res.status} ${errorText}`
27989
+ );
27990
+ }
27991
+ const data = await res.json();
27992
+ return {
27993
+ authToken: data.credentials.token,
27994
+ siteId: data.credentials.site.id,
27995
+ userId: data.credentials.user.id,
27996
+ expiresAt: Date.now() + 30 * 60 * 1e3
27997
+ };
27998
+ }
27999
+ async function getSession(serverUrl, apiVersion, siteContentUrl, patName, patSecret) {
28000
+ const cacheKey = `${serverUrl}|${siteContentUrl}|${patName}`;
28001
+ const cached = sessionCache.get(cacheKey);
28002
+ if (cached && cached.expiresAt > Date.now() + 6e4) {
28003
+ return cached;
28004
+ }
28005
+ const session = await signIn(
28006
+ serverUrl,
28007
+ apiVersion,
28008
+ siteContentUrl,
28009
+ patName,
28010
+ patSecret
28011
+ );
28012
+ sessionCache.set(cacheKey, session);
28013
+ return session;
28014
+ }
28015
+ var inputSchema98 = z98.object({
28016
+ toolUseIntent: z98.string().optional().describe(
28017
+ "Brief description of what you intend to accomplish with this tool call"
28018
+ ),
28019
+ connectionId: z98.string().describe("ID of the Tableau connection to use"),
28020
+ method: z98.enum(["GET", "POST", "PUT", "DELETE"]).describe(
28021
+ "HTTP method. GET for listing/reading, POST for creating, PUT for updates, DELETE for removal."
28022
+ ),
28023
+ path: z98.string().describe(
28024
+ "API path appended to {serverUrl}/api/{apiVersion} (e.g., '/sites/{siteId}/projects', '/sites/{siteId}/workbooks/{workbookId}', '/sites/{siteId}/views/{viewId}/data'). The {siteId} placeholder is automatically replaced with the signed-in site ID."
28025
+ ),
28026
+ queryParams: z98.record(z98.string(), z98.string()).optional().describe(
28027
+ "Query parameters to append (e.g., { pageSize: '100', filter: 'name:eq:Sales' }). Tableau supports field filtering via 'fields' and sorting via 'sort'."
28028
+ ),
28029
+ body: z98.record(z98.string(), z98.unknown()).optional().describe(
28030
+ "JSON request body for POST/PUT (Tableau also accepts XML, but JSON is recommended with Accept: application/json)."
28031
+ )
28032
+ });
28033
+ var outputSchema98 = z98.discriminatedUnion("success", [
28034
+ z98.object({
28035
+ success: z98.literal(true),
28036
+ status: z98.number(),
28037
+ data: z98.unknown()
28038
+ }),
28039
+ z98.object({
28040
+ success: z98.literal(false),
28041
+ error: z98.string()
28042
+ })
28043
+ ]);
28044
+ var requestTool57 = new ConnectorTool({
28045
+ name: "request",
28046
+ description: `Send authenticated requests to the Tableau REST API.
28047
+ The tool signs in once with the configured Personal Access Token (PAT) to obtain an X-Tableau-Auth token (cached per connection), then forwards the request with the token attached.
28048
+ All paths are relative to {serverUrl}/api/{apiVersion}. Use the literal placeholder \`{siteId}\` in the path \u2014 it is automatically substituted with the site ID returned from sign-in.
28049
+ Accept and Content-Type headers default to application/json so list responses come back as JSON instead of Tableau's default XML.`,
28050
+ inputSchema: inputSchema98,
28051
+ outputSchema: outputSchema98,
28052
+ async execute({ connectionId, method, path: path4, queryParams, body }, connections) {
28053
+ const connection = connections.find((c) => c.id === connectionId);
28054
+ if (!connection) {
28055
+ return {
28056
+ success: false,
28057
+ error: `Connection ${connectionId} not found`
28058
+ };
28059
+ }
28060
+ console.log(
28061
+ `[connector-request] tableau/${connection.name}: ${method} ${path4}`
28062
+ );
28063
+ try {
28064
+ const serverUrl = parameters81.serverUrl.getValue(connection);
28065
+ const siteContentUrl = parameters81.siteContentUrl.getValue(connection);
28066
+ const patName = parameters81.patName.getValue(connection);
28067
+ const patSecret = parameters81.patSecret.getValue(connection);
28068
+ const apiVersion = parameters81.apiVersion.tryGetValue(connection) || DEFAULT_API_VERSION;
28069
+ const session = await getSession(
28070
+ serverUrl,
28071
+ apiVersion,
28072
+ siteContentUrl,
28073
+ patName,
28074
+ patSecret
28075
+ );
28076
+ const resolvedPath = path4.trim().replace(/\{siteId\}/g, session.siteId).replace(/^([^/])/, "/$1");
28077
+ let url = `${buildBaseUrl4(serverUrl, apiVersion)}${resolvedPath}`;
28078
+ if (queryParams) {
28079
+ const searchParams = new URLSearchParams(queryParams);
28080
+ url += `?${searchParams.toString()}`;
28081
+ }
28082
+ const controller = new AbortController();
28083
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS75);
28084
+ try {
28085
+ const init = {
28086
+ method,
28087
+ headers: {
28088
+ "X-Tableau-Auth": session.authToken,
28089
+ Accept: "application/json",
28090
+ "Content-Type": "application/json"
28091
+ },
28092
+ signal: controller.signal
28093
+ };
28094
+ if (body !== void 0) {
28095
+ init.body = JSON.stringify(body);
28096
+ }
28097
+ const response = await fetch(url, init);
28098
+ const text = await response.text();
28099
+ const data = text ? (() => {
28100
+ try {
28101
+ return JSON.parse(text);
28102
+ } catch {
28103
+ return text;
28104
+ }
28105
+ })() : null;
28106
+ if (!response.ok) {
28107
+ const errorMessage = data && typeof data === "object" && "error" in data ? JSON.stringify(data.error) : typeof data === "string" && data ? data : `HTTP ${response.status} ${response.statusText}`;
28108
+ return { success: false, error: errorMessage };
28109
+ }
28110
+ return { success: true, status: response.status, data };
28111
+ } finally {
28112
+ clearTimeout(timeout);
28113
+ }
28114
+ } catch (err) {
28115
+ const msg = err instanceof Error ? err.message : String(err);
28116
+ return { success: false, error: msg };
28117
+ }
28118
+ }
28119
+ });
28120
+
28121
+ // ../connectors/src/connectors/tableau/index.ts
28122
+ var tools81 = { request: requestTool57 };
28123
+ var tableauConnector = new ConnectorPlugin({
28124
+ slug: "tableau",
28125
+ authType: AUTH_TYPES.PAT,
28126
+ name: "Tableau",
28127
+ description: "Connect to Tableau Cloud or Tableau Server via a Personal Access Token (PAT). Use it to enumerate projects, workbooks, views, and data sources, and to pull view data.",
28128
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3ejrZvfw7zCDa3FPbUNQx9/d810e117b3a86c45dd96205453bf67a0/tableau-icon.svg",
28129
+ parameters: parameters81,
28130
+ releaseFlag: { dev1: true, dev2: false, prod: false },
28131
+ categories: ["bi"],
28132
+ onboarding: tableauOnboarding,
28133
+ systemPrompt: {
28134
+ en: `### Tools
28135
+
28136
+ - \`tableau_request\`: The only way to call the Tableau REST API. Use it for projects, workbooks, views, data sources, users, and permissions. The tool signs in once with the configured PAT to obtain an \`X-Tableau-Auth\` token (cached), then forwards each request with the token attached. Use the literal \`{siteId}\` placeholder in the path \u2014 it is replaced with the session's site ID automatically.
28137
+
28138
+ ### Business Logic
28139
+
28140
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
28141
+
28142
+ SDK methods (client created via \`connection(connectionId)\`):
28143
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path is appended to \`{serverUrl}/api/{apiVersion}\`; \`{siteId}\` is substituted)
28144
+ - \`client.getSession()\` \u2014 sign in (if needed) and return \`{ authToken, siteId, userId }\`
28145
+ - \`client.listProjects(options?)\` / \`client.listWorkbooks(options?)\` / \`client.listDatasources(options?)\`
28146
+ - \`client.listViewsForWorkbook(workbookId)\`
28147
+ - \`client.getViewData(viewId)\` \u2014 returns the view's underlying data as CSV text
28148
+
28149
+ \`\`\`ts
28150
+ import type { Context } from "hono";
28151
+ import { connection } from "@squadbase/vite-server/connectors/tableau";
28152
+
28153
+ const tableau = connection("<connectionId>");
28154
+
28155
+ export default async function handler(c: Context) {
28156
+ const { pageSize = 20 } = await c.req.json<{ pageSize?: number }>();
28157
+ const { workbooks, pagination } = await tableau.listWorkbooks({ pageSize });
28158
+ return c.json({
28159
+ workbooks: workbooks.workbook,
28160
+ totalAvailable: Number(pagination.totalAvailable),
28161
+ });
28162
+ }
28163
+ \`\`\`
28164
+
28165
+ ### Tableau REST API Reference
28166
+
28167
+ - Base URL: \`{serverUrl}/api/{apiVersion}\` (default version 3.28; see https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm)
28168
+ - Authentication: Sign-in with a PAT returns \`X-Tableau-Auth\` token, site ID, and user ID. Sessions expire after ~240 minutes idle on Tableau Cloud
28169
+ - Response format: JSON when \`Accept: application/json\` is sent (default); otherwise Tableau returns XML
28170
+ - Pagination: \`?pageSize=&pageNumber=\` query params with \`pagination\` object in response
28171
+
28172
+ #### Common Endpoints
28173
+ - POST \`/auth/signin\` \u2014 sign in (handled automatically)
28174
+ - POST \`/auth/signout\` \u2014 sign out
28175
+ - GET \`/sites/{siteId}/projects\` \u2014 list projects
28176
+ - GET \`/sites/{siteId}/workbooks\` \u2014 list workbooks (supports \`filter\`, \`sort\`)
28177
+ - GET \`/sites/{siteId}/workbooks/{workbookId}\` \u2014 get a workbook
28178
+ - GET \`/sites/{siteId}/workbooks/{workbookId}/views\` \u2014 list views in a workbook
28179
+ - GET \`/sites/{siteId}/views/{viewId}/data\` \u2014 get view data as CSV
28180
+ - GET \`/sites/{siteId}/views/{viewId}/image\` \u2014 get view as PNG
28181
+ - GET \`/sites/{siteId}/views/{viewId}/pdf\` \u2014 get view as PDF
28182
+ - GET \`/sites/{siteId}/datasources\` \u2014 list published data sources
28183
+ - GET \`/sites/{siteId}/users\` \u2014 list users
28184
+ - GET \`/sites/{siteId}/groups\` \u2014 list groups
28185
+
28186
+ #### Filter Syntax
28187
+ - \`filter=name:eq:Sales\` \u2014 exact match
28188
+ - \`filter=name:in:[Sales,Marketing]\` \u2014 set membership
28189
+ - \`filter=updatedAt:gte:2024-01-01T00:00:00Z\` \u2014 comparison operators (gt/gte/lt/lte)
28190
+ - Combine: \`filter=ownerName:eq:alice,tags:in:[finance]\``,
28191
+ ja: `### \u30C4\u30FC\u30EB
28192
+
28193
+ - \`tableau_request\`: Tableau REST API \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3001\u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u3001\u30D3\u30E5\u30FC\u3001\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u6A29\u9650\u306A\u3069\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A2D\u5B9A\u3055\u308C\u305F PAT \u3067\u4E00\u5EA6\u30B5\u30A4\u30F3\u30A4\u30F3\u3057\u3066 \`X-Tableau-Auth\` \u30C8\u30FC\u30AF\u30F3\u3092\u53D6\u5F97 (\u30AD\u30E3\u30C3\u30B7\u30E5) \u3057\u3001\u5404\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u305D\u306E\u30C8\u30FC\u30AF\u30F3\u3092\u4ED8\u3051\u3066\u9001\u4FE1\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306B\u306F \`{siteId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044 \u2014 \u30BB\u30C3\u30B7\u30E7\u30F3\u306E\u30B5\u30A4\u30C8 ID \u3067\u81EA\u52D5\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
28194
+
28195
+ ### Business Logic
28196
+
28197
+ \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BF SDK \u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
28198
+
28199
+ SDK \u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
28200
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u8A8D\u8A3C\u4ED8\u304D fetch (path \u306F \`{serverUrl}/api/{apiVersion}\` \u306B\u8FFD\u52A0\u3055\u308C\u3001\`{siteId}\` \u306F\u7F6E\u63DB\u3055\u308C\u307E\u3059)
28201
+ - \`client.getSession()\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3 (\u5FC5\u8981\u306A\u3089) \u3057\u3066 \`{ authToken, siteId, userId }\` \u3092\u8FD4\u3059
28202
+ - \`client.listProjects(options?)\` / \`client.listWorkbooks(options?)\` / \`client.listDatasources(options?)\`
28203
+ - \`client.listViewsForWorkbook(workbookId)\`
28204
+ - \`client.getViewData(viewId)\` \u2014 \u30D3\u30E5\u30FC\u306E\u30C7\u30FC\u30BF\u3092 CSV \u30C6\u30AD\u30B9\u30C8\u3067\u8FD4\u3059
28205
+
28206
+ \`\`\`ts
28207
+ import type { Context } from "hono";
28208
+ import { connection } from "@squadbase/vite-server/connectors/tableau";
28209
+
28210
+ const tableau = connection("<connectionId>");
28211
+
28212
+ export default async function handler(c: Context) {
28213
+ const { pageSize = 20 } = await c.req.json<{ pageSize?: number }>();
28214
+ const { workbooks, pagination } = await tableau.listWorkbooks({ pageSize });
28215
+ return c.json({
28216
+ workbooks: workbooks.workbook,
28217
+ totalAvailable: Number(pagination.totalAvailable),
28218
+ });
28219
+ }
28220
+ \`\`\`
28221
+
28222
+ ### Tableau REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
28223
+
28224
+ - \u30D9\u30FC\u30B9 URL: \`{serverUrl}/api/{apiVersion}\` (\u30C7\u30D5\u30A9\u30EB\u30C8\u30D0\u30FC\u30B8\u30E7\u30F3 3.28; https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm)
28225
+ - \u8A8D\u8A3C: PAT \u3067\u30B5\u30A4\u30F3\u30A4\u30F3\u3059\u308B\u3068 \`X-Tableau-Auth\` \u30C8\u30FC\u30AF\u30F3\u3001\u30B5\u30A4\u30C8 ID\u3001\u30E6\u30FC\u30B6\u30FC ID \u304C\u8FD4\u3055\u308C\u308B\u3002Tableau Cloud \u3067\u306F\u7D04 240 \u5206\u306E\u30A2\u30A4\u30C9\u30EB\u3067\u30BB\u30C3\u30B7\u30E7\u30F3\u5931\u52B9
28226
+ - \u30EC\u30B9\u30DD\u30F3\u30B9\u5F62\u5F0F: \`Accept: application/json\` \u3092\u9001\u308B\u3068 JSON (\u30C7\u30D5\u30A9\u30EB\u30C8)\u3002\u9001\u3089\u306A\u3044\u5834\u5408\u306F XML
28227
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \`?pageSize=&pageNumber=\` \u30AF\u30A8\u30EA\u3002\u30EC\u30B9\u30DD\u30F3\u30B9\u306B \`pagination\` \u30AA\u30D6\u30B8\u30A7\u30AF\u30C8
28228
+
28229
+ #### \u4E3B\u8981\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
28230
+ - POST \`/auth/signin\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3 (\u81EA\u52D5\u51E6\u7406)
28231
+ - POST \`/auth/signout\` \u2014 \u30B5\u30A4\u30F3\u30A2\u30A6\u30C8
28232
+ - GET \`/sites/{siteId}/projects\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7
28233
+ - GET \`/sites/{siteId}/workbooks\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u4E00\u89A7 (\`filter\`, \`sort\` \u5BFE\u5FDC)
28234
+ - GET \`/sites/{siteId}/workbooks/{workbookId}\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u53D6\u5F97
28235
+ - GET \`/sites/{siteId}/workbooks/{workbookId}/views\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u5185\u306E\u30D3\u30E5\u30FC\u4E00\u89A7
28236
+ - GET \`/sites/{siteId}/views/{viewId}/data\` \u2014 \u30D3\u30E5\u30FC\u30C7\u30FC\u30BF\u3092 CSV \u3067\u53D6\u5F97
28237
+ - GET \`/sites/{siteId}/views/{viewId}/image\` \u2014 \u30D3\u30E5\u30FC\u3092 PNG \u3067\u53D6\u5F97
28238
+ - GET \`/sites/{siteId}/views/{viewId}/pdf\` \u2014 \u30D3\u30E5\u30FC\u3092 PDF \u3067\u53D6\u5F97
28239
+ - GET \`/sites/{siteId}/datasources\` \u2014 \u516C\u958B\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9\u4E00\u89A7
28240
+ - GET \`/sites/{siteId}/users\` \u2014 \u30E6\u30FC\u30B6\u30FC\u4E00\u89A7
28241
+ - GET \`/sites/{siteId}/groups\` \u2014 \u30B0\u30EB\u30FC\u30D7\u4E00\u89A7
28242
+
28243
+ #### \u30D5\u30A3\u30EB\u30BF\u69CB\u6587
28244
+ - \`filter=name:eq:Sales\` \u2014 \u5B8C\u5168\u4E00\u81F4
28245
+ - \`filter=name:in:[Sales,Marketing]\` \u2014 \u96C6\u5408\u306B\u542B\u307E\u308C\u308B
28246
+ - \`filter=updatedAt:gte:2024-01-01T00:00:00Z\` \u2014 \u6BD4\u8F03\u6F14\u7B97\u5B50 (gt/gte/lt/lte)
28247
+ - \u7D44\u307F\u5408\u308F\u305B: \`filter=ownerName:eq:alice,tags:in:[finance]\``
28248
+ },
28249
+ tools: tools81,
28250
+ async checkConnection(params) {
28251
+ const serverUrl = params[parameters81.serverUrl.slug];
28252
+ const siteContentUrl = params[parameters81.siteContentUrl.slug];
28253
+ const patName = params[parameters81.patName.slug];
28254
+ const patSecret = params[parameters81.patSecret.slug];
28255
+ const apiVersion = params[parameters81.apiVersion.slug] || "3.28";
28256
+ if (!serverUrl || siteContentUrl == null || !patName || !patSecret) {
28257
+ return {
28258
+ success: false,
28259
+ error: "Missing required parameters: server-url, site-content-url, pat-name, pat-secret"
28260
+ };
28261
+ }
28262
+ try {
28263
+ const res = await fetch(
28264
+ `${serverUrl.replace(/\/$/, "")}/api/${apiVersion}/auth/signin`,
28265
+ {
28266
+ method: "POST",
28267
+ headers: {
28268
+ "Content-Type": "application/json",
28269
+ Accept: "application/json"
28270
+ },
28271
+ body: JSON.stringify({
28272
+ credentials: {
28273
+ personalAccessTokenName: patName,
28274
+ personalAccessTokenSecret: patSecret,
28275
+ site: { contentUrl: siteContentUrl }
28276
+ }
28277
+ })
28278
+ }
28279
+ );
28280
+ if (!res.ok) {
28281
+ const errorText = await res.text().catch(() => res.statusText);
28282
+ return {
28283
+ success: false,
28284
+ error: `Tableau sign-in failed: HTTP ${res.status} ${errorText}`
28285
+ };
28286
+ }
28287
+ return { success: true };
28288
+ } catch (error) {
28289
+ return {
28290
+ success: false,
28291
+ error: error instanceof Error ? error.message : String(error)
28292
+ };
28293
+ }
28294
+ }
28295
+ });
28296
+
28297
+ // ../connectors/src/connectors/outlook-oauth/tools/request.ts
28298
+ import { z as z99 } from "zod";
28299
+ var BASE_HOST13 = "https://graph.microsoft.com";
28300
+ var BASE_PATH_SEGMENT16 = "/v1.0";
28301
+ var BASE_URL42 = `${BASE_HOST13}${BASE_PATH_SEGMENT16}`;
28302
+ var REQUEST_TIMEOUT_MS76 = 6e4;
28303
+ var cachedToken33 = null;
28304
+ async function getProxyToken33(config) {
28305
+ if (cachedToken33 && cachedToken33.expiresAt > Date.now() + 6e4) {
28306
+ return cachedToken33.token;
28307
+ }
28308
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
28309
+ const res = await fetch(url, {
28310
+ method: "POST",
28311
+ headers: {
28312
+ "Content-Type": "application/json",
28313
+ "x-api-key": config.appApiKey,
28314
+ "project-id": config.projectId
28315
+ },
28316
+ body: JSON.stringify({
28317
+ sandboxId: config.sandboxId,
28318
+ issuedBy: "coding-agent"
28319
+ })
28320
+ });
28321
+ if (!res.ok) {
28322
+ const errorText = await res.text().catch(() => res.statusText);
28323
+ throw new Error(
28324
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
28325
+ );
28326
+ }
28327
+ const data = await res.json();
28328
+ cachedToken33 = {
28329
+ token: data.token,
28330
+ expiresAt: new Date(data.expiresAt).getTime()
28331
+ };
28332
+ return data.token;
28333
+ }
28334
+ var inputSchema99 = z99.object({
28335
+ toolUseIntent: z99.string().optional().describe(
28336
+ "Brief description of what you intend to accomplish with this tool call"
28337
+ ),
28338
+ connectionId: z99.string().describe("ID of the Outlook OAuth connection to use"),
28339
+ method: z99.enum(["GET"]).describe("HTTP method (read-only, GET only)"),
28340
+ path: z99.string().describe(
28341
+ "Microsoft Graph path appended to https://graph.microsoft.com/v1.0. Covers Outlook Mail (e.g. '/me', '/me/messages', '/me/messages/{id}', '/me/mailFolders', '/me/messages/{id}/attachments') and Outlook Calendar (e.g. '/me/calendars', '/me/events', '/me/events/{id}', '/me/calendarView'). Use '/me' as the user prefix."
28342
+ ),
28343
+ queryParams: z99.record(z99.string(), z99.string()).optional().describe(
28344
+ `Query parameters to append. Microsoft Graph supports OData operators ($filter, $orderby, $top, $skip, $select, $expand, $search). Examples: { $top: '10', $select: 'subject,from,receivedDateTime' } for mail; { $filter: "conversationId eq '<id>'", $orderby: 'receivedDateTime asc' } for a thread; { startDateTime: '2025-01-15T00:00:00Z', endDateTime: '2025-01-16T00:00:00Z', $orderby: 'start/dateTime' } for calendarView.`
28345
+ )
28346
+ });
28347
+ var outputSchema99 = z99.discriminatedUnion("success", [
28348
+ z99.object({
28349
+ success: z99.literal(true),
28350
+ status: z99.number(),
28351
+ data: z99.record(z99.string(), z99.unknown())
28352
+ }),
28353
+ z99.object({
28354
+ success: z99.literal(false),
28355
+ error: z99.string()
28356
+ })
28357
+ ]);
28358
+ var requestTool58 = new ConnectorTool({
28359
+ name: "request",
28360
+ description: `Send authenticated GET requests to Microsoft Graph for Outlook Mail and Calendar.
28361
+ Authentication is handled automatically via OAuth proxy (Microsoft Entra ID).
28362
+ All paths are relative to https://graph.microsoft.com/v1.0. Use '/me' as the user prefix.
28363
+ Covers mailbox (\`/me/messages\`, \`/me/mailFolders\`), threads (\`/me/messages?$filter=conversationId eq '<id>'\`), attachments (\`/me/messages/{id}/attachments\`), calendars (\`/me/calendars\`), and events (\`/me/events\`, \`/me/calendarView\` for expanded occurrences).
28364
+ For full-text search use the \`$search\` query parameter (must be wrapped in double quotes); for filtering use \`$filter\` with OData syntax (e.g., \`receivedDateTime ge 2025-01-01T00:00:00Z\`).`,
28365
+ inputSchema: inputSchema99,
28366
+ outputSchema: outputSchema99,
28367
+ async execute({ connectionId, method, path: path4, queryParams }, connections, config) {
28368
+ const connection = connections.find((c) => c.id === connectionId);
28369
+ if (!connection) {
28370
+ return {
28371
+ success: false,
28372
+ error: `Connection ${connectionId} not found`
28373
+ };
28374
+ }
28375
+ console.log(
28376
+ `[connector-request] outlook-oauth/${connection.name}: ${method} ${path4}`
28377
+ );
28378
+ try {
28379
+ const normalizedPath = normalizeRequestPath(path4, BASE_PATH_SEGMENT16);
28380
+ let url = `${BASE_URL42}${normalizedPath}`;
28381
+ if (queryParams) {
28382
+ const searchParams = new URLSearchParams(queryParams);
28383
+ url += `?${searchParams.toString()}`;
28384
+ }
28385
+ const token = await getProxyToken33(config.oauthProxy);
28386
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
28387
+ const controller = new AbortController();
28388
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS76);
28389
+ try {
28390
+ const response = await fetch(proxyUrl, {
28391
+ method: "POST",
28392
+ headers: {
28393
+ "Content-Type": "application/json",
28394
+ Authorization: `Bearer ${token}`
28395
+ },
28396
+ body: JSON.stringify({
28397
+ url,
28398
+ method
28399
+ }),
28400
+ signal: controller.signal
28401
+ });
28402
+ const data = await response.json();
28403
+ if (!response.ok) {
28404
+ const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
28405
+ return { success: false, error: errorMessage };
28406
+ }
28407
+ return { success: true, status: response.status, data };
28408
+ } finally {
28409
+ clearTimeout(timeout);
28410
+ }
28411
+ } catch (err) {
28412
+ const msg = err instanceof Error ? err.message : String(err);
28413
+ return { success: false, error: msg };
28414
+ }
28415
+ }
28416
+ });
28417
+
28418
+ // ../connectors/src/connectors/outlook-oauth/setup.ts
28419
+ var requestToolName14 = `outlook-oauth_${requestTool58.name}`;
28420
+ var outlookOnboarding = new ConnectorOnboarding({
28421
+ connectionSetupInstructions: {
28422
+ ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067 Outlook \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
28423
+
28424
+ 1. \`${requestToolName14}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u8A8D\u8A3C\u6E08\u307F\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3059\u308B:
28425
+ - \`method\`: \`"GET"\`
28426
+ - \`path\`: \`"/me"\`
28427
+ 2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u306F\u3001OAuth \u8A8D\u8A3C\u304C\u6B63\u3057\u304F\u5B8C\u4E86\u3057\u3066\u3044\u308B\u304B\u3092\u30E6\u30FC\u30B6\u30FC\u306B\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
28428
+ 3. \`${requestToolName14}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
28429
+ - \`method\`: \`"GET"\`
28430
+ - \`path\`: \`"/me/mailFolders"\`
28431
+
28432
+ #### \u5236\u7D04
28433
+ - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30E1\u30C3\u30BB\u30FC\u30B8\u672C\u6587\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u53D6\u5F97\u3068\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u53D6\u5F97\u306E\u307F
28434
+ - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
28435
+ en: `Follow these steps to set up the Outlook connection.
28436
+
28437
+ 1. Call \`${requestToolName14}\` to get the authenticated user's profile:
28438
+ - \`method\`: \`"GET"\`
28439
+ - \`path\`: \`"/me"\`
28440
+ 2. If an error is returned, ask the user to verify that OAuth authentication completed correctly
28441
+ 3. Call \`${requestToolName14}\` to get the mail folder list:
28442
+ - \`method\`: \`"GET"\`
28443
+ - \`path\`: \`"/me/mailFolders"\`
28444
+
28445
+ #### Constraints
28446
+ - **Do NOT read message bodies during setup**. Only the profile and mail-folder requests specified above are allowed
28447
+ - Write only 1 sentence between tool calls, then immediately call the next tool`
28448
+ },
28449
+ dataOverviewInstructions: {
28450
+ en: `Mail
28451
+ 1. Call outlook-oauth_request with GET /me/mailFolders to list mail folders
28452
+ 2. Call outlook-oauth_request with GET /me/messages?$top=5&$select=id,subject,from,receivedDateTime,conversationId to sample recent messages
28453
+ 3. Call outlook-oauth_request with GET /me/messages/{id} for an interesting message to inspect the full payload
28454
+ 4. Call outlook-oauth_request with GET /me/mailFolders/{folderId}/messages?$top=5 to drill into a specific folder
28455
+ 5. For threading, call outlook-oauth_request with GET /me/messages?$filter=conversationId%20eq%20'<id>'&$orderby=receivedDateTime%20asc to pull every message in a conversation
28456
+
28457
+ Calendar
28458
+ 6. Call outlook-oauth_request with GET /me/calendars to list calendars (default + shared)
28459
+ 7. Call outlook-oauth_request with GET /me/calendarView?startDateTime=<startISO>&endDateTime=<endISO>&$top=5&$select=id,subject,start,end,attendees to sample upcoming occurrences (expands recurring events)
28460
+ 8. Call outlook-oauth_request with GET /me/events/{eventId} for an interesting event to inspect attendees, body, and location`,
28461
+ ja: `\u30E1\u30FC\u30EB
28462
+ 1. outlook-oauth_request \u3067 GET /me/mailFolders \u3092\u547C\u3073\u51FA\u3057\u3001\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u3092\u53D6\u5F97
28463
+ 2. outlook-oauth_request \u3067 GET /me/messages?$top=5&$select=id,subject,from,receivedDateTime,conversationId \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u65B0\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
28464
+ 3. \u8208\u5473\u306E\u3042\u308B\u30E1\u30C3\u30BB\u30FC\u30B8\u306B\u3064\u3044\u3066 outlook-oauth_request \u3067 GET /me/messages/{id} \u3092\u547C\u3073\u51FA\u3057\u3001\u30DA\u30A4\u30ED\u30FC\u30C9\u5168\u4F53\u3092\u78BA\u8A8D
28465
+ 4. outlook-oauth_request \u3067 GET /me/mailFolders/{folderId}/messages?$top=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u7279\u5B9A\u30D5\u30A9\u30EB\u30C0\u306E\u4E2D\u8EAB\u3092\u78BA\u8A8D
28466
+ 5. \u30B9\u30EC\u30C3\u30C9\u3092\u8FFD\u3046\u5834\u5408\u306F outlook-oauth_request \u3067 GET /me/messages?$filter=conversationId%20eq%20'<id>'&$orderby=receivedDateTime%20asc \u3092\u547C\u3073\u51FA\u3057\u3001\u4F1A\u8A71\u306B\u542B\u307E\u308C\u308B\u5168\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97
28467
+
28468
+ \u30AB\u30EC\u30F3\u30C0\u30FC
28469
+ 6. outlook-oauth_request \u3067 GET /me/calendars \u3092\u547C\u3073\u51FA\u3057\u3001\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7 (\u30C7\u30D5\u30A9\u30EB\u30C8 + \u5171\u6709) \u3092\u53D6\u5F97
28470
+ 7. outlook-oauth_request \u3067 GET /me/calendarView?startDateTime=<startISO>&endDateTime=<endISO>&$top=5&$select=id,subject,start,end,attendees \u3092\u547C\u3073\u51FA\u3057\u3001\u76F4\u8FD1\u306E occurrence \u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0 (\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u3092\u5C55\u958B)
28471
+ 8. \u8208\u5473\u306E\u3042\u308B\u30A4\u30D9\u30F3\u30C8\u306B\u3064\u3044\u3066 outlook-oauth_request \u3067 GET /me/events/{eventId} \u3092\u547C\u3073\u51FA\u3057\u3001\u53C2\u52A0\u8005\u30FB\u672C\u6587\u30FB\u5834\u6240\u3092\u78BA\u8A8D`
28472
+ }
28473
+ });
28474
+
28475
+ // ../connectors/src/connectors/outlook-oauth/parameters.ts
28476
+ var parameters82 = {};
28477
+
28478
+ // ../connectors/src/connectors/outlook-oauth/index.ts
28479
+ var tools82 = { request: requestTool58 };
28480
+ var outlookOauthConnector = new ConnectorPlugin({
28481
+ slug: "outlook",
28482
+ authType: AUTH_TYPES.OAUTH,
28483
+ name: "Outlook",
28484
+ description: "Connect to Microsoft Outlook (Mail + Calendar) via Microsoft Graph using OAuth. Read-only access to the user's mailbox, mail folders, messages, attachments, calendars, and events.",
28485
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1J1FrRTYJjOh3CcSIqsz3I/6a467b4d926075ff99dc60820e0ae4b1/Microsoft_Outlook_Icon__2025%C3%A2__present_.svg",
28486
+ parameters: parameters82,
28487
+ releaseFlag: { dev1: true, dev2: false, prod: false },
28488
+ categories: ["productivity"],
28489
+ onboarding: outlookOnboarding,
28490
+ proxyPolicy: {
28491
+ allowlist: [
28492
+ {
28493
+ host: "graph.microsoft.com",
28494
+ methods: ["GET"]
28495
+ }
28496
+ ]
28497
+ },
28498
+ systemPrompt: {
28499
+ en: `### Tools
28500
+
28501
+ - \`outlook-oauth_request\`: The only way to call Microsoft Graph for Outlook (read-only). Use it to fetch the user profile (\`/me\`), list mail folders (\`/me/mailFolders\`), read messages (\`/me/messages\`, \`/me/messages/{id}\`), fetch attachments (\`/me/messages/{id}/attachments\`), list calendars (\`/me/calendars\`), and read events (\`/me/events\`, \`/me/calendarView\`). Authentication is configured automatically via OAuth.
28502
+
28503
+ ### Microsoft Graph Reference (Outlook Mail)
28504
+
28505
+ #### Available Endpoints
28506
+ - GET \`/me\` \u2014 Get the signed-in user's profile (displayName, mail, userPrincipalName)
28507
+ - GET \`/me/mailFolders\` \u2014 List the user's mail folders (Inbox, SentItems, Drafts, etc.)
28508
+ - GET \`/me/mailFolders/{folderId}\` \u2014 Get a specific mail folder
28509
+ - GET \`/me/mailFolders/{folderId}/messages\` \u2014 List messages within a folder
28510
+ - GET \`/me/messages\` \u2014 List messages across all folders
28511
+ - GET \`/me/messages/{id}\` \u2014 Get a specific message with full body
28512
+ - GET \`/me/messages/{id}/attachments\` \u2014 List attachments on a message
28513
+ - GET \`/me/messages/{id}/attachments/{attachmentId}\` \u2014 Get a specific attachment
28514
+
28515
+ #### Well-Known Folder Names (usable in place of {folderId})
28516
+ - \`inbox\`, \`sentitems\`, \`drafts\`, \`deleteditems\`, \`junkemail\`, \`outbox\`, \`archive\`
28517
+
28518
+ #### Conversations (Threads)
28519
+ - Every message has a \`conversationId\`. Fetch all messages in a thread with: GET \`/me/messages?$filter=conversationId eq '<id>'&$orderby=receivedDateTime asc\` (Gmail-style \`getThread\` equivalent).
28520
+
28521
+ ### Microsoft Graph Reference (Outlook Calendar)
28522
+
28523
+ #### Available Endpoints
28524
+ - GET \`/me/calendars\` \u2014 List the user's calendars (default + any shared/group calendars)
28525
+ - GET \`/me/calendars/{calendarId}\` \u2014 Get a calendar's metadata
28526
+ - GET \`/me/events\` \u2014 List events on the default calendar (recurring events are returned as series masters \u2014 use \`/me/calendarView\` to expand)
28527
+ - GET \`/me/calendars/{calendarId}/events\` \u2014 List events on a specific calendar
28528
+ - GET \`/me/events/{eventId}\` \u2014 Get a single event
28529
+ - GET \`/me/calendarView?startDateTime=&endDateTime=\` \u2014 List event **occurrences** in a date range (expands recurring events). Equivalent to Google Calendar's \`events?singleEvents=true\`
28530
+ - GET \`/me/calendars/{calendarId}/calendarView?startDateTime=&endDateTime=\` \u2014 Same, scoped to a specific calendar
28531
+
28532
+ #### Calendar Tips
28533
+ - Use \`/me/calendarView\` when you want individual occurrences of recurring events; \`/me/events\` is closer to the raw stored series
28534
+ - \`startDateTime\` / \`endDateTime\` must be ISO-8601 UTC, e.g. \`2025-01-15T00:00:00Z\`
28535
+ - Combine with \`$select=subject,start,end,attendees,location\` and \`$orderby=start/dateTime\` to keep responses small and sorted
28536
+
28537
+ #### Key Query Parameters (OData, shared by Mail + Calendar)
28538
+ - \`$top\` \u2014 Maximum number of results (default 10, max 1000)
28539
+ - \`$skip\` \u2014 Skip the first N results (for paging)
28540
+ - \`$select\` \u2014 Comma-separated list of properties (e.g. \`subject,from,receivedDateTime,bodyPreview\`)
28541
+ - \`$orderby\` \u2014 Sort (e.g. \`receivedDateTime desc\`, \`start/dateTime asc\`)
28542
+ - \`$filter\` \u2014 OData filter (e.g. \`receivedDateTime ge 2025-01-01T00:00:00Z\`, \`from/emailAddress/address eq 'a@b.com'\`, \`isRead eq false\`, \`conversationId eq '<id>'\`, \`start/dateTime ge '2025-01-15T00:00:00'\`)
28543
+ - \`$search\` \u2014 Full-text search; must be wrapped in double quotes (e.g. \`$search="project status"\`). \`$search\` and \`$filter\` cannot be combined
28544
+ - \`$expand\` \u2014 Expand related resources (e.g. \`attachments\`, \`instances\` for recurring events)
28545
+ - \`$count=true\` \u2014 Return total count (requires \`ConsistencyLevel: eventual\` header on some endpoints)
28546
+
28547
+ #### Pagination
28548
+ - Responses include \`@odata.nextLink\` when more results exist; call that URL (or its path) to get the next page
28549
+
28550
+ #### Tips
28551
+ - Use \`/me\` for the signed-in user \u2014 never substitute another user ID
28552
+ - Prefer \`$select\` to avoid huge payloads; the full message body can be MB-sized when HTML
28553
+ - \`bodyPreview\` (first ~255 chars) is included by default and is cheap for triage
28554
+ - Date/time values are ISO-8601; calendar event times also include a \`timeZone\` field
28555
+
28556
+ ### Business Logic
28557
+
28558
+ 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 read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
28559
+
28560
+ SDK surface (client created via \`connection(connectionId)\`):
28561
+
28562
+ Mail:
28563
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path appended to \`https://graph.microsoft.com/v1.0\`)
28564
+ - \`client.getProfile()\` \u2014 fetch the authenticated user's profile
28565
+ - \`client.listMailFolders()\` \u2014 list all mail folders
28566
+ - \`client.listMessages(options?)\` \u2014 list messages with optional \`top\`, \`skip\`, \`filter\`, \`orderBy\`, \`select\`, \`search\`
28567
+ - \`client.listMessagesInFolder(folderId, options?)\` \u2014 list messages in a folder (well-known names like \`inbox\` work)
28568
+ - \`client.getMessage(id, options?)\` \u2014 fetch a specific message
28569
+ - \`client.listConversation(conversationId, options?)\` \u2014 fetch every message in a thread (Gmail-style \`getThread\` equivalent; orders oldest-first by default)
28570
+
28571
+ Attachments:
28572
+ - \`client.listAttachments(messageId)\` \u2014 list attachments on a message
28573
+ - \`client.getAttachment(messageId, attachmentId)\` \u2014 fetch a single attachment (file attachments include base64 \`contentBytes\`)
28574
+
28575
+ Calendar:
28576
+ - \`client.listCalendars()\` \u2014 list calendars accessible to the user
28577
+ - \`client.listEvents(options?)\` \u2014 list events on the default calendar (or pass \`{ calendarId }\` for a specific one). Recurring events are returned as series masters
28578
+ - \`client.getEvent(id)\` \u2014 fetch a single event
28579
+ - \`client.listCalendarView(startDateTime, endDateTime, options?)\` \u2014 list event **occurrences** in a date range (recurring events expanded). Equivalent to Google Calendar's \`events?singleEvents=true\`
28580
+
28581
+ If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
28582
+
28583
+ #### Example
28584
+
28585
+ \`\`\`ts
28586
+ import { connection } from "@squadbase/vite-server/connectors/outlook-oauth";
28587
+
28588
+ const outlook = connection("<connectionId>");
28589
+
28590
+ // Get user profile
28591
+ const profile = await outlook.getProfile();
28592
+ console.log(profile.displayName, profile.mail);
28593
+
28594
+ // List recent unread messages in Inbox
28595
+ const messages = await outlook.listMessagesInFolder("inbox", {
28596
+ top: 10,
28597
+ filter: "isRead eq false",
28598
+ orderBy: "receivedDateTime desc",
28599
+ select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],
28600
+ });
28601
+ for (const msg of messages.value) {
28602
+ console.log(msg.receivedDateTime, msg.from?.emailAddress.address, msg.subject);
28603
+ }
28604
+
28605
+ // Pull a whole conversation
28606
+ const first = messages.value[0];
28607
+ if (first?.conversationId) {
28608
+ const thread = await outlook.listConversation(first.conversationId);
28609
+ thread.value.forEach(m => console.log(m.receivedDateTime, m.bodyPreview));
28610
+ }
28611
+
28612
+ // Fetch attachments on a message that has them
28613
+ if (first?.hasAttachments) {
28614
+ const atts = await outlook.listAttachments(first.id);
28615
+ for (const a of atts.value) {
28616
+ const full = await outlook.getAttachment(first.id, a.id);
28617
+ console.log(full.name, full.contentType, full.size);
28618
+ // full.contentBytes is base64 for file attachments
28619
+ }
28620
+ }
28621
+
28622
+ // List today's calendar events (expanded occurrences)
28623
+ const todayStart = new Date(); todayStart.setHours(0, 0, 0, 0);
28624
+ const todayEnd = new Date(todayStart); todayEnd.setDate(todayEnd.getDate() + 1);
28625
+ const events = await outlook.listCalendarView(
28626
+ todayStart.toISOString(),
28627
+ todayEnd.toISOString(),
28628
+ { orderBy: "start/dateTime", select: ["id", "subject", "start", "end", "attendees"] },
28629
+ );
28630
+ events.value.forEach(e => console.log(e.start.dateTime, e.subject));
28631
+ \`\`\``,
28632
+ ja: `### \u30C4\u30FC\u30EB
28633
+
28634
+ - \`outlook-oauth_request\`: Outlook \u5411\u3051\u306E Microsoft Graph \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09\u3002\u30E6\u30FC\u30B6\u30FC\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB (\`/me\`)\u3001\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0 (\`/me/mailFolders\`)\u3001\u30E1\u30C3\u30BB\u30FC\u30B8 (\`/me/messages\`)\u3001\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB (\`/me/messages/{id}/attachments\`)\u3001\u30AB\u30EC\u30F3\u30C0\u30FC (\`/me/calendars\`)\u3001\u30A4\u30D9\u30F3\u30C8 (\`/me/events\`, \`/me/calendarView\`) \u306E\u53D6\u5F97\u306B\u4F7F\u3044\u307E\u3059\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
28635
+
28636
+ ### Microsoft Graph \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9 (Outlook \u30E1\u30FC\u30EB)
28637
+
28638
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
28639
+ - GET \`/me\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB (displayName, mail, userPrincipalName)
28640
+ - GET \`/me/mailFolders\` \u2014 \u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7 (Inbox, SentItems, Drafts \u306A\u3069)
28641
+ - GET \`/me/mailFolders/{folderId}\` \u2014 \u7279\u5B9A\u30D5\u30A9\u30EB\u30C0\u306E\u53D6\u5F97
28642
+ - GET \`/me/mailFolders/{folderId}/messages\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7
28643
+ - GET \`/me/messages\` \u2014 \u5168\u30D5\u30A9\u30EB\u30C0\u6A2A\u65AD\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7
28644
+ - GET \`/me/messages/{id}\` \u2014 \u7279\u5B9A\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u672C\u6587\u8FBC\u307F\u3067\u53D6\u5F97
28645
+ - GET \`/me/messages/{id}/attachments\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7
28646
+ - GET \`/me/messages/{id}/attachments/{attachmentId}\` \u2014 \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u5358\u4F53\u53D6\u5F97
28647
+
28648
+ #### Well-Known \u30D5\u30A9\u30EB\u30C0\u540D ({folderId} \u306E\u4EE3\u308F\u308A\u306B\u4F7F\u7528\u53EF\u80FD)
28649
+ - \`inbox\`, \`sentitems\`, \`drafts\`, \`deleteditems\`, \`junkemail\`, \`outbox\`, \`archive\`
28650
+
28651
+ #### \u4F1A\u8A71 (\u30B9\u30EC\u30C3\u30C9)
28652
+ - \u3059\u3079\u3066\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F \`conversationId\` \u3092\u6301\u3064\u3002\u30B9\u30EC\u30C3\u30C9\u5185\u306E\u5168\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97\u3059\u308B\u306B\u306F: GET \`/me/messages?$filter=conversationId eq '<id>'&$orderby=receivedDateTime asc\` (Gmail \u306E \`getThread\` \u76F8\u5F53)\u3002
28653
+
28654
+ ### Microsoft Graph \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9 (Outlook \u30AB\u30EC\u30F3\u30C0\u30FC)
28655
+
28656
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
28657
+ - GET \`/me/calendars\` \u2014 \u30E6\u30FC\u30B6\u30FC\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7 (\u30C7\u30D5\u30A9\u30EB\u30C8 + \u5171\u6709/\u30B0\u30EB\u30FC\u30D7\u30AB\u30EC\u30F3\u30C0\u30FC)
28658
+ - GET \`/me/calendars/{calendarId}\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u5358\u4F53\u53D6\u5F97
28659
+ - GET \`/me/events\` \u2014 \u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7\uFF08\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u306F series master \u306E\u307E\u307E\u8FD4\u308B \u2014 \u5C55\u958B\u3057\u305F\u3044\u5834\u5408\u306F \`/me/calendarView\`\uFF09
28660
+ - GET \`/me/calendars/{calendarId}/events\` \u2014 \u7279\u5B9A\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7
28661
+ - GET \`/me/events/{eventId}\` \u2014 \u30A4\u30D9\u30F3\u30C8\u5358\u4F53\u53D6\u5F97
28662
+ - GET \`/me/calendarView?startDateTime=&endDateTime=\` \u2014 \u65E5\u4ED8\u7BC4\u56F2\u5185\u306E\u30A4\u30D9\u30F3\u30C8 **occurrence** \u4E00\u89A7\uFF08\u7E70\u308A\u8FD4\u3057\u3092\u5C55\u958B\uFF09\u3002Google Calendar \u306E \`events?singleEvents=true\` \u76F8\u5F53
28663
+ - GET \`/me/calendars/{calendarId}/calendarView?startDateTime=&endDateTime=\` \u2014 \u540C\u4E0A\u3001\u7279\u5B9A\u30AB\u30EC\u30F3\u30C0\u30FC\u7248
28664
+
28665
+ #### \u30AB\u30EC\u30F3\u30C0\u30FC Tips
28666
+ - \u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u306E\u500B\u5225 occurrence \u304C\u6B32\u3057\u3044\u5834\u5408\u306F \`/me/calendarView\`\u3001\u751F\u306E\u30B7\u30EA\u30FC\u30BA\u304C\u6B32\u3057\u3044\u5834\u5408\u306F \`/me/events\`
28667
+ - \`startDateTime\` / \`endDateTime\` \u306F ISO-8601 UTC\u3001\u4F8B \`2025-01-15T00:00:00Z\`
28668
+ - \`$select=subject,start,end,attendees,location\` \u3068 \`$orderby=start/dateTime\` \u3092\u7D44\u307F\u5408\u308F\u305B\u308B\u3068\u30DA\u30A4\u30ED\u30FC\u30C9\u6291\u5236 + \u30BD\u30FC\u30C8\u3067\u304D\u308B
28669
+
28670
+ #### \u4E3B\u8981\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF (OData; Mail \u3068 Calendar \u3067\u5171\u901A)
28671
+ - \`$top\` \u2014 \u6700\u5927\u7D50\u679C\u6570 (\u30C7\u30D5\u30A9\u30EB\u30C8 10\u3001\u6700\u5927 1000)
28672
+ - \`$skip\` \u2014 \u5148\u982D N \u4EF6\u3092\u30B9\u30AD\u30C3\u30D7 (\u30DA\u30FC\u30B8\u30F3\u30B0)
28673
+ - \`$select\` \u2014 \u53D6\u5F97\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A (\u4F8B \`subject,from,receivedDateTime,bodyPreview\`)
28674
+ - \`$orderby\` \u2014 \u30BD\u30FC\u30C8 (\u4F8B \`receivedDateTime desc\`\u3001\`start/dateTime asc\`)
28675
+ - \`$filter\` \u2014 OData \u30D5\u30A3\u30EB\u30BF (\u4F8B \`receivedDateTime ge 2025-01-01T00:00:00Z\`\u3001\`from/emailAddress/address eq 'a@b.com'\`\u3001\`isRead eq false\`\u3001\`conversationId eq '<id>'\`\u3001\`start/dateTime ge '2025-01-15T00:00:00'\`)
28676
+ - \`$search\` \u2014 \u5168\u6587\u691C\u7D22\u3002\u30C0\u30D6\u30EB\u30AF\u30A9\u30FC\u30C8\u3067\u56F2\u3080\u5FC5\u8981\u3042\u308A (\u4F8B \`$search="project status"\`)\u3002\`$filter\` \u3068\u4F75\u7528\u4E0D\u53EF
28677
+ - \`$expand\` \u2014 \u95A2\u9023\u30EA\u30BD\u30FC\u30B9\u3092\u5C55\u958B (\u4F8B \`attachments\`\u3001\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u306E \`instances\`)
28678
+ - \`$count=true\` \u2014 \u7DCF\u4EF6\u6570\u3092\u8FD4\u3059 (\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306B\u3088\u3063\u3066\u306F \`ConsistencyLevel: eventual\` \u30D8\u30C3\u30C0\u30FC\u304C\u5FC5\u8981)
28679
+
28680
+ #### \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3
28681
+ - \u7D9A\u304D\u304C\u3042\u308B\u5834\u5408\u30EC\u30B9\u30DD\u30F3\u30B9\u306B \`@odata.nextLink\` \u304C\u542B\u307E\u308C\u308B\u3002\u305D\u306E URL (\u307E\u305F\u306F\u30D1\u30B9) \u3092\u547C\u3073\u51FA\u3057\u3066\u6B21\u30DA\u30FC\u30B8\u3092\u53D6\u5F97
28682
+
28683
+ #### Tips
28684
+ - \u30B5\u30A4\u30F3\u30A4\u30F3\u30E6\u30FC\u30B6\u30FC\u306B\u306F\u5FC5\u305A \`/me\` \u3092\u4F7F\u7528 \u2014 \u4ED6\u30E6\u30FC\u30B6\u30FC\u306E ID \u3092\u5165\u308C\u306A\u3044
28685
+ - \u30DA\u30A4\u30ED\u30FC\u30C9\u80A5\u5927\u5316\u3092\u907F\u3051\u308B\u305F\u3081 \`$select\` \u3092\u6D3B\u7528\u3002HTML \u672C\u6587\u8FBC\u307F\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u306F MB \u5358\u4F4D\u306B\u306A\u308B\u3053\u3068\u304C\u3042\u308B
28686
+ - \`bodyPreview\` (\u5148\u982D\u7D04 255 \u6587\u5B57) \u306F\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u542B\u307E\u308C\u3066\u304A\u308A\u3001\u30C8\u30EA\u30A2\u30FC\u30B8\u306B\u4FBF\u5229
28687
+ - \u65E5\u6642\u5024\u306F ISO-8601\u3002\u30AB\u30EC\u30F3\u30C0\u30FC\u30A4\u30D9\u30F3\u30C8\u306B\u306F \`timeZone\` \u30D5\u30A3\u30FC\u30EB\u30C9\u3082\u542B\u307E\u308C\u308B
28688
+
28689
+ ### Business Logic
28690
+
28691
+ \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\u30BF SDK \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\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
28692
+
28693
+ SDK (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
28694
+
28695
+ \u30E1\u30FC\u30EB:
28696
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u8A8D\u8A3C\u4ED8\u304D fetch (path \u306F \`https://graph.microsoft.com/v1.0\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059)
28697
+ - \`client.getProfile()\` \u2014 \u8A8D\u8A3C\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97
28698
+ - \`client.listMailFolders()\` \u2014 \u5168\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u3092\u4E00\u89A7
28699
+ - \`client.listMessages(options?)\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7 (\`top\`, \`skip\`, \`filter\`, \`orderBy\`, \`select\`, \`search\` \u5BFE\u5FDC)
28700
+ - \`client.listMessagesInFolder(folderId, options?)\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7 (\`inbox\` \u306A\u3069\u306E well-known \u540D\u3082\u4F7F\u7528\u53EF)
28701
+ - \`client.getMessage(id, options?)\` \u2014 \u7279\u5B9A\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97
28702
+ - \`client.listConversation(conversationId, options?)\` \u2014 \u30B9\u30EC\u30C3\u30C9\u5185\u306E\u5168\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97 (Gmail \`getThread\` \u76F8\u5F53\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u3067\u53E4\u3044\u9806)
28703
+
28704
+ \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB:
28705
+ - \`client.listAttachments(messageId)\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7
28706
+ - \`client.getAttachment(messageId, attachmentId)\` \u2014 \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u5358\u4F53\u53D6\u5F97 (file attachment \u306F base64 \u306E \`contentBytes\` \u3092\u542B\u3080)
28707
+
28708
+ \u30AB\u30EC\u30F3\u30C0\u30FC:
28709
+ - \`client.listCalendars()\` \u2014 \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7
28710
+ - \`client.listEvents(options?)\` \u2014 \u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7 (\`{ calendarId }\` \u3067\u7279\u5B9A\u30AB\u30EC\u30F3\u30C0\u30FC\u6307\u5B9A\u53EF)\u3002\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u306F series master \u3068\u3057\u3066\u8FD4\u5374
28711
+ - \`client.getEvent(id)\` \u2014 \u30A4\u30D9\u30F3\u30C8\u5358\u4F53\u53D6\u5F97
28712
+ - \`client.listCalendarView(startDateTime, endDateTime, options?)\` \u2014 \u65E5\u4ED8\u7BC4\u56F2\u5185\u306E\u30A4\u30D9\u30F3\u30C8 **occurrence** \u4E00\u89A7 (\u7E70\u308A\u8FD4\u3057\u3092\u5C55\u958B)\u3002Google Calendar \u306E \`events?singleEvents=true\` \u76F8\u5F53
28713
+
28714
+ \u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
28715
+
28716
+ #### Example
28717
+
28718
+ \`\`\`ts
28719
+ import { connection } from "@squadbase/vite-server/connectors/outlook-oauth";
28720
+
28721
+ const outlook = connection("<connectionId>");
28722
+
28723
+ // \u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u53D6\u5F97
28724
+ const profile = await outlook.getProfile();
28725
+ console.log(profile.displayName, profile.mail);
28726
+
28727
+ // \u53D7\u4FE1\u30C8\u30EC\u30A4\u306E\u672A\u8AAD\u30E1\u30C3\u30BB\u30FC\u30B8\u6700\u65B010\u4EF6
28728
+ const messages = await outlook.listMessagesInFolder("inbox", {
28729
+ top: 10,
28730
+ filter: "isRead eq false",
28731
+ orderBy: "receivedDateTime desc",
28732
+ select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],
28733
+ });
28734
+ for (const msg of messages.value) {
28735
+ console.log(msg.receivedDateTime, msg.from?.emailAddress.address, msg.subject);
28736
+ }
28737
+
28738
+ // \u30B9\u30EC\u30C3\u30C9\u5168\u4F53\u3092\u53D6\u5F97
28739
+ const first = messages.value[0];
28740
+ if (first?.conversationId) {
28741
+ const thread = await outlook.listConversation(first.conversationId);
28742
+ thread.value.forEach(m => console.log(m.receivedDateTime, m.bodyPreview));
28743
+ }
28744
+
28745
+ // \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u3092\u53D6\u5F97
28746
+ if (first?.hasAttachments) {
28747
+ const atts = await outlook.listAttachments(first.id);
28748
+ for (const a of atts.value) {
28749
+ const full = await outlook.getAttachment(first.id, a.id);
28750
+ console.log(full.name, full.contentType, full.size);
28751
+ // full.contentBytes \u306F file attachment \u306E\u5834\u5408 base64
28752
+ }
28753
+ }
28754
+
28755
+ // \u4ECA\u65E5\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u30A4\u30D9\u30F3\u30C8 (occurrence \u5C55\u958B)
28756
+ const todayStart = new Date(); todayStart.setHours(0, 0, 0, 0);
28757
+ const todayEnd = new Date(todayStart); todayEnd.setDate(todayEnd.getDate() + 1);
28758
+ const events = await outlook.listCalendarView(
28759
+ todayStart.toISOString(),
28760
+ todayEnd.toISOString(),
28761
+ { orderBy: "start/dateTime", select: ["id", "subject", "start", "end", "attendees"] },
28762
+ );
28763
+ events.value.forEach(e => console.log(e.start.dateTime, e.subject));
28764
+ \`\`\``
28765
+ },
28766
+ tools: tools82,
28767
+ async checkConnection(_params, config) {
28768
+ const { proxyFetch } = config;
28769
+ const url = "https://graph.microsoft.com/v1.0/me";
28770
+ try {
28771
+ const res = await proxyFetch(url, { method: "GET" });
28772
+ if (!res.ok) {
28773
+ const errorText = await res.text().catch(() => res.statusText);
28774
+ return {
28775
+ success: false,
28776
+ error: `Microsoft Graph failed: HTTP ${res.status} ${errorText}`
28777
+ };
28778
+ }
28779
+ return { success: true };
28780
+ } catch (error) {
28781
+ return {
28782
+ success: false,
28783
+ error: error instanceof Error ? error.message : String(error)
28784
+ };
28785
+ }
28786
+ }
28787
+ });
28788
+
28789
+ // ../connectors/src/connectors/registry.ts
28790
+ var plugins = {
28791
+ snowflake: snowflakeConnector,
28792
+ snowflakePat: snowflakePatConnector,
28793
+ bigquery: bigqueryConnector,
28794
+ bigqueryOauth: bigqueryOauthConnector,
28795
+ databricks: databricksConnector,
28796
+ redshift: redshiftConnector,
28797
+ dbt: dbtConnector,
28798
+ awsAthena: awsAthenaConnector,
28799
+ awsBilling: awsBillingConnector,
28800
+ postgresql: postgresqlConnector,
28801
+ mysql: mysqlConnector,
28802
+ googleAds: googleAdsConnector,
28803
+ googleAnalytics: googleAnalyticsConnector,
28804
+ googleAnalyticsOauth: googleAnalyticsOauthConnector,
28805
+ googleCalendar: googleCalendarConnector,
28806
+ googleCalendarOauth: googleCalendarOauthConnector,
28807
+ googleDocs: googleDocsConnector,
28808
+ googleDrive: googleDriveConnector,
28809
+ googleSheets: googleSheetsConnector,
28810
+ googleSlides: googleSlidesConnector,
28811
+ hubspotOauth: hubspotOauthConnector,
28812
+ stripeOauth: stripeOauthConnector,
28813
+ stripeApiKey: stripeApiKeyConnector,
28814
+ airtable: airtableConnector,
28815
+ airtableOauth: airtableOauthConnector,
28816
+ squadbaseDb: squadbaseDbConnector,
28817
+ kintone: kintoneConnector,
28818
+ kintoneApiToken: kintoneApiTokenConnector,
28819
+ wixStore: wixStoreConnector,
28820
+ openai: openaiConnector,
28821
+ gemini: geminiConnector,
28822
+ anthropic: anthropicConnector,
28823
+ amplitude: amplitudeConnector,
28824
+ attio: attioConnector,
28825
+ shopify: shopifyConnector,
28826
+ shopifyOauth: shopifyOauthConnector,
28827
+ hubspot: hubspotConnector,
28828
+ jira: jiraConnector,
28829
+ linear: linearConnector,
28830
+ asana: asanaConnector,
28831
+ clickhouse: clickhouseConnector,
28832
+ mongodb: mongodbConnector,
28833
+ notion: notionConnector,
28834
+ notionOauth: notionOauthConnector,
28835
+ metaAds: metaAdsConnector,
28836
+ metaAdsOauth: metaAdsOauthConnector,
28837
+ tiktokAds: tiktokAdsConnector,
28838
+ mailchimp: mailchimpConnector,
28839
+ mailchimpOauth: mailchimpOauthConnector,
28840
+ customerio: customerioConnector,
28841
+ gmail: gmailConnector,
28842
+ gmailOauth: gmailOauthConnector,
28843
+ googleAuditLog: googleAuditLogConnector,
28844
+ linkedinAds: linkedinAdsConnector,
28845
+ zendesk: zendeskConnector,
28846
+ zendeskOauth: zendeskOauthConnector,
28847
+ intercom: intercomConnector,
28848
+ intercomOauth: intercomOauthConnector,
28849
+ mixpanel: mixpanelConnector,
28850
+ grafana: grafanaConnector,
28851
+ backlog: backlogConnector,
28852
+ gamma: gammaConnector,
28853
+ sentry: sentryConnector,
28854
+ salesforce: salesforceConnector,
28855
+ influxdb: influxdbConnector,
28856
+ monday: mondayConnector,
28857
+ jdbc: jdbcConnector,
28858
+ semrush: semrushConnector,
28859
+ googleSearchConsoleOauth: googleSearchConsoleOauthConnector,
28860
+ supabase: supabaseConnector,
28861
+ clickup: clickupConnector,
28862
+ sqlserver: sqlserverConnector,
28863
+ azureSql: azureSqlConnector,
28864
+ cosmosdb: cosmosdbConnector,
28865
+ oracle: oracleConnector,
28866
+ freshservice: freshserviceConnector,
28867
+ freshdesk: freshdeskConnector,
28868
+ freshsales: freshsalesConnector,
28869
+ github: githubConnector,
28870
+ powerbiOauth: powerbiOauthConnector,
28871
+ tableau: tableauConnector,
28872
+ outlookOauth: outlookOauthConnector
28873
+ };
28874
+ var connectors = {
28875
+ ...plugins,
28876
+ /**
28877
+ * Return plugins that have at least one matching connection.
28878
+ */
28879
+ pluginsFor(connections) {
28880
+ const keys = new Set(
28881
+ connections.map(
28882
+ (c) => ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType)
28883
+ )
28884
+ );
28885
+ return Object.values(plugins).filter((p) => keys.has(p.connectorKey));
28886
+ },
28887
+ /**
28888
+ * Find a plugin by slug and authType.
28889
+ */
28890
+ findByKey(slug, authType) {
28891
+ const key = ConnectorPlugin.deriveKey(slug, authType);
28892
+ return Object.values(plugins).find((p) => p.connectorKey === key);
28893
+ }
28894
+ };
28895
+
28896
+ // src/connector-client/env.ts
28897
+ function resolveEnvVar(entry, key, connectionId) {
28898
+ const envVarName = entry.envVars[key];
28899
+ if (!envVarName) {
28900
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
28901
+ }
28902
+ const value = process.env[envVarName];
28903
+ if (!value) {
28904
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
27594
28905
  }
27595
28906
  return value;
27596
28907
  }
@@ -27769,62 +29080,62 @@ function resolveParams(entry, connectionId, plugin) {
27769
29080
  var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
27770
29081
 
27771
29082
  // src/types/server-logic.ts
27772
- import { z as z97 } from "zod";
27773
- var parameterMetaSchema = z97.object({
27774
- name: z97.string(),
27775
- type: z97.enum(["string", "number", "boolean"]),
27776
- description: z97.string(),
27777
- required: z97.boolean().optional(),
27778
- default: z97.union([z97.string(), z97.number(), z97.boolean()]).optional()
27779
- });
27780
- var serverLogicCacheConfigSchema = z97.object({
27781
- ttl: z97.number(),
27782
- staleWhileRevalidate: z97.boolean().optional()
27783
- });
27784
- var serverLogicSchemaObjectSchema = z97.lazy(
27785
- () => z97.object({
27786
- type: z97.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
27787
- format: z97.string().optional(),
27788
- description: z97.string().optional(),
27789
- nullable: z97.boolean().optional(),
27790
- enum: z97.array(z97.union([z97.string(), z97.number(), z97.boolean(), z97.null()])).optional(),
29083
+ import { z as z100 } from "zod";
29084
+ var parameterMetaSchema = z100.object({
29085
+ name: z100.string(),
29086
+ type: z100.enum(["string", "number", "boolean"]),
29087
+ description: z100.string(),
29088
+ required: z100.boolean().optional(),
29089
+ default: z100.union([z100.string(), z100.number(), z100.boolean()]).optional()
29090
+ });
29091
+ var serverLogicCacheConfigSchema = z100.object({
29092
+ ttl: z100.number(),
29093
+ staleWhileRevalidate: z100.boolean().optional()
29094
+ });
29095
+ var serverLogicSchemaObjectSchema = z100.lazy(
29096
+ () => z100.object({
29097
+ type: z100.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
29098
+ format: z100.string().optional(),
29099
+ description: z100.string().optional(),
29100
+ nullable: z100.boolean().optional(),
29101
+ enum: z100.array(z100.union([z100.string(), z100.number(), z100.boolean(), z100.null()])).optional(),
27791
29102
  items: serverLogicSchemaObjectSchema.optional(),
27792
- properties: z97.record(z97.string(), serverLogicSchemaObjectSchema).optional(),
27793
- required: z97.array(z97.string()).optional(),
27794
- additionalProperties: z97.union([z97.boolean(), serverLogicSchemaObjectSchema]).optional(),
27795
- minimum: z97.number().optional(),
27796
- maximum: z97.number().optional(),
27797
- minLength: z97.number().optional(),
27798
- maxLength: z97.number().optional(),
27799
- pattern: z97.string().optional()
29103
+ properties: z100.record(z100.string(), serverLogicSchemaObjectSchema).optional(),
29104
+ required: z100.array(z100.string()).optional(),
29105
+ additionalProperties: z100.union([z100.boolean(), serverLogicSchemaObjectSchema]).optional(),
29106
+ minimum: z100.number().optional(),
29107
+ maximum: z100.number().optional(),
29108
+ minLength: z100.number().optional(),
29109
+ maxLength: z100.number().optional(),
29110
+ pattern: z100.string().optional()
27800
29111
  })
27801
29112
  );
27802
- var serverLogicMediaTypeSchema = z97.object({
29113
+ var serverLogicMediaTypeSchema = z100.object({
27803
29114
  schema: serverLogicSchemaObjectSchema.optional(),
27804
- example: z97.unknown().optional()
29115
+ example: z100.unknown().optional()
27805
29116
  });
27806
- var serverLogicResponseSchema = z97.object({
27807
- description: z97.string().optional(),
27808
- content: z97.record(z97.string(), serverLogicMediaTypeSchema).optional()
29117
+ var serverLogicResponseSchema = z100.object({
29118
+ description: z100.string().optional(),
29119
+ content: z100.record(z100.string(), serverLogicMediaTypeSchema).optional()
27809
29120
  });
27810
29121
  var jsonBaseFields = {
27811
- description: z97.string(),
27812
- parameters: z97.array(parameterMetaSchema).optional(),
29122
+ description: z100.string(),
29123
+ parameters: z100.array(parameterMetaSchema).optional(),
27813
29124
  response: serverLogicResponseSchema.optional(),
27814
29125
  cache: serverLogicCacheConfigSchema.optional()
27815
29126
  };
27816
- var jsonSqlServerLogicSchema = z97.object({
29127
+ var jsonSqlServerLogicSchema = z100.object({
27817
29128
  ...jsonBaseFields,
27818
- type: z97.literal("sql").optional(),
27819
- query: z97.string(),
27820
- connectionId: z97.string()
29129
+ type: z100.literal("sql").optional(),
29130
+ query: z100.string(),
29131
+ connectionId: z100.string()
27821
29132
  });
27822
- var jsonTypeScriptServerLogicSchema = z97.object({
29133
+ var jsonTypeScriptServerLogicSchema = z100.object({
27823
29134
  ...jsonBaseFields,
27824
- type: z97.literal("typescript"),
27825
- handlerPath: z97.string()
29135
+ type: z100.literal("typescript"),
29136
+ handlerPath: z100.string()
27826
29137
  });
27827
- var anyJsonServerLogicSchema = z97.union([
29138
+ var anyJsonServerLogicSchema = z100.union([
27828
29139
  jsonTypeScriptServerLogicSchema,
27829
29140
  jsonSqlServerLogicSchema
27830
29141
  ]);