@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,744 @@
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/asana/parameters.ts
46
+ var parameters = {
47
+ personalAccessToken: new ParameterDefinition({
48
+ slug: "personal-access-token",
49
+ name: "Asana Personal Access Token",
50
+ description: "Personal Access Token for Asana API authentication. Generate one at https://app.asana.com/0/my-apps",
51
+ envVarBaseKey: "ASANA_PERSONAL_ACCESS_TOKEN",
52
+ type: "text",
53
+ secret: true,
54
+ required: true
55
+ })
56
+ };
57
+
58
+ // ../connectors/src/connectors/asana/sdk/index.ts
59
+ var BASE_URL = "https://app.asana.com/api/1.0";
60
+ function createClient(params) {
61
+ const token = params[parameters.personalAccessToken.slug];
62
+ if (!token) {
63
+ throw new Error(
64
+ `asana: missing required parameter: ${parameters.personalAccessToken.slug}`
65
+ );
66
+ }
67
+ function authHeaders(extra) {
68
+ const headers = new Headers(extra);
69
+ headers.set("Authorization", `Bearer ${token}`);
70
+ headers.set("Content-Type", "application/json");
71
+ headers.set("Accept", "application/json");
72
+ return headers;
73
+ }
74
+ async function assertOk(res, label) {
75
+ if (!res.ok) {
76
+ const body = await res.text().catch(() => "(unreadable body)");
77
+ throw new Error(
78
+ `asana ${label}: ${res.status} ${res.statusText} \u2014 ${body}`
79
+ );
80
+ }
81
+ }
82
+ function buildQuery(base, opt_fields) {
83
+ const params2 = new URLSearchParams();
84
+ for (const [key, value] of Object.entries(base)) {
85
+ if (value !== void 0) params2.set(key, String(value));
86
+ }
87
+ if (opt_fields && opt_fields.length > 0) {
88
+ params2.set("opt_fields", opt_fields.join(","));
89
+ }
90
+ const qs = params2.toString();
91
+ return qs ? `?${qs}` : "";
92
+ }
93
+ return {
94
+ request(path2, init) {
95
+ const url = `${BASE_URL}${path2}`;
96
+ const headers = new Headers(init?.headers);
97
+ headers.set("Authorization", `Bearer ${token}`);
98
+ headers.set("Content-Type", "application/json");
99
+ headers.set("Accept", "application/json");
100
+ return fetch(url, { ...init, headers });
101
+ },
102
+ async listWorkspaces(options) {
103
+ const qs = buildQuery(
104
+ { limit: options?.limit, offset: options?.offset },
105
+ options?.opt_fields
106
+ );
107
+ const res = await fetch(`${BASE_URL}/workspaces${qs}`, {
108
+ method: "GET",
109
+ headers: authHeaders()
110
+ });
111
+ await assertOk(res, "listWorkspaces");
112
+ return await res.json();
113
+ },
114
+ async listProjects(workspaceGid, options) {
115
+ const qs = buildQuery(
116
+ {
117
+ workspace: workspaceGid,
118
+ archived: options?.archived,
119
+ limit: options?.limit,
120
+ offset: options?.offset
121
+ },
122
+ options?.opt_fields
123
+ );
124
+ const res = await fetch(`${BASE_URL}/projects${qs}`, {
125
+ method: "GET",
126
+ headers: authHeaders()
127
+ });
128
+ await assertOk(res, "listProjects");
129
+ return await res.json();
130
+ },
131
+ async listTasks(projectGid, options) {
132
+ const qs = buildQuery(
133
+ {
134
+ project: projectGid,
135
+ completed_since: options?.completed_since,
136
+ limit: options?.limit,
137
+ offset: options?.offset
138
+ },
139
+ options?.opt_fields
140
+ );
141
+ const res = await fetch(`${BASE_URL}/tasks${qs}`, {
142
+ method: "GET",
143
+ headers: authHeaders()
144
+ });
145
+ await assertOk(res, "listTasks");
146
+ return await res.json();
147
+ },
148
+ async getTask(taskGid, options) {
149
+ const qs = buildQuery({}, options?.opt_fields);
150
+ const res = await fetch(
151
+ `${BASE_URL}/tasks/${encodeURIComponent(taskGid)}${qs}`,
152
+ { method: "GET", headers: authHeaders() }
153
+ );
154
+ await assertOk(res, "getTask");
155
+ return await res.json();
156
+ },
157
+ async createTask(taskData) {
158
+ const res = await fetch(`${BASE_URL}/tasks`, {
159
+ method: "POST",
160
+ headers: authHeaders(),
161
+ body: JSON.stringify({ data: taskData })
162
+ });
163
+ await assertOk(res, "createTask");
164
+ return await res.json();
165
+ },
166
+ async updateTask(taskGid, taskData) {
167
+ const res = await fetch(
168
+ `${BASE_URL}/tasks/${encodeURIComponent(taskGid)}`,
169
+ {
170
+ method: "PUT",
171
+ headers: authHeaders(),
172
+ body: JSON.stringify({ data: taskData })
173
+ }
174
+ );
175
+ await assertOk(res, "updateTask");
176
+ return await res.json();
177
+ },
178
+ async listUsers(workspaceGid, options) {
179
+ const qs = buildQuery(
180
+ {
181
+ workspace: workspaceGid,
182
+ limit: options?.limit,
183
+ offset: options?.offset
184
+ },
185
+ options?.opt_fields
186
+ );
187
+ const res = await fetch(`${BASE_URL}/users${qs}`, {
188
+ method: "GET",
189
+ headers: authHeaders()
190
+ });
191
+ await assertOk(res, "listUsers");
192
+ return await res.json();
193
+ }
194
+ };
195
+ }
196
+
197
+ // ../connectors/src/connector-onboarding.ts
198
+ var ConnectorOnboarding = class {
199
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
200
+ connectionSetupInstructions;
201
+ /** Phase 2: Data overview instructions */
202
+ dataOverviewInstructions;
203
+ constructor(config) {
204
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
205
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
206
+ }
207
+ getConnectionSetupPrompt(language) {
208
+ return this.connectionSetupInstructions?.[language] ?? null;
209
+ }
210
+ getDataOverviewInstructions(language) {
211
+ return this.dataOverviewInstructions[language];
212
+ }
213
+ };
214
+
215
+ // ../connectors/src/connector-tool.ts
216
+ var ConnectorTool = class {
217
+ name;
218
+ description;
219
+ inputSchema;
220
+ outputSchema;
221
+ _execute;
222
+ constructor(config) {
223
+ this.name = config.name;
224
+ this.description = config.description;
225
+ this.inputSchema = config.inputSchema;
226
+ this.outputSchema = config.outputSchema;
227
+ this._execute = config.execute;
228
+ }
229
+ createTool(connections, config) {
230
+ return {
231
+ description: this.description,
232
+ inputSchema: this.inputSchema,
233
+ outputSchema: this.outputSchema,
234
+ execute: (input) => this._execute(input, connections, config)
235
+ };
236
+ }
237
+ };
238
+
239
+ // ../connectors/src/connector-plugin.ts
240
+ var ConnectorPlugin = class _ConnectorPlugin {
241
+ slug;
242
+ authType;
243
+ name;
244
+ description;
245
+ iconUrl;
246
+ parameters;
247
+ releaseFlag;
248
+ proxyPolicy;
249
+ experimentalAttributes;
250
+ onboarding;
251
+ systemPrompt;
252
+ tools;
253
+ query;
254
+ checkConnection;
255
+ constructor(config) {
256
+ this.slug = config.slug;
257
+ this.authType = config.authType;
258
+ this.name = config.name;
259
+ this.description = config.description;
260
+ this.iconUrl = config.iconUrl;
261
+ this.parameters = config.parameters;
262
+ this.releaseFlag = config.releaseFlag;
263
+ this.proxyPolicy = config.proxyPolicy;
264
+ this.experimentalAttributes = config.experimentalAttributes;
265
+ this.onboarding = config.onboarding;
266
+ this.systemPrompt = config.systemPrompt;
267
+ this.tools = config.tools;
268
+ this.query = config.query;
269
+ this.checkConnection = config.checkConnection;
270
+ }
271
+ get connectorKey() {
272
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
273
+ }
274
+ /**
275
+ * Create tools for connections that belong to this connector.
276
+ * Filters connections by connectorKey internally.
277
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
278
+ */
279
+ createTools(connections, config) {
280
+ const myConnections = connections.filter(
281
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
282
+ );
283
+ const result = {};
284
+ for (const t of Object.values(this.tools)) {
285
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
286
+ myConnections,
287
+ config
288
+ );
289
+ }
290
+ return result;
291
+ }
292
+ static deriveKey(slug, authType) {
293
+ return authType ? `${slug}-${authType}` : slug;
294
+ }
295
+ };
296
+
297
+ // ../connectors/src/auth-types.ts
298
+ var AUTH_TYPES = {
299
+ OAUTH: "oauth",
300
+ API_KEY: "api-key",
301
+ JWT: "jwt",
302
+ SERVICE_ACCOUNT: "service-account",
303
+ PAT: "pat",
304
+ USER_PASSWORD: "user-password"
305
+ };
306
+
307
+ // ../connectors/src/connectors/asana/setup.ts
308
+ var asanaOnboarding = new ConnectorOnboarding({
309
+ dataOverviewInstructions: {
310
+ en: `1. Call asana_request with GET /workspaces to list all available workspaces
311
+ 2. Pick the first workspace and call asana_request with GET /projects?workspace=WORKSPACE_GID&opt_fields=name,archived,created_at to list projects
312
+ 3. Pick one project and call asana_request with GET /tasks?project=PROJECT_GID&opt_fields=name,completed,assignee.name,due_on,created_at&limit=10 to sample tasks
313
+ 4. Explore sections via GET /sections?project=PROJECT_GID if the project uses board or section-based workflows`,
314
+ ja: `1. asana_request \u3067 GET /workspaces \u3092\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97
315
+ 2. \u6700\u521D\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u9078\u3073\u3001asana_request \u3067 GET /projects?workspace=WORKSPACE_GID&opt_fields=name,archived,created_at \u3092\u547C\u3073\u51FA\u3057\u3066\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
316
+ 3. \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30921\u3064\u9078\u3073\u3001asana_request \u3067 GET /tasks?project=PROJECT_GID&opt_fields=name,completed,assignee.name,due_on,created_at&limit=10 \u3092\u547C\u3073\u51FA\u3057\u3066\u30BF\u30B9\u30AF\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
317
+ 4. \u30DC\u30FC\u30C9\u3084\u30BB\u30AF\u30B7\u30E7\u30F3\u30D9\u30FC\u30B9\u306E\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u306E\u5834\u5408\u306F GET /sections?project=PROJECT_GID \u3067\u30BB\u30AF\u30B7\u30E7\u30F3\u3092\u78BA\u8A8D`
318
+ }
319
+ });
320
+
321
+ // ../connectors/src/connectors/asana/tools/request.ts
322
+ import { z } from "zod";
323
+ var BASE_URL2 = "https://app.asana.com/api/1.0";
324
+ var REQUEST_TIMEOUT_MS = 6e4;
325
+ var inputSchema = z.object({
326
+ toolUseIntent: z.string().optional().describe(
327
+ "Brief description of what you intend to accomplish with this tool call"
328
+ ),
329
+ connectionId: z.string().describe("ID of the Asana connection to use"),
330
+ method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe(
331
+ "HTTP method. GET for reading resources, POST for creating, PUT for updating, DELETE for removing."
332
+ ),
333
+ path: z.string().describe(
334
+ "API path (e.g., '/workspaces', '/projects', '/tasks', '/tasks/{task_gid}'). Query parameters can be appended (e.g., '/tasks?project=PROJECT_GID&opt_fields=name,completed')."
335
+ ),
336
+ body: z.record(z.string(), z.unknown()).optional().describe(
337
+ 'Request body (JSON) for POST/PUT requests. Wrap payload in a "data" key (e.g., { "data": { "name": "My Task", "workspace": "WORKSPACE_GID" } }).'
338
+ )
339
+ });
340
+ var outputSchema = z.discriminatedUnion("success", [
341
+ z.object({
342
+ success: z.literal(true),
343
+ status: z.number(),
344
+ data: z.record(z.string(), z.unknown())
345
+ }),
346
+ z.object({
347
+ success: z.literal(false),
348
+ error: z.string()
349
+ })
350
+ ]);
351
+ var requestTool = new ConnectorTool({
352
+ name: "request",
353
+ description: `Send authenticated requests to the Asana REST API.
354
+ Authentication is handled automatically using the Personal Access Token (Bearer token).
355
+ Provide the API path relative to the base URL (https://app.asana.com/api/1.0).
356
+ Use opt_fields query parameter to request specific fields and reduce response size.
357
+
358
+ Common endpoints:
359
+ - GET /workspaces \u2014 List workspaces
360
+ - GET /projects?workspace=WORKSPACE_GID \u2014 List projects in a workspace
361
+ - GET /tasks?project=PROJECT_GID \u2014 List tasks in a project
362
+ - GET /tasks/{task_gid} \u2014 Get a single task
363
+ - POST /tasks \u2014 Create a task (body: { "data": { "name": "...", "workspace": "..." } })
364
+ - PUT /tasks/{task_gid} \u2014 Update a task
365
+ - GET /users?workspace=WORKSPACE_GID \u2014 List users in a workspace
366
+ - GET /sections?project=PROJECT_GID \u2014 List sections in a project
367
+ - GET /tags?workspace=WORKSPACE_GID \u2014 List tags
368
+ - POST /tasks/{task_gid}/subtasks \u2014 Create a subtask
369
+ - GET /tasks/{task_gid}/stories \u2014 Get task comments/stories
370
+
371
+ Pagination: Use limit (1-100) and offset query parameters. The response includes next_page.offset for the next page.`,
372
+ inputSchema,
373
+ outputSchema,
374
+ async execute({ connectionId, method, path: path2, body }, connections) {
375
+ const connection2 = connections.find((c) => c.id === connectionId);
376
+ if (!connection2) {
377
+ return {
378
+ success: false,
379
+ error: `Connection ${connectionId} not found`
380
+ };
381
+ }
382
+ console.log(
383
+ `[connector-request] asana/${connection2.name}: ${method} ${path2}`
384
+ );
385
+ try {
386
+ const token = parameters.personalAccessToken.getValue(connection2);
387
+ const url = `${BASE_URL2}${path2}`;
388
+ const controller = new AbortController();
389
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
390
+ try {
391
+ const response = await fetch(url, {
392
+ method,
393
+ headers: {
394
+ Authorization: `Bearer ${token}`,
395
+ "Content-Type": "application/json",
396
+ Accept: "application/json"
397
+ },
398
+ body: body ? JSON.stringify(body) : void 0,
399
+ signal: controller.signal
400
+ });
401
+ const data = await response.json();
402
+ if (!response.ok) {
403
+ const errors = data?.errors;
404
+ const errorMessage = Array.isArray(errors) && errors.length > 0 ? errors[0]?.message ?? `HTTP ${response.status} ${response.statusText}` : `HTTP ${response.status} ${response.statusText}`;
405
+ return { success: false, error: String(errorMessage) };
406
+ }
407
+ return { success: true, status: response.status, data };
408
+ } finally {
409
+ clearTimeout(timeout);
410
+ }
411
+ } catch (err) {
412
+ const msg = err instanceof Error ? err.message : String(err);
413
+ return { success: false, error: msg };
414
+ }
415
+ }
416
+ });
417
+
418
+ // ../connectors/src/connectors/asana/index.ts
419
+ var tools = { request: requestTool };
420
+ var asanaConnector = new ConnectorPlugin({
421
+ slug: "asana",
422
+ authType: AUTH_TYPES.API_KEY,
423
+ name: "Asana",
424
+ description: "Connect to Asana for project management, task tracking, and team collaboration data.",
425
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3eIdaoqzIIZs2Md0OoDJMf/2fa66e0841adb985da4d3120466f3ec4/asana-icon.png",
426
+ parameters,
427
+ releaseFlag: { dev1: true, dev2: false, prod: false },
428
+ onboarding: asanaOnboarding,
429
+ systemPrompt: {
430
+ en: `### Tools
431
+
432
+ - \`asana_request\`: The only way to call the Asana REST API. Use it to list workspaces, projects, tasks, users, sections, tags, and more. Authentication (Bearer token with Personal Access Token) is configured automatically. Provide the API path and optionally append query parameters like opt_fields for field selection.
433
+
434
+ ### Business Logic
435
+
436
+ The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
437
+
438
+ SDK methods (client created via \`connection(connectionId)\`):
439
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (provide path relative to base URL)
440
+ - \`client.listWorkspaces(options?)\` \u2014 list all workspaces
441
+ - \`client.listProjects(workspaceGid, options?)\` \u2014 list projects in a workspace
442
+ - \`client.listTasks(projectGid, options?)\` \u2014 list tasks in a project
443
+ - \`client.getTask(taskGid, options?)\` \u2014 get a single task
444
+ - \`client.createTask(taskData)\` \u2014 create a new task
445
+ - \`client.updateTask(taskGid, taskData)\` \u2014 update an existing task
446
+ - \`client.listUsers(workspaceGid, options?)\` \u2014 list users in a workspace
447
+
448
+ \`\`\`ts
449
+ import type { Context } from "hono";
450
+ import { connection } from "@squadbase/vite-server/connectors/asana";
451
+
452
+ const asana = connection("<connectionId>");
453
+
454
+ export default async function handler(c: Context) {
455
+ const { projectGid } = await c.req.json<{ projectGid: string }>();
456
+
457
+ const { data: tasks } = await asana.listTasks(projectGid, {
458
+ opt_fields: ["name", "completed", "assignee.name", "due_on"],
459
+ limit: 50,
460
+ });
461
+
462
+ return c.json({ tasks });
463
+ }
464
+ \`\`\`
465
+
466
+ ### Asana REST API Reference
467
+
468
+ - Base URL: \`https://app.asana.com/api/1.0\`
469
+ - Authentication: Bearer token (Personal Access Token, handled automatically)
470
+ - All write requests wrap the payload in a \`data\` key: \`{ "data": { ... } }\`
471
+ - Use \`opt_fields\` query parameter to select specific fields and reduce response size
472
+ - Pagination: offset-based with \`limit\` (1-100) and \`offset\` query parameters; response includes \`next_page.offset\`
473
+
474
+ #### Resource Endpoints
475
+
476
+ **Workspaces**
477
+ - GET \`/workspaces\` \u2014 List all workspaces
478
+
479
+ **Projects**
480
+ - GET \`/projects?workspace=WORKSPACE_GID\` \u2014 List projects in a workspace
481
+ - GET \`/projects/{project_gid}\` \u2014 Get a project
482
+ - POST \`/projects\` \u2014 Create a project
483
+ - PUT \`/projects/{project_gid}\` \u2014 Update a project
484
+
485
+ **Tasks**
486
+ - GET \`/tasks?project=PROJECT_GID\` \u2014 List tasks in a project (requires project, or assignee+workspace)
487
+ - GET \`/tasks/{task_gid}\` \u2014 Get a task
488
+ - POST \`/tasks\` \u2014 Create a task (requires workspace or projects in body)
489
+ - PUT \`/tasks/{task_gid}\` \u2014 Update a task
490
+ - DELETE \`/tasks/{task_gid}\` \u2014 Delete a task
491
+ - POST \`/tasks/{task_gid}/subtasks\` \u2014 Create a subtask
492
+ - GET \`/tasks/{task_gid}/subtasks\` \u2014 List subtasks
493
+
494
+ **Sections**
495
+ - GET \`/sections?project=PROJECT_GID\` \u2014 List sections in a project
496
+ - POST \`/sections/{section_gid}/addTask\` \u2014 Add a task to a section
497
+
498
+ **Users**
499
+ - GET \`/users?workspace=WORKSPACE_GID\` \u2014 List users in a workspace
500
+ - GET \`/users/me\` \u2014 Get the authenticated user
501
+ - GET \`/users/{user_gid}\` \u2014 Get a user
502
+
503
+ **Tags**
504
+ - GET \`/tags?workspace=WORKSPACE_GID\` \u2014 List tags in a workspace
505
+
506
+ **Stories (comments)**
507
+ - GET \`/tasks/{task_gid}/stories\` \u2014 List comments/stories on a task
508
+ - POST \`/tasks/{task_gid}/stories\` \u2014 Add a comment to a task
509
+
510
+ **Search**
511
+ - GET \`/workspaces/{workspace_gid}/tasks/search?text=QUERY\` \u2014 Search tasks in a workspace
512
+
513
+ #### Common opt_fields
514
+ - Tasks: name, completed, assignee, assignee.name, due_on, due_at, created_at, modified_at, notes, projects, projects.name, tags, tags.name, parent, parent.name, memberships, memberships.section, memberships.section.name, custom_fields
515
+ - Projects: name, archived, created_at, modified_at, owner, owner.name, team, team.name, members
516
+ - Users: name, email, photo`,
517
+ ja: `### \u30C4\u30FC\u30EB
518
+
519
+ - \`asana_request\`: Asana REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3001\u30BF\u30B9\u30AF\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u30BB\u30AF\u30B7\u30E7\u30F3\u3001\u30BF\u30B0\u306A\u3069\u306E\u4E00\u89A7\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08Personal Access Token\u3092\u4F7F\u7528\u3057\u305FBearer\u30C8\u30FC\u30AF\u30F3\uFF09\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002API\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3001\u5FC5\u8981\u306B\u5FDC\u3058\u3066opt_fields\u306A\u3069\u306E\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4ED8\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002
520
+
521
+ ### Business Logic
522
+
523
+ \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
524
+
525
+ SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
526
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch\uFF08\u30D9\u30FC\u30B9URL\u304B\u3089\u306E\u76F8\u5BFE\u30D1\u30B9\u3092\u6307\u5B9A\uFF09
527
+ - \`client.listWorkspaces(options?)\` \u2014 \u5168\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u4E00\u89A7
528
+ - \`client.listProjects(workspaceGid, options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7
529
+ - \`client.listTasks(projectGid, options?)\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u5185\u306E\u30BF\u30B9\u30AF\u4E00\u89A7
530
+ - \`client.getTask(taskGid, options?)\` \u2014 \u5358\u4E00\u30BF\u30B9\u30AF\u306E\u53D6\u5F97
531
+ - \`client.createTask(taskData)\` \u2014 \u65B0\u898F\u30BF\u30B9\u30AF\u306E\u4F5C\u6210
532
+ - \`client.updateTask(taskGid, taskData)\` \u2014 \u65E2\u5B58\u30BF\u30B9\u30AF\u306E\u66F4\u65B0
533
+ - \`client.listUsers(workspaceGid, options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7
534
+
535
+ \`\`\`ts
536
+ import type { Context } from "hono";
537
+ import { connection } from "@squadbase/vite-server/connectors/asana";
538
+
539
+ const asana = connection("<connectionId>");
540
+
541
+ export default async function handler(c: Context) {
542
+ const { projectGid } = await c.req.json<{ projectGid: string }>();
543
+
544
+ const { data: tasks } = await asana.listTasks(projectGid, {
545
+ opt_fields: ["name", "completed", "assignee.name", "due_on"],
546
+ limit: 50,
547
+ });
548
+
549
+ return c.json({ tasks });
550
+ }
551
+ \`\`\`
552
+
553
+ ### Asana REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
554
+
555
+ - \u30D9\u30FC\u30B9URL: \`https://app.asana.com/api/1.0\`
556
+ - \u8A8D\u8A3C: Bearer\u30C8\u30FC\u30AF\u30F3\uFF08Personal Access Token\u3001\u81EA\u52D5\u8A2D\u5B9A\uFF09
557
+ - \u66F8\u304D\u8FBC\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u306F\u30DA\u30A4\u30ED\u30FC\u30C9\u3092 \`data\` \u30AD\u30FC\u3067\u56F2\u3080: \`{ "data": { ... } }\`
558
+ - \`opt_fields\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u7279\u5B9A\u306E\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u6307\u5B9A\u3057\u3066\u30EC\u30B9\u30DD\u30F3\u30B9\u30B5\u30A4\u30BA\u3092\u524A\u6E1B\u53EF\u80FD
559
+ - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \`limit\`\uFF081-100\uFF09\u3068 \`offset\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AA\u30D5\u30BB\u30C3\u30C8\u30D9\u30FC\u30B9\u3001\u30EC\u30B9\u30DD\u30F3\u30B9\u306B \`next_page.offset\` \u304C\u542B\u307E\u308C\u308B
560
+
561
+ #### \u30EA\u30BD\u30FC\u30B9\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
562
+
563
+ **\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9**
564
+ - GET \`/workspaces\` \u2014 \u5168\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u4E00\u89A7
565
+
566
+ **\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8**
567
+ - GET \`/projects?workspace=WORKSPACE_GID\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7
568
+ - GET \`/projects/{project_gid}\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u53D6\u5F97
569
+ - POST \`/projects\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u4F5C\u6210
570
+ - PUT \`/projects/{project_gid}\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u66F4\u65B0
571
+
572
+ **\u30BF\u30B9\u30AF**
573
+ - GET \`/tasks?project=PROJECT_GID\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u5185\u306E\u30BF\u30B9\u30AF\u4E00\u89A7\uFF08project\u3001\u307E\u305F\u306Fassignee+workspace\u304C\u5FC5\u8981\uFF09
574
+ - GET \`/tasks/{task_gid}\` \u2014 \u30BF\u30B9\u30AF\u306E\u53D6\u5F97
575
+ - POST \`/tasks\` \u2014 \u30BF\u30B9\u30AF\u306E\u4F5C\u6210\uFF08body\u306Bworkspace\u307E\u305F\u306Fprojects\u304C\u5FC5\u8981\uFF09
576
+ - PUT \`/tasks/{task_gid}\` \u2014 \u30BF\u30B9\u30AF\u306E\u66F4\u65B0
577
+ - DELETE \`/tasks/{task_gid}\` \u2014 \u30BF\u30B9\u30AF\u306E\u524A\u9664
578
+ - POST \`/tasks/{task_gid}/subtasks\` \u2014 \u30B5\u30D6\u30BF\u30B9\u30AF\u306E\u4F5C\u6210
579
+ - GET \`/tasks/{task_gid}/subtasks\` \u2014 \u30B5\u30D6\u30BF\u30B9\u30AF\u306E\u4E00\u89A7
580
+
581
+ **\u30BB\u30AF\u30B7\u30E7\u30F3**
582
+ - GET \`/sections?project=PROJECT_GID\` \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u5185\u306E\u30BB\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7
583
+ - POST \`/sections/{section_gid}/addTask\` \u2014 \u30BB\u30AF\u30B7\u30E7\u30F3\u306B\u30BF\u30B9\u30AF\u3092\u8FFD\u52A0
584
+
585
+ **\u30E6\u30FC\u30B6\u30FC**
586
+ - GET \`/users?workspace=WORKSPACE_GID\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7
587
+ - GET \`/users/me\` \u2014 \u8A8D\u8A3C\u30E6\u30FC\u30B6\u30FC\u306E\u53D6\u5F97
588
+ - GET \`/users/{user_gid}\` \u2014 \u30E6\u30FC\u30B6\u30FC\u306E\u53D6\u5F97
589
+
590
+ **\u30BF\u30B0**
591
+ - GET \`/tags?workspace=WORKSPACE_GID\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30BF\u30B0\u4E00\u89A7
592
+
593
+ **\u30B9\u30C8\u30FC\u30EA\u30FC\uFF08\u30B3\u30E1\u30F3\u30C8\uFF09**
594
+ - GET \`/tasks/{task_gid}/stories\` \u2014 \u30BF\u30B9\u30AF\u306E\u30B3\u30E1\u30F3\u30C8/\u30B9\u30C8\u30FC\u30EA\u30FC\u4E00\u89A7
595
+ - POST \`/tasks/{task_gid}/stories\` \u2014 \u30BF\u30B9\u30AF\u306B\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0
596
+
597
+ **\u691C\u7D22**
598
+ - GET \`/workspaces/{workspace_gid}/tasks/search?text=QUERY\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30BF\u30B9\u30AF\u691C\u7D22
599
+
600
+ #### \u3088\u304F\u4F7F\u3046opt_fields
601
+ - \u30BF\u30B9\u30AF: name, completed, assignee, assignee.name, due_on, due_at, created_at, modified_at, notes, projects, projects.name, tags, tags.name, parent, parent.name, memberships, memberships.section, memberships.section.name, custom_fields
602
+ - \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8: name, archived, created_at, modified_at, owner, owner.name, team, team.name, members
603
+ - \u30E6\u30FC\u30B6\u30FC: name, email, photo`
604
+ },
605
+ tools
606
+ });
607
+
608
+ // src/connectors/create-connector-sdk.ts
609
+ import { readFileSync } from "fs";
610
+ import path from "path";
611
+
612
+ // src/connector-client/env.ts
613
+ function resolveEnvVar(entry, key, connectionId) {
614
+ const envVarName = entry.envVars[key];
615
+ if (!envVarName) {
616
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
617
+ }
618
+ const value = process.env[envVarName];
619
+ if (!value) {
620
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
621
+ }
622
+ return value;
623
+ }
624
+ function resolveEnvVarOptional(entry, key) {
625
+ const envVarName = entry.envVars[key];
626
+ if (!envVarName) return void 0;
627
+ return process.env[envVarName] || void 0;
628
+ }
629
+
630
+ // src/connector-client/proxy-fetch.ts
631
+ import { getContext } from "hono/context-storage";
632
+ import { getCookie } from "hono/cookie";
633
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
634
+ function createSandboxProxyFetch(connectionId) {
635
+ return async (input, init) => {
636
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
637
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
638
+ if (!token || !sandboxId) {
639
+ throw new Error(
640
+ "Connection proxy is not configured. Please check your deployment settings."
641
+ );
642
+ }
643
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
644
+ const originalMethod = init?.method ?? "GET";
645
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
646
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
647
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
648
+ return fetch(proxyUrl, {
649
+ method: "POST",
650
+ headers: {
651
+ "Content-Type": "application/json",
652
+ Authorization: `Bearer ${token}`
653
+ },
654
+ body: JSON.stringify({
655
+ url: originalUrl,
656
+ method: originalMethod,
657
+ body: originalBody
658
+ })
659
+ });
660
+ };
661
+ }
662
+ function createDeployedAppProxyFetch(connectionId) {
663
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
664
+ if (!projectId) {
665
+ throw new Error(
666
+ "Connection proxy is not configured. Please check your deployment settings."
667
+ );
668
+ }
669
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
670
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
671
+ return async (input, init) => {
672
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
673
+ const originalMethod = init?.method ?? "GET";
674
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
675
+ const c = getContext();
676
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
677
+ if (!appSession) {
678
+ throw new Error(
679
+ "No authentication method available for connection proxy."
680
+ );
681
+ }
682
+ return fetch(proxyUrl, {
683
+ method: "POST",
684
+ headers: {
685
+ "Content-Type": "application/json",
686
+ Authorization: `Bearer ${appSession}`
687
+ },
688
+ body: JSON.stringify({
689
+ url: originalUrl,
690
+ method: originalMethod,
691
+ body: originalBody
692
+ })
693
+ });
694
+ };
695
+ }
696
+ function createProxyFetch(connectionId) {
697
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
698
+ return createSandboxProxyFetch(connectionId);
699
+ }
700
+ return createDeployedAppProxyFetch(connectionId);
701
+ }
702
+
703
+ // src/connectors/create-connector-sdk.ts
704
+ function loadConnectionsSync() {
705
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
706
+ try {
707
+ const raw = readFileSync(filePath, "utf-8");
708
+ return JSON.parse(raw);
709
+ } catch {
710
+ return {};
711
+ }
712
+ }
713
+ function createConnectorSdk(plugin, createClient2) {
714
+ return (connectionId) => {
715
+ const connections = loadConnectionsSync();
716
+ const entry = connections[connectionId];
717
+ if (!entry) {
718
+ throw new Error(
719
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
720
+ );
721
+ }
722
+ if (entry.connector.slug !== plugin.slug) {
723
+ throw new Error(
724
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
725
+ );
726
+ }
727
+ const params = {};
728
+ for (const param of Object.values(plugin.parameters)) {
729
+ if (param.required) {
730
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
731
+ } else {
732
+ const val = resolveEnvVarOptional(entry, param.slug);
733
+ if (val !== void 0) params[param.slug] = val;
734
+ }
735
+ }
736
+ return createClient2(params, createProxyFetch(connectionId));
737
+ };
738
+ }
739
+
740
+ // src/connectors/entries/asana.ts
741
+ var connection = createConnectorSdk(asanaConnector, createClient);
742
+ export {
743
+ connection
744
+ };