@squadbase/vite-server 0.1.3-dev.9 → 0.1.4-dev.0

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