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