@townco/fly 0.1.30 → 0.1.33
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 +2 -2
- package/dist/api/client/client.gen.js +46 -45
- 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 +7 -7
- package/dist/api/client/utils.gen.js +34 -33
- 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 +3 -3
- package/dist/api/core/bodySerializer.gen.js +3 -3
- package/dist/api/core/params.gen.d.ts +4 -4
- package/dist/api/core/params.gen.js +9 -9
- package/dist/api/core/pathSerializer.gen.d.ts +8 -8
- 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 +4 -4
- package/dist/api/core/serverSentEvents.gen.js +18 -18
- package/dist/api/core/types.gen.d.ts +4 -4
- package/dist/api/core/utils.gen.d.ts +4 -4
- 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 +5 -5
- package/dist/api/sdk.gen.js +130 -160
- package/dist/api/types.gen.d.ts +84 -84
- package/package.json +7 -7
- package/dist/client/client.gen.d.ts +0 -2
- package/dist/client/client.gen.js +0 -228
- package/dist/client/index.d.ts +0 -8
- package/dist/client/index.js +0 -6
- package/dist/client/types.gen.d.ts +0 -117
- package/dist/client/types.gen.js +0 -2
- package/dist/client/utils.gen.d.ts +0 -33
- package/dist/client/utils.gen.js +0 -231
- package/dist/client.gen.d.ts +0 -12
- package/dist/client.gen.js +0 -3
- package/dist/core/auth.gen.d.ts +0 -18
- package/dist/core/auth.gen.js +0 -14
- package/dist/core/bodySerializer.gen.d.ts +0 -25
- package/dist/core/bodySerializer.gen.js +0 -57
- package/dist/core/params.gen.d.ts +0 -43
- package/dist/core/params.gen.js +0 -100
- package/dist/core/pathSerializer.gen.d.ts +0 -33
- package/dist/core/pathSerializer.gen.js +0 -114
- package/dist/core/queryKeySerializer.gen.d.ts +0 -18
- package/dist/core/queryKeySerializer.gen.js +0 -99
- package/dist/core/serverSentEvents.gen.d.ts +0 -71
- package/dist/core/serverSentEvents.gen.js +0 -135
- package/dist/core/types.gen.d.ts +0 -78
- package/dist/core/types.gen.js +0 -2
- package/dist/core/utils.gen.d.ts +0 -19
- package/dist/core/utils.gen.js +0 -87
- package/dist/sdk.gen.d.ts +0 -379
- package/dist/sdk.gen.js +0 -557
- package/dist/types.gen.d.ts +0 -2592
- package/dist/types.gen.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Client, Config } from
|
|
2
|
-
export declare const createClient: (config?: Config) => Client;
|
|
1
|
+
import type { Client, Config } from './types.gen';
|
|
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,29 +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 'json':
|
|
110
111
|
default:
|
|
111
112
|
emptyData = {};
|
|
112
113
|
break;
|
|
113
114
|
}
|
|
114
|
-
return opts.responseStyle ===
|
|
115
|
+
return opts.responseStyle === 'data'
|
|
115
116
|
? emptyData
|
|
116
117
|
: {
|
|
117
118
|
data: emptyData,
|
|
@@ -120,22 +121,22 @@ export const createClient = (config = {}) => {
|
|
|
120
121
|
}
|
|
121
122
|
let data;
|
|
122
123
|
switch (parseAs) {
|
|
123
|
-
case
|
|
124
|
-
case
|
|
125
|
-
case
|
|
126
|
-
case
|
|
127
|
-
case
|
|
124
|
+
case 'arrayBuffer':
|
|
125
|
+
case 'blob':
|
|
126
|
+
case 'formData':
|
|
127
|
+
case 'json':
|
|
128
|
+
case 'text':
|
|
128
129
|
data = await response[parseAs]();
|
|
129
130
|
break;
|
|
130
|
-
case
|
|
131
|
-
return opts.responseStyle ===
|
|
131
|
+
case 'stream':
|
|
132
|
+
return opts.responseStyle === 'data'
|
|
132
133
|
? response.body
|
|
133
134
|
: {
|
|
134
135
|
data: response.body,
|
|
135
136
|
...result,
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
|
-
if (parseAs ===
|
|
139
|
+
if (parseAs === 'json') {
|
|
139
140
|
if (opts.responseValidator) {
|
|
140
141
|
await opts.responseValidator(data);
|
|
141
142
|
}
|
|
@@ -143,7 +144,7 @@ export const createClient = (config = {}) => {
|
|
|
143
144
|
data = await opts.responseTransformer(data);
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
|
-
return opts.responseStyle ===
|
|
147
|
+
return opts.responseStyle === 'data'
|
|
147
148
|
? data
|
|
148
149
|
: {
|
|
149
150
|
data,
|
|
@@ -170,7 +171,7 @@ export const createClient = (config = {}) => {
|
|
|
170
171
|
throw finalError;
|
|
171
172
|
}
|
|
172
173
|
// TODO: we probably want to return error and improve types
|
|
173
|
-
return opts.responseStyle ===
|
|
174
|
+
return opts.responseStyle === 'data'
|
|
174
175
|
? undefined
|
|
175
176
|
: {
|
|
176
177
|
error: finalError,
|
|
@@ -199,29 +200,29 @@ export const createClient = (config = {}) => {
|
|
|
199
200
|
};
|
|
200
201
|
return {
|
|
201
202
|
buildUrl,
|
|
202
|
-
connect: makeMethodFn(
|
|
203
|
-
delete: makeMethodFn(
|
|
204
|
-
get: makeMethodFn(
|
|
203
|
+
connect: makeMethodFn('CONNECT'),
|
|
204
|
+
delete: makeMethodFn('DELETE'),
|
|
205
|
+
get: makeMethodFn('GET'),
|
|
205
206
|
getConfig,
|
|
206
|
-
head: makeMethodFn(
|
|
207
|
+
head: makeMethodFn('HEAD'),
|
|
207
208
|
interceptors,
|
|
208
|
-
options: makeMethodFn(
|
|
209
|
-
patch: makeMethodFn(
|
|
210
|
-
post: makeMethodFn(
|
|
211
|
-
put: makeMethodFn(
|
|
209
|
+
options: makeMethodFn('OPTIONS'),
|
|
210
|
+
patch: makeMethodFn('PATCH'),
|
|
211
|
+
post: makeMethodFn('POST'),
|
|
212
|
+
put: makeMethodFn('PUT'),
|
|
212
213
|
request,
|
|
213
214
|
setConfig,
|
|
214
215
|
sse: {
|
|
215
|
-
connect: makeSseFn(
|
|
216
|
-
delete: makeSseFn(
|
|
217
|
-
get: makeSseFn(
|
|
218
|
-
head: makeSseFn(
|
|
219
|
-
options: makeSseFn(
|
|
220
|
-
patch: makeSseFn(
|
|
221
|
-
post: makeSseFn(
|
|
222
|
-
put: makeSseFn(
|
|
223
|
-
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'),
|
|
224
225
|
},
|
|
225
|
-
trace: makeMethodFn(
|
|
226
|
+
trace: makeMethodFn('TRACE'),
|
|
226
227
|
};
|
|
227
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,16 +1,16 @@
|
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
export declare const getParseAs: (contentType: string | null) =>
|
|
8
|
-
export declare const setAuthParams: ({ security, ...options }: Pick<Required<RequestOptions
|
|
7
|
+
export declare const getParseAs: (contentType: string | null) => "arrayBuffer" | "blob" | "formData" | "json" | "stream" | "text" | undefined;
|
|
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[
|
|
12
|
-
export declare const mergeConfigs: (a: Config
|
|
13
|
-
export declare const mergeHeaders: (...headers:
|
|
11
|
+
export declare const buildUrl: Client['buildUrl'];
|
|
12
|
+
export declare const mergeConfigs: (a: Config<ClientOptions>, b: Config<ClientOptions>) => Config<ClientOptions>;
|
|
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>;
|
|
15
15
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
16
16
|
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
@@ -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,17 +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 'header':
|
|
114
115
|
default:
|
|
115
116
|
options.headers.set(name, token);
|
|
116
117
|
break;
|
|
@@ -121,14 +122,14 @@ export const buildUrl = (options) => getUrl({
|
|
|
121
122
|
baseUrl: options.baseUrl,
|
|
122
123
|
path: options.path,
|
|
123
124
|
query: options.query,
|
|
124
|
-
querySerializer: typeof options.querySerializer ===
|
|
125
|
+
querySerializer: typeof options.querySerializer === 'function'
|
|
125
126
|
? options.querySerializer
|
|
126
127
|
: createQuerySerializer(options.querySerializer),
|
|
127
128
|
url: options.url,
|
|
128
129
|
});
|
|
129
130
|
export const mergeConfigs = (a, b) => {
|
|
130
131
|
const config = { ...a, ...b };
|
|
131
|
-
if (config.baseUrl?.endsWith(
|
|
132
|
+
if (config.baseUrl?.endsWith('/')) {
|
|
132
133
|
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
133
134
|
}
|
|
134
135
|
config.headers = mergeHeaders(a.headers, b.headers);
|
|
@@ -162,7 +163,7 @@ export const mergeHeaders = (...headers) => {
|
|
|
162
163
|
else if (value !== undefined) {
|
|
163
164
|
// assume object headers are meant to be JSON stringified, i.e. their
|
|
164
165
|
// content value in OpenAPI specification is 'application/json'
|
|
165
|
-
mergedHeaders.set(key, typeof value ===
|
|
166
|
+
mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
|
|
166
167
|
}
|
|
167
168
|
}
|
|
168
169
|
}
|
|
@@ -184,7 +185,7 @@ class Interceptors {
|
|
|
184
185
|
return Boolean(this.fns[index]);
|
|
185
186
|
}
|
|
186
187
|
getInterceptorIndex(id) {
|
|
187
|
-
if (typeof id ===
|
|
188
|
+
if (typeof id === 'number') {
|
|
188
189
|
return this.fns[id] ? id : -1;
|
|
189
190
|
}
|
|
190
191
|
return this.fns.indexOf(id);
|
|
@@ -211,20 +212,20 @@ const defaultQuerySerializer = createQuerySerializer({
|
|
|
211
212
|
allowReserved: false,
|
|
212
213
|
array: {
|
|
213
214
|
explode: true,
|
|
214
|
-
style:
|
|
215
|
+
style: 'form',
|
|
215
216
|
},
|
|
216
217
|
object: {
|
|
217
218
|
explode: true,
|
|
218
|
-
style:
|
|
219
|
+
style: 'deepObject',
|
|
219
220
|
},
|
|
220
221
|
});
|
|
221
222
|
const defaultHeaders = {
|
|
222
|
-
|
|
223
|
+
'Content-Type': 'application/json',
|
|
223
224
|
};
|
|
224
225
|
export const createConfig = (override = {}) => ({
|
|
225
226
|
...jsonBodySerializer,
|
|
226
227
|
headers: defaultHeaders,
|
|
227
|
-
parseAs:
|
|
228
|
+
parseAs: 'auto',
|
|
228
229
|
querySerializer: defaultQuerySerializer,
|
|
229
230
|
...override,
|
|
230
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 { createClient, createConfig } from './client';
|
|
3
|
+
import { createClientConfig } from '../hey-api';
|
|
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 = {
|
|
@@ -14,12 +14,12 @@ export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
|
14
14
|
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
15
15
|
};
|
|
16
16
|
export declare const formDataBodySerializer: {
|
|
17
|
-
bodySerializer: <T extends Record<string, any> |
|
|
17
|
+
bodySerializer: <T extends Record<string, any>[] | Record<string, any>>(body: T) => FormData;
|
|
18
18
|
};
|
|
19
19
|
export declare const jsonBodySerializer: {
|
|
20
20
|
bodySerializer: <T>(body: T) => string;
|
|
21
21
|
};
|
|
22
22
|
export declare const urlSearchParamsBodySerializer: {
|
|
23
|
-
bodySerializer: <T extends Record<string, any> |
|
|
23
|
+
bodySerializer: <T extends Record<string, any>[] | Record<string, any>>(body: T) => string;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
|
@@ -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
|
*/
|
|
@@ -39,5 +39,5 @@ interface Params {
|
|
|
39
39
|
path: Record<string, unknown>;
|
|
40
40
|
query: Record<string, unknown>;
|
|
41
41
|
}
|
|
42
|
-
export declare const buildClientParams: (args:
|
|
42
|
+
export declare const buildClientParams: (args: readonly unknown[], fields: FieldsConfig) => Params;
|
|
43
43
|
export {};
|