vigor-fetch 2.2.8 → 3.0.1
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 +958 -264
- package/dist/index.d.ts +453 -368
- package/dist/index.js +988 -631
- package/dist/index.mjs +988 -616
- package/package.json +1 -1
- package/dist/index.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,427 +1,512 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const VigorErrorMessageFuncs: {
|
|
2
|
+
INVALID_TARGET: ({ expected, received }: {
|
|
3
|
+
expected: Array<string>;
|
|
4
|
+
received: unknown;
|
|
5
5
|
}) => string;
|
|
6
|
-
|
|
6
|
+
EXHAUSTED: ({ maxAttempts }: {
|
|
7
7
|
maxAttempts: number;
|
|
8
8
|
}) => string;
|
|
9
|
-
|
|
9
|
+
TIMED_OUT: ({ limit, attempt }: {
|
|
10
|
+
limit: number;
|
|
11
|
+
attempt: number;
|
|
12
|
+
}) => string;
|
|
13
|
+
INVALID_CONTENT_TYPE: ({ expected, received, response }: {
|
|
14
|
+
expected: Array<string>;
|
|
10
15
|
received: unknown;
|
|
16
|
+
response: Response;
|
|
11
17
|
}) => string;
|
|
12
|
-
|
|
18
|
+
PARSER_NOT_FOUND: ({ expected, received, response }: {
|
|
13
19
|
expected: Array<string>;
|
|
14
20
|
received: unknown;
|
|
21
|
+
response: Response;
|
|
15
22
|
}) => string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
url: string;
|
|
23
|
+
PARSER_ALL_FAILED: ({ tried, response }: {
|
|
24
|
+
tried: Array<unknown>;
|
|
25
|
+
response: Response;
|
|
20
26
|
}) => string;
|
|
21
|
-
|
|
22
|
-
expected:
|
|
27
|
+
INVALID_PROTOCOL: ({ expected, received }: {
|
|
28
|
+
expected: Array<string>;
|
|
29
|
+
received: unknown;
|
|
23
30
|
}) => string;
|
|
24
|
-
|
|
25
|
-
expected:
|
|
31
|
+
INVALID_BODY: ({ expected, received }: {
|
|
32
|
+
expected: Array<string>;
|
|
26
33
|
received: unknown;
|
|
27
34
|
}) => string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
FETCH_FAILED: ({ status, response, url, headers, body, statusText }: {
|
|
36
|
+
status: number;
|
|
37
|
+
response: Response;
|
|
38
|
+
url: string;
|
|
39
|
+
headers: unknown;
|
|
40
|
+
body: unknown;
|
|
41
|
+
statusText: string;
|
|
32
42
|
}) => string;
|
|
33
|
-
|
|
34
|
-
readonly UNKNOWN: () => string;
|
|
43
|
+
EMPTY_TARGET: ({}: {}) => string;
|
|
35
44
|
};
|
|
36
|
-
type
|
|
37
|
-
type
|
|
38
|
-
type VigorErrorOptions<C extends
|
|
39
|
-
method?: string;
|
|
45
|
+
type VigorErrorCodes = keyof typeof VigorErrorMessageFuncs;
|
|
46
|
+
type VigorErrorDatas<C extends VigorErrorCodes> = Parameters<typeof VigorErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
|
|
47
|
+
type VigorErrorOptions<C extends VigorErrorCodes, S, T> = {
|
|
40
48
|
cause?: unknown;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
data?: VigorErrorDatas<C>;
|
|
50
|
+
method: string;
|
|
51
|
+
stats?: S;
|
|
52
|
+
context?: T;
|
|
44
53
|
};
|
|
45
|
-
declare abstract class VigorError<C extends
|
|
54
|
+
declare abstract class VigorError<C extends VigorErrorCodes, S, T> extends Error {
|
|
46
55
|
readonly timestamp: Date;
|
|
47
|
-
readonly method?: string;
|
|
48
|
-
readonly code: C;
|
|
49
56
|
readonly cause?: unknown;
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
52
|
-
readonly
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
constructor(code: C, options: VigorErrorOptions<C>);
|
|
57
|
+
readonly code: C;
|
|
58
|
+
readonly data: VigorErrorDatas<C> | undefined;
|
|
59
|
+
readonly method: string;
|
|
60
|
+
readonly stats: S | undefined;
|
|
61
|
+
readonly context: T | undefined;
|
|
62
|
+
constructor(code: C, options: VigorErrorOptions<C, S, T>);
|
|
57
63
|
}
|
|
58
|
-
declare class
|
|
59
|
-
constructor(code: C, options: VigorErrorOptions<C>);
|
|
64
|
+
declare class VigorRetryError<C extends "INVALID_TARGET" | "EXHAUSTED" | "TIMED_OUT"> extends VigorError<C, VigorRetryConfig, VigorRetryContext> {
|
|
65
|
+
constructor(code: C, options: VigorErrorOptions<C, VigorRetryConfig, VigorRetryContext>);
|
|
60
66
|
}
|
|
61
|
-
declare class
|
|
62
|
-
constructor(code: C, options: VigorErrorOptions<C>);
|
|
67
|
+
declare class VigorParseError<C extends "INVALID_CONTENT_TYPE" | "PARSER_NOT_FOUND" | "PARSER_ALL_FAILED" | "INVALID_TARGET"> extends VigorError<C, VigorParseConfig, VigorParseContext> {
|
|
68
|
+
constructor(code: C, options: VigorErrorOptions<C, VigorParseConfig, VigorParseContext>);
|
|
63
69
|
}
|
|
64
|
-
declare class
|
|
65
|
-
constructor(code: C, options: VigorErrorOptions<C>);
|
|
70
|
+
declare class VigorFetchError<C extends "INVALID_PROTOCOL" | "INVALID_BODY" | "FETCH_FAILED"> extends VigorError<C, VigorFetchConfig, VigorFetchContext> {
|
|
71
|
+
constructor(code: C, options: VigorErrorOptions<C, VigorFetchConfig, VigorFetchContext>);
|
|
66
72
|
}
|
|
67
|
-
declare
|
|
68
|
-
|
|
69
|
-
protected readonly _base: T;
|
|
70
|
-
protected readonly _config: T;
|
|
71
|
-
constructor(config: Partial<T>, _base: T);
|
|
72
|
-
getConfig(): T;
|
|
73
|
-
getBase(): T;
|
|
74
|
-
protected _next(config: Partial<T>): this;
|
|
75
|
-
protected _pipsub<C, R extends VigorStatus<C>>(config: C, fn: (r: R) => R, ctor: new (c: C) => R): C;
|
|
73
|
+
declare class VigorAllError<C extends "EMPTY_TARGET"> extends VigorError<C, VigorAllConfig, VigorAllContext | VigorAllEachContext> {
|
|
74
|
+
constructor(code: C, options: VigorErrorOptions<C, VigorAllConfig, VigorAllContext | VigorAllEachContext>);
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
count(num: number): this;
|
|
87
|
-
limit(num: number): this;
|
|
88
|
-
maxDelay(num: number): this;
|
|
89
|
-
default(obj: T): this;
|
|
76
|
+
declare abstract class VigorStatus<C, Self> {
|
|
77
|
+
protected readonly _base: C;
|
|
78
|
+
protected readonly ctor: (config: C) => Self;
|
|
79
|
+
protected readonly _config: C;
|
|
80
|
+
constructor(config: Partial<C> | undefined, _base: C, ctor: (config: C) => Self);
|
|
81
|
+
protected _mergeConfig<C>(source: any, target: C | Partial<C> | undefined): C;
|
|
82
|
+
protected _next(config: Partial<C>): Self;
|
|
83
|
+
_getConfig(): C;
|
|
84
|
+
_getBase(): C;
|
|
90
85
|
}
|
|
91
|
-
type
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
type VigorIncludeSpread<T> = Array<T | Array<T>>;
|
|
87
|
+
type VigorRetrySettingsConfig = {
|
|
88
|
+
default: unknown;
|
|
89
|
+
timeout: number;
|
|
90
|
+
attempt: number;
|
|
95
91
|
jitter: number;
|
|
96
92
|
};
|
|
97
|
-
declare class
|
|
98
|
-
constructor(config?: Partial<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
jitter(num:
|
|
103
|
-
static randomJitter(num: number): number;
|
|
93
|
+
declare class VigorRetrySettings extends VigorStatus<VigorRetrySettingsConfig, VigorRetrySettings> {
|
|
94
|
+
constructor(config?: Partial<VigorRetrySettingsConfig>);
|
|
95
|
+
default(unk: VigorRetrySettingsConfig["default"]): VigorRetrySettings;
|
|
96
|
+
timeout(num: VigorRetrySettingsConfig["timeout"]): VigorRetrySettings;
|
|
97
|
+
attempt(num: VigorRetrySettingsConfig["attempt"]): VigorRetrySettings;
|
|
98
|
+
jitter(num: VigorRetrySettingsConfig["jitter"]): VigorRetrySettings;
|
|
104
99
|
}
|
|
105
|
-
type
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
setAttempt: (attempt: number) => number;
|
|
122
|
-
throwError: (error: Error) => void;
|
|
123
|
-
setDelay: (delay: number) => number;
|
|
124
|
-
};
|
|
125
|
-
type VigorRetryOnError<T> = {
|
|
126
|
-
setResult: (result: T) => T;
|
|
127
|
-
throwError: (error: Error) => void;
|
|
128
|
-
};
|
|
129
|
-
type VigorRetryFn<T, O> = (ctx: VigorRetryContext<T>, obj: O) => void | any | Promise<void | any>;
|
|
130
|
-
type VigorRetryBeforeFn<T> = VigorRetryFn<T, VigorRetryBefore<T>>;
|
|
131
|
-
type VigorRetryAfterFn<T> = VigorRetryFn<T, VigorRetryAfter<T>>;
|
|
132
|
-
type VigorRetryOnErrorFn<T> = VigorRetryFn<T, VigorRetryOnError<T>>;
|
|
133
|
-
type VigorRetryOnRetryFn<T> = VigorRetryFn<T, VigorRetryOnRetry<T>>;
|
|
134
|
-
type VigorRetryRetryIfFn<T> = VigorRetryFn<T, VigorRetryRetryIf<T>>;
|
|
135
|
-
type VigorRetryOptionsTask<T> = {
|
|
136
|
-
abort?: (error: Error) => void;
|
|
137
|
-
signal?: AbortSignal;
|
|
138
|
-
};
|
|
139
|
-
type VigorRetryInterceptorsConfig<T> = {
|
|
140
|
-
before: Array<VigorRetryBeforeFn<T>>;
|
|
141
|
-
after: Array<VigorRetryAfterFn<T>>;
|
|
142
|
-
onError: Array<VigorRetryOnErrorFn<T>>;
|
|
143
|
-
onRetry: Array<VigorRetryOnRetryFn<T>>;
|
|
144
|
-
retryIf: Array<VigorRetryRetryIfFn<T>>;
|
|
145
|
-
};
|
|
146
|
-
declare class VigorRetryInterceptors<T> extends VigorStatus<VigorRetryInterceptorsConfig<T>> {
|
|
147
|
-
constructor(config?: Partial<VigorRetryInterceptorsConfig<T>>);
|
|
148
|
-
before(...funcs: VigorIncludeSpread<VigorRetryBeforeFn<T>>): this;
|
|
149
|
-
after(...funcs: VigorIncludeSpread<VigorRetryAfterFn<T>>): this;
|
|
150
|
-
onError(...funcs: VigorIncludeSpread<VigorRetryOnErrorFn<T>>): this;
|
|
151
|
-
onRetry(...funcs: VigorIncludeSpread<VigorRetryOnRetryFn<T>>): this;
|
|
152
|
-
retryIf(...funcs: VigorIncludeSpread<VigorRetryRetryIfFn<T>>): this;
|
|
100
|
+
type VigorRetryInterceptorsConfig = {
|
|
101
|
+
before: Array<VigorRetryInterceptorsFunctions["before"]>;
|
|
102
|
+
after: Array<VigorRetryInterceptorsFunctions["after"]>;
|
|
103
|
+
result: Array<VigorRetryInterceptorsFunctions["result"]>;
|
|
104
|
+
retryIf: Array<VigorRetryInterceptorsFunctions["retryIf"]>;
|
|
105
|
+
onRetry: Array<VigorRetryInterceptorsFunctions["onRetry"]>;
|
|
106
|
+
onError: Array<VigorRetryInterceptorsFunctions["onError"]>;
|
|
107
|
+
};
|
|
108
|
+
declare class VigorRetryInterceptors extends VigorStatus<VigorRetryInterceptorsConfig, VigorRetryInterceptors> {
|
|
109
|
+
constructor(config?: Partial<VigorRetryInterceptorsConfig>);
|
|
110
|
+
before(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["before"][number]>): VigorRetryInterceptors;
|
|
111
|
+
after(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["after"][number]>): VigorRetryInterceptors;
|
|
112
|
+
result(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["result"][number]>): VigorRetryInterceptors;
|
|
113
|
+
retryIf(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["retryIf"][number]>): VigorRetryInterceptors;
|
|
114
|
+
onRetry(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["onRetry"][number]>): VigorRetryInterceptors;
|
|
115
|
+
onError(...funcs: VigorIncludeSpread<VigorRetryInterceptorsConfig["onError"][number]>): VigorRetryInterceptors;
|
|
153
116
|
}
|
|
154
|
-
type
|
|
155
|
-
|
|
156
|
-
target: VigorRetryTask<T>;
|
|
157
|
-
setting: VigorRetrySettingsConfig<T>;
|
|
158
|
-
backoff: VigorRetryBackoffConfig<T>;
|
|
159
|
-
interceptors: VigorRetryInterceptorsConfig<T>;
|
|
160
|
-
controller: AbortController;
|
|
117
|
+
type VigorRetryAlgorithmsConstantConfig = {
|
|
118
|
+
interval: number;
|
|
161
119
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
retry: boolean;
|
|
172
|
-
error?: unknown;
|
|
173
|
-
};
|
|
120
|
+
declare class VigorRetryAlgorithmsConstant extends VigorStatus<VigorRetryAlgorithmsConstantConfig, VigorRetryAlgorithmsConstant> {
|
|
121
|
+
constructor(config?: Partial<VigorRetryAlgorithmsConstantConfig>);
|
|
122
|
+
interval(num: VigorRetryAlgorithmsConstantConfig["interval"]): VigorRetryAlgorithmsConstant;
|
|
123
|
+
}
|
|
124
|
+
type VigorRetryAlgorithmsLinearConfig = {
|
|
125
|
+
initial: number;
|
|
126
|
+
increment: number;
|
|
127
|
+
minDelay: number;
|
|
128
|
+
maxDelay: number;
|
|
174
129
|
};
|
|
175
|
-
declare class
|
|
176
|
-
constructor(config?: Partial<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
setting(func: (r: VigorRetrySettings<T>) => VigorRetrySettings<T>): this;
|
|
182
|
-
backoff(func: (r: VigorRetryBackoff<T>) => VigorRetryBackoff<T>): this;
|
|
183
|
-
interceptors(func: (r: VigorRetryInterceptors<T>) => VigorRetryInterceptors<T>): this;
|
|
184
|
-
request(): Promise<T>;
|
|
130
|
+
declare class VigorRetryAlgorithmsLinear extends VigorStatus<VigorRetryAlgorithmsLinearConfig, VigorRetryAlgorithmsLinear> {
|
|
131
|
+
constructor(config?: Partial<VigorRetryAlgorithmsLinearConfig>);
|
|
132
|
+
initial(num: VigorRetryAlgorithmsLinearConfig["initial"]): VigorRetryAlgorithmsLinear;
|
|
133
|
+
increment(num: VigorRetryAlgorithmsLinearConfig["increment"]): VigorRetryAlgorithmsLinear;
|
|
134
|
+
minDelay(num: VigorRetryAlgorithmsLinearConfig["minDelay"]): VigorRetryAlgorithmsLinear;
|
|
135
|
+
maxDelay(num: VigorRetryAlgorithmsLinearConfig["maxDelay"]): VigorRetryAlgorithmsLinear;
|
|
185
136
|
}
|
|
186
|
-
type
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}[];
|
|
201
|
-
static supported: string[];
|
|
202
|
-
private _transfer;
|
|
203
|
-
target(res: Response): this;
|
|
204
|
-
original<B extends boolean>(bool: B): VigorParse<T, B>;
|
|
205
|
-
type<K extends keyof Response>(type: K): VigorParse<Response[K] extends (...args: any) => Promise<infer R> ? R : never, O>;
|
|
206
|
-
request<U = T>(): Promise<O extends true ? Response : U>;
|
|
137
|
+
type VigorRetryAlgorithmsBackoffConfig = {
|
|
138
|
+
initial: number;
|
|
139
|
+
multiplier: number;
|
|
140
|
+
unit: number;
|
|
141
|
+
minDelay: number;
|
|
142
|
+
maxDelay: number;
|
|
143
|
+
};
|
|
144
|
+
declare class VigorRetryAlgorithmsBackoff extends VigorStatus<VigorRetryAlgorithmsBackoffConfig, VigorRetryAlgorithmsBackoff> {
|
|
145
|
+
constructor(config?: Partial<VigorRetryAlgorithmsBackoffConfig>);
|
|
146
|
+
initial(num: VigorRetryAlgorithmsBackoffConfig["initial"]): VigorRetryAlgorithmsBackoff;
|
|
147
|
+
multiplier(num: VigorRetryAlgorithmsBackoffConfig["multiplier"]): VigorRetryAlgorithmsBackoff;
|
|
148
|
+
unit(num: VigorRetryAlgorithmsBackoffConfig["unit"]): VigorRetryAlgorithmsBackoff;
|
|
149
|
+
minDelay(num: VigorRetryAlgorithmsBackoffConfig["minDelay"]): VigorRetryAlgorithmsBackoff;
|
|
150
|
+
maxDelay(num: VigorRetryAlgorithmsBackoffConfig["maxDelay"]): VigorRetryAlgorithmsBackoff;
|
|
207
151
|
}
|
|
208
|
-
type
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
headers?: HeadersInit | Record<string, any>;
|
|
217
|
-
body?: XMLHttpRequestBodyInit | object | null;
|
|
218
|
-
options?: object;
|
|
219
|
-
default?: T | typeof EMPTY;
|
|
220
|
-
};
|
|
221
|
-
declare class VigorFetchSettings<T> extends VigorStatus<VigorFetchSettingsConfig<T>> {
|
|
222
|
-
constructor(config?: Partial<VigorFetchSettingsConfig<T>>);
|
|
223
|
-
origin(str: string): VigorFetchSettings<T>;
|
|
224
|
-
path(...strs: (string | string[])[]): VigorFetchSettings<T>;
|
|
225
|
-
query(obj: object): VigorFetchSettings<T>;
|
|
226
|
-
unretry(...numbers: (number | number[])[]): VigorFetchSettings<T>;
|
|
227
|
-
retryHeaders(...strs: (string | string[])[]): VigorFetchSettings<T>;
|
|
228
|
-
method(str: VigorFetchMethods): VigorFetchSettings<T>;
|
|
229
|
-
headers(obj: HeadersInit | Record<string, any>): VigorFetchSettings<T>;
|
|
230
|
-
body(obj: XMLHttpRequestBodyInit | object | null): VigorFetchSettings<T>;
|
|
231
|
-
options(obj: object): VigorFetchSettings<T>;
|
|
232
|
-
default(obj: T): VigorFetchSettings<T>;
|
|
152
|
+
type VigorRetryAlgorithmsCustomConfig = {
|
|
153
|
+
func: VigorRetryAlgorithmsConfig;
|
|
154
|
+
minDelay: number;
|
|
155
|
+
maxDelay: number;
|
|
156
|
+
};
|
|
157
|
+
declare class VigorRetryAlgorithmsCustom extends VigorStatus<VigorRetryAlgorithmsCustomConfig, VigorRetryAlgorithmsCustom> {
|
|
158
|
+
constructor(config?: Partial<VigorRetryAlgorithmsCustomConfig>);
|
|
159
|
+
func(num: VigorRetryAlgorithmsCustomConfig["func"]): VigorRetryAlgorithmsCustom;
|
|
233
160
|
}
|
|
234
|
-
type
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
161
|
+
type VigorRetryAlgorithmsConfig = (attempt: number) => number;
|
|
162
|
+
type VigorRetryInterceptorsApi<R> = {
|
|
163
|
+
setResult: (unk: R) => void;
|
|
164
|
+
throwError: <E extends Error>(err: E) => never;
|
|
165
|
+
breakRetry: <E extends Error>(err: E) => never;
|
|
166
|
+
proceedRetry: () => void;
|
|
167
|
+
cancelRetry: () => void;
|
|
168
|
+
setDelay: <D extends number>(num: D) => void;
|
|
169
|
+
setAttempt: <A extends number>(num: A) => void;
|
|
170
|
+
restart: () => void;
|
|
171
|
+
abort: <E extends Error>(err: E) => void;
|
|
172
|
+
};
|
|
173
|
+
type VigorRetryInterceptorsFn<A extends keyof VigorRetryInterceptorsApi<R>, R = unknown> = (ctx: VigorRetryContext, api: Pick<VigorRetryInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
174
|
+
type VigorRetryInterceptorsFunctions = {
|
|
175
|
+
before: VigorRetryInterceptorsFn<"throwError" | "breakRetry" | "abort">;
|
|
176
|
+
after: VigorRetryInterceptorsFn<"setResult" | "throwError" | "breakRetry">;
|
|
177
|
+
result: VigorRetryInterceptorsFn<"setResult" | "throwError">;
|
|
178
|
+
retryIf: VigorRetryInterceptorsFn<"proceedRetry" | "cancelRetry">;
|
|
179
|
+
onRetry: VigorRetryInterceptorsFn<"throwError" | "setDelay" | "setAttempt">;
|
|
180
|
+
onError: VigorRetryInterceptorsFn<"setResult" | "throwError" | "restart">;
|
|
181
|
+
};
|
|
182
|
+
type VigorRetryConfig = {
|
|
183
|
+
target: (ctx: VigorRetryContext, { abort, signal }: {
|
|
184
|
+
abort: VigorRetryInterceptorsApi<any>["abort"];
|
|
185
|
+
signal: AbortSignal;
|
|
186
|
+
}) => unknown | Promise<unknown>;
|
|
187
|
+
settings: VigorRetrySettingsConfig;
|
|
188
|
+
interceptors: VigorRetryInterceptorsConfig;
|
|
189
|
+
algorithm: VigorRetryAlgorithmsConfig;
|
|
190
|
+
abortSignals: Array<AbortSignal>;
|
|
191
|
+
};
|
|
192
|
+
type VigorRetryContext = {
|
|
193
|
+
result: unknown;
|
|
194
|
+
error: unknown;
|
|
195
|
+
attempt: number;
|
|
196
|
+
delay: number;
|
|
197
|
+
controller: AbortController;
|
|
198
|
+
timeline: Array<{
|
|
199
|
+
action: string;
|
|
200
|
+
content?: unknown;
|
|
201
|
+
}>;
|
|
202
|
+
stats: VigorRetryConfig;
|
|
203
|
+
};
|
|
204
|
+
declare class VigorRetry extends VigorStatus<VigorRetryConfig, VigorRetry> {
|
|
205
|
+
constructor(config?: Partial<VigorRetryConfig>);
|
|
206
|
+
private RetryAlgorithms;
|
|
207
|
+
target(func: VigorRetryConfig["target"]): VigorRetry;
|
|
208
|
+
settings(func: ((s: VigorRetrySettings) => VigorRetrySettings) | VigorRetryConfig["settings"]): VigorRetry;
|
|
209
|
+
interceptors(func: ((i: VigorRetryInterceptors) => VigorRetryInterceptors) | VigorRetryConfig["interceptors"]): VigorRetry;
|
|
210
|
+
algorithms(func: (a: typeof this.RetryAlgorithms) => {
|
|
211
|
+
_calculateDelay: VigorRetryConfig["algorithm"];
|
|
212
|
+
}): VigorRetry;
|
|
213
|
+
abortSignals(...abortSignals: VigorIncludeSpread<AbortSignal>): VigorRetry;
|
|
214
|
+
request<R>(config?: VigorRetryConfig, timeline?: VigorRetryContext["timeline"]): Promise<R>;
|
|
266
215
|
}
|
|
267
|
-
type
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
216
|
+
type VigorParseSettingsConfig = {
|
|
217
|
+
raw: boolean;
|
|
218
|
+
default: unknown;
|
|
219
|
+
};
|
|
220
|
+
declare class VigorParseSettings extends VigorStatus<VigorParseSettingsConfig, VigorParseSettings> {
|
|
221
|
+
constructor(config?: Partial<VigorParseSettingsConfig>);
|
|
222
|
+
original(bool: VigorParseSettingsConfig["raw"]): VigorParseSettings;
|
|
223
|
+
default(unk: VigorParseSettingsConfig["default"]): VigorParseSettings;
|
|
224
|
+
}
|
|
225
|
+
type VigorParseStrategiesConfig = {
|
|
226
|
+
funcs: Array<(response: Response) => Promise<any>>;
|
|
227
|
+
};
|
|
228
|
+
declare class VigorParseStrategies extends VigorStatus<VigorParseStrategiesConfig, VigorParseStrategies> {
|
|
229
|
+
constructor(config?: Partial<VigorParseStrategiesConfig>);
|
|
230
|
+
private ParseAutoHeaders;
|
|
231
|
+
private ParseAutoMethods;
|
|
232
|
+
private ParseAutoAlgorithms;
|
|
233
|
+
contentType(): VigorParseStrategies;
|
|
234
|
+
sniff(): VigorParseStrategies;
|
|
235
|
+
json(): VigorParseStrategies;
|
|
236
|
+
text(): VigorParseStrategies;
|
|
237
|
+
arrayBuffer(): VigorParseStrategies;
|
|
238
|
+
blob(): VigorParseStrategies;
|
|
239
|
+
bytes(): VigorParseStrategies;
|
|
240
|
+
formData(): VigorParseStrategies;
|
|
241
|
+
}
|
|
242
|
+
type VigorParseInterceptorsConfig = {
|
|
243
|
+
before: Array<VigorParseInterceptorsFunctions["before"]>;
|
|
244
|
+
after: Array<VigorParseInterceptorsFunctions["after"]>;
|
|
245
|
+
result: Array<VigorParseInterceptorsFunctions["result"]>;
|
|
246
|
+
onError: Array<VigorParseInterceptorsFunctions["onError"]>;
|
|
247
|
+
};
|
|
248
|
+
declare class VigorParseInterceptors extends VigorStatus<VigorParseInterceptorsConfig, VigorParseInterceptors> {
|
|
249
|
+
constructor(config?: Partial<VigorParseInterceptorsConfig>);
|
|
250
|
+
before(...funcs: VigorIncludeSpread<VigorParseInterceptorsConfig["before"][number]>): VigorParseInterceptors;
|
|
251
|
+
after(...funcs: VigorIncludeSpread<VigorParseInterceptorsConfig["after"][number]>): VigorParseInterceptors;
|
|
252
|
+
result(...funcs: VigorIncludeSpread<VigorParseInterceptorsConfig["result"][number]>): VigorParseInterceptors;
|
|
253
|
+
onError(...funcs: VigorIncludeSpread<VigorParseInterceptorsConfig["onError"][number]>): VigorParseInterceptors;
|
|
254
|
+
}
|
|
255
|
+
type VigorParseInterceptorsApi<R> = {
|
|
256
|
+
setResult: (unk: R) => void;
|
|
257
|
+
throwError: <E extends Error>(err: E) => never;
|
|
258
|
+
};
|
|
259
|
+
type VigorParseInterceptorsFn<A extends keyof VigorParseInterceptorsApi<R>, R = unknown> = (ctx: VigorParseContext, api: Pick<VigorParseInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
260
|
+
type VigorParseInterceptorsFunctions = {
|
|
261
|
+
before: VigorParseInterceptorsFn<"throwError">;
|
|
262
|
+
after: VigorParseInterceptorsFn<"setResult" | "throwError">;
|
|
263
|
+
result: VigorParseInterceptorsFn<"setResult" | "throwError">;
|
|
264
|
+
onError: VigorParseInterceptorsFn<"setResult" | "throwError">;
|
|
265
|
+
};
|
|
266
|
+
type VigorParseConfig = {
|
|
267
|
+
target: Response;
|
|
268
|
+
settings: VigorParseSettingsConfig;
|
|
269
|
+
strategies: VigorParseStrategiesConfig;
|
|
270
|
+
interceptors: VigorParseInterceptorsConfig;
|
|
271
|
+
};
|
|
272
|
+
type VigorParseContext = {
|
|
273
|
+
stats: VigorParseConfig;
|
|
274
|
+
timeline: Array<{
|
|
275
|
+
action: string;
|
|
276
|
+
content?: unknown;
|
|
277
|
+
}>;
|
|
278
|
+
result: unknown;
|
|
279
|
+
error: unknown;
|
|
280
|
+
response: Response;
|
|
281
|
+
};
|
|
282
|
+
declare class VigorParse extends VigorStatus<VigorParseConfig, VigorParse> {
|
|
283
|
+
constructor(config?: Partial<VigorParseConfig>);
|
|
284
|
+
target(response: VigorParseConfig["target"]): VigorParse;
|
|
285
|
+
settings(func: ((i: VigorParseSettings) => VigorParseSettings) | VigorParseConfig["settings"]): VigorParse;
|
|
286
|
+
strategies(func: ((i: VigorParseStrategies) => VigorParseStrategies) | VigorParseConfig["strategies"]): VigorParse;
|
|
287
|
+
interceptors(func: ((i: VigorParseInterceptors) => VigorParseInterceptors) | VigorParseConfig["interceptors"]): VigorParse;
|
|
288
|
+
request<R>(config?: VigorParseConfig, timeline?: VigorParseContext["timeline"]): Promise<R>;
|
|
289
|
+
}
|
|
290
|
+
type VigorFetchSettingsConfig = {
|
|
291
|
+
unretryStatus: Array<number>;
|
|
292
|
+
retryHeaders: Array<string>;
|
|
293
|
+
default: unknown;
|
|
294
|
+
};
|
|
295
|
+
declare class VigorFetchSettings extends VigorStatus<VigorFetchSettingsConfig, VigorFetchSettings> {
|
|
296
|
+
constructor(config?: Partial<VigorFetchSettingsConfig>);
|
|
297
|
+
retryHeaders(...strs: VigorIncludeSpread<VigorFetchSettingsConfig["retryHeaders"][number]>): VigorFetchSettings;
|
|
298
|
+
unretryStatus(...nums: VigorIncludeSpread<VigorFetchSettingsConfig["unretryStatus"][number]>): VigorFetchSettings;
|
|
299
|
+
default(unk: VigorFetchSettingsConfig["default"]): VigorFetchSettings;
|
|
300
|
+
}
|
|
301
|
+
type VigorFetchInterceptorsConfig = {
|
|
302
|
+
before: Array<VigorFetchInterceptorsFunctions["before"]>;
|
|
303
|
+
after: Array<VigorFetchInterceptorsFunctions["after"]>;
|
|
304
|
+
result: Array<VigorFetchInterceptorsFunctions["result"]>;
|
|
305
|
+
onError: Array<VigorFetchInterceptorsFunctions["onError"]>;
|
|
306
|
+
};
|
|
307
|
+
declare class VigorFetchInterceptors extends VigorStatus<VigorFetchInterceptorsConfig, VigorFetchInterceptors> {
|
|
308
|
+
constructor(config?: Partial<VigorFetchInterceptorsConfig>);
|
|
309
|
+
before(...funcs: VigorIncludeSpread<VigorFetchInterceptorsConfig["before"][number]>): VigorFetchInterceptors;
|
|
310
|
+
after(...funcs: VigorIncludeSpread<VigorFetchInterceptorsConfig["after"][number]>): VigorFetchInterceptors;
|
|
311
|
+
result(...funcs: VigorIncludeSpread<VigorFetchInterceptorsConfig["result"][number]>): VigorFetchInterceptors;
|
|
312
|
+
onError(...funcs: VigorIncludeSpread<VigorFetchInterceptorsConfig["onError"][number]>): VigorFetchInterceptors;
|
|
313
|
+
}
|
|
314
|
+
type VigorFetchOptions<T = Record<string, any>> = {
|
|
315
|
+
headers: HeadersInit | Record<string, any>;
|
|
316
|
+
body?: XMLHttpRequestBodyInit | object | null;
|
|
317
|
+
} & T;
|
|
318
|
+
type VigorFetchConfig = {
|
|
319
|
+
origin: Array<string>;
|
|
320
|
+
path: Array<string>;
|
|
321
|
+
query: Array<Record<string, VigorStringable | Array<VigorStringable>>>;
|
|
322
|
+
hash: string;
|
|
323
|
+
options: VigorFetchOptions;
|
|
324
|
+
settings: VigorFetchSettingsConfig;
|
|
325
|
+
interceptors: VigorFetchInterceptorsConfig;
|
|
326
|
+
retryConfig: VigorRetryConfig;
|
|
327
|
+
parseConfig: VigorParseConfig;
|
|
328
|
+
};
|
|
329
|
+
type VigorFetchInterceptorsApi<R> = {
|
|
330
|
+
setResult: (unk: R) => void;
|
|
331
|
+
setOptions: (unk: VigorFetchContext["options"]) => void;
|
|
332
|
+
setHeaders: (unk: VigorFetchConfig["options"]["headers"]) => void;
|
|
333
|
+
setBody: (unk: VigorFetchConfig["options"]["body"]) => void;
|
|
334
|
+
throwError: <E extends Error>(err: E) => never;
|
|
335
|
+
restart: () => void;
|
|
336
|
+
};
|
|
337
|
+
type VigorFetchInterceptorsFn<A extends keyof VigorFetchInterceptorsApi<R>, R = unknown> = (ctx: VigorFetchContext, api: Pick<VigorFetchInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
338
|
+
type VigorFetchInterceptorsFunctions = {
|
|
339
|
+
before: VigorFetchInterceptorsFn<"throwError" | "setOptions" | "setHeaders" | "setBody">;
|
|
340
|
+
after: VigorFetchInterceptorsFn<"setResult" | "throwError">;
|
|
341
|
+
result: VigorFetchInterceptorsFn<"setResult" | "throwError">;
|
|
342
|
+
onError: VigorFetchInterceptorsFn<"setResult" | "throwError" | "restart">;
|
|
343
|
+
};
|
|
344
|
+
type VigorFetchContext = {
|
|
345
|
+
href: string;
|
|
346
|
+
response: Response;
|
|
347
|
+
result: unknown;
|
|
348
|
+
error: unknown;
|
|
349
|
+
options: VigorFetchOptions;
|
|
350
|
+
timeline: Array<{
|
|
351
|
+
action: string;
|
|
352
|
+
content?: unknown;
|
|
353
|
+
}>;
|
|
354
|
+
stats: VigorFetchConfig;
|
|
355
|
+
};
|
|
356
|
+
type VigorStringable = string | number | boolean | null | undefined | Date;
|
|
357
|
+
declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
|
|
358
|
+
constructor(config?: Partial<VigorFetchConfig>);
|
|
359
|
+
private _stringifyList;
|
|
360
|
+
origin(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
361
|
+
path(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
362
|
+
query(...strs: VigorIncludeSpread<VigorFetchConfig["query"][number]>): VigorFetch;
|
|
363
|
+
hash(str: VigorFetchConfig["hash"]): VigorFetch;
|
|
364
|
+
options(obj: VigorFetchConfig["options"]): VigorFetch;
|
|
365
|
+
headers(obj: VigorFetchConfig["options"]["headers"]): VigorFetch;
|
|
366
|
+
body(obj: VigorFetchConfig["options"]["body"]): VigorFetch;
|
|
367
|
+
private _buildUrl;
|
|
368
|
+
private _normalizeOptions;
|
|
369
|
+
settings(func: ((s: VigorFetchSettings) => VigorFetchSettings) | VigorFetchConfig["settings"]): VigorFetch;
|
|
370
|
+
interceptors(func: ((s: VigorFetchInterceptors) => VigorFetchInterceptors) | VigorFetchConfig["interceptors"]): VigorFetch;
|
|
371
|
+
retryConfig(func: ((s: VigorRetry) => VigorRetry) | VigorFetchConfig["retryConfig"]): VigorFetch;
|
|
372
|
+
parseConfig(func: ((s: VigorParse) => VigorParse) | VigorFetchConfig["parseConfig"]): VigorFetch;
|
|
373
|
+
request<R>(config?: VigorFetchConfig, timeline?: VigorFetchContext["timeline"]): Promise<R>;
|
|
301
374
|
}
|
|
302
375
|
type VigorAllSettingsConfig = {
|
|
303
376
|
concurrency: number;
|
|
304
|
-
jitter: number;
|
|
305
377
|
onlySuccess: boolean;
|
|
306
378
|
};
|
|
307
|
-
declare class VigorAllSettings extends VigorStatus<VigorAllSettingsConfig> {
|
|
379
|
+
declare class VigorAllSettings extends VigorStatus<VigorAllSettingsConfig, VigorAllSettings> {
|
|
308
380
|
constructor(config?: Partial<VigorAllSettingsConfig>);
|
|
309
|
-
concurrency(num:
|
|
310
|
-
|
|
311
|
-
onlySuccess(bool: boolean): VigorAllSettings;
|
|
381
|
+
concurrency(num: VigorAllSettingsConfig["concurrency"]): VigorAllSettings;
|
|
382
|
+
onlySuccess(num: VigorAllSettingsConfig["onlySuccess"]): VigorAllSettings;
|
|
312
383
|
}
|
|
313
|
-
type VigorAllBefore = {
|
|
314
|
-
throwError?: (error: Error) => void;
|
|
315
|
-
};
|
|
316
|
-
type VigorAllAfter = {
|
|
317
|
-
setResult?: (result: any) => any;
|
|
318
|
-
throwError?: (error: Error) => void;
|
|
319
|
-
};
|
|
320
|
-
type VigorAllOnError = {
|
|
321
|
-
setResult?: (result: any) => any;
|
|
322
|
-
throwError?: (error: Error) => void;
|
|
323
|
-
};
|
|
324
|
-
type VigorAllResult = {
|
|
325
|
-
setResult?: (result: Array<any>) => Array<any>;
|
|
326
|
-
throwError?: (error: Error) => void;
|
|
327
|
-
};
|
|
328
|
-
type VigorAllFn<O> = (ctx: VigorAllContext<any>, obj: O) => void | any | Promise<void | any>;
|
|
329
|
-
type VigorAllTaskFn<O> = (ctx: VigorAllTaskContext<any>, obj: O) => void | any | Promise<void | any>;
|
|
330
|
-
type VigorAllBeforeFn = VigorAllTaskFn<VigorAllBefore>;
|
|
331
|
-
type VigorAllAfterFn = VigorAllTaskFn<VigorAllAfter>;
|
|
332
|
-
type VigorAllOnErrorFn = VigorAllTaskFn<VigorAllOnError>;
|
|
333
|
-
type VigorAllResultFn = VigorAllFn<VigorAllResult>;
|
|
334
384
|
type VigorAllInterceptorsConfig = {
|
|
335
|
-
before:
|
|
336
|
-
after:
|
|
337
|
-
|
|
338
|
-
|
|
385
|
+
before: Array<VigorAllInterceptorsFunctions["before"]>;
|
|
386
|
+
after: Array<VigorAllInterceptorsFunctions["after"]>;
|
|
387
|
+
result: Array<VigorAllInterceptorsFunctions["result"]>;
|
|
388
|
+
onError: Array<VigorAllInterceptorsFunctions["onError"]>;
|
|
339
389
|
};
|
|
340
|
-
declare class VigorAllInterceptors extends VigorStatus<VigorAllInterceptorsConfig> {
|
|
390
|
+
declare class VigorAllInterceptors extends VigorStatus<VigorAllInterceptorsConfig, VigorAllInterceptors> {
|
|
341
391
|
constructor(config?: Partial<VigorAllInterceptorsConfig>);
|
|
342
|
-
before(...funcs:
|
|
343
|
-
after(...funcs:
|
|
344
|
-
|
|
345
|
-
|
|
392
|
+
before(...funcs: VigorIncludeSpread<VigorAllInterceptorsConfig["before"][number]>): VigorAllInterceptors;
|
|
393
|
+
after(...funcs: VigorIncludeSpread<VigorAllInterceptorsConfig["after"][number]>): VigorAllInterceptors;
|
|
394
|
+
result(...funcs: VigorIncludeSpread<VigorAllInterceptorsConfig["result"][number]>): VigorAllInterceptors;
|
|
395
|
+
onError(...funcs: VigorIncludeSpread<VigorAllInterceptorsConfig["onError"][number]>): VigorAllInterceptors;
|
|
346
396
|
}
|
|
347
|
-
type
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
};
|
|
351
|
-
type VigorAllTask<R = any> = (ctx: VigorAllTaskContext<any>, obj: VigorAllOptionsTask) => R | Promise<R>;
|
|
352
|
-
type TaskReturn<T> = T extends VigorAllTask<infer R> ? R : never;
|
|
353
|
-
type MapTasks<T extends readonly VigorAllTask<any>[]> = {
|
|
354
|
-
[K in keyof T]: TaskReturn<T[K]>;
|
|
355
|
-
};
|
|
356
|
-
type VigorAllConfig<Tasks extends readonly VigorAllTask<any>[]> = {
|
|
357
|
-
target: Tasks;
|
|
358
|
-
setting: VigorAllSettingsConfig;
|
|
397
|
+
type VigorAllConfig = {
|
|
398
|
+
target: Array<(ctx: VigorAllEachContext) => unknown | Promise<unknown>>;
|
|
399
|
+
settings: VigorAllSettingsConfig;
|
|
359
400
|
interceptors: VigorAllInterceptorsConfig;
|
|
360
401
|
};
|
|
361
|
-
type
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
type
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
402
|
+
type VigorAllInterceptorsApi<R> = {
|
|
403
|
+
setResult: (unk: Array<R>) => void;
|
|
404
|
+
throwError: <E extends Error>(err: E) => never;
|
|
405
|
+
};
|
|
406
|
+
type VigorAllInterceptorsEachApi<R> = {
|
|
407
|
+
setResult: (unk: R) => void;
|
|
408
|
+
throwError: <E extends Error>(err: E) => never;
|
|
409
|
+
};
|
|
410
|
+
type VigorAllInterceptorsFn<A extends keyof VigorAllInterceptorsApi<R>, R = unknown> = (ctx: VigorAllContext, api: Pick<VigorAllInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
411
|
+
type VigorAllInterceptorsEachFn<A extends keyof VigorAllInterceptorsApi<R>, R = unknown> = (ctx: VigorAllEachContext, api: Pick<VigorAllInterceptorsEachApi<R>, A>) => void | Promise<void>;
|
|
412
|
+
type VigorAllInterceptorsFunctions = {
|
|
413
|
+
before: VigorAllInterceptorsEachFn<"throwError">;
|
|
414
|
+
after: VigorAllInterceptorsEachFn<"setResult" | "throwError">;
|
|
415
|
+
result: VigorAllInterceptorsFn<"setResult" | "throwError">;
|
|
416
|
+
onError: VigorAllInterceptorsEachFn<"setResult" | "throwError">;
|
|
417
|
+
};
|
|
418
|
+
type VigorAllContext = {
|
|
419
|
+
result: Array<unknown>;
|
|
420
|
+
timeline: Array<{
|
|
421
|
+
action: string;
|
|
422
|
+
content: unknown;
|
|
423
|
+
}>;
|
|
424
|
+
stats: VigorAllConfig;
|
|
425
|
+
queue: Set<Promise<{
|
|
426
|
+
success: boolean;
|
|
427
|
+
value: unknown;
|
|
428
|
+
}>>;
|
|
429
|
+
};
|
|
430
|
+
type VigorAllEachContext = {
|
|
431
|
+
result: unknown;
|
|
432
|
+
error: unknown;
|
|
433
|
+
timeline: Array<{
|
|
434
|
+
action: string;
|
|
435
|
+
content: unknown;
|
|
436
|
+
}>;
|
|
437
|
+
stats: VigorAllConfig;
|
|
438
|
+
root: VigorAllContext;
|
|
439
|
+
target: VigorAllConfig["target"][number];
|
|
440
|
+
semaphore: {
|
|
441
|
+
acquire: () => Promise<void>;
|
|
442
|
+
release: () => void;
|
|
377
443
|
};
|
|
378
444
|
};
|
|
379
|
-
declare class VigorAll
|
|
380
|
-
constructor(config?: Partial<VigorAllConfig
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
request(): Promise<MapTasks<Tasks>>;
|
|
445
|
+
declare class VigorAll extends VigorStatus<VigorAllConfig, VigorAll> {
|
|
446
|
+
constructor(config?: Partial<VigorAllConfig>);
|
|
447
|
+
target(...funcs: VigorIncludeSpread<VigorAllConfig["target"][number]>): VigorAll;
|
|
448
|
+
settings(func: ((s: VigorAllSettings) => VigorAllSettings) | VigorAllConfig["settings"]): VigorAll;
|
|
449
|
+
interceptors(func: ((s: VigorAllInterceptors) => VigorAllInterceptors) | VigorAllConfig["interceptors"]): VigorAll;
|
|
450
|
+
private runTask;
|
|
451
|
+
request<R extends VigorAllContext["result"]>(config?: VigorAllConfig, timeline?: VigorAllContext["timeline"]): Promise<R>;
|
|
387
452
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
main:
|
|
391
|
-
|
|
392
|
-
setting: typeof VigorRetrySettings;
|
|
453
|
+
declare const VigorEntry: {
|
|
454
|
+
retry: {
|
|
455
|
+
main: typeof VigorRetry;
|
|
456
|
+
settings: typeof VigorRetrySettings;
|
|
393
457
|
interceptors: typeof VigorRetryInterceptors;
|
|
394
|
-
|
|
458
|
+
error: typeof VigorRetryError;
|
|
459
|
+
algorithms: {
|
|
460
|
+
constant: typeof VigorRetryAlgorithmsConstant;
|
|
461
|
+
linear: typeof VigorRetryAlgorithmsLinear;
|
|
462
|
+
backoff: typeof VigorRetryAlgorithmsBackoff;
|
|
463
|
+
custom: typeof VigorRetryAlgorithmsCustom;
|
|
464
|
+
};
|
|
395
465
|
};
|
|
396
|
-
|
|
397
|
-
main:
|
|
398
|
-
|
|
399
|
-
|
|
466
|
+
parse: {
|
|
467
|
+
main: typeof VigorParse;
|
|
468
|
+
settings: typeof VigorParseSettings;
|
|
469
|
+
interceptors: typeof VigorParseInterceptors;
|
|
470
|
+
error: typeof VigorParseError;
|
|
471
|
+
strategies: typeof VigorParseStrategies;
|
|
472
|
+
};
|
|
473
|
+
fetch: {
|
|
474
|
+
main: typeof VigorFetch;
|
|
475
|
+
settings: typeof VigorFetchSettings;
|
|
400
476
|
interceptors: typeof VigorFetchInterceptors;
|
|
477
|
+
error: typeof VigorFetchError;
|
|
401
478
|
};
|
|
402
|
-
|
|
403
|
-
main:
|
|
404
|
-
|
|
405
|
-
setting: typeof VigorAllSettings;
|
|
479
|
+
all: {
|
|
480
|
+
main: typeof VigorAll;
|
|
481
|
+
settings: typeof VigorAllSettings;
|
|
406
482
|
interceptors: typeof VigorAllInterceptors;
|
|
483
|
+
error: typeof VigorAllError;
|
|
407
484
|
};
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
485
|
+
};
|
|
486
|
+
declare const vigor: {
|
|
487
|
+
use: <C, R>(func: (entry: typeof VigorEntry, config: C) => R | Promise<R>, config: C) => Promise<R>;
|
|
488
|
+
fetch: (...strs: Parameters<VigorFetch["origin"]>[0][]) => VigorFetch;
|
|
489
|
+
retry: (target: Parameters<VigorRetry["target"]>[0]) => VigorRetry;
|
|
490
|
+
parse: (response: Parameters<VigorParse["target"]>[0]) => VigorParse;
|
|
491
|
+
all: (...funcs: Parameters<VigorAll["target"]>[0][]) => VigorAll;
|
|
492
|
+
builder: {
|
|
493
|
+
fetch: {
|
|
494
|
+
settings: (c?: Partial<VigorFetchSettingsConfig>) => VigorFetchSettings;
|
|
495
|
+
interceptors: (c?: Partial<VigorFetchInterceptorsConfig>) => VigorFetchInterceptors;
|
|
496
|
+
};
|
|
497
|
+
retry: {
|
|
498
|
+
settings: (c?: Partial<VigorRetrySettingsConfig>) => VigorRetrySettings;
|
|
499
|
+
interceptors: (c?: Partial<VigorRetryInterceptorsConfig>) => VigorRetryInterceptors;
|
|
500
|
+
};
|
|
501
|
+
parse: {
|
|
502
|
+
settings: (c?: Partial<VigorParseSettingsConfig>) => VigorParseSettings;
|
|
503
|
+
interceptors: (c?: Partial<VigorParseInterceptorsConfig>) => VigorParseInterceptors;
|
|
504
|
+
};
|
|
505
|
+
all: {
|
|
506
|
+
settings: (c?: Partial<VigorAllSettingsConfig>) => VigorAllSettings;
|
|
507
|
+
interceptors: (c?: Partial<VigorAllInterceptorsConfig>) => VigorAllInterceptors;
|
|
508
|
+
};
|
|
411
509
|
};
|
|
412
510
|
};
|
|
413
|
-
type VigorConfig = {
|
|
414
|
-
registry: VigorRegistry;
|
|
415
|
-
};
|
|
416
|
-
declare class Vigor {
|
|
417
|
-
private readonly registry;
|
|
418
|
-
constructor(config?: Partial<VigorConfig>);
|
|
419
|
-
fetch(origin: string): VigorFetch<unknown>;
|
|
420
|
-
all<const T extends readonly VigorAllTask<any>[]>(...tasks: T): VigorAll<T>;
|
|
421
|
-
parse(response: Response): VigorParse<unknown, false>;
|
|
422
|
-
retry<T>(fn: VigorRetryTask<T>): VigorRetry<T>;
|
|
423
|
-
use(plugin: (ctx: VigorRegistry, options?: object) => void, options?: object): Vigor;
|
|
424
|
-
}
|
|
425
|
-
declare const vigor: Vigor;
|
|
426
511
|
|
|
427
|
-
export {
|
|
512
|
+
export { VigorEntry, vigor as default, vigor };
|