waldur-js-client 8.0.9-dev.31 → 8.0.9-dev.32
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/{client.d.ts → client.gen.d.ts} +1 -1
- package/dist/client/client.gen.js +216 -0
- package/dist/client/index.d.ts +8 -7
- package/dist/client/index.js +6 -4
- package/dist/client/{types.d.ts → types.gen.d.ts} +22 -21
- package/dist/client/types.gen.js +2 -0
- package/dist/client/{utils.d.ts → utils.gen.d.ts} +16 -24
- package/dist/client/{utils.js → utils.gen.js} +65 -121
- package/dist/client.gen.d.ts +3 -3
- package/dist/core/{auth.js → auth.gen.js} +1 -0
- package/dist/core/bodySerializer.gen.d.ts +25 -0
- package/dist/core/{bodySerializer.js → bodySerializer.gen.js} +5 -1
- package/dist/core/{params.d.ts → params.gen.d.ts} +20 -0
- package/dist/core/{params.js → params.gen.js} +23 -10
- package/dist/core/{pathSerializer.js → pathSerializer.gen.js} +4 -11
- package/dist/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/core/queryKeySerializer.gen.js +92 -0
- package/dist/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/core/serverSentEvents.gen.js +132 -0
- package/dist/core/{types.d.ts → types.gen.d.ts} +20 -15
- 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/index.d.ts +2 -2
- package/dist/index.js +1 -2
- package/dist/sdk.gen.d.ts +1060 -3
- package/dist/sdk.gen.js +28375 -55513
- package/dist/types.gen.d.ts +234 -165
- package/package.json +1 -1
- package/dist/client/client.js +0 -143
- package/dist/client/types.js +0 -1
- package/dist/core/bodySerializer.d.ts +0 -17
- package/dist/core/types.js +0 -1
- /package/dist/core/{auth.d.ts → auth.gen.d.ts} +0 -0
- /package/dist/core/{pathSerializer.d.ts → pathSerializer.gen.d.ts} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Client, Config } from './types';
|
|
1
|
+
import type { Client, Config } from './types.gen';
|
|
2
2
|
export declare const createClient: (config?: Config) => Client;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
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
|
+
export const createClient = (config = {}) => {
|
|
6
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
7
|
+
const getConfig = () => ({ ..._config });
|
|
8
|
+
const setConfig = (config) => {
|
|
9
|
+
_config = mergeConfigs(_config, config);
|
|
10
|
+
return getConfig();
|
|
11
|
+
};
|
|
12
|
+
const interceptors = createInterceptors();
|
|
13
|
+
const beforeRequest = async (options) => {
|
|
14
|
+
const opts = {
|
|
15
|
+
..._config,
|
|
16
|
+
...options,
|
|
17
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
18
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
19
|
+
serializedBody: undefined,
|
|
20
|
+
};
|
|
21
|
+
if (opts.security) {
|
|
22
|
+
await setAuthParams(opts);
|
|
23
|
+
}
|
|
24
|
+
if (opts.requestValidator) {
|
|
25
|
+
await opts.requestValidator(opts);
|
|
26
|
+
}
|
|
27
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
28
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
29
|
+
}
|
|
30
|
+
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
31
|
+
if (opts.body === undefined || opts.serializedBody === '') {
|
|
32
|
+
opts.headers.delete('Content-Type');
|
|
33
|
+
}
|
|
34
|
+
const resolvedOpts = opts;
|
|
35
|
+
const url = buildUrl(resolvedOpts);
|
|
36
|
+
return { opts: resolvedOpts, url };
|
|
37
|
+
};
|
|
38
|
+
const request = async (options) => {
|
|
39
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
40
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
41
|
+
let request;
|
|
42
|
+
let response;
|
|
43
|
+
try {
|
|
44
|
+
const { opts, url } = await beforeRequest(options);
|
|
45
|
+
const requestInit = {
|
|
46
|
+
redirect: 'follow',
|
|
47
|
+
...opts,
|
|
48
|
+
body: getValidRequestBody(opts),
|
|
49
|
+
};
|
|
50
|
+
request = new Request(url, requestInit);
|
|
51
|
+
for (const fn of interceptors.request.fns) {
|
|
52
|
+
if (fn) {
|
|
53
|
+
request = await fn(request, opts);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
57
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
58
|
+
const _fetch = opts.fetch;
|
|
59
|
+
response = await _fetch(request);
|
|
60
|
+
for (const fn of interceptors.response.fns) {
|
|
61
|
+
if (fn) {
|
|
62
|
+
response = await fn(response, request, opts);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const result = {
|
|
66
|
+
request,
|
|
67
|
+
response,
|
|
68
|
+
};
|
|
69
|
+
if (response.ok) {
|
|
70
|
+
const parseAs = (opts.parseAs === 'auto'
|
|
71
|
+
? getParseAs(response.headers.get('Content-Type'))
|
|
72
|
+
: opts.parseAs) ?? 'json';
|
|
73
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
74
|
+
let emptyData;
|
|
75
|
+
switch (parseAs) {
|
|
76
|
+
case 'arrayBuffer':
|
|
77
|
+
case 'blob':
|
|
78
|
+
case 'text':
|
|
79
|
+
emptyData = await response[parseAs]();
|
|
80
|
+
break;
|
|
81
|
+
case 'formData':
|
|
82
|
+
emptyData = new FormData();
|
|
83
|
+
break;
|
|
84
|
+
case 'stream':
|
|
85
|
+
emptyData = response.body;
|
|
86
|
+
break;
|
|
87
|
+
case 'json':
|
|
88
|
+
default:
|
|
89
|
+
emptyData = {};
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
return opts.responseStyle === 'data'
|
|
93
|
+
? emptyData
|
|
94
|
+
: {
|
|
95
|
+
data: emptyData,
|
|
96
|
+
...result,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
let data;
|
|
100
|
+
switch (parseAs) {
|
|
101
|
+
case 'arrayBuffer':
|
|
102
|
+
case 'blob':
|
|
103
|
+
case 'formData':
|
|
104
|
+
case 'text':
|
|
105
|
+
data = await response[parseAs]();
|
|
106
|
+
break;
|
|
107
|
+
case 'json': {
|
|
108
|
+
// Some servers return 200 with no Content-Length and empty body.
|
|
109
|
+
// response.json() would throw; read as text and parse if non-empty.
|
|
110
|
+
const text = await response.text();
|
|
111
|
+
data = text ? JSON.parse(text) : {};
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
case 'stream':
|
|
115
|
+
return opts.responseStyle === 'data'
|
|
116
|
+
? response.body
|
|
117
|
+
: {
|
|
118
|
+
data: response.body,
|
|
119
|
+
...result,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (parseAs === 'json') {
|
|
123
|
+
if (opts.responseValidator) {
|
|
124
|
+
await opts.responseValidator(data);
|
|
125
|
+
}
|
|
126
|
+
if (opts.responseTransformer) {
|
|
127
|
+
data = await opts.responseTransformer(data);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return opts.responseStyle === 'data'
|
|
131
|
+
? data
|
|
132
|
+
: {
|
|
133
|
+
data,
|
|
134
|
+
...result,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const textError = await response.text();
|
|
138
|
+
let jsonError;
|
|
139
|
+
try {
|
|
140
|
+
jsonError = JSON.parse(textError);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// noop
|
|
144
|
+
}
|
|
145
|
+
throw jsonError ?? textError;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
let finalError = error;
|
|
149
|
+
for (const fn of interceptors.error.fns) {
|
|
150
|
+
if (fn) {
|
|
151
|
+
finalError = await fn(finalError, response, request, options);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
finalError = finalError || {};
|
|
155
|
+
if (throwOnError) {
|
|
156
|
+
throw finalError;
|
|
157
|
+
}
|
|
158
|
+
// TODO: we probably want to return error and improve types
|
|
159
|
+
return responseStyle === 'data'
|
|
160
|
+
? undefined
|
|
161
|
+
: {
|
|
162
|
+
error: finalError,
|
|
163
|
+
request,
|
|
164
|
+
response,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
169
|
+
const makeSseFn = (method) => async (options) => {
|
|
170
|
+
const { opts, url } = await beforeRequest(options);
|
|
171
|
+
return createSseClient({
|
|
172
|
+
...opts,
|
|
173
|
+
body: opts.body,
|
|
174
|
+
method,
|
|
175
|
+
onRequest: async (url, init) => {
|
|
176
|
+
let request = new Request(url, init);
|
|
177
|
+
for (const fn of interceptors.request.fns) {
|
|
178
|
+
if (fn) {
|
|
179
|
+
request = await fn(request, opts);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return request;
|
|
183
|
+
},
|
|
184
|
+
serializedBody: getValidRequestBody(opts),
|
|
185
|
+
url,
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
189
|
+
return {
|
|
190
|
+
buildUrl: _buildUrl,
|
|
191
|
+
connect: makeMethodFn('CONNECT'),
|
|
192
|
+
delete: makeMethodFn('DELETE'),
|
|
193
|
+
get: makeMethodFn('GET'),
|
|
194
|
+
getConfig,
|
|
195
|
+
head: makeMethodFn('HEAD'),
|
|
196
|
+
interceptors,
|
|
197
|
+
options: makeMethodFn('OPTIONS'),
|
|
198
|
+
patch: makeMethodFn('PATCH'),
|
|
199
|
+
post: makeMethodFn('POST'),
|
|
200
|
+
put: makeMethodFn('PUT'),
|
|
201
|
+
request,
|
|
202
|
+
setConfig,
|
|
203
|
+
sse: {
|
|
204
|
+
connect: makeSseFn('CONNECT'),
|
|
205
|
+
delete: makeSseFn('DELETE'),
|
|
206
|
+
get: makeSseFn('GET'),
|
|
207
|
+
head: makeSseFn('HEAD'),
|
|
208
|
+
options: makeSseFn('OPTIONS'),
|
|
209
|
+
patch: makeSseFn('PATCH'),
|
|
210
|
+
post: makeSseFn('POST'),
|
|
211
|
+
put: makeSseFn('PUT'),
|
|
212
|
+
trace: makeSseFn('TRACE'),
|
|
213
|
+
},
|
|
214
|
+
trace: makeMethodFn('TRACE'),
|
|
215
|
+
};
|
|
216
|
+
};
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export type { Auth } from '../core/auth';
|
|
2
|
-
export type { QuerySerializerOptions } from '../core/bodySerializer';
|
|
3
|
-
export { formDataBodySerializer, jsonBodySerializer, urlSearchParamsBodySerializer, } from '../core/bodySerializer';
|
|
4
|
-
export { buildClientParams } from '../core/params';
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
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/client/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
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,6 +1,7 @@
|
|
|
1
|
-
import type { Auth } from '../core/auth';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
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';
|
|
4
5
|
export type ResponseStyle = 'data' | 'fields';
|
|
5
6
|
export interface Config<T extends ClientOptions = ClientOptions> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
|
6
7
|
/**
|
|
@@ -13,7 +14,7 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
|
|
|
13
14
|
*
|
|
14
15
|
* @default globalThis.fetch
|
|
15
16
|
*/
|
|
16
|
-
fetch?:
|
|
17
|
+
fetch?: typeof fetch;
|
|
17
18
|
/**
|
|
18
19
|
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
19
20
|
* options won't have any effect.
|
|
@@ -43,10 +44,10 @@ export interface Config<T extends ClientOptions = ClientOptions> extends Omit<Re
|
|
|
43
44
|
*/
|
|
44
45
|
throwOnError?: T['throwOnError'];
|
|
45
46
|
}
|
|
46
|
-
export interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
47
|
+
export interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
47
48
|
responseStyle: TResponseStyle;
|
|
48
49
|
throwOnError: ThrowOnError;
|
|
49
|
-
}> {
|
|
50
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
50
51
|
/**
|
|
51
52
|
* Any body that you want to add to your request.
|
|
52
53
|
*
|
|
@@ -61,6 +62,10 @@ export interface RequestOptions<TResponseStyle extends ResponseStyle = 'fields',
|
|
|
61
62
|
security?: ReadonlyArray<Auth>;
|
|
62
63
|
url: Url;
|
|
63
64
|
}
|
|
65
|
+
export interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
66
|
+
headers: Headers;
|
|
67
|
+
serializedBody?: string;
|
|
68
|
+
}
|
|
64
69
|
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 : {
|
|
65
70
|
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
66
71
|
request: Request;
|
|
@@ -72,24 +77,27 @@ export type RequestResult<TData = unknown, TError = unknown, ThrowOnError extend
|
|
|
72
77
|
data: undefined;
|
|
73
78
|
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
74
79
|
}) & {
|
|
75
|
-
request
|
|
76
|
-
|
|
80
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
81
|
+
request?: Request;
|
|
82
|
+
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
|
83
|
+
response?: Response;
|
|
77
84
|
}>;
|
|
78
85
|
export interface ClientOptions {
|
|
79
86
|
baseUrl?: string;
|
|
80
87
|
responseStyle?: ResponseStyle;
|
|
81
88
|
throwOnError?: boolean;
|
|
82
89
|
}
|
|
83
|
-
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
84
|
-
type
|
|
90
|
+
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>;
|
|
91
|
+
type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
|
|
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>;
|
|
85
93
|
type BuildUrlFn = <TData extends {
|
|
86
94
|
body?: unknown;
|
|
87
95
|
path?: Record<string, unknown>;
|
|
88
96
|
query?: Record<string, unknown>;
|
|
89
97
|
url: string;
|
|
90
|
-
}>(options:
|
|
91
|
-
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn> & {
|
|
92
|
-
interceptors: Middleware<Request, Response, unknown,
|
|
98
|
+
}>(options: TData & Options<TData>) => string;
|
|
99
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
100
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
93
101
|
};
|
|
94
102
|
/**
|
|
95
103
|
* The `createClientConfig()` function will be called on client initialization
|
|
@@ -108,12 +116,5 @@ export interface TDataShape {
|
|
|
108
116
|
url: string;
|
|
109
117
|
}
|
|
110
118
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
111
|
-
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & Omit<TData, 'url'
|
|
112
|
-
export type OptionsLegacyParser<TData = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = TData extends {
|
|
113
|
-
body?: any;
|
|
114
|
-
} ? TData extends {
|
|
115
|
-
headers?: any;
|
|
116
|
-
} ? OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'headers' | 'url'> & TData : OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'body' | 'url'> & TData & Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'headers'> : TData extends {
|
|
117
|
-
headers?: any;
|
|
118
|
-
} ? OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'headers' | 'url'> & TData & Pick<RequestOptions<TResponseStyle, ThrowOnError>, 'body'> : OmitKeys<RequestOptions<TResponseStyle, ThrowOnError>, 'url'> & TData;
|
|
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'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
119
120
|
export {};
|
|
@@ -1,45 +1,37 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Client, ClientOptions, Config, RequestOptions } from './types';
|
|
3
|
-
export declare const createQuerySerializer: <T = unknown>({
|
|
1
|
+
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
2
|
+
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
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
7
|
export declare const getParseAs: (contentType: string | null) => Exclude<Config["parseAs"], "auto">;
|
|
8
|
-
export declare
|
|
8
|
+
export declare function setAuthParams(options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
|
|
9
9
|
headers: Headers;
|
|
10
|
-
})
|
|
10
|
+
}): Promise<void>;
|
|
11
11
|
export declare const buildUrl: Client['buildUrl'];
|
|
12
|
-
export declare const getUrl: ({ baseUrl, path, query, querySerializer, url: _url, }: {
|
|
13
|
-
baseUrl?: string;
|
|
14
|
-
path?: Record<string, unknown>;
|
|
15
|
-
query?: Record<string, unknown>;
|
|
16
|
-
querySerializer: QuerySerializer;
|
|
17
|
-
url: string;
|
|
18
|
-
}) => string;
|
|
19
12
|
export declare const mergeConfigs: (a: Config, b: Config) => Config;
|
|
20
13
|
export declare const mergeHeaders: (...headers: Array<Required<Config>["headers"] | undefined>) => Headers;
|
|
21
|
-
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
|
|
14
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
|
|
15
|
+
/** response may be undefined due to a network error where no response object is produced */
|
|
16
|
+
response: Res | undefined,
|
|
17
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
18
|
+
request: Req | undefined, options: Options) => Err | Promise<Err>;
|
|
22
19
|
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
23
20
|
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
24
21
|
declare class Interceptors<Interceptor> {
|
|
25
|
-
|
|
26
|
-
constructor();
|
|
22
|
+
fns: Array<Interceptor | null>;
|
|
27
23
|
clear(): void;
|
|
28
|
-
getInterceptorIndex(id: number | Interceptor): number;
|
|
29
|
-
exists(id: number | Interceptor): boolean;
|
|
30
24
|
eject(id: number | Interceptor): void;
|
|
31
|
-
|
|
25
|
+
exists(id: number | Interceptor): boolean;
|
|
26
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
27
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
32
28
|
use(fn: Interceptor): number;
|
|
33
29
|
}
|
|
34
30
|
export interface Middleware<Req, Res, Err, Options> {
|
|
35
|
-
error: Pick<Interceptors<ErrInterceptor<Err, Res, Req, Options>>, 'eject' | 'use'>;
|
|
36
|
-
request: Pick<Interceptors<ReqInterceptor<Req, Options>>, 'eject' | 'use'>;
|
|
37
|
-
response: Pick<Interceptors<ResInterceptor<Res, Req, Options>>, 'eject' | 'use'>;
|
|
38
|
-
}
|
|
39
|
-
export declare const createInterceptors: <Req, Res, Err, Options>() => {
|
|
40
31
|
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
41
32
|
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
42
33
|
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
43
|
-
}
|
|
34
|
+
}
|
|
35
|
+
export declare const createInterceptors: <Req, Res, Err, Options>() => Middleware<Req, Res, Err, Options>;
|
|
44
36
|
export declare const createConfig: <T extends ClientOptions = ClientOptions>(override?: Config<Omit<ClientOptions, keyof T> & T>) => Config<Omit<ClientOptions, keyof T> & T>;
|
|
45
37
|
export {};
|