@pixelml/sdk 0.0.0-dev-202512250753 → 0.0.0-dev-202512260335
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@pixelml/sdk",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-202512260335",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsgo --noEmit",
|
|
@@ -43,8 +43,5 @@
|
|
|
43
43
|
"typescript": "catalog:",
|
|
44
44
|
"@typescript/native-preview": "catalog:"
|
|
45
45
|
},
|
|
46
|
-
"dependencies": {}
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"directory": "dist"
|
|
49
|
-
}
|
|
46
|
+
"dependencies": {}
|
|
50
47
|
}
|
package/dist/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/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,165 +0,0 @@
|
|
|
1
|
-
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { createSseClient } from "../core/serverSentEvents.gen.js";
|
|
3
|
-
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from "./utils.gen.js";
|
|
4
|
-
export const createClient = (config = {}) => {
|
|
5
|
-
let _config = mergeConfigs(createConfig(), config);
|
|
6
|
-
const getConfig = () => ({ ..._config });
|
|
7
|
-
const setConfig = (config) => {
|
|
8
|
-
_config = mergeConfigs(_config, config);
|
|
9
|
-
return getConfig();
|
|
10
|
-
};
|
|
11
|
-
const interceptors = createInterceptors();
|
|
12
|
-
const beforeRequest = async (options) => {
|
|
13
|
-
const opts = {
|
|
14
|
-
..._config,
|
|
15
|
-
...options,
|
|
16
|
-
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
17
|
-
headers: mergeHeaders(_config.headers, options.headers),
|
|
18
|
-
serializedBody: undefined,
|
|
19
|
-
};
|
|
20
|
-
if (opts.security) {
|
|
21
|
-
await setAuthParams({
|
|
22
|
-
...opts,
|
|
23
|
-
security: opts.security,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (opts.requestValidator) {
|
|
27
|
-
await opts.requestValidator(opts);
|
|
28
|
-
}
|
|
29
|
-
if (opts.body && opts.bodySerializer) {
|
|
30
|
-
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
31
|
-
}
|
|
32
|
-
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
33
|
-
if (opts.serializedBody === undefined || opts.serializedBody === "") {
|
|
34
|
-
opts.headers.delete("Content-Type");
|
|
35
|
-
}
|
|
36
|
-
const url = buildUrl(opts);
|
|
37
|
-
return { opts, url };
|
|
38
|
-
};
|
|
39
|
-
const request = async (options) => {
|
|
40
|
-
// @ts-expect-error
|
|
41
|
-
const { opts, url } = await beforeRequest(options);
|
|
42
|
-
const requestInit = {
|
|
43
|
-
redirect: "follow",
|
|
44
|
-
...opts,
|
|
45
|
-
body: opts.serializedBody,
|
|
46
|
-
};
|
|
47
|
-
let request = new Request(url, requestInit);
|
|
48
|
-
for (const fn of interceptors.request._fns) {
|
|
49
|
-
if (fn) {
|
|
50
|
-
request = await fn(request, opts);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// fetch must be assigned here, otherwise it would throw the error:
|
|
54
|
-
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
55
|
-
const _fetch = opts.fetch;
|
|
56
|
-
let response = await _fetch(request);
|
|
57
|
-
for (const fn of interceptors.response._fns) {
|
|
58
|
-
if (fn) {
|
|
59
|
-
response = await fn(response, request, opts);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const result = {
|
|
63
|
-
request,
|
|
64
|
-
response,
|
|
65
|
-
};
|
|
66
|
-
if (response.ok) {
|
|
67
|
-
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
68
|
-
return opts.responseStyle === "data"
|
|
69
|
-
? {}
|
|
70
|
-
: {
|
|
71
|
-
data: {},
|
|
72
|
-
...result,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
76
|
-
let data;
|
|
77
|
-
switch (parseAs) {
|
|
78
|
-
case "arrayBuffer":
|
|
79
|
-
case "blob":
|
|
80
|
-
case "formData":
|
|
81
|
-
case "json":
|
|
82
|
-
case "text":
|
|
83
|
-
data = await response[parseAs]();
|
|
84
|
-
break;
|
|
85
|
-
case "stream":
|
|
86
|
-
return opts.responseStyle === "data"
|
|
87
|
-
? response.body
|
|
88
|
-
: {
|
|
89
|
-
data: response.body,
|
|
90
|
-
...result,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
if (parseAs === "json") {
|
|
94
|
-
if (opts.responseValidator) {
|
|
95
|
-
await opts.responseValidator(data);
|
|
96
|
-
}
|
|
97
|
-
if (opts.responseTransformer) {
|
|
98
|
-
data = await opts.responseTransformer(data);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return opts.responseStyle === "data"
|
|
102
|
-
? data
|
|
103
|
-
: {
|
|
104
|
-
data,
|
|
105
|
-
...result,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const textError = await response.text();
|
|
109
|
-
let jsonError;
|
|
110
|
-
try {
|
|
111
|
-
jsonError = JSON.parse(textError);
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
// noop
|
|
115
|
-
}
|
|
116
|
-
const error = jsonError ?? textError;
|
|
117
|
-
let finalError = error;
|
|
118
|
-
for (const fn of interceptors.error._fns) {
|
|
119
|
-
if (fn) {
|
|
120
|
-
finalError = (await fn(error, response, request, opts));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
finalError = finalError || {};
|
|
124
|
-
if (opts.throwOnError) {
|
|
125
|
-
throw finalError;
|
|
126
|
-
}
|
|
127
|
-
// TODO: we probably want to return error and improve types
|
|
128
|
-
return opts.responseStyle === "data"
|
|
129
|
-
? undefined
|
|
130
|
-
: {
|
|
131
|
-
error: finalError,
|
|
132
|
-
...result,
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
const makeMethod = (method) => {
|
|
136
|
-
const fn = (options) => request({ ...options, method });
|
|
137
|
-
fn.sse = async (options) => {
|
|
138
|
-
const { opts, url } = await beforeRequest(options);
|
|
139
|
-
return createSseClient({
|
|
140
|
-
...opts,
|
|
141
|
-
body: opts.body,
|
|
142
|
-
headers: opts.headers,
|
|
143
|
-
method,
|
|
144
|
-
url,
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
return fn;
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
buildUrl,
|
|
151
|
-
connect: makeMethod("CONNECT"),
|
|
152
|
-
delete: makeMethod("DELETE"),
|
|
153
|
-
get: makeMethod("GET"),
|
|
154
|
-
getConfig,
|
|
155
|
-
head: makeMethod("HEAD"),
|
|
156
|
-
interceptors,
|
|
157
|
-
options: makeMethod("OPTIONS"),
|
|
158
|
-
patch: makeMethod("PATCH"),
|
|
159
|
-
post: makeMethod("POST"),
|
|
160
|
-
put: makeMethod("PUT"),
|
|
161
|
-
request,
|
|
162
|
-
setConfig,
|
|
163
|
-
trace: makeMethod("TRACE"),
|
|
164
|
-
};
|
|
165
|
-
};
|
|
@@ -1,7 +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 { createClient } from "./client.gen.js";
|
|
6
|
-
export type { Client, ClientOptions, Config, CreateClientConfig, Options, OptionsLegacyParser, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from "./types.gen.js";
|
|
7
|
-
export { createConfig, mergeHeaders } from "./utils.gen.js";
|
package/dist/gen/client/index.js
DELETED
|
@@ -1,5 +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 { createClient } from "./client.gen.js";
|
|
5
|
-
export { createConfig, mergeHeaders } from "./utils.gen.js";
|
|
@@ -1,127 +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?: (request: Request) => ReturnType<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 MethodFnBase = <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 MethodFnServerSentEvents = <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 MethodFn = MethodFnBase & {
|
|
90
|
-
sse: MethodFnServerSentEvents;
|
|
91
|
-
};
|
|
92
|
-
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>;
|
|
93
|
-
type BuildUrlFn = <TData extends {
|
|
94
|
-
body?: unknown;
|
|
95
|
-
path?: Record<string, unknown>;
|
|
96
|
-
query?: Record<string, unknown>;
|
|
97
|
-
url: string;
|
|
98
|
-
}>(options: Pick<TData, "url"> & Options<TData>) => string;
|
|
99
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
100
|
-
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
104
|
-
* and the returned object will become the client's initial configuration.
|
|
105
|
-
*
|
|
106
|
-
* You may want to initialize your client this way instead of calling
|
|
107
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
108
|
-
* to ensure your client always has the correct values.
|
|
109
|
-
*/
|
|
110
|
-
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
111
|
-
export interface TDataShape {
|
|
112
|
-
body?: unknown;
|
|
113
|
-
headers?: unknown;
|
|
114
|
-
path?: unknown;
|
|
115
|
-
query?: unknown;
|
|
116
|
-
url: string;
|
|
117
|
-
}
|
|
118
|
-
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
119
|
-
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"> & Omit<TData, "url">;
|
|
120
|
-
export type OptionsLegacyParser<TData = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = "fields"> = TData extends {
|
|
121
|
-
body?: any;
|
|
122
|
-
} ? TData extends {
|
|
123
|
-
headers?: any;
|
|
124
|
-
} ? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body" | "headers" | "url"> & TData : OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body" | "url"> & TData & Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "headers"> : TData extends {
|
|
125
|
-
headers?: any;
|
|
126
|
-
} ? OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "headers" | "url"> & TData & Pick<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "body"> : OmitKeys<RequestOptions<unknown, TResponseStyle, ThrowOnError>, "url"> & TData;
|
|
127
|
-
export {};
|
|
@@ -1,38 +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>({ allowReserved, array, object }?: 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: (Interceptor | null)[];
|
|
19
|
-
constructor();
|
|
20
|
-
clear(): void;
|
|
21
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
22
|
-
exists(id: number | Interceptor): boolean;
|
|
23
|
-
eject(id: number | Interceptor): void;
|
|
24
|
-
update(id: number | Interceptor, fn: Interceptor): number | false | Interceptor;
|
|
25
|
-
use(fn: Interceptor): number;
|
|
26
|
-
}
|
|
27
|
-
export interface Middleware<Req, Res, Err, Options> {
|
|
28
|
-
error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, "eject" | "use">;
|
|
29
|
-
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, "eject" | "use">;
|
|
30
|
-
response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, "eject" | "use">;
|
|
31
|
-
}
|
|
32
|
-
export declare const createInterceptors: <Req, Res, Err, Options>() => {
|
|
33
|
-
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
34
|
-
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
35
|
-
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
36
|
-
};
|
|
37
|
-
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
38
|
-
export {};
|
|
@@ -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 = ({ allowReserved, array, object } = {}) => {
|
|
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
|
-
if (Array.isArray(value)) {
|
|
16
|
-
const serializedArray = serializeArrayParam({
|
|
17
|
-
allowReserved,
|
|
18
|
-
explode: true,
|
|
19
|
-
name,
|
|
20
|
-
style: "form",
|
|
21
|
-
value,
|
|
22
|
-
...array,
|
|
23
|
-
});
|
|
24
|
-
if (serializedArray)
|
|
25
|
-
search.push(serializedArray);
|
|
26
|
-
}
|
|
27
|
-
else if (typeof value === "object") {
|
|
28
|
-
const serializedObject = serializeObjectParam({
|
|
29
|
-
allowReserved,
|
|
30
|
-
explode: true,
|
|
31
|
-
name,
|
|
32
|
-
style: "deepObject",
|
|
33
|
-
value: value,
|
|
34
|
-
...object,
|
|
35
|
-
});
|
|
36
|
-
if (serializedObject)
|
|
37
|
-
search.push(serializedObject);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const serializedPrimitive = serializePrimitiveParam({
|
|
41
|
-
allowReserved,
|
|
42
|
-
name,
|
|
43
|
-
value: value,
|
|
44
|
-
});
|
|
45
|
-
if (serializedPrimitive)
|
|
46
|
-
search.push(serializedPrimitive);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return search.join("&");
|
|
51
|
-
};
|
|
52
|
-
return querySerializer;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Infers parseAs value from provided Content-Type header.
|
|
56
|
-
*/
|
|
57
|
-
export const getParseAs = (contentType) => {
|
|
58
|
-
if (!contentType) {
|
|
59
|
-
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
60
|
-
// which is effectively the same as the 'stream' option.
|
|
61
|
-
return "stream";
|
|
62
|
-
}
|
|
63
|
-
const cleanContent = contentType.split(";")[0]?.trim();
|
|
64
|
-
if (!cleanContent) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
68
|
-
return "json";
|
|
69
|
-
}
|
|
70
|
-
if (cleanContent === "multipart/form-data") {
|
|
71
|
-
return "formData";
|
|
72
|
-
}
|
|
73
|
-
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
74
|
-
return "blob";
|
|
75
|
-
}
|
|
76
|
-
if (cleanContent.startsWith("text/")) {
|
|
77
|
-
return "text";
|
|
78
|
-
}
|
|
79
|
-
return;
|
|
80
|
-
};
|
|
81
|
-
const checkForExistence = (options, name) => {
|
|
82
|
-
if (!name) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
};
|
|
90
|
-
export const setAuthParams = async ({ security, ...options }) => {
|
|
91
|
-
for (const auth of security) {
|
|
92
|
-
if (checkForExistence(options, auth.name)) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const token = await getAuthToken(auth, options.auth);
|
|
96
|
-
if (!token) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const name = auth.name ?? "Authorization";
|
|
100
|
-
switch (auth.in) {
|
|
101
|
-
case "query":
|
|
102
|
-
if (!options.query) {
|
|
103
|
-
options.query = {};
|
|
104
|
-
}
|
|
105
|
-
options.query[name] = token;
|
|
106
|
-
break;
|
|
107
|
-
case "cookie":
|
|
108
|
-
options.headers.append("Cookie", `${name}=${token}`);
|
|
109
|
-
break;
|
|
110
|
-
case "header":
|
|
111
|
-
default:
|
|
112
|
-
options.headers.set(name, token);
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
export const buildUrl = (options) => getUrl({
|
|
118
|
-
baseUrl: options.baseUrl,
|
|
119
|
-
path: options.path,
|
|
120
|
-
query: options.query,
|
|
121
|
-
querySerializer: typeof options.querySerializer === "function"
|
|
122
|
-
? options.querySerializer
|
|
123
|
-
: createQuerySerializer(options.querySerializer),
|
|
124
|
-
url: options.url,
|
|
125
|
-
});
|
|
126
|
-
export const mergeConfigs = (a, b) => {
|
|
127
|
-
const config = { ...a, ...b };
|
|
128
|
-
if (config.baseUrl?.endsWith("/")) {
|
|
129
|
-
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
130
|
-
}
|
|
131
|
-
config.headers = mergeHeaders(a.headers, b.headers);
|
|
132
|
-
return config;
|
|
133
|
-
};
|
|
134
|
-
export const mergeHeaders = (...headers) => {
|
|
135
|
-
const mergedHeaders = new Headers();
|
|
136
|
-
for (const header of headers) {
|
|
137
|
-
if (!header || typeof header !== "object") {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
|
|
141
|
-
for (const [key, value] of iterator) {
|
|
142
|
-
if (value === null) {
|
|
143
|
-
mergedHeaders.delete(key);
|
|
144
|
-
}
|
|
145
|
-
else if (Array.isArray(value)) {
|
|
146
|
-
for (const v of value) {
|
|
147
|
-
mergedHeaders.append(key, v);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
else if (value !== undefined) {
|
|
151
|
-
// assume object headers are meant to be JSON stringified, i.e. their
|
|
152
|
-
// content value in OpenAPI specification is 'application/json'
|
|
153
|
-
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return mergedHeaders;
|
|
158
|
-
};
|
|
159
|
-
class Interceptors {
|
|
160
|
-
_fns;
|
|
161
|
-
constructor() {
|
|
162
|
-
this._fns = [];
|
|
163
|
-
}
|
|
164
|
-
clear() {
|
|
165
|
-
this._fns = [];
|
|
166
|
-
}
|
|
167
|
-
getInterceptorIndex(id) {
|
|
168
|
-
if (typeof id === "number") {
|
|
169
|
-
return this._fns[id] ? id : -1;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return this._fns.indexOf(id);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
exists(id) {
|
|
176
|
-
const index = this.getInterceptorIndex(id);
|
|
177
|
-
return !!this._fns[index];
|
|
178
|
-
}
|
|
179
|
-
eject(id) {
|
|
180
|
-
const index = this.getInterceptorIndex(id);
|
|
181
|
-
if (this._fns[index]) {
|
|
182
|
-
this._fns[index] = null;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
update(id, fn) {
|
|
186
|
-
const index = this.getInterceptorIndex(id);
|
|
187
|
-
if (this._fns[index]) {
|
|
188
|
-
this._fns[index] = fn;
|
|
189
|
-
return id;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
use(fn) {
|
|
196
|
-
this._fns = [...this._fns, fn];
|
|
197
|
-
return this._fns.length - 1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
// do not add `Middleware` as return type so we can use _fns internally
|
|
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
|
-
});
|
package/dist/gen/client.gen.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ClientOptions } from "./types.gen.js";
|
|
2
|
-
import { type Config, type ClientOptions as DefaultClientOptions } from "./client/index.js";
|
|
3
|
-
/**
|
|
4
|
-
* The `createClientConfig()` function will be called on client initialization
|
|
5
|
-
* and the returned object will become the client's initial configuration.
|
|
6
|
-
*
|
|
7
|
-
* You may want to initialize your client this way instead of calling
|
|
8
|
-
* `setConfig()`. This is useful for example if you're using Next.js
|
|
9
|
-
* to ensure your client always has the correct values.
|
|
10
|
-
*/
|
|
11
|
-
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> = (override?: Config<DefaultClientOptions & T>) => Config<Required<DefaultClientOptions> & T>;
|
|
12
|
-
export declare const client: import("./client/types.gen.js").Client;
|
package/dist/gen/client.gen.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type AuthToken = string | undefined;
|
|
2
|
-
export interface Auth {
|
|
3
|
-
/**
|
|
4
|
-
* Which part of the request do we use to send the auth?
|
|
5
|
-
*
|
|
6
|
-
* @default 'header'
|
|
7
|
-
*/
|
|
8
|
-
in?: "header" | "query" | "cookie";
|
|
9
|
-
/**
|
|
10
|
-
* Header or query parameter name.
|
|
11
|
-
*
|
|
12
|
-
* @default 'Authorization'
|
|
13
|
-
*/
|
|
14
|
-
name?: string;
|
|
15
|
-
scheme?: "basic" | "bearer";
|
|
16
|
-
type: "apiKey" | "http";
|
|
17
|
-
}
|
|
18
|
-
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|