@squadbase/vite-server 0.1.3-dev.3 → 0.1.3-dev.5

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 (50) hide show
  1. package/dist/cli/index.js +2511 -2128
  2. package/dist/connectors/airtable-oauth.js +3 -2
  3. package/dist/connectors/airtable.js +11 -1
  4. package/dist/connectors/amplitude.js +11 -1
  5. package/dist/connectors/anthropic.js +11 -1
  6. package/dist/connectors/asana.js +11 -1
  7. package/dist/connectors/attio.js +11 -1
  8. package/dist/connectors/customerio.js +11 -1
  9. package/dist/connectors/dbt.js +11 -1
  10. package/dist/connectors/gemini.js +11 -1
  11. package/dist/connectors/gmail-oauth.js +3 -2
  12. package/dist/connectors/google-ads-oauth.js +3 -2
  13. package/dist/connectors/google-ads.js +11 -1
  14. package/dist/connectors/google-analytics-oauth.js +3 -2
  15. package/dist/connectors/google-analytics.js +11 -1
  16. package/dist/connectors/{microsoft-teams.d.ts → google-calendar-oauth.d.ts} +1 -1
  17. package/dist/connectors/google-calendar-oauth.js +744 -0
  18. package/dist/connectors/{slack.d.ts → google-calendar.d.ts} +1 -1
  19. package/dist/connectors/google-calendar.js +655 -0
  20. package/dist/connectors/google-sheets-oauth.js +3 -2
  21. package/dist/connectors/google-sheets.js +11 -1
  22. package/dist/connectors/hubspot-oauth.js +3 -2
  23. package/dist/connectors/hubspot.js +5 -4
  24. package/dist/connectors/intercom-oauth.js +3 -2
  25. package/dist/connectors/intercom.js +11 -1
  26. package/dist/connectors/jira-api-key.js +3 -2
  27. package/dist/connectors/kintone-api-token.js +3 -2
  28. package/dist/connectors/kintone.js +12 -2
  29. package/dist/connectors/linkedin-ads-oauth.js +3 -2
  30. package/dist/connectors/linkedin-ads.js +11 -1
  31. package/dist/connectors/mailchimp-oauth.js +2 -1
  32. package/dist/connectors/mailchimp.js +11 -1
  33. package/dist/connectors/notion-oauth.js +3 -2
  34. package/dist/connectors/notion.js +11 -1
  35. package/dist/connectors/openai.js +11 -1
  36. package/dist/connectors/shopify-oauth.js +3 -2
  37. package/dist/connectors/shopify.js +11 -1
  38. package/dist/connectors/{microsoft-teams-oauth.d.ts → stripe-api-key.d.ts} +1 -1
  39. package/dist/connectors/stripe-api-key.js +527 -0
  40. package/dist/connectors/stripe-oauth.js +3 -2
  41. package/dist/connectors/wix-store.js +11 -1
  42. package/dist/connectors/zendesk-oauth.js +3 -2
  43. package/dist/connectors/zendesk.js +11 -1
  44. package/dist/index.js +2508 -2125
  45. package/dist/main.js +2508 -2125
  46. package/dist/vite-plugin.js +2508 -2125
  47. package/package.json +13 -1
  48. package/dist/connectors/microsoft-teams-oauth.js +0 -479
  49. package/dist/connectors/microsoft-teams.js +0 -381
  50. package/dist/connectors/slack.js +0 -362
@@ -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.SlackConnectorSdk;
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleCalendarConnectorSdk;
4
4
 
5
5
  export { connection };
@@ -0,0 +1,655 @@
1
+ // ../connectors/src/parameter-definition.ts
2
+ var ParameterDefinition = class {
3
+ slug;
4
+ name;
5
+ description;
6
+ envVarBaseKey;
7
+ type;
8
+ secret;
9
+ required;
10
+ constructor(config) {
11
+ this.slug = config.slug;
12
+ this.name = config.name;
13
+ this.description = config.description;
14
+ this.envVarBaseKey = config.envVarBaseKey;
15
+ this.type = config.type;
16
+ this.secret = config.secret;
17
+ this.required = config.required;
18
+ }
19
+ /**
20
+ * Get the parameter value from a ConnectorConnectionObject.
21
+ */
22
+ getValue(connection2) {
23
+ const param = connection2.parameters.find(
24
+ (p) => p.parameterSlug === this.slug
25
+ );
26
+ if (!param || param.value == null) {
27
+ throw new Error(
28
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
29
+ );
30
+ }
31
+ return param.value;
32
+ }
33
+ /**
34
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
35
+ */
36
+ tryGetValue(connection2) {
37
+ const param = connection2.parameters.find(
38
+ (p) => p.parameterSlug === this.slug
39
+ );
40
+ if (!param || param.value == null) return void 0;
41
+ return param.value;
42
+ }
43
+ };
44
+
45
+ // ../connectors/src/connectors/google-calendar/sdk/index.ts
46
+ import * as crypto from "crypto";
47
+
48
+ // ../connectors/src/connectors/google-calendar/parameters.ts
49
+ var parameters = {
50
+ serviceAccountKeyJsonBase64: new ParameterDefinition({
51
+ slug: "service-account-key-json-base64",
52
+ name: "Google Cloud Service Account JSON",
53
+ 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 Calendar, and that calendars are shared with the service account email.",
54
+ envVarBaseKey: "GOOGLE_CALENDAR_SERVICE_ACCOUNT_JSON_BASE64",
55
+ type: "base64EncodedJson",
56
+ secret: true,
57
+ required: true
58
+ }),
59
+ calendarId: new ParameterDefinition({
60
+ slug: "calendar-id",
61
+ name: "Default Calendar ID",
62
+ description: "The default Google Calendar ID to use (e.g., 'primary' or an email address like 'user@example.com'). If not set, 'primary' is used.",
63
+ envVarBaseKey: "GOOGLE_CALENDAR_CALENDAR_ID",
64
+ type: "text",
65
+ secret: false,
66
+ required: false
67
+ })
68
+ };
69
+
70
+ // ../connectors/src/connectors/google-calendar/sdk/index.ts
71
+ var TOKEN_URL = "https://oauth2.googleapis.com/token";
72
+ var BASE_URL = "https://www.googleapis.com/calendar/v3";
73
+ var SCOPE = "https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events.readonly";
74
+ function base64url(input) {
75
+ const buf = typeof input === "string" ? Buffer.from(input) : input;
76
+ return buf.toString("base64url");
77
+ }
78
+ function buildJwt(clientEmail, privateKey, nowSec) {
79
+ const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
80
+ const payload = base64url(
81
+ JSON.stringify({
82
+ iss: clientEmail,
83
+ scope: SCOPE,
84
+ aud: TOKEN_URL,
85
+ iat: nowSec,
86
+ exp: nowSec + 3600
87
+ })
88
+ );
89
+ const signingInput = `${header}.${payload}`;
90
+ const sign = crypto.createSign("RSA-SHA256");
91
+ sign.update(signingInput);
92
+ sign.end();
93
+ const signature = base64url(sign.sign(privateKey));
94
+ return `${signingInput}.${signature}`;
95
+ }
96
+ function createClient(params) {
97
+ const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
98
+ const defaultCalendarId = params[parameters.calendarId.slug] ?? "primary";
99
+ if (!serviceAccountKeyJsonBase64) {
100
+ throw new Error(
101
+ `google-calendar: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
102
+ );
103
+ }
104
+ let serviceAccountKey;
105
+ try {
106
+ const decoded = Buffer.from(
107
+ serviceAccountKeyJsonBase64,
108
+ "base64"
109
+ ).toString("utf-8");
110
+ serviceAccountKey = JSON.parse(decoded);
111
+ } catch {
112
+ throw new Error(
113
+ "google-calendar: failed to decode service account key JSON from base64"
114
+ );
115
+ }
116
+ if (!serviceAccountKey.client_email || !serviceAccountKey.private_key) {
117
+ throw new Error(
118
+ "google-calendar: service account key JSON must contain client_email and private_key"
119
+ );
120
+ }
121
+ let cachedToken = null;
122
+ let tokenExpiresAt = 0;
123
+ async function getAccessToken() {
124
+ const nowSec = Math.floor(Date.now() / 1e3);
125
+ if (cachedToken && nowSec < tokenExpiresAt - 60) {
126
+ return cachedToken;
127
+ }
128
+ const jwt = buildJwt(
129
+ serviceAccountKey.client_email,
130
+ serviceAccountKey.private_key,
131
+ nowSec
132
+ );
133
+ const response = await fetch(TOKEN_URL, {
134
+ method: "POST",
135
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
136
+ body: new URLSearchParams({
137
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
138
+ assertion: jwt
139
+ })
140
+ });
141
+ if (!response.ok) {
142
+ const text = await response.text();
143
+ throw new Error(
144
+ `google-calendar: token exchange failed (${response.status}): ${text}`
145
+ );
146
+ }
147
+ const data = await response.json();
148
+ cachedToken = data.access_token;
149
+ tokenExpiresAt = nowSec + data.expires_in;
150
+ return cachedToken;
151
+ }
152
+ function resolveCalendarId(override) {
153
+ return override ?? defaultCalendarId;
154
+ }
155
+ return {
156
+ async request(path2, init) {
157
+ const accessToken = await getAccessToken();
158
+ const resolvedPath = path2.replace(
159
+ /\{calendarId\}/g,
160
+ defaultCalendarId
161
+ );
162
+ const url = `${BASE_URL}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
163
+ const headers = new Headers(init?.headers);
164
+ headers.set("Authorization", `Bearer ${accessToken}`);
165
+ return fetch(url, { ...init, headers });
166
+ },
167
+ async listCalendars() {
168
+ const response = await this.request("/users/me/calendarList", {
169
+ method: "GET"
170
+ });
171
+ if (!response.ok) {
172
+ const text = await response.text();
173
+ throw new Error(
174
+ `google-calendar: listCalendars failed (${response.status}): ${text}`
175
+ );
176
+ }
177
+ const data = await response.json();
178
+ return data.items ?? [];
179
+ },
180
+ async listEvents(options, calendarId) {
181
+ const cid = resolveCalendarId(calendarId);
182
+ const searchParams = new URLSearchParams();
183
+ if (options?.timeMin) searchParams.set("timeMin", options.timeMin);
184
+ if (options?.timeMax) searchParams.set("timeMax", options.timeMax);
185
+ if (options?.maxResults)
186
+ searchParams.set("maxResults", String(options.maxResults));
187
+ if (options?.q) searchParams.set("q", options.q);
188
+ if (options?.singleEvents != null)
189
+ searchParams.set("singleEvents", String(options.singleEvents));
190
+ if (options?.orderBy) searchParams.set("orderBy", options.orderBy);
191
+ if (options?.pageToken) searchParams.set("pageToken", options.pageToken);
192
+ const qs = searchParams.toString();
193
+ const path2 = `/calendars/${encodeURIComponent(cid)}/events${qs ? `?${qs}` : ""}`;
194
+ const response = await this.request(path2, { method: "GET" });
195
+ if (!response.ok) {
196
+ const text = await response.text();
197
+ throw new Error(
198
+ `google-calendar: listEvents failed (${response.status}): ${text}`
199
+ );
200
+ }
201
+ return await response.json();
202
+ },
203
+ async getEvent(eventId, calendarId) {
204
+ const cid = resolveCalendarId(calendarId);
205
+ const path2 = `/calendars/${encodeURIComponent(cid)}/events/${encodeURIComponent(eventId)}`;
206
+ const response = await this.request(path2, { method: "GET" });
207
+ if (!response.ok) {
208
+ const text = await response.text();
209
+ throw new Error(
210
+ `google-calendar: getEvent failed (${response.status}): ${text}`
211
+ );
212
+ }
213
+ return await response.json();
214
+ }
215
+ };
216
+ }
217
+
218
+ // ../connectors/src/connector-onboarding.ts
219
+ var ConnectorOnboarding = class {
220
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
221
+ connectionSetupInstructions;
222
+ /** Phase 2: Data overview instructions */
223
+ dataOverviewInstructions;
224
+ constructor(config) {
225
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
226
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
227
+ }
228
+ getConnectionSetupPrompt(language) {
229
+ return this.connectionSetupInstructions?.[language] ?? null;
230
+ }
231
+ getDataOverviewInstructions(language) {
232
+ return this.dataOverviewInstructions[language];
233
+ }
234
+ };
235
+
236
+ // ../connectors/src/connector-tool.ts
237
+ var ConnectorTool = class {
238
+ name;
239
+ description;
240
+ inputSchema;
241
+ outputSchema;
242
+ _execute;
243
+ constructor(config) {
244
+ this.name = config.name;
245
+ this.description = config.description;
246
+ this.inputSchema = config.inputSchema;
247
+ this.outputSchema = config.outputSchema;
248
+ this._execute = config.execute;
249
+ }
250
+ createTool(connections, config) {
251
+ return {
252
+ description: this.description,
253
+ inputSchema: this.inputSchema,
254
+ outputSchema: this.outputSchema,
255
+ execute: (input) => this._execute(input, connections, config)
256
+ };
257
+ }
258
+ };
259
+
260
+ // ../connectors/src/connector-plugin.ts
261
+ var ConnectorPlugin = class _ConnectorPlugin {
262
+ slug;
263
+ authType;
264
+ name;
265
+ description;
266
+ iconUrl;
267
+ parameters;
268
+ releaseFlag;
269
+ proxyPolicy;
270
+ experimentalAttributes;
271
+ onboarding;
272
+ systemPrompt;
273
+ tools;
274
+ query;
275
+ checkConnection;
276
+ constructor(config) {
277
+ this.slug = config.slug;
278
+ this.authType = config.authType;
279
+ this.name = config.name;
280
+ this.description = config.description;
281
+ this.iconUrl = config.iconUrl;
282
+ this.parameters = config.parameters;
283
+ this.releaseFlag = config.releaseFlag;
284
+ this.proxyPolicy = config.proxyPolicy;
285
+ this.experimentalAttributes = config.experimentalAttributes;
286
+ this.onboarding = config.onboarding;
287
+ this.systemPrompt = config.systemPrompt;
288
+ this.tools = config.tools;
289
+ this.query = config.query;
290
+ this.checkConnection = config.checkConnection;
291
+ }
292
+ get connectorKey() {
293
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
294
+ }
295
+ /**
296
+ * Create tools for connections that belong to this connector.
297
+ * Filters connections by connectorKey internally.
298
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
299
+ */
300
+ createTools(connections, config) {
301
+ const myConnections = connections.filter(
302
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
303
+ );
304
+ const result = {};
305
+ for (const t of Object.values(this.tools)) {
306
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
307
+ myConnections,
308
+ config
309
+ );
310
+ }
311
+ return result;
312
+ }
313
+ static deriveKey(slug, authType) {
314
+ return authType ? `${slug}-${authType}` : slug;
315
+ }
316
+ };
317
+
318
+ // ../connectors/src/auth-types.ts
319
+ var AUTH_TYPES = {
320
+ OAUTH: "oauth",
321
+ API_KEY: "api-key",
322
+ JWT: "jwt",
323
+ SERVICE_ACCOUNT: "service-account",
324
+ PAT: "pat",
325
+ USER_PASSWORD: "user-password"
326
+ };
327
+
328
+ // ../connectors/src/connectors/google-calendar/setup.ts
329
+ var googleCalendarOnboarding = new ConnectorOnboarding({
330
+ dataOverviewInstructions: {
331
+ en: `1. Call google-calendar_request with GET /calendars/{calendarId} to get the default calendar's metadata
332
+ 2. Call google-calendar_request with GET /users/me/calendarList to list all accessible calendars
333
+ 3. Call google-calendar_request with GET /calendars/{calendarId}/events with query params timeMin (RFC3339) and maxResults=10 to sample upcoming events`,
334
+ ja: `1. google-calendar_request \u3067 GET /calendars/{calendarId} \u3092\u547C\u3073\u51FA\u3057\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
335
+ 2. google-calendar_request \u3067 GET /users/me/calendarList \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u3092\u53D6\u5F97
336
+ 3. google-calendar_request \u3067 GET /calendars/{calendarId}/events \u3092\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF timeMin\uFF08RFC3339\u5F62\u5F0F\uFF09\u3068 maxResults=10 \u3067\u547C\u3073\u51FA\u3057\u3001\u76F4\u8FD1\u306E\u30A4\u30D9\u30F3\u30C8\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0`
337
+ }
338
+ });
339
+
340
+ // ../connectors/src/connectors/google-calendar/tools/request.ts
341
+ import { z } from "zod";
342
+ var BASE_URL2 = "https://www.googleapis.com/calendar/v3";
343
+ var REQUEST_TIMEOUT_MS = 6e4;
344
+ var inputSchema = z.object({
345
+ toolUseIntent: z.string().optional().describe(
346
+ "Brief description of what you intend to accomplish with this tool call"
347
+ ),
348
+ connectionId: z.string().describe("ID of the Google Calendar connection to use"),
349
+ method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
350
+ path: z.string().describe(
351
+ "API path appended to https://www.googleapis.com/calendar/v3 (e.g., '/calendars/{calendarId}/events'). {calendarId} is automatically replaced."
352
+ ),
353
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
354
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PUT/PATCH methods")
355
+ });
356
+ var outputSchema = z.discriminatedUnion("success", [
357
+ z.object({
358
+ success: z.literal(true),
359
+ status: z.number(),
360
+ data: z.record(z.string(), z.unknown())
361
+ }),
362
+ z.object({
363
+ success: z.literal(false),
364
+ error: z.string()
365
+ })
366
+ ]);
367
+ var requestTool = new ConnectorTool({
368
+ name: "request",
369
+ description: `Send authenticated requests to the Google Calendar API v3.
370
+ Authentication is handled automatically using a service account.
371
+ {calendarId} in the path is automatically replaced with the connection's default calendar ID.`,
372
+ inputSchema,
373
+ outputSchema,
374
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections) {
375
+ const connection2 = connections.find((c) => c.id === connectionId);
376
+ if (!connection2) {
377
+ return {
378
+ success: false,
379
+ error: `Connection ${connectionId} not found`
380
+ };
381
+ }
382
+ console.log(
383
+ `[connector-request] google-calendar/${connection2.name}: ${method} ${path2}`
384
+ );
385
+ try {
386
+ const { GoogleAuth } = await import("google-auth-library");
387
+ const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
388
+ const calendarId = parameters.calendarId.tryGetValue(connection2) ?? "primary";
389
+ const credentials = JSON.parse(
390
+ Buffer.from(keyJsonBase64, "base64").toString("utf-8")
391
+ );
392
+ const auth = new GoogleAuth({
393
+ credentials,
394
+ scopes: [
395
+ "https://www.googleapis.com/auth/calendar.readonly",
396
+ "https://www.googleapis.com/auth/calendar.events.readonly"
397
+ ]
398
+ });
399
+ const token = await auth.getAccessToken();
400
+ if (!token) {
401
+ return {
402
+ success: false,
403
+ error: "Failed to obtain access token"
404
+ };
405
+ }
406
+ const resolvedPath = path2.replace(/\{calendarId\}/g, calendarId);
407
+ let url = `${BASE_URL2}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
408
+ if (queryParams) {
409
+ const searchParams = new URLSearchParams(queryParams);
410
+ url += `?${searchParams.toString()}`;
411
+ }
412
+ const controller = new AbortController();
413
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
414
+ try {
415
+ const response = await fetch(url, {
416
+ method,
417
+ headers: {
418
+ Authorization: `Bearer ${token}`,
419
+ "Content-Type": "application/json"
420
+ },
421
+ body: body && ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify(body) : void 0,
422
+ signal: controller.signal
423
+ });
424
+ if (method === "DELETE" && response.status === 204) {
425
+ return {
426
+ success: true,
427
+ status: 204,
428
+ data: { message: "Deleted successfully" }
429
+ };
430
+ }
431
+ const data = await response.json();
432
+ if (!response.ok) {
433
+ const errorObj = data?.error;
434
+ return {
435
+ success: false,
436
+ error: errorObj?.message ?? `HTTP ${response.status} ${response.statusText}`
437
+ };
438
+ }
439
+ return { success: true, status: response.status, data };
440
+ } finally {
441
+ clearTimeout(timeout);
442
+ }
443
+ } catch (err) {
444
+ const msg = err instanceof Error ? err.message : String(err);
445
+ return { success: false, error: msg };
446
+ }
447
+ }
448
+ });
449
+
450
+ // ../connectors/src/connectors/google-calendar/index.ts
451
+ var tools = { request: requestTool };
452
+ var googleCalendarConnector = new ConnectorPlugin({
453
+ slug: "google-calendar",
454
+ authType: AUTH_TYPES.SERVICE_ACCOUNT,
455
+ name: "Google Calendar",
456
+ description: "Connect to Google Calendar for calendar and event data access using a service account.",
457
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5D9eTiMxiL7MaezWXyAaLG/dbcf25e1d51ab877548b3d77e4b02c6d/google-calendar.svg",
458
+ parameters,
459
+ releaseFlag: { dev1: true, dev2: true, prod: true },
460
+ onboarding: googleCalendarOnboarding,
461
+ systemPrompt: {
462
+ en: `### Tools
463
+
464
+ - \`google-calendar_request\`: The only way to call the Google Calendar API. Use it to list calendars, get events, and manage calendar data. Authentication is handled automatically using a service account. The {calendarId} placeholder in paths is automatically replaced with the configured default calendar ID.
465
+
466
+ ### Business Logic
467
+
468
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
469
+
470
+ SDK methods (client created via \`connection(connectionId)\`):
471
+ - \`client.listCalendars()\` \u2014 list all accessible calendars
472
+ - \`client.listEvents(options?, calendarId?)\` \u2014 list events with optional filters
473
+ - \`client.getEvent(eventId, calendarId?)\` \u2014 get a single event by ID
474
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
475
+
476
+ \`\`\`ts
477
+ import type { Context } from "hono";
478
+ import { connection } from "@squadbase/vite-server/connectors/google-calendar";
479
+
480
+ const calendar = connection("<connectionId>");
481
+
482
+ export default async function handler(c: Context) {
483
+ const now = new Date().toISOString();
484
+ const { items } = await calendar.listEvents({
485
+ timeMin: now,
486
+ maxResults: 10,
487
+ singleEvents: true,
488
+ orderBy: "startTime",
489
+ });
490
+
491
+ return c.json(
492
+ items.map((event) => ({
493
+ id: event.id,
494
+ summary: event.summary,
495
+ start: event.start.dateTime ?? event.start.date,
496
+ end: event.end.dateTime ?? event.end.date,
497
+ location: event.location,
498
+ })),
499
+ );
500
+ }
501
+ \`\`\`
502
+
503
+ ### Google Calendar API v3 Reference
504
+
505
+ #### Available Endpoints
506
+ - GET \`/calendars/{calendarId}\` \u2014 Get calendar metadata
507
+ - GET \`/users/me/calendarList\` \u2014 List all calendars accessible by the authenticated user
508
+ - GET \`/calendars/{calendarId}/events\` \u2014 List events on a calendar
509
+ - GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 Get a single event
510
+
511
+ #### Common Query Parameters for Event Listing
512
+ - \`timeMin\` \u2014 Lower bound (RFC3339 timestamp, e.g., "2024-01-01T00:00:00Z")
513
+ - \`timeMax\` \u2014 Upper bound (RFC3339 timestamp)
514
+ - \`maxResults\` \u2014 Maximum number of events (default 250, max 2500)
515
+ - \`singleEvents=true\` \u2014 Expand recurring events into individual instances
516
+ - \`orderBy=startTime\` \u2014 Order by start time (requires singleEvents=true)
517
+ - \`q\` \u2014 Free text search terms
518
+
519
+ #### Tips
520
+ - Use \`{calendarId}\` placeholder in paths \u2014 it is automatically replaced with the configured default calendar ID
521
+ - Set \`singleEvents=true\` to expand recurring events into individual instances
522
+ - When using \`orderBy=startTime\`, you must also set \`singleEvents=true\`
523
+ - Use RFC3339 format for time parameters (e.g., "2024-01-15T09:00:00Z" or "2024-01-15T09:00:00+09:00")
524
+ - The default calendar ID is "primary" if not configured`,
525
+ ja: `### \u30C4\u30FC\u30EB
526
+
527
+ - \`google-calendar_request\`: Google Calendar API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u53D6\u5F97\u3001\u30A4\u30D9\u30F3\u30C8\u306E\u53D6\u5F97\u3001\u30AB\u30EC\u30F3\u30C0\u30FC\u30C7\u30FC\u30BF\u306E\u7BA1\u7406\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u4F7F\u7528\u3057\u3066\u8A8D\u8A3C\u306F\u81EA\u52D5\u7684\u306B\u51E6\u7406\u3055\u308C\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{calendarId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FCID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
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\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
532
+
533
+ SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
534
+ - \`client.listCalendars()\` \u2014 \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u53D6\u5F97
535
+ - \`client.listEvents(options?, calendarId?)\` \u2014 \u30D5\u30A3\u30EB\u30BF\u30FC\u4ED8\u304D\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7\u53D6\u5F97
536
+ - \`client.getEvent(eventId, calendarId?)\` \u2014 ID\u306B\u3088\u308B\u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u53D6\u5F97
537
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
538
+
539
+ \`\`\`ts
540
+ import type { Context } from "hono";
541
+ import { connection } from "@squadbase/vite-server/connectors/google-calendar";
542
+
543
+ const calendar = connection("<connectionId>");
544
+
545
+ export default async function handler(c: Context) {
546
+ const now = new Date().toISOString();
547
+ const { items } = await calendar.listEvents({
548
+ timeMin: now,
549
+ maxResults: 10,
550
+ singleEvents: true,
551
+ orderBy: "startTime",
552
+ });
553
+
554
+ return c.json(
555
+ items.map((event) => ({
556
+ id: event.id,
557
+ summary: event.summary,
558
+ start: event.start.dateTime ?? event.start.date,
559
+ end: event.end.dateTime ?? event.end.date,
560
+ location: event.location,
561
+ })),
562
+ );
563
+ }
564
+ \`\`\`
565
+
566
+ ### Google Calendar API v3 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
567
+
568
+ #### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
569
+ - GET \`/calendars/{calendarId}\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
570
+ - GET \`/users/me/calendarList\` \u2014 \u8A8D\u8A3C\u30E6\u30FC\u30B6\u30FC\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7
571
+ - GET \`/calendars/{calendarId}/events\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u4E0A\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7
572
+ - GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 \u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u306E\u53D6\u5F97
573
+
574
+ #### \u30A4\u30D9\u30F3\u30C8\u4E00\u89A7\u306E\u4E3B\u8981\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF
575
+ - \`timeMin\` \u2014 \u4E0B\u9650\uFF08RFC3339\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\u3001\u4F8B: "2024-01-01T00:00:00Z"\uFF09
576
+ - \`timeMax\` \u2014 \u4E0A\u9650\uFF08RFC3339\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\uFF09
577
+ - \`maxResults\` \u2014 \u6700\u5927\u30A4\u30D9\u30F3\u30C8\u6570\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8250\u3001\u6700\u59272500\uFF09
578
+ - \`singleEvents=true\` \u2014 \u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u3092\u500B\u5225\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306B\u5C55\u958B
579
+ - \`orderBy=startTime\` \u2014 \u958B\u59CB\u6642\u9593\u9806\u306B\u4E26\u3079\u66FF\u3048\uFF08singleEvents=true\u304C\u5FC5\u8981\uFF09
580
+ - \`q\` \u2014 \u30D5\u30EA\u30FC\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u8A9E
581
+
582
+ #### \u30D2\u30F3\u30C8
583
+ - \u30D1\u30B9\u306B \`{calendarId}\` \u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u3092\u4F7F\u7528 \u2014 \u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FCID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059
584
+ - \`singleEvents=true\` \u3092\u8A2D\u5B9A\u3059\u308B\u3068\u3001\u7E70\u308A\u8FD4\u3057\u30A4\u30D9\u30F3\u30C8\u304C\u500B\u5225\u306E\u30A4\u30F3\u30B9\u30BF\u30F3\u30B9\u306B\u5C55\u958B\u3055\u308C\u307E\u3059
585
+ - \`orderBy=startTime\` \u3092\u4F7F\u7528\u3059\u308B\u5834\u5408\u3001\`singleEvents=true\` \u3082\u8A2D\u5B9A\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
586
+ - \u6642\u9593\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u306FRFC3339\u5F62\u5F0F\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u4F8B: "2024-01-15T09:00:00Z" \u3084 "2024-01-15T09:00:00+09:00"\uFF09
587
+ - \u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FCID\u306F\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408 "primary" \u304C\u4F7F\u7528\u3055\u308C\u307E\u3059`
588
+ },
589
+ tools
590
+ });
591
+
592
+ // src/connectors/create-connector-sdk.ts
593
+ import { readFileSync } from "fs";
594
+ import path from "path";
595
+
596
+ // src/connector-client/env.ts
597
+ function resolveEnvVar(entry, key, connectionId) {
598
+ const envVarName = entry.envVars[key];
599
+ if (!envVarName) {
600
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
601
+ }
602
+ const value = process.env[envVarName];
603
+ if (!value) {
604
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
605
+ }
606
+ return value;
607
+ }
608
+ function resolveEnvVarOptional(entry, key) {
609
+ const envVarName = entry.envVars[key];
610
+ if (!envVarName) return void 0;
611
+ return process.env[envVarName] || void 0;
612
+ }
613
+
614
+ // src/connectors/create-connector-sdk.ts
615
+ function loadConnectionsSync() {
616
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
617
+ try {
618
+ const raw = readFileSync(filePath, "utf-8");
619
+ return JSON.parse(raw);
620
+ } catch {
621
+ return {};
622
+ }
623
+ }
624
+ function createConnectorSdk(plugin, createClient2) {
625
+ return (connectionId) => {
626
+ const connections = loadConnectionsSync();
627
+ const entry = connections[connectionId];
628
+ if (!entry) {
629
+ throw new Error(
630
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
631
+ );
632
+ }
633
+ if (entry.connector.slug !== plugin.slug) {
634
+ throw new Error(
635
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
636
+ );
637
+ }
638
+ const params = {};
639
+ for (const param of Object.values(plugin.parameters)) {
640
+ if (param.required) {
641
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
642
+ } else {
643
+ const val = resolveEnvVarOptional(entry, param.slug);
644
+ if (val !== void 0) params[param.slug] = val;
645
+ }
646
+ }
647
+ return createClient2(params);
648
+ };
649
+ }
650
+
651
+ // src/connectors/entries/google-calendar.ts
652
+ var connection = createConnectorSdk(googleCalendarConnector, createClient);
653
+ export {
654
+ connection
655
+ };
@@ -227,7 +227,8 @@ var AUTH_TYPES = {
227
227
  API_KEY: "api-key",
228
228
  JWT: "jwt",
229
229
  SERVICE_ACCOUNT: "service-account",
230
- PAT: "pat"
230
+ PAT: "pat",
231
+ USER_PASSWORD: "user-password"
231
232
  };
232
233
 
233
234
  // ../connectors/src/connectors/google-sheets-oauth/tools/request.ts
@@ -402,7 +403,7 @@ var tools = { request: requestTool };
402
403
  var googleSheetsOauthConnector = new ConnectorPlugin({
403
404
  slug: "google-sheets",
404
405
  authType: AUTH_TYPES.OAUTH,
405
- name: "Google Sheets (OAuth)",
406
+ name: "Google Sheets",
406
407
  description: "Connect to Google Sheets for spreadsheet data access using OAuth.",
407
408
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1UPQuggyiZmbb26CuaSr2h/032770e8739b183fa00b7625f024e536/google-sheets.svg",
408
409
  parameters,