@squadbase/vite-server 0.1.3-dev.15 → 0.1.3-dev.16

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 (59) hide show
  1. package/dist/cli/index.js +2105 -2700
  2. package/dist/connectors/airtable-oauth.js +16 -5
  3. package/dist/connectors/airtable.js +16 -5
  4. package/dist/connectors/amplitude.js +16 -5
  5. package/dist/connectors/anthropic.js +16 -5
  6. package/dist/connectors/asana.js +16 -5
  7. package/dist/connectors/attio.js +16 -5
  8. package/dist/connectors/backlog-api-key.js +16 -5
  9. package/dist/connectors/customerio.js +16 -5
  10. package/dist/connectors/dbt.js +16 -5
  11. package/dist/connectors/gamma.js +16 -5
  12. package/dist/connectors/gemini.js +16 -5
  13. package/dist/connectors/gmail-oauth.js +16 -5
  14. package/dist/connectors/gmail.js +68 -34
  15. package/dist/connectors/google-ads.js +16 -5
  16. package/dist/connectors/google-analytics-oauth.js +16 -5
  17. package/dist/connectors/google-analytics.js +16 -5
  18. package/dist/connectors/google-calendar-oauth.js +16 -5
  19. package/dist/connectors/google-calendar.js +71 -48
  20. package/dist/connectors/{google-drive-oauth.d.ts → google-docs.d.ts} +1 -1
  21. package/dist/connectors/google-docs.js +585 -0
  22. package/dist/connectors/google-drive.d.ts +1 -1
  23. package/dist/connectors/google-drive.js +391 -327
  24. package/dist/connectors/google-sheets.d.ts +1 -1
  25. package/dist/connectors/google-sheets.js +210 -280
  26. package/dist/connectors/google-slides.d.ts +1 -1
  27. package/dist/connectors/google-slides.js +198 -335
  28. package/dist/connectors/grafana.js +16 -5
  29. package/dist/connectors/hubspot-oauth.js +16 -5
  30. package/dist/connectors/hubspot.js +16 -5
  31. package/dist/connectors/intercom-oauth.js +16 -5
  32. package/dist/connectors/intercom.js +16 -5
  33. package/dist/connectors/jira-api-key.js +16 -5
  34. package/dist/connectors/kintone-api-token.js +133 -59
  35. package/dist/connectors/kintone.js +16 -5
  36. package/dist/connectors/linkedin-ads.js +16 -5
  37. package/dist/connectors/mailchimp-oauth.js +16 -5
  38. package/dist/connectors/mailchimp.js +16 -5
  39. package/dist/connectors/mixpanel.js +16 -5
  40. package/dist/connectors/notion-oauth.js +16 -5
  41. package/dist/connectors/notion.js +16 -5
  42. package/dist/connectors/openai.js +16 -5
  43. package/dist/connectors/sentry.js +16 -5
  44. package/dist/connectors/shopify-oauth.js +16 -5
  45. package/dist/connectors/shopify.js +16 -5
  46. package/dist/connectors/stripe-api-key.js +16 -5
  47. package/dist/connectors/stripe-oauth.js +16 -5
  48. package/dist/connectors/wix-store.js +16 -5
  49. package/dist/connectors/zendesk-oauth.js +16 -5
  50. package/dist/connectors/zendesk.js +16 -5
  51. package/dist/index.js +2100 -2695
  52. package/dist/main.js +2100 -2695
  53. package/dist/vite-plugin.js +2100 -2695
  54. package/package.json +7 -15
  55. package/dist/connectors/google-drive-oauth.js +0 -879
  56. package/dist/connectors/google-sheets-oauth.d.ts +0 -5
  57. package/dist/connectors/google-sheets-oauth.js +0 -821
  58. package/dist/connectors/google-slides-oauth.d.ts +0 -5
  59. package/dist/connectors/google-slides-oauth.js +0 -742
@@ -0,0 +1,585 @@
1
+ // ../connectors/src/connectors/google-docs/sdk/index.ts
2
+ var DOCS_BASE_URL = "https://docs.googleapis.com/v1/documents";
3
+ function createClient(_params, fetchFn = fetch) {
4
+ function request(path2, init) {
5
+ const url = `${DOCS_BASE_URL}${path2 === "" || path2.startsWith("/") ? "" : "/"}${path2}`;
6
+ return fetchFn(url, init);
7
+ }
8
+ async function getDocument(documentId) {
9
+ const url = `${DOCS_BASE_URL}/${documentId}`;
10
+ const response = await fetchFn(url);
11
+ if (!response.ok) {
12
+ const body = await response.text();
13
+ throw new Error(
14
+ `google-docs: getDocument failed (${response.status}): ${body}`
15
+ );
16
+ }
17
+ return await response.json();
18
+ }
19
+ async function batchUpdate(documentId, requests) {
20
+ const url = `${DOCS_BASE_URL}/${documentId}:batchUpdate`;
21
+ const response = await fetchFn(url, {
22
+ method: "POST",
23
+ headers: { "Content-Type": "application/json" },
24
+ body: JSON.stringify({ requests })
25
+ });
26
+ if (!response.ok) {
27
+ const body = await response.text();
28
+ throw new Error(
29
+ `google-docs: batchUpdate failed (${response.status}): ${body}`
30
+ );
31
+ }
32
+ return await response.json();
33
+ }
34
+ async function createDocument(title) {
35
+ const url = DOCS_BASE_URL;
36
+ const response = await fetchFn(url, {
37
+ method: "POST",
38
+ headers: { "Content-Type": "application/json" },
39
+ body: JSON.stringify({ title })
40
+ });
41
+ if (!response.ok) {
42
+ const body = await response.text();
43
+ throw new Error(
44
+ `google-docs: createDocument failed (${response.status}): ${body}`
45
+ );
46
+ }
47
+ return await response.json();
48
+ }
49
+ return {
50
+ request,
51
+ getDocument,
52
+ batchUpdate,
53
+ createDocument
54
+ };
55
+ }
56
+
57
+ // ../connectors/src/connector-onboarding.ts
58
+ var ConnectorOnboarding = class {
59
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
60
+ connectionSetupInstructions;
61
+ /** Phase 2: Data overview instructions */
62
+ dataOverviewInstructions;
63
+ constructor(config) {
64
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
65
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
66
+ }
67
+ getConnectionSetupPrompt(language) {
68
+ return this.connectionSetupInstructions?.[language] ?? null;
69
+ }
70
+ getDataOverviewInstructions(language) {
71
+ return this.dataOverviewInstructions[language];
72
+ }
73
+ };
74
+
75
+ // ../connectors/src/connector-tool.ts
76
+ var ConnectorTool = class {
77
+ name;
78
+ description;
79
+ inputSchema;
80
+ outputSchema;
81
+ _execute;
82
+ constructor(config) {
83
+ this.name = config.name;
84
+ this.description = config.description;
85
+ this.inputSchema = config.inputSchema;
86
+ this.outputSchema = config.outputSchema;
87
+ this._execute = config.execute;
88
+ }
89
+ createTool(connections, config) {
90
+ return {
91
+ description: this.description,
92
+ inputSchema: this.inputSchema,
93
+ outputSchema: this.outputSchema,
94
+ execute: (input) => this._execute(input, connections, config)
95
+ };
96
+ }
97
+ };
98
+
99
+ // ../connectors/src/connector-plugin.ts
100
+ var ConnectorPlugin = class _ConnectorPlugin {
101
+ slug;
102
+ authType;
103
+ name;
104
+ description;
105
+ iconUrl;
106
+ parameters;
107
+ releaseFlag;
108
+ proxyPolicy;
109
+ experimentalAttributes;
110
+ onboarding;
111
+ systemPrompt;
112
+ tools;
113
+ query;
114
+ checkConnection;
115
+ constructor(config) {
116
+ this.slug = config.slug;
117
+ this.authType = config.authType;
118
+ this.name = config.name;
119
+ this.description = config.description;
120
+ this.iconUrl = config.iconUrl;
121
+ this.parameters = config.parameters;
122
+ this.releaseFlag = config.releaseFlag;
123
+ this.proxyPolicy = config.proxyPolicy;
124
+ this.experimentalAttributes = config.experimentalAttributes;
125
+ this.onboarding = config.onboarding;
126
+ this.systemPrompt = config.systemPrompt;
127
+ this.tools = config.tools;
128
+ this.query = config.query;
129
+ this.checkConnection = config.checkConnection;
130
+ }
131
+ get connectorKey() {
132
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
133
+ }
134
+ /**
135
+ * Create tools for connections that belong to this connector.
136
+ * Filters connections by connectorKey internally.
137
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
138
+ */
139
+ createTools(connections, config, opts) {
140
+ const myConnections = connections.filter(
141
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
142
+ );
143
+ const result = {};
144
+ for (const t of Object.values(this.tools)) {
145
+ const tool = t.createTool(myConnections, config);
146
+ const originalToModelOutput = tool.toModelOutput;
147
+ result[`${this.connectorKey}_${t.name}`] = {
148
+ ...tool,
149
+ toModelOutput: async (options) => {
150
+ if (!originalToModelOutput) {
151
+ return opts.truncateOutput(options.output);
152
+ }
153
+ const modelOutput = await originalToModelOutput(options);
154
+ if (modelOutput.type === "text" || modelOutput.type === "json") {
155
+ return opts.truncateOutput(modelOutput.value);
156
+ }
157
+ return modelOutput;
158
+ }
159
+ };
160
+ }
161
+ return result;
162
+ }
163
+ static deriveKey(slug, authType) {
164
+ return authType ? `${slug}-${authType}` : slug;
165
+ }
166
+ };
167
+
168
+ // ../connectors/src/auth-types.ts
169
+ var AUTH_TYPES = {
170
+ OAUTH: "oauth",
171
+ API_KEY: "api-key",
172
+ JWT: "jwt",
173
+ SERVICE_ACCOUNT: "service-account",
174
+ PAT: "pat",
175
+ USER_PASSWORD: "user-password"
176
+ };
177
+
178
+ // ../connectors/src/connectors/google-docs/setup.ts
179
+ var googleDocsOnboarding = new ConnectorOnboarding({
180
+ dataOverviewInstructions: {
181
+ en: `1. Create a new document with google-docs_request (POST with body { title: "..." }) or use an existing document ID.
182
+ 2. Call google-docs_request with GET /{documentId} to fetch the document's content and metadata.`,
183
+ ja: `1. google-docs_request \u3092 POST\uFF08Body: { title: "..." }\uFF09\u3067\u547C\u3073\u51FA\u3057\u3066\u65B0\u3057\u3044\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u4F5C\u6210\u3059\u308B\u304B\u3001\u65E2\u5B58\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8ID\u3092\u5229\u7528\u3057\u307E\u3059\u3002
184
+ 2. google-docs_request \u3067 GET /{documentId} \u3092\u547C\u3073\u51FA\u3057\u3001\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u5185\u5BB9\u3068\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002`
185
+ }
186
+ });
187
+
188
+ // ../connectors/src/connectors/google-docs/parameters.ts
189
+ var parameters = {};
190
+
191
+ // ../connectors/src/connectors/google-docs/tools/request.ts
192
+ import { z } from "zod";
193
+ var DOCS_BASE_URL2 = "https://docs.googleapis.com/v1/documents";
194
+ var REQUEST_TIMEOUT_MS = 6e4;
195
+ var cachedToken = null;
196
+ async function getProxyToken(config) {
197
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
198
+ return cachedToken.token;
199
+ }
200
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
201
+ const res = await fetch(url, {
202
+ method: "POST",
203
+ headers: {
204
+ "Content-Type": "application/json",
205
+ "x-api-key": config.appApiKey,
206
+ "project-id": config.projectId
207
+ },
208
+ body: JSON.stringify({
209
+ sandboxId: config.sandboxId,
210
+ issuedBy: "coding-agent"
211
+ })
212
+ });
213
+ if (!res.ok) {
214
+ const errorText = await res.text().catch(() => res.statusText);
215
+ throw new Error(
216
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
217
+ );
218
+ }
219
+ const data = await res.json();
220
+ cachedToken = {
221
+ token: data.token,
222
+ expiresAt: new Date(data.expiresAt).getTime()
223
+ };
224
+ return data.token;
225
+ }
226
+ var inputSchema = z.object({
227
+ toolUseIntent: z.string().optional().describe(
228
+ "Brief description of what you intend to accomplish with this tool call"
229
+ ),
230
+ connectionId: z.string().describe("ID of the Google Docs connection to use"),
231
+ method: z.enum(["GET", "POST"]).describe("HTTP method"),
232
+ path: z.string().describe(
233
+ "API path appended to https://docs.googleapis.com/v1/documents (e.g., '', '/{documentId}', '/{documentId}:batchUpdate')."
234
+ ),
235
+ body: z.record(z.string(), z.unknown()).optional().describe("JSON request body for POST requests"),
236
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL")
237
+ });
238
+ var outputSchema = z.discriminatedUnion("success", [
239
+ z.object({
240
+ success: z.literal(true),
241
+ status: z.number(),
242
+ data: z.record(z.string(), z.unknown())
243
+ }),
244
+ z.object({
245
+ success: z.literal(false),
246
+ error: z.string()
247
+ })
248
+ ]);
249
+ var requestTool = new ConnectorTool({
250
+ name: "request",
251
+ description: `Send authenticated requests to the Google Docs API v1.
252
+ Supports GET (read) and POST (create/update) methods.
253
+ Authentication is handled automatically via OAuth proxy.`,
254
+ inputSchema,
255
+ outputSchema,
256
+ async execute({ connectionId, method, path: path2, body, queryParams }, connections, config) {
257
+ const connection2 = connections.find((c) => c.id === connectionId);
258
+ if (!connection2) {
259
+ return {
260
+ success: false,
261
+ error: `Connection ${connectionId} not found`
262
+ };
263
+ }
264
+ console.log(
265
+ `[connector-request] google-docs/${connection2.name}: ${method} ${path2}`
266
+ );
267
+ try {
268
+ let url = `${DOCS_BASE_URL2}${path2 === "" || path2.startsWith("/") ? "" : "/"}${path2}`;
269
+ if (queryParams) {
270
+ const searchParams = new URLSearchParams(queryParams);
271
+ url += `?${searchParams.toString()}`;
272
+ }
273
+ const token = await getProxyToken(config.oauthProxy);
274
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
275
+ const controller = new AbortController();
276
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
277
+ try {
278
+ const response = await fetch(proxyUrl, {
279
+ method: "POST",
280
+ headers: {
281
+ "Content-Type": "application/json",
282
+ Authorization: `Bearer ${token}`
283
+ },
284
+ body: JSON.stringify({
285
+ url,
286
+ method,
287
+ ...body != null ? { body: JSON.stringify(body) } : {}
288
+ }),
289
+ signal: controller.signal
290
+ });
291
+ const data = await response.json();
292
+ if (!response.ok) {
293
+ const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`;
294
+ return { success: false, error: errorMessage };
295
+ }
296
+ return { success: true, status: response.status, data };
297
+ } finally {
298
+ clearTimeout(timeout);
299
+ }
300
+ } catch (err) {
301
+ const msg = err instanceof Error ? err.message : String(err);
302
+ return { success: false, error: msg };
303
+ }
304
+ }
305
+ });
306
+
307
+ // ../connectors/src/connectors/google-docs/index.ts
308
+ var tools = { request: requestTool };
309
+ var googleDocsConnector = new ConnectorPlugin({
310
+ slug: "google-docs",
311
+ authType: AUTH_TYPES.OAUTH,
312
+ name: "Google Docs",
313
+ description: "Connect to Google Docs for document data access and creation using OAuth.",
314
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4oyF4yTRpemMA43X49masx/e1582d25e3b4c9a63ba83df2147c1968/google_slide.png",
315
+ parameters,
316
+ releaseFlag: { dev1: true, dev2: false, prod: false },
317
+ onboarding: googleDocsOnboarding,
318
+ proxyPolicy: {
319
+ allowlist: [
320
+ {
321
+ host: "docs.googleapis.com",
322
+ methods: ["GET", "POST"]
323
+ }
324
+ ]
325
+ },
326
+ systemPrompt: {
327
+ en: `### Tools
328
+
329
+ - \`google-docs_request\`: The way to call the Google Docs API. Supports read and write operations. Use it to get document content, create new documents, and modify document content via batchUpdate. Authentication is configured automatically via OAuth.
330
+
331
+ ### Google Docs API Reference
332
+
333
+ #### Read Endpoints
334
+ - GET \`/{documentId}\` \u2014 Get the document's content and metadata (title, body, revisionId, styles)
335
+
336
+ #### Write Endpoints
337
+ - POST \`\` (empty path, with body) \u2014 Create a new document. Body: \`{ "title": "My Document" }\`
338
+ - POST \`/{documentId}:batchUpdate\` \u2014 Apply multiple updates to a document. Body: \`{ "requests": [...] }\`
339
+
340
+ #### Common batchUpdate Request Types
341
+ - \`insertText\` \u2014 Insert text at a location: \`{ "insertText": { "location": { "index": 1 }, "text": "Hello" } }\`
342
+ - \`deleteContentRange\` \u2014 Delete a range of content: \`{ "deleteContentRange": { "range": { "startIndex": 1, "endIndex": 5 } } }\`
343
+ - \`replaceAllText\` \u2014 Find & replace text: \`{ "replaceAllText": { "containsText": { "text": "old" }, "replaceText": "new" } }\`
344
+ - \`updateTextStyle\` \u2014 Style text (bold, color, font): \`{ "updateTextStyle": { "range": { "startIndex": 1, "endIndex": 5 }, "textStyle": { "bold": true }, "fields": "bold" } }\`
345
+ - \`updateParagraphStyle\` \u2014 Update paragraph style (alignment, indentation, etc.)
346
+ - \`insertTable\` \u2014 Insert a table: \`{ "insertTable": { "location": { "index": 1 }, "rows": 3, "columns": 2 } }\`
347
+ - \`insertInlineImage\` \u2014 Insert an image: \`{ "insertInlineImage": { "location": { "index": 1 }, "uri": "https://..." } }\`
348
+ - \`createParagraphBullets\` / \`deleteParagraphBullets\` \u2014 Add or remove bullets
349
+
350
+ ### Tips
351
+ - Indexes in the Docs API are 1-based and reference the document body positions (including newlines)
352
+ - To explore a document, first GET the document to get its body structure and element indexes
353
+ - batchUpdate requests are applied in order \u2014 use this for complex multi-step modifications
354
+ - Sharing (permissions) cannot be done via this connector; only the OAuth user has access to the created documents
355
+
356
+ ### Business Logic
357
+
358
+ 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.
359
+
360
+ #### Example
361
+
362
+ \`\`\`ts
363
+ import { connection } from "@squadbase/vite-server/connectors/google-docs";
364
+
365
+ const docs = connection("<connectionId>");
366
+
367
+ // Create a new document
368
+ const newDoc = await docs.createDocument("Quarterly Report");
369
+ const documentId = newDoc.documentId;
370
+
371
+ // Get document metadata and content
372
+ const document = await docs.getDocument(documentId);
373
+ console.log(document.title);
374
+
375
+ // Insert text and style it
376
+ await docs.batchUpdate(documentId, [
377
+ { insertText: { location: { index: 1 }, text: "Hello, World!" } },
378
+ { updateTextStyle: {
379
+ range: { startIndex: 1, endIndex: 13 },
380
+ textStyle: { bold: true },
381
+ fields: "bold",
382
+ }
383
+ },
384
+ ]);
385
+ \`\`\``,
386
+ ja: `### \u30C4\u30FC\u30EB
387
+
388
+ - \`google-docs_request\`: Google Docs API\u3092\u547C\u3073\u51FA\u3059\u624B\u6BB5\u3067\u3059\u3002\u8AAD\u307F\u53D6\u308A\u3068\u66F8\u304D\u8FBC\u307F\u306E\u4E21\u65B9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u5185\u5BB9\u306E\u53D6\u5F97\u3001\u65B0\u3057\u3044\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u4F5C\u6210\u3001batchUpdate \u306B\u3088\u308B\u5185\u5BB9\u5909\u66F4\u306A\u3069\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
389
+
390
+ ### Google Docs API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
391
+
392
+ #### \u8AAD\u307F\u53D6\u308A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
393
+ - GET \`/{documentId}\` \u2014 \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u5185\u5BB9\u3068\u30E1\u30BF\u30C7\u30FC\u30BF\uFF08\u30BF\u30A4\u30C8\u30EB\u3001body\u3001revisionId\u3001\u30B9\u30BF\u30A4\u30EB\uFF09\u3092\u53D6\u5F97
394
+
395
+ #### \u66F8\u304D\u8FBC\u307F\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
396
+ - POST \`\`\uFF08\u7A7A\u30D1\u30B9\u3001\u30DC\u30C7\u30A3\u4ED8\u304D\uFF09\u2014 \u65B0\u3057\u3044\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u4F5C\u6210\u3002Body: \`{ "title": "\u30DE\u30A4\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8" }\`
397
+ - POST \`/{documentId}:batchUpdate\` \u2014 \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306B\u8907\u6570\u306E\u66F4\u65B0\u3092\u9069\u7528\u3002Body: \`{ "requests": [...] }\`
398
+
399
+ #### \u4E3B\u306A batchUpdate \u30EA\u30AF\u30A8\u30B9\u30C8\u30BF\u30A4\u30D7
400
+ - \`insertText\` \u2014 \u6307\u5B9A\u4F4D\u7F6E\u306B\u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165: \`{ "insertText": { "location": { "index": 1 }, "text": "Hello" } }\`
401
+ - \`deleteContentRange\` \u2014 \u7BC4\u56F2\u306E\u5185\u5BB9\u3092\u524A\u9664: \`{ "deleteContentRange": { "range": { "startIndex": 1, "endIndex": 5 } } }\`
402
+ - \`replaceAllText\` \u2014 \u30C6\u30AD\u30B9\u30C8\u306E\u691C\u7D22\u3068\u7F6E\u63DB: \`{ "replaceAllText": { "containsText": { "text": "\u53E4\u3044" }, "replaceText": "\u65B0\u3057\u3044" } }\`
403
+ - \`updateTextStyle\` \u2014 \u30C6\u30AD\u30B9\u30C8\u306E\u30B9\u30BF\u30A4\u30EB\u8A2D\u5B9A\uFF08\u592A\u5B57\u3001\u8272\u3001\u30D5\u30A9\u30F3\u30C8\uFF09: \`{ "updateTextStyle": { "range": { "startIndex": 1, "endIndex": 5 }, "textStyle": { "bold": true }, "fields": "bold" } }\`
404
+ - \`updateParagraphStyle\` \u2014 \u6BB5\u843D\u30B9\u30BF\u30A4\u30EB\u3092\u66F4\u65B0\uFF08\u914D\u7F6E\u3001\u30A4\u30F3\u30C7\u30F3\u30C8\u7B49\uFF09
405
+ - \`insertTable\` \u2014 \u30C6\u30FC\u30D6\u30EB\u3092\u633F\u5165: \`{ "insertTable": { "location": { "index": 1 }, "rows": 3, "columns": 2 } }\`
406
+ - \`insertInlineImage\` \u2014 \u753B\u50CF\u3092\u633F\u5165: \`{ "insertInlineImage": { "location": { "index": 1 }, "uri": "https://..." } }\`
407
+ - \`createParagraphBullets\` / \`deleteParagraphBullets\` \u2014 \u7B87\u6761\u66F8\u304D\u306E\u8FFD\u52A0\u30FB\u524A\u9664
408
+
409
+ ### \u30D2\u30F3\u30C8
410
+ - Docs API \u306E\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u306F 1-based \u3067\u3001\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u672C\u6587\u306E\u4F4D\u7F6E\uFF08\u6539\u884C\u3082\u542B\u3080\uFF09\u3092\u53C2\u7167\u3057\u307E\u3059
411
+ - \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u63A2\u7D22\u3059\u308B\u306B\u306F\u3001\u307E\u305A GET \u3067\u53D6\u5F97\u3057\u3066\u672C\u6587\u69CB\u9020\u3068\u8981\u7D20\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u3092\u78BA\u8A8D\u3057\u307E\u3059
412
+ - batchUpdate \u30EA\u30AF\u30A8\u30B9\u30C8\u306F\u9806\u756A\u306B\u9069\u7528\u3055\u308C\u307E\u3059 \u2014 \u8907\u96D1\u306A\u8907\u6570\u30B9\u30C6\u30C3\u30D7\u306E\u5909\u66F4\u306B\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044
413
+ - \u5171\u6709\uFF08permissions\uFF09\u306F\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u7D4C\u7531\u3067\u306F\u884C\u3048\u307E\u305B\u3093\u3002\u4F5C\u6210\u3057\u305F\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3078\u306F\u63A5\u7D9A\u3057\u305FOAuth\u30E6\u30FC\u30B6\u30FC\u306E\u307F\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3059
414
+
415
+ ### Business Logic
416
+
417
+ \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
418
+
419
+ #### Example
420
+
421
+ \`\`\`ts
422
+ import { connection } from "@squadbase/vite-server/connectors/google-docs";
423
+
424
+ const docs = connection("<connectionId>");
425
+
426
+ // \u65B0\u3057\u3044\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u4F5C\u6210
427
+ const newDoc = await docs.createDocument("\u56DB\u534A\u671F\u30EC\u30DD\u30FC\u30C8");
428
+ const documentId = newDoc.documentId;
429
+
430
+ // \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3068\u5185\u5BB9\u3092\u53D6\u5F97
431
+ const document = await docs.getDocument(documentId);
432
+ console.log(document.title);
433
+
434
+ // \u30C6\u30AD\u30B9\u30C8\u3092\u633F\u5165\u3057\u3066\u30B9\u30BF\u30A4\u30EB\u3092\u9069\u7528
435
+ await docs.batchUpdate(documentId, [
436
+ { insertText: { location: { index: 1 }, text: "Hello, World!" } },
437
+ { updateTextStyle: {
438
+ range: { startIndex: 1, endIndex: 13 },
439
+ textStyle: { bold: true },
440
+ fields: "bold",
441
+ }
442
+ },
443
+ ]);
444
+ \`\`\``
445
+ },
446
+ tools
447
+ });
448
+
449
+ // src/connectors/create-connector-sdk.ts
450
+ import { readFileSync } from "fs";
451
+ import path from "path";
452
+
453
+ // src/connector-client/env.ts
454
+ function resolveEnvVar(entry, key, connectionId) {
455
+ const envVarName = entry.envVars[key];
456
+ if (!envVarName) {
457
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
458
+ }
459
+ const value = process.env[envVarName];
460
+ if (!value) {
461
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
462
+ }
463
+ return value;
464
+ }
465
+ function resolveEnvVarOptional(entry, key) {
466
+ const envVarName = entry.envVars[key];
467
+ if (!envVarName) return void 0;
468
+ return process.env[envVarName] || void 0;
469
+ }
470
+
471
+ // src/connector-client/proxy-fetch.ts
472
+ import { getContext } from "hono/context-storage";
473
+ import { getCookie } from "hono/cookie";
474
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
475
+ function createSandboxProxyFetch(connectionId) {
476
+ return async (input, init) => {
477
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
478
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
479
+ if (!token || !sandboxId) {
480
+ throw new Error(
481
+ "Connection proxy is not configured. Please check your deployment settings."
482
+ );
483
+ }
484
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
485
+ const originalMethod = init?.method ?? "GET";
486
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
487
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
488
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
489
+ return fetch(proxyUrl, {
490
+ method: "POST",
491
+ headers: {
492
+ "Content-Type": "application/json",
493
+ Authorization: `Bearer ${token}`
494
+ },
495
+ body: JSON.stringify({
496
+ url: originalUrl,
497
+ method: originalMethod,
498
+ body: originalBody
499
+ })
500
+ });
501
+ };
502
+ }
503
+ function createDeployedAppProxyFetch(connectionId) {
504
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
505
+ if (!projectId) {
506
+ throw new Error(
507
+ "Connection proxy is not configured. Please check your deployment settings."
508
+ );
509
+ }
510
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
511
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
512
+ return async (input, init) => {
513
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
514
+ const originalMethod = init?.method ?? "GET";
515
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
516
+ const c = getContext();
517
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
518
+ if (!appSession) {
519
+ throw new Error(
520
+ "No authentication method available for connection proxy."
521
+ );
522
+ }
523
+ return fetch(proxyUrl, {
524
+ method: "POST",
525
+ headers: {
526
+ "Content-Type": "application/json",
527
+ Authorization: `Bearer ${appSession}`
528
+ },
529
+ body: JSON.stringify({
530
+ url: originalUrl,
531
+ method: originalMethod,
532
+ body: originalBody
533
+ })
534
+ });
535
+ };
536
+ }
537
+ function createProxyFetch(connectionId) {
538
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
539
+ return createSandboxProxyFetch(connectionId);
540
+ }
541
+ return createDeployedAppProxyFetch(connectionId);
542
+ }
543
+
544
+ // src/connectors/create-connector-sdk.ts
545
+ function loadConnectionsSync() {
546
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
547
+ try {
548
+ const raw = readFileSync(filePath, "utf-8");
549
+ return JSON.parse(raw);
550
+ } catch {
551
+ return {};
552
+ }
553
+ }
554
+ function createConnectorSdk(plugin, createClient2) {
555
+ return (connectionId) => {
556
+ const connections = loadConnectionsSync();
557
+ const entry = connections[connectionId];
558
+ if (!entry) {
559
+ throw new Error(
560
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
561
+ );
562
+ }
563
+ if (entry.connector.slug !== plugin.slug) {
564
+ throw new Error(
565
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
566
+ );
567
+ }
568
+ const params = {};
569
+ for (const param of Object.values(plugin.parameters)) {
570
+ if (param.required) {
571
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
572
+ } else {
573
+ const val = resolveEnvVarOptional(entry, param.slug);
574
+ if (val !== void 0) params[param.slug] = val;
575
+ }
576
+ }
577
+ return createClient2(params, createProxyFetch(connectionId));
578
+ };
579
+ }
580
+
581
+ // src/connectors/entries/google-docs.ts
582
+ var connection = createConnectorSdk(googleDocsConnector, createClient);
583
+ export {
584
+ connection
585
+ };
@@ -1,5 +1,5 @@
1
1
  import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
2
 
3
- declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleDriveServiceAccountConnectorSdk;
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleDriveConnectorSdk;
4
4
 
5
5
  export { connection };