@squadbase/vite-server 0.1.3-dev.6 → 0.1.3-dev.8

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 (49) hide show
  1. package/dist/cli/index.js +1858 -1340
  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 -52
  17. package/dist/connectors/google-calendar-oauth.js +75 -2
  18. package/dist/connectors/google-calendar.d.ts +1 -8
  19. package/dist/connectors/google-calendar.js +363 -60
  20. package/dist/connectors/google-sheets-oauth.js +141 -31
  21. package/dist/connectors/google-sheets.js +108 -9
  22. package/dist/connectors/grafana.d.ts +5 -0
  23. package/dist/connectors/grafana.js +638 -0
  24. package/dist/connectors/hubspot-oauth.js +74 -1
  25. package/dist/connectors/hubspot.js +74 -1
  26. package/dist/connectors/intercom-oauth.js +74 -1
  27. package/dist/connectors/intercom.js +74 -1
  28. package/dist/connectors/jira-api-key.js +74 -1
  29. package/dist/connectors/kintone-api-token.js +74 -1
  30. package/dist/connectors/kintone.js +74 -1
  31. package/dist/connectors/linkedin-ads-oauth.js +74 -1
  32. package/dist/connectors/linkedin-ads.js +74 -1
  33. package/dist/connectors/mailchimp-oauth.js +74 -1
  34. package/dist/connectors/mailchimp.js +74 -1
  35. package/dist/connectors/notion-oauth.js +74 -1
  36. package/dist/connectors/notion.js +74 -1
  37. package/dist/connectors/openai.js +74 -1
  38. package/dist/connectors/shopify-oauth.js +74 -1
  39. package/dist/connectors/shopify.js +74 -1
  40. package/dist/connectors/stripe-api-key.js +74 -1
  41. package/dist/connectors/stripe-oauth.js +74 -1
  42. package/dist/connectors/wix-store.js +74 -1
  43. package/dist/connectors/zendesk-oauth.js +74 -1
  44. package/dist/connectors/zendesk.js +74 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +1808 -1291
  47. package/dist/main.js +1807 -1289
  48. package/dist/vite-plugin.js +1807 -1289
  49. package/package.json +5 -1
@@ -55,15 +55,6 @@ var parameters = {
55
55
  type: "base64EncodedJson",
56
56
  secret: true,
57
57
  required: true
58
- }),
59
- propertyId: new ParameterDefinition({
60
- slug: "property-id",
61
- name: "Google Analytics Property ID",
62
- description: "The Google Analytics 4 property ID (e.g., 123456789). Set during connection setup.",
63
- envVarBaseKey: "GA_PROPERTY_ID",
64
- type: "text",
65
- secret: false,
66
- required: false
67
58
  })
68
59
  };
69
60
 
@@ -95,15 +86,9 @@ function buildJwt(clientEmail, privateKey, nowSec) {
95
86
  }
96
87
  function createClient(params) {
97
88
  const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
98
- const propertyId = params[parameters.propertyId.slug];
99
- if (!serviceAccountKeyJsonBase64 || !propertyId) {
100
- const required = [
101
- parameters.serviceAccountKeyJsonBase64.slug,
102
- parameters.propertyId.slug
103
- ];
104
- const missing = required.filter((s) => !params[s]);
89
+ if (!serviceAccountKeyJsonBase64) {
105
90
  throw new Error(
106
- `google-analytics: missing required parameters: ${missing.join(", ")}`
91
+ `google-analytics: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
107
92
  );
108
93
  }
109
94
  let serviceAccountKey;
@@ -157,13 +142,12 @@ function createClient(params) {
157
142
  return {
158
143
  async request(path2, init) {
159
144
  const accessToken = await getAccessToken2();
160
- const resolvedPath = path2.replace(/\{propertyId\}/g, propertyId);
161
- const url = `${BASE_URL.replace(/\/+$/, "")}/${resolvedPath.replace(/^\/+/, "")}`;
145
+ const url = `${BASE_URL.replace(/\/+$/, "")}/${path2.replace(/^\/+/, "")}`;
162
146
  const headers = new Headers(init?.headers);
163
147
  headers.set("Authorization", `Bearer ${accessToken}`);
164
148
  return fetch(url, { ...init, headers });
165
149
  },
166
- async runReport(request) {
150
+ async runReport(propertyId, request) {
167
151
  const response = await this.request(
168
152
  `properties/${propertyId}:runReport`,
169
153
  {
@@ -184,7 +168,7 @@ function createClient(params) {
184
168
  rowCount: data.rowCount ?? 0
185
169
  };
186
170
  },
187
- async getMetadata() {
171
+ async getMetadata(propertyId) {
188
172
  const response = await this.request(
189
173
  `properties/${propertyId}/metadata`,
190
174
  { method: "GET" }
@@ -197,7 +181,7 @@ function createClient(params) {
197
181
  }
198
182
  return await response.json();
199
183
  },
200
- async runRealtimeReport(request) {
184
+ async runRealtimeReport(propertyId, request) {
201
185
  const response = await this.request(
202
186
  `properties/${propertyId}:runRealtimeReport`,
203
187
  {
@@ -521,13 +505,16 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
521
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
522
506
 
523
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
524
- 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:
525
- - \`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
526
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
527
- 4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
528
- - \`parameterSlug\`: \`"property-id"\`
529
- - \`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
530
- 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
531
518
  6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
532
519
  - \`property\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8868\u793A\u540D
533
520
  - \`propertyId\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3ID
@@ -535,17 +522,21 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
535
522
 
536
523
  #### \u5236\u7D04
537
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
538
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`,
539
527
  en: `Follow these steps to set up the Google Analytics (Service Account) connection.
540
528
 
541
529
  1. Call \`${listAccountsToolName}\` to get the list of Google Analytics accounts accessible with the service account credentials
542
- 2. Tell the user "Please select an account.", then call \`askUserQuestion\`:
543
- - \`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
544
534
  3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
545
- 4. Call \`updateConnectionParameters\`:
546
- - \`parameterSlug\`: \`"property-id"\`
547
- - \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
548
- 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
549
540
  6. Call \`updateConnectionContext\`:
550
541
  - \`property\`: The selected property's display name
551
542
  - \`propertyId\`: The selected property ID
@@ -553,6 +544,7 @@ var googleAnalyticsOnboarding = new ConnectorOnboarding({
553
544
 
554
545
  #### Constraints
555
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
556
548
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
557
549
  },
558
550
  dataOverviewInstructions: {
@@ -571,7 +563,7 @@ var inputSchema3 = z3.object({
571
563
  toolUseIntent: z3.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
572
564
  connectionId: z3.string().describe("ID of the Google Analytics connection to use"),
573
565
  method: z3.enum(["GET", "POST"]).describe("HTTP method"),
574
- 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')."),
575
567
  body: z3.record(z3.string(), z3.unknown()).optional().describe("POST request body (JSON)")
576
568
  });
577
569
  var outputSchema3 = z3.discriminatedUnion("success", [
@@ -589,7 +581,7 @@ var requestTool = new ConnectorTool({
589
581
  name: "request",
590
582
  description: `Send authenticated requests to the Google Analytics Data API.
591
583
  Authentication is handled automatically using a service account.
592
- {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').`,
593
585
  inputSchema: inputSchema3,
594
586
  outputSchema: outputSchema3,
595
587
  async execute({ connectionId, method, path: path2, body }, connections) {
@@ -601,7 +593,6 @@ Authentication is handled automatically using a service account.
601
593
  try {
602
594
  const { GoogleAuth } = await import("google-auth-library");
603
595
  const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
604
- const propertyId = parameters.propertyId.tryGetValue(connection2);
605
596
  const credentials = JSON.parse(
606
597
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
607
598
  );
@@ -613,8 +604,7 @@ Authentication is handled automatically using a service account.
613
604
  if (!token) {
614
605
  return { success: false, error: "Failed to obtain access token" };
615
606
  }
616
- const resolvedPath = propertyId ? path2.replace(/\{propertyId\}/g, propertyId) : path2;
617
- const url = `${BASE_URL2}${resolvedPath}`;
607
+ const url = `${BASE_URL2}${path2}`;
618
608
  const controller = new AbortController();
619
609
  const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS3);
620
610
  try {
@@ -672,17 +662,18 @@ var googleAnalyticsConnector = new ConnectorPlugin({
672
662
 
673
663
  The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
674
664
 
675
- SDK methods (client created via \`connection(connectionId)\`):
676
- - \`client.runReport(request)\` \u2014 run a GA4 report
677
- - \`client.runRealtimeReport(request)\` \u2014 run a realtime report
678
- - \`client.getMetadata()\` \u2014 fetch available dimensions/metrics
679
- - \`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)
680
670
 
681
671
  \`\`\`ts
682
672
  import type { Context } from "hono";
683
673
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
684
674
 
685
675
  const ga = connection("<connectionId>");
676
+ const PROPERTY_ID = "<propertyId from connection context>";
686
677
 
687
678
  export default async function handler(c: Context) {
688
679
  const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
@@ -690,7 +681,7 @@ export default async function handler(c: Context) {
690
681
  endDate?: string;
691
682
  }>();
692
683
 
693
- const { rows } = await ga.runReport({
684
+ const { rows } = await ga.runReport(PROPERTY_ID, {
694
685
  dateRanges: [{ startDate, endDate }],
695
686
  dimensions: [{ name: "date" }],
696
687
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -742,17 +733,18 @@ activeUsers, sessions, screenPageViews, bounceRate, averageSessionDuration, conv
742
733
 
743
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
744
735
 
745
- SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
746
- - \`client.runReport(request)\` \u2014 GA4\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
747
- - \`client.runRealtimeReport(request)\` \u2014 \u30EA\u30A2\u30EB\u30BF\u30A4\u30E0\u30EC\u30DD\u30FC\u30C8\u3092\u5B9F\u884C
748
- - \`client.getMetadata()\` \u2014 \u5229\u7528\u53EF\u80FD\u306A\u30C7\u30A3\u30E1\u30F3\u30B7\u30E7\u30F3/\u30E1\u30C8\u30EA\u30AF\u30B9\u3092\u53D6\u5F97
749
- - \`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
750
741
 
751
742
  \`\`\`ts
752
743
  import type { Context } from "hono";
753
744
  import { connection } from "@squadbase/vite-server/connectors/google-analytics";
754
745
 
755
746
  const ga = connection("<connectionId>");
747
+ const PROPERTY_ID = "<connection context \u306E propertyId>";
756
748
 
757
749
  export default async function handler(c: Context) {
758
750
  const { startDate = "7daysAgo", endDate = "today" } = await c.req.json<{
@@ -760,7 +752,7 @@ export default async function handler(c: Context) {
760
752
  endDate?: string;
761
753
  }>();
762
754
 
763
- const { rows } = await ga.runReport({
755
+ const { rows } = await ga.runReport(PROPERTY_ID, {
764
756
  dateRanges: [{ startDate, endDate }],
765
757
  dimensions: [{ name: "date" }],
766
758
  metrics: [{ name: "activeUsers" }, { name: "sessions" }],
@@ -828,6 +820,79 @@ function resolveEnvVarOptional(entry, key) {
828
820
  return process.env[envVarName] || void 0;
829
821
  }
830
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
+
831
896
  // src/connectors/create-connector-sdk.ts
832
897
  function loadConnectionsSync() {
833
898
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -861,7 +926,7 @@ function createConnectorSdk(plugin, createClient2) {
861
926
  if (val !== void 0) params[param.slug] = val;
862
927
  }
863
928
  }
864
- return createClient2(params);
929
+ return createClient2(params, createProxyFetch(connectionId));
865
930
  };
866
931
  }
867
932
 
@@ -526,7 +526,7 @@ var googleCalendarOauthConnector = new ConnectorPlugin({
526
526
  authType: AUTH_TYPES.OAUTH,
527
527
  name: "Google Calendar",
528
528
  description: "Connect to Google Calendar for calendar and event data access using OAuth.",
529
- iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5D9eTiMxiL7MaezWXyAaLG/dbcf25e1d51ab877548b3d77e4b02c6d/google-calendar.svg",
529
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2YsqoBEpdELmfDeFcyGHyE/4494c633b5ae15e562cb739cd85442c1/google-calendar.png",
530
530
  parameters,
531
531
  releaseFlag: { dev1: true, dev2: false, prod: false },
532
532
  onboarding: googleCalendarOauthOnboarding,
@@ -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 };