@pixelml/sdk 0.0.0-dev-202512250746 → 0.0.0-dev-202512260319
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/package.json +2 -5
- package/dist/client.d.ts +0 -7
- package/dist/client.js +0 -25
- package/dist/gen/client/client.gen.d.ts +0 -2
- package/dist/gen/client/client.gen.js +0 -165
- package/dist/gen/client/index.d.ts +0 -7
- package/dist/gen/client/index.js +0 -5
- package/dist/gen/client/types.gen.d.ts +0 -127
- package/dist/gen/client/types.gen.js +0 -2
- package/dist/gen/client/utils.gen.d.ts +0 -38
- package/dist/gen/client/utils.gen.js +0 -226
- package/dist/gen/client.gen.d.ts +0 -12
- package/dist/gen/client.gen.js +0 -5
- package/dist/gen/core/auth.gen.d.ts +0 -18
- package/dist/gen/core/auth.gen.js +0 -14
- package/dist/gen/core/bodySerializer.gen.d.ts +0 -17
- package/dist/gen/core/bodySerializer.gen.js +0 -57
- package/dist/gen/core/params.gen.d.ts +0 -33
- package/dist/gen/core/params.gen.js +0 -89
- package/dist/gen/core/pathSerializer.gen.d.ts +0 -33
- package/dist/gen/core/pathSerializer.gen.js +0 -106
- package/dist/gen/core/serverSentEvents.gen.d.ts +0 -59
- package/dist/gen/core/serverSentEvents.gen.js +0 -117
- package/dist/gen/core/types.gen.d.ts +0 -78
- package/dist/gen/core/types.gen.js +0 -2
- package/dist/gen/core/utils.gen.d.ts +0 -14
- package/dist/gen/core/utils.gen.js +0 -69
- package/dist/gen/sdk.gen.d.ts +0 -403
- package/dist/gen/sdk.gen.js +0 -881
- package/dist/gen/types.gen.d.ts +0 -3368
- package/dist/gen/types.gen.js +0 -2
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -16
- package/dist/server.d.ts +0 -23
- package/dist/server.js +0 -91
- package/dist/v2/client.d.ts +0 -7
- package/dist/v2/client.js +0 -25
- package/dist/v2/gen/client/client.gen.d.ts +0 -2
- package/dist/v2/gen/client/client.gen.js +0 -225
- package/dist/v2/gen/client/index.d.ts +0 -8
- package/dist/v2/gen/client/index.js +0 -6
- package/dist/v2/gen/client/types.gen.d.ts +0 -117
- package/dist/v2/gen/client/types.gen.js +0 -2
- package/dist/v2/gen/client/utils.gen.d.ts +0 -33
- package/dist/v2/gen/client/utils.gen.js +0 -226
- package/dist/v2/gen/client.gen.d.ts +0 -12
- package/dist/v2/gen/client.gen.js +0 -3
- package/dist/v2/gen/core/auth.gen.d.ts +0 -18
- package/dist/v2/gen/core/auth.gen.js +0 -14
- package/dist/v2/gen/core/bodySerializer.gen.d.ts +0 -25
- package/dist/v2/gen/core/bodySerializer.gen.js +0 -57
- package/dist/v2/gen/core/params.gen.d.ts +0 -43
- package/dist/v2/gen/core/params.gen.js +0 -102
- package/dist/v2/gen/core/pathSerializer.gen.d.ts +0 -33
- package/dist/v2/gen/core/pathSerializer.gen.js +0 -106
- package/dist/v2/gen/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/v2/gen/core/queryKeySerializer.gen.js +0 -93
- package/dist/v2/gen/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/v2/gen/core/serverSentEvents.gen.js +0 -131
- package/dist/v2/gen/core/types.gen.d.ts +0 -78
- package/dist/v2/gen/core/types.gen.js +0 -2
- package/dist/v2/gen/core/utils.gen.d.ts +0 -19
- package/dist/v2/gen/core/utils.gen.js +0 -87
- package/dist/v2/gen/sdk.gen.d.ts +0 -902
- package/dist/v2/gen/sdk.gen.js +0 -1726
- package/dist/v2/gen/types.gen.d.ts +0 -3719
- package/dist/v2/gen/types.gen.js +0 -2
- package/dist/v2/index.d.ts +0 -10
- package/dist/v2/index.js +0 -16
- package/dist/v2/server.d.ts +0 -23
- package/dist/v2/server.js +0 -91
package/dist/gen/types.gen.js
DELETED
package/dist/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./client.js";
|
|
2
|
-
export * from "./server.js";
|
|
3
|
-
import type { ServerOptions } from "./server.js";
|
|
4
|
-
export declare function createClaw(options?: ServerOptions): Promise<{
|
|
5
|
-
client: import("./client.js").ClawClient;
|
|
6
|
-
server: {
|
|
7
|
-
url: string;
|
|
8
|
-
close(): void;
|
|
9
|
-
};
|
|
10
|
-
}>;
|
package/dist/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export * from "./client.js";
|
|
2
|
-
export * from "./server.js";
|
|
3
|
-
import { createClawClient } from "./client.js";
|
|
4
|
-
import { createClawServer } from "./server.js";
|
|
5
|
-
export async function createClaw(options) {
|
|
6
|
-
const server = await createClawServer({
|
|
7
|
-
...options,
|
|
8
|
-
});
|
|
9
|
-
const client = createClawClient({
|
|
10
|
-
baseUrl: server.url,
|
|
11
|
-
});
|
|
12
|
-
return {
|
|
13
|
-
client,
|
|
14
|
-
server,
|
|
15
|
-
};
|
|
16
|
-
}
|
package/dist/server.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Config } from "./gen/types.gen.js";
|
|
2
|
-
export type ServerOptions = {
|
|
3
|
-
hostname?: string;
|
|
4
|
-
port?: number;
|
|
5
|
-
signal?: AbortSignal;
|
|
6
|
-
timeout?: number;
|
|
7
|
-
config?: Config;
|
|
8
|
-
};
|
|
9
|
-
export type TuiOptions = {
|
|
10
|
-
project?: string;
|
|
11
|
-
model?: string;
|
|
12
|
-
session?: string;
|
|
13
|
-
agent?: string;
|
|
14
|
-
signal?: AbortSignal;
|
|
15
|
-
config?: Config;
|
|
16
|
-
};
|
|
17
|
-
export declare function createClawServer(options?: ServerOptions): Promise<{
|
|
18
|
-
url: string;
|
|
19
|
-
close(): void;
|
|
20
|
-
}>;
|
|
21
|
-
export declare function createClawTui(options?: TuiOptions): {
|
|
22
|
-
close(): void;
|
|
23
|
-
};
|
package/dist/server.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
export async function createClawServer(options) {
|
|
3
|
-
options = Object.assign({
|
|
4
|
-
hostname: "127.0.0.1",
|
|
5
|
-
port: 4096,
|
|
6
|
-
timeout: 5000,
|
|
7
|
-
}, options ?? {});
|
|
8
|
-
const proc = spawn(`claw`, [`serve`, `--hostname=${options.hostname}`, `--port=${options.port}`], {
|
|
9
|
-
signal: options.signal,
|
|
10
|
-
env: {
|
|
11
|
-
...process.env,
|
|
12
|
-
CLAW_CONFIG_CONTENT: JSON.stringify(options.config ?? {}),
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const url = await new Promise((resolve, reject) => {
|
|
16
|
-
const id = setTimeout(() => {
|
|
17
|
-
reject(new Error(`Timeout waiting for server to start after ${options.timeout}ms`));
|
|
18
|
-
}, options.timeout);
|
|
19
|
-
let output = "";
|
|
20
|
-
proc.stdout?.on("data", (chunk) => {
|
|
21
|
-
output += chunk.toString();
|
|
22
|
-
const lines = output.split("\n");
|
|
23
|
-
for (const line of lines) {
|
|
24
|
-
if (line.startsWith("claw server listening")) {
|
|
25
|
-
const match = line.match(/on\s+(https?:\/\/[^\s]+)/);
|
|
26
|
-
if (!match) {
|
|
27
|
-
throw new Error(`Failed to parse server url from output: ${line}`);
|
|
28
|
-
}
|
|
29
|
-
clearTimeout(id);
|
|
30
|
-
resolve(match[1]);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
proc.stderr?.on("data", (chunk) => {
|
|
36
|
-
output += chunk.toString();
|
|
37
|
-
});
|
|
38
|
-
proc.on("exit", (code) => {
|
|
39
|
-
clearTimeout(id);
|
|
40
|
-
let msg = `Server exited with code ${code}`;
|
|
41
|
-
if (output.trim()) {
|
|
42
|
-
msg += `\nServer output: ${output}`;
|
|
43
|
-
}
|
|
44
|
-
reject(new Error(msg));
|
|
45
|
-
});
|
|
46
|
-
proc.on("error", (error) => {
|
|
47
|
-
clearTimeout(id);
|
|
48
|
-
reject(error);
|
|
49
|
-
});
|
|
50
|
-
if (options.signal) {
|
|
51
|
-
options.signal.addEventListener("abort", () => {
|
|
52
|
-
clearTimeout(id);
|
|
53
|
-
reject(new Error("Aborted"));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
return {
|
|
58
|
-
url,
|
|
59
|
-
close() {
|
|
60
|
-
proc.kill();
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
export function createClawTui(options) {
|
|
65
|
-
const args = [];
|
|
66
|
-
if (options?.project) {
|
|
67
|
-
args.push(`--project=${options.project}`);
|
|
68
|
-
}
|
|
69
|
-
if (options?.model) {
|
|
70
|
-
args.push(`--model=${options.model}`);
|
|
71
|
-
}
|
|
72
|
-
if (options?.session) {
|
|
73
|
-
args.push(`--session=${options.session}`);
|
|
74
|
-
}
|
|
75
|
-
if (options?.agent) {
|
|
76
|
-
args.push(`--agent=${options.agent}`);
|
|
77
|
-
}
|
|
78
|
-
const proc = spawn(`claw`, args, {
|
|
79
|
-
signal: options?.signal,
|
|
80
|
-
stdio: "inherit",
|
|
81
|
-
env: {
|
|
82
|
-
...process.env,
|
|
83
|
-
CLAW_CONFIG_CONTENT: JSON.stringify(options?.config ?? {}),
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
return {
|
|
87
|
-
close() {
|
|
88
|
-
proc.kill();
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
}
|
package/dist/v2/client.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "./gen/types.gen.js";
|
|
2
|
-
import { type Config } from "./gen/client/types.gen.js";
|
|
3
|
-
import { ClawClient } from "./gen/sdk.gen.js";
|
|
4
|
-
export { type Config as ClawClientConfig, ClawClient };
|
|
5
|
-
export declare function createClawClient(config?: Config & {
|
|
6
|
-
directory?: string;
|
|
7
|
-
}): ClawClient;
|
package/dist/v2/client.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export * from "./gen/types.gen.js";
|
|
2
|
-
import { createClient } from "./gen/client/client.gen.js";
|
|
3
|
-
import { ClawClient } from "./gen/sdk.gen.js";
|
|
4
|
-
export { ClawClient };
|
|
5
|
-
export function createClawClient(config) {
|
|
6
|
-
if (!config?.fetch) {
|
|
7
|
-
const customFetch = (req) => {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
req.timeout = false;
|
|
10
|
-
return fetch(req);
|
|
11
|
-
};
|
|
12
|
-
config = {
|
|
13
|
-
...config,
|
|
14
|
-
fetch: customFetch,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (config?.directory) {
|
|
18
|
-
config.headers = {
|
|
19
|
-
...config.headers,
|
|
20
|
-
"x-claw-directory": config.directory,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const client = createClient(config);
|
|
24
|
-
return new ClawClient({ client });
|
|
25
|
-
}
|
|
@@ -1,225 +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 "json":
|
|
125
|
-
case "text":
|
|
126
|
-
data = await response[parseAs]();
|
|
127
|
-
break;
|
|
128
|
-
case "stream":
|
|
129
|
-
return opts.responseStyle === "data"
|
|
130
|
-
? response.body
|
|
131
|
-
: {
|
|
132
|
-
data: response.body,
|
|
133
|
-
...result,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
if (parseAs === "json") {
|
|
137
|
-
if (opts.responseValidator) {
|
|
138
|
-
await opts.responseValidator(data);
|
|
139
|
-
}
|
|
140
|
-
if (opts.responseTransformer) {
|
|
141
|
-
data = await opts.responseTransformer(data);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return opts.responseStyle === "data"
|
|
145
|
-
? data
|
|
146
|
-
: {
|
|
147
|
-
data,
|
|
148
|
-
...result,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
const textError = await response.text();
|
|
152
|
-
let jsonError;
|
|
153
|
-
try {
|
|
154
|
-
jsonError = JSON.parse(textError);
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
// noop
|
|
158
|
-
}
|
|
159
|
-
const error = jsonError ?? textError;
|
|
160
|
-
let finalError = error;
|
|
161
|
-
for (const fn of interceptors.error.fns) {
|
|
162
|
-
if (fn) {
|
|
163
|
-
finalError = (await fn(error, response, request, opts));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
finalError = finalError || {};
|
|
167
|
-
if (opts.throwOnError) {
|
|
168
|
-
throw finalError;
|
|
169
|
-
}
|
|
170
|
-
// TODO: we probably want to return error and improve types
|
|
171
|
-
return opts.responseStyle === "data"
|
|
172
|
-
? undefined
|
|
173
|
-
: {
|
|
174
|
-
error: finalError,
|
|
175
|
-
...result,
|
|
176
|
-
};
|
|
177
|
-
};
|
|
178
|
-
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
179
|
-
const makeSseFn = (method) => async (options) => {
|
|
180
|
-
const { opts, url } = await beforeRequest(options);
|
|
181
|
-
return createSseClient({
|
|
182
|
-
...opts,
|
|
183
|
-
body: opts.body,
|
|
184
|
-
headers: opts.headers,
|
|
185
|
-
method,
|
|
186
|
-
onRequest: async (url, init) => {
|
|
187
|
-
let request = new Request(url, init);
|
|
188
|
-
for (const fn of interceptors.request.fns) {
|
|
189
|
-
if (fn) {
|
|
190
|
-
request = await fn(request, opts);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return request;
|
|
194
|
-
},
|
|
195
|
-
url,
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
return {
|
|
199
|
-
buildUrl,
|
|
200
|
-
connect: makeMethodFn("CONNECT"),
|
|
201
|
-
delete: makeMethodFn("DELETE"),
|
|
202
|
-
get: makeMethodFn("GET"),
|
|
203
|
-
getConfig,
|
|
204
|
-
head: makeMethodFn("HEAD"),
|
|
205
|
-
interceptors,
|
|
206
|
-
options: makeMethodFn("OPTIONS"),
|
|
207
|
-
patch: makeMethodFn("PATCH"),
|
|
208
|
-
post: makeMethodFn("POST"),
|
|
209
|
-
put: makeMethodFn("PUT"),
|
|
210
|
-
request,
|
|
211
|
-
setConfig,
|
|
212
|
-
sse: {
|
|
213
|
-
connect: makeSseFn("CONNECT"),
|
|
214
|
-
delete: makeSseFn("DELETE"),
|
|
215
|
-
get: makeSseFn("GET"),
|
|
216
|
-
head: makeSseFn("HEAD"),
|
|
217
|
-
options: makeSseFn("OPTIONS"),
|
|
218
|
-
patch: makeSseFn("PATCH"),
|
|
219
|
-
post: makeSseFn("POST"),
|
|
220
|
-
put: makeSseFn("PUT"),
|
|
221
|
-
trace: makeSseFn("TRACE"),
|
|
222
|
-
},
|
|
223
|
-
trace: makeMethodFn("TRACE"),
|
|
224
|
-
};
|
|
225
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type { Auth } from "../core/auth.gen.js";
|
|
2
|
-
export type { QuerySerializerOptions } from "../core/bodySerializer.gen.js";
|
|
3
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen.js";
|
|
4
|
-
export { buildClientParams } from "../core/params.gen.js";
|
|
5
|
-
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen.js";
|
|
6
|
-
export { createClient } from "./client.gen.js";
|
|
7
|
-
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from "./types.gen.js";
|
|
8
|
-
export { createConfig, mergeHeaders } from "./utils.gen.js";
|
|
@@ -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,117 +0,0 @@
|
|
|
1
|
-
import type { Auth } from "../core/auth.gen.js";
|
|
2
|
-
import type { ServerSentEventsOptions, ServerSentEventsResult } from "../core/serverSentEvents.gen.js";
|
|
3
|
-
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.gen.js";
|
|
4
|
-
import type { Middleware } from "./utils.gen.js";
|
|
5
|
-
export type ResponseStyle = "data" | "fields";
|
|
6
|
-
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, "body" | "headers" | "method">, CoreConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Base URL for all requests made by this client.
|
|
9
|
-
*/
|
|
10
|
-
baseUrl?: T["baseUrl"];
|
|
11
|
-
/**
|
|
12
|
-
* Fetch API implementation. You can use this option to provide a custom
|
|
13
|
-
* fetch instance.
|
|
14
|
-
*
|
|
15
|
-
* @default globalThis.fetch
|
|
16
|
-
*/
|
|
17
|
-
fetch?: typeof fetch;
|
|
18
|
-
/**
|
|
19
|
-
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
20
|
-
* options won't have any effect.
|
|
21
|
-
*
|
|
22
|
-
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
23
|
-
*/
|
|
24
|
-
next?: never;
|
|
25
|
-
/**
|
|
26
|
-
* Return the response data parsed in a specified format. By default, `auto`
|
|
27
|
-
* will infer the appropriate method from the `Content-Type` response header.
|
|
28
|
-
* You can override this behavior with any of the {@link Body} methods.
|
|
29
|
-
* Select `stream` if you don't want to parse response data at all.
|
|
30
|
-
*
|
|
31
|
-
* @default 'auto'
|
|
32
|
-
*/
|
|
33
|
-
parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text";
|
|
34
|
-
/**
|
|
35
|
-
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
36
|
-
*
|
|
37
|
-
* @default 'fields'
|
|
38
|
-
*/
|
|
39
|
-
responseStyle?: ResponseStyle;
|
|
40
|
-
/**
|
|
41
|
-
* Throw an error instead of returning it in the response?
|
|
42
|
-
*
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
throwOnError?: T["throwOnError"];
|
|
46
|
-
}
|
|
47
|
-
export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
48
|
-
responseStyle: TResponseStyle;
|
|
49
|
-
throwOnError: ThrowOnError;
|
|
50
|
-
}>, Pick<ServerSentEventsOptions<TData>, "onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"> {
|
|
51
|
-
/**
|
|
52
|
-
* Any body that you want to add to your request.
|
|
53
|
-
*
|
|
54
|
-
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
55
|
-
*/
|
|
56
|
-
body?: unknown;
|
|
57
|
-
path?: Record<string, unknown>;
|
|
58
|
-
query?: Record<string, unknown>;
|
|
59
|
-
/**
|
|
60
|
-
* Security mechanism(s) to use for the request.
|
|
61
|
-
*/
|
|
62
|
-
security?: ReadonlyArray<Auth>;
|
|
63
|
-
url: Url;
|
|
64
|
-
}
|
|
65
|
-
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
66
|
-
serializedBody?: string;
|
|
67
|
-
}
|
|
68
|
-
export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = "fields"> = ThrowOnError extends true ? Promise<TResponseStyle extends "data" ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
69
|
-
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
70
|
-
request: Request;
|
|
71
|
-
response: Response;
|
|
72
|
-
}> : Promise<TResponseStyle extends "data" ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
73
|
-
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
74
|
-
error: undefined;
|
|
75
|
-
} | {
|
|
76
|
-
data: undefined;
|
|
77
|
-
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
78
|
-
}) & {
|
|
79
|
-
request: Request;
|
|
80
|
-
response: Response;
|
|
81
|
-
}>;
|
|
82
|
-
export interface ClientOptions {
|
|
83
|
-
baseUrl?: string;
|
|
84
|
-
responseStyle?: ResponseStyle;
|
|
85
|
-
throwOnError?: boolean;
|
|
86
|
-
}
|
|
87
|
-
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
88
|
-
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method">) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
89
|
-
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = "fields">(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, "method"> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, "method">) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
90
|
-
type BuildUrlFn = <TData extends {
|
|
91
|
-
body?: unknown;
|
|
92
|
-
path?: Record<string, unknown>;
|
|
93
|
-
query?: Record<string, unknown>;
|
|
94
|
-
url: string;
|
|
95
|
-
}>(options: TData & Options<TData>) => string;
|
|
96
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
97
|
-
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
101
|
-
* and the returned object will become the client's initial configuration.
|
|
102
|
-
*
|
|
103
|
-
* You may want to initialize your client this way instead of calling
|
|
104
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
105
|
-
* to ensure your client always has the correct values.
|
|
106
|
-
*/
|
|
107
|
-
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
108
|
-
export interface TDataShape {
|
|
109
|
-
body?: unknown;
|
|
110
|
-
headers?: unknown;
|
|
111
|
-
path?: unknown;
|
|
112
|
-
query?: unknown;
|
|
113
|
-
url: string;
|
|
114
|
-
}
|
|
115
|
-
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
116
|
-
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = "fields"> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, "body" | "path" | "query" | "url"> & ([TData] extends [never] ? unknown : Omit<TData, "url">);
|
|
117
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { QuerySerializerOptions } from "../core/bodySerializer.gen.js";
|
|
2
|
-
import type { Client, ClientOptions, Config, RequestOptions } from "./types.gen.js";
|
|
3
|
-
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
|
-
/**
|
|
5
|
-
* Infers parseAs value from provided Content-Type header.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
|
|
8
|
-
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions>, "security"> & Pick<RequestOptions, "auth" | "query"> & {
|
|
9
|
-
headers: Headers;
|
|
10
|
-
}) => Promise<void>;
|
|
11
|
-
export declare const buildUrl: Client["buildUrl"];
|
|
12
|
-
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
13
|
-
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
14
|
-
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
15
|
-
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
16
|
-
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
17
|
-
declare class Interceptors<Interceptor> {
|
|
18
|
-
fns: Array<Interceptor | null>;
|
|
19
|
-
clear(): void;
|
|
20
|
-
eject(id: number | Interceptor): void;
|
|
21
|
-
exists(id: number | Interceptor): boolean;
|
|
22
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
23
|
-
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
24
|
-
use(fn: Interceptor): number;
|
|
25
|
-
}
|
|
26
|
-
export interface Middleware<Req, Res, Err, Options> {
|
|
27
|
-
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
28
|
-
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
29
|
-
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
30
|
-
}
|
|
31
|
-
export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
|
|
32
|
-
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
33
|
-
export {};
|