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

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 (34) hide show
  1. package/dist/cli/index.js +13282 -4299
  2. package/dist/connectors/asana.d.ts +5 -0
  3. package/dist/connectors/asana.js +661 -0
  4. package/dist/connectors/customerio.d.ts +5 -0
  5. package/dist/connectors/customerio.js +633 -0
  6. package/dist/connectors/gmail-oauth.d.ts +5 -0
  7. package/dist/connectors/gmail-oauth.js +639 -0
  8. package/dist/connectors/google-ads.d.ts +5 -0
  9. package/dist/connectors/google-ads.js +784 -0
  10. package/dist/connectors/google-sheets.d.ts +5 -0
  11. package/dist/connectors/google-sheets.js +598 -0
  12. package/dist/connectors/hubspot.js +14 -5
  13. package/dist/connectors/intercom-oauth.d.ts +5 -0
  14. package/dist/connectors/intercom-oauth.js +510 -0
  15. package/dist/connectors/intercom.d.ts +5 -0
  16. package/dist/connectors/intercom.js +627 -0
  17. package/dist/connectors/jira-api-key.d.ts +5 -0
  18. package/dist/connectors/jira-api-key.js +523 -0
  19. package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
  20. package/dist/connectors/linkedin-ads-oauth.js +774 -0
  21. package/dist/connectors/linkedin-ads.d.ts +5 -0
  22. package/dist/connectors/linkedin-ads.js +782 -0
  23. package/dist/connectors/mailchimp-oauth.d.ts +5 -0
  24. package/dist/connectors/mailchimp-oauth.js +539 -0
  25. package/dist/connectors/mailchimp.d.ts +5 -0
  26. package/dist/connectors/mailchimp.js +646 -0
  27. package/dist/connectors/zendesk-oauth.d.ts +5 -0
  28. package/dist/connectors/zendesk-oauth.js +505 -0
  29. package/dist/connectors/zendesk.d.ts +5 -0
  30. package/dist/connectors/zendesk.js +631 -0
  31. package/dist/index.js +13238 -4255
  32. package/dist/main.js +13240 -4257
  33. package/dist/vite-plugin.js +13240 -4257
  34. package/package.json +42 -2
@@ -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,539 @@
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
+ };
169
+
170
+ // ../connectors/src/connectors/mailchimp-oauth/setup.ts
171
+ var mailchimpOauthOnboarding = new ConnectorOnboarding({
172
+ dataOverviewInstructions: {
173
+ en: `1. Call mailchimp-oauth_request with GET /lists to list all audiences
174
+ 2. Pick an audience and call GET /lists/{list_id}/members?count=5 to sample members
175
+ 3. Call GET /campaigns?count=5 to list recent campaigns
176
+ 4. Call GET /reports?count=5 to view campaign reports`,
177
+ 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
178
+ 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
179
+ 3. GET /campaigns?count=5 \u3067\u6700\u8FD1\u306E\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u4E00\u89A7\u3092\u53D6\u5F97
180
+ 4. GET /reports?count=5 \u3067\u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u3092\u8868\u793A`
181
+ }
182
+ });
183
+
184
+ // ../connectors/src/connectors/mailchimp-oauth/parameters.ts
185
+ var parameters = {
186
+ serverPrefix: new ParameterDefinition({
187
+ slug: "server-prefix",
188
+ name: "Server Prefix (Datacenter)",
189
+ description: "The Mailchimp datacenter prefix for your account (e.g., us6, us19). Found in the OAuth metadata or your Mailchimp account URL.",
190
+ envVarBaseKey: "MAILCHIMP_SERVER_PREFIX",
191
+ type: "text",
192
+ secret: false,
193
+ required: true
194
+ })
195
+ };
196
+
197
+ // ../connectors/src/connectors/mailchimp-oauth/tools/request.ts
198
+ import { z } from "zod";
199
+ var REQUEST_TIMEOUT_MS = 6e4;
200
+ var cachedToken = null;
201
+ async function getProxyToken(config) {
202
+ if (cachedToken && cachedToken.expiresAt > Date.now() + 6e4) {
203
+ return cachedToken.token;
204
+ }
205
+ const url = `${config.appApiBaseUrl}/v0/database/${config.projectId}/environment/${config.environmentId}/oauth-request-proxy-token`;
206
+ const res = await fetch(url, {
207
+ method: "POST",
208
+ headers: {
209
+ "Content-Type": "application/json",
210
+ "x-api-key": config.appApiKey,
211
+ "project-id": config.projectId
212
+ },
213
+ body: JSON.stringify({
214
+ sandboxId: config.sandboxId,
215
+ issuedBy: "coding-agent"
216
+ })
217
+ });
218
+ if (!res.ok) {
219
+ const errorText = await res.text().catch(() => res.statusText);
220
+ throw new Error(
221
+ `Failed to get proxy token: HTTP ${res.status} ${errorText}`
222
+ );
223
+ }
224
+ const data = await res.json();
225
+ cachedToken = {
226
+ token: data.token,
227
+ expiresAt: new Date(data.expiresAt).getTime()
228
+ };
229
+ return data.token;
230
+ }
231
+ var inputSchema = z.object({
232
+ toolUseIntent: z.string().optional().describe(
233
+ "Brief description of what you intend to accomplish with this tool call"
234
+ ),
235
+ connectionId: z.string().describe("ID of the Mailchimp OAuth connection to use"),
236
+ method: z.enum(["GET", "POST", "PATCH", "PUT", "DELETE"]).describe("HTTP method"),
237
+ path: z.string().describe(
238
+ "API path appended to the base URL (e.g., '/lists', '/campaigns', '/lists/{list_id}/members')"
239
+ ),
240
+ queryParams: z.record(z.string(), z.string()).optional().describe("Query parameters to append to the URL"),
241
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body (JSON) for POST/PATCH/PUT requests")
242
+ });
243
+ var outputSchema = z.discriminatedUnion("success", [
244
+ z.object({
245
+ success: z.literal(true),
246
+ status: z.number(),
247
+ data: z.record(z.string(), z.unknown())
248
+ }),
249
+ z.object({
250
+ success: z.literal(false),
251
+ error: z.string()
252
+ })
253
+ ]);
254
+ var requestTool = new ConnectorTool({
255
+ name: "request",
256
+ description: `Send authenticated requests to the Mailchimp Marketing API v3.
257
+ Authentication is handled automatically via OAuth proxy.`,
258
+ inputSchema,
259
+ outputSchema,
260
+ async execute({ connectionId, method, path: path2, queryParams, body }, connections, config) {
261
+ const connection2 = connections.find((c) => c.id === connectionId);
262
+ if (!connection2) {
263
+ return {
264
+ success: false,
265
+ error: `Connection ${connectionId} not found`
266
+ };
267
+ }
268
+ console.log(
269
+ `[connector-request] mailchimp-oauth/${connection2.name}: ${method} ${path2}`
270
+ );
271
+ try {
272
+ const serverPrefix = parameters.serverPrefix.getValue(connection2);
273
+ const baseUrl = `https://${serverPrefix}.api.mailchimp.com/3.0`;
274
+ let url = `${baseUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
275
+ if (queryParams) {
276
+ const searchParams = new URLSearchParams(queryParams);
277
+ url += `?${searchParams.toString()}`;
278
+ }
279
+ const token = await getProxyToken(config.oauthProxy);
280
+ const proxyUrl = `https://${config.oauthProxy.sandboxId}.${config.oauthProxy.previewBaseDomain}/_sqcore/connections/${connectionId}/request`;
281
+ const controller = new AbortController();
282
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
283
+ try {
284
+ const response = await fetch(proxyUrl, {
285
+ method: "POST",
286
+ headers: {
287
+ "Content-Type": "application/json",
288
+ Authorization: `Bearer ${token}`
289
+ },
290
+ body: JSON.stringify({
291
+ url,
292
+ method,
293
+ body: body ? JSON.stringify(body) : void 0
294
+ }),
295
+ signal: controller.signal
296
+ });
297
+ const data = await response.json();
298
+ if (!response.ok) {
299
+ 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}`;
300
+ return { success: false, error: errorMessage };
301
+ }
302
+ return { success: true, status: response.status, data };
303
+ } finally {
304
+ clearTimeout(timeout);
305
+ }
306
+ } catch (err) {
307
+ const msg = err instanceof Error ? err.message : String(err);
308
+ return { success: false, error: msg };
309
+ }
310
+ }
311
+ });
312
+
313
+ // ../connectors/src/connectors/mailchimp-oauth/index.ts
314
+ var tools = { request: requestTool };
315
+ var mailchimpOauthConnector = new ConnectorPlugin({
316
+ slug: "mailchimp",
317
+ authType: AUTH_TYPES.OAUTH,
318
+ name: "Mailchimp (OAuth)",
319
+ description: "Connect to Mailchimp for email marketing, audiences, campaigns, and analytics using OAuth.",
320
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5JXJ9GsMCDsJtGhO2EgTDj/a3a62e7a4e4e4e4e4e4e4e4e4e4e4e4e/mailchimp.svg",
321
+ parameters,
322
+ releaseFlag: { dev1: true, dev2: false, prod: false },
323
+ onboarding: mailchimpOauthOnboarding,
324
+ proxyPolicy: {
325
+ allowlist: [
326
+ {
327
+ host: "*.api.mailchimp.com",
328
+ methods: ["GET", "POST", "PATCH", "PUT", "DELETE"]
329
+ }
330
+ ]
331
+ },
332
+ systemPrompt: {
333
+ en: `### Tools
334
+
335
+ - \`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.
336
+
337
+ ### Mailchimp Marketing API v3 Reference
338
+
339
+ - Base URL: \`https://{dc}.api.mailchimp.com/3.0\` (datacenter from server-prefix parameter)
340
+ - Pagination: offset-based with \`count\` (default 10, max 1000) and \`offset\` parameters
341
+
342
+ #### Audiences / Lists
343
+ - GET \`/lists\` \u2014 List all audiences
344
+ - GET \`/lists/{list_id}\` \u2014 Get audience details
345
+ - POST \`/lists\` \u2014 Create an audience
346
+ - PATCH \`/lists/{list_id}\` \u2014 Update an audience
347
+ - DELETE \`/lists/{list_id}\` \u2014 Delete an audience
348
+
349
+ #### Members / Subscribers
350
+ - GET \`/lists/{list_id}/members\` \u2014 List members
351
+ - GET \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Get member (hash = MD5 of lowercase email)
352
+ - POST \`/lists/{list_id}/members\` \u2014 Add a member
353
+ - PUT \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Add or update a member
354
+ - PATCH \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Update a member
355
+ - DELETE \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 Archive a member
356
+
357
+ #### Campaigns
358
+ - GET \`/campaigns\` \u2014 List campaigns
359
+ - POST \`/campaigns\` \u2014 Create a campaign
360
+ - PATCH \`/campaigns/{campaign_id}\` \u2014 Update a campaign
361
+ - DELETE \`/campaigns/{campaign_id}\` \u2014 Delete a campaign
362
+ - POST \`/campaigns/{campaign_id}/actions/send\` \u2014 Send a campaign
363
+
364
+ #### Templates
365
+ - GET \`/templates\` \u2014 List templates
366
+ - POST \`/templates\` \u2014 Create a template
367
+
368
+ #### Automations
369
+ - GET \`/automations\` \u2014 List automations
370
+ - GET \`/automations/{workflow_id}/emails\` \u2014 List automation emails
371
+
372
+ #### Reports
373
+ - GET \`/reports\` \u2014 List campaign reports
374
+ - GET \`/reports/{campaign_id}\` \u2014 Get a campaign report
375
+
376
+ #### Search
377
+ - GET \`/search-members?query={query}\` \u2014 Search members
378
+
379
+ ### Business Logic
380
+
381
+ 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.
382
+
383
+ \`\`\`ts
384
+ import { connection } from "@squadbase/vite-server/connectors/mailchimp-oauth";
385
+
386
+ const mailchimp = connection("<connectionId>");
387
+
388
+ const res = await mailchimp.request("/lists?count=10");
389
+ const data = await res.json();
390
+ \`\`\``,
391
+ ja: `### \u30C4\u30FC\u30EB
392
+
393
+ - \`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
394
+
395
+ ### Mailchimp Marketing API v3 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
396
+
397
+ - \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
398
+ - \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
399
+
400
+ #### \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9 / \u30EA\u30B9\u30C8
401
+ - GET \`/lists\` \u2014 \u5168\u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u4E00\u89A7
402
+ - GET \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u8A73\u7D30
403
+ - POST \`/lists\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u4F5C\u6210
404
+ - PATCH \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u66F4\u65B0
405
+ - DELETE \`/lists/{list_id}\` \u2014 \u30AA\u30FC\u30C7\u30A3\u30A8\u30F3\u30B9\u306E\u524A\u9664
406
+
407
+ #### \u30E1\u30F3\u30D0\u30FC / \u30B5\u30D6\u30B9\u30AF\u30E9\u30A4\u30D0\u30FC
408
+ - GET \`/lists/{list_id}/members\` \u2014 \u30E1\u30F3\u30D0\u30FC\u4E00\u89A7
409
+ - GET \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8A73\u7D30\uFF08hash = \u30E1\u30FC\u30EB\u5C0F\u6587\u5B57\u306EMD5\uFF09
410
+ - POST \`/lists/{list_id}/members\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8FFD\u52A0
411
+ - PUT \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u8FFD\u52A0\u307E\u305F\u306F\u66F4\u65B0
412
+ - PATCH \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u66F4\u65B0
413
+ - DELETE \`/lists/{list_id}/members/{subscriber_hash}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u306E\u30A2\u30FC\u30AB\u30A4\u30D6
414
+
415
+ #### \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3
416
+ - GET \`/campaigns\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u4E00\u89A7
417
+ - POST \`/campaigns\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u4F5C\u6210
418
+ - PATCH \`/campaigns/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u66F4\u65B0
419
+ - DELETE \`/campaigns/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u524A\u9664
420
+ - POST \`/campaigns/{campaign_id}/actions/send\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u306E\u9001\u4FE1
421
+
422
+ #### \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8
423
+ - GET \`/templates\` \u2014 \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u4E00\u89A7
424
+ - POST \`/templates\` \u2014 \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u306E\u4F5C\u6210
425
+
426
+ #### \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3
427
+ - GET \`/automations\` \u2014 \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3\u4E00\u89A7
428
+ - GET \`/automations/{workflow_id}/emails\` \u2014 \u30AA\u30FC\u30C8\u30E1\u30FC\u30B7\u30E7\u30F3\u30E1\u30FC\u30EB\u4E00\u89A7
429
+
430
+ #### \u30EC\u30DD\u30FC\u30C8
431
+ - GET \`/reports\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u4E00\u89A7
432
+ - GET \`/reports/{campaign_id}\` \u2014 \u30AD\u30E3\u30F3\u30DA\u30FC\u30F3\u30EC\u30DD\u30FC\u30C8\u306E\u53D6\u5F97
433
+
434
+ #### \u691C\u7D22
435
+ - GET \`/search-members?query={query}\` \u2014 \u30E1\u30F3\u30D0\u30FC\u691C\u7D22
436
+
437
+ ### Business Logic
438
+
439
+ \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
440
+
441
+ \`\`\`ts
442
+ import { connection } from "@squadbase/vite-server/connectors/mailchimp-oauth";
443
+
444
+ const mailchimp = connection("<connectionId>");
445
+
446
+ const res = await mailchimp.request("/lists?count=10");
447
+ const data = await res.json();
448
+ \`\`\``
449
+ },
450
+ tools,
451
+ async checkConnection(params, config) {
452
+ const { proxyFetch } = config;
453
+ const serverPrefix = params["server-prefix"];
454
+ try {
455
+ const res = await proxyFetch(
456
+ `https://${serverPrefix}.api.mailchimp.com/3.0/ping`,
457
+ { method: "GET" }
458
+ );
459
+ if (!res.ok) {
460
+ const errorText = await res.text().catch(() => res.statusText);
461
+ return {
462
+ success: false,
463
+ error: `Mailchimp API failed: HTTP ${res.status} ${errorText}`
464
+ };
465
+ }
466
+ return { success: true };
467
+ } catch (error) {
468
+ return {
469
+ success: false,
470
+ error: error instanceof Error ? error.message : String(error)
471
+ };
472
+ }
473
+ }
474
+ });
475
+
476
+ // src/connectors/create-connector-sdk.ts
477
+ import { readFileSync } from "fs";
478
+ import path from "path";
479
+
480
+ // src/connector-client/env.ts
481
+ function resolveEnvVar(entry, key, connectionId) {
482
+ const envVarName = entry.envVars[key];
483
+ if (!envVarName) {
484
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
485
+ }
486
+ const value = process.env[envVarName];
487
+ if (!value) {
488
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
489
+ }
490
+ return value;
491
+ }
492
+ function resolveEnvVarOptional(entry, key) {
493
+ const envVarName = entry.envVars[key];
494
+ if (!envVarName) return void 0;
495
+ return process.env[envVarName] || void 0;
496
+ }
497
+
498
+ // src/connectors/create-connector-sdk.ts
499
+ function loadConnectionsSync() {
500
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
501
+ try {
502
+ const raw = readFileSync(filePath, "utf-8");
503
+ return JSON.parse(raw);
504
+ } catch {
505
+ return {};
506
+ }
507
+ }
508
+ function createConnectorSdk(plugin, createClient2) {
509
+ return (connectionId) => {
510
+ const connections = loadConnectionsSync();
511
+ const entry = connections[connectionId];
512
+ if (!entry) {
513
+ throw new Error(
514
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
515
+ );
516
+ }
517
+ if (entry.connector.slug !== plugin.slug) {
518
+ throw new Error(
519
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
520
+ );
521
+ }
522
+ const params = {};
523
+ for (const param of Object.values(plugin.parameters)) {
524
+ if (param.required) {
525
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
526
+ } else {
527
+ const val = resolveEnvVarOptional(entry, param.slug);
528
+ if (val !== void 0) params[param.slug] = val;
529
+ }
530
+ }
531
+ return createClient2(params);
532
+ };
533
+ }
534
+
535
+ // src/connectors/entries/mailchimp-oauth.ts
536
+ var connection = createConnectorSdk(mailchimpOauthConnector, createClient);
537
+ export {
538
+ connection
539
+ };
@@ -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 };