@squadbase/vite-server 0.1.10 → 0.1.12-dev.8860f37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1977 -278
- package/dist/connectors/oracle.js +1 -1
- package/dist/connectors/outlook-oauth.d.ts +5 -0
- package/dist/connectors/outlook-oauth.js +929 -0
- package/dist/connectors/powerbi-oauth.d.ts +5 -0
- package/dist/connectors/powerbi-oauth.js +720 -0
- package/dist/connectors/powerbi.d.ts +5 -0
- package/dist/connectors/powerbi.js +869 -0
- package/dist/connectors/tableau.d.ts +5 -0
- package/dist/connectors/tableau.js +879 -0
- package/dist/index.js +1975 -276
- package/dist/main.js +1975 -276
- package/dist/vite-plugin.js +1977 -278
- package/package.json +17 -1
package/dist/vite-plugin.js
CHANGED
|
@@ -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
|
|
378
|
-
var
|
|
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.
|
|
403
|
-
Use for: schema exploration (SHOW DATABASES/SCHEMAS/TABLES, DESCRIBE TABLE, INFORMATION_SCHEMA),
|
|
404
|
-
|
|
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
|
-
|
|
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:
|
|
457
|
-
complete: (err
|
|
458
|
-
clearTimeout(timeoutId);
|
|
518
|
+
sqlText: `ALTER SESSION SET STATEMENT_TIMEOUT_IN_SECONDS = ${STATEMENT_TIMEOUT_SECONDS}`,
|
|
519
|
+
complete: (err) => {
|
|
459
520
|
if (err)
|
|
460
|
-
reject(
|
|
461
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
|
668
|
-
var
|
|
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 ${
|
|
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
|
-
},
|
|
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 >
|
|
829
|
+
const truncated = allRows.length > MAX_ROWS;
|
|
757
830
|
return {
|
|
758
831
|
success: true,
|
|
759
|
-
rowCount: Math.min(allRows.length,
|
|
832
|
+
rowCount: Math.min(allRows.length, MAX_ROWS),
|
|
760
833
|
truncated,
|
|
761
|
-
rows: allRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
1230
|
+
const truncated = rows.length > MAX_ROWS2;
|
|
1158
1231
|
return {
|
|
1159
1232
|
success: true,
|
|
1160
|
-
rowCount: Math.min(rows.length,
|
|
1233
|
+
rowCount: Math.min(rows.length, MAX_ROWS2),
|
|
1161
1234
|
truncated,
|
|
1162
|
-
rows: rows.slice(0,
|
|
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
|
|
1372
|
+
var MAX_ROWS3 = 500;
|
|
1300
1373
|
var CONNECT_TIMEOUT_MS2 = 1e4;
|
|
1301
|
-
var
|
|
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 ${
|
|
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")),
|
|
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 >
|
|
1433
|
+
const truncated = resultRows.length > MAX_ROWS3;
|
|
1361
1434
|
return {
|
|
1362
1435
|
success: true,
|
|
1363
|
-
rowCount: Math.min(resultRows.length,
|
|
1436
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS3),
|
|
1364
1437
|
truncated,
|
|
1365
|
-
rows: resultRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
1816
|
+
const truncated = allRows.length > MAX_ROWS4;
|
|
1744
1817
|
return {
|
|
1745
1818
|
success: true,
|
|
1746
|
-
rowCount: Math.min(allRows.length,
|
|
1819
|
+
rowCount: Math.min(allRows.length, MAX_ROWS4),
|
|
1747
1820
|
truncated,
|
|
1748
|
-
rows: allRows.slice(0,
|
|
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
|
|
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 ${
|
|
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:
|
|
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 >
|
|
2332
|
+
const truncated = rows.length > MAX_ROWS5;
|
|
2260
2333
|
return {
|
|
2261
2334
|
success: true,
|
|
2262
|
-
rowCount: Math.min(rows.length,
|
|
2335
|
+
rowCount: Math.min(rows.length, MAX_ROWS5),
|
|
2263
2336
|
truncated,
|
|
2264
|
-
rows: rows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
2618
|
+
const truncated = dataRows.length > MAX_ROWS6;
|
|
2546
2619
|
return {
|
|
2547
2620
|
success: true,
|
|
2548
|
-
rowCount: Math.min(dataRows.length,
|
|
2621
|
+
rowCount: Math.min(dataRows.length, MAX_ROWS6),
|
|
2549
2622
|
truncated,
|
|
2550
|
-
rows: dataRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
3643
|
+
const truncated = allRows.length > MAX_ROWS7;
|
|
3571
3644
|
return {
|
|
3572
3645
|
success: true,
|
|
3573
|
-
rowCount: Math.min(allRows.length,
|
|
3646
|
+
rowCount: Math.min(allRows.length, MAX_ROWS7),
|
|
3574
3647
|
truncated,
|
|
3575
|
-
rows: allRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
3922
|
+
const truncated = allRows.length > MAX_ROWS8;
|
|
3850
3923
|
return {
|
|
3851
3924
|
success: true,
|
|
3852
|
-
rowCount: Math.min(allRows.length,
|
|
3925
|
+
rowCount: Math.min(allRows.length, MAX_ROWS8),
|
|
3853
3926
|
truncated,
|
|
3854
|
-
rows: allRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
10925
|
+
const truncated = rows.length > MAX_ROWS9;
|
|
10853
10926
|
return {
|
|
10854
10927
|
success: true,
|
|
10855
|
-
rowCount: Math.min(rows.length,
|
|
10928
|
+
rowCount: Math.min(rows.length, MAX_ROWS9),
|
|
10856
10929
|
truncated,
|
|
10857
|
-
rows: rows.slice(0,
|
|
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
|
|
13632
|
-
var
|
|
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 ${
|
|
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:
|
|
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 >
|
|
13763
|
+
const truncated = allRows.length > MAX_ROWS10;
|
|
13691
13764
|
return {
|
|
13692
13765
|
success: true,
|
|
13693
|
-
rowCount: Math.min(allRows.length,
|
|
13766
|
+
rowCount: Math.min(allRows.length, MAX_ROWS10),
|
|
13694
13767
|
truncated,
|
|
13695
|
-
rows: allRows.slice(0,
|
|
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
|
|
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:
|
|
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
|
|
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:
|
|
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
|
|
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 ${
|
|
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,
|
|
23304
|
-
truncated: rows.length >
|
|
23305
|
-
rows: rows.slice(0,
|
|
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,
|
|
23321
|
-
truncated: rows.length >
|
|
23322
|
-
rows: rows.slice(0,
|
|
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 >
|
|
23419
|
+
const truncated = rows.length > MAX_ROWS11;
|
|
23347
23420
|
return {
|
|
23348
23421
|
success: true,
|
|
23349
|
-
rowCount: Math.min(rows.length,
|
|
23422
|
+
rowCount: Math.min(rows.length, MAX_ROWS11),
|
|
23350
23423
|
truncated,
|
|
23351
|
-
rows: rows.slice(0,
|
|
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 >
|
|
23445
|
+
const truncated = resultRows.length > MAX_ROWS11;
|
|
23373
23446
|
return {
|
|
23374
23447
|
success: true,
|
|
23375
|
-
rowCount: Math.min(resultRows.length,
|
|
23448
|
+
rowCount: Math.min(resultRows.length, MAX_ROWS11),
|
|
23376
23449
|
truncated,
|
|
23377
|
-
rows: resultRows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
24775
|
+
const truncated = rows.length > MAX_ROWS12;
|
|
24703
24776
|
return {
|
|
24704
24777
|
success: true,
|
|
24705
|
-
rowCount: Math.min(rows.length,
|
|
24778
|
+
rowCount: Math.min(rows.length, MAX_ROWS12),
|
|
24706
24779
|
truncated,
|
|
24707
|
-
rows: rows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
25316
|
+
const truncated = rows.length > MAX_ROWS13;
|
|
25244
25317
|
return {
|
|
25245
25318
|
success: true,
|
|
25246
|
-
rowCount: Math.min(rows.length,
|
|
25319
|
+
rowCount: Math.min(rows.length, MAX_ROWS13),
|
|
25247
25320
|
truncated,
|
|
25248
|
-
rows: rows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
25512
|
+
const truncated = rows.length > MAX_ROWS14;
|
|
25440
25513
|
return {
|
|
25441
25514
|
success: true,
|
|
25442
|
-
rowCount: Math.min(rows.length,
|
|
25515
|
+
rowCount: Math.min(rows.length, MAX_ROWS14),
|
|
25443
25516
|
truncated,
|
|
25444
|
-
rows: rows.slice(0,
|
|
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
|
|
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 ${
|
|
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 >
|
|
26053
|
+
const truncated = rows.length > MAX_ROWS15;
|
|
25981
26054
|
return {
|
|
25982
26055
|
success: true,
|
|
25983
|
-
rowCount: Math.min(rows.length,
|
|
26056
|
+
rowCount: Math.min(rows.length, MAX_ROWS15),
|
|
25984
26057
|
truncated,
|
|
25985
|
-
rows: rows.slice(0,
|
|
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:
|
|
26077
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
26005
26078
|
categories: ["database"],
|
|
26006
26079
|
onboarding: oracleOnboarding,
|
|
26007
26080
|
systemPrompt: {
|
|
@@ -27478,115 +27551,1741 @@ export default async function handler(c: Context) {
|
|
|
27478
27551
|
tools: tools79
|
|
27479
27552
|
});
|
|
27480
27553
|
|
|
27481
|
-
// ../connectors/src/connectors/
|
|
27482
|
-
var
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
27487
|
-
|
|
27488
|
-
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
|
|
27492
|
-
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27498
|
-
|
|
27499
|
-
|
|
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));
|
|
27554
|
+
// ../connectors/src/connectors/powerbi/setup.ts
|
|
27555
|
+
var powerbiOnboarding = new ConnectorOnboarding({
|
|
27556
|
+
connectionSetupInstructions: {
|
|
27557
|
+
en: `Follow these steps to verify the Power BI Service Principal connection.
|
|
27558
|
+
|
|
27559
|
+
1. Call \`powerbi_request\` with \`method: "GET"\` and \`path: "/groups"\` to list workspaces the Service Principal can access
|
|
27560
|
+
2. If the response is an empty \`value\` array, ask the user to add the Service Principal as Member/Admin to at least one workspace (Power BI Service > Workspace > Access). The 'Allow service principals to use Power BI APIs' tenant setting must also be enabled
|
|
27561
|
+
|
|
27562
|
+
#### Constraints
|
|
27563
|
+
- **Do NOT execute DAX queries or refresh datasets during setup**. Only the workspace listing above is allowed
|
|
27564
|
+
- Service Principals cannot access "My workspace" \u2014 always work through workspace (group) IDs`,
|
|
27565
|
+
ja: `Power BI Service Principal \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
|
|
27566
|
+
|
|
27567
|
+
1. \`powerbi_request\` \u3092 \`method: "GET"\`\u3001\`path: "/groups"\` \u3067\u547C\u3073\u51FA\u3057\u3001Service Principal \u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
27568
|
+
2. \`value\` \u304C\u7A7A\u914D\u5217\u3067\u8FD4\u3063\u3066\u304D\u305F\u5834\u5408\u306F\u3001Power BI Service > \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9 > \u30A2\u30AF\u30BB\u30B9 \u304B\u3089\u8A72\u5F53\u306E Service Principal \u3092 Member/Admin \u3068\u3057\u3066\u8FFD\u52A0\u3059\u308B\u3088\u3046\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u308B\u3002\u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8A2D\u5B9A\u3067\u300C\u30B5\u30FC\u30D3\u30B9 \u30D7\u30EA\u30F3\u30B7\u30D1\u30EB\u306B Power BI API \u306E\u4F7F\u7528\u3092\u8A31\u53EF\u3059\u308B\u300D\u3082\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308B
|
|
27569
|
+
|
|
27570
|
+
#### \u5236\u7D04
|
|
27571
|
+
- **\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
|
|
27572
|
+
- Service Principal \u306F\u300C\u30DE\u30A4 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u300D\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u306A\u3044 \u2014 \u5FC5\u305A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9 (group) ID \u7D4C\u7531\u3067\u64CD\u4F5C\u3059\u308B\u3053\u3068`
|
|
27575
27573
|
},
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27579
|
-
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
|
|
27574
|
+
dataOverviewInstructions: {
|
|
27575
|
+
en: `1. Call powerbi_request with GET /groups to list accessible workspaces
|
|
27576
|
+
2. For a target workspace, call powerbi_request with GET /groups/{groupId}/datasets to list datasets
|
|
27577
|
+
3. Call powerbi_request with GET /groups/{groupId}/reports to list reports
|
|
27578
|
+
4. For each interesting dataset call powerbi_request with GET /groups/{groupId}/datasets/{datasetId}/tables to inspect tables (requires the dataset to allow XMLA / metadata reads)`,
|
|
27579
|
+
ja: `1. powerbi_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
|
|
27580
|
+
2. \u5BFE\u8C61\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B\u5BFE\u3057\u3066 powerbi_request \u3067 GET /groups/{groupId}/datasets \u3092\u547C\u3073\u51FA\u3057\u3001\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
27581
|
+
3. powerbi_request \u3067 GET /groups/{groupId}/reports \u3092\u547C\u3073\u51FA\u3057\u3001\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
27582
|
+
4. \u8208\u5473\u306E\u3042\u308B\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u306B\u3064\u3044\u3066 powerbi_request \u3067 GET /groups/{groupId}/datasets/{datasetId}/tables \u3092\u547C\u3073\u51FA\u3057\u3001\u30C6\u30FC\u30D6\u30EB\u69CB\u9020\u3092\u78BA\u8A8D\uFF08XMLA / \u30E1\u30BF\u30C7\u30FC\u30BF\u8AAD\u307F\u53D6\u308A\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u308B\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u306B\u9650\u308B\uFF09`
|
|
27583
|
+
}
|
|
27584
|
+
});
|
|
27585
|
+
|
|
27586
|
+
// ../connectors/src/connectors/powerbi/parameters.ts
|
|
27587
|
+
var parameters80 = {
|
|
27588
|
+
tenantId: new ParameterDefinition({
|
|
27589
|
+
slug: "tenant-id",
|
|
27590
|
+
name: "Azure Tenant ID",
|
|
27591
|
+
description: "The Microsoft Entra ID (Azure AD) tenant ID that owns the Service Principal. Found in Azure Portal > Microsoft Entra ID > Overview > Tenant ID.",
|
|
27592
|
+
envVarBaseKey: "POWERBI_TENANT_ID",
|
|
27593
|
+
type: "text",
|
|
27594
|
+
secret: false,
|
|
27595
|
+
required: true
|
|
27596
|
+
}),
|
|
27597
|
+
clientId: new ParameterDefinition({
|
|
27598
|
+
slug: "client-id",
|
|
27599
|
+
name: "Application (Client) ID",
|
|
27600
|
+
description: "The Application (client) ID of the Microsoft Entra app registration used as the Power BI Service Principal. Found in Azure Portal > App registrations > Overview.",
|
|
27601
|
+
envVarBaseKey: "POWERBI_CLIENT_ID",
|
|
27602
|
+
type: "text",
|
|
27603
|
+
secret: false,
|
|
27604
|
+
required: true
|
|
27605
|
+
}),
|
|
27606
|
+
clientSecret: new ParameterDefinition({
|
|
27607
|
+
slug: "client-secret",
|
|
27608
|
+
name: "Client Secret",
|
|
27609
|
+
description: "A client secret value for the app registration. Generated under App registrations > Certificates & secrets > Client secrets. The Service Principal must be granted Power BI tenant access (via 'Allow service principals to use Power BI APIs' admin setting) and added to each workspace as a Member/Admin.",
|
|
27610
|
+
envVarBaseKey: "POWERBI_CLIENT_SECRET",
|
|
27611
|
+
type: "text",
|
|
27612
|
+
secret: true,
|
|
27613
|
+
required: true
|
|
27614
|
+
})
|
|
27583
27615
|
};
|
|
27584
27616
|
|
|
27585
|
-
// src/
|
|
27586
|
-
|
|
27587
|
-
|
|
27588
|
-
|
|
27589
|
-
|
|
27617
|
+
// ../connectors/src/connectors/powerbi/tools/request.ts
|
|
27618
|
+
import { z as z97 } from "zod";
|
|
27619
|
+
var BASE_HOST12 = "https://api.powerbi.com";
|
|
27620
|
+
var BASE_PATH_SEGMENT15 = "/v1.0/myorg";
|
|
27621
|
+
var BASE_URL41 = `${BASE_HOST12}${BASE_PATH_SEGMENT15}`;
|
|
27622
|
+
var TOKEN_SCOPE = "https://analysis.windows.net/powerbi/api/.default";
|
|
27623
|
+
var REQUEST_TIMEOUT_MS74 = 6e4;
|
|
27624
|
+
var tokenCache = /* @__PURE__ */ new Map();
|
|
27625
|
+
async function getAccessToken(tenantId, clientId, clientSecret) {
|
|
27626
|
+
const cacheKey = `${tenantId}:${clientId}`;
|
|
27627
|
+
const cached = tokenCache.get(cacheKey);
|
|
27628
|
+
if (cached && cached.expiresAt > Date.now() + 6e4) {
|
|
27629
|
+
return cached.token;
|
|
27630
|
+
}
|
|
27631
|
+
const tokenUrl = `https://login.microsoftonline.com/${encodeURIComponent(tenantId)}/oauth2/v2.0/token`;
|
|
27632
|
+
const body = new URLSearchParams({
|
|
27633
|
+
grant_type: "client_credentials",
|
|
27634
|
+
client_id: clientId,
|
|
27635
|
+
client_secret: clientSecret,
|
|
27636
|
+
scope: TOKEN_SCOPE
|
|
27637
|
+
});
|
|
27638
|
+
const res = await fetch(tokenUrl, {
|
|
27639
|
+
method: "POST",
|
|
27640
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
27641
|
+
body: body.toString()
|
|
27642
|
+
});
|
|
27643
|
+
if (!res.ok) {
|
|
27644
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
27645
|
+
throw new Error(
|
|
27646
|
+
`Power BI token request failed: HTTP ${res.status} ${errorText}`
|
|
27647
|
+
);
|
|
27648
|
+
}
|
|
27649
|
+
const data = await res.json();
|
|
27650
|
+
tokenCache.set(cacheKey, {
|
|
27651
|
+
token: data.access_token,
|
|
27652
|
+
expiresAt: Date.now() + data.expires_in * 1e3
|
|
27653
|
+
});
|
|
27654
|
+
return data.access_token;
|
|
27655
|
+
}
|
|
27656
|
+
var inputSchema97 = z97.object({
|
|
27657
|
+
toolUseIntent: z97.string().optional().describe(
|
|
27658
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
27659
|
+
),
|
|
27660
|
+
connectionId: z97.string().describe("ID of the Power BI connection to use"),
|
|
27661
|
+
method: z97.enum(["GET", "POST", "PATCH", "PUT", "DELETE"]).describe(
|
|
27662
|
+
"HTTP method. Use GET for reading workspaces/datasets/reports, POST for execute queries / refresh, PATCH/PUT for updates, DELETE for removal."
|
|
27663
|
+
),
|
|
27664
|
+
path: z97.string().describe(
|
|
27665
|
+
"API path appended to https://api.powerbi.com/v1.0/myorg (e.g., '/groups', '/groups/{groupId}/datasets', '/groups/{groupId}/reports/{reportId}'). Service Principal cannot access 'My workspace' \u2014 always work through workspace (group) IDs."
|
|
27666
|
+
),
|
|
27667
|
+
queryParams: z97.record(z97.string(), z97.string()).optional().describe(
|
|
27668
|
+
`Query parameters to append to the URL (e.g., { $top: '50', $filter: "name eq 'Sales'" }). OData operators ($filter, $top, $skip, $expand) are supported on many list endpoints.`
|
|
27669
|
+
),
|
|
27670
|
+
body: z97.record(z97.string(), z97.unknown()).optional().describe(
|
|
27671
|
+
"JSON request body for POST/PATCH/PUT/DELETE. Example: executeQueries body { queries: [{ query: 'EVALUATE TOPN(10, Sales)' }], serializerSettings: { includeNulls: true } }."
|
|
27672
|
+
)
|
|
27673
|
+
});
|
|
27674
|
+
var outputSchema97 = z97.discriminatedUnion("success", [
|
|
27675
|
+
z97.object({
|
|
27676
|
+
success: z97.literal(true),
|
|
27677
|
+
status: z97.number(),
|
|
27678
|
+
data: z97.unknown()
|
|
27679
|
+
}),
|
|
27680
|
+
z97.object({
|
|
27681
|
+
success: z97.literal(false),
|
|
27682
|
+
error: z97.string()
|
|
27683
|
+
})
|
|
27684
|
+
]);
|
|
27685
|
+
var requestTool56 = new ConnectorTool({
|
|
27686
|
+
name: "request",
|
|
27687
|
+
description: `Send authenticated requests to the Power BI REST API v1.0.
|
|
27688
|
+
Authentication uses a Microsoft Entra Service Principal (client_credentials) \u2014 the token is acquired and cached automatically.
|
|
27689
|
+
All paths are relative to https://api.powerbi.com/v1.0/myorg. Service Principals cannot access 'My workspace'; always operate on workspaces ('groups') the SP has been added to.
|
|
27690
|
+
Use the executeQueries endpoint (POST /groups/{groupId}/datasets/{datasetId}/executeQueries) to run DAX against a dataset.`,
|
|
27691
|
+
inputSchema: inputSchema97,
|
|
27692
|
+
outputSchema: outputSchema97,
|
|
27693
|
+
async execute({ connectionId, method, path: path4, queryParams, body }, connections) {
|
|
27694
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
27695
|
+
if (!connection) {
|
|
27696
|
+
return {
|
|
27697
|
+
success: false,
|
|
27698
|
+
error: `Connection ${connectionId} not found`
|
|
27699
|
+
};
|
|
27700
|
+
}
|
|
27701
|
+
console.log(
|
|
27702
|
+
`[connector-request] powerbi/${connection.name}: ${method} ${path4}`
|
|
27703
|
+
);
|
|
27704
|
+
try {
|
|
27705
|
+
const tenantId = parameters80.tenantId.getValue(connection);
|
|
27706
|
+
const clientId = parameters80.clientId.getValue(connection);
|
|
27707
|
+
const clientSecret = parameters80.clientSecret.getValue(connection);
|
|
27708
|
+
const normalizedPath = normalizeRequestPath(path4, BASE_PATH_SEGMENT15);
|
|
27709
|
+
let url = `${BASE_URL41}${normalizedPath}`;
|
|
27710
|
+
if (queryParams) {
|
|
27711
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
27712
|
+
url += `?${searchParams.toString()}`;
|
|
27713
|
+
}
|
|
27714
|
+
const token = await getAccessToken(tenantId, clientId, clientSecret);
|
|
27715
|
+
const controller = new AbortController();
|
|
27716
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS74);
|
|
27717
|
+
try {
|
|
27718
|
+
const init = {
|
|
27719
|
+
method,
|
|
27720
|
+
headers: {
|
|
27721
|
+
Authorization: `Bearer ${token}`,
|
|
27722
|
+
"Content-Type": "application/json",
|
|
27723
|
+
Accept: "application/json"
|
|
27724
|
+
},
|
|
27725
|
+
signal: controller.signal
|
|
27726
|
+
};
|
|
27727
|
+
if (body !== void 0) {
|
|
27728
|
+
init.body = JSON.stringify(body);
|
|
27729
|
+
}
|
|
27730
|
+
const response = await fetch(url, init);
|
|
27731
|
+
const text = await response.text();
|
|
27732
|
+
const data = text ? (() => {
|
|
27733
|
+
try {
|
|
27734
|
+
return JSON.parse(text);
|
|
27735
|
+
} catch {
|
|
27736
|
+
return text;
|
|
27737
|
+
}
|
|
27738
|
+
})() : null;
|
|
27739
|
+
if (!response.ok) {
|
|
27740
|
+
const errorMessage = data && typeof data === "object" && "error" in data ? JSON.stringify(data.error) : typeof data === "string" && data ? data : `HTTP ${response.status} ${response.statusText}`;
|
|
27741
|
+
return { success: false, error: errorMessage };
|
|
27742
|
+
}
|
|
27743
|
+
return { success: true, status: response.status, data };
|
|
27744
|
+
} finally {
|
|
27745
|
+
clearTimeout(timeout);
|
|
27746
|
+
}
|
|
27747
|
+
} catch (err) {
|
|
27748
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
27749
|
+
return { success: false, error: msg };
|
|
27750
|
+
}
|
|
27751
|
+
}
|
|
27752
|
+
});
|
|
27753
|
+
|
|
27754
|
+
// ../connectors/src/connectors/powerbi/index.ts
|
|
27755
|
+
var tools80 = { request: requestTool56 };
|
|
27756
|
+
var powerbiConnector = new ConnectorPlugin({
|
|
27757
|
+
slug: "powerbi",
|
|
27758
|
+
authType: AUTH_TYPES.API_KEY,
|
|
27759
|
+
name: "Power BI",
|
|
27760
|
+
description: "Connect to Microsoft Power BI via a Service Principal (Microsoft Entra ID app + tenant ID / client ID / client secret). Use it to enumerate workspaces, datasets, and reports, and to run DAX queries.",
|
|
27761
|
+
iconUrl: "https://upload.wikimedia.org/wikipedia/commons/c/cf/New_Power_BI_Logo.svg",
|
|
27762
|
+
parameters: parameters80,
|
|
27763
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
27764
|
+
categories: ["other"],
|
|
27765
|
+
onboarding: powerbiOnboarding,
|
|
27766
|
+
systemPrompt: {
|
|
27767
|
+
en: `### Tools
|
|
27768
|
+
|
|
27769
|
+
- \`powerbi_request\`: The only way to call the Power BI REST API v1.0. Use it to list workspaces (\`/groups\`), datasets, reports, dashboards, and to run DAX via the \`executeQueries\` endpoint. Service Principal authentication (\`client_credentials\`) is handled automatically and the bearer token is cached.
|
|
27770
|
+
|
|
27771
|
+
### Business Logic
|
|
27772
|
+
|
|
27773
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
27774
|
+
|
|
27775
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
27776
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path appended to \`https://api.powerbi.com/v1.0/myorg\`)
|
|
27777
|
+
- \`client.listGroups(options?)\` \u2014 list workspaces (\`$top\`, \`$skip\`, \`$filter\`)
|
|
27778
|
+
- \`client.listDatasets(groupId)\` / \`client.listReports(groupId)\` \u2014 list datasets / reports in a workspace
|
|
27779
|
+
- \`client.getDataset(groupId, datasetId)\` \u2014 fetch a single dataset
|
|
27780
|
+
- \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 run DAX queries against a dataset
|
|
27781
|
+
- \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 trigger an async refresh
|
|
27782
|
+
|
|
27783
|
+
\`\`\`ts
|
|
27784
|
+
import type { Context } from "hono";
|
|
27785
|
+
import { connection } from "@squadbase/vite-server/connectors/powerbi";
|
|
27786
|
+
|
|
27787
|
+
const powerbi = connection("<connectionId>");
|
|
27788
|
+
|
|
27789
|
+
export default async function handler(c: Context) {
|
|
27790
|
+
const { groupId, datasetId, dax } = await c.req.json<{
|
|
27791
|
+
groupId: string;
|
|
27792
|
+
datasetId: string;
|
|
27793
|
+
dax: string;
|
|
27794
|
+
}>();
|
|
27795
|
+
|
|
27796
|
+
const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
|
|
27797
|
+
const rows = result.results[0]?.tables[0]?.rows ?? [];
|
|
27798
|
+
return c.json({ rows });
|
|
27799
|
+
}
|
|
27800
|
+
\`\`\`
|
|
27801
|
+
|
|
27802
|
+
### Power BI REST API Reference
|
|
27803
|
+
|
|
27804
|
+
- Base URL: \`https://api.powerbi.com/v1.0/myorg\`
|
|
27805
|
+
- Authentication: Microsoft Entra Service Principal via OAuth2 \`client_credentials\` grant against \`https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token\` with scope \`https://analysis.windows.net/powerbi/api/.default\` (handled automatically)
|
|
27806
|
+
- Service Principals cannot access "My workspace"; the SP must be added as Member/Admin to each workspace
|
|
27807
|
+
- The tenant admin must enable "Allow service principals to use Power BI APIs" in the Power BI admin portal
|
|
27808
|
+
|
|
27809
|
+
#### Common Endpoints
|
|
27810
|
+
- GET \`/groups\` \u2014 List workspaces accessible to the Service Principal
|
|
27811
|
+
- GET \`/groups/{groupId}/datasets\` \u2014 List datasets in a workspace
|
|
27812
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 Get dataset metadata
|
|
27813
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/tables\` \u2014 List tables (requires XMLA / metadata reads enabled)
|
|
27814
|
+
- GET \`/groups/{groupId}/reports\` \u2014 List reports
|
|
27815
|
+
- GET \`/groups/{groupId}/dashboards\` \u2014 List dashboards
|
|
27816
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 Run DAX (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
|
|
27817
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 Trigger a dataset refresh
|
|
27818
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 List recent refresh history
|
|
27819
|
+
|
|
27820
|
+
#### DAX Tips
|
|
27821
|
+
- \`EVALUATE TOPN(10, 'TableName')\` \u2014 sample 10 rows from a table
|
|
27822
|
+
- \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 aggregate
|
|
27823
|
+
- Each \`executeQueries\` call accepts one query in the \`queries\` array (per current Power BI API limits); large result sets are truncated server-side (100k rows max)`,
|
|
27824
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
27825
|
+
|
|
27826
|
+
- \`powerbi_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\u3001\u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9\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\u3002Service Principal \u8A8D\u8A3C (\`client_credentials\`) \u306F\u81EA\u52D5\u3067\u51E6\u7406\u3055\u308C\u3001Bearer \u30C8\u30FC\u30AF\u30F3\u306F\u30AD\u30E3\u30C3\u30B7\u30E5\u3055\u308C\u307E\u3059\u3002
|
|
27827
|
+
|
|
27828
|
+
### Business Logic
|
|
27829
|
+
|
|
27830
|
+
\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
|
|
27831
|
+
|
|
27832
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
27833
|
+
- \`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)
|
|
27834
|
+
- \`client.listGroups(options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7 (\`$top\`, \`$skip\`, \`$filter\`)
|
|
27835
|
+
- \`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
|
|
27836
|
+
- \`client.getDataset(groupId, datasetId)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u5358\u4F53\u53D6\u5F97
|
|
27837
|
+
- \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 DAX \u30AF\u30A8\u30EA\u5B9F\u884C
|
|
27838
|
+
- \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u3092\u975E\u540C\u671F\u30C8\u30EA\u30AC\u30FC
|
|
27839
|
+
|
|
27840
|
+
\`\`\`ts
|
|
27841
|
+
import type { Context } from "hono";
|
|
27842
|
+
import { connection } from "@squadbase/vite-server/connectors/powerbi";
|
|
27843
|
+
|
|
27844
|
+
const powerbi = connection("<connectionId>");
|
|
27845
|
+
|
|
27846
|
+
export default async function handler(c: Context) {
|
|
27847
|
+
const { groupId, datasetId, dax } = await c.req.json<{
|
|
27848
|
+
groupId: string;
|
|
27849
|
+
datasetId: string;
|
|
27850
|
+
dax: string;
|
|
27851
|
+
}>();
|
|
27852
|
+
|
|
27853
|
+
const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
|
|
27854
|
+
const rows = result.results[0]?.tables[0]?.rows ?? [];
|
|
27855
|
+
return c.json({ rows });
|
|
27856
|
+
}
|
|
27857
|
+
\`\`\`
|
|
27858
|
+
|
|
27859
|
+
### Power BI REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
27860
|
+
|
|
27861
|
+
- \u30D9\u30FC\u30B9 URL: \`https://api.powerbi.com/v1.0/myorg\`
|
|
27862
|
+
- \u8A8D\u8A3C: Microsoft Entra Service Principal \u306B\u3088\u308B OAuth2 \`client_credentials\` \u30B0\u30E9\u30F3\u30C8\u3002\`https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token\` \u306B\u5BFE\u3057\u30B9\u30B3\u30FC\u30D7 \`https://analysis.windows.net/powerbi/api/.default\` \u3067\u30C8\u30FC\u30AF\u30F3\u53D6\u5F97 (\u81EA\u52D5)
|
|
27863
|
+
- Service Principal \u306F\u300C\u30DE\u30A4 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u300D\u306B\u30A2\u30AF\u30BB\u30B9\u4E0D\u53EF\u3002\u5404\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306B Member/Admin \u3068\u3057\u3066\u8FFD\u52A0\u304C\u5FC5\u8981
|
|
27864
|
+
- \u30C6\u30CA\u30F3\u30C8\u7BA1\u7406\u8005\u304C Power BI \u7BA1\u7406\u30DD\u30FC\u30BF\u30EB\u3067\u300C\u30B5\u30FC\u30D3\u30B9 \u30D7\u30EA\u30F3\u30B7\u30D1\u30EB\u306B Power BI API \u306E\u4F7F\u7528\u3092\u8A31\u53EF\u3059\u308B\u300D\u3092\u6709\u52B9\u306B\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
|
|
27865
|
+
|
|
27866
|
+
#### \u4E3B\u8981\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
27867
|
+
- GET \`/groups\` \u2014 Service Principal \u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
|
|
27868
|
+
- GET \`/groups/{groupId}/datasets\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7
|
|
27869
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8 \u30E1\u30BF\u30C7\u30FC\u30BF
|
|
27870
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/tables\` \u2014 \u30C6\u30FC\u30D6\u30EB\u4E00\u89A7 (XMLA / \u30E1\u30BF\u30C7\u30FC\u30BF\u8AAD\u307F\u53D6\u308A\u304C\u6709\u52B9\u3067\u3042\u308B\u5FC5\u8981\u3042\u308A)
|
|
27871
|
+
- GET \`/groups/{groupId}/reports\` \u2014 \u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
|
|
27872
|
+
- GET \`/groups/{groupId}/dashboards\` \u2014 \u30C0\u30C3\u30B7\u30E5\u30DC\u30FC\u30C9\u4E00\u89A7
|
|
27873
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 DAX \u5B9F\u884C (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
|
|
27874
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u30C8\u30EA\u30AC\u30FC
|
|
27875
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u76F4\u8FD1\u306E\u66F4\u65B0\u5C65\u6B74
|
|
27876
|
+
|
|
27877
|
+
#### DAX Tips
|
|
27878
|
+
- \`EVALUATE TOPN(10, 'TableName')\` \u2014 \u30C6\u30FC\u30D6\u30EB\u304B\u3089 10 \u884C\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
27879
|
+
- \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 \u96C6\u8A08
|
|
27880
|
+
- \`executeQueries\` \u306F\u73FE\u72B6 1 \u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u3064\u304D 1 \u30AF\u30A8\u30EA\u306E\u307F\u3002\u7D50\u679C\u306F\u6700\u5927 10 \u4E07\u884C\u307E\u3067\u30B5\u30FC\u30D0\u30FC\u5074\u3067\u5207\u308A\u8A70\u3081\u3089\u308C\u307E\u3059`
|
|
27881
|
+
},
|
|
27882
|
+
tools: tools80,
|
|
27883
|
+
async checkConnection(params) {
|
|
27884
|
+
const tenantId = params[parameters80.tenantId.slug];
|
|
27885
|
+
const clientId = params[parameters80.clientId.slug];
|
|
27886
|
+
const clientSecret = params[parameters80.clientSecret.slug];
|
|
27887
|
+
if (!tenantId || !clientId || !clientSecret) {
|
|
27888
|
+
return {
|
|
27889
|
+
success: false,
|
|
27890
|
+
error: "Missing required parameters: tenant-id, client-id, client-secret"
|
|
27891
|
+
};
|
|
27892
|
+
}
|
|
27893
|
+
try {
|
|
27894
|
+
const tokenUrl = `https://login.microsoftonline.com/${encodeURIComponent(tenantId)}/oauth2/v2.0/token`;
|
|
27895
|
+
const body = new URLSearchParams({
|
|
27896
|
+
grant_type: "client_credentials",
|
|
27897
|
+
client_id: clientId,
|
|
27898
|
+
client_secret: clientSecret,
|
|
27899
|
+
scope: "https://analysis.windows.net/powerbi/api/.default"
|
|
27900
|
+
});
|
|
27901
|
+
const tokenRes = await fetch(tokenUrl, {
|
|
27902
|
+
method: "POST",
|
|
27903
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
27904
|
+
body: body.toString()
|
|
27905
|
+
});
|
|
27906
|
+
if (!tokenRes.ok) {
|
|
27907
|
+
const errorText = await tokenRes.text().catch(() => tokenRes.statusText);
|
|
27908
|
+
return {
|
|
27909
|
+
success: false,
|
|
27910
|
+
error: `Power BI token request failed: HTTP ${tokenRes.status} ${errorText}`
|
|
27911
|
+
};
|
|
27912
|
+
}
|
|
27913
|
+
const { access_token } = await tokenRes.json();
|
|
27914
|
+
const apiRes = await fetch(
|
|
27915
|
+
"https://api.powerbi.com/v1.0/myorg/groups?$top=1",
|
|
27916
|
+
{
|
|
27917
|
+
method: "GET",
|
|
27918
|
+
headers: {
|
|
27919
|
+
Authorization: `Bearer ${access_token}`,
|
|
27920
|
+
Accept: "application/json"
|
|
27921
|
+
}
|
|
27922
|
+
}
|
|
27923
|
+
);
|
|
27924
|
+
if (!apiRes.ok) {
|
|
27925
|
+
const errorText = await apiRes.text().catch(() => apiRes.statusText);
|
|
27926
|
+
return {
|
|
27927
|
+
success: false,
|
|
27928
|
+
error: `Power BI API failed: HTTP ${apiRes.status} ${errorText}`
|
|
27929
|
+
};
|
|
27930
|
+
}
|
|
27931
|
+
return { success: true };
|
|
27932
|
+
} catch (error) {
|
|
27933
|
+
return {
|
|
27934
|
+
success: false,
|
|
27935
|
+
error: error instanceof Error ? error.message : String(error)
|
|
27936
|
+
};
|
|
27937
|
+
}
|
|
27938
|
+
}
|
|
27939
|
+
});
|
|
27940
|
+
|
|
27941
|
+
// ../connectors/src/connectors/powerbi-oauth/tools/request.ts
|
|
27942
|
+
import { z as z98 } from "zod";
|
|
27943
|
+
var BASE_HOST13 = "https://api.powerbi.com";
|
|
27944
|
+
var BASE_PATH_SEGMENT16 = "/v1.0/myorg";
|
|
27945
|
+
var BASE_URL42 = `${BASE_HOST13}${BASE_PATH_SEGMENT16}`;
|
|
27946
|
+
var REQUEST_TIMEOUT_MS75 = 6e4;
|
|
27947
|
+
var cachedToken32 = null;
|
|
27948
|
+
async function getProxyToken32(config) {
|
|
27949
|
+
if (cachedToken32 && cachedToken32.expiresAt > Date.now() + 6e4) {
|
|
27950
|
+
return cachedToken32.token;
|
|
27951
|
+
}
|
|
27952
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
27953
|
+
const res = await fetch(url, {
|
|
27954
|
+
method: "POST",
|
|
27955
|
+
headers: {
|
|
27956
|
+
"Content-Type": "application/json",
|
|
27957
|
+
"x-api-key": config.appApiKey,
|
|
27958
|
+
"project-id": config.projectId
|
|
27959
|
+
},
|
|
27960
|
+
body: JSON.stringify({
|
|
27961
|
+
sandboxId: config.sandboxId,
|
|
27962
|
+
issuedBy: "coding-agent"
|
|
27963
|
+
})
|
|
27964
|
+
});
|
|
27965
|
+
if (!res.ok) {
|
|
27966
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
27967
|
+
throw new Error(
|
|
27968
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
27969
|
+
);
|
|
27970
|
+
}
|
|
27971
|
+
const data = await res.json();
|
|
27972
|
+
cachedToken32 = {
|
|
27973
|
+
token: data.token,
|
|
27974
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
27975
|
+
};
|
|
27976
|
+
return data.token;
|
|
27977
|
+
}
|
|
27978
|
+
var inputSchema98 = z98.object({
|
|
27979
|
+
toolUseIntent: z98.string().optional().describe(
|
|
27980
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
27981
|
+
),
|
|
27982
|
+
connectionId: z98.string().describe("ID of the Power BI OAuth connection to use"),
|
|
27983
|
+
method: z98.enum(["GET", "POST", "PATCH", "PUT", "DELETE"]).describe(
|
|
27984
|
+
"HTTP method. GET for reading workspaces/datasets/reports, POST for executeQueries / refresh, PATCH/PUT for updates, DELETE for removal."
|
|
27985
|
+
),
|
|
27986
|
+
path: z98.string().describe(
|
|
27987
|
+
"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."
|
|
27988
|
+
),
|
|
27989
|
+
queryParams: z98.record(z98.string(), z98.string()).optional().describe(
|
|
27990
|
+
`Query parameters to append (e.g., { $top: '50', $filter: "name eq 'Sales'" }).`
|
|
27991
|
+
),
|
|
27992
|
+
body: z98.record(z98.string(), z98.unknown()).optional().describe(
|
|
27993
|
+
"JSON request body for POST/PATCH/PUT/DELETE. Example executeQueries body: { queries: [{ query: 'EVALUATE TOPN(10, Sales)' }], serializerSettings: { includeNulls: true } }."
|
|
27994
|
+
)
|
|
27995
|
+
});
|
|
27996
|
+
var outputSchema98 = z98.discriminatedUnion("success", [
|
|
27997
|
+
z98.object({
|
|
27998
|
+
success: z98.literal(true),
|
|
27999
|
+
status: z98.number(),
|
|
28000
|
+
data: z98.unknown()
|
|
28001
|
+
}),
|
|
28002
|
+
z98.object({
|
|
28003
|
+
success: z98.literal(false),
|
|
28004
|
+
error: z98.string()
|
|
28005
|
+
})
|
|
28006
|
+
]);
|
|
28007
|
+
var requestTool57 = new ConnectorTool({
|
|
28008
|
+
name: "request",
|
|
28009
|
+
description: `Send authenticated requests to the Power BI REST API v1.0 using the user's Microsoft Entra OAuth token (proxied automatically).
|
|
28010
|
+
All paths are relative to https://api.powerbi.com/v1.0/myorg. Use the executeQueries endpoint to run DAX against a dataset.
|
|
28011
|
+
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.`,
|
|
28012
|
+
inputSchema: inputSchema98,
|
|
28013
|
+
outputSchema: outputSchema98,
|
|
28014
|
+
async execute({ connectionId, method, path: path4, queryParams, body }, connections, config) {
|
|
28015
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
28016
|
+
if (!connection) {
|
|
28017
|
+
return {
|
|
28018
|
+
success: false,
|
|
28019
|
+
error: `Connection ${connectionId} not found`
|
|
28020
|
+
};
|
|
28021
|
+
}
|
|
28022
|
+
console.log(
|
|
28023
|
+
`[connector-request] powerbi-oauth/${connection.name}: ${method} ${path4}`
|
|
28024
|
+
);
|
|
28025
|
+
try {
|
|
28026
|
+
const normalizedPath = normalizeRequestPath(path4, BASE_PATH_SEGMENT16);
|
|
28027
|
+
let url = `${BASE_URL42}${normalizedPath}`;
|
|
28028
|
+
if (queryParams) {
|
|
28029
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
28030
|
+
url += `?${searchParams.toString()}`;
|
|
28031
|
+
}
|
|
28032
|
+
const token = await getProxyToken32(config.oauthProxy);
|
|
28033
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
28034
|
+
const controller = new AbortController();
|
|
28035
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS75);
|
|
28036
|
+
try {
|
|
28037
|
+
const response = await fetch(proxyUrl, {
|
|
28038
|
+
method: "POST",
|
|
28039
|
+
headers: {
|
|
28040
|
+
"Content-Type": "application/json",
|
|
28041
|
+
Authorization: `Bearer ${token}`
|
|
28042
|
+
},
|
|
28043
|
+
body: JSON.stringify({
|
|
28044
|
+
url,
|
|
28045
|
+
method,
|
|
28046
|
+
...body !== void 0 ? { body } : {}
|
|
28047
|
+
}),
|
|
28048
|
+
signal: controller.signal
|
|
28049
|
+
});
|
|
28050
|
+
const text = await response.text();
|
|
28051
|
+
const data = text ? (() => {
|
|
28052
|
+
try {
|
|
28053
|
+
return JSON.parse(text);
|
|
28054
|
+
} catch {
|
|
28055
|
+
return text;
|
|
28056
|
+
}
|
|
28057
|
+
})() : null;
|
|
28058
|
+
if (!response.ok) {
|
|
28059
|
+
const errorMessage = data && typeof data === "object" && "error" in data ? JSON.stringify(data.error) : typeof data === "string" && data ? data : `HTTP ${response.status} ${response.statusText}`;
|
|
28060
|
+
return { success: false, error: errorMessage };
|
|
28061
|
+
}
|
|
28062
|
+
return { success: true, status: response.status, data };
|
|
28063
|
+
} finally {
|
|
28064
|
+
clearTimeout(timeout);
|
|
28065
|
+
}
|
|
28066
|
+
} catch (err) {
|
|
28067
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28068
|
+
return { success: false, error: msg };
|
|
28069
|
+
}
|
|
28070
|
+
}
|
|
28071
|
+
});
|
|
28072
|
+
|
|
28073
|
+
// ../connectors/src/connectors/powerbi-oauth/setup.ts
|
|
28074
|
+
var requestToolName13 = `powerbi-oauth_${requestTool57.name}`;
|
|
28075
|
+
var powerbiOauthOnboarding = new ConnectorOnboarding({
|
|
28076
|
+
connectionSetupInstructions: {
|
|
28077
|
+
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
|
|
28078
|
+
|
|
28079
|
+
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
|
|
28080
|
+
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
|
|
28081
|
+
|
|
28082
|
+
#### \u5236\u7D04
|
|
28083
|
+
- **\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
|
|
28084
|
+
- \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
|
|
28085
|
+
en: `Follow these steps to set up the Power BI OAuth connection.
|
|
28086
|
+
|
|
28087
|
+
1. Call \`${requestToolName13}\` with \`method: "GET"\` and \`path: "/groups"\` to list the workspaces the user has access to
|
|
28088
|
+
2. If an error is returned, ask the user to verify that OAuth authentication completed correctly
|
|
28089
|
+
|
|
28090
|
+
#### Constraints
|
|
28091
|
+
- **Do NOT execute DAX queries or refresh datasets during setup**. Only the workspace listing above is allowed
|
|
28092
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool`
|
|
28093
|
+
},
|
|
28094
|
+
dataOverviewInstructions: {
|
|
28095
|
+
en: `1. Call powerbi-oauth_request with GET /groups to list accessible workspaces
|
|
28096
|
+
2. For a target workspace, call powerbi-oauth_request with GET /groups/{groupId}/datasets to list datasets
|
|
28097
|
+
3. Call powerbi-oauth_request with GET /groups/{groupId}/reports to list reports
|
|
28098
|
+
4. For each interesting dataset call powerbi-oauth_request with GET /groups/{groupId}/datasets/{datasetId}/tables to inspect tables`,
|
|
28099
|
+
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
|
|
28100
|
+
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
|
|
28101
|
+
3. powerbi-oauth_request \u3067 GET /groups/{groupId}/reports \u3092\u547C\u3073\u51FA\u3057\u3001\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
|
|
28102
|
+
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`
|
|
28103
|
+
}
|
|
28104
|
+
});
|
|
28105
|
+
|
|
28106
|
+
// ../connectors/src/connectors/powerbi-oauth/parameters.ts
|
|
28107
|
+
var parameters81 = {};
|
|
28108
|
+
|
|
28109
|
+
// ../connectors/src/connectors/powerbi-oauth/index.ts
|
|
28110
|
+
var tools81 = { request: requestTool57 };
|
|
28111
|
+
var powerbiOauthConnector = new ConnectorPlugin({
|
|
28112
|
+
slug: "powerbi",
|
|
28113
|
+
authType: AUTH_TYPES.OAUTH,
|
|
28114
|
+
name: "Power BI",
|
|
28115
|
+
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.",
|
|
28116
|
+
iconUrl: "https://upload.wikimedia.org/wikipedia/commons/c/cf/New_Power_BI_Logo.svg",
|
|
28117
|
+
parameters: parameters81,
|
|
28118
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
28119
|
+
categories: ["other"],
|
|
28120
|
+
onboarding: powerbiOauthOnboarding,
|
|
28121
|
+
proxyPolicy: {
|
|
28122
|
+
allowlist: [
|
|
28123
|
+
{
|
|
28124
|
+
host: "api.powerbi.com",
|
|
28125
|
+
methods: ["GET", "POST", "PATCH", "PUT", "DELETE"]
|
|
28126
|
+
}
|
|
28127
|
+
]
|
|
28128
|
+
},
|
|
28129
|
+
systemPrompt: {
|
|
28130
|
+
en: `### Tools
|
|
28131
|
+
|
|
28132
|
+
- \`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).
|
|
28133
|
+
|
|
28134
|
+
### Business Logic
|
|
28135
|
+
|
|
28136
|
+
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.
|
|
28137
|
+
|
|
28138
|
+
SDK surface (client created via \`connection(connectionId)\`):
|
|
28139
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path appended to \`https://api.powerbi.com/v1.0/myorg\`)
|
|
28140
|
+
- \`client.listGroups(options?)\` \u2014 list workspaces (\`$top\`, \`$skip\`, \`$filter\`)
|
|
28141
|
+
- \`client.listDatasets(groupId)\` / \`client.listReports(groupId)\` \u2014 list datasets / reports in a workspace
|
|
28142
|
+
- \`client.getDataset(groupId, datasetId)\` \u2014 fetch a single dataset
|
|
28143
|
+
- \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 run DAX queries
|
|
28144
|
+
- \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 trigger an async refresh
|
|
28145
|
+
|
|
28146
|
+
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.
|
|
28147
|
+
|
|
28148
|
+
\`\`\`ts
|
|
28149
|
+
import type { Context } from "hono";
|
|
28150
|
+
import { connection } from "@squadbase/vite-server/connectors/powerbi-oauth";
|
|
28151
|
+
|
|
28152
|
+
const powerbi = connection("<connectionId>");
|
|
28153
|
+
|
|
28154
|
+
export default async function handler(c: Context) {
|
|
28155
|
+
const { groupId, datasetId, dax } = await c.req.json<{
|
|
28156
|
+
groupId: string;
|
|
28157
|
+
datasetId: string;
|
|
28158
|
+
dax: string;
|
|
28159
|
+
}>();
|
|
28160
|
+
|
|
28161
|
+
const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
|
|
28162
|
+
const rows = result.results[0]?.tables[0]?.rows ?? [];
|
|
28163
|
+
return c.json({ rows });
|
|
28164
|
+
}
|
|
28165
|
+
\`\`\`
|
|
28166
|
+
|
|
28167
|
+
### Power BI REST API Reference
|
|
28168
|
+
|
|
28169
|
+
- Base URL: \`https://api.powerbi.com/v1.0/myorg\`
|
|
28170
|
+
- Authentication: Microsoft Entra OAuth (delegated; handled automatically)
|
|
28171
|
+
- Unlike Service Principals, OAuth users can also access "My workspace" via the \`/datasets\` (without \`/groups/\`) endpoints
|
|
28172
|
+
|
|
28173
|
+
#### Common Endpoints
|
|
28174
|
+
- GET \`/groups\` \u2014 List workspaces the signed-in user has access to
|
|
28175
|
+
- GET \`/groups/{groupId}/datasets\` \u2014 List datasets in a workspace
|
|
28176
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 Get dataset metadata
|
|
28177
|
+
- GET \`/groups/{groupId}/reports\` \u2014 List reports
|
|
28178
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 Run DAX (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
|
|
28179
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 Trigger a dataset refresh
|
|
28180
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 List recent refresh history
|
|
28181
|
+
|
|
28182
|
+
#### DAX Tips
|
|
28183
|
+
- \`EVALUATE TOPN(10, 'TableName')\` \u2014 sample 10 rows from a table
|
|
28184
|
+
- \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 aggregate
|
|
28185
|
+
- Each \`executeQueries\` call accepts one query in the \`queries\` array (per current Power BI API limits)`,
|
|
28186
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
28187
|
+
|
|
28188
|
+
- \`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
|
|
28189
|
+
|
|
28190
|
+
### Business Logic
|
|
28191
|
+
|
|
28192
|
+
\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
|
|
28193
|
+
|
|
28194
|
+
SDK (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
28195
|
+
- \`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)
|
|
28196
|
+
- \`client.listGroups(options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7 (\`$top\`, \`$skip\`, \`$filter\`)
|
|
28197
|
+
- \`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
|
|
28198
|
+
- \`client.getDataset(groupId, datasetId)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u5358\u4F53\u53D6\u5F97
|
|
28199
|
+
- \`client.executeQueries(groupId, datasetId, queries, options?)\` \u2014 DAX \u30AF\u30A8\u30EA\u5B9F\u884C
|
|
28200
|
+
- \`client.refreshDataset(groupId, datasetId, options?)\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u3092\u975E\u540C\u671F\u30C8\u30EA\u30AC\u30FC
|
|
28201
|
+
|
|
28202
|
+
\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
|
|
28203
|
+
|
|
28204
|
+
\`\`\`ts
|
|
28205
|
+
import type { Context } from "hono";
|
|
28206
|
+
import { connection } from "@squadbase/vite-server/connectors/powerbi-oauth";
|
|
28207
|
+
|
|
28208
|
+
const powerbi = connection("<connectionId>");
|
|
28209
|
+
|
|
28210
|
+
export default async function handler(c: Context) {
|
|
28211
|
+
const { groupId, datasetId, dax } = await c.req.json<{
|
|
28212
|
+
groupId: string;
|
|
28213
|
+
datasetId: string;
|
|
28214
|
+
dax: string;
|
|
28215
|
+
}>();
|
|
28216
|
+
|
|
28217
|
+
const result = await powerbi.executeQueries(groupId, datasetId, [dax]);
|
|
28218
|
+
const rows = result.results[0]?.tables[0]?.rows ?? [];
|
|
28219
|
+
return c.json({ rows });
|
|
28220
|
+
}
|
|
28221
|
+
\`\`\`
|
|
28222
|
+
|
|
28223
|
+
### Power BI REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
28224
|
+
|
|
28225
|
+
- \u30D9\u30FC\u30B9 URL: \`https://api.powerbi.com/v1.0/myorg\`
|
|
28226
|
+
- \u8A8D\u8A3C: Microsoft Entra OAuth (\u59D4\u4EFB\u578B\u3001\u81EA\u52D5\u8A2D\u5B9A)
|
|
28227
|
+
- 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
|
|
28228
|
+
|
|
28229
|
+
#### \u4E3B\u8981\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
28230
|
+
- GET \`/groups\` \u2014 \u30E6\u30FC\u30B6\u30FC\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
|
|
28231
|
+
- GET \`/groups/{groupId}/datasets\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u4E00\u89A7
|
|
28232
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8 \u30E1\u30BF\u30C7\u30FC\u30BF
|
|
28233
|
+
- GET \`/groups/{groupId}/reports\` \u2014 \u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
|
|
28234
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/executeQueries\` \u2014 DAX \u5B9F\u884C (body: \`{ queries: [{ query: "EVALUATE ..." }], serializerSettings: { includeNulls: true } }\`)
|
|
28235
|
+
- POST \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u30C7\u30FC\u30BF\u30BB\u30C3\u30C8\u66F4\u65B0\u30C8\u30EA\u30AC\u30FC
|
|
28236
|
+
- GET \`/groups/{groupId}/datasets/{datasetId}/refreshes\` \u2014 \u76F4\u8FD1\u306E\u66F4\u65B0\u5C65\u6B74
|
|
28237
|
+
|
|
28238
|
+
#### DAX Tips
|
|
28239
|
+
- \`EVALUATE TOPN(10, 'TableName')\` \u2014 \u30C6\u30FC\u30D6\u30EB\u304B\u3089 10 \u884C\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
28240
|
+
- \`EVALUATE SUMMARIZECOLUMNS('Date'[Year], "Sales", SUM('Sales'[Amount]))\` \u2014 \u96C6\u8A08
|
|
28241
|
+
- \`executeQueries\` \u306F\u73FE\u72B6 1 \u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u3064\u304D 1 \u30AF\u30A8\u30EA\u306E\u307F`
|
|
28242
|
+
},
|
|
28243
|
+
tools: tools81,
|
|
28244
|
+
async checkConnection(_params, config) {
|
|
28245
|
+
const { proxyFetch } = config;
|
|
28246
|
+
const url = "https://api.powerbi.com/v1.0/myorg/groups?$top=1";
|
|
28247
|
+
try {
|
|
28248
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
28249
|
+
if (!res.ok) {
|
|
28250
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
28251
|
+
return {
|
|
28252
|
+
success: false,
|
|
28253
|
+
error: `Power BI API failed: HTTP ${res.status} ${errorText}`
|
|
28254
|
+
};
|
|
28255
|
+
}
|
|
28256
|
+
return { success: true };
|
|
28257
|
+
} catch (error) {
|
|
28258
|
+
return {
|
|
28259
|
+
success: false,
|
|
28260
|
+
error: error instanceof Error ? error.message : String(error)
|
|
28261
|
+
};
|
|
28262
|
+
}
|
|
28263
|
+
}
|
|
28264
|
+
});
|
|
28265
|
+
|
|
28266
|
+
// ../connectors/src/connectors/tableau/setup.ts
|
|
28267
|
+
var tableauOnboarding = new ConnectorOnboarding({
|
|
28268
|
+
connectionSetupInstructions: {
|
|
28269
|
+
en: `Follow these steps to verify the Tableau PAT connection.
|
|
28270
|
+
|
|
28271
|
+
1. Call \`tableau_request\` with \`method: "GET"\` and \`path: "/sites/{siteId}/projects?pageSize=5"\` to list a few projects on the signed-in site
|
|
28272
|
+
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)
|
|
28273
|
+
|
|
28274
|
+
#### Constraints
|
|
28275
|
+
- **Do NOT mutate Tableau resources during setup** (no publish/update/delete). Only the project listing above is allowed
|
|
28276
|
+
- The literal placeholder \`{siteId}\` in the path is automatically replaced with the session's site ID \u2014 do NOT hardcode the ID`,
|
|
28277
|
+
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
|
|
28278
|
+
|
|
28279
|
+
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
|
|
28280
|
+
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
|
|
28281
|
+
|
|
28282
|
+
#### \u5236\u7D04
|
|
28283
|
+
- **\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
|
|
28284
|
+
- \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`
|
|
28285
|
+
},
|
|
28286
|
+
dataOverviewInstructions: {
|
|
28287
|
+
en: `1. Call tableau_request with GET /sites/{siteId}/projects to list projects
|
|
28288
|
+
2. Call tableau_request with GET /sites/{siteId}/workbooks?pageSize=20 to list workbooks
|
|
28289
|
+
3. For a target workbook, call tableau_request with GET /sites/{siteId}/workbooks/{workbookId}/views to list its views
|
|
28290
|
+
4. Call tableau_request with GET /sites/{siteId}/datasources?pageSize=20 to list published data sources`,
|
|
28291
|
+
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
|
|
28292
|
+
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
|
|
28293
|
+
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
|
|
28294
|
+
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`
|
|
28295
|
+
}
|
|
28296
|
+
});
|
|
28297
|
+
|
|
28298
|
+
// ../connectors/src/connectors/tableau/parameters.ts
|
|
28299
|
+
var parameters82 = {
|
|
28300
|
+
serverUrl: new ParameterDefinition({
|
|
28301
|
+
slug: "server-url",
|
|
28302
|
+
name: "Tableau Server URL",
|
|
28303
|
+
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.",
|
|
28304
|
+
envVarBaseKey: "TABLEAU_SERVER_URL",
|
|
28305
|
+
type: "text",
|
|
28306
|
+
secret: false,
|
|
28307
|
+
required: true
|
|
28308
|
+
}),
|
|
28309
|
+
siteContentUrl: new ParameterDefinition({
|
|
28310
|
+
slug: "site-content-url",
|
|
28311
|
+
name: "Site Content URL",
|
|
28312
|
+
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.",
|
|
28313
|
+
envVarBaseKey: "TABLEAU_SITE_CONTENT_URL",
|
|
28314
|
+
type: "text",
|
|
28315
|
+
secret: false,
|
|
28316
|
+
required: true
|
|
28317
|
+
}),
|
|
28318
|
+
patName: new ParameterDefinition({
|
|
28319
|
+
slug: "pat-name",
|
|
28320
|
+
name: "Personal Access Token Name",
|
|
28321
|
+
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.",
|
|
28322
|
+
envVarBaseKey: "TABLEAU_PAT_NAME",
|
|
28323
|
+
type: "text",
|
|
28324
|
+
secret: false,
|
|
28325
|
+
required: true
|
|
28326
|
+
}),
|
|
28327
|
+
patSecret: new ParameterDefinition({
|
|
28328
|
+
slug: "pat-secret",
|
|
28329
|
+
name: "Personal Access Token Secret",
|
|
28330
|
+
description: "Secret value shown once when the PAT is created. Tokens expire after 15 days of inactivity (default) and must be rotated regularly.",
|
|
28331
|
+
envVarBaseKey: "TABLEAU_PAT_SECRET",
|
|
28332
|
+
type: "text",
|
|
28333
|
+
secret: true,
|
|
28334
|
+
required: true
|
|
28335
|
+
}),
|
|
28336
|
+
apiVersion: new ParameterDefinition({
|
|
28337
|
+
slug: "api-version",
|
|
28338
|
+
name: "REST API Version",
|
|
28339
|
+
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.",
|
|
28340
|
+
envVarBaseKey: "TABLEAU_API_VERSION",
|
|
28341
|
+
type: "text",
|
|
28342
|
+
secret: false,
|
|
28343
|
+
required: false
|
|
28344
|
+
})
|
|
28345
|
+
};
|
|
28346
|
+
|
|
28347
|
+
// ../connectors/src/connectors/tableau/tools/request.ts
|
|
28348
|
+
import { z as z99 } from "zod";
|
|
28349
|
+
var DEFAULT_API_VERSION = "3.28";
|
|
28350
|
+
var REQUEST_TIMEOUT_MS76 = 6e4;
|
|
28351
|
+
var sessionCache = /* @__PURE__ */ new Map();
|
|
28352
|
+
function buildBaseUrl4(serverUrl, apiVersion) {
|
|
28353
|
+
return `${serverUrl.replace(/\/$/, "")}/api/${apiVersion}`;
|
|
28354
|
+
}
|
|
28355
|
+
async function signIn(serverUrl, apiVersion, siteContentUrl, patName, patSecret) {
|
|
28356
|
+
const url = `${buildBaseUrl4(serverUrl, apiVersion)}/auth/signin`;
|
|
28357
|
+
const body = {
|
|
28358
|
+
credentials: {
|
|
28359
|
+
personalAccessTokenName: patName,
|
|
28360
|
+
personalAccessTokenSecret: patSecret,
|
|
28361
|
+
site: { contentUrl: siteContentUrl }
|
|
28362
|
+
}
|
|
28363
|
+
};
|
|
28364
|
+
const res = await fetch(url, {
|
|
28365
|
+
method: "POST",
|
|
28366
|
+
headers: {
|
|
28367
|
+
"Content-Type": "application/json",
|
|
28368
|
+
Accept: "application/json"
|
|
28369
|
+
},
|
|
28370
|
+
body: JSON.stringify(body)
|
|
28371
|
+
});
|
|
28372
|
+
if (!res.ok) {
|
|
28373
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
28374
|
+
throw new Error(
|
|
28375
|
+
`Tableau sign-in failed: HTTP ${res.status} ${errorText}`
|
|
28376
|
+
);
|
|
28377
|
+
}
|
|
28378
|
+
const data = await res.json();
|
|
28379
|
+
return {
|
|
28380
|
+
authToken: data.credentials.token,
|
|
28381
|
+
siteId: data.credentials.site.id,
|
|
28382
|
+
userId: data.credentials.user.id,
|
|
28383
|
+
expiresAt: Date.now() + 30 * 60 * 1e3
|
|
28384
|
+
};
|
|
28385
|
+
}
|
|
28386
|
+
async function getSession(serverUrl, apiVersion, siteContentUrl, patName, patSecret) {
|
|
28387
|
+
const cacheKey = `${serverUrl}|${siteContentUrl}|${patName}`;
|
|
28388
|
+
const cached = sessionCache.get(cacheKey);
|
|
28389
|
+
if (cached && cached.expiresAt > Date.now() + 6e4) {
|
|
28390
|
+
return cached;
|
|
28391
|
+
}
|
|
28392
|
+
const session = await signIn(
|
|
28393
|
+
serverUrl,
|
|
28394
|
+
apiVersion,
|
|
28395
|
+
siteContentUrl,
|
|
28396
|
+
patName,
|
|
28397
|
+
patSecret
|
|
28398
|
+
);
|
|
28399
|
+
sessionCache.set(cacheKey, session);
|
|
28400
|
+
return session;
|
|
28401
|
+
}
|
|
28402
|
+
var inputSchema99 = z99.object({
|
|
28403
|
+
toolUseIntent: z99.string().optional().describe(
|
|
28404
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
28405
|
+
),
|
|
28406
|
+
connectionId: z99.string().describe("ID of the Tableau connection to use"),
|
|
28407
|
+
method: z99.enum(["GET", "POST", "PUT", "DELETE"]).describe(
|
|
28408
|
+
"HTTP method. GET for listing/reading, POST for creating, PUT for updates, DELETE for removal."
|
|
28409
|
+
),
|
|
28410
|
+
path: z99.string().describe(
|
|
28411
|
+
"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."
|
|
28412
|
+
),
|
|
28413
|
+
queryParams: z99.record(z99.string(), z99.string()).optional().describe(
|
|
28414
|
+
"Query parameters to append (e.g., { pageSize: '100', filter: 'name:eq:Sales' }). Tableau supports field filtering via 'fields' and sorting via 'sort'."
|
|
28415
|
+
),
|
|
28416
|
+
body: z99.record(z99.string(), z99.unknown()).optional().describe(
|
|
28417
|
+
"JSON request body for POST/PUT (Tableau also accepts XML, but JSON is recommended with Accept: application/json)."
|
|
28418
|
+
)
|
|
28419
|
+
});
|
|
28420
|
+
var outputSchema99 = z99.discriminatedUnion("success", [
|
|
28421
|
+
z99.object({
|
|
28422
|
+
success: z99.literal(true),
|
|
28423
|
+
status: z99.number(),
|
|
28424
|
+
data: z99.unknown()
|
|
28425
|
+
}),
|
|
28426
|
+
z99.object({
|
|
28427
|
+
success: z99.literal(false),
|
|
28428
|
+
error: z99.string()
|
|
28429
|
+
})
|
|
28430
|
+
]);
|
|
28431
|
+
var requestTool58 = new ConnectorTool({
|
|
28432
|
+
name: "request",
|
|
28433
|
+
description: `Send authenticated requests to the Tableau REST API.
|
|
28434
|
+
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.
|
|
28435
|
+
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.
|
|
28436
|
+
Accept and Content-Type headers default to application/json so list responses come back as JSON instead of Tableau's default XML.`,
|
|
28437
|
+
inputSchema: inputSchema99,
|
|
28438
|
+
outputSchema: outputSchema99,
|
|
28439
|
+
async execute({ connectionId, method, path: path4, queryParams, body }, connections) {
|
|
28440
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
28441
|
+
if (!connection) {
|
|
28442
|
+
return {
|
|
28443
|
+
success: false,
|
|
28444
|
+
error: `Connection ${connectionId} not found`
|
|
28445
|
+
};
|
|
28446
|
+
}
|
|
28447
|
+
console.log(
|
|
28448
|
+
`[connector-request] tableau/${connection.name}: ${method} ${path4}`
|
|
28449
|
+
);
|
|
28450
|
+
try {
|
|
28451
|
+
const serverUrl = parameters82.serverUrl.getValue(connection);
|
|
28452
|
+
const siteContentUrl = parameters82.siteContentUrl.getValue(connection);
|
|
28453
|
+
const patName = parameters82.patName.getValue(connection);
|
|
28454
|
+
const patSecret = parameters82.patSecret.getValue(connection);
|
|
28455
|
+
const apiVersion = parameters82.apiVersion.tryGetValue(connection) || DEFAULT_API_VERSION;
|
|
28456
|
+
const session = await getSession(
|
|
28457
|
+
serverUrl,
|
|
28458
|
+
apiVersion,
|
|
28459
|
+
siteContentUrl,
|
|
28460
|
+
patName,
|
|
28461
|
+
patSecret
|
|
28462
|
+
);
|
|
28463
|
+
const resolvedPath = path4.trim().replace(/\{siteId\}/g, session.siteId).replace(/^([^/])/, "/$1");
|
|
28464
|
+
let url = `${buildBaseUrl4(serverUrl, apiVersion)}${resolvedPath}`;
|
|
28465
|
+
if (queryParams) {
|
|
28466
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
28467
|
+
url += `?${searchParams.toString()}`;
|
|
28468
|
+
}
|
|
28469
|
+
const controller = new AbortController();
|
|
28470
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS76);
|
|
28471
|
+
try {
|
|
28472
|
+
const init = {
|
|
28473
|
+
method,
|
|
28474
|
+
headers: {
|
|
28475
|
+
"X-Tableau-Auth": session.authToken,
|
|
28476
|
+
Accept: "application/json",
|
|
28477
|
+
"Content-Type": "application/json"
|
|
28478
|
+
},
|
|
28479
|
+
signal: controller.signal
|
|
28480
|
+
};
|
|
28481
|
+
if (body !== void 0) {
|
|
28482
|
+
init.body = JSON.stringify(body);
|
|
28483
|
+
}
|
|
28484
|
+
const response = await fetch(url, init);
|
|
28485
|
+
const text = await response.text();
|
|
28486
|
+
const data = text ? (() => {
|
|
28487
|
+
try {
|
|
28488
|
+
return JSON.parse(text);
|
|
28489
|
+
} catch {
|
|
28490
|
+
return text;
|
|
28491
|
+
}
|
|
28492
|
+
})() : null;
|
|
28493
|
+
if (!response.ok) {
|
|
28494
|
+
const errorMessage = data && typeof data === "object" && "error" in data ? JSON.stringify(data.error) : typeof data === "string" && data ? data : `HTTP ${response.status} ${response.statusText}`;
|
|
28495
|
+
return { success: false, error: errorMessage };
|
|
28496
|
+
}
|
|
28497
|
+
return { success: true, status: response.status, data };
|
|
28498
|
+
} finally {
|
|
28499
|
+
clearTimeout(timeout);
|
|
28500
|
+
}
|
|
28501
|
+
} catch (err) {
|
|
28502
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28503
|
+
return { success: false, error: msg };
|
|
28504
|
+
}
|
|
28505
|
+
}
|
|
28506
|
+
});
|
|
28507
|
+
|
|
28508
|
+
// ../connectors/src/connectors/tableau/index.ts
|
|
28509
|
+
var tools82 = { request: requestTool58 };
|
|
28510
|
+
var tableauConnector = new ConnectorPlugin({
|
|
28511
|
+
slug: "tableau",
|
|
28512
|
+
authType: AUTH_TYPES.PAT,
|
|
28513
|
+
name: "Tableau",
|
|
28514
|
+
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.",
|
|
28515
|
+
iconUrl: "https://upload.wikimedia.org/wikipedia/commons/4/4b/Tableau_Logo.png",
|
|
28516
|
+
parameters: parameters82,
|
|
28517
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
28518
|
+
categories: ["other"],
|
|
28519
|
+
onboarding: tableauOnboarding,
|
|
28520
|
+
systemPrompt: {
|
|
28521
|
+
en: `### Tools
|
|
28522
|
+
|
|
28523
|
+
- \`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.
|
|
28524
|
+
|
|
28525
|
+
### Business Logic
|
|
28526
|
+
|
|
28527
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
28528
|
+
|
|
28529
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
28530
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path is appended to \`{serverUrl}/api/{apiVersion}\`; \`{siteId}\` is substituted)
|
|
28531
|
+
- \`client.getSession()\` \u2014 sign in (if needed) and return \`{ authToken, siteId, userId }\`
|
|
28532
|
+
- \`client.listProjects(options?)\` / \`client.listWorkbooks(options?)\` / \`client.listDatasources(options?)\`
|
|
28533
|
+
- \`client.listViewsForWorkbook(workbookId)\`
|
|
28534
|
+
- \`client.getViewData(viewId)\` \u2014 returns the view's underlying data as CSV text
|
|
28535
|
+
|
|
28536
|
+
\`\`\`ts
|
|
28537
|
+
import type { Context } from "hono";
|
|
28538
|
+
import { connection } from "@squadbase/vite-server/connectors/tableau";
|
|
28539
|
+
|
|
28540
|
+
const tableau = connection("<connectionId>");
|
|
28541
|
+
|
|
28542
|
+
export default async function handler(c: Context) {
|
|
28543
|
+
const { pageSize = 20 } = await c.req.json<{ pageSize?: number }>();
|
|
28544
|
+
const { workbooks, pagination } = await tableau.listWorkbooks({ pageSize });
|
|
28545
|
+
return c.json({
|
|
28546
|
+
workbooks: workbooks.workbook,
|
|
28547
|
+
totalAvailable: Number(pagination.totalAvailable),
|
|
28548
|
+
});
|
|
28549
|
+
}
|
|
28550
|
+
\`\`\`
|
|
28551
|
+
|
|
28552
|
+
### Tableau REST API Reference
|
|
28553
|
+
|
|
28554
|
+
- 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)
|
|
28555
|
+
- 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
|
|
28556
|
+
- Response format: JSON when \`Accept: application/json\` is sent (default); otherwise Tableau returns XML
|
|
28557
|
+
- Pagination: \`?pageSize=&pageNumber=\` query params with \`pagination\` object in response
|
|
28558
|
+
|
|
28559
|
+
#### Common Endpoints
|
|
28560
|
+
- POST \`/auth/signin\` \u2014 sign in (handled automatically)
|
|
28561
|
+
- POST \`/auth/signout\` \u2014 sign out
|
|
28562
|
+
- GET \`/sites/{siteId}/projects\` \u2014 list projects
|
|
28563
|
+
- GET \`/sites/{siteId}/workbooks\` \u2014 list workbooks (supports \`filter\`, \`sort\`)
|
|
28564
|
+
- GET \`/sites/{siteId}/workbooks/{workbookId}\` \u2014 get a workbook
|
|
28565
|
+
- GET \`/sites/{siteId}/workbooks/{workbookId}/views\` \u2014 list views in a workbook
|
|
28566
|
+
- GET \`/sites/{siteId}/views/{viewId}/data\` \u2014 get view data as CSV
|
|
28567
|
+
- GET \`/sites/{siteId}/views/{viewId}/image\` \u2014 get view as PNG
|
|
28568
|
+
- GET \`/sites/{siteId}/views/{viewId}/pdf\` \u2014 get view as PDF
|
|
28569
|
+
- GET \`/sites/{siteId}/datasources\` \u2014 list published data sources
|
|
28570
|
+
- GET \`/sites/{siteId}/users\` \u2014 list users
|
|
28571
|
+
- GET \`/sites/{siteId}/groups\` \u2014 list groups
|
|
28572
|
+
|
|
28573
|
+
#### Filter Syntax
|
|
28574
|
+
- \`filter=name:eq:Sales\` \u2014 exact match
|
|
28575
|
+
- \`filter=name:in:[Sales,Marketing]\` \u2014 set membership
|
|
28576
|
+
- \`filter=updatedAt:gte:2024-01-01T00:00:00Z\` \u2014 comparison operators (gt/gte/lt/lte)
|
|
28577
|
+
- Combine: \`filter=ownerName:eq:alice,tags:in:[finance]\``,
|
|
28578
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
28579
|
+
|
|
28580
|
+
- \`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
|
|
28581
|
+
|
|
28582
|
+
### Business Logic
|
|
28583
|
+
|
|
28584
|
+
\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
|
|
28585
|
+
|
|
28586
|
+
SDK \u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
28587
|
+
- \`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)
|
|
28588
|
+
- \`client.getSession()\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3 (\u5FC5\u8981\u306A\u3089) \u3057\u3066 \`{ authToken, siteId, userId }\` \u3092\u8FD4\u3059
|
|
28589
|
+
- \`client.listProjects(options?)\` / \`client.listWorkbooks(options?)\` / \`client.listDatasources(options?)\`
|
|
28590
|
+
- \`client.listViewsForWorkbook(workbookId)\`
|
|
28591
|
+
- \`client.getViewData(viewId)\` \u2014 \u30D3\u30E5\u30FC\u306E\u30C7\u30FC\u30BF\u3092 CSV \u30C6\u30AD\u30B9\u30C8\u3067\u8FD4\u3059
|
|
28592
|
+
|
|
28593
|
+
\`\`\`ts
|
|
28594
|
+
import type { Context } from "hono";
|
|
28595
|
+
import { connection } from "@squadbase/vite-server/connectors/tableau";
|
|
28596
|
+
|
|
28597
|
+
const tableau = connection("<connectionId>");
|
|
28598
|
+
|
|
28599
|
+
export default async function handler(c: Context) {
|
|
28600
|
+
const { pageSize = 20 } = await c.req.json<{ pageSize?: number }>();
|
|
28601
|
+
const { workbooks, pagination } = await tableau.listWorkbooks({ pageSize });
|
|
28602
|
+
return c.json({
|
|
28603
|
+
workbooks: workbooks.workbook,
|
|
28604
|
+
totalAvailable: Number(pagination.totalAvailable),
|
|
28605
|
+
});
|
|
28606
|
+
}
|
|
28607
|
+
\`\`\`
|
|
28608
|
+
|
|
28609
|
+
### Tableau REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
28610
|
+
|
|
28611
|
+
- \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)
|
|
28612
|
+
- \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
|
|
28613
|
+
- \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
|
|
28614
|
+
- \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
|
|
28615
|
+
|
|
28616
|
+
#### \u4E3B\u8981\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
28617
|
+
- POST \`/auth/signin\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3 (\u81EA\u52D5\u51E6\u7406)
|
|
28618
|
+
- POST \`/auth/signout\` \u2014 \u30B5\u30A4\u30F3\u30A2\u30A6\u30C8
|
|
28619
|
+
- GET \`/sites/{siteId}/projects\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7
|
|
28620
|
+
- GET \`/sites/{siteId}/workbooks\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u4E00\u89A7 (\`filter\`, \`sort\` \u5BFE\u5FDC)
|
|
28621
|
+
- GET \`/sites/{siteId}/workbooks/{workbookId}\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u53D6\u5F97
|
|
28622
|
+
- GET \`/sites/{siteId}/workbooks/{workbookId}/views\` \u2014 \u30EF\u30FC\u30AF\u30D6\u30C3\u30AF\u5185\u306E\u30D3\u30E5\u30FC\u4E00\u89A7
|
|
28623
|
+
- GET \`/sites/{siteId}/views/{viewId}/data\` \u2014 \u30D3\u30E5\u30FC\u30C7\u30FC\u30BF\u3092 CSV \u3067\u53D6\u5F97
|
|
28624
|
+
- GET \`/sites/{siteId}/views/{viewId}/image\` \u2014 \u30D3\u30E5\u30FC\u3092 PNG \u3067\u53D6\u5F97
|
|
28625
|
+
- GET \`/sites/{siteId}/views/{viewId}/pdf\` \u2014 \u30D3\u30E5\u30FC\u3092 PDF \u3067\u53D6\u5F97
|
|
28626
|
+
- GET \`/sites/{siteId}/datasources\` \u2014 \u516C\u958B\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9\u4E00\u89A7
|
|
28627
|
+
- GET \`/sites/{siteId}/users\` \u2014 \u30E6\u30FC\u30B6\u30FC\u4E00\u89A7
|
|
28628
|
+
- GET \`/sites/{siteId}/groups\` \u2014 \u30B0\u30EB\u30FC\u30D7\u4E00\u89A7
|
|
28629
|
+
|
|
28630
|
+
#### \u30D5\u30A3\u30EB\u30BF\u69CB\u6587
|
|
28631
|
+
- \`filter=name:eq:Sales\` \u2014 \u5B8C\u5168\u4E00\u81F4
|
|
28632
|
+
- \`filter=name:in:[Sales,Marketing]\` \u2014 \u96C6\u5408\u306B\u542B\u307E\u308C\u308B
|
|
28633
|
+
- \`filter=updatedAt:gte:2024-01-01T00:00:00Z\` \u2014 \u6BD4\u8F03\u6F14\u7B97\u5B50 (gt/gte/lt/lte)
|
|
28634
|
+
- \u7D44\u307F\u5408\u308F\u305B: \`filter=ownerName:eq:alice,tags:in:[finance]\``
|
|
28635
|
+
},
|
|
28636
|
+
tools: tools82,
|
|
28637
|
+
async checkConnection(params) {
|
|
28638
|
+
const serverUrl = params[parameters82.serverUrl.slug];
|
|
28639
|
+
const siteContentUrl = params[parameters82.siteContentUrl.slug];
|
|
28640
|
+
const patName = params[parameters82.patName.slug];
|
|
28641
|
+
const patSecret = params[parameters82.patSecret.slug];
|
|
28642
|
+
const apiVersion = params[parameters82.apiVersion.slug] || "3.28";
|
|
28643
|
+
if (!serverUrl || siteContentUrl == null || !patName || !patSecret) {
|
|
28644
|
+
return {
|
|
28645
|
+
success: false,
|
|
28646
|
+
error: "Missing required parameters: server-url, site-content-url, pat-name, pat-secret"
|
|
28647
|
+
};
|
|
28648
|
+
}
|
|
28649
|
+
try {
|
|
28650
|
+
const res = await fetch(
|
|
28651
|
+
`${serverUrl.replace(/\/$/, "")}/api/${apiVersion}/auth/signin`,
|
|
28652
|
+
{
|
|
28653
|
+
method: "POST",
|
|
28654
|
+
headers: {
|
|
28655
|
+
"Content-Type": "application/json",
|
|
28656
|
+
Accept: "application/json"
|
|
28657
|
+
},
|
|
28658
|
+
body: JSON.stringify({
|
|
28659
|
+
credentials: {
|
|
28660
|
+
personalAccessTokenName: patName,
|
|
28661
|
+
personalAccessTokenSecret: patSecret,
|
|
28662
|
+
site: { contentUrl: siteContentUrl }
|
|
28663
|
+
}
|
|
28664
|
+
})
|
|
28665
|
+
}
|
|
28666
|
+
);
|
|
28667
|
+
if (!res.ok) {
|
|
28668
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
28669
|
+
return {
|
|
28670
|
+
success: false,
|
|
28671
|
+
error: `Tableau sign-in failed: HTTP ${res.status} ${errorText}`
|
|
28672
|
+
};
|
|
28673
|
+
}
|
|
28674
|
+
return { success: true };
|
|
28675
|
+
} catch (error) {
|
|
28676
|
+
return {
|
|
28677
|
+
success: false,
|
|
28678
|
+
error: error instanceof Error ? error.message : String(error)
|
|
28679
|
+
};
|
|
28680
|
+
}
|
|
28681
|
+
}
|
|
28682
|
+
});
|
|
28683
|
+
|
|
28684
|
+
// ../connectors/src/connectors/outlook-oauth/tools/request.ts
|
|
28685
|
+
import { z as z100 } from "zod";
|
|
28686
|
+
var BASE_HOST14 = "https://graph.microsoft.com";
|
|
28687
|
+
var BASE_PATH_SEGMENT17 = "/v1.0";
|
|
28688
|
+
var BASE_URL43 = `${BASE_HOST14}${BASE_PATH_SEGMENT17}`;
|
|
28689
|
+
var REQUEST_TIMEOUT_MS77 = 6e4;
|
|
28690
|
+
var cachedToken33 = null;
|
|
28691
|
+
async function getProxyToken33(config) {
|
|
28692
|
+
if (cachedToken33 && cachedToken33.expiresAt > Date.now() + 6e4) {
|
|
28693
|
+
return cachedToken33.token;
|
|
28694
|
+
}
|
|
28695
|
+
const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
|
|
28696
|
+
const res = await fetch(url, {
|
|
28697
|
+
method: "POST",
|
|
28698
|
+
headers: {
|
|
28699
|
+
"Content-Type": "application/json",
|
|
28700
|
+
"x-api-key": config.appApiKey,
|
|
28701
|
+
"project-id": config.projectId
|
|
28702
|
+
},
|
|
28703
|
+
body: JSON.stringify({
|
|
28704
|
+
sandboxId: config.sandboxId,
|
|
28705
|
+
issuedBy: "coding-agent"
|
|
28706
|
+
})
|
|
28707
|
+
});
|
|
28708
|
+
if (!res.ok) {
|
|
28709
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
28710
|
+
throw new Error(
|
|
28711
|
+
`Failed to get proxy token: HTTP ${res.status} ${errorText}`
|
|
28712
|
+
);
|
|
28713
|
+
}
|
|
28714
|
+
const data = await res.json();
|
|
28715
|
+
cachedToken33 = {
|
|
28716
|
+
token: data.token,
|
|
28717
|
+
expiresAt: new Date(data.expiresAt).getTime()
|
|
28718
|
+
};
|
|
28719
|
+
return data.token;
|
|
28720
|
+
}
|
|
28721
|
+
var inputSchema100 = z100.object({
|
|
28722
|
+
toolUseIntent: z100.string().optional().describe(
|
|
28723
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
28724
|
+
),
|
|
28725
|
+
connectionId: z100.string().describe("ID of the Outlook OAuth connection to use"),
|
|
28726
|
+
method: z100.enum(["GET"]).describe("HTTP method (read-only, GET only)"),
|
|
28727
|
+
path: z100.string().describe(
|
|
28728
|
+
"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."
|
|
28729
|
+
),
|
|
28730
|
+
queryParams: z100.record(z100.string(), z100.string()).optional().describe(
|
|
28731
|
+
`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.`
|
|
28732
|
+
)
|
|
28733
|
+
});
|
|
28734
|
+
var outputSchema100 = z100.discriminatedUnion("success", [
|
|
28735
|
+
z100.object({
|
|
28736
|
+
success: z100.literal(true),
|
|
28737
|
+
status: z100.number(),
|
|
28738
|
+
data: z100.record(z100.string(), z100.unknown())
|
|
28739
|
+
}),
|
|
28740
|
+
z100.object({
|
|
28741
|
+
success: z100.literal(false),
|
|
28742
|
+
error: z100.string()
|
|
28743
|
+
})
|
|
28744
|
+
]);
|
|
28745
|
+
var requestTool59 = new ConnectorTool({
|
|
28746
|
+
name: "request",
|
|
28747
|
+
description: `Send authenticated GET requests to Microsoft Graph for Outlook Mail and Calendar.
|
|
28748
|
+
Authentication is handled automatically via OAuth proxy (Microsoft Entra ID).
|
|
28749
|
+
All paths are relative to https://graph.microsoft.com/v1.0. Use '/me' as the user prefix.
|
|
28750
|
+
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).
|
|
28751
|
+
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\`).`,
|
|
28752
|
+
inputSchema: inputSchema100,
|
|
28753
|
+
outputSchema: outputSchema100,
|
|
28754
|
+
async execute({ connectionId, method, path: path4, queryParams }, connections, config) {
|
|
28755
|
+
const connection = connections.find((c) => c.id === connectionId);
|
|
28756
|
+
if (!connection) {
|
|
28757
|
+
return {
|
|
28758
|
+
success: false,
|
|
28759
|
+
error: `Connection ${connectionId} not found`
|
|
28760
|
+
};
|
|
28761
|
+
}
|
|
28762
|
+
console.log(
|
|
28763
|
+
`[connector-request] outlook-oauth/${connection.name}: ${method} ${path4}`
|
|
28764
|
+
);
|
|
28765
|
+
try {
|
|
28766
|
+
const normalizedPath = normalizeRequestPath(path4, BASE_PATH_SEGMENT17);
|
|
28767
|
+
let url = `${BASE_URL43}${normalizedPath}`;
|
|
28768
|
+
if (queryParams) {
|
|
28769
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
28770
|
+
url += `?${searchParams.toString()}`;
|
|
28771
|
+
}
|
|
28772
|
+
const token = await getProxyToken33(config.oauthProxy);
|
|
28773
|
+
const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
28774
|
+
const controller = new AbortController();
|
|
28775
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS77);
|
|
28776
|
+
try {
|
|
28777
|
+
const response = await fetch(proxyUrl, {
|
|
28778
|
+
method: "POST",
|
|
28779
|
+
headers: {
|
|
28780
|
+
"Content-Type": "application/json",
|
|
28781
|
+
Authorization: `Bearer ${token}`
|
|
28782
|
+
},
|
|
28783
|
+
body: JSON.stringify({
|
|
28784
|
+
url,
|
|
28785
|
+
method
|
|
28786
|
+
}),
|
|
28787
|
+
signal: controller.signal
|
|
28788
|
+
});
|
|
28789
|
+
const data = await response.json();
|
|
28790
|
+
if (!response.ok) {
|
|
28791
|
+
const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
|
|
28792
|
+
return { success: false, error: errorMessage };
|
|
28793
|
+
}
|
|
28794
|
+
return { success: true, status: response.status, data };
|
|
28795
|
+
} finally {
|
|
28796
|
+
clearTimeout(timeout);
|
|
28797
|
+
}
|
|
28798
|
+
} catch (err) {
|
|
28799
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
28800
|
+
return { success: false, error: msg };
|
|
28801
|
+
}
|
|
28802
|
+
}
|
|
28803
|
+
});
|
|
28804
|
+
|
|
28805
|
+
// ../connectors/src/connectors/outlook-oauth/setup.ts
|
|
28806
|
+
var requestToolName14 = `outlook-oauth_${requestTool59.name}`;
|
|
28807
|
+
var outlookOnboarding = new ConnectorOnboarding({
|
|
28808
|
+
connectionSetupInstructions: {
|
|
28809
|
+
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
|
|
28810
|
+
|
|
28811
|
+
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:
|
|
28812
|
+
- \`method\`: \`"GET"\`
|
|
28813
|
+
- \`path\`: \`"/me"\`
|
|
28814
|
+
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
|
|
28815
|
+
3. \`${requestToolName14}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
|
|
28816
|
+
- \`method\`: \`"GET"\`
|
|
28817
|
+
- \`path\`: \`"/me/mailFolders"\`
|
|
28818
|
+
|
|
28819
|
+
#### \u5236\u7D04
|
|
28820
|
+
- **\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
|
|
28821
|
+
- \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
|
|
28822
|
+
en: `Follow these steps to set up the Outlook connection.
|
|
28823
|
+
|
|
28824
|
+
1. Call \`${requestToolName14}\` to get the authenticated user's profile:
|
|
28825
|
+
- \`method\`: \`"GET"\`
|
|
28826
|
+
- \`path\`: \`"/me"\`
|
|
28827
|
+
2. If an error is returned, ask the user to verify that OAuth authentication completed correctly
|
|
28828
|
+
3. Call \`${requestToolName14}\` to get the mail folder list:
|
|
28829
|
+
- \`method\`: \`"GET"\`
|
|
28830
|
+
- \`path\`: \`"/me/mailFolders"\`
|
|
28831
|
+
|
|
28832
|
+
#### Constraints
|
|
28833
|
+
- **Do NOT read message bodies during setup**. Only the profile and mail-folder requests specified above are allowed
|
|
28834
|
+
- Write only 1 sentence between tool calls, then immediately call the next tool`
|
|
28835
|
+
},
|
|
28836
|
+
dataOverviewInstructions: {
|
|
28837
|
+
en: `Mail
|
|
28838
|
+
1. Call outlook-oauth_request with GET /me/mailFolders to list mail folders
|
|
28839
|
+
2. Call outlook-oauth_request with GET /me/messages?$top=5&$select=id,subject,from,receivedDateTime,conversationId to sample recent messages
|
|
28840
|
+
3. Call outlook-oauth_request with GET /me/messages/{id} for an interesting message to inspect the full payload
|
|
28841
|
+
4. Call outlook-oauth_request with GET /me/mailFolders/{folderId}/messages?$top=5 to drill into a specific folder
|
|
28842
|
+
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
|
|
28843
|
+
|
|
28844
|
+
Calendar
|
|
28845
|
+
6. Call outlook-oauth_request with GET /me/calendars to list calendars (default + shared)
|
|
28846
|
+
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)
|
|
28847
|
+
8. Call outlook-oauth_request with GET /me/events/{eventId} for an interesting event to inspect attendees, body, and location`,
|
|
28848
|
+
ja: `\u30E1\u30FC\u30EB
|
|
28849
|
+
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
|
|
28850
|
+
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
|
|
28851
|
+
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
|
|
28852
|
+
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
|
|
28853
|
+
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
|
|
28854
|
+
|
|
28855
|
+
\u30AB\u30EC\u30F3\u30C0\u30FC
|
|
28856
|
+
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
|
|
28857
|
+
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)
|
|
28858
|
+
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`
|
|
28859
|
+
}
|
|
28860
|
+
});
|
|
28861
|
+
|
|
28862
|
+
// ../connectors/src/connectors/outlook-oauth/parameters.ts
|
|
28863
|
+
var parameters83 = {};
|
|
28864
|
+
|
|
28865
|
+
// ../connectors/src/connectors/outlook-oauth/index.ts
|
|
28866
|
+
var tools83 = { request: requestTool59 };
|
|
28867
|
+
var outlookOauthConnector = new ConnectorPlugin({
|
|
28868
|
+
slug: "outlook",
|
|
28869
|
+
authType: AUTH_TYPES.OAUTH,
|
|
28870
|
+
name: "Outlook",
|
|
28871
|
+
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.",
|
|
28872
|
+
iconUrl: "https://upload.wikimedia.org/wikipedia/commons/d/df/Microsoft_Office_Outlook_%282018%E2%80%93present%29.svg",
|
|
28873
|
+
parameters: parameters83,
|
|
28874
|
+
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
28875
|
+
categories: ["productivity"],
|
|
28876
|
+
onboarding: outlookOnboarding,
|
|
28877
|
+
proxyPolicy: {
|
|
28878
|
+
allowlist: [
|
|
28879
|
+
{
|
|
28880
|
+
host: "graph.microsoft.com",
|
|
28881
|
+
methods: ["GET"]
|
|
28882
|
+
}
|
|
28883
|
+
]
|
|
28884
|
+
},
|
|
28885
|
+
systemPrompt: {
|
|
28886
|
+
en: `### Tools
|
|
28887
|
+
|
|
28888
|
+
- \`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.
|
|
28889
|
+
|
|
28890
|
+
### Microsoft Graph Reference (Outlook Mail)
|
|
28891
|
+
|
|
28892
|
+
#### Available Endpoints
|
|
28893
|
+
- GET \`/me\` \u2014 Get the signed-in user's profile (displayName, mail, userPrincipalName)
|
|
28894
|
+
- GET \`/me/mailFolders\` \u2014 List the user's mail folders (Inbox, SentItems, Drafts, etc.)
|
|
28895
|
+
- GET \`/me/mailFolders/{folderId}\` \u2014 Get a specific mail folder
|
|
28896
|
+
- GET \`/me/mailFolders/{folderId}/messages\` \u2014 List messages within a folder
|
|
28897
|
+
- GET \`/me/messages\` \u2014 List messages across all folders
|
|
28898
|
+
- GET \`/me/messages/{id}\` \u2014 Get a specific message with full body
|
|
28899
|
+
- GET \`/me/messages/{id}/attachments\` \u2014 List attachments on a message
|
|
28900
|
+
- GET \`/me/messages/{id}/attachments/{attachmentId}\` \u2014 Get a specific attachment
|
|
28901
|
+
|
|
28902
|
+
#### Well-Known Folder Names (usable in place of {folderId})
|
|
28903
|
+
- \`inbox\`, \`sentitems\`, \`drafts\`, \`deleteditems\`, \`junkemail\`, \`outbox\`, \`archive\`
|
|
28904
|
+
|
|
28905
|
+
#### Conversations (Threads)
|
|
28906
|
+
- 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).
|
|
28907
|
+
|
|
28908
|
+
### Microsoft Graph Reference (Outlook Calendar)
|
|
28909
|
+
|
|
28910
|
+
#### Available Endpoints
|
|
28911
|
+
- GET \`/me/calendars\` \u2014 List the user's calendars (default + any shared/group calendars)
|
|
28912
|
+
- GET \`/me/calendars/{calendarId}\` \u2014 Get a calendar's metadata
|
|
28913
|
+
- GET \`/me/events\` \u2014 List events on the default calendar (recurring events are returned as series masters \u2014 use \`/me/calendarView\` to expand)
|
|
28914
|
+
- GET \`/me/calendars/{calendarId}/events\` \u2014 List events on a specific calendar
|
|
28915
|
+
- GET \`/me/events/{eventId}\` \u2014 Get a single event
|
|
28916
|
+
- GET \`/me/calendarView?startDateTime=&endDateTime=\` \u2014 List event **occurrences** in a date range (expands recurring events). Equivalent to Google Calendar's \`events?singleEvents=true\`
|
|
28917
|
+
- GET \`/me/calendars/{calendarId}/calendarView?startDateTime=&endDateTime=\` \u2014 Same, scoped to a specific calendar
|
|
28918
|
+
|
|
28919
|
+
#### Calendar Tips
|
|
28920
|
+
- Use \`/me/calendarView\` when you want individual occurrences of recurring events; \`/me/events\` is closer to the raw stored series
|
|
28921
|
+
- \`startDateTime\` / \`endDateTime\` must be ISO-8601 UTC, e.g. \`2025-01-15T00:00:00Z\`
|
|
28922
|
+
- Combine with \`$select=subject,start,end,attendees,location\` and \`$orderby=start/dateTime\` to keep responses small and sorted
|
|
28923
|
+
|
|
28924
|
+
#### Key Query Parameters (OData, shared by Mail + Calendar)
|
|
28925
|
+
- \`$top\` \u2014 Maximum number of results (default 10, max 1000)
|
|
28926
|
+
- \`$skip\` \u2014 Skip the first N results (for paging)
|
|
28927
|
+
- \`$select\` \u2014 Comma-separated list of properties (e.g. \`subject,from,receivedDateTime,bodyPreview\`)
|
|
28928
|
+
- \`$orderby\` \u2014 Sort (e.g. \`receivedDateTime desc\`, \`start/dateTime asc\`)
|
|
28929
|
+
- \`$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'\`)
|
|
28930
|
+
- \`$search\` \u2014 Full-text search; must be wrapped in double quotes (e.g. \`$search="project status"\`). \`$search\` and \`$filter\` cannot be combined
|
|
28931
|
+
- \`$expand\` \u2014 Expand related resources (e.g. \`attachments\`, \`instances\` for recurring events)
|
|
28932
|
+
- \`$count=true\` \u2014 Return total count (requires \`ConsistencyLevel: eventual\` header on some endpoints)
|
|
28933
|
+
|
|
28934
|
+
#### Pagination
|
|
28935
|
+
- Responses include \`@odata.nextLink\` when more results exist; call that URL (or its path) to get the next page
|
|
28936
|
+
|
|
28937
|
+
#### Tips
|
|
28938
|
+
- Use \`/me\` for the signed-in user \u2014 never substitute another user ID
|
|
28939
|
+
- Prefer \`$select\` to avoid huge payloads; the full message body can be MB-sized when HTML
|
|
28940
|
+
- \`bodyPreview\` (first ~255 chars) is included by default and is cheap for triage
|
|
28941
|
+
- Date/time values are ISO-8601; calendar event times also include a \`timeZone\` field
|
|
28942
|
+
|
|
28943
|
+
### Business Logic
|
|
28944
|
+
|
|
28945
|
+
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.
|
|
28946
|
+
|
|
28947
|
+
SDK surface (client created via \`connection(connectionId)\`):
|
|
28948
|
+
|
|
28949
|
+
Mail:
|
|
28950
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path appended to \`https://graph.microsoft.com/v1.0\`)
|
|
28951
|
+
- \`client.getProfile()\` \u2014 fetch the authenticated user's profile
|
|
28952
|
+
- \`client.listMailFolders()\` \u2014 list all mail folders
|
|
28953
|
+
- \`client.listMessages(options?)\` \u2014 list messages with optional \`top\`, \`skip\`, \`filter\`, \`orderBy\`, \`select\`, \`search\`
|
|
28954
|
+
- \`client.listMessagesInFolder(folderId, options?)\` \u2014 list messages in a folder (well-known names like \`inbox\` work)
|
|
28955
|
+
- \`client.getMessage(id, options?)\` \u2014 fetch a specific message
|
|
28956
|
+
- \`client.listConversation(conversationId, options?)\` \u2014 fetch every message in a thread (Gmail-style \`getThread\` equivalent; orders oldest-first by default)
|
|
28957
|
+
|
|
28958
|
+
Attachments:
|
|
28959
|
+
- \`client.listAttachments(messageId)\` \u2014 list attachments on a message
|
|
28960
|
+
- \`client.getAttachment(messageId, attachmentId)\` \u2014 fetch a single attachment (file attachments include base64 \`contentBytes\`)
|
|
28961
|
+
|
|
28962
|
+
Calendar:
|
|
28963
|
+
- \`client.listCalendars()\` \u2014 list calendars accessible to the user
|
|
28964
|
+
- \`client.listEvents(options?)\` \u2014 list events on the default calendar (or pass \`{ calendarId }\` for a specific one). Recurring events are returned as series masters
|
|
28965
|
+
- \`client.getEvent(id)\` \u2014 fetch a single event
|
|
28966
|
+
- \`client.listCalendarView(startDateTime, endDateTime, options?)\` \u2014 list event **occurrences** in a date range (recurring events expanded). Equivalent to Google Calendar's \`events?singleEvents=true\`
|
|
28967
|
+
|
|
28968
|
+
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.
|
|
28969
|
+
|
|
28970
|
+
#### Example
|
|
28971
|
+
|
|
28972
|
+
\`\`\`ts
|
|
28973
|
+
import { connection } from "@squadbase/vite-server/connectors/outlook-oauth";
|
|
28974
|
+
|
|
28975
|
+
const outlook = connection("<connectionId>");
|
|
28976
|
+
|
|
28977
|
+
// Get user profile
|
|
28978
|
+
const profile = await outlook.getProfile();
|
|
28979
|
+
console.log(profile.displayName, profile.mail);
|
|
28980
|
+
|
|
28981
|
+
// List recent unread messages in Inbox
|
|
28982
|
+
const messages = await outlook.listMessagesInFolder("inbox", {
|
|
28983
|
+
top: 10,
|
|
28984
|
+
filter: "isRead eq false",
|
|
28985
|
+
orderBy: "receivedDateTime desc",
|
|
28986
|
+
select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],
|
|
28987
|
+
});
|
|
28988
|
+
for (const msg of messages.value) {
|
|
28989
|
+
console.log(msg.receivedDateTime, msg.from?.emailAddress.address, msg.subject);
|
|
28990
|
+
}
|
|
28991
|
+
|
|
28992
|
+
// Pull a whole conversation
|
|
28993
|
+
const first = messages.value[0];
|
|
28994
|
+
if (first?.conversationId) {
|
|
28995
|
+
const thread = await outlook.listConversation(first.conversationId);
|
|
28996
|
+
thread.value.forEach(m => console.log(m.receivedDateTime, m.bodyPreview));
|
|
28997
|
+
}
|
|
28998
|
+
|
|
28999
|
+
// Fetch attachments on a message that has them
|
|
29000
|
+
if (first?.hasAttachments) {
|
|
29001
|
+
const atts = await outlook.listAttachments(first.id);
|
|
29002
|
+
for (const a of atts.value) {
|
|
29003
|
+
const full = await outlook.getAttachment(first.id, a.id);
|
|
29004
|
+
console.log(full.name, full.contentType, full.size);
|
|
29005
|
+
// full.contentBytes is base64 for file attachments
|
|
29006
|
+
}
|
|
29007
|
+
}
|
|
29008
|
+
|
|
29009
|
+
// List today's calendar events (expanded occurrences)
|
|
29010
|
+
const todayStart = new Date(); todayStart.setHours(0, 0, 0, 0);
|
|
29011
|
+
const todayEnd = new Date(todayStart); todayEnd.setDate(todayEnd.getDate() + 1);
|
|
29012
|
+
const events = await outlook.listCalendarView(
|
|
29013
|
+
todayStart.toISOString(),
|
|
29014
|
+
todayEnd.toISOString(),
|
|
29015
|
+
{ orderBy: "start/dateTime", select: ["id", "subject", "start", "end", "attendees"] },
|
|
29016
|
+
);
|
|
29017
|
+
events.value.forEach(e => console.log(e.start.dateTime, e.subject));
|
|
29018
|
+
\`\`\``,
|
|
29019
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
29020
|
+
|
|
29021
|
+
- \`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
|
|
29022
|
+
|
|
29023
|
+
### Microsoft Graph \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9 (Outlook \u30E1\u30FC\u30EB)
|
|
29024
|
+
|
|
29025
|
+
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
29026
|
+
- GET \`/me\` \u2014 \u30B5\u30A4\u30F3\u30A4\u30F3\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB (displayName, mail, userPrincipalName)
|
|
29027
|
+
- GET \`/me/mailFolders\` \u2014 \u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7 (Inbox, SentItems, Drafts \u306A\u3069)
|
|
29028
|
+
- GET \`/me/mailFolders/{folderId}\` \u2014 \u7279\u5B9A\u30D5\u30A9\u30EB\u30C0\u306E\u53D6\u5F97
|
|
29029
|
+
- GET \`/me/mailFolders/{folderId}/messages\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7
|
|
29030
|
+
- GET \`/me/messages\` \u2014 \u5168\u30D5\u30A9\u30EB\u30C0\u6A2A\u65AD\u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7
|
|
29031
|
+
- GET \`/me/messages/{id}\` \u2014 \u7279\u5B9A\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u672C\u6587\u8FBC\u307F\u3067\u53D6\u5F97
|
|
29032
|
+
- GET \`/me/messages/{id}/attachments\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7
|
|
29033
|
+
- GET \`/me/messages/{id}/attachments/{attachmentId}\` \u2014 \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u5358\u4F53\u53D6\u5F97
|
|
29034
|
+
|
|
29035
|
+
#### Well-Known \u30D5\u30A9\u30EB\u30C0\u540D ({folderId} \u306E\u4EE3\u308F\u308A\u306B\u4F7F\u7528\u53EF\u80FD)
|
|
29036
|
+
- \`inbox\`, \`sentitems\`, \`drafts\`, \`deleteditems\`, \`junkemail\`, \`outbox\`, \`archive\`
|
|
29037
|
+
|
|
29038
|
+
#### \u4F1A\u8A71 (\u30B9\u30EC\u30C3\u30C9)
|
|
29039
|
+
- \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
|
|
29040
|
+
|
|
29041
|
+
### Microsoft Graph \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9 (Outlook \u30AB\u30EC\u30F3\u30C0\u30FC)
|
|
29042
|
+
|
|
29043
|
+
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
29044
|
+
- 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)
|
|
29045
|
+
- GET \`/me/calendars/{calendarId}\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u5358\u4F53\u53D6\u5F97
|
|
29046
|
+
- 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
|
|
29047
|
+
- GET \`/me/calendars/{calendarId}/events\` \u2014 \u7279\u5B9A\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7
|
|
29048
|
+
- GET \`/me/events/{eventId}\` \u2014 \u30A4\u30D9\u30F3\u30C8\u5358\u4F53\u53D6\u5F97
|
|
29049
|
+
- 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
|
|
29050
|
+
- GET \`/me/calendars/{calendarId}/calendarView?startDateTime=&endDateTime=\` \u2014 \u540C\u4E0A\u3001\u7279\u5B9A\u30AB\u30EC\u30F3\u30C0\u30FC\u7248
|
|
29051
|
+
|
|
29052
|
+
#### \u30AB\u30EC\u30F3\u30C0\u30FC Tips
|
|
29053
|
+
- \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\`
|
|
29054
|
+
- \`startDateTime\` / \`endDateTime\` \u306F ISO-8601 UTC\u3001\u4F8B \`2025-01-15T00:00:00Z\`
|
|
29055
|
+
- \`$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
|
|
29056
|
+
|
|
29057
|
+
#### \u4E3B\u8981\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF (OData; Mail \u3068 Calendar \u3067\u5171\u901A)
|
|
29058
|
+
- \`$top\` \u2014 \u6700\u5927\u7D50\u679C\u6570 (\u30C7\u30D5\u30A9\u30EB\u30C8 10\u3001\u6700\u5927 1000)
|
|
29059
|
+
- \`$skip\` \u2014 \u5148\u982D N \u4EF6\u3092\u30B9\u30AD\u30C3\u30D7 (\u30DA\u30FC\u30B8\u30F3\u30B0)
|
|
29060
|
+
- \`$select\` \u2014 \u53D6\u5F97\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u30AB\u30F3\u30DE\u533A\u5207\u308A (\u4F8B \`subject,from,receivedDateTime,bodyPreview\`)
|
|
29061
|
+
- \`$orderby\` \u2014 \u30BD\u30FC\u30C8 (\u4F8B \`receivedDateTime desc\`\u3001\`start/dateTime asc\`)
|
|
29062
|
+
- \`$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'\`)
|
|
29063
|
+
- \`$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
|
|
29064
|
+
- \`$expand\` \u2014 \u95A2\u9023\u30EA\u30BD\u30FC\u30B9\u3092\u5C55\u958B (\u4F8B \`attachments\`\u3001\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u306E \`instances\`)
|
|
29065
|
+
- \`$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)
|
|
29066
|
+
|
|
29067
|
+
#### \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3
|
|
29068
|
+
- \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
|
|
29069
|
+
|
|
29070
|
+
#### Tips
|
|
29071
|
+
- \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
|
|
29072
|
+
- \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
|
|
29073
|
+
- \`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
|
|
29074
|
+
- \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
|
|
29075
|
+
|
|
29076
|
+
### Business Logic
|
|
29077
|
+
|
|
29078
|
+
\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
|
|
29079
|
+
|
|
29080
|
+
SDK (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
29081
|
+
|
|
29082
|
+
\u30E1\u30FC\u30EB:
|
|
29083
|
+
- \`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)
|
|
29084
|
+
- \`client.getProfile()\` \u2014 \u8A8D\u8A3C\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97
|
|
29085
|
+
- \`client.listMailFolders()\` \u2014 \u5168\u30E1\u30FC\u30EB\u30D5\u30A9\u30EB\u30C0\u3092\u4E00\u89A7
|
|
29086
|
+
- \`client.listMessages(options?)\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7 (\`top\`, \`skip\`, \`filter\`, \`orderBy\`, \`select\`, \`search\` \u5BFE\u5FDC)
|
|
29087
|
+
- \`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)
|
|
29088
|
+
- \`client.getMessage(id, options?)\` \u2014 \u7279\u5B9A\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97
|
|
29089
|
+
- \`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)
|
|
29090
|
+
|
|
29091
|
+
\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB:
|
|
29092
|
+
- \`client.listAttachments(messageId)\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u306E\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u4E00\u89A7
|
|
29093
|
+
- \`client.getAttachment(messageId, attachmentId)\` \u2014 \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u5358\u4F53\u53D6\u5F97 (file attachment \u306F base64 \u306E \`contentBytes\` \u3092\u542B\u3080)
|
|
29094
|
+
|
|
29095
|
+
\u30AB\u30EC\u30F3\u30C0\u30FC:
|
|
29096
|
+
- \`client.listCalendars()\` \u2014 \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7
|
|
29097
|
+
- \`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
|
|
29098
|
+
- \`client.getEvent(id)\` \u2014 \u30A4\u30D9\u30F3\u30C8\u5358\u4F53\u53D6\u5F97
|
|
29099
|
+
- \`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
|
|
29100
|
+
|
|
29101
|
+
\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
|
|
29102
|
+
|
|
29103
|
+
#### Example
|
|
29104
|
+
|
|
29105
|
+
\`\`\`ts
|
|
29106
|
+
import { connection } from "@squadbase/vite-server/connectors/outlook-oauth";
|
|
29107
|
+
|
|
29108
|
+
const outlook = connection("<connectionId>");
|
|
29109
|
+
|
|
29110
|
+
// \u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u53D6\u5F97
|
|
29111
|
+
const profile = await outlook.getProfile();
|
|
29112
|
+
console.log(profile.displayName, profile.mail);
|
|
29113
|
+
|
|
29114
|
+
// \u53D7\u4FE1\u30C8\u30EC\u30A4\u306E\u672A\u8AAD\u30E1\u30C3\u30BB\u30FC\u30B8\u6700\u65B010\u4EF6
|
|
29115
|
+
const messages = await outlook.listMessagesInFolder("inbox", {
|
|
29116
|
+
top: 10,
|
|
29117
|
+
filter: "isRead eq false",
|
|
29118
|
+
orderBy: "receivedDateTime desc",
|
|
29119
|
+
select: ["id", "subject", "from", "receivedDateTime", "bodyPreview", "conversationId"],
|
|
29120
|
+
});
|
|
29121
|
+
for (const msg of messages.value) {
|
|
29122
|
+
console.log(msg.receivedDateTime, msg.from?.emailAddress.address, msg.subject);
|
|
29123
|
+
}
|
|
29124
|
+
|
|
29125
|
+
// \u30B9\u30EC\u30C3\u30C9\u5168\u4F53\u3092\u53D6\u5F97
|
|
29126
|
+
const first = messages.value[0];
|
|
29127
|
+
if (first?.conversationId) {
|
|
29128
|
+
const thread = await outlook.listConversation(first.conversationId);
|
|
29129
|
+
thread.value.forEach(m => console.log(m.receivedDateTime, m.bodyPreview));
|
|
29130
|
+
}
|
|
29131
|
+
|
|
29132
|
+
// \u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB\u3092\u53D6\u5F97
|
|
29133
|
+
if (first?.hasAttachments) {
|
|
29134
|
+
const atts = await outlook.listAttachments(first.id);
|
|
29135
|
+
for (const a of atts.value) {
|
|
29136
|
+
const full = await outlook.getAttachment(first.id, a.id);
|
|
29137
|
+
console.log(full.name, full.contentType, full.size);
|
|
29138
|
+
// full.contentBytes \u306F file attachment \u306E\u5834\u5408 base64
|
|
29139
|
+
}
|
|
29140
|
+
}
|
|
29141
|
+
|
|
29142
|
+
// \u4ECA\u65E5\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u30A4\u30D9\u30F3\u30C8 (occurrence \u5C55\u958B)
|
|
29143
|
+
const todayStart = new Date(); todayStart.setHours(0, 0, 0, 0);
|
|
29144
|
+
const todayEnd = new Date(todayStart); todayEnd.setDate(todayEnd.getDate() + 1);
|
|
29145
|
+
const events = await outlook.listCalendarView(
|
|
29146
|
+
todayStart.toISOString(),
|
|
29147
|
+
todayEnd.toISOString(),
|
|
29148
|
+
{ orderBy: "start/dateTime", select: ["id", "subject", "start", "end", "attendees"] },
|
|
29149
|
+
);
|
|
29150
|
+
events.value.forEach(e => console.log(e.start.dateTime, e.subject));
|
|
29151
|
+
\`\`\``
|
|
29152
|
+
},
|
|
29153
|
+
tools: tools83,
|
|
29154
|
+
async checkConnection(_params, config) {
|
|
29155
|
+
const { proxyFetch } = config;
|
|
29156
|
+
const url = "https://graph.microsoft.com/v1.0/me";
|
|
29157
|
+
try {
|
|
29158
|
+
const res = await proxyFetch(url, { method: "GET" });
|
|
29159
|
+
if (!res.ok) {
|
|
29160
|
+
const errorText = await res.text().catch(() => res.statusText);
|
|
29161
|
+
return {
|
|
29162
|
+
success: false,
|
|
29163
|
+
error: `Microsoft Graph failed: HTTP ${res.status} ${errorText}`
|
|
29164
|
+
};
|
|
29165
|
+
}
|
|
29166
|
+
return { success: true };
|
|
29167
|
+
} catch (error) {
|
|
29168
|
+
return {
|
|
29169
|
+
success: false,
|
|
29170
|
+
error: error instanceof Error ? error.message : String(error)
|
|
29171
|
+
};
|
|
29172
|
+
}
|
|
29173
|
+
}
|
|
29174
|
+
});
|
|
29175
|
+
|
|
29176
|
+
// ../connectors/src/connectors/registry.ts
|
|
29177
|
+
var plugins = {
|
|
29178
|
+
snowflake: snowflakeConnector,
|
|
29179
|
+
snowflakePat: snowflakePatConnector,
|
|
29180
|
+
bigquery: bigqueryConnector,
|
|
29181
|
+
bigqueryOauth: bigqueryOauthConnector,
|
|
29182
|
+
databricks: databricksConnector,
|
|
29183
|
+
redshift: redshiftConnector,
|
|
29184
|
+
dbt: dbtConnector,
|
|
29185
|
+
awsAthena: awsAthenaConnector,
|
|
29186
|
+
awsBilling: awsBillingConnector,
|
|
29187
|
+
postgresql: postgresqlConnector,
|
|
29188
|
+
mysql: mysqlConnector,
|
|
29189
|
+
googleAds: googleAdsConnector,
|
|
29190
|
+
googleAnalytics: googleAnalyticsConnector,
|
|
29191
|
+
googleAnalyticsOauth: googleAnalyticsOauthConnector,
|
|
29192
|
+
googleCalendar: googleCalendarConnector,
|
|
29193
|
+
googleCalendarOauth: googleCalendarOauthConnector,
|
|
29194
|
+
googleDocs: googleDocsConnector,
|
|
29195
|
+
googleDrive: googleDriveConnector,
|
|
29196
|
+
googleSheets: googleSheetsConnector,
|
|
29197
|
+
googleSlides: googleSlidesConnector,
|
|
29198
|
+
hubspotOauth: hubspotOauthConnector,
|
|
29199
|
+
stripeOauth: stripeOauthConnector,
|
|
29200
|
+
stripeApiKey: stripeApiKeyConnector,
|
|
29201
|
+
airtable: airtableConnector,
|
|
29202
|
+
airtableOauth: airtableOauthConnector,
|
|
29203
|
+
squadbaseDb: squadbaseDbConnector,
|
|
29204
|
+
kintone: kintoneConnector,
|
|
29205
|
+
kintoneApiToken: kintoneApiTokenConnector,
|
|
29206
|
+
wixStore: wixStoreConnector,
|
|
29207
|
+
openai: openaiConnector,
|
|
29208
|
+
gemini: geminiConnector,
|
|
29209
|
+
anthropic: anthropicConnector,
|
|
29210
|
+
amplitude: amplitudeConnector,
|
|
29211
|
+
attio: attioConnector,
|
|
29212
|
+
shopify: shopifyConnector,
|
|
29213
|
+
shopifyOauth: shopifyOauthConnector,
|
|
29214
|
+
hubspot: hubspotConnector,
|
|
29215
|
+
jira: jiraConnector,
|
|
29216
|
+
linear: linearConnector,
|
|
29217
|
+
asana: asanaConnector,
|
|
29218
|
+
clickhouse: clickhouseConnector,
|
|
29219
|
+
mongodb: mongodbConnector,
|
|
29220
|
+
notion: notionConnector,
|
|
29221
|
+
notionOauth: notionOauthConnector,
|
|
29222
|
+
metaAds: metaAdsConnector,
|
|
29223
|
+
metaAdsOauth: metaAdsOauthConnector,
|
|
29224
|
+
tiktokAds: tiktokAdsConnector,
|
|
29225
|
+
mailchimp: mailchimpConnector,
|
|
29226
|
+
mailchimpOauth: mailchimpOauthConnector,
|
|
29227
|
+
customerio: customerioConnector,
|
|
29228
|
+
gmail: gmailConnector,
|
|
29229
|
+
gmailOauth: gmailOauthConnector,
|
|
29230
|
+
googleAuditLog: googleAuditLogConnector,
|
|
29231
|
+
linkedinAds: linkedinAdsConnector,
|
|
29232
|
+
zendesk: zendeskConnector,
|
|
29233
|
+
zendeskOauth: zendeskOauthConnector,
|
|
29234
|
+
intercom: intercomConnector,
|
|
29235
|
+
intercomOauth: intercomOauthConnector,
|
|
29236
|
+
mixpanel: mixpanelConnector,
|
|
29237
|
+
grafana: grafanaConnector,
|
|
29238
|
+
backlog: backlogConnector,
|
|
29239
|
+
gamma: gammaConnector,
|
|
29240
|
+
sentry: sentryConnector,
|
|
29241
|
+
salesforce: salesforceConnector,
|
|
29242
|
+
influxdb: influxdbConnector,
|
|
29243
|
+
monday: mondayConnector,
|
|
29244
|
+
jdbc: jdbcConnector,
|
|
29245
|
+
semrush: semrushConnector,
|
|
29246
|
+
googleSearchConsoleOauth: googleSearchConsoleOauthConnector,
|
|
29247
|
+
supabase: supabaseConnector,
|
|
29248
|
+
clickup: clickupConnector,
|
|
29249
|
+
sqlserver: sqlserverConnector,
|
|
29250
|
+
azureSql: azureSqlConnector,
|
|
29251
|
+
cosmosdb: cosmosdbConnector,
|
|
29252
|
+
oracle: oracleConnector,
|
|
29253
|
+
freshservice: freshserviceConnector,
|
|
29254
|
+
freshdesk: freshdeskConnector,
|
|
29255
|
+
freshsales: freshsalesConnector,
|
|
29256
|
+
github: githubConnector,
|
|
29257
|
+
powerbi: powerbiConnector,
|
|
29258
|
+
powerbiOauth: powerbiOauthConnector,
|
|
29259
|
+
tableau: tableauConnector,
|
|
29260
|
+
outlookOauth: outlookOauthConnector
|
|
29261
|
+
};
|
|
29262
|
+
var connectors = {
|
|
29263
|
+
...plugins,
|
|
29264
|
+
/**
|
|
29265
|
+
* Return plugins that have at least one matching connection.
|
|
29266
|
+
*/
|
|
29267
|
+
pluginsFor(connections) {
|
|
29268
|
+
const keys = new Set(
|
|
29269
|
+
connections.map(
|
|
29270
|
+
(c) => ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType)
|
|
29271
|
+
)
|
|
29272
|
+
);
|
|
29273
|
+
return Object.values(plugins).filter((p) => keys.has(p.connectorKey));
|
|
29274
|
+
},
|
|
29275
|
+
/**
|
|
29276
|
+
* Find a plugin by slug and authType.
|
|
29277
|
+
*/
|
|
29278
|
+
findByKey(slug, authType) {
|
|
29279
|
+
const key = ConnectorPlugin.deriveKey(slug, authType);
|
|
29280
|
+
return Object.values(plugins).find((p) => p.connectorKey === key);
|
|
29281
|
+
}
|
|
29282
|
+
};
|
|
29283
|
+
|
|
29284
|
+
// src/connector-client/env.ts
|
|
29285
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
29286
|
+
const envVarName = entry.envVars[key];
|
|
29287
|
+
if (!envVarName) {
|
|
29288
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
27590
29289
|
}
|
|
27591
29290
|
const value = process.env[envVarName];
|
|
27592
29291
|
if (!value) {
|
|
@@ -27769,62 +29468,62 @@ function resolveParams(entry, connectionId, plugin) {
|
|
|
27769
29468
|
var { getQuery, loadConnections, reloadEnvFile, watchConnectionsFile } = createConnectorRegistry();
|
|
27770
29469
|
|
|
27771
29470
|
// src/types/server-logic.ts
|
|
27772
|
-
import { z as
|
|
27773
|
-
var parameterMetaSchema =
|
|
27774
|
-
name:
|
|
27775
|
-
type:
|
|
27776
|
-
description:
|
|
27777
|
-
required:
|
|
27778
|
-
default:
|
|
27779
|
-
});
|
|
27780
|
-
var serverLogicCacheConfigSchema =
|
|
27781
|
-
ttl:
|
|
27782
|
-
staleWhileRevalidate:
|
|
27783
|
-
});
|
|
27784
|
-
var serverLogicSchemaObjectSchema =
|
|
27785
|
-
() =>
|
|
27786
|
-
type:
|
|
27787
|
-
format:
|
|
27788
|
-
description:
|
|
27789
|
-
nullable:
|
|
27790
|
-
enum:
|
|
29471
|
+
import { z as z101 } from "zod";
|
|
29472
|
+
var parameterMetaSchema = z101.object({
|
|
29473
|
+
name: z101.string(),
|
|
29474
|
+
type: z101.enum(["string", "number", "boolean"]),
|
|
29475
|
+
description: z101.string(),
|
|
29476
|
+
required: z101.boolean().optional(),
|
|
29477
|
+
default: z101.union([z101.string(), z101.number(), z101.boolean()]).optional()
|
|
29478
|
+
});
|
|
29479
|
+
var serverLogicCacheConfigSchema = z101.object({
|
|
29480
|
+
ttl: z101.number(),
|
|
29481
|
+
staleWhileRevalidate: z101.boolean().optional()
|
|
29482
|
+
});
|
|
29483
|
+
var serverLogicSchemaObjectSchema = z101.lazy(
|
|
29484
|
+
() => z101.object({
|
|
29485
|
+
type: z101.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
|
|
29486
|
+
format: z101.string().optional(),
|
|
29487
|
+
description: z101.string().optional(),
|
|
29488
|
+
nullable: z101.boolean().optional(),
|
|
29489
|
+
enum: z101.array(z101.union([z101.string(), z101.number(), z101.boolean(), z101.null()])).optional(),
|
|
27791
29490
|
items: serverLogicSchemaObjectSchema.optional(),
|
|
27792
|
-
properties:
|
|
27793
|
-
required:
|
|
27794
|
-
additionalProperties:
|
|
27795
|
-
minimum:
|
|
27796
|
-
maximum:
|
|
27797
|
-
minLength:
|
|
27798
|
-
maxLength:
|
|
27799
|
-
pattern:
|
|
29491
|
+
properties: z101.record(z101.string(), serverLogicSchemaObjectSchema).optional(),
|
|
29492
|
+
required: z101.array(z101.string()).optional(),
|
|
29493
|
+
additionalProperties: z101.union([z101.boolean(), serverLogicSchemaObjectSchema]).optional(),
|
|
29494
|
+
minimum: z101.number().optional(),
|
|
29495
|
+
maximum: z101.number().optional(),
|
|
29496
|
+
minLength: z101.number().optional(),
|
|
29497
|
+
maxLength: z101.number().optional(),
|
|
29498
|
+
pattern: z101.string().optional()
|
|
27800
29499
|
})
|
|
27801
29500
|
);
|
|
27802
|
-
var serverLogicMediaTypeSchema =
|
|
29501
|
+
var serverLogicMediaTypeSchema = z101.object({
|
|
27803
29502
|
schema: serverLogicSchemaObjectSchema.optional(),
|
|
27804
|
-
example:
|
|
29503
|
+
example: z101.unknown().optional()
|
|
27805
29504
|
});
|
|
27806
|
-
var serverLogicResponseSchema =
|
|
27807
|
-
description:
|
|
27808
|
-
content:
|
|
29505
|
+
var serverLogicResponseSchema = z101.object({
|
|
29506
|
+
description: z101.string().optional(),
|
|
29507
|
+
content: z101.record(z101.string(), serverLogicMediaTypeSchema).optional()
|
|
27809
29508
|
});
|
|
27810
29509
|
var jsonBaseFields = {
|
|
27811
|
-
description:
|
|
27812
|
-
parameters:
|
|
29510
|
+
description: z101.string(),
|
|
29511
|
+
parameters: z101.array(parameterMetaSchema).optional(),
|
|
27813
29512
|
response: serverLogicResponseSchema.optional(),
|
|
27814
29513
|
cache: serverLogicCacheConfigSchema.optional()
|
|
27815
29514
|
};
|
|
27816
|
-
var jsonSqlServerLogicSchema =
|
|
29515
|
+
var jsonSqlServerLogicSchema = z101.object({
|
|
27817
29516
|
...jsonBaseFields,
|
|
27818
|
-
type:
|
|
27819
|
-
query:
|
|
27820
|
-
connectionId:
|
|
29517
|
+
type: z101.literal("sql").optional(),
|
|
29518
|
+
query: z101.string(),
|
|
29519
|
+
connectionId: z101.string()
|
|
27821
29520
|
});
|
|
27822
|
-
var jsonTypeScriptServerLogicSchema =
|
|
29521
|
+
var jsonTypeScriptServerLogicSchema = z101.object({
|
|
27823
29522
|
...jsonBaseFields,
|
|
27824
|
-
type:
|
|
27825
|
-
handlerPath:
|
|
29523
|
+
type: z101.literal("typescript"),
|
|
29524
|
+
handlerPath: z101.string()
|
|
27826
29525
|
});
|
|
27827
|
-
var anyJsonServerLogicSchema =
|
|
29526
|
+
var anyJsonServerLogicSchema = z101.union([
|
|
27828
29527
|
jsonTypeScriptServerLogicSchema,
|
|
27829
29528
|
jsonSqlServerLogicSchema
|
|
27830
29529
|
]);
|