tanstack-fetch 1.0.0 → 1.0.2
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/README.md +134 -3
- package/dist/cli.js +22 -239
- package/dist/client.type-BBYqVrTM.d.cts +156 -0
- package/dist/client.type-Btgj3NQn.d.ts +156 -0
- package/dist/config.type-eG_cuxpu.d.cts +132 -0
- package/dist/config.type-eG_cuxpu.d.ts +132 -0
- package/dist/index.cjs +2 -881
- package/dist/index.d.cts +23 -17
- package/dist/index.d.ts +23 -17
- package/dist/index.js +2 -3
- package/dist/plugins.cjs +1 -0
- package/dist/plugins.d.cts +19 -0
- package/dist/plugins.d.ts +19 -0
- package/dist/plugins.js +1 -0
- package/dist/react.cjs +1 -951
- package/dist/react.d.cts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +1 -91
- package/dist/sse.cjs +7 -0
- package/dist/sse.d.cts +9 -0
- package/dist/sse.d.ts +9 -0
- package/dist/sse.js +7 -0
- package/package.json +19 -6
- package/dist/chunk-T27KPHCL.js +0 -867
- package/dist/chunk-T27KPHCL.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/fetch-error-B10Od9AT.d.cts +0 -257
- package/dist/fetch-error-B10Od9AT.d.ts +0 -257
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.js.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { M as MaybePromise, C as ClientSource, I as IncomingHeaders, b as HttpInterceptor, P as PluginName, A as AuthConfig, S as StatusHandler, g as StatusHandlers, c as HttpMethod, h as PathParams, Q as QueryParams, a as FetchErrorInfo, F as FetchResult } from './config.type-eG_cuxpu.js';
|
|
2
|
+
|
|
3
|
+
type SseEvent<T = unknown> = {
|
|
4
|
+
event?: string;
|
|
5
|
+
data: T;
|
|
6
|
+
id?: string;
|
|
7
|
+
retry?: number;
|
|
8
|
+
};
|
|
9
|
+
type SseSubscription = {
|
|
10
|
+
/** Stop the stream. */
|
|
11
|
+
close: () => void;
|
|
12
|
+
};
|
|
13
|
+
type SseHandlers<T = unknown> = {
|
|
14
|
+
/** Simple path — only the payload. */
|
|
15
|
+
onMessage?: (data: T, event: SseEvent<T>) => void;
|
|
16
|
+
/** Full SSE event (`event`, `data`, `id`). */
|
|
17
|
+
onEvent?: (event: SseEvent<T>) => void;
|
|
18
|
+
onOpen?: () => void;
|
|
19
|
+
onError?: (error: unknown) => void;
|
|
20
|
+
onClose?: () => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type UploadProgressEvent = {
|
|
24
|
+
loaded: number;
|
|
25
|
+
total?: number;
|
|
26
|
+
/** `loaded / total` when `total` is known (0–1). */
|
|
27
|
+
progress?: number;
|
|
28
|
+
};
|
|
29
|
+
type UploadProgressHandler = (event: UploadProgressEvent) => void;
|
|
30
|
+
type FormDataPrimitive = string | number | boolean | Blob;
|
|
31
|
+
type FormDataFieldValue = FormDataPrimitive | null | undefined | FormDataPrimitive[];
|
|
32
|
+
type FormDataFields = Record<string, FormDataFieldValue>;
|
|
33
|
+
type UploadBody = FormData | Blob | ArrayBuffer | URLSearchParams | string;
|
|
34
|
+
type UploadOptions = {
|
|
35
|
+
/** Pre-built body (`FormData`, `Blob`, `File`, …). */
|
|
36
|
+
body?: UploadBody;
|
|
37
|
+
/** Single file — appended as `fieldName` (default `"file"`). */
|
|
38
|
+
file?: Blob;
|
|
39
|
+
/** Multiple files — same field name repeated. */
|
|
40
|
+
files?: Blob[];
|
|
41
|
+
/** Extra multipart fields (strings, numbers, Blobs). */
|
|
42
|
+
fields?: FormDataFields;
|
|
43
|
+
/** Form field name for `file` / `files`. Default `"file"`. */
|
|
44
|
+
fieldName?: string;
|
|
45
|
+
/** HTTP method. Default `POST`. */
|
|
46
|
+
method?: 'POST' | 'PUT' | 'PATCH';
|
|
47
|
+
onUploadProgress?: UploadProgressHandler;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type RequestInterceptorConfig = {
|
|
51
|
+
use?: HttpInterceptor[];
|
|
52
|
+
eject?: string[];
|
|
53
|
+
};
|
|
54
|
+
type RequestOptions = {
|
|
55
|
+
params?: PathParams;
|
|
56
|
+
query?: QueryParams;
|
|
57
|
+
body?: unknown;
|
|
58
|
+
headers?: HeadersInit;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
/** Default `true` — matches TanStack Query `queryFn` (throw on HTTP error). */
|
|
62
|
+
throwOnError?: boolean;
|
|
63
|
+
parseAs?: 'json' | 'text' | 'blob';
|
|
64
|
+
operation?: string;
|
|
65
|
+
interceptors?: RequestInterceptorConfig;
|
|
66
|
+
/** Browser-only — uses XHR under the hood when set (fetch has no upload progress). */
|
|
67
|
+
onUploadProgress?: UploadProgressHandler;
|
|
68
|
+
};
|
|
69
|
+
type CreateFetchOptions = {
|
|
70
|
+
baseUrl?: string;
|
|
71
|
+
headers?: HeadersInit | (() => MaybePromise<HeadersInit>);
|
|
72
|
+
source?: ClientSource;
|
|
73
|
+
incoming?: IncomingHeaders | (() => MaybePromise<IncomingHeaders>);
|
|
74
|
+
timeoutMs?: number;
|
|
75
|
+
/** Default `true` for TanStack Query. Set `false` to get `FetchResult`. */
|
|
76
|
+
throwOnError?: boolean;
|
|
77
|
+
interceptors?: HttpInterceptor[];
|
|
78
|
+
plugins?: PluginName[];
|
|
79
|
+
fetch?: typeof fetch;
|
|
80
|
+
credentials?: RequestCredentials;
|
|
81
|
+
maxRetries?: number;
|
|
82
|
+
/** Simple auth: attach Bearer token on every request. */
|
|
83
|
+
getToken?: () => MaybePromise<string | null | undefined>;
|
|
84
|
+
/** Advanced auth config (overrides `getToken` when both set via `auth`). */
|
|
85
|
+
auth?: AuthConfig;
|
|
86
|
+
/** Called on HTTP 401 before the error is thrown / returned. */
|
|
87
|
+
onUnauthorized?: StatusHandler;
|
|
88
|
+
/** Called on HTTP 403. */
|
|
89
|
+
onForbidden?: StatusHandler;
|
|
90
|
+
/** Called on HTTP 404. */
|
|
91
|
+
onNotFound?: StatusHandler;
|
|
92
|
+
/** Called on HTTP 5xx (500–599). */
|
|
93
|
+
onServerError?: StatusHandler;
|
|
94
|
+
/** Advanced per-status map (`401`, `403`, `4xx`, `5xx`, `default`, …). */
|
|
95
|
+
onStatus?: StatusHandlers;
|
|
96
|
+
};
|
|
97
|
+
type ThrowingOptions = Omit<RequestOptions, 'throwOnError'> & {
|
|
98
|
+
throwOnError?: true;
|
|
99
|
+
};
|
|
100
|
+
type ResultOptions = Omit<RequestOptions, 'throwOnError'> & {
|
|
101
|
+
throwOnError: false;
|
|
102
|
+
};
|
|
103
|
+
type FetchMethod = {
|
|
104
|
+
<T>(path: string, options?: ThrowingOptions): Promise<T>;
|
|
105
|
+
<T, E = FetchErrorInfo>(path: string, options: ResultOptions): Promise<FetchResult<T, E>>;
|
|
106
|
+
};
|
|
107
|
+
type FetchRequest = {
|
|
108
|
+
<T>(method: HttpMethod, path: string, options?: ThrowingOptions): Promise<T>;
|
|
109
|
+
<T, E = FetchErrorInfo>(method: HttpMethod, path: string, options: ResultOptions): Promise<FetchResult<T, E>>;
|
|
110
|
+
};
|
|
111
|
+
type UploadCallOptions = Omit<RequestOptions, 'body' | 'onUploadProgress'> & UploadOptions;
|
|
112
|
+
type UploadMethod = {
|
|
113
|
+
<T>(path: string, options?: UploadCallOptions & {
|
|
114
|
+
throwOnError?: true;
|
|
115
|
+
}): Promise<T>;
|
|
116
|
+
<T, E = FetchErrorInfo>(path: string, options: UploadCallOptions & {
|
|
117
|
+
throwOnError: false;
|
|
118
|
+
}): Promise<FetchResult<T, E>>;
|
|
119
|
+
};
|
|
120
|
+
type SseCallOptions<T = unknown> = RequestOptions & SseHandlers<T> & {
|
|
121
|
+
lastEventId?: string;
|
|
122
|
+
};
|
|
123
|
+
type FetchClient = {
|
|
124
|
+
use: (name: string, interceptor: Omit<HttpInterceptor, 'name'> & {
|
|
125
|
+
name?: string;
|
|
126
|
+
}, config?: {
|
|
127
|
+
order?: number;
|
|
128
|
+
}) => void;
|
|
129
|
+
eject: (name: string) => void;
|
|
130
|
+
request: FetchRequest;
|
|
131
|
+
get: FetchMethod;
|
|
132
|
+
post: FetchMethod;
|
|
133
|
+
put: FetchMethod;
|
|
134
|
+
patch: FetchMethod;
|
|
135
|
+
delete: FetchMethod;
|
|
136
|
+
/** Multipart / file upload — returns the same typed response body as `post`. */
|
|
137
|
+
upload: UploadMethod;
|
|
138
|
+
/**
|
|
139
|
+
* Simple: pass `onMessage` / `onEvent` → returns `{ close }`.
|
|
140
|
+
* Advanced: no handlers → `AsyncIterable` for `for await`.
|
|
141
|
+
*/
|
|
142
|
+
sse: {
|
|
143
|
+
<T>(path: string, options: SseCallOptions<T> & ({
|
|
144
|
+
onMessage: SseHandlers<T>['onMessage'];
|
|
145
|
+
} | {
|
|
146
|
+
onEvent: SseHandlers<T>['onEvent'];
|
|
147
|
+
})): SseSubscription;
|
|
148
|
+
<T>(path: string, options?: SseCallOptions<T>): AsyncIterable<SseEvent<T>>;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
/** @deprecated Use CreateFetchOptions */
|
|
152
|
+
type CreateClientOptions = CreateFetchOptions;
|
|
153
|
+
/** @deprecated Use FetchClient */
|
|
154
|
+
type HttpClient = FetchClient;
|
|
155
|
+
|
|
156
|
+
export type { CreateFetchOptions as C, FetchClient as F, HttpClient as H, RequestOptions as R, SseCallOptions as S, UploadCallOptions as U, FormDataFields as a, CreateClientOptions as b, FormDataFieldValue as c, SseEvent as d, SseHandlers as e, SseSubscription as f, UploadOptions as g, UploadProgressEvent as h, UploadProgressHandler as i };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
2
|
+
type ClientSource = 'browser' | 'ssr' | 'edge';
|
|
3
|
+
type IncomingHeaders = {
|
|
4
|
+
cookie?: string;
|
|
5
|
+
authorization?: string;
|
|
6
|
+
requestId?: string;
|
|
7
|
+
};
|
|
8
|
+
type PathParams = Record<string, string | number>;
|
|
9
|
+
type QueryParams = Record<string, string | number | boolean | undefined | null>;
|
|
10
|
+
type PluginName = 'trace' | 'ssr-forward' | 'retry-idempotent' | 'sse-resume';
|
|
11
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
12
|
+
|
|
13
|
+
type OkResult<T> = {
|
|
14
|
+
ok: true;
|
|
15
|
+
status: number;
|
|
16
|
+
data: T;
|
|
17
|
+
headers: Headers;
|
|
18
|
+
};
|
|
19
|
+
type ErrResult<E> = {
|
|
20
|
+
ok: false;
|
|
21
|
+
status: number;
|
|
22
|
+
error: E;
|
|
23
|
+
headers: Headers;
|
|
24
|
+
};
|
|
25
|
+
type FetchResult<T, E = FetchErrorInfo> = OkResult<T> | ErrResult<E>;
|
|
26
|
+
type FetchErrorInfo = {
|
|
27
|
+
status: number;
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
body: unknown;
|
|
31
|
+
};
|
|
32
|
+
/** @deprecated Use FetchResult */
|
|
33
|
+
type HttpResult<T, E = FetchErrorInfo> = FetchResult<T, E>;
|
|
34
|
+
/** @deprecated Use FetchErrorInfo */
|
|
35
|
+
type HttpError = FetchErrorInfo;
|
|
36
|
+
|
|
37
|
+
type RequestContext = {
|
|
38
|
+
request: {
|
|
39
|
+
method: HttpMethod;
|
|
40
|
+
url: URL;
|
|
41
|
+
headers: Headers;
|
|
42
|
+
body?: unknown;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
};
|
|
45
|
+
response?: Response;
|
|
46
|
+
data?: unknown;
|
|
47
|
+
error?: FetchErrorInfo;
|
|
48
|
+
incoming?: IncomingHeaders;
|
|
49
|
+
meta: {
|
|
50
|
+
attempt: number;
|
|
51
|
+
maxRetries: number;
|
|
52
|
+
source: ClientSource;
|
|
53
|
+
operation?: string;
|
|
54
|
+
requestId?: string;
|
|
55
|
+
lastEventId?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
type SseEventContext<T = unknown> = RequestContext & {
|
|
59
|
+
event: {
|
|
60
|
+
event?: string;
|
|
61
|
+
data: T;
|
|
62
|
+
id?: string;
|
|
63
|
+
retry?: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type InterceptorDecision<T> = {
|
|
67
|
+
action: 'continue';
|
|
68
|
+
context?: T;
|
|
69
|
+
} | {
|
|
70
|
+
action: 'skip';
|
|
71
|
+
} | {
|
|
72
|
+
action: 'drop';
|
|
73
|
+
} | {
|
|
74
|
+
action: 'retry';
|
|
75
|
+
delayMs?: number;
|
|
76
|
+
} | {
|
|
77
|
+
action: 'short-circuit';
|
|
78
|
+
result: FetchResult<unknown, unknown>;
|
|
79
|
+
};
|
|
80
|
+
type InterceptorHandler<T> = (context: T) => MaybePromise<InterceptorDecision<T> | void>;
|
|
81
|
+
type HttpInterceptor = {
|
|
82
|
+
name: string;
|
|
83
|
+
order?: number;
|
|
84
|
+
match?: {
|
|
85
|
+
operation?: string;
|
|
86
|
+
method?: HttpMethod;
|
|
87
|
+
pathPrefix?: string;
|
|
88
|
+
status?: number;
|
|
89
|
+
};
|
|
90
|
+
onRequest?: InterceptorHandler<RequestContext>;
|
|
91
|
+
onRequestError?: InterceptorHandler<RequestContext>;
|
|
92
|
+
onResponse?: InterceptorHandler<RequestContext>;
|
|
93
|
+
onResponseError?: InterceptorHandler<RequestContext>;
|
|
94
|
+
onSseOpen?: InterceptorHandler<RequestContext>;
|
|
95
|
+
onSseEvent?: InterceptorHandler<SseEventContext>;
|
|
96
|
+
onSseError?: InterceptorHandler<RequestContext>;
|
|
97
|
+
onSseReconnect?: InterceptorHandler<RequestContext>;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type StatusHandlerInput = {
|
|
101
|
+
status: number;
|
|
102
|
+
error: FetchErrorInfo;
|
|
103
|
+
context: RequestContext;
|
|
104
|
+
};
|
|
105
|
+
type StatusHandlerResult = void | {
|
|
106
|
+
action: 'continue';
|
|
107
|
+
} | {
|
|
108
|
+
action: 'retry';
|
|
109
|
+
delayMs?: number;
|
|
110
|
+
};
|
|
111
|
+
type StatusHandler = (input: StatusHandlerInput) => MaybePromise<StatusHandlerResult>;
|
|
112
|
+
type StatusHandlers = {
|
|
113
|
+
401?: StatusHandler;
|
|
114
|
+
403?: StatusHandler;
|
|
115
|
+
404?: StatusHandler;
|
|
116
|
+
500?: StatusHandler;
|
|
117
|
+
'4xx'?: StatusHandler;
|
|
118
|
+
'5xx'?: StatusHandler;
|
|
119
|
+
default?: StatusHandler;
|
|
120
|
+
} & {
|
|
121
|
+
[status: number]: StatusHandler | undefined;
|
|
122
|
+
};
|
|
123
|
+
type AuthConfig = {
|
|
124
|
+
/** Return access token (or null/undefined to skip). */
|
|
125
|
+
getToken: () => MaybePromise<string | null | undefined>;
|
|
126
|
+
/** Header name. Default: `authorization`. */
|
|
127
|
+
header?: string;
|
|
128
|
+
/** Prefix before token. Default: `Bearer`. Use `''` for raw token. */
|
|
129
|
+
scheme?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type { AuthConfig as A, ClientSource as C, FetchResult as F, HttpError as H, IncomingHeaders as I, MaybePromise as M, PluginName as P, QueryParams as Q, RequestContext as R, StatusHandler as S, FetchErrorInfo as a, HttpInterceptor as b, HttpMethod as c, HttpResult as d, StatusHandlerInput as e, StatusHandlerResult as f, StatusHandlers as g, PathParams as h };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
2
|
+
type ClientSource = 'browser' | 'ssr' | 'edge';
|
|
3
|
+
type IncomingHeaders = {
|
|
4
|
+
cookie?: string;
|
|
5
|
+
authorization?: string;
|
|
6
|
+
requestId?: string;
|
|
7
|
+
};
|
|
8
|
+
type PathParams = Record<string, string | number>;
|
|
9
|
+
type QueryParams = Record<string, string | number | boolean | undefined | null>;
|
|
10
|
+
type PluginName = 'trace' | 'ssr-forward' | 'retry-idempotent' | 'sse-resume';
|
|
11
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
12
|
+
|
|
13
|
+
type OkResult<T> = {
|
|
14
|
+
ok: true;
|
|
15
|
+
status: number;
|
|
16
|
+
data: T;
|
|
17
|
+
headers: Headers;
|
|
18
|
+
};
|
|
19
|
+
type ErrResult<E> = {
|
|
20
|
+
ok: false;
|
|
21
|
+
status: number;
|
|
22
|
+
error: E;
|
|
23
|
+
headers: Headers;
|
|
24
|
+
};
|
|
25
|
+
type FetchResult<T, E = FetchErrorInfo> = OkResult<T> | ErrResult<E>;
|
|
26
|
+
type FetchErrorInfo = {
|
|
27
|
+
status: number;
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
body: unknown;
|
|
31
|
+
};
|
|
32
|
+
/** @deprecated Use FetchResult */
|
|
33
|
+
type HttpResult<T, E = FetchErrorInfo> = FetchResult<T, E>;
|
|
34
|
+
/** @deprecated Use FetchErrorInfo */
|
|
35
|
+
type HttpError = FetchErrorInfo;
|
|
36
|
+
|
|
37
|
+
type RequestContext = {
|
|
38
|
+
request: {
|
|
39
|
+
method: HttpMethod;
|
|
40
|
+
url: URL;
|
|
41
|
+
headers: Headers;
|
|
42
|
+
body?: unknown;
|
|
43
|
+
signal?: AbortSignal;
|
|
44
|
+
};
|
|
45
|
+
response?: Response;
|
|
46
|
+
data?: unknown;
|
|
47
|
+
error?: FetchErrorInfo;
|
|
48
|
+
incoming?: IncomingHeaders;
|
|
49
|
+
meta: {
|
|
50
|
+
attempt: number;
|
|
51
|
+
maxRetries: number;
|
|
52
|
+
source: ClientSource;
|
|
53
|
+
operation?: string;
|
|
54
|
+
requestId?: string;
|
|
55
|
+
lastEventId?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
type SseEventContext<T = unknown> = RequestContext & {
|
|
59
|
+
event: {
|
|
60
|
+
event?: string;
|
|
61
|
+
data: T;
|
|
62
|
+
id?: string;
|
|
63
|
+
retry?: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type InterceptorDecision<T> = {
|
|
67
|
+
action: 'continue';
|
|
68
|
+
context?: T;
|
|
69
|
+
} | {
|
|
70
|
+
action: 'skip';
|
|
71
|
+
} | {
|
|
72
|
+
action: 'drop';
|
|
73
|
+
} | {
|
|
74
|
+
action: 'retry';
|
|
75
|
+
delayMs?: number;
|
|
76
|
+
} | {
|
|
77
|
+
action: 'short-circuit';
|
|
78
|
+
result: FetchResult<unknown, unknown>;
|
|
79
|
+
};
|
|
80
|
+
type InterceptorHandler<T> = (context: T) => MaybePromise<InterceptorDecision<T> | void>;
|
|
81
|
+
type HttpInterceptor = {
|
|
82
|
+
name: string;
|
|
83
|
+
order?: number;
|
|
84
|
+
match?: {
|
|
85
|
+
operation?: string;
|
|
86
|
+
method?: HttpMethod;
|
|
87
|
+
pathPrefix?: string;
|
|
88
|
+
status?: number;
|
|
89
|
+
};
|
|
90
|
+
onRequest?: InterceptorHandler<RequestContext>;
|
|
91
|
+
onRequestError?: InterceptorHandler<RequestContext>;
|
|
92
|
+
onResponse?: InterceptorHandler<RequestContext>;
|
|
93
|
+
onResponseError?: InterceptorHandler<RequestContext>;
|
|
94
|
+
onSseOpen?: InterceptorHandler<RequestContext>;
|
|
95
|
+
onSseEvent?: InterceptorHandler<SseEventContext>;
|
|
96
|
+
onSseError?: InterceptorHandler<RequestContext>;
|
|
97
|
+
onSseReconnect?: InterceptorHandler<RequestContext>;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
type StatusHandlerInput = {
|
|
101
|
+
status: number;
|
|
102
|
+
error: FetchErrorInfo;
|
|
103
|
+
context: RequestContext;
|
|
104
|
+
};
|
|
105
|
+
type StatusHandlerResult = void | {
|
|
106
|
+
action: 'continue';
|
|
107
|
+
} | {
|
|
108
|
+
action: 'retry';
|
|
109
|
+
delayMs?: number;
|
|
110
|
+
};
|
|
111
|
+
type StatusHandler = (input: StatusHandlerInput) => MaybePromise<StatusHandlerResult>;
|
|
112
|
+
type StatusHandlers = {
|
|
113
|
+
401?: StatusHandler;
|
|
114
|
+
403?: StatusHandler;
|
|
115
|
+
404?: StatusHandler;
|
|
116
|
+
500?: StatusHandler;
|
|
117
|
+
'4xx'?: StatusHandler;
|
|
118
|
+
'5xx'?: StatusHandler;
|
|
119
|
+
default?: StatusHandler;
|
|
120
|
+
} & {
|
|
121
|
+
[status: number]: StatusHandler | undefined;
|
|
122
|
+
};
|
|
123
|
+
type AuthConfig = {
|
|
124
|
+
/** Return access token (or null/undefined to skip). */
|
|
125
|
+
getToken: () => MaybePromise<string | null | undefined>;
|
|
126
|
+
/** Header name. Default: `authorization`. */
|
|
127
|
+
header?: string;
|
|
128
|
+
/** Prefix before token. Default: `Bearer`. Use `''` for raw token. */
|
|
129
|
+
scheme?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type { AuthConfig as A, ClientSource as C, FetchResult as F, HttpError as H, IncomingHeaders as I, MaybePromise as M, PluginName as P, QueryParams as Q, RequestContext as R, StatusHandler as S, FetchErrorInfo as a, HttpInterceptor as b, HttpMethod as c, HttpResult as d, StatusHandlerInput as e, StatusHandlerResult as f, StatusHandlers as g, PathParams as h };
|