@townco/fly 0.1.59 → 0.1.61
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/api/client/client.gen.d.ts +1 -1
- package/dist/api/client/client.gen.js +46 -46
- package/dist/api/client/index.d.ts +8 -8
- package/dist/api/client/index.js +5 -5
- package/dist/api/client/types.gen.d.ts +18 -18
- package/dist/api/client/utils.gen.d.ts +3 -3
- package/dist/api/client/utils.gen.js +34 -34
- package/dist/api/client.gen.d.ts +2 -2
- package/dist/api/client.gen.js +3 -3
- package/dist/api/core/auth.gen.d.ts +3 -3
- package/dist/api/core/auth.gen.js +3 -3
- package/dist/api/core/bodySerializer.gen.d.ts +1 -1
- package/dist/api/core/bodySerializer.gen.js +3 -3
- package/dist/api/core/params.gen.d.ts +3 -3
- package/dist/api/core/params.gen.js +9 -9
- package/dist/api/core/pathSerializer.gen.d.ts +3 -3
- package/dist/api/core/pathSerializer.gen.js +36 -36
- package/dist/api/core/queryKeySerializer.gen.js +11 -11
- package/dist/api/core/serverSentEvents.gen.d.ts +3 -3
- package/dist/api/core/serverSentEvents.gen.js +19 -19
- package/dist/api/core/types.gen.d.ts +4 -4
- package/dist/api/core/utils.gen.d.ts +1 -1
- package/dist/api/core/utils.gen.js +17 -17
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +1 -1
- package/dist/api/sdk.gen.d.ts +2 -2
- package/dist/api/sdk.gen.js +160 -130
- package/dist/api/types.gen.d.ts +79 -79
- package/dist/client/client.gen.d.ts +2 -0
- package/dist/client/client.gen.js +228 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.js +6 -0
- package/dist/client/types.gen.d.ts +117 -0
- package/dist/client/types.gen.js +2 -0
- package/dist/client/utils.gen.d.ts +33 -0
- package/dist/client/utils.gen.js +231 -0
- package/dist/client.gen.d.ts +12 -0
- package/dist/client.gen.js +3 -0
- package/dist/core/auth.gen.d.ts +18 -0
- package/dist/core/auth.gen.js +14 -0
- package/dist/core/bodySerializer.gen.d.ts +25 -0
- package/dist/core/bodySerializer.gen.js +57 -0
- package/dist/core/params.gen.d.ts +43 -0
- package/dist/core/params.gen.js +100 -0
- package/dist/core/pathSerializer.gen.d.ts +33 -0
- package/dist/core/pathSerializer.gen.js +114 -0
- package/dist/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/core/queryKeySerializer.gen.js +99 -0
- package/dist/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/core/serverSentEvents.gen.js +135 -0
- package/dist/core/types.gen.d.ts +78 -0
- package/dist/core/types.gen.js +2 -0
- package/dist/core/utils.gen.d.ts +19 -0
- package/dist/core/utils.gen.js +87 -0
- package/dist/hey-api.js +18 -2
- package/dist/sdk.gen.d.ts +379 -0
- package/dist/sdk.gen.js +557 -0
- package/dist/types.gen.d.ts +2592 -0
- package/dist/types.gen.js +2 -0
- package/package.json +6 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Client, Config } from
|
|
1
|
+
import type { Client, Config } from "./types.gen";
|
|
2
2
|
export declare const createClient: (config?: Config<import("./types.gen").ClientOptions>) => Client;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { createSseClient } from
|
|
3
|
-
import { getValidRequestBody } from
|
|
4
|
-
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from
|
|
2
|
+
import { createSseClient } from "../core/serverSentEvents.gen";
|
|
3
|
+
import { getValidRequestBody } from "../core/utils.gen";
|
|
4
|
+
import { buildUrl, createConfig, createInterceptors, getParseAs, mergeConfigs, mergeHeaders, setAuthParams, } from "./utils.gen";
|
|
5
5
|
export const createClient = (config = {}) => {
|
|
6
6
|
let _config = mergeConfigs(createConfig(), config);
|
|
7
7
|
const getConfig = () => ({ ..._config });
|
|
@@ -31,8 +31,8 @@ export const createClient = (config = {}) => {
|
|
|
31
31
|
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
32
32
|
}
|
|
33
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(
|
|
34
|
+
if (opts.body === undefined || opts.serializedBody === "") {
|
|
35
|
+
opts.headers.delete("Content-Type");
|
|
36
36
|
}
|
|
37
37
|
const url = buildUrl(opts);
|
|
38
38
|
return { opts, url };
|
|
@@ -41,7 +41,7 @@ export const createClient = (config = {}) => {
|
|
|
41
41
|
// @ts-expect-error
|
|
42
42
|
const { opts, url } = await beforeRequest(options);
|
|
43
43
|
const requestInit = {
|
|
44
|
-
redirect:
|
|
44
|
+
redirect: "follow",
|
|
45
45
|
...opts,
|
|
46
46
|
body: getValidRequestBody(opts),
|
|
47
47
|
};
|
|
@@ -71,7 +71,7 @@ export const createClient = (config = {}) => {
|
|
|
71
71
|
throw finalError;
|
|
72
72
|
}
|
|
73
73
|
// Return error response
|
|
74
|
-
return opts.responseStyle ===
|
|
74
|
+
return opts.responseStyle === "data"
|
|
75
75
|
? undefined
|
|
76
76
|
: {
|
|
77
77
|
error: finalError,
|
|
@@ -89,30 +89,30 @@ export const createClient = (config = {}) => {
|
|
|
89
89
|
response,
|
|
90
90
|
};
|
|
91
91
|
if (response.ok) {
|
|
92
|
-
const parseAs = (opts.parseAs ===
|
|
93
|
-
? getParseAs(response.headers.get(
|
|
94
|
-
: opts.parseAs) ??
|
|
92
|
+
const parseAs = (opts.parseAs === "auto"
|
|
93
|
+
? getParseAs(response.headers.get("Content-Type"))
|
|
94
|
+
: opts.parseAs) ?? "json";
|
|
95
95
|
if (response.status === 204 ||
|
|
96
|
-
response.headers.get(
|
|
96
|
+
response.headers.get("Content-Length") === "0") {
|
|
97
97
|
let emptyData;
|
|
98
98
|
switch (parseAs) {
|
|
99
|
-
case
|
|
100
|
-
case
|
|
101
|
-
case
|
|
99
|
+
case "arrayBuffer":
|
|
100
|
+
case "blob":
|
|
101
|
+
case "text":
|
|
102
102
|
emptyData = await response[parseAs]();
|
|
103
103
|
break;
|
|
104
|
-
case
|
|
104
|
+
case "formData":
|
|
105
105
|
emptyData = new FormData();
|
|
106
106
|
break;
|
|
107
|
-
case
|
|
107
|
+
case "stream":
|
|
108
108
|
emptyData = response.body;
|
|
109
109
|
break;
|
|
110
|
-
case
|
|
110
|
+
case "json":
|
|
111
111
|
default:
|
|
112
112
|
emptyData = {};
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
|
-
return opts.responseStyle ===
|
|
115
|
+
return opts.responseStyle === "data"
|
|
116
116
|
? emptyData
|
|
117
117
|
: {
|
|
118
118
|
data: emptyData,
|
|
@@ -121,22 +121,22 @@ export const createClient = (config = {}) => {
|
|
|
121
121
|
}
|
|
122
122
|
let data;
|
|
123
123
|
switch (parseAs) {
|
|
124
|
-
case
|
|
125
|
-
case
|
|
126
|
-
case
|
|
127
|
-
case
|
|
128
|
-
case
|
|
124
|
+
case "arrayBuffer":
|
|
125
|
+
case "blob":
|
|
126
|
+
case "formData":
|
|
127
|
+
case "json":
|
|
128
|
+
case "text":
|
|
129
129
|
data = await response[parseAs]();
|
|
130
130
|
break;
|
|
131
|
-
case
|
|
132
|
-
return opts.responseStyle ===
|
|
131
|
+
case "stream":
|
|
132
|
+
return opts.responseStyle === "data"
|
|
133
133
|
? response.body
|
|
134
134
|
: {
|
|
135
135
|
data: response.body,
|
|
136
136
|
...result,
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
if (parseAs ===
|
|
139
|
+
if (parseAs === "json") {
|
|
140
140
|
if (opts.responseValidator) {
|
|
141
141
|
await opts.responseValidator(data);
|
|
142
142
|
}
|
|
@@ -144,7 +144,7 @@ export const createClient = (config = {}) => {
|
|
|
144
144
|
data = await opts.responseTransformer(data);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
return opts.responseStyle ===
|
|
147
|
+
return opts.responseStyle === "data"
|
|
148
148
|
? data
|
|
149
149
|
: {
|
|
150
150
|
data,
|
|
@@ -171,7 +171,7 @@ export const createClient = (config = {}) => {
|
|
|
171
171
|
throw finalError;
|
|
172
172
|
}
|
|
173
173
|
// TODO: we probably want to return error and improve types
|
|
174
|
-
return opts.responseStyle ===
|
|
174
|
+
return opts.responseStyle === "data"
|
|
175
175
|
? undefined
|
|
176
176
|
: {
|
|
177
177
|
error: finalError,
|
|
@@ -200,29 +200,29 @@ export const createClient = (config = {}) => {
|
|
|
200
200
|
};
|
|
201
201
|
return {
|
|
202
202
|
buildUrl,
|
|
203
|
-
connect: makeMethodFn(
|
|
204
|
-
delete: makeMethodFn(
|
|
205
|
-
get: makeMethodFn(
|
|
203
|
+
connect: makeMethodFn("CONNECT"),
|
|
204
|
+
delete: makeMethodFn("DELETE"),
|
|
205
|
+
get: makeMethodFn("GET"),
|
|
206
206
|
getConfig,
|
|
207
|
-
head: makeMethodFn(
|
|
207
|
+
head: makeMethodFn("HEAD"),
|
|
208
208
|
interceptors,
|
|
209
|
-
options: makeMethodFn(
|
|
210
|
-
patch: makeMethodFn(
|
|
211
|
-
post: makeMethodFn(
|
|
212
|
-
put: makeMethodFn(
|
|
209
|
+
options: makeMethodFn("OPTIONS"),
|
|
210
|
+
patch: makeMethodFn("PATCH"),
|
|
211
|
+
post: makeMethodFn("POST"),
|
|
212
|
+
put: makeMethodFn("PUT"),
|
|
213
213
|
request,
|
|
214
214
|
setConfig,
|
|
215
215
|
sse: {
|
|
216
|
-
connect: makeSseFn(
|
|
217
|
-
delete: makeSseFn(
|
|
218
|
-
get: makeSseFn(
|
|
219
|
-
head: makeSseFn(
|
|
220
|
-
options: makeSseFn(
|
|
221
|
-
patch: makeSseFn(
|
|
222
|
-
post: makeSseFn(
|
|
223
|
-
put: makeSseFn(
|
|
224
|
-
trace: makeSseFn(
|
|
216
|
+
connect: makeSseFn("CONNECT"),
|
|
217
|
+
delete: makeSseFn("DELETE"),
|
|
218
|
+
get: makeSseFn("GET"),
|
|
219
|
+
head: makeSseFn("HEAD"),
|
|
220
|
+
options: makeSseFn("OPTIONS"),
|
|
221
|
+
patch: makeSseFn("PATCH"),
|
|
222
|
+
post: makeSseFn("POST"),
|
|
223
|
+
put: makeSseFn("PUT"),
|
|
224
|
+
trace: makeSseFn("TRACE"),
|
|
225
225
|
},
|
|
226
|
-
trace: makeMethodFn(
|
|
226
|
+
trace: makeMethodFn("TRACE"),
|
|
227
227
|
};
|
|
228
228
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export type { Auth } from
|
|
2
|
-
export type { QuerySerializerOptions } from
|
|
3
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from
|
|
4
|
-
export { buildClientParams } from
|
|
5
|
-
export { serializeQueryKeyValue } from
|
|
6
|
-
export { createClient } from
|
|
7
|
-
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from
|
|
8
|
-
export { createConfig, mergeHeaders } from
|
|
1
|
+
export type { Auth } from "../core/auth.gen";
|
|
2
|
+
export type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
|
3
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen";
|
|
4
|
+
export { buildClientParams } from "../core/params.gen";
|
|
5
|
+
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen";
|
|
6
|
+
export { createClient } from "./client.gen";
|
|
7
|
+
export type { Client, ClientOptions, Config, CreateClientConfig, Options, RequestOptions, RequestResult, ResolvedRequestOptions, ResponseStyle, TDataShape, } from "./types.gen";
|
|
8
|
+
export { createConfig, mergeHeaders } from "./utils.gen";
|
package/dist/api/client/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from
|
|
3
|
-
export { buildClientParams } from
|
|
4
|
-
export { serializeQueryKeyValue } from
|
|
5
|
-
export { createClient } from
|
|
6
|
-
export { createConfig, mergeHeaders } from
|
|
2
|
+
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from "../core/bodySerializer.gen";
|
|
3
|
+
export { buildClientParams } from "../core/params.gen";
|
|
4
|
+
export { serializeQueryKeyValue } from "../core/queryKeySerializer.gen";
|
|
5
|
+
export { createClient } from "./client.gen";
|
|
6
|
+
export { createConfig, mergeHeaders } from "./utils.gen";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Auth } from
|
|
2
|
-
import type { ServerSentEventsOptions, ServerSentEventsResult } from
|
|
3
|
-
import type { Client as CoreClient, Config as CoreConfig } from
|
|
4
|
-
import type { Middleware } from
|
|
5
|
-
export type ResponseStyle =
|
|
6
|
-
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit,
|
|
1
|
+
import type { Auth } from "../core/auth.gen";
|
|
2
|
+
import type { ServerSentEventsOptions, ServerSentEventsResult } from "../core/serverSentEvents.gen";
|
|
3
|
+
import type { Client as CoreClient, Config as CoreConfig } from "../core/types.gen";
|
|
4
|
+
import type { Middleware } from "./utils.gen";
|
|
5
|
+
export type ResponseStyle = "data" | "fields";
|
|
6
|
+
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, "body" | "headers" | "method">, CoreConfig {
|
|
7
7
|
/**
|
|
8
8
|
* Base URL for all requests made by this client.
|
|
9
9
|
*/
|
|
10
|
-
baseUrl?: T[
|
|
10
|
+
baseUrl?: T["baseUrl"];
|
|
11
11
|
/**
|
|
12
12
|
* Fetch API implementation. You can use this option to provide a custom
|
|
13
13
|
* fetch instance.
|
|
@@ -30,7 +30,7 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
|
|
|
30
30
|
*
|
|
31
31
|
* @default 'auto'
|
|
32
32
|
*/
|
|
33
|
-
parseAs?:
|
|
33
|
+
parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text";
|
|
34
34
|
/**
|
|
35
35
|
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
36
36
|
*
|
|
@@ -42,12 +42,12 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
|
|
|
42
42
|
*
|
|
43
43
|
* @default false
|
|
44
44
|
*/
|
|
45
|
-
throwOnError?: T[
|
|
45
|
+
throwOnError?: T["throwOnError"];
|
|
46
46
|
}
|
|
47
|
-
export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle =
|
|
47
|
+
export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
48
48
|
responseStyle: TResponseStyle;
|
|
49
49
|
throwOnError: ThrowOnError;
|
|
50
|
-
}>, Pick<ServerSentEventsOptions<TData>,
|
|
50
|
+
}>, Pick<ServerSentEventsOptions<TData>, "onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"> {
|
|
51
51
|
/**
|
|
52
52
|
* Any body that you want to add to your request.
|
|
53
53
|
*
|
|
@@ -62,14 +62,14 @@ export interface RequestOptions<TData = unknown, TResponseStyle extends Response
|
|
|
62
62
|
security?: ReadonlyArray<Auth>;
|
|
63
63
|
url: Url;
|
|
64
64
|
}
|
|
65
|
-
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle =
|
|
65
|
+
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = "fields", ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
66
66
|
serializedBody?: string;
|
|
67
67
|
}
|
|
68
|
-
export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle =
|
|
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
69
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
70
70
|
request: Request;
|
|
71
71
|
response: Response;
|
|
72
|
-
}> : Promise<TResponseStyle extends
|
|
72
|
+
}> : Promise<TResponseStyle extends "data" ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
73
73
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
74
74
|
error: undefined;
|
|
75
75
|
} | {
|
|
@@ -84,9 +84,9 @@ export interface ClientOptions {
|
|
|
84
84
|
responseStyle?: ResponseStyle;
|
|
85
85
|
throwOnError?: boolean;
|
|
86
86
|
}
|
|
87
|
-
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle =
|
|
88
|
-
type SseFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle =
|
|
89
|
-
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle =
|
|
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
90
|
type BuildUrlFn = <TData extends {
|
|
91
91
|
body?: unknown;
|
|
92
92
|
path?: Record<string, unknown>;
|
|
@@ -113,5 +113,5 @@ export interface TDataShape {
|
|
|
113
113
|
url: string;
|
|
114
114
|
}
|
|
115
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 =
|
|
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
117
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { QuerySerializerOptions } from
|
|
2
|
-
import type { Client, ClientOptions, Config, RequestOptions } from
|
|
1
|
+
import type { QuerySerializerOptions } from "../core/bodySerializer.gen";
|
|
2
|
+
import type { Client, ClientOptions, Config, RequestOptions } from "./types.gen";
|
|
3
3
|
export declare const createQuerySerializer: <T = unknown>({ parameters, ...args }?: QuerySerializerOptions) => (queryParams: T) => string;
|
|
4
4
|
/**
|
|
5
5
|
* Infers parseAs value from provided Content-Type header.
|
|
@@ -8,7 +8,7 @@ export declare const getParseAs: (contentType: string | null) => "arrayBuffer" |
|
|
|
8
8
|
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions<unknown, "fields", boolean, string>>, "security"> & Pick<RequestOptions<unknown, "fields", boolean, string>, "auth" | "query"> & {
|
|
9
9
|
headers: Headers;
|
|
10
10
|
}) => Promise<void>;
|
|
11
|
-
export declare const buildUrl: Client[
|
|
11
|
+
export declare const buildUrl: Client["buildUrl"];
|
|
12
12
|
export declare const mergeConfigs: (a: Config<ClientOptions>, b: Config<ClientOptions>) => Config<ClientOptions>;
|
|
13
13
|
export declare const mergeHeaders: (...headers: (Record<string, unknown> | HeadersInit | undefined)[]) => Headers;
|
|
14
14
|
type ErrInterceptor<Err, Res, Req, Options> = (error: Err, response: Res, request: Req, options: Options) => Err | Promise<Err>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import { getAuthToken } from
|
|
3
|
-
import { jsonBodySerializer } from
|
|
4
|
-
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from
|
|
5
|
-
import { getUrl } from
|
|
2
|
+
import { getAuthToken } from "../core/auth.gen";
|
|
3
|
+
import { jsonBodySerializer } from "../core/bodySerializer.gen";
|
|
4
|
+
import { serializeArrayParam, serializeObjectParam, serializePrimitiveParam, } from "../core/pathSerializer.gen";
|
|
5
|
+
import { getUrl } from "../core/utils.gen";
|
|
6
6
|
export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
7
7
|
const querySerializer = (queryParams) => {
|
|
8
8
|
const search = [];
|
|
9
|
-
if (queryParams && typeof queryParams ===
|
|
9
|
+
if (queryParams && typeof queryParams === "object") {
|
|
10
10
|
for (const name in queryParams) {
|
|
11
11
|
const value = queryParams[name];
|
|
12
12
|
if (value === undefined || value === null) {
|
|
@@ -18,19 +18,19 @@ export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
18
18
|
allowReserved: options.allowReserved,
|
|
19
19
|
explode: true,
|
|
20
20
|
name,
|
|
21
|
-
style:
|
|
21
|
+
style: "form",
|
|
22
22
|
value,
|
|
23
23
|
...options.array,
|
|
24
24
|
});
|
|
25
25
|
if (serializedArray)
|
|
26
26
|
search.push(serializedArray);
|
|
27
27
|
}
|
|
28
|
-
else if (typeof value ===
|
|
28
|
+
else if (typeof value === "object") {
|
|
29
29
|
const serializedObject = serializeObjectParam({
|
|
30
30
|
allowReserved: options.allowReserved,
|
|
31
31
|
explode: true,
|
|
32
32
|
name,
|
|
33
|
-
style:
|
|
33
|
+
style: "deepObject",
|
|
34
34
|
value: value,
|
|
35
35
|
...options.object,
|
|
36
36
|
});
|
|
@@ -48,7 +48,7 @@ export const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
return search.join(
|
|
51
|
+
return search.join("&");
|
|
52
52
|
};
|
|
53
53
|
return querySerializer;
|
|
54
54
|
};
|
|
@@ -59,24 +59,24 @@ export const getParseAs = (contentType) => {
|
|
|
59
59
|
if (!contentType) {
|
|
60
60
|
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
61
61
|
// which is effectively the same as the 'stream' option.
|
|
62
|
-
return
|
|
62
|
+
return "stream";
|
|
63
63
|
}
|
|
64
|
-
const cleanContent = contentType.split(
|
|
64
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
65
65
|
if (!cleanContent) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
-
if (cleanContent.startsWith(
|
|
69
|
-
cleanContent.endsWith(
|
|
70
|
-
return
|
|
68
|
+
if (cleanContent.startsWith("application/json") ||
|
|
69
|
+
cleanContent.endsWith("+json")) {
|
|
70
|
+
return "json";
|
|
71
71
|
}
|
|
72
|
-
if (cleanContent ===
|
|
73
|
-
return
|
|
72
|
+
if (cleanContent === "multipart/form-data") {
|
|
73
|
+
return "formData";
|
|
74
74
|
}
|
|
75
|
-
if ([
|
|
76
|
-
return
|
|
75
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
76
|
+
return "blob";
|
|
77
77
|
}
|
|
78
|
-
if (cleanContent.startsWith(
|
|
79
|
-
return
|
|
78
|
+
if (cleanContent.startsWith("text/")) {
|
|
79
|
+
return "text";
|
|
80
80
|
}
|
|
81
81
|
return;
|
|
82
82
|
};
|
|
@@ -86,7 +86,7 @@ const checkForExistence = (options, name) => {
|
|
|
86
86
|
}
|
|
87
87
|
if (options.headers.has(name) ||
|
|
88
88
|
options.query?.[name] ||
|
|
89
|
-
options.headers.get(
|
|
89
|
+
options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
90
90
|
return true;
|
|
91
91
|
}
|
|
92
92
|
return false;
|
|
@@ -100,18 +100,18 @@ export const setAuthParams = async ({ security, ...options }) => {
|
|
|
100
100
|
if (!token) {
|
|
101
101
|
continue;
|
|
102
102
|
}
|
|
103
|
-
const name = auth.name ??
|
|
103
|
+
const name = auth.name ?? "Authorization";
|
|
104
104
|
switch (auth.in) {
|
|
105
|
-
case
|
|
105
|
+
case "query":
|
|
106
106
|
if (!options.query) {
|
|
107
107
|
options.query = {};
|
|
108
108
|
}
|
|
109
109
|
options.query[name] = token;
|
|
110
110
|
break;
|
|
111
|
-
case
|
|
112
|
-
options.headers.append(
|
|
111
|
+
case "cookie":
|
|
112
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
113
113
|
break;
|
|
114
|
-
case
|
|
114
|
+
case "header":
|
|
115
115
|
default:
|
|
116
116
|
options.headers.set(name, token);
|
|
117
117
|
break;
|
|
@@ -122,14 +122,14 @@ export const buildUrl = (options) => getUrl({
|
|
|
122
122
|
baseUrl: options.baseUrl,
|
|
123
123
|
path: options.path,
|
|
124
124
|
query: options.query,
|
|
125
|
-
querySerializer: typeof options.querySerializer ===
|
|
125
|
+
querySerializer: typeof options.querySerializer === "function"
|
|
126
126
|
? options.querySerializer
|
|
127
127
|
: createQuerySerializer(options.querySerializer),
|
|
128
128
|
url: options.url,
|
|
129
129
|
});
|
|
130
130
|
export const mergeConfigs = (a, b) => {
|
|
131
131
|
const config = { ...a, ...b };
|
|
132
|
-
if (config.baseUrl?.endsWith(
|
|
132
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
133
133
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
134
134
|
}
|
|
135
135
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
@@ -163,7 +163,7 @@ export const mergeHeaders = (...headers) => {
|
|
|
163
163
|
else if (value !== undefined) {
|
|
164
164
|
// assume object headers are meant to be JSON stringified, i.e. their
|
|
165
165
|
// content value in OpenAPI specification is 'application/json'
|
|
166
|
-
mergedHeaders.set(key, typeof value ===
|
|
166
|
+
mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -185,7 +185,7 @@ class Interceptors {
|
|
|
185
185
|
return Boolean(this.fns[index]);
|
|
186
186
|
}
|
|
187
187
|
getInterceptorIndex(id) {
|
|
188
|
-
if (typeof id ===
|
|
188
|
+
if (typeof id === "number") {
|
|
189
189
|
return this.fns[id] ? id : -1;
|
|
190
190
|
}
|
|
191
191
|
return this.fns.indexOf(id);
|
|
@@ -212,20 +212,20 @@ const defaultQuerySerializer = createQuerySerializer({
|
|
|
212
212
|
allowReserved: false,
|
|
213
213
|
array: {
|
|
214
214
|
explode: true,
|
|
215
|
-
style:
|
|
215
|
+
style: "form",
|
|
216
216
|
},
|
|
217
217
|
object: {
|
|
218
218
|
explode: true,
|
|
219
|
-
style:
|
|
219
|
+
style: "deepObject",
|
|
220
220
|
},
|
|
221
221
|
});
|
|
222
222
|
const defaultHeaders = {
|
|
223
|
-
|
|
223
|
+
"Content-Type": "application/json",
|
|
224
224
|
};
|
|
225
225
|
export const createConfig = (override = {}) => ({
|
|
226
226
|
...jsonBodySerializer,
|
|
227
227
|
headers: defaultHeaders,
|
|
228
|
-
parseAs:
|
|
228
|
+
parseAs: "auto",
|
|
229
229
|
querySerializer: defaultQuerySerializer,
|
|
230
230
|
...override,
|
|
231
231
|
});
|
package/dist/api/client.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ClientOptions, type Config } from
|
|
2
|
-
import type { ClientOptions as ClientOptions2 } from
|
|
1
|
+
import { type ClientOptions, type Config } from "./client";
|
|
2
|
+
import type { ClientOptions as ClientOptions2 } from "./types.gen";
|
|
3
3
|
/**
|
|
4
4
|
* The `createClientConfig()` function will be called on client initialization
|
|
5
5
|
* and the returned object will become the client's initial configuration.
|
package/dist/api/client.gen.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export const client = createClient(createClientConfig(createConfig({ baseUrl:
|
|
2
|
+
import { createClientConfig } from "../hey-api";
|
|
3
|
+
import { createClient, createConfig, } from "./client";
|
|
4
|
+
export const client = createClient(createClientConfig(createConfig({ baseUrl: "https://api.machines.dev/v1" })));
|
|
@@ -5,14 +5,14 @@ export interface Auth {
|
|
|
5
5
|
*
|
|
6
6
|
* @default 'header'
|
|
7
7
|
*/
|
|
8
|
-
in?:
|
|
8
|
+
in?: "header" | "query" | "cookie";
|
|
9
9
|
/**
|
|
10
10
|
* Header or query parameter name.
|
|
11
11
|
*
|
|
12
12
|
* @default 'Authorization'
|
|
13
13
|
*/
|
|
14
14
|
name?: string;
|
|
15
|
-
scheme?:
|
|
16
|
-
type:
|
|
15
|
+
scheme?: "basic" | "bearer";
|
|
16
|
+
type: "apiKey" | "http";
|
|
17
17
|
}
|
|
18
18
|
export declare const getAuthToken: (auth: Auth, callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken) => Promise<string | undefined>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
export const getAuthToken = async (auth, callback) => {
|
|
3
|
-
const token = typeof callback ===
|
|
3
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
4
4
|
if (!token) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
if (auth.scheme ===
|
|
7
|
+
if (auth.scheme === "bearer") {
|
|
8
8
|
return `Bearer ${token}`;
|
|
9
9
|
}
|
|
10
|
-
if (auth.scheme ===
|
|
10
|
+
if (auth.scheme === "basic") {
|
|
11
11
|
return `Basic ${btoa(token)}`;
|
|
12
12
|
}
|
|
13
13
|
return token;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArrayStyle, ObjectStyle, SerializerOptions } from
|
|
1
|
+
import type { ArrayStyle, ObjectStyle, SerializerOptions } from "./pathSerializer.gen";
|
|
2
2
|
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
3
3
|
export type BodySerializer = (body: any) => any;
|
|
4
4
|
type QuerySerializerOptionsObject = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
const serializeFormDataPair = (data, key, value) => {
|
|
3
|
-
if (typeof value ===
|
|
3
|
+
if (typeof value === "string" || value instanceof Blob) {
|
|
4
4
|
data.append(key, value);
|
|
5
5
|
}
|
|
6
6
|
else if (value instanceof Date) {
|
|
@@ -11,7 +11,7 @@ const serializeFormDataPair = (data, key, value) => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
const serializeUrlSearchParamsPair = (data, key, value) => {
|
|
14
|
-
if (typeof value ===
|
|
14
|
+
if (typeof value === "string") {
|
|
15
15
|
data.append(key, value);
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
@@ -36,7 +36,7 @@ export const formDataBodySerializer = {
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
export const jsonBodySerializer = {
|
|
39
|
-
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value ===
|
|
39
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value),
|
|
40
40
|
};
|
|
41
41
|
export const urlSearchParamsBodySerializer = {
|
|
42
42
|
bodySerializer: (body) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type Slot =
|
|
1
|
+
type Slot = "body" | "headers" | "path" | "query";
|
|
2
2
|
export type Field = {
|
|
3
|
-
in: Exclude<Slot,
|
|
3
|
+
in: Exclude<Slot, "body">;
|
|
4
4
|
/**
|
|
5
5
|
* Field name. This is the name we want the user to see and use.
|
|
6
6
|
*/
|
|
@@ -11,7 +11,7 @@ export type Field = {
|
|
|
11
11
|
*/
|
|
12
12
|
map?: string;
|
|
13
13
|
} | {
|
|
14
|
-
in: Extract<Slot,
|
|
14
|
+
in: Extract<Slot, "body">;
|
|
15
15
|
/**
|
|
16
16
|
* Key isn't required for bodies.
|
|
17
17
|
*/
|