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

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.
@@ -0,0 +1,592 @@
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/backlog/parameters.ts
46
+ var parameters = {
47
+ spaceUrl: new ParameterDefinition({
48
+ slug: "space-url",
49
+ name: "Backlog Space URL",
50
+ description: "Your Backlog space URL \u2014 just the base address, without any trailing path. For example: https://your-space.backlog.com or https://your-space.backlog.jp",
51
+ envVarBaseKey: "BACKLOG_SPACE_URL",
52
+ type: "text",
53
+ secret: false,
54
+ required: true
55
+ }),
56
+ apiKey: new ParameterDefinition({
57
+ slug: "api-key",
58
+ name: "API Key",
59
+ description: "Your Backlog API key. You can generate one at: Your Space > Personal Settings > API (https://your-space.backlog.com/EditApiSettings.action).",
60
+ envVarBaseKey: "BACKLOG_API_KEY",
61
+ type: "text",
62
+ secret: true,
63
+ required: true
64
+ })
65
+ };
66
+
67
+ // ../connectors/src/connectors/backlog/sdk/index.ts
68
+ function createClient(params) {
69
+ const spaceUrl = params[parameters.spaceUrl.slug];
70
+ const apiKey = params[parameters.apiKey.slug];
71
+ if (!spaceUrl || !apiKey) {
72
+ const required = [
73
+ parameters.spaceUrl.slug,
74
+ parameters.apiKey.slug
75
+ ];
76
+ const missing = required.filter((s) => !params[s]);
77
+ throw new Error(
78
+ `backlog: missing required parameters: ${missing.join(", ")}`
79
+ );
80
+ }
81
+ return {
82
+ request(path2, init) {
83
+ const separator = path2.includes("?") ? "&" : "?";
84
+ const url = `${spaceUrl.replace(/\/+$/, "")}${path2}${separator}apiKey=${apiKey}`;
85
+ const headers = new Headers(init?.headers);
86
+ headers.set("Accept", "application/json");
87
+ if (init?.body) {
88
+ headers.set("Content-Type", "application/json");
89
+ }
90
+ return fetch(url, { ...init, headers });
91
+ }
92
+ };
93
+ }
94
+
95
+ // ../connectors/src/connector-onboarding.ts
96
+ var ConnectorOnboarding = class {
97
+ /** Phase 1: Connection setup instructions (optional — some connectors don't need this) */
98
+ connectionSetupInstructions;
99
+ /** Phase 2: Data overview instructions */
100
+ dataOverviewInstructions;
101
+ constructor(config) {
102
+ this.connectionSetupInstructions = config.connectionSetupInstructions;
103
+ this.dataOverviewInstructions = config.dataOverviewInstructions;
104
+ }
105
+ getConnectionSetupPrompt(language) {
106
+ return this.connectionSetupInstructions?.[language] ?? null;
107
+ }
108
+ getDataOverviewInstructions(language) {
109
+ return this.dataOverviewInstructions[language];
110
+ }
111
+ };
112
+
113
+ // ../connectors/src/connector-tool.ts
114
+ var ConnectorTool = class {
115
+ name;
116
+ description;
117
+ inputSchema;
118
+ outputSchema;
119
+ _execute;
120
+ constructor(config) {
121
+ this.name = config.name;
122
+ this.description = config.description;
123
+ this.inputSchema = config.inputSchema;
124
+ this.outputSchema = config.outputSchema;
125
+ this._execute = config.execute;
126
+ }
127
+ createTool(connections, config) {
128
+ return {
129
+ description: this.description,
130
+ inputSchema: this.inputSchema,
131
+ outputSchema: this.outputSchema,
132
+ execute: (input) => this._execute(input, connections, config)
133
+ };
134
+ }
135
+ };
136
+
137
+ // ../connectors/src/connector-plugin.ts
138
+ var ConnectorPlugin = class _ConnectorPlugin {
139
+ slug;
140
+ authType;
141
+ name;
142
+ description;
143
+ iconUrl;
144
+ parameters;
145
+ releaseFlag;
146
+ proxyPolicy;
147
+ experimentalAttributes;
148
+ onboarding;
149
+ systemPrompt;
150
+ tools;
151
+ query;
152
+ checkConnection;
153
+ constructor(config) {
154
+ this.slug = config.slug;
155
+ this.authType = config.authType;
156
+ this.name = config.name;
157
+ this.description = config.description;
158
+ this.iconUrl = config.iconUrl;
159
+ this.parameters = config.parameters;
160
+ this.releaseFlag = config.releaseFlag;
161
+ this.proxyPolicy = config.proxyPolicy;
162
+ this.experimentalAttributes = config.experimentalAttributes;
163
+ this.onboarding = config.onboarding;
164
+ this.systemPrompt = config.systemPrompt;
165
+ this.tools = config.tools;
166
+ this.query = config.query;
167
+ this.checkConnection = config.checkConnection;
168
+ }
169
+ get connectorKey() {
170
+ return _ConnectorPlugin.deriveKey(this.slug, this.authType);
171
+ }
172
+ /**
173
+ * Create tools for connections that belong to this connector.
174
+ * Filters connections by connectorKey internally.
175
+ * Returns tools keyed as `${connectorKey}_${toolName}`.
176
+ */
177
+ createTools(connections, config) {
178
+ const myConnections = connections.filter(
179
+ (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
180
+ );
181
+ const result = {};
182
+ for (const t of Object.values(this.tools)) {
183
+ result[`${this.connectorKey}_${t.name}`] = t.createTool(
184
+ myConnections,
185
+ config
186
+ );
187
+ }
188
+ return result;
189
+ }
190
+ static deriveKey(slug, authType) {
191
+ return authType ? `${slug}-${authType}` : slug;
192
+ }
193
+ };
194
+
195
+ // ../connectors/src/auth-types.ts
196
+ var AUTH_TYPES = {
197
+ OAUTH: "oauth",
198
+ API_KEY: "api-key",
199
+ JWT: "jwt",
200
+ SERVICE_ACCOUNT: "service-account",
201
+ PAT: "pat",
202
+ USER_PASSWORD: "user-password"
203
+ };
204
+
205
+ // ../connectors/src/connectors/backlog/setup.ts
206
+ var backlogOnboarding = new ConnectorOnboarding({
207
+ dataOverviewInstructions: {
208
+ en: `1. Call backlog-api-key_request with GET space to verify the connection and get space information
209
+ 2. Call backlog-api-key_request with GET projects to list all accessible projects
210
+ 3. For key projects, call backlog-api-key_request with GET issues?projectId[]={projectId}&count=5&order=desc to retrieve recent issues
211
+ 4. Call backlog-api-key_request with GET projects/{projectIdOrKey}/statuses to understand the workflow statuses`,
212
+ ja: `1. backlog-api-key_request \u3067 GET space \u3092\u547C\u3073\u51FA\u3057\u3001\u63A5\u7D9A\u78BA\u8A8D\u3068\u30B9\u30DA\u30FC\u30B9\u60C5\u5831\u3092\u53D6\u5F97
213
+ 2. backlog-api-key_request \u3067 GET projects \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
214
+ 3. \u4E3B\u8981\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B\u3064\u3044\u3066 backlog-api-key_request \u3067 GET issues?projectId[]={projectId}&count=5&order=desc \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u8FD1\u306E\u8AB2\u984C\u3092\u53D6\u5F97
215
+ 4. backlog-api-key_request \u3067 GET projects/{projectIdOrKey}/statuses \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u306E\u30B9\u30C6\u30FC\u30BF\u30B9\u3092\u78BA\u8A8D`
216
+ }
217
+ });
218
+
219
+ // ../connectors/src/connectors/backlog/tools/request.ts
220
+ import { z } from "zod";
221
+ var REQUEST_TIMEOUT_MS = 6e4;
222
+ var inputSchema = z.object({
223
+ toolUseIntent: z.string().optional().describe("Brief description of what you intend to accomplish with this tool call"),
224
+ connectionId: z.string().describe("ID of the Backlog connection to use"),
225
+ method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method. Use GET to read resources, POST to create, PATCH/PUT to update, DELETE to remove."),
226
+ path: z.string().describe("API path relative to /api/v2/ (e.g., 'space', 'projects', 'issues?projectId[]=12345'). Query parameters can be appended. The apiKey query parameter is added automatically \u2014 do NOT include it."),
227
+ body: z.record(z.string(), z.unknown()).optional().describe("Request body as JSON object. Required for POST, PUT, and PATCH requests (e.g., issue creation, comment addition).")
228
+ });
229
+ var outputSchema = z.discriminatedUnion("success", [
230
+ z.object({
231
+ success: z.literal(true),
232
+ status: z.number(),
233
+ data: z.union([z.record(z.string(), z.unknown()), z.array(z.unknown())])
234
+ }),
235
+ z.object({
236
+ success: z.literal(false),
237
+ error: z.string()
238
+ })
239
+ ]);
240
+ var requestTool = new ConnectorTool({
241
+ name: "request",
242
+ description: `Send authenticated requests to the Backlog REST API (v2).
243
+ Authentication is handled automatically by appending the apiKey query parameter to every request.
244
+ Use this tool for all Backlog operations: listing projects, searching and creating issues, managing wikis, retrieving users, and more.
245
+ The base URL and API key are configured per connection \u2014 only specify the API path relative to /api/v2/.
246
+ Do NOT include the apiKey parameter yourself; it is injected automatically.`,
247
+ inputSchema,
248
+ outputSchema,
249
+ async execute({ connectionId, method, path: path2, body }, connections) {
250
+ const connection2 = connections.find((c) => c.id === connectionId);
251
+ if (!connection2) {
252
+ return { success: false, error: `Connection ${connectionId} not found` };
253
+ }
254
+ console.log(`[connector-request] backlog-api-key/${connection2.name}: ${method} ${path2}`);
255
+ try {
256
+ const spaceUrl = parameters.spaceUrl.getValue(connection2);
257
+ const apiKey = parameters.apiKey.getValue(connection2);
258
+ const separator = path2.includes("?") ? "&" : "?";
259
+ const url = `${spaceUrl.replace(/\/+$/, "")}/api/v2/${path2}${separator}apiKey=${apiKey}`;
260
+ const controller = new AbortController();
261
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
262
+ try {
263
+ const headers = {
264
+ Accept: "application/json"
265
+ };
266
+ if (body) {
267
+ headers["Content-Type"] = "application/json";
268
+ }
269
+ const response = await fetch(url, {
270
+ method,
271
+ headers,
272
+ body: body ? JSON.stringify(body) : void 0,
273
+ signal: controller.signal
274
+ });
275
+ if (response.status === 204) {
276
+ return { success: true, status: 204, data: {} };
277
+ }
278
+ const data = await response.json();
279
+ if (!response.ok) {
280
+ const errData = data;
281
+ const errors = errData?.errors;
282
+ const errorMessage = Array.isArray(errors) ? errors.map((e) => e.message).join("; ") : errData?.message ?? `HTTP ${response.status} ${response.statusText}`;
283
+ return { success: false, error: errorMessage };
284
+ }
285
+ return { success: true, status: response.status, data };
286
+ } finally {
287
+ clearTimeout(timeout);
288
+ }
289
+ } catch (err) {
290
+ const msg = err instanceof Error ? err.message : String(err);
291
+ return { success: false, error: msg };
292
+ }
293
+ }
294
+ });
295
+
296
+ // ../connectors/src/connectors/backlog/index.ts
297
+ var tools = { request: requestTool };
298
+ var backlogConnector = new ConnectorPlugin({
299
+ slug: "backlog",
300
+ authType: AUTH_TYPES.API_KEY,
301
+ name: "Backlog",
302
+ description: "Connect to Nulab Backlog for project management, issue tracking, and wiki data retrieval using API key authentication.",
303
+ iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6KcVBGf3mUHnuCOQgQMvtT/e8558c7990e40e3be46948e9476190fb/backlog-favicon.svg",
304
+ parameters,
305
+ releaseFlag: { dev1: true, dev2: true, prod: false },
306
+ onboarding: backlogOnboarding,
307
+ systemPrompt: {
308
+ en: `### Tools
309
+
310
+ - \`backlog-api-key_request\`: The only way to call the Backlog REST API (v2). Use it to list projects, search issues, get issue details, create/update issues, manage wikis, and retrieve users. Authentication (API key as query parameter) and space URL are configured automatically.
311
+
312
+ ### Business Logic
313
+
314
+ 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.
315
+
316
+ #### Example
317
+
318
+ \`\`\`ts
319
+ import { connection } from "@squadbase/vite-server/connectors/backlog-api-key";
320
+
321
+ const backlog = connection("<connectionId>");
322
+
323
+ // List projects
324
+ const res = await backlog.request("/api/v2/projects");
325
+ const projects = await res.json();
326
+
327
+ // Get issues for a project
328
+ const issuesRes = await backlog.request("/api/v2/issues?projectId[]=12345&count=20&sort=updated&order=desc");
329
+ const issues = await issuesRes.json();
330
+
331
+ // Create an issue
332
+ await backlog.request("/api/v2/issues", {
333
+ method: "POST",
334
+ body: JSON.stringify({
335
+ projectId: 12345,
336
+ summary: "New issue title",
337
+ issueTypeId: 67890,
338
+ priorityId: 3,
339
+ }),
340
+ });
341
+ \`\`\`
342
+
343
+ ### Backlog REST API v2 Reference
344
+
345
+ #### Space
346
+ - GET space \u2014 Get space information
347
+ - GET space/activities \u2014 Get recent activities in the space
348
+
349
+ #### Projects
350
+ - GET projects \u2014 List all projects (query params: archived, all)
351
+ - GET projects/{projectIdOrKey} \u2014 Get project details
352
+ - GET projects/{projectIdOrKey}/statuses \u2014 List issue statuses
353
+ - GET projects/{projectIdOrKey}/issueTypes \u2014 List issue types
354
+ - GET projects/{projectIdOrKey}/categories \u2014 List issue categories
355
+
356
+ #### Issues
357
+ - GET issues \u2014 Search issues (query params: projectId[], statusId[], assigneeId[], sort, order, count, offset, keyword)
358
+ - GET issues/{issueIdOrKey} \u2014 Get issue details
359
+ - GET issues/count \u2014 Get issue count
360
+ - POST issues \u2014 Create an issue (body: projectId, summary, issueTypeId, priorityId, and optional fields)
361
+ - PATCH issues/{issueIdOrKey} \u2014 Update an issue
362
+ - DELETE issues/{issueIdOrKey} \u2014 Delete an issue
363
+ - GET issues/{issueIdOrKey}/comments \u2014 List comments
364
+ - POST issues/{issueIdOrKey}/comments \u2014 Add a comment (body: { content: "comment text" })
365
+
366
+ #### Wiki
367
+ - GET wikis \u2014 List wiki pages (query params: projectIdOrKey, keyword)
368
+ - GET wikis/{wikiId} \u2014 Get wiki page details
369
+ - POST wikis \u2014 Create a wiki page (body: projectId, name, content)
370
+ - PATCH wikis/{wikiId} \u2014 Update a wiki page
371
+
372
+ #### Users
373
+ - GET users \u2014 List users in the space
374
+ - GET users/myself \u2014 Get authenticated user info
375
+
376
+ #### Pagination
377
+ - Use count (max 100, default 20) and offset parameters for pagination
378
+ - sort: "created", "updated", "issueType", "category", "priority", etc.
379
+ - order: "asc" or "desc"`,
380
+ ja: `### \u30C4\u30FC\u30EB
381
+
382
+ - \`backlog-api-key_request\`: Backlog REST API\uFF08v2\uFF09\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u306E\u53D6\u5F97\u3001\u8AB2\u984C\u306E\u691C\u7D22\u3001\u8AB2\u984C\u8A73\u7D30\u306E\u53D6\u5F97\u3001\u8AB2\u984C\u306E\u4F5C\u6210\u30FB\u66F4\u65B0\u3001Wiki\u7BA1\u7406\u3001\u30E6\u30FC\u30B6\u30FC\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08API\u30AD\u30FC\u3092\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u3068\u3057\u3066\u4ED8\u4E0E\uFF09\u3068\u30B9\u30DA\u30FC\u30B9URL\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
383
+
384
+ ### Business Logic
385
+
386
+ \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\u306B\u793A\u3059\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
387
+
388
+ #### Example
389
+
390
+ \`\`\`ts
391
+ import { connection } from "@squadbase/vite-server/connectors/backlog-api-key";
392
+
393
+ const backlog = connection("<connectionId>");
394
+
395
+ // \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u3092\u53D6\u5F97
396
+ const res = await backlog.request("/api/v2/projects");
397
+ const projects = await res.json();
398
+
399
+ // \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u8AB2\u984C\u3092\u53D6\u5F97
400
+ const issuesRes = await backlog.request("/api/v2/issues?projectId[]=12345&count=20&sort=updated&order=desc");
401
+ const issues = await issuesRes.json();
402
+
403
+ // \u8AB2\u984C\u3092\u4F5C\u6210
404
+ await backlog.request("/api/v2/issues", {
405
+ method: "POST",
406
+ body: JSON.stringify({
407
+ projectId: 12345,
408
+ summary: "\u65B0\u3057\u3044\u8AB2\u984C",
409
+ issueTypeId: 67890,
410
+ priorityId: 3,
411
+ }),
412
+ });
413
+ \`\`\`
414
+
415
+ ### Backlog REST API v2 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
416
+
417
+ #### \u30B9\u30DA\u30FC\u30B9
418
+ - GET space \u2014 \u30B9\u30DA\u30FC\u30B9\u60C5\u5831\u306E\u53D6\u5F97
419
+ - GET space/activities \u2014 \u30B9\u30DA\u30FC\u30B9\u306E\u6700\u8FD1\u306E\u6D3B\u52D5\u3092\u53D6\u5F97
420
+
421
+ #### \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8
422
+ - GET projects \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u4E00\u89A7\u306E\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: archived, all\uFF09
423
+ - GET projects/{projectIdOrKey} \u2014 \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u8A73\u7D30\u306E\u53D6\u5F97
424
+ - GET projects/{projectIdOrKey}/statuses \u2014 \u8AB2\u984C\u30B9\u30C6\u30FC\u30BF\u30B9\u4E00\u89A7
425
+ - GET projects/{projectIdOrKey}/issueTypes \u2014 \u8AB2\u984C\u7A2E\u5225\u4E00\u89A7
426
+ - GET projects/{projectIdOrKey}/categories \u2014 \u8AB2\u984C\u30AB\u30C6\u30B4\u30EA\u4E00\u89A7
427
+
428
+ #### \u8AB2\u984C
429
+ - GET issues \u2014 \u8AB2\u984C\u306E\u691C\u7D22\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: projectId[], statusId[], assigneeId[], sort, order, count, offset, keyword\uFF09
430
+ - GET issues/{issueIdOrKey} \u2014 \u8AB2\u984C\u8A73\u7D30\u306E\u53D6\u5F97
431
+ - GET issues/count \u2014 \u8AB2\u984C\u6570\u306E\u53D6\u5F97
432
+ - POST issues \u2014 \u8AB2\u984C\u306E\u4F5C\u6210\uFF08body: projectId, summary, issueTypeId, priorityId, \u305D\u306E\u4ED6\u30AA\u30D7\u30B7\u30E7\u30F3\u30D5\u30A3\u30FC\u30EB\u30C9\uFF09
433
+ - PATCH issues/{issueIdOrKey} \u2014 \u8AB2\u984C\u306E\u66F4\u65B0
434
+ - DELETE issues/{issueIdOrKey} \u2014 \u8AB2\u984C\u306E\u524A\u9664
435
+ - GET issues/{issueIdOrKey}/comments \u2014 \u30B3\u30E1\u30F3\u30C8\u4E00\u89A7
436
+ - POST issues/{issueIdOrKey}/comments \u2014 \u30B3\u30E1\u30F3\u30C8\u306E\u8FFD\u52A0\uFF08body: { content: "\u30B3\u30E1\u30F3\u30C8\u5185\u5BB9" }\uFF09
437
+
438
+ #### Wiki
439
+ - GET wikis \u2014 Wiki\u30DA\u30FC\u30B8\u4E00\u89A7\u306E\u53D6\u5F97\uFF08\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF: projectIdOrKey, keyword\uFF09
440
+ - GET wikis/{wikiId} \u2014 Wiki\u30DA\u30FC\u30B8\u8A73\u7D30\u306E\u53D6\u5F97
441
+ - POST wikis \u2014 Wiki\u30DA\u30FC\u30B8\u306E\u4F5C\u6210\uFF08body: projectId, name, content\uFF09
442
+ - PATCH wikis/{wikiId} \u2014 Wiki\u30DA\u30FC\u30B8\u306E\u66F4\u65B0
443
+
444
+ #### \u30E6\u30FC\u30B6\u30FC
445
+ - GET users \u2014 \u30B9\u30DA\u30FC\u30B9\u5185\u306E\u30E6\u30FC\u30B6\u30FC\u4E00\u89A7
446
+ - GET users/myself \u2014 \u8A8D\u8A3C\u6E08\u307F\u30E6\u30FC\u30B6\u30FC\u60C5\u5831\u306E\u53D6\u5F97
447
+
448
+ #### \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3
449
+ - count\uFF08\u6700\u5927100\u3001\u30C7\u30D5\u30A9\u30EB\u30C820\uFF09\u3068 offset \u30D1\u30E9\u30E1\u30FC\u30BF\u3067\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3
450
+ - sort: "created", "updated", "issueType", "category", "priority" \u7B49
451
+ - order: "asc" \u307E\u305F\u306F "desc"`
452
+ },
453
+ tools
454
+ });
455
+
456
+ // src/connectors/create-connector-sdk.ts
457
+ import { readFileSync } from "fs";
458
+ import path from "path";
459
+
460
+ // src/connector-client/env.ts
461
+ function resolveEnvVar(entry, key, connectionId) {
462
+ const envVarName = entry.envVars[key];
463
+ if (!envVarName) {
464
+ throw new Error(`Connection "${connectionId}" is missing envVars mapping for key "${key}"`);
465
+ }
466
+ const value = process.env[envVarName];
467
+ if (!value) {
468
+ throw new Error(`Environment variable "${envVarName}" (for connection "${connectionId}", key "${key}") is not set`);
469
+ }
470
+ return value;
471
+ }
472
+ function resolveEnvVarOptional(entry, key) {
473
+ const envVarName = entry.envVars[key];
474
+ if (!envVarName) return void 0;
475
+ return process.env[envVarName] || void 0;
476
+ }
477
+
478
+ // src/connector-client/proxy-fetch.ts
479
+ import { getContext } from "hono/context-storage";
480
+ import { getCookie } from "hono/cookie";
481
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
482
+ function createSandboxProxyFetch(connectionId) {
483
+ return async (input, init) => {
484
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
485
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
486
+ if (!token || !sandboxId) {
487
+ throw new Error(
488
+ "Connection proxy is not configured. Please check your deployment settings."
489
+ );
490
+ }
491
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
492
+ const originalMethod = init?.method ?? "GET";
493
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
494
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
495
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
496
+ return fetch(proxyUrl, {
497
+ method: "POST",
498
+ headers: {
499
+ "Content-Type": "application/json",
500
+ Authorization: `Bearer ${token}`
501
+ },
502
+ body: JSON.stringify({
503
+ url: originalUrl,
504
+ method: originalMethod,
505
+ body: originalBody
506
+ })
507
+ });
508
+ };
509
+ }
510
+ function createDeployedAppProxyFetch(connectionId) {
511
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
512
+ if (!projectId) {
513
+ throw new Error(
514
+ "Connection proxy is not configured. Please check your deployment settings."
515
+ );
516
+ }
517
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
518
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
519
+ return async (input, init) => {
520
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
521
+ const originalMethod = init?.method ?? "GET";
522
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
523
+ const c = getContext();
524
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
525
+ if (!appSession) {
526
+ throw new Error(
527
+ "No authentication method available for connection proxy."
528
+ );
529
+ }
530
+ return fetch(proxyUrl, {
531
+ method: "POST",
532
+ headers: {
533
+ "Content-Type": "application/json",
534
+ Authorization: `Bearer ${appSession}`
535
+ },
536
+ body: JSON.stringify({
537
+ url: originalUrl,
538
+ method: originalMethod,
539
+ body: originalBody
540
+ })
541
+ });
542
+ };
543
+ }
544
+ function createProxyFetch(connectionId) {
545
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
546
+ return createSandboxProxyFetch(connectionId);
547
+ }
548
+ return createDeployedAppProxyFetch(connectionId);
549
+ }
550
+
551
+ // src/connectors/create-connector-sdk.ts
552
+ function loadConnectionsSync() {
553
+ const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
554
+ try {
555
+ const raw = readFileSync(filePath, "utf-8");
556
+ return JSON.parse(raw);
557
+ } catch {
558
+ return {};
559
+ }
560
+ }
561
+ function createConnectorSdk(plugin, createClient2) {
562
+ return (connectionId) => {
563
+ const connections = loadConnectionsSync();
564
+ const entry = connections[connectionId];
565
+ if (!entry) {
566
+ throw new Error(
567
+ `Connection "${connectionId}" not found in .squadbase/connections.json`
568
+ );
569
+ }
570
+ if (entry.connector.slug !== plugin.slug) {
571
+ throw new Error(
572
+ `Connection "${connectionId}" is not a ${plugin.slug} connection (got "${entry.connector.slug}")`
573
+ );
574
+ }
575
+ const params = {};
576
+ for (const param of Object.values(plugin.parameters)) {
577
+ if (param.required) {
578
+ params[param.slug] = resolveEnvVar(entry, param.slug, connectionId);
579
+ } else {
580
+ const val = resolveEnvVarOptional(entry, param.slug);
581
+ if (val !== void 0) params[param.slug] = val;
582
+ }
583
+ }
584
+ return createClient2(params, createProxyFetch(connectionId));
585
+ };
586
+ }
587
+
588
+ // src/connectors/entries/backlog-api-key.ts
589
+ var connection = createConnectorSdk(backlogConnector, createClient);
590
+ export {
591
+ connection
592
+ };