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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/cli/index.js +82859 -9645
  2. package/dist/connectors/airtable-oauth.js +77 -3
  3. package/dist/connectors/airtable.js +85 -2
  4. package/dist/connectors/amplitude.js +85 -2
  5. package/dist/connectors/anthropic.js +85 -2
  6. package/dist/connectors/{slack.d.ts → asana.d.ts} +1 -1
  7. package/dist/connectors/asana.js +744 -0
  8. package/dist/connectors/attio.js +85 -2
  9. package/dist/connectors/{microsoft-teams-oauth.d.ts → customerio.d.ts} +1 -1
  10. package/dist/connectors/customerio.js +716 -0
  11. package/dist/connectors/dbt.js +85 -2
  12. package/dist/connectors/gemini.js +86 -3
  13. package/dist/connectors/{microsoft-teams.d.ts → gmail-oauth.d.ts} +1 -1
  14. package/dist/connectors/gmail-oauth.js +713 -0
  15. package/dist/connectors/gmail.d.ts +5 -0
  16. package/dist/connectors/gmail.js +875 -0
  17. package/dist/connectors/google-ads-oauth.js +78 -4
  18. package/dist/connectors/google-ads.d.ts +5 -0
  19. package/dist/connectors/google-ads.js +867 -0
  20. package/dist/connectors/google-analytics-oauth.js +90 -8
  21. package/dist/connectors/google-analytics.js +85 -2
  22. package/dist/connectors/google-calendar-oauth.d.ts +5 -0
  23. package/dist/connectors/google-calendar-oauth.js +817 -0
  24. package/dist/connectors/google-calendar.d.ts +5 -0
  25. package/dist/connectors/google-calendar.js +991 -0
  26. package/dist/connectors/google-sheets-oauth.js +144 -33
  27. package/dist/connectors/google-sheets.d.ts +5 -0
  28. package/dist/connectors/google-sheets.js +707 -0
  29. package/dist/connectors/grafana.d.ts +5 -0
  30. package/dist/connectors/grafana.js +638 -0
  31. package/dist/connectors/hubspot-oauth.js +77 -3
  32. package/dist/connectors/hubspot.js +89 -6
  33. package/dist/connectors/intercom-oauth.d.ts +5 -0
  34. package/dist/connectors/intercom-oauth.js +584 -0
  35. package/dist/connectors/intercom.d.ts +5 -0
  36. package/dist/connectors/intercom.js +710 -0
  37. package/dist/connectors/jira-api-key.d.ts +5 -0
  38. package/dist/connectors/jira-api-key.js +598 -0
  39. package/dist/connectors/kintone-api-token.js +77 -3
  40. package/dist/connectors/kintone.js +86 -3
  41. package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
  42. package/dist/connectors/linkedin-ads-oauth.js +848 -0
  43. package/dist/connectors/linkedin-ads.d.ts +5 -0
  44. package/dist/connectors/linkedin-ads.js +865 -0
  45. package/dist/connectors/mailchimp-oauth.d.ts +5 -0
  46. package/dist/connectors/mailchimp-oauth.js +613 -0
  47. package/dist/connectors/mailchimp.d.ts +5 -0
  48. package/dist/connectors/mailchimp.js +729 -0
  49. package/dist/connectors/notion-oauth.d.ts +5 -0
  50. package/dist/connectors/notion-oauth.js +567 -0
  51. package/dist/connectors/notion.d.ts +5 -0
  52. package/dist/connectors/notion.js +663 -0
  53. package/dist/connectors/openai.js +85 -2
  54. package/dist/connectors/shopify-oauth.js +77 -3
  55. package/dist/connectors/shopify.js +85 -2
  56. package/dist/connectors/stripe-api-key.d.ts +5 -0
  57. package/dist/connectors/stripe-api-key.js +600 -0
  58. package/dist/connectors/stripe-oauth.js +77 -3
  59. package/dist/connectors/wix-store.js +85 -2
  60. package/dist/connectors/zendesk-oauth.d.ts +5 -0
  61. package/dist/connectors/zendesk-oauth.js +579 -0
  62. package/dist/connectors/zendesk.d.ts +5 -0
  63. package/dist/connectors/zendesk.js +714 -0
  64. package/dist/index.js +83024 -7099
  65. package/dist/main.js +82988 -7063
  66. package/dist/vite-plugin.js +82862 -6974
  67. package/package.json +86 -2
  68. package/dist/connectors/microsoft-teams-oauth.js +0 -479
  69. package/dist/connectors/microsoft-teams.js +0 -381
  70. package/dist/connectors/slack.js +0 -362
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.MailchimpOauthConnectorSdk;
4
+
5
+ export { connection };
@@ -0,0 +1,613 @@
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/mailchimp-oauth/sdk/index.ts
46
+ function createClient(params, fetchFn = fetch) {
47
+ const serverPrefix = params["server-prefix"];
48
+ if (!serverPrefix) {
49
+ throw new Error(
50
+ "mailchimp-oauth: missing required parameter: server-prefix"
51
+ );
52
+ }
53
+ const baseUrl = `https://${serverPrefix}.api.mailchimp.com/3.0`;
54
+ function request(path2, init) {
55
+ const url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
56
+ return fetchFn(url, init);
57
+ }
58
+ return { request };
59
+ }
60
+
61
+ // ../connectors/src/connector-onboarding.ts
62
+ var ConnectorOnboarding = class {
63
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
64
+ connectionSetupInstructions;
65
+ /** Phase 2: Data overview instructions */
66
+ dataOverviewInstructions;
67
+ constructor(config) {
68
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
69
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
70
+ }
71
+ getConnectionSetupPrompt(language) {
72
+ return this.connectionSetupInstructions?.[language] ?? null;
73
+ }
74
+ getDataOverviewInstructions(language) {
75
+ return this.dataOverviewInstructions[language];
76
+ }
77
+ };
78
+
79
+ // ../connectors/src/connector-tool.ts
80
+ var ConnectorTool = class {
81
+ name;
82
+ description;
83
+ inputSchema;
84
+ outputSchema;
85
+ _execute;
86
+ constructor(config) {
87
+ this.name = config.name;
88
+ this.description = config.description;
89
+ this.inputSchema = config.inputSchema;
90
+ this.outputSchema = config.outputSchema;
91
+ this._execute = config.execute;
92
+ }
93
+ createTool(connections, config) {
94
+ return {
95
+ description: this.description,
96
+ inputSchema: this.inputSchema,
97
+ outputSchema: this.outputSchema,
98
+ execute: (input) => this._execute(input, connections, config)
99
+ };
100
+ }
101
+ };
102
+
103
+ // ../connectors/src/connector-plugin.ts
104
+ var ConnectorPlugin = class _ConnectorPlugin {
105
+ slug;
106
+ authType;
107
+ name;
108
+ description;
109
+ iconUrl;
110
+ parameters;
111
+ releaseFlag;
112
+ proxyPolicy;
113
+ experimentalAttributes;
114
+ onboarding;
115
+ systemPrompt;
116
+ tools;
117
+ query;
118
+ checkConnection;
119
+ constructor(config) {
120
+ this.slug = config.slug;
121
+ this.authType = config.authType;
122
+ this.name = config.name;
123
+ this.description = config.description;
124
+ this.iconUrl = config.iconUrl;
125
+ this.parameters = config.parameters;
126
+ this.releaseFlag = config.releaseFlag;
127
+ this.proxyPolicy = config.proxyPolicy;
128
+ this.experimentalAttributes = config.experimentalAttributes;
129
+ this.onboarding = config.onboarding;
130
+ this.systemPrompt = config.systemPrompt;
131
+ this.tools = config.tools;
132
+ this.query = config.query;
133
+ this.checkConnection = config.checkConnection;
134
+ }
135
+ get connectorKey() {
136
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
137
+ }
138
+ /**
139
+ * Create tools for connections that belong to this connector.
140
+ * Filters connections by connectorKey internally.
141
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
142
+ */
143
+ createTools(connections, config) {
144
+ const myConnections = connections.filter(
145
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
146
+ );
147
+ const result = {};
148
+ for (const t of Object.values(this.tools)) {
149
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
150
+ myConnections,
151
+ config
152
+ );
153
+ }
154
+ return result;
155
+ }
156
+ static deriveKey(slug, authType) {
157
+ return authType ? `${slug}-${authType}` : slug;
158
+ }
159
+ };
160
+
161
+ // ../connectors/src/auth-types.ts
162
+ var AUTH_TYPES = {
163
+ OAUTH: "oauth",
164
+ API_KEY: "api-key",
165
+ JWT: "jwt",
166
+ SERVICE_ACCOUNT: "service-account",
167
+ PAT: "pat",
168
+ USER_PASSWORD: "user-password"
169
+ };
170
+
171
+ // ../connectors/src/connectors/mailchimp-oauth/setup.ts
172
+ var mailchimpOauthOnboarding = new ConnectorOnboarding({
173
+ dataOverviewInstructions: {
174
+ en: `1. Call mailchimp-oauth_request with GET /lists to list all audiences
175
+ 2. Pick an audience and call GET /lists/{list_id}/members?count=5 to sample members
176
+ 3. Call GET /campaigns?count=5 to list recent campaigns
177
+ 4. Call GET /reports?count=5 to view campaign reports`,
178
+ ja: `1. mailchimp-oauth_request \u3067 GET /lists \u3092\u547C\u3073\u51FA\u3057\u3001\u5168\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u4E00\u89A7\u3092\u53D6\u5F97
179
+ 2. \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u3092\u9078\u629E\u3057 GET /lists/{list_id}/members?count=5 \u3067\u30E1\u30F3\u30D0\u30FC\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
180
+ 3. GET /campaigns?count=5 \u3067\u6700\u8FD1\u306E\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u4E00\u89A7\u3092\u53D6\u5F97
181
+ 4. GET /reports?count=5 \u3067\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u3092\u8868\u793A`
182
+ }
183
+ });
184
+
185
+ // ../connectors/src/connectors/mailchimp-oauth/parameters.ts
186
+ var parameters = {
187
+ serverPrefix: new ParameterDefinition({
188
+ slug: "server-prefix",
189
+ name: "Server Prefix (Datacenter)",
190
+ description: "The Mailchimp datacenter prefix for your account (e.g., us6, us19). Found in the OAuth metadata or your Mailchimp account URL.",
191
+ envVarBaseKey: "MAILCHIMP_SERVER_PREFIX",
192
+ type: "text",
193
+ secret: false,
194
+ required: true
195
+ })
196
+ };
197
+
198
+ // ../connectors/src/connectors/mailchimp-oauth/tools/request.ts
199
+ import { z } from "zod";
200
+ var REQUEST_TIMEOUT_MS = 6e4;
201
+ var cachedToken = null;
202
+ async function getProxyToken(config) {
203
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
204
+ return cachedToken.token;
205
+ }
206
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
207
+ const res = await fetch(url, {
208
+ method: "POST",
209
+ headers: {
210
+ "Content-Type": "application/json",
211
+ "x-api-key": config.appApiKey,
212
+ "project-id": config.projectId
213
+ },
214
+ body: JSON.stringify({
215
+ sandboxId: config.sandboxId,
216
+ issuedBy: "coding-agent"
217
+ })
218
+ });
219
+ if (!res.ok) {
220
+ const errorText = await res.text().catch(() => res.statusText);
221
+ throw new Error(
222
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
223
+ );
224
+ }
225
+ const data = await res.json();
226
+ cachedToken = {
227
+ token: data.token,
228
+ expiresAt: new Date(data.expiresAt).getTime()
229
+ };
230
+ return data.token;
231
+ }
232
+ var inputSchema = z.object({
233
+ toolUseIntent: z.string().optional().describe(
234
+ "Brief description of what you intend to accomplish with this tool call"
235
+ ),
236
+ connectionId: z.string().describe("ID of the Mailchimp OAuth connection to use"),
237
+ method: z.enum(["GET", "POST", "PATCH", "PUT", "DELETE"]).describe("HTTP method"),
238
+ path: z.string().describe(
239
+ "API path appended to the base URL (e.g., '/lists', '/campaigns', '/lists/{list_id}/members')"
240
+ ),
241
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
242
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PATCH/PUT requests")
243
+ });
244
+ var outputSchema = z.discriminatedUnion("success", [
245
+ z.object({
246
+ success: z.literal(true),
247
+ status: z.number(),
248
+ data: z.record(z.string(), z.unknown())
249
+ }),
250
+ z.object({
251
+ success: z.literal(false),
252
+ error: z.string()
253
+ })
254
+ ]);
255
+ var requestTool = new ConnectorTool({
256
+ name: "request",
257
+ description: `Send authenticated requests to the Mailchimp Marketing API v3.
258
+ Authentication is handled automatically via OAuth proxy.`,
259
+ inputSchema,
260
+ outputSchema,
261
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
262
+ const connection2 = connections.find((c) => c.id === connectionId);
263
+ if (!connection2) {
264
+ return {
265
+ success: false,
266
+ error: `Connection ${connectionId} not found`
267
+ };
268
+ }
269
+ console.log(
270
+ `[connector-request] mailchimp-oauth/${connection2.name}: ${method} ${path2}`
271
+ );
272
+ try {
273
+ const serverPrefix = parameters.serverPrefix.getValue(connection2);
274
+ const baseUrl = `https://${serverPrefix}.api.mailchimp.com/3.0`;
275
+ let url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
276
+ if (queryParams) {
277
+ const searchParams = new URLSearchParams(queryParams);
278
+ url += `?${searchParams.toString()}`;
279
+ }
280
+ const token = await getProxyToken(config.oauthProxy);
281
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
282
+ const controller = new AbortController();
283
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
284
+ try {
285
+ const response = await fetch(proxyUrl, {
286
+ method: "POST",
287
+ headers: {
288
+ "Content-Type": "application/json",
289
+ Authorization: `Bearer ${token}`
290
+ },
291
+ body: JSON.stringify({
292
+ url,
293
+ method,
294
+ body: body ? JSON.stringify(body) : void 0
295
+ }),
296
+ signal: controller.signal
297
+ });
298
+ const data = await response.json();
299
+ if (!response.ok) {
300
+ const errorMessage = typeof data?.error === "string" ? data.error : typeof data?.detail === "string" ? data.detail : typeof data?.title === "string" ? data.title : `HTTP ${response.status} ${response.statusText}`;
301
+ return { success: false, error: errorMessage };
302
+ }
303
+ return { success: true, status: response.status, data };
304
+ } finally {
305
+ clearTimeout(timeout);
306
+ }
307
+ } catch (err) {
308
+ const msg = err instanceof Error ? err.message : String(err);
309
+ return { success: false, error: msg };
310
+ }
311
+ }
312
+ });
313
+
314
+ // ../connectors/src/connectors/mailchimp-oauth/index.ts
315
+ var tools = { request: requestTool };
316
+ var mailchimpOauthConnector = new ConnectorPlugin({
317
+ slug: "mailchimp",
318
+ authType: AUTH_TYPES.OAUTH,
319
+ name: "Mailchimp (OAuth)",
320
+ description: "Connect to Mailchimp for email marketing, audiences, campaigns, and analytics using OAuth.",
321
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19Rac6B8eGiLpQb4lKMbG3/10f567f85572aeb16f2ee6aaa6602987/mailchimp.png",
322
+ parameters,
323
+ releaseFlag: { dev1: true, dev2: false, prod: false },
324
+ onboarding: mailchimpOauthOnboarding,
325
+ proxyPolicy: {
326
+ allowlist: [
327
+ {
328
+ host: "*.api.mailchimp.com",
329
+ methods: ["GET", "POST", "PATCH", "PUT", "DELETE"]
330
+ }
331
+ ]
332
+ },
333
+ systemPrompt: {
334
+ en: `### Tools
335
+
336
+ - \`mailchimp-oauth_request\`: The only way to call the Mailchimp Marketing API v3. Use it to manage audiences/lists, subscribers/members, campaigns, templates, automations, and reports. Authentication is configured automatically via OAuth.
337
+
338
+ ### Mailchimp Marketing API v3 Reference
339
+
340
+ - Base URL: \`https://{dc}.api.mailchimp.com/3.0\` (datacenter from server-prefix parameter)
341
+ - Pagination: offset-based with \`count\` (default 10, max 1000) and \`offset\` parameters
342
+
343
+ #### Audiences / Lists
344
+ - GET \`/lists\` \u2014 List all audiences
345
+ - GET \`/lists/{list_id}\` \u2014 Get audience details
346
+ - POST \`/lists\` \u2014 Create an audience
347
+ - PATCH \`/lists/{list_id}\` \u2014 Update an audience
348
+ - DELETE \`/lists/{list_id}\` \u2014 Delete an audience
349
+
350
+ #### Members / Subscribers
351
+ - GET \`/lists/{list_id}/members\` \u2014 List members
352
+ - GET \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Get member (hash = MD5 of lowercase email)
353
+ - POST \`/lists/{list_id}/members\` \u2014 Add a member
354
+ - PUT \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Add or update a member
355
+ - PATCH \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Update a member
356
+ - DELETE \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Archive a member
357
+
358
+ #### Campaigns
359
+ - GET \`/campaigns\` \u2014 List campaigns
360
+ - POST \`/campaigns\` \u2014 Create a campaign
361
+ - PATCH \`/campaigns/{campaign_id}\` \u2014 Update a campaign
362
+ - DELETE \`/campaigns/{campaign_id}\` \u2014 Delete a campaign
363
+ - POST \`/campaigns/{campaign_id}/actions/send\` \u2014 Send a campaign
364
+
365
+ #### Templates
366
+ - GET \`/templates\` \u2014 List templates
367
+ - POST \`/templates\` \u2014 Create a template
368
+
369
+ #### Automations
370
+ - GET \`/automations\` \u2014 List automations
371
+ - GET \`/automations/{workflow_id}/emails\` \u2014 List automation emails
372
+
373
+ #### Reports
374
+ - GET \`/reports\` \u2014 List campaign reports
375
+ - GET \`/reports/{campaign_id}\` \u2014 Get a campaign report
376
+
377
+ #### Search
378
+ - GET \`/search-members?query={query}\` \u2014 Search members
379
+
380
+ ### Business Logic
381
+
382
+ 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.
383
+
384
+ \`\`\`ts
385
+ import { connection } from "@squadbase/vite-server/connectors/mailchimp-oauth";
386
+
387
+ const mailchimp = connection("<connectionId>");
388
+
389
+ const res = await mailchimp.request("/lists?count=10");
390
+ const data = await res.json();
391
+ \`\`\``,
392
+ ja: `### \u30C4\u30FC\u30EB
393
+
394
+ - \`mailchimp-oauth_request\`: Mailchimp Marketing API v3\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9/\u30EA\u30B9\u30C8\u3001\u30B5\u30D6\u30B9\u30AF\u30E9\u30A4\u30D0\u30FC/\u30E1\u30F3\u30D0\u30FC\u3001\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u3001\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3001\u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3\u3001\u30EC\u30DD\u30FC\u30C8\u306E\u7BA1\u7406\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
395
+
396
+ ### Mailchimp Marketing API v3 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
397
+
398
+ - \u30D9\u30FC\u30B9URL: \`https://{dc}.api.mailchimp.com/3.0\`\uFF08\u30C7\u30FC\u30BF\u30BB\u30F3\u30BF\u30FC\u306Fserver-prefix\u30D1\u30E9\u30E1\u30FC\u30BF\u304B\u3089\u53D6\u5F97\uFF09
399
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \`count\`\uFF08\u30C7\u30D5\u30A9\u30EB\u30C810\u3001\u6700\u59271000\uFF09\u3068\`offset\`\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AA\u30D5\u30BB\u30C3\u30C8\u30D9\u30FC\u30B9
400
+
401
+ #### \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9 / \u30EA\u30B9\u30C8
402
+ - GET \`/lists\` \u2014 \u5168\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u4E00\u89A7
403
+ - GET \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u8A73\u7D30
404
+ - POST \`/lists\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u4F5C\u6210
405
+ - PATCH \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u66F4\u65B0
406
+ - DELETE \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u524A\u9664
407
+
408
+ #### \u30E1\u30F3\u30D0\u30FC / \u30B5\u30D6\u30B9\u30AF\u30E9\u30A4\u30D0\u30FC
409
+ - GET \`/lists/{list_id}/members\` \u2014 \u30E1\u30F3\u30D0\u30FC\u4E00\u89A7
410
+ - GET \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8A73\u7D30\uFF08hash = \u30E1\u30FC\u30EB\u5C0F\u6587\u5B57\u306EMD5\uFF09
411
+ - POST \`/lists/{list_id}/members\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8FFD\u52A0
412
+ - PUT \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8FFD\u52A0\u307E\u305F\u306F\u66F4\u65B0
413
+ - PATCH \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u66F4\u65B0
414
+ - DELETE \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u30A2\u30FC\u30AB\u30A4\u30D6
415
+
416
+ #### \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3
417
+ - GET \`/campaigns\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u4E00\u89A7
418
+ - POST \`/campaigns\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u4F5C\u6210
419
+ - PATCH \`/campaigns/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u66F4\u65B0
420
+ - DELETE \`/campaigns/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u524A\u9664
421
+ - POST \`/campaigns/{campaign_id}/actions/send\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u9001\u4FE1
422
+
423
+ #### \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8
424
+ - GET \`/templates\` \u2014 \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u4E00\u89A7
425
+ - POST \`/templates\` \u2014 \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u4F5C\u6210
426
+
427
+ #### \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3
428
+ - GET \`/automations\` \u2014 \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3\u4E00\u89A7
429
+ - GET \`/automations/{workflow_id}/emails\` \u2014 \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3\u30E1\u30FC\u30EB\u4E00\u89A7
430
+
431
+ #### \u30EC\u30DD\u30FC\u30C8
432
+ - GET \`/reports\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
433
+ - GET \`/reports/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u306E\u53D6\u5F97
434
+
435
+ #### \u691C\u7D22
436
+ - GET \`/search-members?query={query}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u691C\u7D22
437
+
438
+ ### Business Logic
439
+
440
+ \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\u306E\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
441
+
442
+ \`\`\`ts
443
+ import { connection } from "@squadbase/vite-server/connectors/mailchimp-oauth";
444
+
445
+ const mailchimp = connection("<connectionId>");
446
+
447
+ const res = await mailchimp.request("/lists?count=10");
448
+ const data = await res.json();
449
+ \`\`\``
450
+ },
451
+ tools,
452
+ async checkConnection(params, config) {
453
+ const { proxyFetch } = config;
454
+ const serverPrefix = params["server-prefix"];
455
+ try {
456
+ const res = await proxyFetch(
457
+ `https://${serverPrefix}.api.mailchimp.com/3.0/ping`,
458
+ { method: "GET" }
459
+ );
460
+ if (!res.ok) {
461
+ const errorText = await res.text().catch(() => res.statusText);
462
+ return {
463
+ success: false,
464
+ error: `Mailchimp API failed: HTTP ${res.status} ${errorText}`
465
+ };
466
+ }
467
+ return { success: true };
468
+ } catch (error) {
469
+ return {
470
+ success: false,
471
+ error: error instanceof Error ? error.message : String(error)
472
+ };
473
+ }
474
+ }
475
+ });
476
+
477
+ // src/connectors/create-connector-sdk.ts
478
+ import { readFileSync } from "fs";
479
+ import path from "path";
480
+
481
+ // src/connector-client/env.ts
482
+ function resolveEnvVar(entry, key, connectionId) {
483
+ const envVarName = entry.envVars[key];
484
+ if (!envVarName) {
485
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
486
+ }
487
+ const value = process.env[envVarName];
488
+ if (!value) {
489
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
490
+ }
491
+ return value;
492
+ }
493
+ function resolveEnvVarOptional(entry, key) {
494
+ const envVarName = entry.envVars[key];
495
+ if (!envVarName) return void 0;
496
+ return process.env[envVarName] || void 0;
497
+ }
498
+
499
+ // src/connector-client/proxy-fetch.ts
500
+ import { getContext } from "hono/context-storage";
501
+ import { getCookie } from "hono/cookie";
502
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
503
+ function createSandboxProxyFetch(connectionId) {
504
+ return async (input, init) => {
505
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
506
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
507
+ if (!token || !sandboxId) {
508
+ throw new Error(
509
+ "Connection proxy is not configured. Please check your deployment settings."
510
+ );
511
+ }
512
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
513
+ const originalMethod = init?.method ?? "GET";
514
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
515
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
516
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
517
+ return fetch(proxyUrl, {
518
+ method: "POST",
519
+ headers: {
520
+ "Content-Type": "application/json",
521
+ Authorization: `Bearer ${token}`
522
+ },
523
+ body: JSON.stringify({
524
+ url: originalUrl,
525
+ method: originalMethod,
526
+ body: originalBody
527
+ })
528
+ });
529
+ };
530
+ }
531
+ function createDeployedAppProxyFetch(connectionId) {
532
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
533
+ if (!projectId) {
534
+ throw new Error(
535
+ "Connection proxy is not configured. Please check your deployment settings."
536
+ );
537
+ }
538
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
539
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
540
+ return async (input, init) => {
541
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
542
+ const originalMethod = init?.method ?? "GET";
543
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
544
+ const c = getContext();
545
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
546
+ if (!appSession) {
547
+ throw new Error(
548
+ "No authentication method available for connection proxy."
549
+ );
550
+ }
551
+ return fetch(proxyUrl, {
552
+ method: "POST",
553
+ headers: {
554
+ "Content-Type": "application/json",
555
+ Authorization: `Bearer ${appSession}`
556
+ },
557
+ body: JSON.stringify({
558
+ url: originalUrl,
559
+ method: originalMethod,
560
+ body: originalBody
561
+ })
562
+ });
563
+ };
564
+ }
565
+ function createProxyFetch(connectionId) {
566
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
567
+ return createSandboxProxyFetch(connectionId);
568
+ }
569
+ return createDeployedAppProxyFetch(connectionId);
570
+ }
571
+
572
+ // src/connectors/create-connector-sdk.ts
573
+ function loadConnectionsSync() {
574
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
575
+ try {
576
+ const raw = readFileSync(filePath, "utf-8");
577
+ return JSON.parse(raw);
578
+ } catch {
579
+ return {};
580
+ }
581
+ }
582
+ function createConnectorSdk(plugin, createClient2) {
583
+ return (connectionId) => {
584
+ const connections = loadConnectionsSync();
585
+ const entry = connections[connectionId];
586
+ if (!entry) {
587
+ throw new Error(
588
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
589
+ );
590
+ }
591
+ if (entry.connector.slug !== plugin.slug) {
592
+ throw new Error(
593
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
594
+ );
595
+ }
596
+ const params = {};
597
+ for (const param of Object.values(plugin.parameters)) {
598
+ if (param.required) {
599
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
600
+ } else {
601
+ const val = resolveEnvVarOptional(entry, param.slug);
602
+ if (val !== void 0) params[param.slug] = val;
603
+ }
604
+ }
605
+ return createClient2(params, createProxyFetch(connectionId));
606
+ };
607
+ }
608
+
609
+ // src/connectors/entries/mailchimp-oauth.ts
610
+ var connection = createConnectorSdk(mailchimpOauthConnector, createClient);
611
+ export {
612
+ connection
613
+ };
@@ -0,0 +1,5 @@
1
+ import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
+
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.MailchimpConnectorSdk;
4
+
5
+ export { connection };