@squadbase/vite-server 0.1.3-dev.0 → 0.1.3-dev.10

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 (70) hide show
  1. package/dist/cli/index.js +82859 -9645
  2. package/dist/connectors/airtable-oauth.js +77 -3
  3. package/dist/connectors/airtable.js +85 -2
  4. package/dist/connectors/amplitude.js +85 -2
  5. package/dist/connectors/anthropic.js +85 -2
  6. package/dist/connectors/{slack.d.ts → asana.d.ts} +1 -1
  7. package/dist/connectors/asana.js +744 -0
  8. package/dist/connectors/attio.js +85 -2
  9. package/dist/connectors/{microsoft-teams-oauth.d.ts → customerio.d.ts} +1 -1
  10. package/dist/connectors/customerio.js +716 -0
  11. package/dist/connectors/dbt.js +85 -2
  12. package/dist/connectors/gemini.js +86 -3
  13. package/dist/connectors/{microsoft-teams.d.ts → gmail-oauth.d.ts} +1 -1
  14. package/dist/connectors/gmail-oauth.js +713 -0
  15. package/dist/connectors/gmail.d.ts +5 -0
  16. package/dist/connectors/gmail.js +875 -0
  17. package/dist/connectors/google-ads-oauth.js +78 -4
  18. package/dist/connectors/google-ads.d.ts +5 -0
  19. package/dist/connectors/google-ads.js +867 -0
  20. package/dist/connectors/google-analytics-oauth.js +90 -8
  21. package/dist/connectors/google-analytics.js +85 -2
  22. package/dist/connectors/google-calendar-oauth.d.ts +5 -0
  23. package/dist/connectors/google-calendar-oauth.js +817 -0
  24. package/dist/connectors/google-calendar.d.ts +5 -0
  25. package/dist/connectors/google-calendar.js +991 -0
  26. package/dist/connectors/google-sheets-oauth.js +144 -33
  27. package/dist/connectors/google-sheets.d.ts +5 -0
  28. package/dist/connectors/google-sheets.js +707 -0
  29. package/dist/connectors/grafana.d.ts +5 -0
  30. package/dist/connectors/grafana.js +638 -0
  31. package/dist/connectors/hubspot-oauth.js +77 -3
  32. package/dist/connectors/hubspot.js +89 -6
  33. package/dist/connectors/intercom-oauth.d.ts +5 -0
  34. package/dist/connectors/intercom-oauth.js +584 -0
  35. package/dist/connectors/intercom.d.ts +5 -0
  36. package/dist/connectors/intercom.js +710 -0
  37. package/dist/connectors/jira-api-key.d.ts +5 -0
  38. package/dist/connectors/jira-api-key.js +598 -0
  39. package/dist/connectors/kintone-api-token.js +77 -3
  40. package/dist/connectors/kintone.js +86 -3
  41. package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
  42. package/dist/connectors/linkedin-ads-oauth.js +848 -0
  43. package/dist/connectors/linkedin-ads.d.ts +5 -0
  44. package/dist/connectors/linkedin-ads.js +865 -0
  45. package/dist/connectors/mailchimp-oauth.d.ts +5 -0
  46. package/dist/connectors/mailchimp-oauth.js +613 -0
  47. package/dist/connectors/mailchimp.d.ts +5 -0
  48. package/dist/connectors/mailchimp.js +729 -0
  49. package/dist/connectors/notion-oauth.d.ts +5 -0
  50. package/dist/connectors/notion-oauth.js +567 -0
  51. package/dist/connectors/notion.d.ts +5 -0
  52. package/dist/connectors/notion.js +663 -0
  53. package/dist/connectors/openai.js +85 -2
  54. package/dist/connectors/shopify-oauth.js +77 -3
  55. package/dist/connectors/shopify.js +85 -2
  56. package/dist/connectors/stripe-api-key.d.ts +5 -0
  57. package/dist/connectors/stripe-api-key.js +600 -0
  58. package/dist/connectors/stripe-oauth.js +77 -3
  59. package/dist/connectors/wix-store.js +85 -2
  60. package/dist/connectors/zendesk-oauth.d.ts +5 -0
  61. package/dist/connectors/zendesk-oauth.js +579 -0
  62. package/dist/connectors/zendesk.d.ts +5 -0
  63. package/dist/connectors/zendesk.js +714 -0
  64. package/dist/index.js +83024 -7099
  65. package/dist/main.js +82988 -7063
  66. package/dist/vite-plugin.js +82862 -6974
  67. package/package.json +86 -2
  68. package/dist/connectors/microsoft-teams-oauth.js +0 -479
  69. package/dist/connectors/microsoft-teams.js +0 -381
  70. package/dist/connectors/slack.js +0 -362
@@ -0,0 +1,707 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+
6
+ // ../connectors/src/connectors/google-sheets/utils.ts
7
+ function extractSpreadsheetId(urlOrId) {
8
+ const trimmed = urlOrId.trim();
9
+ const match = trimmed.match(SPREADSHEET_URL_PATTERN);
10
+ if (match) {
11
+ return match[1];
12
+ }
13
+ return trimmed;
14
+ }
15
+ var SPREADSHEET_URL_PATTERN;
16
+ var init_utils = __esm({
17
+ "../connectors/src/connectors/google-sheets/utils.ts"() {
18
+ "use strict";
19
+ SPREADSHEET_URL_PATTERN = /docs\.google\.com\/spreadsheets\/d\/([a-zA-Z0-9_-]+)/;
20
+ }
21
+ });
22
+
23
+ // ../connectors/src/parameter-definition.ts
24
+ var ParameterDefinition = class {
25
+ slug;
26
+ name;
27
+ description;
28
+ envVarBaseKey;
29
+ type;
30
+ secret;
31
+ required;
32
+ constructor(config) {
33
+ this.slug = config.slug;
34
+ this.name = config.name;
35
+ this.description = config.description;
36
+ this.envVarBaseKey = config.envVarBaseKey;
37
+ this.type = config.type;
38
+ this.secret = config.secret;
39
+ this.required = config.required;
40
+ }
41
+ /**
42
+ * Get the parameter value from a ConnectorConnectionObject.
43
+ */
44
+ getValue(connection2) {
45
+ const param = connection2.parameters.find(
46
+ (p) => p.parameterSlug === this.slug
47
+ );
48
+ if (!param || param.value == null) {
49
+ throw new Error(
50
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
51
+ );
52
+ }
53
+ return param.value;
54
+ }
55
+ /**
56
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
57
+ */
58
+ tryGetValue(connection2) {
59
+ const param = connection2.parameters.find(
60
+ (p) => p.parameterSlug === this.slug
61
+ );
62
+ if (!param || param.value == null) return void 0;
63
+ return param.value;
64
+ }
65
+ };
66
+
67
+ // ../connectors/src/connectors/google-sheets/sdk/index.ts
68
+ import * as crypto from "crypto";
69
+
70
+ // ../connectors/src/connectors/google-sheets/parameters.ts
71
+ var parameters = {
72
+ serviceAccountKeyJsonBase64: new ParameterDefinition({
73
+ slug: "service-account-key-json-base64",
74
+ name: "Google Cloud Service Account JSON",
75
+ description: "The service account JSON key used to authenticate with Google Cloud Platform. Ensure that the service account has the necessary permissions to access Google Sheets.",
76
+ envVarBaseKey: "GOOGLE_SHEETS_SERVICE_ACCOUNT_JSON_BASE64",
77
+ type: "base64EncodedJson",
78
+ secret: true,
79
+ required: true
80
+ }),
81
+ spreadsheetUrl: new ParameterDefinition({
82
+ slug: "spreadsheet-url",
83
+ name: "Google Spreadsheet URL",
84
+ description: "The URL of the Google Spreadsheet (e.g., https://docs.google.com/spreadsheets/d/xxxxx/edit). The spreadsheet ID is automatically extracted from the URL.",
85
+ envVarBaseKey: "GOOGLE_SHEETS_SPREADSHEET_URL",
86
+ type: "text",
87
+ secret: false,
88
+ required: true
89
+ })
90
+ };
91
+
92
+ // ../connectors/src/connectors/google-sheets/sdk/index.ts
93
+ init_utils();
94
+ var TOKEN_URL = "https://oauth2.googleapis.com/token";
95
+ var BASE_URL = "https://sheets.googleapis.com/v4/spreadsheets";
96
+ var SCOPE = "https://www.googleapis.com/auth/spreadsheets.readonly";
97
+ function base64url(input) {
98
+ const buf = typeof input === "string" ? Buffer.from(input) : input;
99
+ return buf.toString("base64url");
100
+ }
101
+ function buildJwt(clientEmail, privateKey, nowSec) {
102
+ const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
103
+ const payload = base64url(
104
+ JSON.stringify({
105
+ iss: clientEmail,
106
+ scope: SCOPE,
107
+ aud: TOKEN_URL,
108
+ iat: nowSec,
109
+ exp: nowSec + 3600
110
+ })
111
+ );
112
+ const signingInput = `${header}.${payload}`;
113
+ const sign = crypto.createSign("RSA-SHA256");
114
+ sign.update(signingInput);
115
+ sign.end();
116
+ const signature = base64url(sign.sign(privateKey));
117
+ return `${signingInput}.${signature}`;
118
+ }
119
+ function createClient(params) {
120
+ const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
121
+ const spreadsheetUrl = params[parameters.spreadsheetUrl.slug];
122
+ const defaultSpreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
123
+ if (!serviceAccountKeyJsonBase64) {
124
+ throw new Error(
125
+ `google-sheets: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
126
+ );
127
+ }
128
+ let serviceAccountKey;
129
+ try {
130
+ const decoded = Buffer.from(
131
+ serviceAccountKeyJsonBase64,
132
+ "base64"
133
+ ).toString("utf-8");
134
+ serviceAccountKey = JSON.parse(decoded);
135
+ } catch {
136
+ throw new Error(
137
+ "google-sheets: failed to decode service account key JSON from base64"
138
+ );
139
+ }
140
+ if (!serviceAccountKey.client_email || !serviceAccountKey.private_key) {
141
+ throw new Error(
142
+ "google-sheets: service account key JSON must contain client_email and private_key"
143
+ );
144
+ }
145
+ let cachedToken = null;
146
+ let tokenExpiresAt = 0;
147
+ async function getAccessToken() {
148
+ const nowSec = Math.floor(Date.now() / 1e3);
149
+ if (cachedToken && nowSec < tokenExpiresAt - 60) {
150
+ return cachedToken;
151
+ }
152
+ const jwt = buildJwt(
153
+ serviceAccountKey.client_email,
154
+ serviceAccountKey.private_key,
155
+ nowSec
156
+ );
157
+ const response = await fetch(TOKEN_URL, {
158
+ method: "POST",
159
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
160
+ body: new URLSearchParams({
161
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
162
+ assertion: jwt
163
+ })
164
+ });
165
+ if (!response.ok) {
166
+ const text = await response.text();
167
+ throw new Error(
168
+ `google-sheets: token exchange failed (${response.status}): ${text}`
169
+ );
170
+ }
171
+ const data = await response.json();
172
+ cachedToken = data.access_token;
173
+ tokenExpiresAt = nowSec + data.expires_in;
174
+ return cachedToken;
175
+ }
176
+ function resolveSpreadsheetId(override) {
177
+ const id = override ?? defaultSpreadsheetId;
178
+ if (!id) {
179
+ throw new Error(
180
+ "google-sheets: spreadsheetId is required. Either configure a default or pass it explicitly."
181
+ );
182
+ }
183
+ return id;
184
+ }
185
+ async function authenticatedFetch(url, init) {
186
+ const accessToken = await getAccessToken();
187
+ const headers = new Headers(init?.headers);
188
+ headers.set("Authorization", `Bearer ${accessToken}`);
189
+ return fetch(url, { ...init, headers });
190
+ }
191
+ return {
192
+ async request(path2, init) {
193
+ const resolvedPath = defaultSpreadsheetId ? path2.replace(/\{spreadsheetId\}/g, defaultSpreadsheetId) : path2;
194
+ const url = `${BASE_URL}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
195
+ return authenticatedFetch(url, init);
196
+ },
197
+ async getSpreadsheet(spreadsheetId) {
198
+ const id = resolveSpreadsheetId(spreadsheetId);
199
+ const url = `${BASE_URL}/${id}?fields=spreadsheetId,properties,sheets.properties`;
200
+ const response = await authenticatedFetch(url);
201
+ if (!response.ok) {
202
+ const body = await response.text();
203
+ throw new Error(
204
+ `google-sheets: getSpreadsheet failed (${response.status}): ${body}`
205
+ );
206
+ }
207
+ return await response.json();
208
+ },
209
+ async getValues(range, spreadsheetId) {
210
+ const id = resolveSpreadsheetId(spreadsheetId);
211
+ const url = `${BASE_URL}/${id}/values/${encodeURIComponent(range)}`;
212
+ const response = await authenticatedFetch(url);
213
+ if (!response.ok) {
214
+ const body = await response.text();
215
+ throw new Error(
216
+ `google-sheets: getValues failed (${response.status}): ${body}`
217
+ );
218
+ }
219
+ return await response.json();
220
+ },
221
+ async batchGetValues(ranges, spreadsheetId) {
222
+ const id = resolveSpreadsheetId(spreadsheetId);
223
+ const searchParams = new URLSearchParams();
224
+ for (const range of ranges) {
225
+ searchParams.append("ranges", range);
226
+ }
227
+ const url = `${BASE_URL}/${id}/values:batchGet?${searchParams.toString()}`;
228
+ const response = await authenticatedFetch(url);
229
+ if (!response.ok) {
230
+ const body = await response.text();
231
+ throw new Error(
232
+ `google-sheets: batchGetValues failed (${response.status}): ${body}`
233
+ );
234
+ }
235
+ return await response.json();
236
+ }
237
+ };
238
+ }
239
+
240
+ // ../connectors/src/connector-onboarding.ts
241
+ var ConnectorOnboarding = class {
242
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
243
+ connectionSetupInstructions;
244
+ /** Phase 2: Data overview instructions */
245
+ dataOverviewInstructions;
246
+ constructor(config) {
247
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
248
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
249
+ }
250
+ getConnectionSetupPrompt(language) {
251
+ return this.connectionSetupInstructions?.[language] ?? null;
252
+ }
253
+ getDataOverviewInstructions(language) {
254
+ return this.dataOverviewInstructions[language];
255
+ }
256
+ };
257
+
258
+ // ../connectors/src/connector-tool.ts
259
+ var ConnectorTool = class {
260
+ name;
261
+ description;
262
+ inputSchema;
263
+ outputSchema;
264
+ _execute;
265
+ constructor(config) {
266
+ this.name = config.name;
267
+ this.description = config.description;
268
+ this.inputSchema = config.inputSchema;
269
+ this.outputSchema = config.outputSchema;
270
+ this._execute = config.execute;
271
+ }
272
+ createTool(connections, config) {
273
+ return {
274
+ description: this.description,
275
+ inputSchema: this.inputSchema,
276
+ outputSchema: this.outputSchema,
277
+ execute: (input) => this._execute(input, connections, config)
278
+ };
279
+ }
280
+ };
281
+
282
+ // ../connectors/src/connector-plugin.ts
283
+ var ConnectorPlugin = class _ConnectorPlugin {
284
+ slug;
285
+ authType;
286
+ name;
287
+ description;
288
+ iconUrl;
289
+ parameters;
290
+ releaseFlag;
291
+ proxyPolicy;
292
+ experimentalAttributes;
293
+ onboarding;
294
+ systemPrompt;
295
+ tools;
296
+ query;
297
+ checkConnection;
298
+ constructor(config) {
299
+ this.slug = config.slug;
300
+ this.authType = config.authType;
301
+ this.name = config.name;
302
+ this.description = config.description;
303
+ this.iconUrl = config.iconUrl;
304
+ this.parameters = config.parameters;
305
+ this.releaseFlag = config.releaseFlag;
306
+ this.proxyPolicy = config.proxyPolicy;
307
+ this.experimentalAttributes = config.experimentalAttributes;
308
+ this.onboarding = config.onboarding;
309
+ this.systemPrompt = config.systemPrompt;
310
+ this.tools = config.tools;
311
+ this.query = config.query;
312
+ this.checkConnection = config.checkConnection;
313
+ }
314
+ get connectorKey() {
315
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
316
+ }
317
+ /**
318
+ * Create tools for connections that belong to this connector.
319
+ * Filters connections by connectorKey internally.
320
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
321
+ */
322
+ createTools(connections, config) {
323
+ const myConnections = connections.filter(
324
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
325
+ );
326
+ const result = {};
327
+ for (const t of Object.values(this.tools)) {
328
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
329
+ myConnections,
330
+ config
331
+ );
332
+ }
333
+ return result;
334
+ }
335
+ static deriveKey(slug, authType) {
336
+ return authType ? `${slug}-${authType}` : slug;
337
+ }
338
+ };
339
+
340
+ // ../connectors/src/auth-types.ts
341
+ var AUTH_TYPES = {
342
+ OAUTH: "oauth",
343
+ API_KEY: "api-key",
344
+ JWT: "jwt",
345
+ SERVICE_ACCOUNT: "service-account",
346
+ PAT: "pat",
347
+ USER_PASSWORD: "user-password"
348
+ };
349
+
350
+ // ../connectors/src/connectors/google-sheets/setup.ts
351
+ var googleSheetsOnboarding = new ConnectorOnboarding({
352
+ dataOverviewInstructions: {
353
+ en: `1. Call google-sheets_request with GET /{spreadsheetId} to get spreadsheet metadata (sheet names and properties)
354
+ 2. Call google-sheets_request with GET /{spreadsheetId}/values/{sheetName}!A1:Z5 to sample data from key sheets`,
355
+ ja: `1. google-sheets_request \u3067 GET /{spreadsheetId} \u3092\u547C\u3073\u51FA\u3057\u3001\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\uFF08\u30B7\u30FC\u30C8\u540D\u3068\u30D7\u30ED\u30D1\u30C6\u30A3\uFF09\u3092\u53D6\u5F97
356
+ 2. google-sheets_request \u3067 GET /{spreadsheetId}/values/{sheetName}!A1:Z5 \u3092\u547C\u3073\u51FA\u3057\u3001\u4E3B\u8981\u30B7\u30FC\u30C8\u306E\u30C7\u30FC\u30BF\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0`
357
+ }
358
+ });
359
+
360
+ // ../connectors/src/connectors/google-sheets/tools/request.ts
361
+ import { z } from "zod";
362
+ init_utils();
363
+ var BASE_URL2 = "https://sheets.googleapis.com/v4/spreadsheets";
364
+ var REQUEST_TIMEOUT_MS = 6e4;
365
+ var inputSchema = z.object({
366
+ toolUseIntent: z.string().optional().describe(
367
+ "Brief description of what you intend to accomplish with this tool call"
368
+ ),
369
+ connectionId: z.string().describe("ID of the Google Sheets connection to use"),
370
+ method: z.enum(["GET"]).describe("HTTP method (read-only, GET only)"),
371
+ path: z.string().describe(
372
+ "API path appended to https://sheets.googleapis.com/v4/spreadsheets (e.g., '/{spreadsheetId}', '/{spreadsheetId}/values/Sheet1!A1:D10'). {spreadsheetId} is automatically replaced if a default is configured."
373
+ ),
374
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL")
375
+ });
376
+ var outputSchema = z.discriminatedUnion("success", [
377
+ z.object({
378
+ success: z.literal(true),
379
+ status: z.number(),
380
+ data: z.record(z.string(), z.unknown())
381
+ }),
382
+ z.object({
383
+ success: z.literal(false),
384
+ error: z.string()
385
+ })
386
+ ]);
387
+ var requestTool = new ConnectorTool({
388
+ name: "request",
389
+ description: `Send authenticated GET requests to the Google Sheets API v4.
390
+ Authentication is handled automatically using a service account.
391
+ {spreadsheetId} in the path is automatically replaced with the connection's default spreadsheet ID if configured.`,
392
+ inputSchema,
393
+ outputSchema,
394
+ async execute({ connectionId, method, path: path2, queryParams }, connections) {
395
+ const connection2 = connections.find((c) => c.id === connectionId);
396
+ if (!connection2) {
397
+ return {
398
+ success: false,
399
+ error: `Connection ${connectionId} not found`
400
+ };
401
+ }
402
+ console.log(
403
+ `[connector-request] google-sheets/${connection2.name}: ${method} ${path2}`
404
+ );
405
+ try {
406
+ const { GoogleAuth } = await import("google-auth-library");
407
+ const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
408
+ const spreadsheetUrl = parameters.spreadsheetUrl.tryGetValue(connection2);
409
+ const spreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
410
+ const credentials = JSON.parse(
411
+ Buffer.from(keyJsonBase64, "base64").toString("utf-8")
412
+ );
413
+ const auth = new GoogleAuth({
414
+ credentials,
415
+ scopes: ["https://www.googleapis.com/auth/spreadsheets.readonly"]
416
+ });
417
+ const token = await auth.getAccessToken();
418
+ if (!token) {
419
+ return {
420
+ success: false,
421
+ error: "Failed to obtain access token"
422
+ };
423
+ }
424
+ const resolvedPath = spreadsheetId ? path2.replace(/\{spreadsheetId\}/g, spreadsheetId) : path2;
425
+ let url = `${BASE_URL2}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
426
+ if (queryParams) {
427
+ const searchParams = new URLSearchParams(queryParams);
428
+ url += `?${searchParams.toString()}`;
429
+ }
430
+ const controller = new AbortController();
431
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
432
+ try {
433
+ const response = await fetch(url, {
434
+ method,
435
+ headers: {
436
+ Authorization: `Bearer ${token}`
437
+ },
438
+ signal: controller.signal
439
+ });
440
+ const data = await response.json();
441
+ if (!response.ok) {
442
+ const errorObj = data?.error;
443
+ return {
444
+ success: false,
445
+ error: errorObj?.message ?? `HTTP ${response.status} ${response.statusText}`
446
+ };
447
+ }
448
+ return { success: true, status: response.status, data };
449
+ } finally {
450
+ clearTimeout(timeout);
451
+ }
452
+ } catch (err) {
453
+ const msg = err instanceof Error ? err.message : String(err);
454
+ return { success: false, error: msg };
455
+ }
456
+ }
457
+ });
458
+
459
+ // ../connectors/src/connectors/google-sheets/index.ts
460
+ var tools = { request: requestTool };
461
+ var googleSheetsConnector = new ConnectorPlugin({
462
+ slug: "google-sheets",
463
+ authType: AUTH_TYPES.SERVICE_ACCOUNT,
464
+ name: "Google Sheets",
465
+ description: "Connect to Google Sheets for spreadsheet data access using a service account.",
466
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1UPQuggyiZmbb26CuaSr2h/032770e8739b183fa00b7625f024e536/google-sheets.svg",
467
+ parameters,
468
+ releaseFlag: { dev1: true, dev2: false, prod: false },
469
+ onboarding: googleSheetsOnboarding,
470
+ systemPrompt: {
471
+ en: `### Tools
472
+
473
+ - \`google-sheets_request\`: The only way to call the Google Sheets API (read-only). Use it to get spreadsheet metadata, cell values, and batch values. Authentication is configured automatically via service account. The {spreadsheetId} placeholder in paths is automatically replaced with the configured default spreadsheet ID.
474
+
475
+ ### Google Sheets API Reference
476
+
477
+ #### Available Endpoints
478
+ - GET \`/{spreadsheetId}\` \u2014 Get spreadsheet metadata (title, sheets, properties)
479
+ - GET \`/{spreadsheetId}/values/{range}\` \u2014 Get cell values for a range
480
+ - GET \`/{spreadsheetId}/values:batchGet?ranges={range1}&ranges={range2}\` \u2014 Get values for multiple ranges
481
+
482
+ ### Range Notation (A1 notation)
483
+ - \`Sheet1!A1:D10\` \u2014 Specific range on Sheet1
484
+ - \`Sheet1!A:A\` \u2014 Entire column A on Sheet1
485
+ - \`Sheet1!1:3\` \u2014 Rows 1 to 3 on Sheet1
486
+ - \`Sheet1\` \u2014 All data on Sheet1
487
+ - \`A1:D10\` \u2014 Range on the first sheet (when only one sheet exists)
488
+
489
+ ### Tips
490
+ - Use \`{spreadsheetId}\` placeholder in paths \u2014 it is automatically replaced with the configured default spreadsheet ID
491
+ - To explore a spreadsheet, first get metadata to see available sheet names
492
+ - Use \`valueRenderOption=FORMATTED_VALUE\` query param to get display values
493
+ - Use \`valueRenderOption=UNFORMATTED_VALUE\` for raw numeric values
494
+ - Use \`majorDimension=COLUMNS\` to get data organized by columns instead of rows
495
+
496
+ ### Business Logic
497
+
498
+ 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.
499
+
500
+ #### Example
501
+
502
+ \`\`\`ts
503
+ import { connection } from "@squadbase/vite-server/connectors/google-sheets";
504
+
505
+ const sheets = connection("<connectionId>");
506
+
507
+ // Get spreadsheet metadata
508
+ const metadata = await sheets.getSpreadsheet();
509
+ console.log(metadata.properties.title, metadata.sheets.map(s => s.properties.title));
510
+
511
+ // Get cell values
512
+ const values = await sheets.getValues("Sheet1!A1:D10");
513
+ console.log(values.values); // 2D array
514
+
515
+ // Get multiple ranges at once
516
+ const batch = await sheets.batchGetValues(["Sheet1!A1:B5", "Sheet2!A1:C3"]);
517
+ batch.valueRanges.forEach(vr => console.log(vr.range, vr.values));
518
+ \`\`\``,
519
+ ja: `### \u30C4\u30FC\u30EB
520
+
521
+ - \`google-sheets_request\`: Google Sheets API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09\u3002\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3001\u30BB\u30EB\u5024\u3001\u30D0\u30C3\u30C1\u5024\u306E\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{spreadsheetId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
522
+
523
+ ### Google Sheets API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
524
+
525
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
526
+ - GET \`/{spreadsheetId}\` \u2014 \u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\uFF08\u30BF\u30A4\u30C8\u30EB\u3001\u30B7\u30FC\u30C8\u3001\u30D7\u30ED\u30D1\u30C6\u30A3\uFF09
527
+ - GET \`/{spreadsheetId}/values/{range}\` \u2014 \u7BC4\u56F2\u306E\u30BB\u30EB\u5024\u3092\u53D6\u5F97
528
+ - GET \`/{spreadsheetId}/values:batchGet?ranges={range1}&ranges={range2}\` \u2014 \u8907\u6570\u7BC4\u56F2\u306E\u5024\u3092\u53D6\u5F97
529
+
530
+ ### \u7BC4\u56F2\u306E\u8868\u8A18\u6CD5\uFF08A1\u8868\u8A18\u6CD5\uFF09
531
+ - \`Sheet1!A1:D10\` \u2014 Sheet1\u4E0A\u306E\u7279\u5B9A\u7BC4\u56F2
532
+ - \`Sheet1!A:A\` \u2014 Sheet1\u306EA\u5217\u5168\u4F53
533
+ - \`Sheet1!1:3\` \u2014 Sheet1\u306E1\u884C\u76EE\u304B\u30893\u884C\u76EE
534
+ - \`Sheet1\` \u2014 Sheet1\u306E\u5168\u30C7\u30FC\u30BF
535
+ - \`A1:D10\` \u2014 \u6700\u521D\u306E\u30B7\u30FC\u30C8\u306E\u7BC4\u56F2\uFF08\u30B7\u30FC\u30C8\u304C1\u3064\u306E\u307F\u306E\u5834\u5408\uFF09
536
+
537
+ ### \u30D2\u30F3\u30C8
538
+ - \u30D1\u30B9\u306B \`{spreadsheetId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u3092\u4F7F\u7528 \u2014 \u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059
539
+ - \u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u3092\u63A2\u7D22\u3059\u308B\u306B\u306F\u3001\u307E\u305A\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u3066\u5229\u7528\u53EF\u80FD\u306A\u30B7\u30FC\u30C8\u540D\u3092\u78BA\u8A8D\u3057\u307E\u3059
540
+ - \u8868\u793A\u5024\u3092\u53D6\u5F97\u3059\u308B\u306B\u306F \`valueRenderOption=FORMATTED_VALUE\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u307E\u3059
541
+ - \u751F\u306E\u6570\u5024\u3092\u53D6\u5F97\u3059\u308B\u306B\u306F \`valueRenderOption=UNFORMATTED_VALUE\` \u3092\u4F7F\u7528\u3057\u307E\u3059
542
+ - \u5217\u3054\u3068\u306B\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3059\u308B\u306B\u306F \`majorDimension=COLUMNS\` \u3092\u4F7F\u7528\u3057\u307E\u3059
543
+
544
+ ### Business Logic
545
+
546
+ \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\u30BFSDK\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
547
+
548
+ #### Example
549
+
550
+ \`\`\`ts
551
+ import { connection } from "@squadbase/vite-server/connectors/google-sheets";
552
+
553
+ const sheets = connection("<connectionId>");
554
+
555
+ // Get spreadsheet metadata
556
+ const metadata = await sheets.getSpreadsheet();
557
+ console.log(metadata.properties.title, metadata.sheets.map(s => s.properties.title));
558
+
559
+ // Get cell values
560
+ const values = await sheets.getValues("Sheet1!A1:D10");
561
+ console.log(values.values); // 2D array
562
+
563
+ // Get multiple ranges at once
564
+ const batch = await sheets.batchGetValues(["Sheet1!A1:B5", "Sheet2!A1:C3"]);
565
+ batch.valueRanges.forEach(vr => console.log(vr.range, vr.values));
566
+ \`\`\``
567
+ },
568
+ tools
569
+ });
570
+
571
+ // src/connectors/create-connector-sdk.ts
572
+ import { readFileSync } from "fs";
573
+ import path from "path";
574
+
575
+ // src/connector-client/env.ts
576
+ function resolveEnvVar(entry, key, connectionId) {
577
+ const envVarName = entry.envVars[key];
578
+ if (!envVarName) {
579
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
580
+ }
581
+ const value = process.env[envVarName];
582
+ if (!value) {
583
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
584
+ }
585
+ return value;
586
+ }
587
+ function resolveEnvVarOptional(entry, key) {
588
+ const envVarName = entry.envVars[key];
589
+ if (!envVarName) return void 0;
590
+ return process.env[envVarName] || void 0;
591
+ }
592
+
593
+ // src/connector-client/proxy-fetch.ts
594
+ import { getContext } from "hono/context-storage";
595
+ import { getCookie } from "hono/cookie";
596
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
597
+ function createSandboxProxyFetch(connectionId) {
598
+ return async (input, init) => {
599
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
600
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
601
+ if (!token || !sandboxId) {
602
+ throw new Error(
603
+ "Connection proxy is not configured. Please check your deployment settings."
604
+ );
605
+ }
606
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
607
+ const originalMethod = init?.method ?? "GET";
608
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
609
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
610
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
611
+ return fetch(proxyUrl, {
612
+ method: "POST",
613
+ headers: {
614
+ "Content-Type": "application/json",
615
+ Authorization: `Bearer ${token}`
616
+ },
617
+ body: JSON.stringify({
618
+ url: originalUrl,
619
+ method: originalMethod,
620
+ body: originalBody
621
+ })
622
+ });
623
+ };
624
+ }
625
+ function createDeployedAppProxyFetch(connectionId) {
626
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
627
+ if (!projectId) {
628
+ throw new Error(
629
+ "Connection proxy is not configured. Please check your deployment settings."
630
+ );
631
+ }
632
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
633
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
634
+ return async (input, init) => {
635
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
636
+ const originalMethod = init?.method ?? "GET";
637
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
638
+ const c = getContext();
639
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
640
+ if (!appSession) {
641
+ throw new Error(
642
+ "No authentication method available for connection proxy."
643
+ );
644
+ }
645
+ return fetch(proxyUrl, {
646
+ method: "POST",
647
+ headers: {
648
+ "Content-Type": "application/json",
649
+ Authorization: `Bearer ${appSession}`
650
+ },
651
+ body: JSON.stringify({
652
+ url: originalUrl,
653
+ method: originalMethod,
654
+ body: originalBody
655
+ })
656
+ });
657
+ };
658
+ }
659
+ function createProxyFetch(connectionId) {
660
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
661
+ return createSandboxProxyFetch(connectionId);
662
+ }
663
+ return createDeployedAppProxyFetch(connectionId);
664
+ }
665
+
666
+ // src/connectors/create-connector-sdk.ts
667
+ function loadConnectionsSync() {
668
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
669
+ try {
670
+ const raw = readFileSync(filePath, "utf-8");
671
+ return JSON.parse(raw);
672
+ } catch {
673
+ return {};
674
+ }
675
+ }
676
+ function createConnectorSdk(plugin, createClient2) {
677
+ return (connectionId) => {
678
+ const connections = loadConnectionsSync();
679
+ const entry = connections[connectionId];
680
+ if (!entry) {
681
+ throw new Error(
682
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
683
+ );
684
+ }
685
+ if (entry.connector.slug !== plugin.slug) {
686
+ throw new Error(
687
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
688
+ );
689
+ }
690
+ const params = {};
691
+ for (const param of Object.values(plugin.parameters)) {
692
+ if (param.required) {
693
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
694
+ } else {
695
+ const val = resolveEnvVarOptional(entry, param.slug);
696
+ if (val !== void 0) params[param.slug] = val;
697
+ }
698
+ }
699
+ return createClient2(params, createProxyFetch(connectionId));
700
+ };
701
+ }
702
+
703
+ // src/connectors/entries/google-sheets.ts
704
+ var connection = createConnectorSdk(googleSheetsConnector, createClient);
705
+ export {
706
+ connection
707
+ };