@squadbase/vite-server 0.1.3-dev.7 → 0.1.3-dev.9

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.
Files changed (48) hide show
  1. package/dist/cli/index.js +1532 -1335
  2. package/dist/connectors/airtable-oauth.js +74 -1
  3. package/dist/connectors/airtable.js +74 -1
  4. package/dist/connectors/amplitude.js +74 -1
  5. package/dist/connectors/anthropic.js +74 -1
  6. package/dist/connectors/asana.js +74 -1
  7. package/dist/connectors/attio.js +74 -1
  8. package/dist/connectors/customerio.js +74 -1
  9. package/dist/connectors/dbt.js +74 -1
  10. package/dist/connectors/gemini.js +74 -1
  11. package/dist/connectors/gmail-oauth.js +74 -1
  12. package/dist/connectors/gmail.js +74 -1
  13. package/dist/connectors/google-ads-oauth.js +74 -1
  14. package/dist/connectors/google-ads.js +74 -1
  15. package/dist/connectors/google-analytics-oauth.js +87 -6
  16. package/dist/connectors/google-analytics.js +117 -46
  17. package/dist/connectors/google-calendar-oauth.js +74 -1
  18. package/dist/connectors/google-calendar.d.ts +1 -8
  19. package/dist/connectors/google-calendar.js +316 -64
  20. package/dist/connectors/google-sheets-oauth.js +85 -18
  21. package/dist/connectors/google-sheets.js +75 -2
  22. package/dist/connectors/grafana.js +74 -1
  23. package/dist/connectors/hubspot-oauth.js +74 -1
  24. package/dist/connectors/hubspot.js +74 -1
  25. package/dist/connectors/intercom-oauth.js +74 -1
  26. package/dist/connectors/intercom.js +74 -1
  27. package/dist/connectors/jira-api-key.js +74 -1
  28. package/dist/connectors/kintone-api-token.js +74 -1
  29. package/dist/connectors/kintone.js +74 -1
  30. package/dist/connectors/linkedin-ads-oauth.js +74 -1
  31. package/dist/connectors/linkedin-ads.js +74 -1
  32. package/dist/connectors/mailchimp-oauth.js +74 -1
  33. package/dist/connectors/mailchimp.js +74 -1
  34. package/dist/connectors/notion-oauth.js +74 -1
  35. package/dist/connectors/notion.js +74 -1
  36. package/dist/connectors/openai.js +74 -1
  37. package/dist/connectors/shopify-oauth.js +74 -1
  38. package/dist/connectors/shopify.js +74 -1
  39. package/dist/connectors/stripe-api-key.js +74 -1
  40. package/dist/connectors/stripe-oauth.js +74 -1
  41. package/dist/connectors/wix-store.js +74 -1
  42. package/dist/connectors/zendesk-oauth.js +74 -1
  43. package/dist/connectors/zendesk.js +74 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +1568 -1335
  46. package/dist/main.js +1567 -1333
  47. package/dist/vite-plugin.js +1483 -1286
  48. package/package.json +1 -1
@@ -57,7 +57,6 @@ var parameters = {
57
57
  required: true
58
58
  })
59
59
  };
60
- var PROPERTY_ID_SLUG = "property-id";
61
60
 
62
61
  // ../connectors/src/connectors/google-analytics/sdk/index.ts
63
62
  var TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -87,15 +86,9 @@ function buildJwt(clientEmail, privateKey, nowSec) {
87
86
  }
88
87
  function createClient(params) {
89
88
  const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
90
- const propertyId = params[PROPERTY_ID_SLUG];
91
- if (!serviceAccountKeyJsonBase64 || !propertyId) {
92
- const required = [
93
- parameters.serviceAccountKeyJsonBase64.slug,
94
- PROPERTY_ID_SLUG
95
- ];
96
- const missing = required.filter((s) => !params[s]);
89
+ if (!serviceAccountKeyJsonBase64) {
97
90
  throw new Error(
98
- `google-analytics: missing required parameters: ${missing.join(", ")}`
91
+ `google-analytics: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
99
92
  );
100
93
  }
101
94
  let serviceAccountKey;
@@ -149,13 +142,12 @@ function createClient(params) {
149
142
  return {
150
143
  async request(path2, init) {
151
144
  const accessToken = await getAccessToken2();
152
- const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
153
- const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
145
+ const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
154
146
  const headers = new Headers(init?.headers);
155
147
  headers.set("Authorization", `Bearer ${accessToken}`);
156
148
  return fetch(url, { ...init, headers });
157
149
  },
158
- async runReport(request) {
150
+ async runReport(propertyId, request) {
159
151
  const response = await this.request(
160
152
  `properties/${propertyId}:runReport`,
161
153
  {
@@ -176,7 +168,7 @@ function createClient(params) {
176
168
  rowCount: data.rowCount ?? 0
177
169
  };
178
170
  },
179
- async getMetadata() {
171
+ async getMetadata(propertyId) {
180
172
  const response = await this.request(
181
173
  `properties/${propertyId}/metadata`,
182
174
  { method: "GET" }
@@ -189,7 +181,7 @@ function createClient(params) {
189
181
  }
190
182
  return await response.json();
191
183
  },
192
- async runRealtimeReport(request) {
184
+ async runRealtimeReport(propertyId, request) {
193
185
  const response = await this.request(
194
186
  `properties/${propertyId}:runRealtimeReport`,
195
187
  {
@@ -513,13 +505,16 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
513
505
  ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Analytics (Service Account) \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
514
506
 
515
507
  1. \`${listAccountsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001Service Account\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
516
- 2. \u300C\u4F7F\u7528\u3059\u308B\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059:
517
- - \`options\`: \u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (name)\` \u306E\u5F62\u5F0F
508
+ 2. \u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u9078\u629E:
509
+ - \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **2\u4EF6\u4EE5\u4E0A**: \u300C\u4F7F\u7528\u3059\u308B\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059\uFF08\`options\`: \u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (name)\` \u306E\u5F62\u5F0F\uFF09
510
+ - \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
511
+ - \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
518
512
  3. \`${listPropertiesToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u9078\u629E\u3055\u308C\u305F\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
519
- 4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
520
- - \`parameterSlug\`: \`"property-id"\`
521
- - \`options\`: \u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30D1\u30C6\u30A3ID
522
- 5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
513
+ 4. \u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u9078\u629E:
514
+ - \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **2\u4EF6\u4EE5\u4E0A**: \u300C\u4F7F\u7528\u3059\u308B\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059\uFF08\`options\`: \u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\uFF09
515
+ - \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
516
+ - \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
517
+ 5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\uFF08\u3082\u3057\u304F\u306F\u81EA\u52D5\u9078\u629E\u3055\u308C\u305F\uFF09\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u60C5\u5831\u3092\u57FA\u306B\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
523
518
  6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
524
519
  - \`property\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8868\u793A\u540D
525
520
  - \`propertyId\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID
@@ -527,17 +522,21 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
527
522
 
528
523
  #### \u5236\u7D04
529
524
  - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30EC\u30DD\u30FC\u30C8\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u306E\u307F
525
+ - \`askUserQuestion\` \u306E \`options\` \u306F\u6700\u4F4E2\u4EF6\u5FC5\u8981\u3002\u5019\u88DC\u304C1\u4EF6\u4EE5\u4E0B\u306E\u5834\u5408\u306F\u5FC5\u305A\u30B9\u30AD\u30C3\u30D7\u3059\u308B\u3053\u3068
530
526
  - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`,
531
527
  en: `Follow these steps to set up the Google Analytics (Service Account) connection.
532
528
 
533
529
  1. Call \`${listAccountsToolName}\` to get the list of Google Analytics accounts accessible with the service account credentials
534
- 2. Tell the user "Please select an account.", then call \`askUserQuestion\`:
535
- - \`options\`: The account list. Each option's \`label\` should be \`Display Name (name)\`
530
+ 2. Select an account:
531
+ - **2 or more accounts**: Tell the user "Please select an account.", then call \`askUserQuestion\` (\`options\`: each option's \`label\` should be \`Display Name (name)\`)
532
+ - **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
533
+ - **0 accounts**: Abort setup and inform the user that no accessible accounts are available
536
534
  3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
537
- 4. Call \`updateConnectionParameters\`:
538
- - \`parameterSlug\`: \`"property-id"\`
539
- - \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
540
- 5. The \`label\` of the user's selected property will arrive as a message. Proceed to the next step
535
+ 4. Select a property:
536
+ - **2 or more properties**: Tell the user "Please select a property.", then call \`askUserQuestion\` (\`options\`: each option's \`label\` should be \`Display Name (id: propertyId)\`)
537
+ - **Only 1 property**: Skip \`askUserQuestion\` and proceed using that property as the selection
538
+ - **0 properties**: Abort setup and inform the user that no accessible properties are available
539
+ 5. Proceed to the next step using the user-selected (or auto-selected) property's information
541
540
  6. Call \`updateConnectionContext\`:
542
541
  - \`property\`: The selected property's display name
543
542
  - \`propertyId\`: The selected property ID
@@ -545,6 +544,7 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
545
544
 
546
545
  #### Constraints
547
546
  - **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
547
+ - \`askUserQuestion\` requires at least 2 \`options\`. Always skip it when there is 1 or fewer candidates
548
548
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
549
549
  },
550
550
  dataOverviewInstructions: {
@@ -563,7 +563,7 @@ var inputSchema3 = z3.object({
563
563
  toolUseIntent: z3.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
564
564
  connectionId: z3.string().describe("ID of the Google Analytics connection to use"),
565
565
  method: z3.enum(["GET", "POST"]).describe("HTTP method"),
566
- path: z3.string().describe("API path (e.g., 'properties/{propertyId}:runReport'). {propertyId} is automatically replaced."),
566
+ path: z3.string().describe("API path including the property ID (e.g., 'properties/123456789:runReport')."),
567
567
  body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
568
568
  });
569
569
  var outputSchema3 = z3.discriminatedUnion("success", [
@@ -581,7 +581,7 @@ var requestTool = new ConnectorTool({
581
581
  name: "request",
582
582
  description: `Send authenticated requests to the Google Analytics Data API.
583
583
  Authentication is handled automatically using a service account.
584
- {propertyId} in the path is automatically replaced with the connection's property-id.`,
584
+ Include the full property ID in the path (e.g., 'properties/123456789:runReport').`,
585
585
  inputSchema: inputSchema3,
586
586
  outputSchema: outputSchema3,
587
587
  async execute({ connectionId, method, path: path2, body }, connections) {
@@ -593,9 +593,6 @@ Authentication is handled automatically using a service account.
593
593
  try {
594
594
  const { GoogleAuth } = await import("google-auth-library");
595
595
  const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
596
- const propertyId = connection2.parameters.find(
597
- (p) => p.parameterSlug === PROPERTY_ID_SLUG
598
- )?.value ?? void 0;
599
596
  const credentials = JSON.parse(
600
597
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
601
598
  );
@@ -607,8 +604,7 @@ Authentication is handled automatically using a service account.
607
604
  if (!token) {
608
605
  return { success: false, error: "Failed to obtain access token" };
609
606
  }
610
- const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
611
- const url = `${BASE_URL2}${resolvedPath}`;
607
+ const url = `${BASE_URL2}${path2}`;
612
608
  const controller = new AbortController();
613
609
  const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS3);
614
610
  try {
@@ -666,17 +662,18 @@ var googleAnalyticsConnector = new ConnectorPlugin({
666
662
 
667
663
  The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
668
664
 
669
- SDK methods (client created via \`connection(connectionId)\`):
670
- - \`client.runReport(request)\` \u2014 run a GA4 report
671
- - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
672
- - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
673
- - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
665
+ SDK methods (client created via \`connection(connectionId)\`). The GA4 property ID is NOT stored as a connection parameter \u2014 pass it explicitly to each call. Use the \`propertyId\` recorded in the connection context during setup:
666
+ - \`client.runReport(propertyId, request)\` \u2014 run a GA4 report
667
+ - \`client.runRealtimeReport(propertyId, request)\` \u2014 run a realtime report
668
+ - \`client.getMetadata(propertyId)\` \u2014 fetch available dimensions/metrics
669
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (path must include the property ID)
674
670
 
675
671
  \`\`\`ts
676
672
  import type { Context } from "hono";
677
673
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
678
674
 
679
675
  const ga = connection("<connectionId>");
676
+ const PROPERTY_ID = "<propertyId from connection context>";
680
677
 
681
678
  export default async function handler(c: Context) {
682
679
  const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
@@ -684,7 +681,7 @@ export default async function handler(c: Context) {
684
681
  endDate?: string;
685
682
  }>();
686
683
 
687
- const { rows } = await ga.runReport({
684
+ const { rows } = await ga.runReport(PROPERTY_ID, {
688
685
  dateRanges: [{ startDate, endDate }],
689
686
  dimensions: [{ name: "date" }],
690
687
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -736,17 +733,18 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
736
733
 
737
734
  \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\u30BFSDK\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
738
735
 
739
- SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
740
- - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
741
- - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
742
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
743
- - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
736
+ SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8)\u3002GA4 \u30D7\u30ED\u30D1\u30C6\u30A3ID\u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u4FDD\u5B58\u3055\u308C\u307E\u305B\u3093\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B connection context \u306B\u8A18\u9332\u3055\u308C\u305F \`propertyId\` \u3092\u5404\u547C\u3073\u51FA\u3057\u306B\u660E\u793A\u7684\u306B\u6E21\u3057\u3066\u304F\u3060\u3055\u3044:
737
+ - \`client.runReport(propertyId, request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
738
+ - \`client.runRealtimeReport(propertyId, request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
739
+ - \`client.getMetadata(propertyId)\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
740
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch\uFF08path \u306B\u30D7\u30ED\u30D1\u30C6\u30A3ID\u3092\u542B\u3081\u308B\uFF09
744
741
 
745
742
  \`\`\`ts
746
743
  import type { Context } from "hono";
747
744
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
748
745
 
749
746
  const ga = connection("<connectionId>");
747
+ const PROPERTY_ID = "<connection context \u306E propertyId>";
750
748
 
751
749
  export default async function handler(c: Context) {
752
750
  const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
@@ -754,7 +752,7 @@ export default async function handler(c: Context) {
754
752
  endDate?: string;
755
753
  }>();
756
754
 
757
- const { rows } = await ga.runReport({
755
+ const { rows } = await ga.runReport(PROPERTY_ID, {
758
756
  dateRanges: [{ startDate, endDate }],
759
757
  dimensions: [{ name: "date" }],
760
758
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -822,6 +820,79 @@ function resolveEnvVarOptional(entry, key) {
822
820
  return process.env[envVarName] || void 0;
823
821
  }
824
822
 
823
+ // src/connector-client/proxy-fetch.ts
824
+ import { getContext } from "hono/context-storage";
825
+ import { getCookie } from "hono/cookie";
826
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
827
+ function createSandboxProxyFetch(connectionId) {
828
+ return async (input, init) => {
829
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
830
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
831
+ if (!token || !sandboxId) {
832
+ throw new Error(
833
+ "Connection proxy is not configured. Please check your deployment settings."
834
+ );
835
+ }
836
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
837
+ const originalMethod = init?.method ?? "GET";
838
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
839
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
840
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
841
+ return fetch(proxyUrl, {
842
+ method: "POST",
843
+ headers: {
844
+ "Content-Type": "application/json",
845
+ Authorization: `Bearer ${token}`
846
+ },
847
+ body: JSON.stringify({
848
+ url: originalUrl,
849
+ method: originalMethod,
850
+ body: originalBody
851
+ })
852
+ });
853
+ };
854
+ }
855
+ function createDeployedAppProxyFetch(connectionId) {
856
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
857
+ if (!projectId) {
858
+ throw new Error(
859
+ "Connection proxy is not configured. Please check your deployment settings."
860
+ );
861
+ }
862
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
863
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
864
+ return async (input, init) => {
865
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
866
+ const originalMethod = init?.method ?? "GET";
867
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
868
+ const c = getContext();
869
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
870
+ if (!appSession) {
871
+ throw new Error(
872
+ "No authentication method available for connection proxy."
873
+ );
874
+ }
875
+ return fetch(proxyUrl, {
876
+ method: "POST",
877
+ headers: {
878
+ "Content-Type": "application/json",
879
+ Authorization: `Bearer ${appSession}`
880
+ },
881
+ body: JSON.stringify({
882
+ url: originalUrl,
883
+ method: originalMethod,
884
+ body: originalBody
885
+ })
886
+ });
887
+ };
888
+ }
889
+ function createProxyFetch(connectionId) {
890
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
891
+ return createSandboxProxyFetch(connectionId);
892
+ }
893
+ return createDeployedAppProxyFetch(connectionId);
894
+ }
895
+
825
896
  // src/connectors/create-connector-sdk.ts
826
897
  function loadConnectionsSync() {
827
898
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -855,7 +926,7 @@ function createConnectorSdk(plugin, createClient2) {
855
926
  if (val !== void 0) params[param.slug] = val;
856
927
  }
857
928
  }
858
- return createClient2(params);
929
+ return createClient2(params, createProxyFetch(connectionId));
859
930
  };
860
931
  }
861
932
 
@@ -700,6 +700,79 @@ function resolveEnvVarOptional(entry, key) {
700
700
  return process.env[envVarName] || void 0;
701
701
  }
702
702
 
703
+ // src/connector-client/proxy-fetch.ts
704
+ import { getContext } from "hono/context-storage";
705
+ import { getCookie } from "hono/cookie";
706
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
707
+ function createSandboxProxyFetch(connectionId) {
708
+ return async (input, init) => {
709
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
710
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
711
+ if (!token || !sandboxId) {
712
+ throw new Error(
713
+ "Connection proxy is not configured. Please check your deployment settings."
714
+ );
715
+ }
716
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
717
+ const originalMethod = init?.method ?? "GET";
718
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
719
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
720
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
721
+ return fetch(proxyUrl, {
722
+ method: "POST",
723
+ headers: {
724
+ "Content-Type": "application/json",
725
+ Authorization: `Bearer ${token}`
726
+ },
727
+ body: JSON.stringify({
728
+ url: originalUrl,
729
+ method: originalMethod,
730
+ body: originalBody
731
+ })
732
+ });
733
+ };
734
+ }
735
+ function createDeployedAppProxyFetch(connectionId) {
736
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
737
+ if (!projectId) {
738
+ throw new Error(
739
+ "Connection proxy is not configured. Please check your deployment settings."
740
+ );
741
+ }
742
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
743
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
744
+ return async (input, init) => {
745
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
746
+ const originalMethod = init?.method ?? "GET";
747
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
748
+ const c = getContext();
749
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
750
+ if (!appSession) {
751
+ throw new Error(
752
+ "No authentication method available for connection proxy."
753
+ );
754
+ }
755
+ return fetch(proxyUrl, {
756
+ method: "POST",
757
+ headers: {
758
+ "Content-Type": "application/json",
759
+ Authorization: `Bearer ${appSession}`
760
+ },
761
+ body: JSON.stringify({
762
+ url: originalUrl,
763
+ method: originalMethod,
764
+ body: originalBody
765
+ })
766
+ });
767
+ };
768
+ }
769
+ function createProxyFetch(connectionId) {
770
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
771
+ return createSandboxProxyFetch(connectionId);
772
+ }
773
+ return createDeployedAppProxyFetch(connectionId);
774
+ }
775
+
703
776
  // src/connectors/create-connector-sdk.ts
704
777
  function loadConnectionsSync() {
705
778
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -733,7 +806,7 @@ function createConnectorSdk(plugin, createClient2) {
733
806
  if (val !== void 0) params[param.slug] = val;
734
807
  }
735
808
  }
736
- return createClient2(params);
809
+ return createClient2(params, createProxyFetch(connectionId));
737
810
  };
738
811
  }
739
812
 
@@ -1,12 +1,5 @@
1
1
  import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
- import { GoogleCalendarClientOptions } from '@squadbase/connectors/sdk';
3
2
 
4
- /**
5
- * Create a Google Calendar SDK client for the given connection.
6
- *
7
- * @param connectionId - The connection ID from .squadbase/connections.json
8
- * @param options - Optional configuration (e.g., subject for Domain-wide Delegation)
9
- */
10
- declare const connection: (connectionId: string, options?: GoogleCalendarClientOptions) => _squadbase_connectors_sdk.GoogleCalendarConnectorSdk;
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleCalendarConnectorSdk;
11
4
 
12
5
  export { connection };