@opencode-ai/sdk 1.0.134 → 1.0.138
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/dist/client.d.ts +1 -1
- package/dist/client.js +7 -6
- package/dist/gen/sdk.gen.d.ts +32 -7
- package/dist/gen/sdk.gen.js +74 -15
- package/dist/gen/types.gen.d.ts +184 -1
- package/dist/v2/client.d.ts +7 -0
- package/dist/v2/client.js +25 -0
- package/dist/v2/gen/client/client.gen.d.ts +2 -0
- package/dist/v2/gen/client/client.gen.js +225 -0
- package/dist/v2/gen/client/index.d.ts +8 -0
- package/dist/v2/gen/client/index.js +6 -0
- package/dist/v2/gen/client/types.gen.d.ts +117 -0
- package/dist/v2/gen/client/types.gen.js +2 -0
- package/dist/v2/gen/client/utils.gen.d.ts +33 -0
- package/dist/v2/gen/client/utils.gen.js +226 -0
- package/dist/v2/gen/client.gen.d.ts +12 -0
- package/dist/v2/gen/client.gen.js +3 -0
- package/dist/v2/gen/core/auth.gen.d.ts +18 -0
- package/dist/v2/gen/core/auth.gen.js +14 -0
- package/dist/v2/gen/core/bodySerializer.gen.d.ts +25 -0
- package/dist/v2/gen/core/bodySerializer.gen.js +57 -0
- package/dist/v2/gen/core/params.gen.d.ts +43 -0
- package/dist/v2/gen/core/params.gen.js +102 -0
- package/dist/v2/gen/core/pathSerializer.gen.d.ts +33 -0
- package/dist/v2/gen/core/pathSerializer.gen.js +106 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/v2/gen/core/queryKeySerializer.gen.js +93 -0
- package/dist/v2/gen/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/v2/gen/core/serverSentEvents.gen.js +131 -0
- package/dist/v2/gen/core/types.gen.d.ts +78 -0
- package/dist/v2/gen/core/types.gen.js +2 -0
- package/dist/v2/gen/core/utils.gen.d.ts +19 -0
- package/dist/v2/gen/core/utils.gen.js +87 -0
- package/dist/v2/gen/sdk.gen.d.ts +850 -0
- package/dist/v2/gen/sdk.gen.js +1626 -0
- package/dist/v2/gen/types.gen.d.ts +3357 -0
- package/dist/v2/gen/types.gen.js +2 -0
- package/dist/v2/index.d.ts +10 -0
- package/dist/v2/index.js +16 -0
- package/dist/v2/server.d.ts +23 -0
- package/dist/v2/server.js +91 -0
- package/package.json +15 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Auth, AuthToken } from "./auth.gen.js";
|
|
2
|
+
import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from "./bodySerializer.gen.js";
|
|
3
|
+
export type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace";
|
|
4
|
+
export type Client<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the final request URL.
|
|
7
|
+
*/
|
|
8
|
+
buildUrl: BuildUrlFn;
|
|
9
|
+
getConfig: () => Config;
|
|
10
|
+
request: RequestFn;
|
|
11
|
+
setConfig: (config: Config) => Config;
|
|
12
|
+
} & {
|
|
13
|
+
[K in HttpMethod]: MethodFn;
|
|
14
|
+
} & ([SseFn] extends [never] ? {
|
|
15
|
+
sse?: never;
|
|
16
|
+
} : {
|
|
17
|
+
sse: {
|
|
18
|
+
[K in HttpMethod]: SseFn;
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
export interface Config {
|
|
22
|
+
/**
|
|
23
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
24
|
+
* added to the request payload as defined by its `security` array.
|
|
25
|
+
*/
|
|
26
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
27
|
+
/**
|
|
28
|
+
* A function for serializing request body parameter. By default,
|
|
29
|
+
* {@link JSON.stringify()} will be used.
|
|
30
|
+
*/
|
|
31
|
+
bodySerializer?: BodySerializer | null;
|
|
32
|
+
/**
|
|
33
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
34
|
+
* `Headers` object with.
|
|
35
|
+
*
|
|
36
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
37
|
+
*/
|
|
38
|
+
headers?: RequestInit["headers"] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* The request method.
|
|
41
|
+
*
|
|
42
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
43
|
+
*/
|
|
44
|
+
method?: Uppercase<HttpMethod>;
|
|
45
|
+
/**
|
|
46
|
+
* A function for serializing request query parameters. By default, arrays
|
|
47
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
48
|
+
* style, and reserved characters are percent-encoded.
|
|
49
|
+
*
|
|
50
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
51
|
+
* API function is used.
|
|
52
|
+
*
|
|
53
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
54
|
+
*/
|
|
55
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
56
|
+
/**
|
|
57
|
+
* A function validating request data. This is useful if you want to ensure
|
|
58
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
59
|
+
* the server.
|
|
60
|
+
*/
|
|
61
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* A function transforming response data before it's returned. This is useful
|
|
64
|
+
* for post-processing data, e.g. converting ISO strings into Date objects.
|
|
65
|
+
*/
|
|
66
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* A function validating response data. This is useful if you want to ensure
|
|
69
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
70
|
+
* the transformers and returned to the user.
|
|
71
|
+
*/
|
|
72
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
73
|
+
}
|
|
74
|
+
type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never] ? true : [T] extends [never | undefined] ? [undefined] extends [T] ? false : true : false;
|
|
75
|
+
export type OmitNever<T extends Record<string, unknown>> = {
|
|
76
|
+
[K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
|
|
77
|
+
};
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen.js";
|
|
2
|
+
export interface PathSerializer {
|
|
3
|
+
path: Record<string, unknown>;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const PATH_PARAM_RE: RegExp;
|
|
7
|
+
export declare const defaultPathSerializer: ({ path, url: _url }: PathSerializer) => string;
|
|
8
|
+
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
path?: Record<string, unknown>;
|
|
11
|
+
query?: Record<string, unknown>;
|
|
12
|
+
querySerializer: QuerySerializer;
|
|
13
|
+
url: string;
|
|
14
|
+
}) => string;
|
|
15
|
+
export declare function getValidRequestBody(options: {
|
|
16
|
+
body?: unknown;
|
|
17
|
+
bodySerializer?: BodySerializer | null;
|
|
18
|
+
serializedBody?: unknown;
|
|
19
|
+
}): unknown;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "./pathSerializer.gen.js";
|
|
3
|
+
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
4
|
+
export const defaultPathSerializer = ({ path, url: _url }) => {
|
|
5
|
+
let url = _url;
|
|
6
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
7
|
+
if (matches) {
|
|
8
|
+
for (const match of matches) {
|
|
9
|
+
let explode = false;
|
|
10
|
+
let name = match.substring(1, match.length - 1);
|
|
11
|
+
let style = "simple";
|
|
12
|
+
if (name.endsWith("*")) {
|
|
13
|
+
explode = true;
|
|
14
|
+
name = name.substring(0, name.length - 1);
|
|
15
|
+
}
|
|
16
|
+
if (name.startsWith(".")) {
|
|
17
|
+
name = name.substring(1);
|
|
18
|
+
style = "label";
|
|
19
|
+
}
|
|
20
|
+
else if (name.startsWith(";")) {
|
|
21
|
+
name = name.substring(1);
|
|
22
|
+
style = "matrix";
|
|
23
|
+
}
|
|
24
|
+
const value = path[name];
|
|
25
|
+
if (value === undefined || value === null) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "object") {
|
|
33
|
+
url = url.replace(match, serializeObjectParam({
|
|
34
|
+
explode,
|
|
35
|
+
name,
|
|
36
|
+
style,
|
|
37
|
+
value: value,
|
|
38
|
+
valueOnly: true,
|
|
39
|
+
}));
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (style === "matrix") {
|
|
43
|
+
url = url.replace(match, `;${serializePrimitiveParam({
|
|
44
|
+
name,
|
|
45
|
+
value: value,
|
|
46
|
+
})}`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
|
|
50
|
+
url = url.replace(match, replaceValue);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return url;
|
|
54
|
+
};
|
|
55
|
+
export const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
56
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
57
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
58
|
+
if (path) {
|
|
59
|
+
url = defaultPathSerializer({ path, url });
|
|
60
|
+
}
|
|
61
|
+
let search = query ? querySerializer(query) : "";
|
|
62
|
+
if (search.startsWith("?")) {
|
|
63
|
+
search = search.substring(1);
|
|
64
|
+
}
|
|
65
|
+
if (search) {
|
|
66
|
+
url += `?${search}`;
|
|
67
|
+
}
|
|
68
|
+
return url;
|
|
69
|
+
};
|
|
70
|
+
export function getValidRequestBody(options) {
|
|
71
|
+
const hasBody = options.body !== undefined;
|
|
72
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
73
|
+
if (isSerializedBody) {
|
|
74
|
+
if ("serializedBody" in options) {
|
|
75
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
|
|
76
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
77
|
+
}
|
|
78
|
+
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
79
|
+
return options.body !== "" ? options.body : null;
|
|
80
|
+
}
|
|
81
|
+
// plain/text body
|
|
82
|
+
if (hasBody) {
|
|
83
|
+
return options.body;
|
|
84
|
+
}
|
|
85
|
+
// no body was provided
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|