@squadbase/vite-server 0.1.9-dev.d3c856d → 0.1.9-dev.f236b23
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.
- package/dist/cli/index.js +63434 -64705
- package/dist/connectors/aws-billing.js +27 -28871
- package/dist/connectors/azure-sql.d.ts +5 -0
- package/dist/connectors/azure-sql.js +682 -0
- package/dist/connectors/clickup.d.ts +5 -0
- package/dist/connectors/clickup.js +850 -0
- package/dist/connectors/freshdesk.d.ts +5 -0
- package/dist/connectors/freshdesk.js +842 -0
- package/dist/connectors/freshsales.d.ts +5 -0
- package/dist/connectors/freshsales.js +867 -0
- package/dist/connectors/freshservice.d.ts +5 -0
- package/dist/connectors/freshservice.js +813 -0
- package/dist/connectors/github.d.ts +5 -0
- package/dist/connectors/github.js +963 -0
- package/dist/connectors/google-search-console-oauth.d.ts +5 -0
- package/dist/connectors/google-search-console-oauth.js +954 -0
- package/dist/connectors/jdbc.d.ts +5 -0
- package/dist/connectors/jdbc.js +21521 -0
- package/dist/connectors/monday.d.ts +5 -0
- package/dist/connectors/monday.js +853 -0
- package/dist/connectors/oracle.d.ts +5 -0
- package/dist/connectors/oracle.js +689 -0
- package/dist/connectors/semrush.d.ts +5 -0
- package/dist/connectors/semrush.js +825 -0
- package/dist/connectors/sqlserver.d.ts +5 -0
- package/dist/connectors/sqlserver.js +679 -0
- package/dist/connectors/supabase.d.ts +5 -0
- package/dist/connectors/supabase.js +582 -0
- package/dist/index.js +73024 -74295
- package/dist/main.js +73018 -74289
- package/dist/vite-plugin.js +70006 -71276
- package/package.json +57 -2
|
@@ -0,0 +1,850 @@
|
|
|
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/clickup/parameters.ts
|
|
46
|
+
var parameters = {
|
|
47
|
+
apiToken: new ParameterDefinition({
|
|
48
|
+
slug: "api-token",
|
|
49
|
+
name: "ClickUp Personal API Token",
|
|
50
|
+
description: "Personal API Token for ClickUp authentication. Generate one at ClickUp \u2192 Avatar (bottom-left) \u2192 Settings \u2192 Apps \u2192 API Token. Tokens start with `pk_`.",
|
|
51
|
+
envVarBaseKey: "CLICKUP_API_TOKEN",
|
|
52
|
+
type: "text",
|
|
53
|
+
secret: true,
|
|
54
|
+
required: true
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// ../connectors/src/connectors/clickup/sdk/index.ts
|
|
59
|
+
var BASE_URL = "https://api.clickup.com/api/v2";
|
|
60
|
+
function createClient(params) {
|
|
61
|
+
const token = params[parameters.apiToken.slug];
|
|
62
|
+
if (!token) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
`clickup: missing required parameter: ${parameters.apiToken.slug}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function authHeaders(extra) {
|
|
68
|
+
const headers = new Headers(extra);
|
|
69
|
+
headers.set("Authorization", 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
|
+
`clickup ${label}: ${res.status} ${res.statusText} \u2014 ${body}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function buildQuery(base, arrays) {
|
|
83
|
+
const search = new URLSearchParams();
|
|
84
|
+
for (const [key, value] of Object.entries(base)) {
|
|
85
|
+
if (value !== void 0) search.set(key, String(value));
|
|
86
|
+
}
|
|
87
|
+
if (arrays) {
|
|
88
|
+
for (const [key, values] of Object.entries(arrays)) {
|
|
89
|
+
if (!values) continue;
|
|
90
|
+
for (const v of values) search.append(`${key}[]`, String(v));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const qs = search.toString();
|
|
94
|
+
return qs ? `?${qs}` : "";
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
request(path2, init) {
|
|
98
|
+
const url = `${BASE_URL}${path2}`;
|
|
99
|
+
const headers = new Headers(init?.headers);
|
|
100
|
+
headers.set("Authorization", token);
|
|
101
|
+
if (!headers.has("Content-Type")) {
|
|
102
|
+
headers.set("Content-Type", "application/json");
|
|
103
|
+
}
|
|
104
|
+
if (!headers.has("Accept")) {
|
|
105
|
+
headers.set("Accept", "application/json");
|
|
106
|
+
}
|
|
107
|
+
return fetch(url, { ...init, headers });
|
|
108
|
+
},
|
|
109
|
+
async listWorkspaces() {
|
|
110
|
+
const res = await fetch(`${BASE_URL}/team`, {
|
|
111
|
+
method: "GET",
|
|
112
|
+
headers: authHeaders()
|
|
113
|
+
});
|
|
114
|
+
await assertOk(res, "listWorkspaces");
|
|
115
|
+
return await res.json();
|
|
116
|
+
},
|
|
117
|
+
async listSpaces(workspaceId, options) {
|
|
118
|
+
const qs = buildQuery({
|
|
119
|
+
archived: options?.archived ?? false
|
|
120
|
+
});
|
|
121
|
+
const res = await fetch(
|
|
122
|
+
`${BASE_URL}/team/${encodeURIComponent(workspaceId)}/space${qs}`,
|
|
123
|
+
{ method: "GET", headers: authHeaders() }
|
|
124
|
+
);
|
|
125
|
+
await assertOk(res, "listSpaces");
|
|
126
|
+
return await res.json();
|
|
127
|
+
},
|
|
128
|
+
async listFolders(spaceId, options) {
|
|
129
|
+
const qs = buildQuery({
|
|
130
|
+
archived: options?.archived ?? false
|
|
131
|
+
});
|
|
132
|
+
const res = await fetch(
|
|
133
|
+
`${BASE_URL}/space/${encodeURIComponent(spaceId)}/folder${qs}`,
|
|
134
|
+
{ method: "GET", headers: authHeaders() }
|
|
135
|
+
);
|
|
136
|
+
await assertOk(res, "listFolders");
|
|
137
|
+
return await res.json();
|
|
138
|
+
},
|
|
139
|
+
async listLists(folderId, options) {
|
|
140
|
+
const qs = buildQuery({
|
|
141
|
+
archived: options?.archived ?? false
|
|
142
|
+
});
|
|
143
|
+
const res = await fetch(
|
|
144
|
+
`${BASE_URL}/folder/${encodeURIComponent(folderId)}/list${qs}`,
|
|
145
|
+
{ method: "GET", headers: authHeaders() }
|
|
146
|
+
);
|
|
147
|
+
await assertOk(res, "listLists");
|
|
148
|
+
return await res.json();
|
|
149
|
+
},
|
|
150
|
+
async listFolderlessLists(spaceId, options) {
|
|
151
|
+
const qs = buildQuery({
|
|
152
|
+
archived: options?.archived ?? false
|
|
153
|
+
});
|
|
154
|
+
const res = await fetch(
|
|
155
|
+
`${BASE_URL}/space/${encodeURIComponent(spaceId)}/list${qs}`,
|
|
156
|
+
{ method: "GET", headers: authHeaders() }
|
|
157
|
+
);
|
|
158
|
+
await assertOk(res, "listFolderlessLists");
|
|
159
|
+
return await res.json();
|
|
160
|
+
},
|
|
161
|
+
async listTasks(listId, options) {
|
|
162
|
+
const qs = buildQuery(
|
|
163
|
+
{
|
|
164
|
+
page: options?.page,
|
|
165
|
+
archived: options?.archived,
|
|
166
|
+
include_closed: options?.include_closed,
|
|
167
|
+
subtasks: options?.subtasks,
|
|
168
|
+
order_by: options?.order_by,
|
|
169
|
+
reverse: options?.reverse
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
statuses: options?.statuses,
|
|
173
|
+
assignees: options?.assignees
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
const res = await fetch(
|
|
177
|
+
`${BASE_URL}/list/${encodeURIComponent(listId)}/task${qs}`,
|
|
178
|
+
{ method: "GET", headers: authHeaders() }
|
|
179
|
+
);
|
|
180
|
+
await assertOk(res, "listTasks");
|
|
181
|
+
return await res.json();
|
|
182
|
+
},
|
|
183
|
+
async getTask(taskId, options) {
|
|
184
|
+
const qs = buildQuery({
|
|
185
|
+
include_subtasks: options?.include_subtasks,
|
|
186
|
+
custom_task_ids: options?.custom_task_ids,
|
|
187
|
+
team_id: options?.team_id
|
|
188
|
+
});
|
|
189
|
+
const res = await fetch(
|
|
190
|
+
`${BASE_URL}/task/${encodeURIComponent(taskId)}${qs}`,
|
|
191
|
+
{ method: "GET", headers: authHeaders() }
|
|
192
|
+
);
|
|
193
|
+
await assertOk(res, "getTask");
|
|
194
|
+
return await res.json();
|
|
195
|
+
},
|
|
196
|
+
async createTask(listId, taskData) {
|
|
197
|
+
const res = await fetch(
|
|
198
|
+
`${BASE_URL}/list/${encodeURIComponent(listId)}/task`,
|
|
199
|
+
{
|
|
200
|
+
method: "POST",
|
|
201
|
+
headers: authHeaders(),
|
|
202
|
+
body: JSON.stringify(taskData)
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
await assertOk(res, "createTask");
|
|
206
|
+
return await res.json();
|
|
207
|
+
},
|
|
208
|
+
async updateTask(taskId, taskData) {
|
|
209
|
+
const res = await fetch(
|
|
210
|
+
`${BASE_URL}/task/${encodeURIComponent(taskId)}`,
|
|
211
|
+
{
|
|
212
|
+
method: "PUT",
|
|
213
|
+
headers: authHeaders(),
|
|
214
|
+
body: JSON.stringify(taskData)
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
await assertOk(res, "updateTask");
|
|
218
|
+
return await res.json();
|
|
219
|
+
},
|
|
220
|
+
async listMembers(listId) {
|
|
221
|
+
const res = await fetch(
|
|
222
|
+
`${BASE_URL}/list/${encodeURIComponent(listId)}/member`,
|
|
223
|
+
{ method: "GET", headers: authHeaders() }
|
|
224
|
+
);
|
|
225
|
+
await assertOk(res, "listMembers");
|
|
226
|
+
return await res.json();
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ../connectors/src/connector-onboarding.ts
|
|
232
|
+
var ConnectorOnboarding = class {
|
|
233
|
+
/** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
|
|
234
|
+
connectionSetupInstructions;
|
|
235
|
+
/** Phase 2: Data overview instructions */
|
|
236
|
+
dataOverviewInstructions;
|
|
237
|
+
constructor(config) {
|
|
238
|
+
this.connectionSetupInstructions = config.connectionSetupInstructions;
|
|
239
|
+
this.dataOverviewInstructions = config.dataOverviewInstructions;
|
|
240
|
+
}
|
|
241
|
+
getConnectionSetupPrompt(language) {
|
|
242
|
+
return this.connectionSetupInstructions?.[language] ?? null;
|
|
243
|
+
}
|
|
244
|
+
getDataOverviewInstructions(language) {
|
|
245
|
+
return this.dataOverviewInstructions[language];
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// ../connectors/src/connector-tool.ts
|
|
250
|
+
var ConnectorTool = class {
|
|
251
|
+
name;
|
|
252
|
+
description;
|
|
253
|
+
inputSchema;
|
|
254
|
+
outputSchema;
|
|
255
|
+
_execute;
|
|
256
|
+
constructor(config) {
|
|
257
|
+
this.name = config.name;
|
|
258
|
+
this.description = config.description;
|
|
259
|
+
this.inputSchema = config.inputSchema;
|
|
260
|
+
this.outputSchema = config.outputSchema;
|
|
261
|
+
this._execute = config.execute;
|
|
262
|
+
}
|
|
263
|
+
createTool(connections, config) {
|
|
264
|
+
return {
|
|
265
|
+
description: this.description,
|
|
266
|
+
inputSchema: this.inputSchema,
|
|
267
|
+
outputSchema: this.outputSchema,
|
|
268
|
+
execute: (input) => this._execute(input, connections, config)
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// ../connectors/src/connector-plugin.ts
|
|
274
|
+
var ConnectorPlugin = class _ConnectorPlugin {
|
|
275
|
+
slug;
|
|
276
|
+
authType;
|
|
277
|
+
name;
|
|
278
|
+
description;
|
|
279
|
+
iconUrl;
|
|
280
|
+
parameters;
|
|
281
|
+
releaseFlag;
|
|
282
|
+
proxyPolicy;
|
|
283
|
+
experimentalAttributes;
|
|
284
|
+
categories;
|
|
285
|
+
onboarding;
|
|
286
|
+
systemPrompt;
|
|
287
|
+
tools;
|
|
288
|
+
query;
|
|
289
|
+
checkConnection;
|
|
290
|
+
constructor(config) {
|
|
291
|
+
this.slug = config.slug;
|
|
292
|
+
this.authType = config.authType;
|
|
293
|
+
this.name = config.name;
|
|
294
|
+
this.description = config.description;
|
|
295
|
+
this.iconUrl = config.iconUrl;
|
|
296
|
+
this.parameters = config.parameters;
|
|
297
|
+
this.releaseFlag = config.releaseFlag;
|
|
298
|
+
this.proxyPolicy = config.proxyPolicy;
|
|
299
|
+
this.experimentalAttributes = config.experimentalAttributes;
|
|
300
|
+
this.categories = config.categories ?? [];
|
|
301
|
+
this.onboarding = config.onboarding;
|
|
302
|
+
this.systemPrompt = config.systemPrompt;
|
|
303
|
+
this.tools = config.tools;
|
|
304
|
+
this.query = config.query;
|
|
305
|
+
this.checkConnection = config.checkConnection;
|
|
306
|
+
}
|
|
307
|
+
get connectorKey() {
|
|
308
|
+
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Create tools for connections that belong to this connector.
|
|
312
|
+
* Filters connections by connectorKey internally.
|
|
313
|
+
* Returns tools keyed as `${connectorKey}_${toolName}`.
|
|
314
|
+
*/
|
|
315
|
+
createTools(connections, config, opts) {
|
|
316
|
+
const myConnections = connections.filter(
|
|
317
|
+
(c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
|
|
318
|
+
);
|
|
319
|
+
const result = {};
|
|
320
|
+
for (const t of Object.values(this.tools)) {
|
|
321
|
+
const tool = t.createTool(myConnections, config);
|
|
322
|
+
const originalToModelOutput = tool.toModelOutput;
|
|
323
|
+
result[`${this.connectorKey}_${t.name}`] = {
|
|
324
|
+
...tool,
|
|
325
|
+
toModelOutput: async (options) => {
|
|
326
|
+
if (!originalToModelOutput) {
|
|
327
|
+
return opts.truncateOutput(options.output);
|
|
328
|
+
}
|
|
329
|
+
const modelOutput = await originalToModelOutput(options);
|
|
330
|
+
if (modelOutput.type === "text" || modelOutput.type === "json") {
|
|
331
|
+
return opts.truncateOutput(modelOutput.value);
|
|
332
|
+
}
|
|
333
|
+
return modelOutput;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
static deriveKey(slug, authType) {
|
|
340
|
+
if (authType) return `${slug}-${authType}`;
|
|
341
|
+
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
342
|
+
// user-password
|
|
343
|
+
"postgresql": "user-password",
|
|
344
|
+
"mysql": "user-password",
|
|
345
|
+
"clickhouse": "user-password",
|
|
346
|
+
"kintone": "user-password",
|
|
347
|
+
"squadbase-db": "user-password",
|
|
348
|
+
// service-account
|
|
349
|
+
"snowflake": "service-account",
|
|
350
|
+
"bigquery": "service-account",
|
|
351
|
+
"google-analytics": "service-account",
|
|
352
|
+
"google-calendar": "service-account",
|
|
353
|
+
"aws-athena": "service-account",
|
|
354
|
+
"redshift": "service-account",
|
|
355
|
+
// api-key
|
|
356
|
+
"databricks": "api-key",
|
|
357
|
+
"dbt": "api-key",
|
|
358
|
+
"airtable": "api-key",
|
|
359
|
+
"openai": "api-key",
|
|
360
|
+
"gemini": "api-key",
|
|
361
|
+
"anthropic": "api-key",
|
|
362
|
+
"wix-store": "api-key"
|
|
363
|
+
};
|
|
364
|
+
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
365
|
+
if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
|
|
366
|
+
return slug;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// ../connectors/src/auth-types.ts
|
|
371
|
+
var AUTH_TYPES = {
|
|
372
|
+
OAUTH: "oauth",
|
|
373
|
+
API_KEY: "api-key",
|
|
374
|
+
JWT: "jwt",
|
|
375
|
+
SERVICE_ACCOUNT: "service-account",
|
|
376
|
+
PAT: "pat",
|
|
377
|
+
USER_PASSWORD: "user-password"
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// ../connectors/src/lib/normalize-path.ts
|
|
381
|
+
function normalizeRequestPath(path2, basePathSegment) {
|
|
382
|
+
let p = path2.trim();
|
|
383
|
+
if (!p.startsWith("/")) p = "/" + p;
|
|
384
|
+
if (p === basePathSegment || p.startsWith(basePathSegment + "/")) {
|
|
385
|
+
p = p.slice(basePathSegment.length) || "/";
|
|
386
|
+
}
|
|
387
|
+
return p;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// ../connectors/src/connectors/clickup/setup.ts
|
|
391
|
+
var clickupOnboarding = new ConnectorOnboarding({
|
|
392
|
+
dataOverviewInstructions: {
|
|
393
|
+
en: `1. Call clickup_request with GET /team to list workspaces (the ClickUp API still calls workspaces "teams"). Pick the first workspace's \`id\`.
|
|
394
|
+
2. Call clickup_request with GET /team/{team_id}/space?archived=false to list spaces in the workspace.
|
|
395
|
+
3. Pick one space and list its folders (GET /space/{space_id}/folder?archived=false) and folderless lists (GET /space/{space_id}/list?archived=false). Each folder also contains lists at GET /folder/{folder_id}/list.
|
|
396
|
+
4. Pick one list and call clickup_request with GET /list/{list_id}/task?page=0&include_closed=true to sample tasks. Inspect each task's \`status\`, \`assignees\`, \`due_date\`, and \`custom_fields\`.
|
|
397
|
+
5. If custom fields are used, call GET /list/{list_id}/field to get their definitions.`,
|
|
398
|
+
ja: `1. clickup_request \u3067 GET /team \u3092\u547C\u3073\u51FA\u3057\u3066\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\uFF08ClickUp API \u3067\u306F\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092 "team" \u3068\u547C\u3073\u307E\u3059\uFF09\u3002\u6700\u521D\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E \`id\` \u3092\u9078\u629E\u3057\u307E\u3059\u3002
|
|
399
|
+
2. clickup_request \u3067 GET /team/{team_id}/space?archived=false \u3092\u547C\u3073\u51FA\u3057\u3066\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002
|
|
400
|
+
3. \u30B9\u30DA\u30FC\u30B9\u30921\u3064\u9078\u3073\u3001\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7\uFF08GET /space/{space_id}/folder?archived=false\uFF09\u3068\u30D5\u30A9\u30EB\u30C0\u7121\u3057\u30EA\u30B9\u30C8\u4E00\u89A7\uFF08GET /space/{space_id}/list?archived=false\uFF09\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u5404\u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30EA\u30B9\u30C8\u306F GET /folder/{folder_id}/list \u3067\u53D6\u5F97\u3067\u304D\u307E\u3059\u3002
|
|
401
|
+
4. \u30EA\u30B9\u30C8\u30921\u3064\u9078\u3073\u3001clickup_request \u3067 GET /list/{list_id}/task?page=0&include_closed=true \u3092\u547C\u3073\u51FA\u3057\u3066\u30BF\u30B9\u30AF\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u3057\u307E\u3059\u3002\u5404\u30BF\u30B9\u30AF\u306E \`status\`, \`assignees\`, \`due_date\`, \`custom_fields\` \u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
402
|
+
5. \u30AB\u30B9\u30BF\u30E0\u30D5\u30A3\u30FC\u30EB\u30C9\u304C\u5229\u7528\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u306F GET /list/{list_id}/field \u3067\u305D\u306E\u5B9A\u7FA9\u3092\u53D6\u5F97\u3057\u3066\u304F\u3060\u3055\u3044\u3002`
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
// ../connectors/src/connectors/clickup/tools/request.ts
|
|
407
|
+
import { z } from "zod";
|
|
408
|
+
var BASE_HOST = "https://api.clickup.com";
|
|
409
|
+
var BASE_PATH_SEGMENT = "/api/v2";
|
|
410
|
+
var BASE_URL2 = `${BASE_HOST}${BASE_PATH_SEGMENT}`;
|
|
411
|
+
var REQUEST_TIMEOUT_MS = 6e4;
|
|
412
|
+
var inputSchema = z.object({
|
|
413
|
+
toolUseIntent: z.string().optional().describe(
|
|
414
|
+
"Brief description of what you intend to accomplish with this tool call"
|
|
415
|
+
),
|
|
416
|
+
connectionId: z.string().describe("ID of the ClickUp connection to use"),
|
|
417
|
+
method: z.enum(["GET", "POST", "PUT", "DELETE"]).describe(
|
|
418
|
+
"HTTP method. GET for reading resources, POST for creating, PUT for updating, DELETE for removing."
|
|
419
|
+
),
|
|
420
|
+
path: z.string().describe(
|
|
421
|
+
"API path (e.g., '/team', '/team/{team_id}/space', '/list/{list_id}/task'). Query parameters can be appended (e.g., '/list/{list_id}/task?page=0&include_closed=true'). The ClickUp API uses 'team' to mean 'workspace'."
|
|
422
|
+
),
|
|
423
|
+
body: z.record(z.string(), z.unknown()).optional().describe(
|
|
424
|
+
'Request body (JSON) for POST/PUT requests. Example for creating a task: { "name": "My task", "description": "...", "assignees": [12345], "status": "to do" }.'
|
|
425
|
+
)
|
|
426
|
+
});
|
|
427
|
+
var outputSchema = z.discriminatedUnion("success", [
|
|
428
|
+
z.object({
|
|
429
|
+
success: z.literal(true),
|
|
430
|
+
status: z.number(),
|
|
431
|
+
data: z.union([
|
|
432
|
+
z.record(z.string(), z.unknown()),
|
|
433
|
+
z.array(z.unknown())
|
|
434
|
+
])
|
|
435
|
+
}),
|
|
436
|
+
z.object({
|
|
437
|
+
success: z.literal(false),
|
|
438
|
+
error: z.string()
|
|
439
|
+
})
|
|
440
|
+
]);
|
|
441
|
+
var requestTool = new ConnectorTool({
|
|
442
|
+
name: "request",
|
|
443
|
+
description: `Send authenticated requests to the ClickUp REST API v2.
|
|
444
|
+
Authentication is handled automatically using the Personal API Token (sent in the Authorization header \u2014 note: ClickUp does NOT use the "Bearer" prefix).
|
|
445
|
+
Provide the API path relative to the base URL (https://api.clickup.com/api/v2).
|
|
446
|
+
|
|
447
|
+
ClickUp uses "team" as a synonym for "workspace" in its URLs.
|
|
448
|
+
|
|
449
|
+
Hierarchy: Workspace (team) \u2192 Space \u2192 Folder \u2192 List \u2192 Task. Lists can also live directly under a Space (folderless lists).
|
|
450
|
+
|
|
451
|
+
Common endpoints:
|
|
452
|
+
- GET /team \u2014 List workspaces
|
|
453
|
+
- GET /team/{team_id}/space?archived=false \u2014 List spaces in a workspace
|
|
454
|
+
- GET /space/{space_id}/folder?archived=false \u2014 List folders in a space
|
|
455
|
+
- GET /folder/{folder_id}/list?archived=false \u2014 List lists in a folder
|
|
456
|
+
- GET /space/{space_id}/list?archived=false \u2014 List folderless lists in a space
|
|
457
|
+
- GET /list/{list_id}/task?page=0 \u2014 List tasks in a list (paginated)
|
|
458
|
+
- GET /task/{task_id} \u2014 Get a single task
|
|
459
|
+
- POST /list/{list_id}/task \u2014 Create a task in a list
|
|
460
|
+
- PUT /task/{task_id} \u2014 Update a task
|
|
461
|
+
- DELETE /task/{task_id} \u2014 Delete a task
|
|
462
|
+
- GET /list/{list_id}/member \u2014 List members on a list
|
|
463
|
+
- GET /list/{list_id}/field \u2014 List custom field definitions on a list
|
|
464
|
+
- POST /task/{task_id}/comment \u2014 Add a comment to a task
|
|
465
|
+
|
|
466
|
+
Pagination: ClickUp uses zero-indexed \`page\` query parameter on list endpoints (page=0, page=1, ...). Each page returns up to 100 tasks; you must increment \`page\` until the response array is empty.`,
|
|
467
|
+
inputSchema,
|
|
468
|
+
outputSchema,
|
|
469
|
+
async execute({ connectionId, method, path: path2, body }, connections) {
|
|
470
|
+
const connection2 = connections.find((c) => c.id === connectionId);
|
|
471
|
+
if (!connection2) {
|
|
472
|
+
return {
|
|
473
|
+
success: false,
|
|
474
|
+
error: `Connection ${connectionId} not found`
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
console.log(
|
|
478
|
+
`[connector-request] clickup/${connection2.name}: ${method} ${path2}`
|
|
479
|
+
);
|
|
480
|
+
try {
|
|
481
|
+
const token = parameters.apiToken.getValue(connection2);
|
|
482
|
+
const normalizedPath = normalizeRequestPath(path2, BASE_PATH_SEGMENT);
|
|
483
|
+
const url = `${BASE_URL2}${normalizedPath}`;
|
|
484
|
+
const controller = new AbortController();
|
|
485
|
+
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
486
|
+
try {
|
|
487
|
+
const response = await fetch(url, {
|
|
488
|
+
method,
|
|
489
|
+
headers: {
|
|
490
|
+
Authorization: token,
|
|
491
|
+
"Content-Type": "application/json",
|
|
492
|
+
Accept: "application/json"
|
|
493
|
+
},
|
|
494
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
495
|
+
signal: controller.signal
|
|
496
|
+
});
|
|
497
|
+
const text = await response.text();
|
|
498
|
+
const data = text ? JSON.parse(text) : {};
|
|
499
|
+
if (!response.ok) {
|
|
500
|
+
const errObj = !Array.isArray(data) ? data : {};
|
|
501
|
+
const errorMessage = typeof errObj.err === "string" && errObj.err || typeof errObj.ECODE === "string" && `${errObj.ECODE}` || `HTTP ${response.status} ${response.statusText}`;
|
|
502
|
+
return { success: false, error: String(errorMessage) };
|
|
503
|
+
}
|
|
504
|
+
return { success: true, status: response.status, data };
|
|
505
|
+
} finally {
|
|
506
|
+
clearTimeout(timeout);
|
|
507
|
+
}
|
|
508
|
+
} catch (err) {
|
|
509
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
510
|
+
return { success: false, error: msg };
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// ../connectors/src/connectors/clickup/index.ts
|
|
516
|
+
var tools = { request: requestTool };
|
|
517
|
+
var clickupConnector = new ConnectorPlugin({
|
|
518
|
+
slug: "clickup",
|
|
519
|
+
authType: AUTH_TYPES.API_KEY,
|
|
520
|
+
name: "ClickUp",
|
|
521
|
+
description: "Connect to ClickUp for project management, task tracking, time tracking, and team collaboration data via Personal API Token.",
|
|
522
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/5bzXkRjOeFJ7KoWdN55RAK/8b9270e4b09a9760912edae36d805fe4/clickup-icon.webp",
|
|
523
|
+
parameters,
|
|
524
|
+
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
525
|
+
categories: ["productivity"],
|
|
526
|
+
onboarding: clickupOnboarding,
|
|
527
|
+
systemPrompt: {
|
|
528
|
+
en: `### Tools
|
|
529
|
+
|
|
530
|
+
- \`clickup_request\`: The only way to call the ClickUp REST API v2. Use it to list workspaces, spaces, folders, lists, tasks, members, and custom fields. Authentication (Personal API Token in the \`Authorization\` header \u2014 no \`Bearer\` prefix) is configured automatically. Provide the API path and optionally append query parameters like \`page\`, \`archived\`, \`include_closed\`.
|
|
531
|
+
|
|
532
|
+
### Business Logic
|
|
533
|
+
|
|
534
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
535
|
+
|
|
536
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
537
|
+
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch (provide path relative to base URL)
|
|
538
|
+
- \`client.listWorkspaces()\` \u2014 list workspaces (returned under the \`teams\` key)
|
|
539
|
+
- \`client.listSpaces(workspaceId, options?)\` \u2014 list spaces in a workspace
|
|
540
|
+
- \`client.listFolders(spaceId, options?)\` \u2014 list folders in a space
|
|
541
|
+
- \`client.listLists(folderId, options?)\` \u2014 list lists inside a folder
|
|
542
|
+
- \`client.listFolderlessLists(spaceId, options?)\` \u2014 list lists directly under a space
|
|
543
|
+
- \`client.listTasks(listId, options?)\` \u2014 list tasks in a list (paginated with \`page\`)
|
|
544
|
+
- \`client.getTask(taskId, options?)\` \u2014 get a single task
|
|
545
|
+
- \`client.createTask(listId, taskData)\` \u2014 create a task
|
|
546
|
+
- \`client.updateTask(taskId, taskData)\` \u2014 update an existing task
|
|
547
|
+
- \`client.listMembers(listId)\` \u2014 list members on a list
|
|
548
|
+
|
|
549
|
+
\`\`\`ts
|
|
550
|
+
import type { Context } from "hono";
|
|
551
|
+
import { connection } from "@squadbase/vite-server/connectors/clickup";
|
|
552
|
+
|
|
553
|
+
const clickup = connection("<connectionId>");
|
|
554
|
+
|
|
555
|
+
export default async function handler(c: Context) {
|
|
556
|
+
const { listId } = await c.req.json<{ listId: string }>();
|
|
557
|
+
|
|
558
|
+
const { tasks } = await clickup.listTasks(listId, {
|
|
559
|
+
page: 0,
|
|
560
|
+
include_closed: true,
|
|
561
|
+
subtasks: true,
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
return c.json({ tasks });
|
|
565
|
+
}
|
|
566
|
+
\`\`\`
|
|
567
|
+
|
|
568
|
+
### ClickUp REST API v2 Reference
|
|
569
|
+
|
|
570
|
+
- Base URL: \`https://api.clickup.com/api/v2\`
|
|
571
|
+
- Authentication: \`Authorization: <PERSONAL_TOKEN>\` header (no \`Bearer\` prefix). Personal tokens start with \`pk_\`.
|
|
572
|
+
- Hierarchy: Workspace (called "team" in URLs) \u2192 Space \u2192 Folder \u2192 List \u2192 Task. Lists can also live directly under a Space (folderless lists).
|
|
573
|
+
- Pagination: Task list endpoints use a zero-indexed \`page\` query parameter (100 tasks per page). Loop until the response \`tasks\` array is empty or \`last_page\` is true.
|
|
574
|
+
- Errors: Failure responses return JSON like \`{ "err": "...", "ECODE": "..." }\`.
|
|
575
|
+
|
|
576
|
+
#### Resource Endpoints
|
|
577
|
+
|
|
578
|
+
**Workspaces (a.k.a. teams)**
|
|
579
|
+
- GET \`/team\` \u2014 List workspaces accessible to the token
|
|
580
|
+
|
|
581
|
+
**Spaces**
|
|
582
|
+
- GET \`/team/{team_id}/space?archived=false\` \u2014 List spaces in a workspace
|
|
583
|
+
- GET \`/space/{space_id}\` \u2014 Get a single space
|
|
584
|
+
|
|
585
|
+
**Folders**
|
|
586
|
+
- GET \`/space/{space_id}/folder?archived=false\` \u2014 List folders in a space
|
|
587
|
+
- GET \`/folder/{folder_id}\` \u2014 Get a folder
|
|
588
|
+
|
|
589
|
+
**Lists**
|
|
590
|
+
- GET \`/folder/{folder_id}/list?archived=false\` \u2014 List lists in a folder
|
|
591
|
+
- GET \`/space/{space_id}/list?archived=false\` \u2014 List folderless lists in a space
|
|
592
|
+
- GET \`/list/{list_id}\` \u2014 Get a list
|
|
593
|
+
- POST \`/folder/{folder_id}/list\` \u2014 Create a list inside a folder
|
|
594
|
+
- POST \`/space/{space_id}/list\` \u2014 Create a folderless list
|
|
595
|
+
|
|
596
|
+
**Tasks**
|
|
597
|
+
- GET \`/list/{list_id}/task?page=0\` \u2014 List tasks in a list (paginated)
|
|
598
|
+
- GET \`/task/{task_id}\` \u2014 Get a task
|
|
599
|
+
- POST \`/list/{list_id}/task\` \u2014 Create a task
|
|
600
|
+
- PUT \`/task/{task_id}\` \u2014 Update a task
|
|
601
|
+
- DELETE \`/task/{task_id}\` \u2014 Delete a task
|
|
602
|
+
- POST \`/task/{task_id}/comment\` \u2014 Add a comment to a task
|
|
603
|
+
- GET \`/task/{task_id}/comment\` \u2014 List comments on a task
|
|
604
|
+
|
|
605
|
+
**Members & Custom Fields**
|
|
606
|
+
- GET \`/list/{list_id}/member\` \u2014 List members on a list
|
|
607
|
+
- GET \`/task/{task_id}/member\` \u2014 List members on a task
|
|
608
|
+
- GET \`/list/{list_id}/field\` \u2014 List custom field definitions on a list
|
|
609
|
+
- POST \`/task/{task_id}/field/{field_id}\` \u2014 Set a custom field value on a task
|
|
610
|
+
|
|
611
|
+
**Time Tracking**
|
|
612
|
+
- GET \`/team/{team_id}/time_entries?start_date=...&end_date=...\` \u2014 List time entries (Unix ms timestamps)
|
|
613
|
+
- POST \`/team/{team_id}/time_entries\` \u2014 Create a time entry`,
|
|
614
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
615
|
+
|
|
616
|
+
- \`clickup_request\`: ClickUp REST API v2 \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3001\u30B9\u30DA\u30FC\u30B9\u3001\u30D5\u30A9\u30EB\u30C0\u3001\u30EA\u30B9\u30C8\u3001\u30BF\u30B9\u30AF\u3001\u30E1\u30F3\u30D0\u30FC\u3001\u30AB\u30B9\u30BF\u30E0\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u53D6\u5F97\u30FB\u66F4\u65B0\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08Personal API Token \u3092 \`Authorization\` \u30D8\u30C3\u30C0\u30FC\u306B\u8A2D\u5B9A \u2014 \`Bearer\` \u30D7\u30EC\u30D5\u30A3\u30C3\u30AF\u30B9\u306F\u4ED8\u304D\u307E\u305B\u3093\uFF09\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u307E\u3059\u3002API\u30D1\u30B9\u3092\u6307\u5B9A\u3057\u3001\u5FC5\u8981\u306B\u5FDC\u3058\u3066 \`page\`, \`archived\`, \`include_closed\` \u306A\u3069\u306E\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4ED8\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
617
|
+
|
|
618
|
+
### Business Logic
|
|
619
|
+
|
|
620
|
+
\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
|
|
621
|
+
|
|
622
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
623
|
+
- \`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
|
|
624
|
+
- \`client.listWorkspaces()\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7\uFF08\u30EC\u30B9\u30DD\u30F3\u30B9\u306F \`teams\` \u30AD\u30FC\u3067\u8FD4\u308A\u307E\u3059\uFF09
|
|
625
|
+
- \`client.listSpaces(workspaceId, options?)\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
|
|
626
|
+
- \`client.listFolders(spaceId, options?)\` \u2014 \u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7
|
|
627
|
+
- \`client.listLists(folderId, options?)\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30EA\u30B9\u30C8\u4E00\u89A7
|
|
628
|
+
- \`client.listFolderlessLists(spaceId, options?)\` \u2014 \u30B9\u30DA\u30FC\u30B9\u76F4\u4E0B\u306E\u30D5\u30A9\u30EB\u30C0\u7121\u3057\u30EA\u30B9\u30C8\u4E00\u89A7
|
|
629
|
+
- \`client.listTasks(listId, options?)\` \u2014 \u30EA\u30B9\u30C8\u5185\u306E\u30BF\u30B9\u30AF\u4E00\u89A7\uFF08\`page\` \u3067\u30DA\u30FC\u30B8\u30F3\u30B0\uFF09
|
|
630
|
+
- \`client.getTask(taskId, options?)\` \u2014 \u5358\u4E00\u30BF\u30B9\u30AF\u306E\u53D6\u5F97
|
|
631
|
+
- \`client.createTask(listId, taskData)\` \u2014 \u30BF\u30B9\u30AF\u306E\u65B0\u898F\u4F5C\u6210
|
|
632
|
+
- \`client.updateTask(taskId, taskData)\` \u2014 \u65E2\u5B58\u30BF\u30B9\u30AF\u306E\u66F4\u65B0
|
|
633
|
+
- \`client.listMembers(listId)\` \u2014 \u30EA\u30B9\u30C8\u306E\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7
|
|
634
|
+
|
|
635
|
+
\`\`\`ts
|
|
636
|
+
import type { Context } from "hono";
|
|
637
|
+
import { connection } from "@squadbase/vite-server/connectors/clickup";
|
|
638
|
+
|
|
639
|
+
const clickup = connection("<connectionId>");
|
|
640
|
+
|
|
641
|
+
export default async function handler(c: Context) {
|
|
642
|
+
const { listId } = await c.req.json<{ listId: string }>();
|
|
643
|
+
|
|
644
|
+
const { tasks } = await clickup.listTasks(listId, {
|
|
645
|
+
page: 0,
|
|
646
|
+
include_closed: true,
|
|
647
|
+
subtasks: true,
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
return c.json({ tasks });
|
|
651
|
+
}
|
|
652
|
+
\`\`\`
|
|
653
|
+
|
|
654
|
+
### ClickUp REST API v2 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
655
|
+
|
|
656
|
+
- \u30D9\u30FC\u30B9URL: \`https://api.clickup.com/api/v2\`
|
|
657
|
+
- \u8A8D\u8A3C: \`Authorization: <PERSONAL_TOKEN>\` \u30D8\u30C3\u30C0\u30FC\uFF08\`Bearer\` \u30D7\u30EC\u30D5\u30A3\u30C3\u30AF\u30B9\u306F\u4ED8\u304D\u307E\u305B\u3093\uFF09\u3002Personal Token \u306F \`pk_\` \u3067\u59CB\u307E\u308A\u307E\u3059\u3002
|
|
658
|
+
- \u968E\u5C64\u69CB\u9020: \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\uFF08URL\u4E0A\u306F "team" \u3068\u547C\u3070\u308C\u307E\u3059\uFF09 \u2192 \u30B9\u30DA\u30FC\u30B9 \u2192 \u30D5\u30A9\u30EB\u30C0 \u2192 \u30EA\u30B9\u30C8 \u2192 \u30BF\u30B9\u30AF\u3002\u30EA\u30B9\u30C8\u306F\u30B9\u30DA\u30FC\u30B9\u76F4\u4E0B\u306B\u3082\u5B58\u5728\u3067\u304D\u307E\u3059\uFF08\u30D5\u30A9\u30EB\u30C0\u7121\u3057\u30EA\u30B9\u30C8\uFF09\u3002
|
|
659
|
+
- \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3: \u30BF\u30B9\u30AF\u4E00\u89A7\u7CFB\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306F0\u59CB\u307E\u308A\u306E \`page\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\u3057\u307E\u3059\uFF081\u30DA\u30FC\u30B8100\u4EF6\uFF09\u3002\u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`tasks\` \u914D\u5217\u304C\u7A7A\u306B\u306A\u308B\u304B \`last_page\` \u304C true \u306B\u306A\u308B\u307E\u3067\u30EB\u30FC\u30D7\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
660
|
+
- \u30A8\u30E9\u30FC: \u5931\u6557\u6642\u306E\u30EC\u30B9\u30DD\u30F3\u30B9\u306F \`{ "err": "...", "ECODE": "..." }\` \u306E\u5F62\u306EJSON\u3067\u3059\u3002
|
|
661
|
+
|
|
662
|
+
#### \u30EA\u30BD\u30FC\u30B9\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
663
|
+
|
|
664
|
+
**\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\uFF08"team"\uFF09**
|
|
665
|
+
- GET \`/team\` \u2014 \u30C8\u30FC\u30AF\u30F3\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
|
|
666
|
+
|
|
667
|
+
**\u30B9\u30DA\u30FC\u30B9**
|
|
668
|
+
- GET \`/team/{team_id}/space?archived=false\` \u2014 \u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30B9\u30DA\u30FC\u30B9\u4E00\u89A7
|
|
669
|
+
- GET \`/space/{space_id}\` \u2014 \u30B9\u30DA\u30FC\u30B9\u306E\u53D6\u5F97
|
|
670
|
+
|
|
671
|
+
**\u30D5\u30A9\u30EB\u30C0**
|
|
672
|
+
- GET \`/space/{space_id}/folder?archived=false\` \u2014 \u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30D5\u30A9\u30EB\u30C0\u4E00\u89A7
|
|
673
|
+
- GET \`/folder/{folder_id}\` \u2014 \u30D5\u30A9\u30EB\u30C0\u306E\u53D6\u5F97
|
|
674
|
+
|
|
675
|
+
**\u30EA\u30B9\u30C8**
|
|
676
|
+
- GET \`/folder/{folder_id}/list?archived=false\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306E\u30EA\u30B9\u30C8\u4E00\u89A7
|
|
677
|
+
- GET \`/space/{space_id}/list?archived=false\` \u2014 \u30B9\u30DA\u30FC\u30B9\u76F4\u4E0B\u306E\u30D5\u30A9\u30EB\u30C0\u7121\u3057\u30EA\u30B9\u30C8\u4E00\u89A7
|
|
678
|
+
- GET \`/list/{list_id}\` \u2014 \u30EA\u30B9\u30C8\u306E\u53D6\u5F97
|
|
679
|
+
- POST \`/folder/{folder_id}/list\` \u2014 \u30D5\u30A9\u30EB\u30C0\u5185\u306B\u30EA\u30B9\u30C8\u3092\u4F5C\u6210
|
|
680
|
+
- POST \`/space/{space_id}/list\` \u2014 \u30D5\u30A9\u30EB\u30C0\u7121\u3057\u30EA\u30B9\u30C8\u3092\u4F5C\u6210
|
|
681
|
+
|
|
682
|
+
**\u30BF\u30B9\u30AF**
|
|
683
|
+
- GET \`/list/{list_id}/task?page=0\` \u2014 \u30EA\u30B9\u30C8\u5185\u306E\u30BF\u30B9\u30AF\u4E00\u89A7\uFF08\u30DA\u30FC\u30B8\u30F3\u30B0\uFF09
|
|
684
|
+
- GET \`/task/{task_id}\` \u2014 \u30BF\u30B9\u30AF\u306E\u53D6\u5F97
|
|
685
|
+
- POST \`/list/{list_id}/task\` \u2014 \u30BF\u30B9\u30AF\u306E\u4F5C\u6210
|
|
686
|
+
- PUT \`/task/{task_id}\` \u2014 \u30BF\u30B9\u30AF\u306E\u66F4\u65B0
|
|
687
|
+
- DELETE \`/task/{task_id}\` \u2014 \u30BF\u30B9\u30AF\u306E\u524A\u9664
|
|
688
|
+
- POST \`/task/{task_id}/comment\` \u2014 \u30BF\u30B9\u30AF\u3078\u306E\u30B3\u30E1\u30F3\u30C8\u6295\u7A3F
|
|
689
|
+
- GET \`/task/{task_id}/comment\` \u2014 \u30BF\u30B9\u30AF\u306E\u30B3\u30E1\u30F3\u30C8\u4E00\u89A7
|
|
690
|
+
|
|
691
|
+
**\u30E1\u30F3\u30D0\u30FC & \u30AB\u30B9\u30BF\u30E0\u30D5\u30A3\u30FC\u30EB\u30C9**
|
|
692
|
+
- GET \`/list/{list_id}/member\` \u2014 \u30EA\u30B9\u30C8\u306E\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7
|
|
693
|
+
- GET \`/task/{task_id}/member\` \u2014 \u30BF\u30B9\u30AF\u306E\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7
|
|
694
|
+
- GET \`/list/{list_id}/field\` \u2014 \u30EA\u30B9\u30C8\u306E\u30AB\u30B9\u30BF\u30E0\u30D5\u30A3\u30FC\u30EB\u30C9\u5B9A\u7FA9\u4E00\u89A7
|
|
695
|
+
- POST \`/task/{task_id}/field/{field_id}\` \u2014 \u30BF\u30B9\u30AF\u306E\u30AB\u30B9\u30BF\u30E0\u30D5\u30A3\u30FC\u30EB\u30C9\u5024\u3092\u8A2D\u5B9A
|
|
696
|
+
|
|
697
|
+
**\u30BF\u30A4\u30E0\u30C8\u30E9\u30C3\u30AD\u30F3\u30B0**
|
|
698
|
+
- GET \`/team/{team_id}/time_entries?start_date=...&end_date=...\` \u2014 \u6642\u9593\u8A18\u9332\u4E00\u89A7\uFF08Unix \u30DF\u30EA\u79D2\u30BF\u30A4\u30E0\u30B9\u30BF\u30F3\u30D7\uFF09
|
|
699
|
+
- POST \`/team/{team_id}/time_entries\` \u2014 \u6642\u9593\u8A18\u9332\u306E\u4F5C\u6210`
|
|
700
|
+
},
|
|
701
|
+
tools
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
// src/connectors/create-connector-sdk.ts
|
|
705
|
+
import { readFileSync } from "fs";
|
|
706
|
+
import path from "path";
|
|
707
|
+
|
|
708
|
+
// src/connector-client/env.ts
|
|
709
|
+
function resolveEnvVar(entry, key, connectionId) {
|
|
710
|
+
const envVarName = entry.envVars[key];
|
|
711
|
+
if (!envVarName) {
|
|
712
|
+
throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
|
|
713
|
+
}
|
|
714
|
+
const value = process.env[envVarName];
|
|
715
|
+
if (!value) {
|
|
716
|
+
throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
|
|
717
|
+
}
|
|
718
|
+
return value;
|
|
719
|
+
}
|
|
720
|
+
function resolveEnvVarOptional(entry, key) {
|
|
721
|
+
const envVarName = entry.envVars[key];
|
|
722
|
+
if (!envVarName) return void 0;
|
|
723
|
+
return process.env[envVarName] || void 0;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// src/connector-client/proxy-fetch.ts
|
|
727
|
+
import { getContext } from "hono/context-storage";
|
|
728
|
+
import { getCookie } from "hono/cookie";
|
|
729
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
730
|
+
function normalizeHeaders(input) {
|
|
731
|
+
const out = {};
|
|
732
|
+
if (!input) return out;
|
|
733
|
+
new Headers(input).forEach((value, key) => {
|
|
734
|
+
out[key] = value;
|
|
735
|
+
});
|
|
736
|
+
return out;
|
|
737
|
+
}
|
|
738
|
+
function createSandboxProxyFetch(connectionId) {
|
|
739
|
+
return async (input, init) => {
|
|
740
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
741
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
742
|
+
if (!token || !sandboxId) {
|
|
743
|
+
throw new Error(
|
|
744
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
748
|
+
const originalMethod = init?.method ?? "GET";
|
|
749
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
750
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
751
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
752
|
+
return fetch(proxyUrl, {
|
|
753
|
+
method: "POST",
|
|
754
|
+
headers: {
|
|
755
|
+
"Content-Type": "application/json",
|
|
756
|
+
Authorization: `Bearer ${token}`
|
|
757
|
+
},
|
|
758
|
+
body: JSON.stringify({
|
|
759
|
+
url: originalUrl,
|
|
760
|
+
method: originalMethod,
|
|
761
|
+
headers: normalizeHeaders(init?.headers),
|
|
762
|
+
body: originalBody
|
|
763
|
+
})
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
768
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
769
|
+
if (!projectId) {
|
|
770
|
+
throw new Error(
|
|
771
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
775
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
776
|
+
return async (input, init) => {
|
|
777
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
778
|
+
const originalMethod = init?.method ?? "GET";
|
|
779
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
780
|
+
const c = getContext();
|
|
781
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
782
|
+
if (!appSession) {
|
|
783
|
+
throw new Error(
|
|
784
|
+
"No authentication method available for connection proxy."
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
return fetch(proxyUrl, {
|
|
788
|
+
method: "POST",
|
|
789
|
+
headers: {
|
|
790
|
+
"Content-Type": "application/json",
|
|
791
|
+
Authorization: `Bearer ${appSession}`
|
|
792
|
+
},
|
|
793
|
+
body: JSON.stringify({
|
|
794
|
+
url: originalUrl,
|
|
795
|
+
method: originalMethod,
|
|
796
|
+
headers: normalizeHeaders(init?.headers),
|
|
797
|
+
body: originalBody
|
|
798
|
+
})
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
function createProxyFetch(connectionId) {
|
|
803
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
804
|
+
return createSandboxProxyFetch(connectionId);
|
|
805
|
+
}
|
|
806
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// src/connectors/create-connector-sdk.ts
|
|
810
|
+
function loadConnectionsSync() {
|
|
811
|
+
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
812
|
+
try {
|
|
813
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
814
|
+
return JSON.parse(raw);
|
|
815
|
+
} catch {
|
|
816
|
+
return {};
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function createConnectorSdk(plugin, createClient2) {
|
|
820
|
+
return (connectionId) => {
|
|
821
|
+
const connections = loadConnectionsSync();
|
|
822
|
+
const entry = connections[connectionId];
|
|
823
|
+
if (!entry) {
|
|
824
|
+
throw new Error(
|
|
825
|
+
`Connection "${connectionId}" not found in .squadbase/connections.json`
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
if (entry.connector.slug !== plugin.slug) {
|
|
829
|
+
throw new Error(
|
|
830
|
+
`Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
const params = {};
|
|
834
|
+
for (const param of Object.values(plugin.parameters)) {
|
|
835
|
+
if (param.required) {
|
|
836
|
+
params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
|
|
837
|
+
} else {
|
|
838
|
+
const val = resolveEnvVarOptional(entry, param.slug);
|
|
839
|
+
if (val !== void 0) params[param.slug] = val;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/connectors/entries/clickup.ts
|
|
847
|
+
var connection = createConnectorSdk(clickupConnector, createClient);
|
|
848
|
+
export {
|
|
849
|
+
connection
|
|
850
|
+
};
|