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

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 +14229 -29321
  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 +43 -6
  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 +4476 -3949
  58. package/dist/main.js +4474 -3948
  59. package/dist/vite-plugin.js +4474 -3948
  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
@@ -0,0 +1,866 @@
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/gamma/parameters.ts
46
+ var parameters = {
47
+ apiKey: new ParameterDefinition({
48
+ slug: "api-key",
49
+ name: "Gamma API Key",
50
+ description: "The Gamma API key for authentication. Generate from Account Settings > API Keys. Requires Pro, Ultra, Teams, or Business plan.",
51
+ envVarBaseKey: "GAMMA_API_KEY",
52
+ type: "text",
53
+ secret: true,
54
+ required: true
55
+ })
56
+ };
57
+
58
+ // ../connectors/src/connectors/gamma/sdk/index.ts
59
+ var BASE_URL = "https://public-api.gamma.app/v1.0";
60
+ function createClient(params) {
61
+ const apiKey = params[parameters.apiKey.slug];
62
+ if (!apiKey) {
63
+ throw new Error(
64
+ `gamma: missing required parameter: ${parameters.apiKey.slug}`
65
+ );
66
+ }
67
+ function authHeaders(extra) {
68
+ const headers = new Headers(extra);
69
+ headers.set("X-API-KEY", apiKey);
70
+ headers.set("Content-Type", "application/json");
71
+ return headers;
72
+ }
73
+ async function assertOk(res, label) {
74
+ if (!res.ok) {
75
+ const body = await res.text().catch(() => "(unreadable body)");
76
+ throw new Error(
77
+ `gamma ${label}: ${res.status} ${res.statusText} \u2014 ${body}`
78
+ );
79
+ }
80
+ }
81
+ return {
82
+ request(path2, init) {
83
+ const url = `${BASE_URL}${path2}`;
84
+ const headers = new Headers(init?.headers);
85
+ headers.set("X-API-KEY", apiKey);
86
+ headers.set("Content-Type", "application/json");
87
+ return fetch(url, { ...init, headers });
88
+ },
89
+ async listThemes(options) {
90
+ const params2 = new URLSearchParams();
91
+ if (options?.query) params2.set("query", options.query);
92
+ if (options?.limit) params2.set("limit", String(options.limit));
93
+ if (options?.after) params2.set("after", options.after);
94
+ const qs = params2.toString();
95
+ const res = await fetch(
96
+ `${BASE_URL}/themes${qs ? `?${qs}` : ""}`,
97
+ { method: "GET", headers: authHeaders() }
98
+ );
99
+ await assertOk(res, "listThemes");
100
+ return await res.json();
101
+ },
102
+ async listFolders(options) {
103
+ const params2 = new URLSearchParams();
104
+ if (options?.query) params2.set("query", options.query);
105
+ if (options?.limit) params2.set("limit", String(options.limit));
106
+ if (options?.after) params2.set("after", options.after);
107
+ const qs = params2.toString();
108
+ const res = await fetch(
109
+ `${BASE_URL}/folders${qs ? `?${qs}` : ""}`,
110
+ { method: "GET", headers: authHeaders() }
111
+ );
112
+ await assertOk(res, "listFolders");
113
+ return await res.json();
114
+ },
115
+ async createGeneration(options) {
116
+ const res = await fetch(`${BASE_URL}/generations`, {
117
+ method: "POST",
118
+ headers: authHeaders(),
119
+ body: JSON.stringify(options)
120
+ });
121
+ await assertOk(res, "createGeneration");
122
+ return await res.json();
123
+ },
124
+ async getGeneration(generationId) {
125
+ const res = await fetch(
126
+ `${BASE_URL}/generations/${encodeURIComponent(generationId)}`,
127
+ { method: "GET", headers: authHeaders() }
128
+ );
129
+ await assertOk(res, "getGeneration");
130
+ return await res.json();
131
+ },
132
+ async generateAndWait(options) {
133
+ const { generationId } = await this.createGeneration(options);
134
+ const deadline = Date.now() + 3e5;
135
+ while (Date.now() < deadline) {
136
+ await new Promise((resolve) => setTimeout(resolve, 5e3));
137
+ const result = await this.getGeneration(generationId);
138
+ if (result.status === "completed" || result.status === "failed") {
139
+ return result;
140
+ }
141
+ }
142
+ return {
143
+ generationId,
144
+ status: "failed",
145
+ error: {
146
+ message: `Generation timed out after 300s`,
147
+ statusCode: 408
148
+ }
149
+ };
150
+ }
151
+ };
152
+ }
153
+
154
+ // ../connectors/src/connector-onboarding.ts
155
+ var ConnectorOnboarding = class {
156
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
157
+ connectionSetupInstructions;
158
+ /** Phase 2: Data overview instructions */
159
+ dataOverviewInstructions;
160
+ constructor(config) {
161
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
162
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
163
+ }
164
+ getConnectionSetupPrompt(language) {
165
+ return this.connectionSetupInstructions?.[language] ?? null;
166
+ }
167
+ getDataOverviewInstructions(language) {
168
+ return this.dataOverviewInstructions[language];
169
+ }
170
+ };
171
+
172
+ // ../connectors/src/connector-tool.ts
173
+ var ConnectorTool = class {
174
+ name;
175
+ description;
176
+ inputSchema;
177
+ outputSchema;
178
+ _execute;
179
+ constructor(config) {
180
+ this.name = config.name;
181
+ this.description = config.description;
182
+ this.inputSchema = config.inputSchema;
183
+ this.outputSchema = config.outputSchema;
184
+ this._execute = config.execute;
185
+ }
186
+ createTool(connections, config) {
187
+ return {
188
+ description: this.description,
189
+ inputSchema: this.inputSchema,
190
+ outputSchema: this.outputSchema,
191
+ execute: (input) => this._execute(input, connections, config)
192
+ };
193
+ }
194
+ };
195
+
196
+ // ../connectors/src/connector-plugin.ts
197
+ var ConnectorPlugin = class _ConnectorPlugin {
198
+ slug;
199
+ authType;
200
+ name;
201
+ description;
202
+ iconUrl;
203
+ parameters;
204
+ releaseFlag;
205
+ proxyPolicy;
206
+ experimentalAttributes;
207
+ onboarding;
208
+ systemPrompt;
209
+ tools;
210
+ query;
211
+ checkConnection;
212
+ constructor(config) {
213
+ this.slug = config.slug;
214
+ this.authType = config.authType;
215
+ this.name = config.name;
216
+ this.description = config.description;
217
+ this.iconUrl = config.iconUrl;
218
+ this.parameters = config.parameters;
219
+ this.releaseFlag = config.releaseFlag;
220
+ this.proxyPolicy = config.proxyPolicy;
221
+ this.experimentalAttributes = config.experimentalAttributes;
222
+ this.onboarding = config.onboarding;
223
+ this.systemPrompt = config.systemPrompt;
224
+ this.tools = config.tools;
225
+ this.query = config.query;
226
+ this.checkConnection = config.checkConnection;
227
+ }
228
+ get connectorKey() {
229
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
230
+ }
231
+ /**
232
+ * Create tools for connections that belong to this connector.
233
+ * Filters connections by connectorKey internally.
234
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
235
+ */
236
+ createTools(connections, config, opts) {
237
+ const myConnections = connections.filter(
238
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
239
+ );
240
+ const result = {};
241
+ for (const t of Object.values(this.tools)) {
242
+ const tool = t.createTool(myConnections, config);
243
+ const originalToModelOutput = tool.toModelOutput;
244
+ result[`${this.connectorKey}_${t.name}`] = {
245
+ ...tool,
246
+ toModelOutput: async (options) => {
247
+ if (!originalToModelOutput) {
248
+ return opts.truncateOutput(options.output);
249
+ }
250
+ const modelOutput = await originalToModelOutput(options);
251
+ if (modelOutput.type === "text" || modelOutput.type === "json") {
252
+ return opts.truncateOutput(modelOutput.value);
253
+ }
254
+ return modelOutput;
255
+ }
256
+ };
257
+ }
258
+ return result;
259
+ }
260
+ static deriveKey(slug, authType) {
261
+ if (authType) return `${slug}-${authType}`;
262
+ const LEGACY_NULL_AUTH_TYPE_MAP = {
263
+ // user-password
264
+ "postgresql": "user-password",
265
+ "mysql": "user-password",
266
+ "clickhouse": "user-password",
267
+ "kintone": "user-password",
268
+ "squadbase-db": "user-password",
269
+ // service-account
270
+ "snowflake": "service-account",
271
+ "bigquery": "service-account",
272
+ "google-analytics": "service-account",
273
+ "google-calendar": "service-account",
274
+ "aws-athena": "service-account",
275
+ "redshift": "service-account",
276
+ // api-key
277
+ "databricks": "api-key",
278
+ "dbt": "api-key",
279
+ "airtable": "api-key",
280
+ "openai": "api-key",
281
+ "gemini": "api-key",
282
+ "anthropic": "api-key",
283
+ "wix-store": "api-key"
284
+ };
285
+ const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
286
+ if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
287
+ return slug;
288
+ }
289
+ };
290
+
291
+ // ../connectors/src/auth-types.ts
292
+ var AUTH_TYPES = {
293
+ OAUTH: "oauth",
294
+ API_KEY: "api-key",
295
+ JWT: "jwt",
296
+ SERVICE_ACCOUNT: "service-account",
297
+ PAT: "pat",
298
+ USER_PASSWORD: "user-password"
299
+ };
300
+
301
+ // ../connectors/src/connectors/gamma/setup.ts
302
+ var gammaOnboarding = new ConnectorOnboarding({
303
+ dataOverviewInstructions: {
304
+ en: `1. Call gamma_request with GET /themes to list available themes in the workspace
305
+ 2. Call gamma_request with GET /folders to list workspace folders
306
+ 3. Try generating a simple presentation with gamma_generate: inputText "Sample presentation about AI", textMode "generate", numCards 3`,
307
+ ja: `1. gamma_request \u3067 GET /themes \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3067\u5229\u7528\u53EF\u80FD\u306A\u30C6\u30FC\u30DE\u4E00\u89A7\u3092\u53D6\u5F97
308
+ 2. gamma_request \u3067 GET /folders \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u3092\u53D6\u5F97
309
+ 3. gamma_generate \u3067\u30B7\u30F3\u30D7\u30EB\u306A\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3092\u8A66\u4F5C: inputText "AI\u306B\u3064\u3044\u3066\u306E\u30B5\u30F3\u30D7\u30EB\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3", textMode "generate", numCards 3`
310
+ }
311
+ });
312
+
313
+ // ../connectors/src/connectors/gamma/tools/request.ts
314
+ import { z } from "zod";
315
+ var BASE_URL2 = "https://public-api.gamma.app/v1.0";
316
+ var REQUEST_TIMEOUT_MS = 6e4;
317
+ var inputSchema = z.object({
318
+ toolUseIntent: z.string().optional().describe(
319
+ "Brief description of what you intend to accomplish with this tool call"
320
+ ),
321
+ connectionId: z.string().describe("ID of the Gamma connection to use"),
322
+ method: z.enum(["GET", "POST"]).describe("HTTP method. GET for listing resources, POST for creating."),
323
+ path: z.string().describe(
324
+ "API path (e.g., '/themes', '/folders', '/generations', '/generations/{generationId}')"
325
+ ),
326
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST requests")
327
+ });
328
+ var outputSchema = z.discriminatedUnion("success", [
329
+ z.object({
330
+ success: z.literal(true),
331
+ status: z.number(),
332
+ data: z.unknown()
333
+ }),
334
+ z.object({
335
+ success: z.literal(false),
336
+ error: z.string()
337
+ })
338
+ ]);
339
+ var requestTool = new ConnectorTool({
340
+ name: "request",
341
+ description: `Send authenticated requests to the Gamma REST API.
342
+ Authentication is handled automatically using the API Key (X-API-KEY header).
343
+ Use this tool for listing themes, listing folders, checking generation status, and other read operations.
344
+ For creating presentations/documents, prefer the gamma_generate tool instead.`,
345
+ inputSchema,
346
+ outputSchema,
347
+ async execute({ connectionId, method, path: path2, body }, connections) {
348
+ const connection2 = connections.find((c) => c.id === connectionId);
349
+ if (!connection2) {
350
+ return {
351
+ success: false,
352
+ error: `Connection ${connectionId} not found`
353
+ };
354
+ }
355
+ console.log(
356
+ `[connector-request] gamma/${connection2.name}: ${method} ${path2}`
357
+ );
358
+ try {
359
+ const apiKey = parameters.apiKey.getValue(connection2);
360
+ const url = `${BASE_URL2}${path2}`;
361
+ const controller = new AbortController();
362
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
363
+ try {
364
+ const response = await fetch(url, {
365
+ method,
366
+ headers: {
367
+ "X-API-KEY": apiKey,
368
+ "Content-Type": "application/json"
369
+ },
370
+ body: body ? JSON.stringify(body) : void 0,
371
+ signal: controller.signal
372
+ });
373
+ const data = await response.json();
374
+ if (!response.ok) {
375
+ const err = data;
376
+ const errorMessage = typeof err?.message === "string" ? err.message : typeof err?.error === "string" ? err.error : `HTTP ${response.status} ${response.statusText}`;
377
+ return { success: false, error: errorMessage };
378
+ }
379
+ return { success: true, status: response.status, data };
380
+ } finally {
381
+ clearTimeout(timeout);
382
+ }
383
+ } catch (err) {
384
+ const msg = err instanceof Error ? err.message : String(err);
385
+ return { success: false, error: msg };
386
+ }
387
+ }
388
+ });
389
+
390
+ // ../connectors/src/connectors/gamma/tools/generate.ts
391
+ import { z as z2 } from "zod";
392
+ var BASE_URL3 = "https://public-api.gamma.app/v1.0";
393
+ var POLL_INTERVAL_MS = 5e3;
394
+ var MAX_POLL_DURATION_MS = 3e5;
395
+ var inputSchema2 = z2.object({
396
+ toolUseIntent: z2.string().optional().describe(
397
+ "Brief description of what you intend to accomplish with this tool call"
398
+ ),
399
+ connectionId: z2.string().describe("ID of the Gamma connection to use"),
400
+ inputText: z2.string().describe(
401
+ "Content for the generation. Can include text and image URLs. Max ~400,000 characters."
402
+ ),
403
+ textMode: z2.enum(["generate", "condense", "preserve"]).describe(
404
+ "How inputText is modified: 'generate' creates new content from the topic, 'condense' shortens existing text, 'preserve' keeps text as-is."
405
+ ),
406
+ format: z2.enum(["presentation", "document", "webpage", "social"]).optional().describe("Type of artifact to create. Defaults to 'presentation'."),
407
+ numCards: z2.number().int().min(1).max(75).optional().describe("Number of cards/slides. Defaults to 10."),
408
+ themeId: z2.string().optional().describe(
409
+ "Theme ID for look and feel. Use gamma_request GET /themes to list available themes."
410
+ ),
411
+ tone: z2.string().optional().describe(
412
+ "Tone/voice of the output (e.g., 'professional', 'casual', 'academic'). Max 500 chars."
413
+ ),
414
+ audience: z2.string().optional().describe(
415
+ "Target audience description (e.g., 'marketing executives'). Max 500 chars."
416
+ ),
417
+ language: z2.string().optional().describe("Output language code (e.g., 'en', 'ja'). Defaults to 'en'."),
418
+ textAmount: z2.enum(["brief", "medium", "detailed", "extensive"]).optional().describe("Text volume per card. Defaults to 'medium'."),
419
+ imageSource: z2.enum([
420
+ "aiGenerated",
421
+ "pictographic",
422
+ "pexels",
423
+ "giphy",
424
+ "webAllImages",
425
+ "webFreeToUse",
426
+ "webFreeToUseCommercially",
427
+ "themeAccent",
428
+ "placeholder",
429
+ "noImages"
430
+ ]).optional().describe("Image source. Defaults to 'aiGenerated'."),
431
+ additionalInstructions: z2.string().optional().describe(
432
+ "Additional specifications for content, layout, and aesthetics. Max 5000 chars."
433
+ ),
434
+ exportAs: z2.enum(["pdf", "pptx", "png"]).optional().describe("Export file format. If omitted, no export file is generated.")
435
+ });
436
+ var outputSchema2 = z2.discriminatedUnion("success", [
437
+ z2.object({
438
+ success: z2.literal(true),
439
+ generationId: z2.string(),
440
+ gammaId: z2.string(),
441
+ gammaUrl: z2.string(),
442
+ exportUrl: z2.string().optional(),
443
+ credits: z2.object({
444
+ deducted: z2.number(),
445
+ remaining: z2.number()
446
+ }).optional()
447
+ }),
448
+ z2.object({
449
+ success: z2.literal(false),
450
+ error: z2.string()
451
+ })
452
+ ]);
453
+ var generateTool = new ConnectorTool({
454
+ name: "generate",
455
+ description: `Generate a presentation, document, webpage, or social post using Gamma AI.
456
+ This tool creates the generation, then automatically polls until completion and returns the result URL.
457
+ Use gamma_request GET /themes first if you want to pick a specific theme.
458
+ Gamma does NOT support image uploads. To visualize data, embed raw numbers directly into inputText as structured text (markdown tables, bullet lists with figures) \u2014 Gamma AI will render charts and visuals from the data.`,
459
+ inputSchema: inputSchema2,
460
+ outputSchema: outputSchema2,
461
+ async execute({
462
+ connectionId,
463
+ inputText,
464
+ textMode,
465
+ format,
466
+ numCards,
467
+ themeId,
468
+ tone,
469
+ audience,
470
+ language,
471
+ textAmount,
472
+ imageSource,
473
+ additionalInstructions,
474
+ exportAs
475
+ }, connections) {
476
+ const connection2 = connections.find((c) => c.id === connectionId);
477
+ if (!connection2) {
478
+ return {
479
+ success: false,
480
+ error: `Connection ${connectionId} not found`
481
+ };
482
+ }
483
+ console.log(
484
+ `[connector-generate] gamma/${connection2.name}: creating ${format ?? "presentation"}`
485
+ );
486
+ try {
487
+ const apiKey = parameters.apiKey.getValue(connection2);
488
+ const headers = {
489
+ "X-API-KEY": apiKey,
490
+ "Content-Type": "application/json"
491
+ };
492
+ const body = {
493
+ inputText,
494
+ textMode
495
+ };
496
+ if (format) body.format = format;
497
+ if (numCards) body.numCards = numCards;
498
+ if (themeId) body.themeId = themeId;
499
+ if (additionalInstructions)
500
+ body.additionalInstructions = additionalInstructions;
501
+ if (exportAs) body.exportAs = exportAs;
502
+ const textOptions = {};
503
+ if (tone) textOptions.tone = tone;
504
+ if (audience) textOptions.audience = audience;
505
+ if (language) textOptions.language = language;
506
+ if (textAmount) textOptions.amount = textAmount;
507
+ if (Object.keys(textOptions).length > 0) body.textOptions = textOptions;
508
+ if (imageSource) body.imageOptions = { source: imageSource };
509
+ const createRes = await fetch(`${BASE_URL3}/generations`, {
510
+ method: "POST",
511
+ headers,
512
+ body: JSON.stringify(body)
513
+ });
514
+ const createData = await createRes.json();
515
+ if (!createRes.ok) {
516
+ const errorMessage = typeof createData?.message === "string" ? createData.message : typeof createData?.error === "string" ? createData.error : `HTTP ${createRes.status} ${createRes.statusText}`;
517
+ return { success: false, error: errorMessage };
518
+ }
519
+ const generationId = createData.generationId;
520
+ if (!generationId) {
521
+ return {
522
+ success: false,
523
+ error: "No generationId returned from API"
524
+ };
525
+ }
526
+ const deadline = Date.now() + MAX_POLL_DURATION_MS;
527
+ while (Date.now() < deadline) {
528
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
529
+ const pollRes = await fetch(`${BASE_URL3}/generations/${generationId}`, {
530
+ method: "GET",
531
+ headers
532
+ });
533
+ const pollData = await pollRes.json();
534
+ if (!pollRes.ok) {
535
+ const errorMessage = typeof pollData?.message === "string" ? pollData.message : `Polling failed: HTTP ${pollRes.status}`;
536
+ return { success: false, error: errorMessage };
537
+ }
538
+ const status = pollData.status;
539
+ if (status === "completed") {
540
+ return {
541
+ success: true,
542
+ generationId,
543
+ gammaId: pollData.gammaId,
544
+ gammaUrl: pollData.gammaUrl,
545
+ exportUrl: pollData.exportUrl || void 0,
546
+ credits: pollData.credits
547
+ };
548
+ }
549
+ if (status === "failed") {
550
+ const error = pollData.error;
551
+ const errorMessage = typeof error?.message === "string" ? error.message : "Generation failed";
552
+ return { success: false, error: errorMessage };
553
+ }
554
+ }
555
+ return {
556
+ success: false,
557
+ error: `Generation timed out after ${MAX_POLL_DURATION_MS / 1e3}s. generationId: ${generationId} \u2014 you can check status with GET /generations/${generationId}`
558
+ };
559
+ } catch (err) {
560
+ const msg = err instanceof Error ? err.message : String(err);
561
+ return { success: false, error: msg };
562
+ }
563
+ }
564
+ });
565
+
566
+ // ../connectors/src/connectors/gamma/index.ts
567
+ var tools = { request: requestTool, generate: generateTool };
568
+ var gammaConnector = new ConnectorPlugin({
569
+ slug: "gamma",
570
+ authType: AUTH_TYPES.API_KEY,
571
+ name: "Gamma",
572
+ description: "Connect to Gamma for AI-powered presentation, document, webpage, and social post generation.",
573
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/KoMGPpPcgtB9oDYe1OBjS/1ba7eb061c4497106bf6d249866dc471/gamma.svg",
574
+ parameters,
575
+ releaseFlag: { dev1: true, dev2: false, prod: false },
576
+ onboarding: gammaOnboarding,
577
+ systemPrompt: {
578
+ en: `### Tools
579
+
580
+ - \`gamma_request\`: Send authenticated requests to the Gamma REST API. Use for listing themes, folders, and checking generation status. Authentication (X-API-KEY) is configured automatically.
581
+ - \`gamma_generate\`: Generate a presentation, document, webpage, or social post using Gamma AI. This tool handles the full workflow: creates the generation, polls for completion, and returns the result URL. Prefer this over manually calling POST /generations + polling.
582
+
583
+ ### Business Logic
584
+
585
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
586
+
587
+ SDK methods (client created via \`connection(connectionId)\`):
588
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch
589
+ - \`client.listThemes(options?)\` \u2014 list available themes (query, limit, after)
590
+ - \`client.listFolders(options?)\` \u2014 list workspace folders (query, limit, after)
591
+ - \`client.createGeneration(options)\` \u2014 create a generation, returns generationId
592
+ - \`client.getGeneration(generationId)\` \u2014 get generation status and result
593
+ - \`client.generateAndWait(options)\` \u2014 create generation and poll until completion
594
+
595
+ \`\`\`ts
596
+ import type { Context } from "hono";
597
+ import { connection } from "@squadbase/vite-server/connectors/gamma";
598
+
599
+ const gamma = connection("<connectionId>");
600
+
601
+ export default async function handler(c: Context) {
602
+ const { topic, numCards = 5 } = await c.req.json<{
603
+ topic: string;
604
+ numCards?: number;
605
+ }>();
606
+
607
+ const result = await gamma.generateAndWait({
608
+ inputText: topic,
609
+ textMode: "generate",
610
+ format: "presentation",
611
+ numCards,
612
+ });
613
+
614
+ return c.json(result);
615
+ }
616
+ \`\`\`
617
+
618
+ ### Gamma REST API Reference
619
+
620
+ - Base URL: \`https://public-api.gamma.app/v1.0\`
621
+ - Authentication: X-API-KEY header (handled automatically)
622
+
623
+ #### Endpoints
624
+
625
+ - POST \`/generations\` \u2014 Create a generation (presentation, document, webpage, social)
626
+ - Required: \`inputText\` (string), \`textMode\` ("generate" | "condense" | "preserve")
627
+ - Optional: \`format\`, \`numCards\`, \`themeId\`, \`textOptions\` (tone, audience, language, amount), \`imageOptions\` (source, model, style), \`additionalInstructions\`, \`exportAs\` (pdf, pptx, png), \`folderIds\`, \`sharingOptions\`
628
+ - Returns: \`{ generationId }\`
629
+ - GET \`/generations/{generationId}\` \u2014 Poll generation status
630
+ - Returns: \`{ generationId, status, gammaId?, gammaUrl?, exportUrl?, credits?, error? }\`
631
+ - Status values: "pending", "completed", "failed"
632
+ - Poll every 5 seconds until status changes from "pending"
633
+ - GET \`/themes\` \u2014 List available themes (query, limit, after for pagination)
634
+ - GET \`/folders\` \u2014 List workspace folders (query, limit, after for pagination)
635
+
636
+ #### Generation Formats
637
+ - \`presentation\` \u2014 Slide deck (dimensions: fluid, 16x9, 4x3)
638
+ - \`document\` \u2014 Document (dimensions: fluid, pageless, letter, a4)
639
+ - \`webpage\` \u2014 Web page
640
+ - \`social\` \u2014 Social media post (dimensions: 1x1, 4x5, 9x16)
641
+
642
+ #### Text Modes
643
+ - \`generate\` \u2014 AI generates new content from the input topic
644
+ - \`condense\` \u2014 AI shortens the provided text
645
+ - \`preserve\` \u2014 Input text is used as-is
646
+
647
+ #### Image Sources
648
+ - \`aiGenerated\`, \`pictographic\`, \`pexels\`, \`giphy\`, \`webFreeToUseCommercially\`, \`noImages\`, etc.
649
+
650
+ #### Data Visualization
651
+ Gamma does NOT support uploading images. If you want to visualize data (charts, graphs, tables), embed the raw numbers and data directly into \`inputText\` as structured text (e.g., markdown tables, bullet lists with figures). Gamma AI will render appropriate visual elements from the data. Do NOT generate chart images locally and try to include them \u2014 instead, pass the data values inline so Gamma can create its own visualizations.`,
652
+ ja: `### \u30C4\u30FC\u30EB
653
+
654
+ - \`gamma_request\`: Gamma REST API\u306B\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30C6\u30FC\u30DE\u4E00\u89A7\u3001\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u3001\u751F\u6210\u30B9\u30C6\u30FC\u30BF\u30B9\u306E\u78BA\u8A8D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08X-API-KEY\uFF09\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
655
+ - \`gamma_generate\`: Gamma AI\u3092\u4F7F\u3063\u3066\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3001\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3001\u30A6\u30A7\u30D6\u30DA\u30FC\u30B8\u3001\u30BD\u30FC\u30B7\u30E3\u30EB\u6295\u7A3F\u3092\u751F\u6210\u3057\u307E\u3059\u3002\u751F\u6210\u306E\u4F5C\u6210\u304B\u3089\u30DD\u30FC\u30EA\u30F3\u30B0\u3001\u7D50\u679CURL\u306E\u8FD4\u5374\u307E\u3067\u4E00\u62EC\u3067\u51E6\u7406\u3057\u307E\u3059\u3002\u624B\u52D5\u3067POST /generations + \u30DD\u30FC\u30EA\u30F3\u30B0\u3059\u308B\u3088\u308A\u3082\u3053\u3061\u3089\u3092\u63A8\u5968\u3057\u307E\u3059\u3002
656
+
657
+ ### Business Logic
658
+
659
+ \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
660
+
661
+ SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
662
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
663
+ - \`client.listThemes(options?)\` \u2014 \u30C6\u30FC\u30DE\u4E00\u89A7\u306E\u53D6\u5F97\uFF08query, limit, after\uFF09
664
+ - \`client.listFolders(options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\u306E\u53D6\u5F97\uFF08query, limit, after\uFF09
665
+ - \`client.createGeneration(options)\` \u2014 \u751F\u6210\u306E\u4F5C\u6210\u3001generationId\u3092\u8FD4\u3059
666
+ - \`client.getGeneration(generationId)\` \u2014 \u751F\u6210\u30B9\u30C6\u30FC\u30BF\u30B9\u3068\u7D50\u679C\u306E\u53D6\u5F97
667
+ - \`client.generateAndWait(options)\` \u2014 \u751F\u6210\u3092\u4F5C\u6210\u3057\u5B8C\u4E86\u307E\u3067\u30DD\u30FC\u30EA\u30F3\u30B0
668
+
669
+ \`\`\`ts
670
+ import type { Context } from "hono";
671
+ import { connection } from "@squadbase/vite-server/connectors/gamma";
672
+
673
+ const gamma = connection("<connectionId>");
674
+
675
+ export default async function handler(c: Context) {
676
+ const { topic, numCards = 5 } = await c.req.json<{
677
+ topic: string;
678
+ numCards?: number;
679
+ }>();
680
+
681
+ const result = await gamma.generateAndWait({
682
+ inputText: topic,
683
+ textMode: "generate",
684
+ format: "presentation",
685
+ numCards,
686
+ });
687
+
688
+ return c.json(result);
689
+ }
690
+ \`\`\`
691
+
692
+ ### Gamma REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
693
+
694
+ - \u30D9\u30FC\u30B9URL: \`https://public-api.gamma.app/v1.0\`
695
+ - \u8A8D\u8A3C: X-API-KEY\u30D8\u30C3\u30C0\u30FC\uFF08\u81EA\u52D5\u8A2D\u5B9A\uFF09
696
+
697
+ #### \u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
698
+
699
+ - POST \`/generations\` \u2014 \u751F\u6210\u306E\u4F5C\u6210\uFF08\u30D7\u30EC\u30BC\u30F3\u30C6\u30FC\u30B7\u30E7\u30F3\u3001\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3001\u30A6\u30A7\u30D6\u30DA\u30FC\u30B8\u3001\u30BD\u30FC\u30B7\u30E3\u30EB\uFF09
700
+ - \u5FC5\u9808: \`inputText\`\uFF08\u6587\u5B57\u5217\uFF09\u3001\`textMode\`\uFF08"generate" | "condense" | "preserve"\uFF09
701
+ - \u30AA\u30D7\u30B7\u30E7\u30F3: \`format\`, \`numCards\`, \`themeId\`, \`textOptions\`\uFF08tone, audience, language, amount\uFF09, \`imageOptions\`\uFF08source, model, style\uFF09, \`additionalInstructions\`, \`exportAs\`\uFF08pdf, pptx, png\uFF09, \`folderIds\`, \`sharingOptions\`
702
+ - \u8FD4\u5374: \`{ generationId }\`
703
+ - GET \`/generations/{generationId}\` \u2014 \u751F\u6210\u30B9\u30C6\u30FC\u30BF\u30B9\u306E\u30DD\u30FC\u30EA\u30F3\u30B0
704
+ - \u8FD4\u5374: \`{ generationId, status, gammaId?, gammaUrl?, exportUrl?, credits?, error? }\`
705
+ - \u30B9\u30C6\u30FC\u30BF\u30B9\u5024: "pending", "completed", "failed"
706
+ - status\u304C"pending"\u3067\u306A\u304F\u306A\u308B\u307E\u30675\u79D2\u3054\u3068\u306B\u30DD\u30FC\u30EA\u30F3\u30B0
707
+ - GET \`/themes\` \u2014 \u30C6\u30FC\u30DE\u4E00\u89A7\uFF08query, limit, after\u3067\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\uFF09
708
+ - GET \`/folders\` \u2014 \u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\uFF08query, limit, after\u3067\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\uFF09
709
+
710
+ #### \u751F\u6210\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8
711
+ - \`presentation\` \u2014 \u30B9\u30E9\u30A4\u30C9\u30C7\u30C3\u30AD\uFF08\u5BF8\u6CD5: fluid, 16x9, 4x3\uFF09
712
+ - \`document\` \u2014 \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\uFF08\u5BF8\u6CD5: fluid, pageless, letter, a4\uFF09
713
+ - \`webpage\` \u2014 \u30A6\u30A7\u30D6\u30DA\u30FC\u30B8
714
+ - \`social\` \u2014 \u30BD\u30FC\u30B7\u30E3\u30EB\u30E1\u30C7\u30A3\u30A2\u6295\u7A3F\uFF08\u5BF8\u6CD5: 1x1, 4x5, 9x16\uFF09
715
+
716
+ #### \u30C6\u30AD\u30B9\u30C8\u30E2\u30FC\u30C9
717
+ - \`generate\` \u2014 AI\u304C\u5165\u529B\u30C8\u30D4\u30C3\u30AF\u304B\u3089\u65B0\u3057\u3044\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u751F\u6210
718
+ - \`condense\` \u2014 AI\u304C\u63D0\u4F9B\u3055\u308C\u305F\u30C6\u30AD\u30B9\u30C8\u3092\u77ED\u7E2E
719
+ - \`preserve\` \u2014 \u5165\u529B\u30C6\u30AD\u30B9\u30C8\u3092\u305D\u306E\u307E\u307E\u4F7F\u7528
720
+
721
+ #### \u753B\u50CF\u30BD\u30FC\u30B9
722
+ - \`aiGenerated\`, \`pictographic\`, \`pexels\`, \`giphy\`, \`webFreeToUseCommercially\`, \`noImages\` \u306A\u3069
723
+
724
+ #### \u30C7\u30FC\u30BF\u306E\u53EF\u8996\u5316
725
+ Gamma\u306F\u753B\u50CF\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002\u30C7\u30FC\u30BF\u3092\u53EF\u8996\u5316\u3057\u305F\u3044\u5834\u5408\uFF08\u30C1\u30E3\u30FC\u30C8\u3001\u30B0\u30E9\u30D5\u3001\u30C6\u30FC\u30D6\u30EB\u306A\u3069\uFF09\u306F\u3001\`inputText\` \u306B\u6570\u5024\u3084\u30C7\u30FC\u30BF\u3092\u69CB\u9020\u5316\u30C6\u30AD\u30B9\u30C8\uFF08\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u30C6\u30FC\u30D6\u30EB\u3001\u6570\u5024\u4ED8\u304D\u7B87\u6761\u66F8\u304D\u306A\u3069\uFF09\u3068\u3057\u3066\u76F4\u63A5\u57CB\u3081\u8FBC\u3093\u3067\u304F\u3060\u3055\u3044\u3002Gamma AI\u304C\u30C7\u30FC\u30BF\u304B\u3089\u9069\u5207\u306A\u30D3\u30B8\u30E5\u30A2\u30EB\u8981\u7D20\u3092\u751F\u6210\u3057\u307E\u3059\u3002\u30ED\u30FC\u30AB\u30EB\u3067\u30C1\u30E3\u30FC\u30C8\u753B\u50CF\u3092\u751F\u6210\u3057\u3066\u542B\u3081\u308B\u306E\u3067\u306F\u306A\u304F\u3001\u30C7\u30FC\u30BF\u306E\u5024\u3092\u30A4\u30F3\u30E9\u30A4\u30F3\u3067\u6E21\u3057\u3066Gamma\u306B\u53EF\u8996\u5316\u3055\u305B\u3066\u304F\u3060\u3055\u3044\u3002`
726
+ },
727
+ tools
728
+ });
729
+
730
+ // src/connectors/create-connector-sdk.ts
731
+ import { readFileSync } from "fs";
732
+ import path from "path";
733
+
734
+ // src/connector-client/env.ts
735
+ function resolveEnvVar(entry, key, connectionId) {
736
+ const envVarName = entry.envVars[key];
737
+ if (!envVarName) {
738
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
739
+ }
740
+ const value = process.env[envVarName];
741
+ if (!value) {
742
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
743
+ }
744
+ return value;
745
+ }
746
+ function resolveEnvVarOptional(entry, key) {
747
+ const envVarName = entry.envVars[key];
748
+ if (!envVarName) return void 0;
749
+ return process.env[envVarName] || void 0;
750
+ }
751
+
752
+ // src/connector-client/proxy-fetch.ts
753
+ import { getContext } from "hono/context-storage";
754
+ import { getCookie } from "hono/cookie";
755
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
756
+ function createSandboxProxyFetch(connectionId) {
757
+ return async (input, init) => {
758
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
759
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
760
+ if (!token || !sandboxId) {
761
+ throw new Error(
762
+ "Connection proxy is not configured. Please check your deployment settings."
763
+ );
764
+ }
765
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
766
+ const originalMethod = init?.method ?? "GET";
767
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
768
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
769
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
770
+ return fetch(proxyUrl, {
771
+ method: "POST",
772
+ headers: {
773
+ "Content-Type": "application/json",
774
+ Authorization: `Bearer ${token}`
775
+ },
776
+ body: JSON.stringify({
777
+ url: originalUrl,
778
+ method: originalMethod,
779
+ body: originalBody
780
+ })
781
+ });
782
+ };
783
+ }
784
+ function createDeployedAppProxyFetch(connectionId) {
785
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
786
+ if (!projectId) {
787
+ throw new Error(
788
+ "Connection proxy is not configured. Please check your deployment settings."
789
+ );
790
+ }
791
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
792
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
793
+ return async (input, init) => {
794
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
795
+ const originalMethod = init?.method ?? "GET";
796
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
797
+ const c = getContext();
798
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
799
+ if (!appSession) {
800
+ throw new Error(
801
+ "No authentication method available for connection proxy."
802
+ );
803
+ }
804
+ return fetch(proxyUrl, {
805
+ method: "POST",
806
+ headers: {
807
+ "Content-Type": "application/json",
808
+ Authorization: `Bearer ${appSession}`
809
+ },
810
+ body: JSON.stringify({
811
+ url: originalUrl,
812
+ method: originalMethod,
813
+ body: originalBody
814
+ })
815
+ });
816
+ };
817
+ }
818
+ function createProxyFetch(connectionId) {
819
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
820
+ return createSandboxProxyFetch(connectionId);
821
+ }
822
+ return createDeployedAppProxyFetch(connectionId);
823
+ }
824
+
825
+ // src/connectors/create-connector-sdk.ts
826
+ function loadConnectionsSync() {
827
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
828
+ try {
829
+ const raw = readFileSync(filePath, "utf-8");
830
+ return JSON.parse(raw);
831
+ } catch {
832
+ return {};
833
+ }
834
+ }
835
+ function createConnectorSdk(plugin, createClient2) {
836
+ return (connectionId) => {
837
+ const connections = loadConnectionsSync();
838
+ const entry = connections[connectionId];
839
+ if (!entry) {
840
+ throw new Error(
841
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
842
+ );
843
+ }
844
+ if (entry.connector.slug !== plugin.slug) {
845
+ throw new Error(
846
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
847
+ );
848
+ }
849
+ const params = {};
850
+ for (const param of Object.values(plugin.parameters)) {
851
+ if (param.required) {
852
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
853
+ } else {
854
+ const val = resolveEnvVarOptional(entry, param.slug);
855
+ if (val !== void 0) params[param.slug] = val;
856
+ }
857
+ }
858
+ return createClient2(params, createProxyFetch(connectionId));
859
+ };
860
+ }
861
+
862
+ // src/connectors/entries/gamma.ts
863
+ var connection = createConnectorSdk(gammaConnector, createClient);
864
+ export {
865
+ connection
866
+ };