@squadbase/vite-server 0.1.11-dev.0c78963 → 0.1.12-dev.8860f37

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