@deepailab/dal-remote-daemon 0.1.0 → 0.1.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/NOTICE +21 -1
- package/THIRD-PARTY-NOTICES.md +192 -0
- package/node_modules/@deepailab/dal-remote-server/NOTICE +21 -1
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/acp-agent.js +9 -5
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/claude/query.js +3 -2
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/claude/rewind.js +2 -2
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/cursor-acp-agent.js +13 -9
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/opencode/event-consumer.js +2 -2
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/opencode/v2/runtime.js +2 -1
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/opencode-agent.js +2 -2
- package/node_modules/@deepailab/dal-remote-server/dist/server/server/agent/providers/provider-sdk.js +46 -0
- package/node_modules/@deepailab/dal-remote-server/package.json +2 -5
- package/node_modules/@getpaseo/client/NOTICE +21 -1
- package/node_modules/@getpaseo/client/package.json +2 -1
- package/node_modules/@getpaseo/highlight/NOTICE +21 -1
- package/node_modules/@getpaseo/highlight/package.json +2 -1
- package/node_modules/@getpaseo/plugin/NOTICE +21 -1
- package/node_modules/@getpaseo/plugin/package.json +2 -1
- package/node_modules/@getpaseo/protocol/NOTICE +21 -1
- package/node_modules/@getpaseo/protocol/package.json +2 -1
- package/node_modules/@getpaseo/relay/NOTICE +21 -1
- package/node_modules/@getpaseo/relay/package.json +2 -1
- package/package.json +3 -8
- package/node_modules/@agentclientprotocol/sdk/LICENSE +0 -191
- package/node_modules/@agentclientprotocol/sdk/dist/acp.js +0 -1001
- package/node_modules/@agentclientprotocol/sdk/dist/schema/index.js +0 -32
- package/node_modules/@agentclientprotocol/sdk/dist/schema/zod.gen.js +0 -2054
- package/node_modules/@agentclientprotocol/sdk/dist/stream.js +0 -64
- package/node_modules/@agentclientprotocol/sdk/package.json +0 -33
- package/node_modules/@anthropic-ai/claude-agent-sdk/LICENSE.md +0 -1
- package/node_modules/@anthropic-ai/claude-agent-sdk/package.json +0 -74
- package/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs +0 -165
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/error-interceptor.js +0 -43
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/client.js +0 -78
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/client/client.gen.js +0 -232
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/client/index.js +0 -6
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/client/utils.gen.js +0 -226
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/client.gen.js +0 -3
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/auth.gen.js +0 -14
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/bodySerializer.gen.js +0 -57
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/params.gen.js +0 -102
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/pathSerializer.gen.js +0 -106
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/queryKeySerializer.gen.js +0 -93
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js +0 -139
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js +0 -87
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/sdk.gen.js +0 -3176
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/gen/types.gen.js +0 -2
- package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/package.json +0 -43
- package/node_modules/@opencode/client/dist/chunks/service-contender-1tbj6z39.js +0 -81
- package/node_modules/@opencode/client/dist/chunks/service-contender-4tveyqeh.js +0 -34
- package/node_modules/@opencode/client/dist/chunks/service-contender-7p1wryha.js +0 -30
- package/node_modules/@opencode/client/dist/chunks/service-contender-9rqn6x4v.js +0 -16
- package/node_modules/@opencode/client/dist/chunks/service-contender-frbwqjmf.js +0 -145
- package/node_modules/@opencode/client/dist/chunks/service-contender-m2eywc8w.js +0 -0
- package/node_modules/@opencode/client/dist/chunks/service-contender-n3c99vt5.js +0 -11
- package/node_modules/@opencode/client/dist/chunks/service-contender-radw39tv.js +0 -1402
- package/node_modules/@opencode/client/dist/chunks/service-contender-vyas3vgt.js +0 -0
- package/node_modules/@opencode/client/dist/promise/index.js +0 -79
- package/node_modules/@opencode/client/package.json +0 -54
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wrap whatever the generated client decoded from a non-2xx error body
|
|
3
|
-
* into a real `Error` so downstream formatters (TUI, plugins) get a
|
|
4
|
-
* useful `.message` instead of `[object Object]` or blank. The original
|
|
5
|
-
* parsed body and status live under `.cause` for callers that need
|
|
6
|
-
* structured fields.
|
|
7
|
-
*
|
|
8
|
-
* Only fires when the caller used `{ throwOnError: true }`. Callers that
|
|
9
|
-
* read `result.error` directly (the result-tuple path) get the parsed
|
|
10
|
-
* body unchanged so existing field-level reads (`.error.name`,
|
|
11
|
-
* `JSON.stringify(error)`, etc.) are byte-for-byte identical to before.
|
|
12
|
-
*/
|
|
13
|
-
export function wrapClientError(error, response, request, opts) {
|
|
14
|
-
if (!opts?.throwOnError)
|
|
15
|
-
return error;
|
|
16
|
-
if (error instanceof Error)
|
|
17
|
-
return error;
|
|
18
|
-
// NamedError-shaped responses (the common case for opencode 4xx) come
|
|
19
|
-
// through as POJOs — extract a useful message first, then wrap.
|
|
20
|
-
if (typeof error === "object" && error !== null && Object.keys(error).length > 0) {
|
|
21
|
-
const obj = error;
|
|
22
|
-
const message = (typeof obj.data?.message === "string" && obj.data.message) ||
|
|
23
|
-
(typeof obj.message === "string" && obj.message) ||
|
|
24
|
-
(typeof obj.name === "string" && obj.name) ||
|
|
25
|
-
describe(request, response);
|
|
26
|
-
return new Error(message, { cause: { body: error, status: response?.status } });
|
|
27
|
-
}
|
|
28
|
-
if (typeof error === "string" && error.length > 0) {
|
|
29
|
-
return new Error(error, { cause: { body: error, status: response?.status } });
|
|
30
|
-
}
|
|
31
|
-
// Empty body / network failure / undefined / null / empty object.
|
|
32
|
-
const reason = response ? "(empty response body)" : "network error (no response)";
|
|
33
|
-
return new Error(`opencode server ${describe(request, response)}: ${reason}`, {
|
|
34
|
-
cause: { body: error, status: response?.status },
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function describe(request, response) {
|
|
38
|
-
const method = request?.method ?? "?";
|
|
39
|
-
const url = request?.url ?? "?";
|
|
40
|
-
const status = response?.status;
|
|
41
|
-
const statusText = response?.statusText;
|
|
42
|
-
return `${method} ${url}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
|
|
43
|
-
}
|
package/node_modules/@deepailab/dal-remote-server/node_modules/@opencode-ai/sdk/dist/v2/client.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export * from "./gen/types.gen.js";
|
|
2
|
-
import { createClient } from "./gen/client/client.gen.js";
|
|
3
|
-
import { OpencodeClient } from "./gen/sdk.gen.js";
|
|
4
|
-
import { wrapClientError } from "../error-interceptor.js";
|
|
5
|
-
export { OpencodeClient };
|
|
6
|
-
function pick(value, fallback, encode) {
|
|
7
|
-
if (!value)
|
|
8
|
-
return;
|
|
9
|
-
if (!fallback)
|
|
10
|
-
return value;
|
|
11
|
-
if (value === fallback)
|
|
12
|
-
return fallback;
|
|
13
|
-
if (encode && value === encode(fallback))
|
|
14
|
-
return fallback;
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
function rewrite(request, values) {
|
|
18
|
-
if (request.method !== "GET" && request.method !== "HEAD")
|
|
19
|
-
return request;
|
|
20
|
-
const url = new URL(request.url);
|
|
21
|
-
let changed = false;
|
|
22
|
-
for (const [name, key] of [
|
|
23
|
-
["x-opencode-directory", "directory"],
|
|
24
|
-
["x-opencode-workspace", "workspace"],
|
|
25
|
-
]) {
|
|
26
|
-
const value = pick(request.headers.get(name), key === "directory" ? values.directory : values.workspace, key === "directory" ? encodeURIComponent : undefined);
|
|
27
|
-
if (!value)
|
|
28
|
-
continue;
|
|
29
|
-
if (!url.searchParams.has(key)) {
|
|
30
|
-
url.searchParams.set(key, value);
|
|
31
|
-
}
|
|
32
|
-
changed = true;
|
|
33
|
-
}
|
|
34
|
-
if (!changed)
|
|
35
|
-
return request;
|
|
36
|
-
const next = new Request(url, request);
|
|
37
|
-
next.headers.delete("x-opencode-directory");
|
|
38
|
-
next.headers.delete("x-opencode-workspace");
|
|
39
|
-
return next;
|
|
40
|
-
}
|
|
41
|
-
export function createOpencodeClient(config) {
|
|
42
|
-
if (!config?.fetch) {
|
|
43
|
-
const customFetch = (req) => {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
req.timeout = false;
|
|
46
|
-
return fetch(req);
|
|
47
|
-
};
|
|
48
|
-
config = {
|
|
49
|
-
...config,
|
|
50
|
-
fetch: customFetch,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (config?.directory) {
|
|
54
|
-
config.headers = {
|
|
55
|
-
...config.headers,
|
|
56
|
-
"x-opencode-directory": encodeURIComponent(config.directory),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (config?.experimental_workspaceID) {
|
|
60
|
-
config.headers = {
|
|
61
|
-
...config.headers,
|
|
62
|
-
"x-opencode-workspace": config.experimental_workspaceID,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const client = createClient(config);
|
|
66
|
-
client.interceptors.request.use((request) => rewrite(request, {
|
|
67
|
-
directory: config?.directory,
|
|
68
|
-
workspace: config?.experimental_workspaceID,
|
|
69
|
-
}));
|
|
70
|
-
client.interceptors.response.use((response) => {
|
|
71
|
-
const contentType = response.headers.get("content-type");
|
|
72
|
-
if (contentType === "text/html")
|
|
73
|
-
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
|
|
74
|
-
return response;
|
|
75
|
-
});
|
|
76
|
-
client.interceptors.error.use(wrapClientError);
|
|
77
|
-
return new OpencodeClient({ client });
|
|
78
|
-
}
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { createSseClient } from "../core/serverSentEvents.gen.js";
|
|
3
|
-
import { getValidRequestBody } from "../core/utils.gen.js";
|
|
4
|
-
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from "./utils.gen.js";
|
|
5
|
-
export const createClient = (config = {}) => {
|
|
6
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
7
|
-
const getConfig = () => ({ ..._config });
|
|
8
|
-
const setConfig = (config) => {
|
|
9
|
-
_config = mergeConfigs(_config, config);
|
|
10
|
-
return getConfig();
|
|
11
|
-
};
|
|
12
|
-
const interceptors = createInterceptors();
|
|
13
|
-
const beforeRequest = async (options) => {
|
|
14
|
-
const opts = {
|
|
15
|
-
..._config,
|
|
16
|
-
...options,
|
|
17
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
18
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
19
|
-
serializedBody: undefined,
|
|
20
|
-
};
|
|
21
|
-
if (opts.security) {
|
|
22
|
-
await setAuthParams({
|
|
23
|
-
...opts,
|
|
24
|
-
security: opts.security,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
if (opts.requestValidator) {
|
|
28
|
-
await opts.requestValidator(opts);
|
|
29
|
-
}
|
|
30
|
-
if (opts.body !== undefined && opts.bodySerializer) {
|
|
31
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
32
|
-
}
|
|
33
|
-
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
34
|
-
if (opts.body === undefined || opts.serializedBody === "") {
|
|
35
|
-
opts.headers.delete("Content-Type");
|
|
36
|
-
}
|
|
37
|
-
const url = buildUrl(opts);
|
|
38
|
-
return { opts, url };
|
|
39
|
-
};
|
|
40
|
-
const request = async (options) => {
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
const { opts, url } = await beforeRequest(options);
|
|
43
|
-
const requestInit = {
|
|
44
|
-
redirect: "follow",
|
|
45
|
-
...opts,
|
|
46
|
-
body: getValidRequestBody(opts),
|
|
47
|
-
};
|
|
48
|
-
let request = new Request(url, requestInit);
|
|
49
|
-
for (const fn of interceptors.request.fns) {
|
|
50
|
-
if (fn) {
|
|
51
|
-
request = await fn(request, opts);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
55
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
56
|
-
const _fetch = opts.fetch;
|
|
57
|
-
let response;
|
|
58
|
-
try {
|
|
59
|
-
response = await _fetch(request);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
// Handle fetch exceptions (AbortError, network errors, etc.)
|
|
63
|
-
let finalError = error;
|
|
64
|
-
for (const fn of interceptors.error.fns) {
|
|
65
|
-
if (fn) {
|
|
66
|
-
finalError = (await fn(error, undefined, request, opts));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
finalError = finalError || {};
|
|
70
|
-
if (opts.throwOnError) {
|
|
71
|
-
throw finalError;
|
|
72
|
-
}
|
|
73
|
-
// Return error response
|
|
74
|
-
return opts.responseStyle === "data"
|
|
75
|
-
? undefined
|
|
76
|
-
: {
|
|
77
|
-
error: finalError,
|
|
78
|
-
request,
|
|
79
|
-
response: undefined,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
for (const fn of interceptors.response.fns) {
|
|
83
|
-
if (fn) {
|
|
84
|
-
response = await fn(response, request, opts);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const result = {
|
|
88
|
-
request,
|
|
89
|
-
response,
|
|
90
|
-
};
|
|
91
|
-
if (response.ok) {
|
|
92
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
93
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
94
|
-
let emptyData;
|
|
95
|
-
switch (parseAs) {
|
|
96
|
-
case "arrayBuffer":
|
|
97
|
-
case "blob":
|
|
98
|
-
case "text":
|
|
99
|
-
emptyData = await response[parseAs]();
|
|
100
|
-
break;
|
|
101
|
-
case "formData":
|
|
102
|
-
emptyData = new FormData();
|
|
103
|
-
break;
|
|
104
|
-
case "stream":
|
|
105
|
-
emptyData = response.body;
|
|
106
|
-
break;
|
|
107
|
-
case "json":
|
|
108
|
-
default:
|
|
109
|
-
emptyData = {};
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
return opts.responseStyle === "data"
|
|
113
|
-
? emptyData
|
|
114
|
-
: {
|
|
115
|
-
data: emptyData,
|
|
116
|
-
...result,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
let data;
|
|
120
|
-
switch (parseAs) {
|
|
121
|
-
case "arrayBuffer":
|
|
122
|
-
case "blob":
|
|
123
|
-
case "formData":
|
|
124
|
-
case "text":
|
|
125
|
-
data = await response[parseAs]();
|
|
126
|
-
break;
|
|
127
|
-
case "json": {
|
|
128
|
-
// Some servers return 200 with no Content-Length and empty body.
|
|
129
|
-
// response.json() would throw; read as text and parse if non-empty.
|
|
130
|
-
const text = await response.text();
|
|
131
|
-
data = text ? JSON.parse(text) : {};
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
case "stream":
|
|
135
|
-
return opts.responseStyle === "data"
|
|
136
|
-
? response.body
|
|
137
|
-
: {
|
|
138
|
-
data: response.body,
|
|
139
|
-
...result,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
if (parseAs === "json") {
|
|
143
|
-
if (opts.responseValidator) {
|
|
144
|
-
await opts.responseValidator(data);
|
|
145
|
-
}
|
|
146
|
-
if (opts.responseTransformer) {
|
|
147
|
-
data = await opts.responseTransformer(data);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return opts.responseStyle === "data"
|
|
151
|
-
? data
|
|
152
|
-
: {
|
|
153
|
-
data,
|
|
154
|
-
...result,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const textError = await response.text();
|
|
158
|
-
let jsonError;
|
|
159
|
-
try {
|
|
160
|
-
jsonError = JSON.parse(textError);
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
// noop
|
|
164
|
-
}
|
|
165
|
-
const error = jsonError ?? textError;
|
|
166
|
-
let finalError = error;
|
|
167
|
-
for (const fn of interceptors.error.fns) {
|
|
168
|
-
if (fn) {
|
|
169
|
-
finalError = (await fn(error, response, request, opts));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
finalError = finalError || {};
|
|
173
|
-
if (opts.throwOnError) {
|
|
174
|
-
throw finalError;
|
|
175
|
-
}
|
|
176
|
-
// TODO: we probably want to return error and improve types
|
|
177
|
-
return opts.responseStyle === "data"
|
|
178
|
-
? undefined
|
|
179
|
-
: {
|
|
180
|
-
error: finalError,
|
|
181
|
-
...result,
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
185
|
-
const makeSseFn = (method) => async (options) => {
|
|
186
|
-
const { opts, url } = await beforeRequest(options);
|
|
187
|
-
return createSseClient({
|
|
188
|
-
...opts,
|
|
189
|
-
body: opts.body,
|
|
190
|
-
headers: opts.headers,
|
|
191
|
-
method,
|
|
192
|
-
onRequest: async (url, init) => {
|
|
193
|
-
let request = new Request(url, init);
|
|
194
|
-
for (const fn of interceptors.request.fns) {
|
|
195
|
-
if (fn) {
|
|
196
|
-
request = await fn(request, opts);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return request;
|
|
200
|
-
},
|
|
201
|
-
serializedBody: getValidRequestBody(opts),
|
|
202
|
-
url,
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
return {
|
|
206
|
-
buildUrl,
|
|
207
|
-
connect: makeMethodFn("CONNECT"),
|
|
208
|
-
delete: makeMethodFn("DELETE"),
|
|
209
|
-
get: makeMethodFn("GET"),
|
|
210
|
-
getConfig,
|
|
211
|
-
head: makeMethodFn("HEAD"),
|
|
212
|
-
interceptors,
|
|
213
|
-
options: makeMethodFn("OPTIONS"),
|
|
214
|
-
patch: makeMethodFn("PATCH"),
|
|
215
|
-
post: makeMethodFn("POST"),
|
|
216
|
-
put: makeMethodFn("PUT"),
|
|
217
|
-
request,
|
|
218
|
-
setConfig,
|
|
219
|
-
sse: {
|
|
220
|
-
connect: makeSseFn("CONNECT"),
|
|
221
|
-
delete: makeSseFn("DELETE"),
|
|
222
|
-
get: makeSseFn("GET"),
|
|
223
|
-
head: makeSseFn("HEAD"),
|
|
224
|
-
options: makeSseFn("OPTIONS"),
|
|
225
|
-
patch: makeSseFn("PATCH"),
|
|
226
|
-
post: makeSseFn("POST"),
|
|
227
|
-
put: makeSseFn("PUT"),
|
|
228
|
-
trace: makeSseFn("TRACE"),
|
|
229
|
-
},
|
|
230
|
-
trace: makeMethodFn("TRACE"),
|
|
231
|
-
};
|
|
232
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen.js";
|
|
3
|
-
export { buildClientParams } from "../core/params.gen.js";
|
|
4
|
-
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js";
|
|
5
|
-
export { createClient } from "./client.gen.js";
|
|
6
|
-
export { createConfig, mergeHeaders } from "./utils.gen.js";
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { getAuthToken } from "../core/auth.gen.js";
|
|
3
|
-
import { jsonBodySerializer } from "../core/bodySerializer.gen.js";
|
|
4
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam } from "../core/pathSerializer.gen.js";
|
|
5
|
-
import { getUrl } from "../core/utils.gen.js";
|
|
6
|
-
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
7
|
-
const querySerializer = (queryParams) => {
|
|
8
|
-
const search = [];
|
|
9
|
-
if (queryParams && typeof queryParams === "object") {
|
|
10
|
-
for (const name in queryParams) {
|
|
11
|
-
const value = queryParams[name];
|
|
12
|
-
if (value === undefined || value === null) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const options = parameters[name] || args;
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
const serializedArray = serializeArrayParam({
|
|
18
|
-
allowReserved: options.allowReserved,
|
|
19
|
-
explode: true,
|
|
20
|
-
name,
|
|
21
|
-
style: "form",
|
|
22
|
-
value,
|
|
23
|
-
...options.array,
|
|
24
|
-
});
|
|
25
|
-
if (serializedArray)
|
|
26
|
-
search.push(serializedArray);
|
|
27
|
-
}
|
|
28
|
-
else if (typeof value === "object") {
|
|
29
|
-
const serializedObject = serializeObjectParam({
|
|
30
|
-
allowReserved: options.allowReserved,
|
|
31
|
-
explode: true,
|
|
32
|
-
name,
|
|
33
|
-
style: "deepObject",
|
|
34
|
-
value: value,
|
|
35
|
-
...options.object,
|
|
36
|
-
});
|
|
37
|
-
if (serializedObject)
|
|
38
|
-
search.push(serializedObject);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
42
|
-
allowReserved: options.allowReserved,
|
|
43
|
-
name,
|
|
44
|
-
value: value,
|
|
45
|
-
});
|
|
46
|
-
if (serializedPrimitive)
|
|
47
|
-
search.push(serializedPrimitive);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return search.join("&");
|
|
52
|
-
};
|
|
53
|
-
return querySerializer;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Infers parseAs value from provided Content-Type header.
|
|
57
|
-
*/
|
|
58
|
-
export const getParseAs = (contentType) => {
|
|
59
|
-
if (!contentType) {
|
|
60
|
-
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
61
|
-
// which is effectively the same as the 'stream' option.
|
|
62
|
-
return "stream";
|
|
63
|
-
}
|
|
64
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
65
|
-
if (!cleanContent) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
69
|
-
return "json";
|
|
70
|
-
}
|
|
71
|
-
if (cleanContent === "multipart/form-data") {
|
|
72
|
-
return "formData";
|
|
73
|
-
}
|
|
74
|
-
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
75
|
-
return "blob";
|
|
76
|
-
}
|
|
77
|
-
if (cleanContent.startsWith("text/")) {
|
|
78
|
-
return "text";
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
};
|
|
82
|
-
const checkForExistence = (options, name) => {
|
|
83
|
-
if (!name) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
return false;
|
|
90
|
-
};
|
|
91
|
-
export const setAuthParams = async ({ security, ...options }) => {
|
|
92
|
-
for (const auth of security) {
|
|
93
|
-
if (checkForExistence(options, auth.name)) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
const token = await getAuthToken(auth, options.auth);
|
|
97
|
-
if (!token) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const name = auth.name ?? "Authorization";
|
|
101
|
-
switch (auth.in) {
|
|
102
|
-
case "query":
|
|
103
|
-
if (!options.query) {
|
|
104
|
-
options.query = {};
|
|
105
|
-
}
|
|
106
|
-
options.query[name] = token;
|
|
107
|
-
break;
|
|
108
|
-
case "cookie":
|
|
109
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
110
|
-
break;
|
|
111
|
-
case "header":
|
|
112
|
-
default:
|
|
113
|
-
options.headers.set(name, token);
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
export const buildUrl = (options) => getUrl({
|
|
119
|
-
baseUrl: options.baseUrl,
|
|
120
|
-
path: options.path,
|
|
121
|
-
query: options.query,
|
|
122
|
-
querySerializer: typeof options.querySerializer === "function"
|
|
123
|
-
? options.querySerializer
|
|
124
|
-
: createQuerySerializer(options.querySerializer),
|
|
125
|
-
url: options.url,
|
|
126
|
-
});
|
|
127
|
-
export const mergeConfigs = (a, b) => {
|
|
128
|
-
const config = { ...a, ...b };
|
|
129
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
130
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
131
|
-
}
|
|
132
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
133
|
-
return config;
|
|
134
|
-
};
|
|
135
|
-
const headersEntries = (headers) => {
|
|
136
|
-
const entries = [];
|
|
137
|
-
headers.forEach((value, key) => {
|
|
138
|
-
entries.push([key, value]);
|
|
139
|
-
});
|
|
140
|
-
return entries;
|
|
141
|
-
};
|
|
142
|
-
export const mergeHeaders = (...headers) => {
|
|
143
|
-
const mergedHeaders = new Headers();
|
|
144
|
-
for (const header of headers) {
|
|
145
|
-
if (!header) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
149
|
-
for (const [key, value] of iterator) {
|
|
150
|
-
if (value === null) {
|
|
151
|
-
mergedHeaders.delete(key);
|
|
152
|
-
}
|
|
153
|
-
else if (Array.isArray(value)) {
|
|
154
|
-
for (const v of value) {
|
|
155
|
-
mergedHeaders.append(key, v);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
else if (value !== undefined) {
|
|
159
|
-
// assume object headers are meant to be JSON stringified, i.e. their
|
|
160
|
-
// content value in OpenAPI specification is 'application/json'
|
|
161
|
-
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return mergedHeaders;
|
|
166
|
-
};
|
|
167
|
-
class Interceptors {
|
|
168
|
-
fns = [];
|
|
169
|
-
clear() {
|
|
170
|
-
this.fns = [];
|
|
171
|
-
}
|
|
172
|
-
eject(id) {
|
|
173
|
-
const index = this.getInterceptorIndex(id);
|
|
174
|
-
if (this.fns[index]) {
|
|
175
|
-
this.fns[index] = null;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
exists(id) {
|
|
179
|
-
const index = this.getInterceptorIndex(id);
|
|
180
|
-
return Boolean(this.fns[index]);
|
|
181
|
-
}
|
|
182
|
-
getInterceptorIndex(id) {
|
|
183
|
-
if (typeof id === "number") {
|
|
184
|
-
return this.fns[id] ? id : -1;
|
|
185
|
-
}
|
|
186
|
-
return this.fns.indexOf(id);
|
|
187
|
-
}
|
|
188
|
-
update(id, fn) {
|
|
189
|
-
const index = this.getInterceptorIndex(id);
|
|
190
|
-
if (this.fns[index]) {
|
|
191
|
-
this.fns[index] = fn;
|
|
192
|
-
return id;
|
|
193
|
-
}
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
use(fn) {
|
|
197
|
-
this.fns.push(fn);
|
|
198
|
-
return this.fns.length - 1;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
export const createInterceptors = () => ({
|
|
202
|
-
error: new Interceptors(),
|
|
203
|
-
request: new Interceptors(),
|
|
204
|
-
response: new Interceptors(),
|
|
205
|
-
});
|
|
206
|
-
const defaultQuerySerializer = createQuerySerializer({
|
|
207
|
-
allowReserved: false,
|
|
208
|
-
array: {
|
|
209
|
-
explode: true,
|
|
210
|
-
style: "form",
|
|
211
|
-
},
|
|
212
|
-
object: {
|
|
213
|
-
explode: true,
|
|
214
|
-
style: "deepObject",
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
const defaultHeaders = {
|
|
218
|
-
"Content-Type": "application/json",
|
|
219
|
-
};
|
|
220
|
-
export const createConfig = (override = {}) => ({
|
|
221
|
-
...jsonBodySerializer,
|
|
222
|
-
headers: defaultHeaders,
|
|
223
|
-
parseAs: "auto",
|
|
224
|
-
querySerializer: defaultQuerySerializer,
|
|
225
|
-
...override,
|
|
226
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export const getAuthToken = async (auth, callback) => {
|
|
3
|
-
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
4
|
-
if (!token) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
if (auth.scheme === "bearer") {
|
|
8
|
-
return `Bearer ${token}`;
|
|
9
|
-
}
|
|
10
|
-
if (auth.scheme === "basic") {
|
|
11
|
-
return `Basic ${btoa(token)}`;
|
|
12
|
-
}
|
|
13
|
-
return token;
|
|
14
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
-
if (typeof value === "string" || value instanceof Blob) {
|
|
4
|
-
data.append(key, value);
|
|
5
|
-
}
|
|
6
|
-
else if (value instanceof Date) {
|
|
7
|
-
data.append(key, value.toISOString());
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
data.append(key, JSON.stringify(value));
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
-
if (typeof value === "string") {
|
|
15
|
-
data.append(key, value);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
data.append(key, JSON.stringify(value));
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export const formDataBodySerializer = {
|
|
22
|
-
bodySerializer: (body) => {
|
|
23
|
-
const data = new FormData();
|
|
24
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
25
|
-
if (value === undefined || value === null) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(value)) {
|
|
29
|
-
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
serializeFormDataPair(data, key, value);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return data;
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
export const jsonBodySerializer = {
|
|
39
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => (typeof value === "bigint" ? value.toString() : value)),
|
|
40
|
-
};
|
|
41
|
-
export const urlSearchParamsBodySerializer = {
|
|
42
|
-
bodySerializer: (body) => {
|
|
43
|
-
const data = new URLSearchParams();
|
|
44
|
-
Object.entries(body).forEach(([key, value]) => {
|
|
45
|
-
if (value === undefined || value === null) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
serializeUrlSearchParamsPair(data, key, value);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
return data.toString();
|
|
56
|
-
},
|
|
57
|
-
};
|