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