@xutest1/sdk 0.1.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +8 -0
- package/client.js +11 -1280
- package/gen/client/client.gen.d.ts +2 -0
- package/gen/client/client.gen.js +167 -0
- package/gen/client/index.d.ts +7 -0
- package/gen/client/index.js +5 -0
- package/gen/client/types.gen.d.ts +127 -0
- package/gen/client/types.gen.js +2 -0
- package/gen/client/utils.gen.d.ts +38 -0
- package/gen/client/utils.gen.js +228 -0
- package/gen/client.gen.d.ts +12 -0
- package/gen/client.gen.js +5 -0
- package/gen/core/auth.gen.d.ts +18 -0
- package/gen/core/auth.gen.js +14 -0
- package/gen/core/bodySerializer.gen.d.ts +17 -0
- package/gen/core/bodySerializer.gen.js +57 -0
- package/gen/core/params.gen.d.ts +33 -0
- package/gen/core/params.gen.js +89 -0
- package/gen/core/pathSerializer.gen.d.ts +33 -0
- package/gen/core/pathSerializer.gen.js +106 -0
- package/gen/core/serverSentEvents.gen.d.ts +59 -0
- package/gen/core/serverSentEvents.gen.js +117 -0
- package/gen/core/types.gen.d.ts +78 -0
- package/gen/core/types.gen.js +2 -0
- package/gen/core/utils.gen.d.ts +14 -0
- package/gen/core/utils.gen.js +69 -0
- package/gen/sdk.gen.d.ts +338 -0
- package/gen/sdk.gen.js +735 -0
- package/gen/types.gen.d.ts +2868 -0
- package/gen/types.gen.js +2 -0
- package/index.d.ts +15 -0
- package/index.js +20 -1426
- package/package.json +22 -15
- package/server.d.ts +23 -0
- package/server.js +99 -123
package/client.js
CHANGED
|
@@ -1,1280 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
...options
|
|
13
|
-
}) => {
|
|
14
|
-
let lastEventId;
|
|
15
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
16
|
-
const createStream = async function* () {
|
|
17
|
-
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
18
|
-
let attempt = 0;
|
|
19
|
-
const signal = options.signal ?? new AbortController().signal;
|
|
20
|
-
while (true) {
|
|
21
|
-
if (signal.aborted)
|
|
22
|
-
break;
|
|
23
|
-
attempt++;
|
|
24
|
-
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
25
|
-
if (lastEventId !== undefined) {
|
|
26
|
-
headers.set("Last-Event-ID", lastEventId);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const response = await fetch(url, { ...options, headers, signal });
|
|
30
|
-
if (!response.ok)
|
|
31
|
-
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
32
|
-
if (!response.body)
|
|
33
|
-
throw new Error("No body in SSE response");
|
|
34
|
-
const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
|
|
35
|
-
let buffer = "";
|
|
36
|
-
const abortHandler = () => {
|
|
37
|
-
try {
|
|
38
|
-
reader.cancel();
|
|
39
|
-
} catch {}
|
|
40
|
-
};
|
|
41
|
-
signal.addEventListener("abort", abortHandler);
|
|
42
|
-
try {
|
|
43
|
-
while (true) {
|
|
44
|
-
const { done, value } = await reader.read();
|
|
45
|
-
if (done)
|
|
46
|
-
break;
|
|
47
|
-
buffer += value;
|
|
48
|
-
const chunks = buffer.split(`
|
|
49
|
-
|
|
50
|
-
`);
|
|
51
|
-
buffer = chunks.pop() ?? "";
|
|
52
|
-
for (const chunk of chunks) {
|
|
53
|
-
const lines = chunk.split(`
|
|
54
|
-
`);
|
|
55
|
-
const dataLines = [];
|
|
56
|
-
let eventName;
|
|
57
|
-
for (const line of lines) {
|
|
58
|
-
if (line.startsWith("data:")) {
|
|
59
|
-
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
60
|
-
} else if (line.startsWith("event:")) {
|
|
61
|
-
eventName = line.replace(/^event:\s*/, "");
|
|
62
|
-
} else if (line.startsWith("id:")) {
|
|
63
|
-
lastEventId = line.replace(/^id:\s*/, "");
|
|
64
|
-
} else if (line.startsWith("retry:")) {
|
|
65
|
-
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
66
|
-
if (!Number.isNaN(parsed)) {
|
|
67
|
-
retryDelay = parsed;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
let data;
|
|
72
|
-
let parsedJson = false;
|
|
73
|
-
if (dataLines.length) {
|
|
74
|
-
const rawData = dataLines.join(`
|
|
75
|
-
`);
|
|
76
|
-
try {
|
|
77
|
-
data = JSON.parse(rawData);
|
|
78
|
-
parsedJson = true;
|
|
79
|
-
} catch {
|
|
80
|
-
data = rawData;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (parsedJson) {
|
|
84
|
-
if (responseValidator) {
|
|
85
|
-
await responseValidator(data);
|
|
86
|
-
}
|
|
87
|
-
if (responseTransformer) {
|
|
88
|
-
data = await responseTransformer(data);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
onSseEvent?.({
|
|
92
|
-
data,
|
|
93
|
-
event: eventName,
|
|
94
|
-
id: lastEventId,
|
|
95
|
-
retry: retryDelay
|
|
96
|
-
});
|
|
97
|
-
if (dataLines.length) {
|
|
98
|
-
yield data;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
} finally {
|
|
103
|
-
signal.removeEventListener("abort", abortHandler);
|
|
104
|
-
reader.releaseLock();
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
} catch (error) {
|
|
108
|
-
onSseError?.(error);
|
|
109
|
-
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
113
|
-
await sleep(backoff);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
const stream = createStream();
|
|
118
|
-
return { stream };
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// src/gen/core/auth.gen.ts
|
|
122
|
-
var getAuthToken = async (auth, callback) => {
|
|
123
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
124
|
-
if (!token) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (auth.scheme === "bearer") {
|
|
128
|
-
return `Bearer ${token}`;
|
|
129
|
-
}
|
|
130
|
-
if (auth.scheme === "basic") {
|
|
131
|
-
return `Basic ${btoa(token)}`;
|
|
132
|
-
}
|
|
133
|
-
return token;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/gen/core/bodySerializer.gen.ts
|
|
137
|
-
var jsonBodySerializer = {
|
|
138
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/gen/core/pathSerializer.gen.ts
|
|
142
|
-
var separatorArrayExplode = (style) => {
|
|
143
|
-
switch (style) {
|
|
144
|
-
case "label":
|
|
145
|
-
return ".";
|
|
146
|
-
case "matrix":
|
|
147
|
-
return ";";
|
|
148
|
-
case "simple":
|
|
149
|
-
return ",";
|
|
150
|
-
default:
|
|
151
|
-
return "&";
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
var separatorArrayNoExplode = (style) => {
|
|
155
|
-
switch (style) {
|
|
156
|
-
case "form":
|
|
157
|
-
return ",";
|
|
158
|
-
case "pipeDelimited":
|
|
159
|
-
return "|";
|
|
160
|
-
case "spaceDelimited":
|
|
161
|
-
return "%20";
|
|
162
|
-
default:
|
|
163
|
-
return ",";
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
var separatorObjectExplode = (style) => {
|
|
167
|
-
switch (style) {
|
|
168
|
-
case "label":
|
|
169
|
-
return ".";
|
|
170
|
-
case "matrix":
|
|
171
|
-
return ";";
|
|
172
|
-
case "simple":
|
|
173
|
-
return ",";
|
|
174
|
-
default:
|
|
175
|
-
return "&";
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var serializeArrayParam = ({
|
|
179
|
-
allowReserved,
|
|
180
|
-
explode,
|
|
181
|
-
name,
|
|
182
|
-
style,
|
|
183
|
-
value
|
|
184
|
-
}) => {
|
|
185
|
-
if (!explode) {
|
|
186
|
-
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
187
|
-
switch (style) {
|
|
188
|
-
case "label":
|
|
189
|
-
return `.${joinedValues2}`;
|
|
190
|
-
case "matrix":
|
|
191
|
-
return `;${name}=${joinedValues2}`;
|
|
192
|
-
case "simple":
|
|
193
|
-
return joinedValues2;
|
|
194
|
-
default:
|
|
195
|
-
return `${name}=${joinedValues2}`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
const separator = separatorArrayExplode(style);
|
|
199
|
-
const joinedValues = value.map((v) => {
|
|
200
|
-
if (style === "label" || style === "simple") {
|
|
201
|
-
return allowReserved ? v : encodeURIComponent(v);
|
|
202
|
-
}
|
|
203
|
-
return serializePrimitiveParam({
|
|
204
|
-
allowReserved,
|
|
205
|
-
name,
|
|
206
|
-
value: v
|
|
207
|
-
});
|
|
208
|
-
}).join(separator);
|
|
209
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
210
|
-
};
|
|
211
|
-
var serializePrimitiveParam = ({
|
|
212
|
-
allowReserved,
|
|
213
|
-
name,
|
|
214
|
-
value
|
|
215
|
-
}) => {
|
|
216
|
-
if (value === undefined || value === null) {
|
|
217
|
-
return "";
|
|
218
|
-
}
|
|
219
|
-
if (typeof value === "object") {
|
|
220
|
-
throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
|
|
221
|
-
}
|
|
222
|
-
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
223
|
-
};
|
|
224
|
-
var serializeObjectParam = ({
|
|
225
|
-
allowReserved,
|
|
226
|
-
explode,
|
|
227
|
-
name,
|
|
228
|
-
style,
|
|
229
|
-
value,
|
|
230
|
-
valueOnly
|
|
231
|
-
}) => {
|
|
232
|
-
if (value instanceof Date) {
|
|
233
|
-
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
234
|
-
}
|
|
235
|
-
if (style !== "deepObject" && !explode) {
|
|
236
|
-
let values = [];
|
|
237
|
-
Object.entries(value).forEach(([key, v]) => {
|
|
238
|
-
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
239
|
-
});
|
|
240
|
-
const joinedValues2 = values.join(",");
|
|
241
|
-
switch (style) {
|
|
242
|
-
case "form":
|
|
243
|
-
return `${name}=${joinedValues2}`;
|
|
244
|
-
case "label":
|
|
245
|
-
return `.${joinedValues2}`;
|
|
246
|
-
case "matrix":
|
|
247
|
-
return `;${name}=${joinedValues2}`;
|
|
248
|
-
default:
|
|
249
|
-
return joinedValues2;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
const separator = separatorObjectExplode(style);
|
|
253
|
-
const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
|
|
254
|
-
allowReserved,
|
|
255
|
-
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
256
|
-
value: v
|
|
257
|
-
})).join(separator);
|
|
258
|
-
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// src/gen/core/utils.gen.ts
|
|
262
|
-
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
263
|
-
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
264
|
-
let url = _url;
|
|
265
|
-
const matches = _url.match(PATH_PARAM_RE);
|
|
266
|
-
if (matches) {
|
|
267
|
-
for (const match of matches) {
|
|
268
|
-
let explode = false;
|
|
269
|
-
let name = match.substring(1, match.length - 1);
|
|
270
|
-
let style = "simple";
|
|
271
|
-
if (name.endsWith("*")) {
|
|
272
|
-
explode = true;
|
|
273
|
-
name = name.substring(0, name.length - 1);
|
|
274
|
-
}
|
|
275
|
-
if (name.startsWith(".")) {
|
|
276
|
-
name = name.substring(1);
|
|
277
|
-
style = "label";
|
|
278
|
-
} else if (name.startsWith(";")) {
|
|
279
|
-
name = name.substring(1);
|
|
280
|
-
style = "matrix";
|
|
281
|
-
}
|
|
282
|
-
const value = path[name];
|
|
283
|
-
if (value === undefined || value === null) {
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
if (Array.isArray(value)) {
|
|
287
|
-
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
if (typeof value === "object") {
|
|
291
|
-
url = url.replace(match, serializeObjectParam({
|
|
292
|
-
explode,
|
|
293
|
-
name,
|
|
294
|
-
style,
|
|
295
|
-
value,
|
|
296
|
-
valueOnly: true
|
|
297
|
-
}));
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if (style === "matrix") {
|
|
301
|
-
url = url.replace(match, `;${serializePrimitiveParam({
|
|
302
|
-
name,
|
|
303
|
-
value
|
|
304
|
-
})}`);
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
308
|
-
url = url.replace(match, replaceValue);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return url;
|
|
312
|
-
};
|
|
313
|
-
var getUrl = ({
|
|
314
|
-
baseUrl,
|
|
315
|
-
path,
|
|
316
|
-
query,
|
|
317
|
-
querySerializer,
|
|
318
|
-
url: _url
|
|
319
|
-
}) => {
|
|
320
|
-
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
321
|
-
let url = (baseUrl ?? "") + pathUrl;
|
|
322
|
-
if (path) {
|
|
323
|
-
url = defaultPathSerializer({ path, url });
|
|
324
|
-
}
|
|
325
|
-
let search = query ? querySerializer(query) : "";
|
|
326
|
-
if (search.startsWith("?")) {
|
|
327
|
-
search = search.substring(1);
|
|
328
|
-
}
|
|
329
|
-
if (search) {
|
|
330
|
-
url += `?${search}`;
|
|
331
|
-
}
|
|
332
|
-
return url;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// src/gen/client/utils.gen.ts
|
|
336
|
-
var createQuerySerializer = ({
|
|
337
|
-
allowReserved,
|
|
338
|
-
array,
|
|
339
|
-
object
|
|
340
|
-
} = {}) => {
|
|
341
|
-
const querySerializer = (queryParams) => {
|
|
342
|
-
const search = [];
|
|
343
|
-
if (queryParams && typeof queryParams === "object") {
|
|
344
|
-
for (const name in queryParams) {
|
|
345
|
-
const value = queryParams[name];
|
|
346
|
-
if (value === undefined || value === null) {
|
|
347
|
-
continue;
|
|
348
|
-
}
|
|
349
|
-
if (Array.isArray(value)) {
|
|
350
|
-
const serializedArray = serializeArrayParam({
|
|
351
|
-
allowReserved,
|
|
352
|
-
explode: true,
|
|
353
|
-
name,
|
|
354
|
-
style: "form",
|
|
355
|
-
value,
|
|
356
|
-
...array
|
|
357
|
-
});
|
|
358
|
-
if (serializedArray)
|
|
359
|
-
search.push(serializedArray);
|
|
360
|
-
} else if (typeof value === "object") {
|
|
361
|
-
const serializedObject = serializeObjectParam({
|
|
362
|
-
allowReserved,
|
|
363
|
-
explode: true,
|
|
364
|
-
name,
|
|
365
|
-
style: "deepObject",
|
|
366
|
-
value,
|
|
367
|
-
...object
|
|
368
|
-
});
|
|
369
|
-
if (serializedObject)
|
|
370
|
-
search.push(serializedObject);
|
|
371
|
-
} else {
|
|
372
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
373
|
-
allowReserved,
|
|
374
|
-
name,
|
|
375
|
-
value
|
|
376
|
-
});
|
|
377
|
-
if (serializedPrimitive)
|
|
378
|
-
search.push(serializedPrimitive);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
return search.join("&");
|
|
383
|
-
};
|
|
384
|
-
return querySerializer;
|
|
385
|
-
};
|
|
386
|
-
var getParseAs = (contentType) => {
|
|
387
|
-
if (!contentType) {
|
|
388
|
-
return "stream";
|
|
389
|
-
}
|
|
390
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
391
|
-
if (!cleanContent) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
395
|
-
return "json";
|
|
396
|
-
}
|
|
397
|
-
if (cleanContent === "multipart/form-data") {
|
|
398
|
-
return "formData";
|
|
399
|
-
}
|
|
400
|
-
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
401
|
-
return "blob";
|
|
402
|
-
}
|
|
403
|
-
if (cleanContent.startsWith("text/")) {
|
|
404
|
-
return "text";
|
|
405
|
-
}
|
|
406
|
-
return;
|
|
407
|
-
};
|
|
408
|
-
var checkForExistence = (options, name) => {
|
|
409
|
-
if (!name) {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
return false;
|
|
416
|
-
};
|
|
417
|
-
var setAuthParams = async ({
|
|
418
|
-
security,
|
|
419
|
-
...options
|
|
420
|
-
}) => {
|
|
421
|
-
for (const auth of security) {
|
|
422
|
-
if (checkForExistence(options, auth.name)) {
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
const token = await getAuthToken(auth, options.auth);
|
|
426
|
-
if (!token) {
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
const name = auth.name ?? "Authorization";
|
|
430
|
-
switch (auth.in) {
|
|
431
|
-
case "query":
|
|
432
|
-
if (!options.query) {
|
|
433
|
-
options.query = {};
|
|
434
|
-
}
|
|
435
|
-
options.query[name] = token;
|
|
436
|
-
break;
|
|
437
|
-
case "cookie":
|
|
438
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
439
|
-
break;
|
|
440
|
-
case "header":
|
|
441
|
-
default:
|
|
442
|
-
options.headers.set(name, token);
|
|
443
|
-
break;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
var buildUrl = (options) => getUrl({
|
|
448
|
-
baseUrl: options.baseUrl,
|
|
449
|
-
path: options.path,
|
|
450
|
-
query: options.query,
|
|
451
|
-
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
452
|
-
url: options.url
|
|
453
|
-
});
|
|
454
|
-
var mergeConfigs = (a, b) => {
|
|
455
|
-
const config = { ...a, ...b };
|
|
456
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
457
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
458
|
-
}
|
|
459
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
460
|
-
return config;
|
|
461
|
-
};
|
|
462
|
-
var mergeHeaders = (...headers) => {
|
|
463
|
-
const mergedHeaders = new Headers;
|
|
464
|
-
for (const header of headers) {
|
|
465
|
-
if (!header || typeof header !== "object") {
|
|
466
|
-
continue;
|
|
467
|
-
}
|
|
468
|
-
const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
|
|
469
|
-
for (const [key, value] of iterator) {
|
|
470
|
-
if (value === null) {
|
|
471
|
-
mergedHeaders.delete(key);
|
|
472
|
-
} else if (Array.isArray(value)) {
|
|
473
|
-
for (const v of value) {
|
|
474
|
-
mergedHeaders.append(key, v);
|
|
475
|
-
}
|
|
476
|
-
} else if (value !== undefined) {
|
|
477
|
-
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return mergedHeaders;
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
class Interceptors {
|
|
485
|
-
_fns;
|
|
486
|
-
constructor() {
|
|
487
|
-
this._fns = [];
|
|
488
|
-
}
|
|
489
|
-
clear() {
|
|
490
|
-
this._fns = [];
|
|
491
|
-
}
|
|
492
|
-
getInterceptorIndex(id) {
|
|
493
|
-
if (typeof id === "number") {
|
|
494
|
-
return this._fns[id] ? id : -1;
|
|
495
|
-
} else {
|
|
496
|
-
return this._fns.indexOf(id);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
exists(id) {
|
|
500
|
-
const index = this.getInterceptorIndex(id);
|
|
501
|
-
return !!this._fns[index];
|
|
502
|
-
}
|
|
503
|
-
eject(id) {
|
|
504
|
-
const index = this.getInterceptorIndex(id);
|
|
505
|
-
if (this._fns[index]) {
|
|
506
|
-
this._fns[index] = null;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
update(id, fn) {
|
|
510
|
-
const index = this.getInterceptorIndex(id);
|
|
511
|
-
if (this._fns[index]) {
|
|
512
|
-
this._fns[index] = fn;
|
|
513
|
-
return id;
|
|
514
|
-
} else {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
use(fn) {
|
|
519
|
-
this._fns = [...this._fns, fn];
|
|
520
|
-
return this._fns.length - 1;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
var createInterceptors = () => ({
|
|
524
|
-
error: new Interceptors,
|
|
525
|
-
request: new Interceptors,
|
|
526
|
-
response: new Interceptors
|
|
527
|
-
});
|
|
528
|
-
var defaultQuerySerializer = createQuerySerializer({
|
|
529
|
-
allowReserved: false,
|
|
530
|
-
array: {
|
|
531
|
-
explode: true,
|
|
532
|
-
style: "form"
|
|
533
|
-
},
|
|
534
|
-
object: {
|
|
535
|
-
explode: true,
|
|
536
|
-
style: "deepObject"
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
var defaultHeaders = {
|
|
540
|
-
"Content-Type": "application/json"
|
|
541
|
-
};
|
|
542
|
-
var createConfig = (override = {}) => ({
|
|
543
|
-
...jsonBodySerializer,
|
|
544
|
-
headers: defaultHeaders,
|
|
545
|
-
parseAs: "auto",
|
|
546
|
-
querySerializer: defaultQuerySerializer,
|
|
547
|
-
...override
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
// src/gen/client/client.gen.ts
|
|
551
|
-
var createClient = (config = {}) => {
|
|
552
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
553
|
-
const getConfig = () => ({ ..._config });
|
|
554
|
-
const setConfig = (config2) => {
|
|
555
|
-
_config = mergeConfigs(_config, config2);
|
|
556
|
-
return getConfig();
|
|
557
|
-
};
|
|
558
|
-
const interceptors = createInterceptors();
|
|
559
|
-
const beforeRequest = async (options) => {
|
|
560
|
-
const opts = {
|
|
561
|
-
..._config,
|
|
562
|
-
...options,
|
|
563
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
564
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
565
|
-
serializedBody: undefined
|
|
566
|
-
};
|
|
567
|
-
if (opts.security) {
|
|
568
|
-
await setAuthParams({
|
|
569
|
-
...opts,
|
|
570
|
-
security: opts.security
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
if (opts.requestValidator) {
|
|
574
|
-
await opts.requestValidator(opts);
|
|
575
|
-
}
|
|
576
|
-
if (opts.body && opts.bodySerializer) {
|
|
577
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
578
|
-
}
|
|
579
|
-
if (opts.serializedBody === undefined || opts.serializedBody === "") {
|
|
580
|
-
opts.headers.delete("Content-Type");
|
|
581
|
-
}
|
|
582
|
-
const url = buildUrl(opts);
|
|
583
|
-
return { opts, url };
|
|
584
|
-
};
|
|
585
|
-
const request = async (options) => {
|
|
586
|
-
const { opts, url } = await beforeRequest(options);
|
|
587
|
-
const requestInit = {
|
|
588
|
-
redirect: "follow",
|
|
589
|
-
...opts,
|
|
590
|
-
body: opts.serializedBody
|
|
591
|
-
};
|
|
592
|
-
let request2 = new Request(url, requestInit);
|
|
593
|
-
for (const fn of interceptors.request._fns) {
|
|
594
|
-
if (fn) {
|
|
595
|
-
request2 = await fn(request2, opts);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const _fetch = opts.fetch;
|
|
599
|
-
let response = await _fetch(request2);
|
|
600
|
-
for (const fn of interceptors.response._fns) {
|
|
601
|
-
if (fn) {
|
|
602
|
-
response = await fn(response, request2, opts);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
const result = {
|
|
606
|
-
request: request2,
|
|
607
|
-
response
|
|
608
|
-
};
|
|
609
|
-
if (response.ok) {
|
|
610
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
611
|
-
return opts.responseStyle === "data" ? {} : {
|
|
612
|
-
data: {},
|
|
613
|
-
...result
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
617
|
-
let data;
|
|
618
|
-
switch (parseAs) {
|
|
619
|
-
case "arrayBuffer":
|
|
620
|
-
case "blob":
|
|
621
|
-
case "formData":
|
|
622
|
-
case "json":
|
|
623
|
-
case "text":
|
|
624
|
-
data = await response[parseAs]();
|
|
625
|
-
break;
|
|
626
|
-
case "stream":
|
|
627
|
-
return opts.responseStyle === "data" ? response.body : {
|
|
628
|
-
data: response.body,
|
|
629
|
-
...result
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
if (parseAs === "json") {
|
|
633
|
-
if (opts.responseValidator) {
|
|
634
|
-
await opts.responseValidator(data);
|
|
635
|
-
}
|
|
636
|
-
if (opts.responseTransformer) {
|
|
637
|
-
data = await opts.responseTransformer(data);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
return opts.responseStyle === "data" ? data : {
|
|
641
|
-
data,
|
|
642
|
-
...result
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
const textError = await response.text();
|
|
646
|
-
let jsonError;
|
|
647
|
-
try {
|
|
648
|
-
jsonError = JSON.parse(textError);
|
|
649
|
-
} catch {}
|
|
650
|
-
const error = jsonError ?? textError;
|
|
651
|
-
let finalError = error;
|
|
652
|
-
for (const fn of interceptors.error._fns) {
|
|
653
|
-
if (fn) {
|
|
654
|
-
finalError = await fn(error, response, request2, opts);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
finalError = finalError || {};
|
|
658
|
-
if (opts.throwOnError) {
|
|
659
|
-
throw finalError;
|
|
660
|
-
}
|
|
661
|
-
return opts.responseStyle === "data" ? undefined : {
|
|
662
|
-
error: finalError,
|
|
663
|
-
...result
|
|
664
|
-
};
|
|
665
|
-
};
|
|
666
|
-
const makeMethod = (method) => {
|
|
667
|
-
const fn = (options) => request({ ...options, method });
|
|
668
|
-
fn.sse = async (options) => {
|
|
669
|
-
const { opts, url } = await beforeRequest(options);
|
|
670
|
-
return createSseClient({
|
|
671
|
-
...opts,
|
|
672
|
-
body: opts.body,
|
|
673
|
-
headers: opts.headers,
|
|
674
|
-
method,
|
|
675
|
-
url
|
|
676
|
-
});
|
|
677
|
-
};
|
|
678
|
-
return fn;
|
|
679
|
-
};
|
|
680
|
-
return {
|
|
681
|
-
buildUrl,
|
|
682
|
-
connect: makeMethod("CONNECT"),
|
|
683
|
-
delete: makeMethod("DELETE"),
|
|
684
|
-
get: makeMethod("GET"),
|
|
685
|
-
getConfig,
|
|
686
|
-
head: makeMethod("HEAD"),
|
|
687
|
-
interceptors,
|
|
688
|
-
options: makeMethod("OPTIONS"),
|
|
689
|
-
patch: makeMethod("PATCH"),
|
|
690
|
-
post: makeMethod("POST"),
|
|
691
|
-
put: makeMethod("PUT"),
|
|
692
|
-
request,
|
|
693
|
-
setConfig,
|
|
694
|
-
trace: makeMethod("TRACE")
|
|
695
|
-
};
|
|
696
|
-
};
|
|
697
|
-
// src/gen/core/params.gen.ts
|
|
698
|
-
var extraPrefixesMap = {
|
|
699
|
-
$body_: "body",
|
|
700
|
-
$headers_: "headers",
|
|
701
|
-
$path_: "path",
|
|
702
|
-
$query_: "query"
|
|
703
|
-
};
|
|
704
|
-
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
705
|
-
// src/gen/client.gen.ts
|
|
706
|
-
var client = createClient(createConfig({
|
|
707
|
-
baseUrl: "http://localhost:4096"
|
|
708
|
-
}));
|
|
709
|
-
|
|
710
|
-
// src/gen/sdk.gen.ts
|
|
711
|
-
class _HeyApiClient {
|
|
712
|
-
_client = client;
|
|
713
|
-
constructor(args) {
|
|
714
|
-
if (args?.client) {
|
|
715
|
-
this._client = args.client;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
class Project extends _HeyApiClient {
|
|
721
|
-
list(options) {
|
|
722
|
-
return (options?.client ?? this._client).get({
|
|
723
|
-
url: "/project",
|
|
724
|
-
...options
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
current(options) {
|
|
728
|
-
return (options?.client ?? this._client).get({
|
|
729
|
-
url: "/project/current",
|
|
730
|
-
...options
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
class Current extends _HeyApiClient {
|
|
736
|
-
context(options) {
|
|
737
|
-
return (options?.client ?? this._client).get({
|
|
738
|
-
url: "/fds/paper/current/context",
|
|
739
|
-
...options
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
class Spec extends _HeyApiClient {
|
|
745
|
-
set(options) {
|
|
746
|
-
return (options.client ?? this._client).put({
|
|
747
|
-
url: "/fds/paper/{id}/spec",
|
|
748
|
-
...options,
|
|
749
|
-
headers: {
|
|
750
|
-
"Content-Type": "application/json",
|
|
751
|
-
...options.headers
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
class Paper extends _HeyApiClient {
|
|
758
|
-
load(options) {
|
|
759
|
-
return (options?.client ?? this._client).post({
|
|
760
|
-
url: "/fds/paper/load",
|
|
761
|
-
...options,
|
|
762
|
-
headers: {
|
|
763
|
-
"Content-Type": "application/json",
|
|
764
|
-
...options?.headers
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
context(options) {
|
|
769
|
-
return (options.client ?? this._client).get({
|
|
770
|
-
url: "/fds/paper/{id}/context",
|
|
771
|
-
...options
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
delete(options) {
|
|
775
|
-
return (options.client ?? this._client).delete({
|
|
776
|
-
url: "/fds/paper/{id}",
|
|
777
|
-
...options
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
get(options) {
|
|
781
|
-
return (options.client ?? this._client).get({
|
|
782
|
-
url: "/fds/paper/{id}",
|
|
783
|
-
...options
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
list(options) {
|
|
787
|
-
return (options?.client ?? this._client).get({
|
|
788
|
-
url: "/fds/paper",
|
|
789
|
-
...options
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
phase(options) {
|
|
793
|
-
return (options.client ?? this._client).patch({
|
|
794
|
-
url: "/fds/paper/{id}/phase",
|
|
795
|
-
...options,
|
|
796
|
-
headers: {
|
|
797
|
-
"Content-Type": "application/json",
|
|
798
|
-
...options.headers
|
|
799
|
-
}
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
current = new Current({ client: this._client });
|
|
803
|
-
spec = new Spec({ client: this._client });
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
class Fds extends _HeyApiClient {
|
|
807
|
-
dependencies(options) {
|
|
808
|
-
return (options?.client ?? this._client).get({
|
|
809
|
-
url: "/fds/dependencies",
|
|
810
|
-
...options
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
paper = new Paper({ client: this._client });
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
class Config extends _HeyApiClient {
|
|
817
|
-
get(options) {
|
|
818
|
-
return (options?.client ?? this._client).get({
|
|
819
|
-
url: "/config",
|
|
820
|
-
...options
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
update(options) {
|
|
824
|
-
return (options?.client ?? this._client).patch({
|
|
825
|
-
url: "/config",
|
|
826
|
-
...options,
|
|
827
|
-
headers: {
|
|
828
|
-
"Content-Type": "application/json",
|
|
829
|
-
...options?.headers
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
providers(options) {
|
|
834
|
-
return (options?.client ?? this._client).get({
|
|
835
|
-
url: "/config/providers",
|
|
836
|
-
...options
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
class Tool extends _HeyApiClient {
|
|
842
|
-
ids(options) {
|
|
843
|
-
return (options?.client ?? this._client).get({
|
|
844
|
-
url: "/experimental/tool/ids",
|
|
845
|
-
...options
|
|
846
|
-
});
|
|
847
|
-
}
|
|
848
|
-
list(options) {
|
|
849
|
-
return (options.client ?? this._client).get({
|
|
850
|
-
url: "/experimental/tool",
|
|
851
|
-
...options
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
class Path extends _HeyApiClient {
|
|
857
|
-
get(options) {
|
|
858
|
-
return (options?.client ?? this._client).get({
|
|
859
|
-
url: "/path",
|
|
860
|
-
...options
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
class Session extends _HeyApiClient {
|
|
866
|
-
list(options) {
|
|
867
|
-
return (options?.client ?? this._client).get({
|
|
868
|
-
url: "/session",
|
|
869
|
-
...options
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
create(options) {
|
|
873
|
-
return (options?.client ?? this._client).post({
|
|
874
|
-
url: "/session",
|
|
875
|
-
...options,
|
|
876
|
-
headers: {
|
|
877
|
-
"Content-Type": "application/json",
|
|
878
|
-
...options?.headers
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
delete(options) {
|
|
883
|
-
return (options.client ?? this._client).delete({
|
|
884
|
-
url: "/session/{id}",
|
|
885
|
-
...options
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
get(options) {
|
|
889
|
-
return (options.client ?? this._client).get({
|
|
890
|
-
url: "/session/{id}",
|
|
891
|
-
...options
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
update(options) {
|
|
895
|
-
return (options.client ?? this._client).patch({
|
|
896
|
-
url: "/session/{id}",
|
|
897
|
-
...options,
|
|
898
|
-
headers: {
|
|
899
|
-
"Content-Type": "application/json",
|
|
900
|
-
...options.headers
|
|
901
|
-
}
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
children(options) {
|
|
905
|
-
return (options.client ?? this._client).get({
|
|
906
|
-
url: "/session/{id}/children",
|
|
907
|
-
...options
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
todo(options) {
|
|
911
|
-
return (options.client ?? this._client).get({
|
|
912
|
-
url: "/session/{id}/todo",
|
|
913
|
-
...options
|
|
914
|
-
});
|
|
915
|
-
}
|
|
916
|
-
init(options) {
|
|
917
|
-
return (options.client ?? this._client).post({
|
|
918
|
-
url: "/session/{id}/init",
|
|
919
|
-
...options,
|
|
920
|
-
headers: {
|
|
921
|
-
"Content-Type": "application/json",
|
|
922
|
-
...options.headers
|
|
923
|
-
}
|
|
924
|
-
});
|
|
925
|
-
}
|
|
926
|
-
fork(options) {
|
|
927
|
-
return (options.client ?? this._client).post({
|
|
928
|
-
url: "/session/{id}/fork",
|
|
929
|
-
...options,
|
|
930
|
-
headers: {
|
|
931
|
-
"Content-Type": "application/json",
|
|
932
|
-
...options.headers
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
abort(options) {
|
|
937
|
-
return (options.client ?? this._client).post({
|
|
938
|
-
url: "/session/{id}/abort",
|
|
939
|
-
...options
|
|
940
|
-
});
|
|
941
|
-
}
|
|
942
|
-
togglePermission(options) {
|
|
943
|
-
return (options.client ?? this._client).patch({
|
|
944
|
-
url: "/session/{id}/permission",
|
|
945
|
-
...options,
|
|
946
|
-
headers: {
|
|
947
|
-
"Content-Type": "application/json",
|
|
948
|
-
...options.headers
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
unshare(options) {
|
|
953
|
-
return (options.client ?? this._client).delete({
|
|
954
|
-
url: "/session/{id}/share",
|
|
955
|
-
...options
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
share(options) {
|
|
959
|
-
return (options.client ?? this._client).post({
|
|
960
|
-
url: "/session/{id}/share",
|
|
961
|
-
...options
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
diff(options) {
|
|
965
|
-
return (options.client ?? this._client).get({
|
|
966
|
-
url: "/session/{id}/diff",
|
|
967
|
-
...options
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
summarize(options) {
|
|
971
|
-
return (options.client ?? this._client).post({
|
|
972
|
-
url: "/session/{id}/summarize",
|
|
973
|
-
...options,
|
|
974
|
-
headers: {
|
|
975
|
-
"Content-Type": "application/json",
|
|
976
|
-
...options.headers
|
|
977
|
-
}
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
messages(options) {
|
|
981
|
-
return (options.client ?? this._client).get({
|
|
982
|
-
url: "/session/{id}/message",
|
|
983
|
-
...options
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
prompt(options) {
|
|
987
|
-
return (options.client ?? this._client).post({
|
|
988
|
-
url: "/session/{id}/message",
|
|
989
|
-
...options,
|
|
990
|
-
headers: {
|
|
991
|
-
"Content-Type": "application/json",
|
|
992
|
-
...options.headers
|
|
993
|
-
}
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
message(options) {
|
|
997
|
-
return (options.client ?? this._client).get({
|
|
998
|
-
url: "/session/{id}/message/{messageID}",
|
|
999
|
-
...options
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
command(options) {
|
|
1003
|
-
return (options.client ?? this._client).post({
|
|
1004
|
-
url: "/session/{id}/command",
|
|
1005
|
-
...options,
|
|
1006
|
-
headers: {
|
|
1007
|
-
"Content-Type": "application/json",
|
|
1008
|
-
...options.headers
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
shell(options) {
|
|
1013
|
-
return (options.client ?? this._client).post({
|
|
1014
|
-
url: "/session/{id}/shell",
|
|
1015
|
-
...options,
|
|
1016
|
-
headers: {
|
|
1017
|
-
"Content-Type": "application/json",
|
|
1018
|
-
...options.headers
|
|
1019
|
-
}
|
|
1020
|
-
});
|
|
1021
|
-
}
|
|
1022
|
-
revert(options) {
|
|
1023
|
-
return (options.client ?? this._client).post({
|
|
1024
|
-
url: "/session/{id}/revert",
|
|
1025
|
-
...options,
|
|
1026
|
-
headers: {
|
|
1027
|
-
"Content-Type": "application/json",
|
|
1028
|
-
...options.headers
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
unrevert(options) {
|
|
1033
|
-
return (options.client ?? this._client).post({
|
|
1034
|
-
url: "/session/{id}/unrevert",
|
|
1035
|
-
...options
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
class Command extends _HeyApiClient {
|
|
1041
|
-
list(options) {
|
|
1042
|
-
return (options?.client ?? this._client).get({
|
|
1043
|
-
url: "/command",
|
|
1044
|
-
...options
|
|
1045
|
-
});
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
class Find extends _HeyApiClient {
|
|
1050
|
-
text(options) {
|
|
1051
|
-
return (options.client ?? this._client).get({
|
|
1052
|
-
url: "/find",
|
|
1053
|
-
...options
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
files(options) {
|
|
1057
|
-
return (options.client ?? this._client).get({
|
|
1058
|
-
url: "/find/file",
|
|
1059
|
-
...options
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
symbols(options) {
|
|
1063
|
-
return (options.client ?? this._client).get({
|
|
1064
|
-
url: "/find/symbol",
|
|
1065
|
-
...options
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
class File extends _HeyApiClient {
|
|
1071
|
-
list(options) {
|
|
1072
|
-
return (options.client ?? this._client).get({
|
|
1073
|
-
url: "/file",
|
|
1074
|
-
...options
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
read(options) {
|
|
1078
|
-
return (options.client ?? this._client).get({
|
|
1079
|
-
url: "/file/content",
|
|
1080
|
-
...options
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
status(options) {
|
|
1084
|
-
return (options?.client ?? this._client).get({
|
|
1085
|
-
url: "/file/status",
|
|
1086
|
-
...options
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
class App extends _HeyApiClient {
|
|
1092
|
-
log(options) {
|
|
1093
|
-
return (options?.client ?? this._client).post({
|
|
1094
|
-
url: "/log",
|
|
1095
|
-
...options,
|
|
1096
|
-
headers: {
|
|
1097
|
-
"Content-Type": "application/json",
|
|
1098
|
-
...options?.headers
|
|
1099
|
-
}
|
|
1100
|
-
});
|
|
1101
|
-
}
|
|
1102
|
-
agents(options) {
|
|
1103
|
-
return (options?.client ?? this._client).get({
|
|
1104
|
-
url: "/agent",
|
|
1105
|
-
...options
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
class Agent extends _HeyApiClient {
|
|
1111
|
-
updatePermission(options) {
|
|
1112
|
-
return (options.client ?? this._client).patch({
|
|
1113
|
-
url: "/agent/{name}/permission",
|
|
1114
|
-
...options,
|
|
1115
|
-
headers: {
|
|
1116
|
-
"Content-Type": "application/json",
|
|
1117
|
-
...options.headers
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
class Mcp extends _HeyApiClient {
|
|
1124
|
-
status(options) {
|
|
1125
|
-
return (options?.client ?? this._client).get({
|
|
1126
|
-
url: "/mcp",
|
|
1127
|
-
...options
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
refresh(options) {
|
|
1131
|
-
return (options?.client ?? this._client).post({
|
|
1132
|
-
url: "/mcp/refresh",
|
|
1133
|
-
...options
|
|
1134
|
-
});
|
|
1135
|
-
}
|
|
1136
|
-
enable(options) {
|
|
1137
|
-
return (options.client ?? this._client).post({
|
|
1138
|
-
url: "/mcp/{name}/enable",
|
|
1139
|
-
...options
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
disable(options) {
|
|
1143
|
-
return (options.client ?? this._client).post({
|
|
1144
|
-
url: "/mcp/{name}/disable",
|
|
1145
|
-
...options
|
|
1146
|
-
});
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
class Tui extends _HeyApiClient {
|
|
1151
|
-
appendPrompt(options) {
|
|
1152
|
-
return (options?.client ?? this._client).post({
|
|
1153
|
-
url: "/tui/append-prompt",
|
|
1154
|
-
...options,
|
|
1155
|
-
headers: {
|
|
1156
|
-
"Content-Type": "application/json",
|
|
1157
|
-
...options?.headers
|
|
1158
|
-
}
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
openHelp(options) {
|
|
1162
|
-
return (options?.client ?? this._client).post({
|
|
1163
|
-
url: "/tui/open-help",
|
|
1164
|
-
...options
|
|
1165
|
-
});
|
|
1166
|
-
}
|
|
1167
|
-
openSessions(options) {
|
|
1168
|
-
return (options?.client ?? this._client).post({
|
|
1169
|
-
url: "/tui/open-sessions",
|
|
1170
|
-
...options
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
openThemes(options) {
|
|
1174
|
-
return (options?.client ?? this._client).post({
|
|
1175
|
-
url: "/tui/open-themes",
|
|
1176
|
-
...options
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
openModels(options) {
|
|
1180
|
-
return (options?.client ?? this._client).post({
|
|
1181
|
-
url: "/tui/open-models",
|
|
1182
|
-
...options
|
|
1183
|
-
});
|
|
1184
|
-
}
|
|
1185
|
-
submitPrompt(options) {
|
|
1186
|
-
return (options?.client ?? this._client).post({
|
|
1187
|
-
url: "/tui/submit-prompt",
|
|
1188
|
-
...options
|
|
1189
|
-
});
|
|
1190
|
-
}
|
|
1191
|
-
clearPrompt(options) {
|
|
1192
|
-
return (options?.client ?? this._client).post({
|
|
1193
|
-
url: "/tui/clear-prompt",
|
|
1194
|
-
...options
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
executeCommand(options) {
|
|
1198
|
-
return (options?.client ?? this._client).post({
|
|
1199
|
-
url: "/tui/execute-command",
|
|
1200
|
-
...options,
|
|
1201
|
-
headers: {
|
|
1202
|
-
"Content-Type": "application/json",
|
|
1203
|
-
...options?.headers
|
|
1204
|
-
}
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
showToast(options) {
|
|
1208
|
-
return (options?.client ?? this._client).post({
|
|
1209
|
-
url: "/tui/show-toast",
|
|
1210
|
-
...options,
|
|
1211
|
-
headers: {
|
|
1212
|
-
"Content-Type": "application/json",
|
|
1213
|
-
...options?.headers
|
|
1214
|
-
}
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
class Auth extends _HeyApiClient {
|
|
1220
|
-
set(options) {
|
|
1221
|
-
return (options.client ?? this._client).put({
|
|
1222
|
-
url: "/auth/{id}",
|
|
1223
|
-
...options,
|
|
1224
|
-
headers: {
|
|
1225
|
-
"Content-Type": "application/json",
|
|
1226
|
-
...options.headers
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
|
-
class Event extends _HeyApiClient {
|
|
1233
|
-
subscribe(options) {
|
|
1234
|
-
return (options?.client ?? this._client).get.sse({
|
|
1235
|
-
url: "/event",
|
|
1236
|
-
...options
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
class OpencodeClient extends _HeyApiClient {
|
|
1242
|
-
postSessionIdPermissionsPermissionId(options) {
|
|
1243
|
-
return (options.client ?? this._client).post({
|
|
1244
|
-
url: "/session/{id}/permissions/{permissionID}",
|
|
1245
|
-
...options,
|
|
1246
|
-
headers: {
|
|
1247
|
-
"Content-Type": "application/json",
|
|
1248
|
-
...options.headers
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
project = new Project({ client: this._client });
|
|
1253
|
-
fds = new Fds({ client: this._client });
|
|
1254
|
-
config = new Config({ client: this._client });
|
|
1255
|
-
tool = new Tool({ client: this._client });
|
|
1256
|
-
path = new Path({ client: this._client });
|
|
1257
|
-
session = new Session({ client: this._client });
|
|
1258
|
-
command = new Command({ client: this._client });
|
|
1259
|
-
find = new Find({ client: this._client });
|
|
1260
|
-
file = new File({ client: this._client });
|
|
1261
|
-
app = new App({ client: this._client });
|
|
1262
|
-
agent = new Agent({ client: this._client });
|
|
1263
|
-
mcp = new Mcp({ client: this._client });
|
|
1264
|
-
tui = new Tui({ client: this._client });
|
|
1265
|
-
auth = new Auth({ client: this._client });
|
|
1266
|
-
event = new Event({ client: this._client });
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
// src/client.ts
|
|
1270
|
-
function createOpencodeClient(config) {
|
|
1271
|
-
const client2 = createClient(config);
|
|
1272
|
-
return new OpencodeClient({ client: client2 });
|
|
1273
|
-
}
|
|
1274
|
-
var createA3codeClient = createOpencodeClient;
|
|
1275
|
-
export {
|
|
1276
|
-
createOpencodeClient,
|
|
1277
|
-
createA3codeClient,
|
|
1278
|
-
OpencodeClient,
|
|
1279
|
-
OpencodeClient as A3codeClient
|
|
1280
|
-
};
|
|
1
|
+
export * from "./gen/types.gen.js";
|
|
2
|
+
export { OpencodeClient };
|
|
3
|
+
export { OpencodeClient as A3codeClient };
|
|
4
|
+
import { createClient } from "./gen/client/client.gen.js";
|
|
5
|
+
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
6
|
+
export function createOpencodeClient(config) {
|
|
7
|
+
const client = createClient(config);
|
|
8
|
+
return new OpencodeClient({ client });
|
|
9
|
+
}
|
|
10
|
+
// A3code alias
|
|
11
|
+
export const createA3codeClient = createOpencodeClient;
|