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/dist/index.d.ts CHANGED
@@ -1,427 +1,512 @@
1
- declare const VIGOR_ERROR_MESSAGES: {
2
- readonly TIMEOUT: ({ limit, attempt }: {
3
- limit: number;
4
- attempt: number;
1
+ declare const VigorErrorMessageFuncs: {
2
+ INVALID_TARGET: ({ expected, received }: {
3
+ expected: Array<string>;
4
+ received: unknown;
5
5
  }) => string;
6
- readonly EXHAUSTED: ({ maxAttempts }: {
6
+ EXHAUSTED: ({ maxAttempts }: {
7
7
  maxAttempts: number;
8
8
  }) => string;
9
- readonly INVALID_URL: ({ received }: {
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
- readonly INVALID_PROTOCOL: ({ expected, received }: {
18
+ PARSER_NOT_FOUND: ({ expected, received, response }: {
13
19
  expected: Array<string>;
14
20
  received: unknown;
21
+ response: Response;
15
22
  }) => string;
16
- readonly FETCH_ERROR: ({ status, statusText, url }: {
17
- status: number;
18
- statusText: string;
19
- url: string;
23
+ PARSER_ALL_FAILED: ({ tried, response }: {
24
+ tried: Array<unknown>;
25
+ response: Response;
20
26
  }) => string;
21
- readonly PARSE_FAILED: ({ expected }: {
22
- expected: unknown;
27
+ INVALID_PROTOCOL: ({ expected, received }: {
28
+ expected: Array<string>;
29
+ received: unknown;
23
30
  }) => string;
24
- readonly INVALID_TYPE: ({ expected, received }: {
25
- expected: unknown;
31
+ INVALID_BODY: ({ expected, received }: {
32
+ expected: Array<string>;
26
33
  received: unknown;
27
34
  }) => string;
28
- readonly TARGET_MISSING: () => string;
29
- readonly REQUEST_FAILED: ({ index, error }: {
30
- index: number;
31
- error: Error;
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
- readonly RESULT_NOT_SET: () => string;
34
- readonly UNKNOWN: () => string;
43
+ EMPTY_TARGET: ({}: {}) => string;
35
44
  };
36
- type VigorErrorCode = keyof typeof VIGOR_ERROR_MESSAGES;
37
- type ErrorData<C extends VigorErrorCode> = Parameters<typeof VIGOR_ERROR_MESSAGES[C]> extends [infer A] ? A : undefined;
38
- type VigorErrorOptions<C extends VigorErrorCode> = {
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
- context?: unknown;
42
- type?: string;
43
- data: ErrorData<C>;
49
+ data?: VigorErrorDatas<C>;
50
+ method: string;
51
+ stats?: S;
52
+ context?: T;
44
53
  };
45
- declare abstract class VigorError<C extends VigorErrorCode> extends Error {
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 context?: unknown;
51
- readonly type?: string;
52
- readonly data: ErrorData<C>;
53
- constructor(code: C, options: VigorErrorOptions<C>);
54
- }
55
- declare class VigorRetryError<C extends "TIMEOUT" | "EXHAUSTED"> extends VigorError<C> {
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 VigorParseError<C extends "PARSE_FAILED" | "INVALID_TYPE" | "TARGET_MISSING"> extends VigorError<C> {
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 VigorFetchError<C extends "FETCH_ERROR" | "INVALID_URL" | "INVALID_PROTOCOL"> extends VigorError<C> {
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 VigorAllError<C extends "REQUEST_FAILED" | "TARGET_MISSING" | "RESULT_NOT_SET"> extends VigorError<C> {
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 const EMPTY: unique symbol;
68
- declare abstract class VigorStatus<T> {
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
- type VigorIncludeSpread<T> = Array<(T | Array<T>)>;
78
- type VigorRetrySettingsConfig<T> = {
79
- count: number;
80
- limit: number;
81
- maxDelay: number;
82
- default?: T | typeof EMPTY;
83
- };
84
- declare class VigorRetrySettings<T> extends VigorStatus<VigorRetrySettingsConfig<T>> {
85
- constructor(config?: Partial<VigorRetrySettingsConfig<T>>);
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 VigorRetryBackoffConfig<T> = {
92
- initialDelay: number;
93
- baseDelay: number;
94
- factor: number;
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 VigorRetryBackoff<T> extends VigorStatus<VigorRetryBackoffConfig<T>> {
98
- constructor(config?: Partial<VigorRetryBackoffConfig<T>>);
99
- initialDelay(num: number): this;
100
- baseDelay(num: number): this;
101
- factor(num: number): this;
102
- jitter(num: number): this;
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 VigorRetryBefore<T> = {
106
- setAttempt: (attempt: number) => number;
107
- throwError: (error: Error) => void;
108
- abort: (error: Error) => void;
109
- };
110
- type VigorRetryAfter<T> = {
111
- setAttempt: (attempt: number) => number;
112
- throwError: (error: Error) => void;
113
- setResult: (result: T) => T;
114
- };
115
- type VigorRetryRetryIf<T> = {
116
- throwError: (error: Error) => void;
117
- proceedRetry: () => boolean;
118
- cancelRetry: (error?: Error) => boolean;
119
- };
120
- type VigorRetryOnRetry<T> = {
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 VigorRetryTask<T> = (ctx: VigorRetryContext<T>, obj: VigorRetryOptionsTask<T>) => T | Promise<T>;
155
- type VigorRetryConfig<T> = {
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
- type VigorRetryContext<T> = VigorRetryConfig<T> & {
163
- runtime: {
164
- result?: T | typeof EMPTY;
165
- attempt: number;
166
- controller: AbortController;
167
- abortPromise?: Promise<never>;
168
- aborted: boolean;
169
- signal: AbortSignal;
170
- delay: number;
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 VigorRetry<T> extends VigorStatus<VigorRetryConfig<T>> {
176
- constructor(config?: Partial<VigorRetryConfig<T>>);
177
- private _transfer;
178
- private _calculateDelay;
179
- createController(): VigorRetryConfig<T>["controller"];
180
- target<U>(func: VigorRetryConfig<U>["target"]): VigorRetry<U>;
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 VigorParseConfig<T, O = false> = {
187
- target?: Response;
188
- original: O;
189
- type?: (keyof Response) | undefined;
190
- result?: T;
191
- };
192
- declare class VigorParse<T, O extends boolean = false> extends VigorStatus<VigorParseConfig<T, O>> {
193
- constructor(config?: Partial<VigorParseConfig<T, O> & {
194
- original: O;
195
- }>);
196
- static stategy: {
197
- key: RegExp;
198
- parse: (res: Response) => Promise<any>;
199
- type: string;
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 VigorFetchMethods = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE";
209
- type VigorFetchSettingsConfig<T> = {
210
- origin?: string;
211
- path?: Array<string>;
212
- query?: object;
213
- unretry?: Array<number>;
214
- retryHeaders?: Array<string>;
215
- method?: VigorFetchMethods;
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 VigorFetchBefore<T> = {
235
- setOptions?: (obj: object) => void;
236
- throwError?: (error: Error) => void;
237
- };
238
- type VigorFetchAfter<T> = {
239
- throwError?: (error: Error) => void;
240
- };
241
- type VigorFetchOnError<T> = {
242
- setResult?: (result: T) => T;
243
- throwError?: (error: Error) => void;
244
- };
245
- type VigorFetchResult<T> = {
246
- setResult?: (result: T) => T;
247
- throwError?: (error: Error) => void;
248
- };
249
- type VigorFetchFn<T, O> = (ctx: VigorFetchContext<T>, obj: O) => void | any | Promise<void | any>;
250
- type VigorFetchBeforeFn<T> = VigorFetchFn<T, VigorFetchBefore<T>>;
251
- type VigorFetchAfterFn<T> = VigorFetchFn<T, VigorFetchAfter<T>>;
252
- type VigorFetchOnErrorFn<T> = VigorFetchFn<T, VigorFetchOnError<T>>;
253
- type VigorFetchResultFn<T> = VigorFetchFn<T, VigorFetchResult<T>>;
254
- type VigorFetchInterceptorsConfig<T> = {
255
- before: VigorFetchBeforeFn<T>[];
256
- after: VigorFetchAfterFn<T>[];
257
- onError: VigorFetchOnErrorFn<T>[];
258
- result: VigorFetchResultFn<T>[];
259
- };
260
- declare class VigorFetchInterceptors<T> extends VigorStatus<VigorFetchInterceptorsConfig<T>> {
261
- constructor(config?: Partial<VigorFetchInterceptorsConfig<T>>);
262
- before(...funcs: VigorIncludeSpread<VigorFetchBeforeFn<T>>): VigorFetchInterceptors<T>;
263
- after(...funcs: VigorIncludeSpread<VigorFetchAfterFn<T>>): VigorFetchInterceptors<T>;
264
- onError(...funcs: VigorIncludeSpread<VigorFetchOnErrorFn<T>>): VigorFetchInterceptors<T>;
265
- result(...funcs: VigorIncludeSpread<VigorFetchResultFn<T>>): VigorFetchInterceptors<T>;
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 VigorFetchConfig<T> = {
268
- setting: VigorFetchSettingsConfig<T>;
269
- retryConfig: VigorRetryConfig<T>;
270
- parseConfig: VigorParseConfig<T>;
271
- interceptors: VigorFetchInterceptorsConfig<T>;
272
- };
273
- type VigorFetchContext<T> = VigorFetchConfig<T> & {
274
- runtime: {
275
- retryEngine?: VigorRetry<T>;
276
- parseEngine?: VigorParse<T>;
277
- unretrySet?: Set<number>;
278
- url?: string;
279
- baseOptions?: object;
280
- options?: object;
281
- response?: Response;
282
- result?: T | typeof EMPTY;
283
- error?: unknown;
284
- };
285
- };
286
- declare class VigorFetch<T> extends VigorStatus<VigorFetchConfig<T>> {
287
- constructor(config?: Partial<VigorFetchConfig<T>>);
288
- origin(str: string): this;
289
- path(...strs: (string | number | (string | number)[])[]): this;
290
- query(obj: object): this;
291
- method(str: VigorFetchMethods): this;
292
- headers(obj: HeadersInit | Record<string, any>): this;
293
- body(obj: XMLHttpRequestBodyInit | object | null): this;
294
- options(obj: object): this;
295
- setting(func: (r: VigorFetchSettings<T>) => VigorFetchSettings<T>): this;
296
- interceptors(func: (r: VigorFetchInterceptors<T>) => VigorFetchInterceptors<T>): this;
297
- retryConfig(func: (r: VigorRetry<T>) => VigorRetry<T>): this;
298
- parseConfig(func: (r: VigorParse<T>) => VigorParse<T>): this;
299
- buildUrl(origin: string, path: string[], query: object): string;
300
- request<U = T>(): Promise<U>;
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: number): VigorAllSettings;
310
- jitter(num: number): VigorAllSettings;
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: VigorAllBeforeFn[];
336
- after: VigorAllAfterFn[];
337
- onError: VigorAllOnErrorFn[];
338
- result: VigorAllResultFn[];
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: (VigorAllBeforeFn | VigorAllBeforeFn[])[]): VigorAllInterceptors;
343
- after(...funcs: (VigorAllAfterFn | VigorAllAfterFn[])[]): VigorAllInterceptors;
344
- onError(...funcs: (VigorAllOnErrorFn | VigorAllOnErrorFn[])[]): VigorAllInterceptors;
345
- result(...funcs: (VigorAllResultFn | VigorAllResultFn[])[]): VigorAllInterceptors;
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 VigorAllOptionsTask = {
348
- abort?: (error: Error) => void;
349
- signal?: AbortSignal;
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 VigorAllContext<Tasks extends readonly VigorAllTask<any>[]> = VigorAllConfig<Tasks> & {
362
- runtime: {
363
- tasks: {
364
- [K in keyof Tasks]: Promise<TaskReturn<Tasks[K]>>;
365
- };
366
- result: {
367
- [K in keyof Tasks]: TaskReturn<Tasks[K]> | Error;
368
- };
369
- };
370
- };
371
- type VigorAllTaskContext<Task extends VigorAllTask<any>> = {
372
- target: Task;
373
- runtime: {
374
- result: TaskReturn<Task> | typeof EMPTY;
375
- error: unknown;
376
- jitter: number;
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<Tasks extends readonly VigorAllTask<any>[]> extends VigorStatus<VigorAllConfig<Tasks>> {
380
- constructor(config?: Partial<VigorAllConfig<Tasks>>);
381
- private _transfer;
382
- target<T extends readonly VigorAllTask<any>[]>(funcs: T): VigorAll<T>;
383
- target<T extends readonly VigorAllTask<any>[]>(...funcs: T): VigorAll<T>;
384
- setting(func: (r: VigorAllSettings) => VigorAllSettings): this;
385
- interceptors(func: (r: VigorAllInterceptors) => VigorAllInterceptors): this;
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
- type VigorRegistry = {
389
- VigorRetry: {
390
- main: <T>() => VigorRetry<T>;
391
- error: typeof VigorRetryError;
392
- setting: typeof VigorRetrySettings;
453
+ declare const VigorEntry: {
454
+ retry: {
455
+ main: typeof VigorRetry;
456
+ settings: typeof VigorRetrySettings;
393
457
  interceptors: typeof VigorRetryInterceptors;
394
- backoff: typeof VigorRetryBackoff;
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
- VigorFetch: {
397
- main: <T>() => VigorFetch<T>;
398
- error: typeof VigorFetchError;
399
- setting: typeof VigorFetchSettings;
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
- VigorAll: {
403
- main: () => VigorAll<any>;
404
- error: typeof VigorAllError;
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
- VigorParse: {
409
- main: <T>() => VigorParse<T>;
410
- error: typeof VigorParseError;
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 { Vigor, VigorAll, VigorAllError, VigorAllInterceptors, VigorAllSettings, VigorFetch, VigorFetchError, VigorFetchInterceptors, VigorFetchSettings, VigorParse, VigorParseError, VigorRetry, VigorRetryBackoff, VigorRetryError, VigorRetryInterceptors, VigorRetrySettings, vigor as default, vigor };
512
+ export { VigorEntry, vigor as default, vigor };