vigor-fetch 3.0.1 → 3.1.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 +5 -22
- package/dist/index.d.ts +296 -30
- package/dist/index.js +769 -232
- package/dist/index.mjs +769 -232
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vigor-fetch
|
|
2
2
|
|
|
3
|
-
## Vigor is a composable, lightweighted (minified + gzipped ~5.
|
|
3
|
+
## Vigor is a composable, lightweighted (minified + gzipped ~5.8kb) network workflow toolkit built on top of native Fetch.
|
|
4
4
|
|
|
5
5
|
> Vigor provides a fluent, chainable API for building robust network logic with built-in retry, backoff, interceptors, parsing, and concurrency control.
|
|
6
6
|
|
|
@@ -57,6 +57,7 @@ const data = await vigor
|
|
|
57
57
|
.request();
|
|
58
58
|
// -> https://api.example.com/api/v1/main
|
|
59
59
|
```
|
|
60
|
+
|
|
60
61
|
#### Advanced
|
|
61
62
|
```ts
|
|
62
63
|
const data = await vigor
|
|
@@ -70,7 +71,7 @@ const data = await vigor
|
|
|
70
71
|
)
|
|
71
72
|
.interceptors(i => i
|
|
72
73
|
.onError((ctx, api) => {
|
|
73
|
-
api.
|
|
74
|
+
api.restart();
|
|
74
75
|
})
|
|
75
76
|
)
|
|
76
77
|
.request();
|
|
@@ -702,6 +703,7 @@ const data = await vigor
|
|
|
702
703
|
|
|
703
704
|
| Method | Description |
|
|
704
705
|
|---|---|
|
|
706
|
+
| method(http method) | Forces the http method |
|
|
705
707
|
| origin(...paths) | Sets base URL and origin paths |
|
|
706
708
|
| path(...paths) | Appends request paths |
|
|
707
709
|
| query(params) | Sets query parameters |
|
|
@@ -934,7 +936,7 @@ Runs when fetch fails.
|
|
|
934
936
|
|---|---|
|
|
935
937
|
| setResult(value) | Returns fallback value |
|
|
936
938
|
| throwError(error) | Throws error |
|
|
937
|
-
|
|
|
939
|
+
| restart() | Re-executes fetch pipeline |
|
|
938
940
|
|
|
939
941
|
---
|
|
940
942
|
|
|
@@ -1064,25 +1066,6 @@ Runs before task execution starts.
|
|
|
1064
1066
|
|
|
1065
1067
|
---
|
|
1066
1068
|
|
|
1067
|
-
### afterEach
|
|
1068
|
-
|
|
1069
|
-
Runs after each task resolves.
|
|
1070
|
-
|
|
1071
|
-
```ts
|
|
1072
|
-
.afterEach(async (ctx, api) => {
|
|
1073
|
-
console.log(ctx.result);
|
|
1074
|
-
})
|
|
1075
|
-
```
|
|
1076
|
-
|
|
1077
|
-
#### Available APIs
|
|
1078
|
-
|
|
1079
|
-
| API | Description |
|
|
1080
|
-
|---|---|
|
|
1081
|
-
| setResult(value) | Replaces task result |
|
|
1082
|
-
| throwError(error) | Throws error |
|
|
1083
|
-
|
|
1084
|
-
---
|
|
1085
|
-
|
|
1086
1069
|
### after
|
|
1087
1070
|
|
|
1088
1071
|
Runs after all tasks complete.
|
package/dist/index.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ declare abstract class VigorStatus<C, Self> {
|
|
|
78
78
|
protected readonly ctor: (config: C) => Self;
|
|
79
79
|
protected readonly _config: C;
|
|
80
80
|
constructor(config: Partial<C> | undefined, _base: C, ctor: (config: C) => Self);
|
|
81
|
-
protected _mergeConfig
|
|
81
|
+
protected _mergeConfig(source: any, target: C | Partial<C> | undefined): C;
|
|
82
82
|
protected _next(config: Partial<C>): Self;
|
|
83
83
|
_getConfig(): C;
|
|
84
84
|
_getBase(): C;
|
|
@@ -195,15 +195,74 @@ type VigorRetryContext = {
|
|
|
195
195
|
attempt: number;
|
|
196
196
|
delay: number;
|
|
197
197
|
controller: AbortController;
|
|
198
|
-
timeline: Array<
|
|
199
|
-
action: string;
|
|
200
|
-
content?: unknown;
|
|
201
|
-
}>;
|
|
198
|
+
timeline: Array<VigorRetryTimelineItem<any, any>>;
|
|
202
199
|
stats: VigorRetryConfig;
|
|
200
|
+
flag: {
|
|
201
|
+
broke: boolean;
|
|
202
|
+
overwritten: boolean;
|
|
203
|
+
restarted: boolean;
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
type VigorRetryTimelineItem<I extends keyof VigorRetryInterceptorsFunctions, H extends keyof VigorRetryProcessHandler> = {
|
|
207
|
+
[K in keyof VigorRetryTimeline<I, H>]: {
|
|
208
|
+
action: K;
|
|
209
|
+
content: VigorRetryTimeline<I, H>[K];
|
|
210
|
+
time: number;
|
|
211
|
+
};
|
|
212
|
+
}[keyof VigorRetryTimeline<I, H>];
|
|
213
|
+
type VigorRetryAllowedApis<I extends keyof VigorRetryInterceptorsFunctions> = VigorRetryInterceptorsFunctions[I] extends VigorRetryInterceptorsFn<infer A, any> ? A : never;
|
|
214
|
+
type VigorRetryProcessHandler = {
|
|
215
|
+
REQUEST_START: {};
|
|
216
|
+
REQUEST_ERROR: {
|
|
217
|
+
error: unknown;
|
|
218
|
+
};
|
|
219
|
+
RETRY_START: {};
|
|
220
|
+
RETRY_ERROR: {
|
|
221
|
+
error: unknown;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
type VigorRetryTimeline<I extends keyof VigorRetryInterceptorsFunctions, H extends keyof VigorRetryProcessHandler> = {
|
|
225
|
+
ATTEMPT_INCREASED: {
|
|
226
|
+
attempt: VigorRetryContext["attempt"];
|
|
227
|
+
};
|
|
228
|
+
PROCESS_HANDLING: {
|
|
229
|
+
type: H;
|
|
230
|
+
data: VigorRetryProcessHandler[H];
|
|
231
|
+
};
|
|
232
|
+
TARGET_REQUEST_STARTED: {
|
|
233
|
+
target: VigorRetryConfig["target"];
|
|
234
|
+
};
|
|
235
|
+
TARGET_REQUEST_ENDED: {
|
|
236
|
+
target: VigorRetryConfig["target"];
|
|
237
|
+
took: number;
|
|
238
|
+
};
|
|
239
|
+
TARGET_API_CALLED: {
|
|
240
|
+
target: VigorRetryConfig["target"];
|
|
241
|
+
method: string;
|
|
242
|
+
};
|
|
243
|
+
INTERCEPTOR_LOOP_STARTED: {
|
|
244
|
+
interceptorType: I;
|
|
245
|
+
interceptors: Array<VigorRetryInterceptorsFunctions[I]>;
|
|
246
|
+
};
|
|
247
|
+
INTERCEPTOR_LOOP_ENDED: {
|
|
248
|
+
interceptorType: I;
|
|
249
|
+
interceptors: Array<VigorRetryInterceptorsFunctions[I]>;
|
|
250
|
+
took: number;
|
|
251
|
+
};
|
|
252
|
+
INTERCEPTOR_API_CALLED: {
|
|
253
|
+
[A in VigorRetryAllowedApis<I>]: {
|
|
254
|
+
interceptorType: I;
|
|
255
|
+
interceptor: VigorRetryInterceptorsFunctions[I];
|
|
256
|
+
method: A;
|
|
257
|
+
args: Parameters<VigorRetryInterceptorsApi<any>[A]>;
|
|
258
|
+
};
|
|
259
|
+
}[VigorRetryAllowedApis<I>];
|
|
203
260
|
};
|
|
204
261
|
declare class VigorRetry extends VigorStatus<VigorRetryConfig, VigorRetry> {
|
|
205
262
|
constructor(config?: Partial<VigorRetryConfig>);
|
|
206
263
|
private RetryAlgorithms;
|
|
264
|
+
private _createTimelineHandler;
|
|
265
|
+
private _createInterceptorHandler;
|
|
207
266
|
target(func: VigorRetryConfig["target"]): VigorRetry;
|
|
208
267
|
settings(func: ((s: VigorRetrySettings) => VigorRetrySettings) | VigorRetryConfig["settings"]): VigorRetry;
|
|
209
268
|
interceptors(func: ((i: VigorRetryInterceptors) => VigorRetryInterceptors) | VigorRetryConfig["interceptors"]): VigorRetry;
|
|
@@ -271,16 +330,55 @@ type VigorParseConfig = {
|
|
|
271
330
|
};
|
|
272
331
|
type VigorParseContext = {
|
|
273
332
|
stats: VigorParseConfig;
|
|
274
|
-
timeline: Array<
|
|
275
|
-
action: string;
|
|
276
|
-
content?: unknown;
|
|
277
|
-
}>;
|
|
333
|
+
timeline: Array<VigorParseTimelineItem<any, any>>;
|
|
278
334
|
result: unknown;
|
|
279
335
|
error: unknown;
|
|
280
336
|
response: Response;
|
|
337
|
+
flag: {
|
|
338
|
+
overwritten: boolean;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
type VigorParseTimelineItem<I extends keyof VigorParseInterceptorsFunctions, H extends keyof VigorParseProcessHandler> = {
|
|
342
|
+
[K in keyof VigorParseTimeline<I, H>]: {
|
|
343
|
+
action: K;
|
|
344
|
+
content: VigorParseTimeline<I, H>[K];
|
|
345
|
+
time: number;
|
|
346
|
+
};
|
|
347
|
+
}[keyof VigorParseTimeline<I, H>];
|
|
348
|
+
type VigorParseAllowedApis<I extends keyof VigorParseInterceptorsFunctions> = VigorParseInterceptorsFunctions[I] extends VigorParseInterceptorsFn<infer A, any> ? A : never;
|
|
349
|
+
type VigorParseProcessHandler = {
|
|
350
|
+
REQUEST_START: {};
|
|
351
|
+
REQUEST_ERROR: {
|
|
352
|
+
error: unknown;
|
|
353
|
+
};
|
|
354
|
+
};
|
|
355
|
+
type VigorParseTimeline<I extends keyof VigorParseInterceptorsFunctions, H extends keyof VigorParseProcessHandler> = {
|
|
356
|
+
PROCESS_HANDLING: {
|
|
357
|
+
type: H;
|
|
358
|
+
data: VigorRetryProcessHandler[H];
|
|
359
|
+
};
|
|
360
|
+
INTERCEPTOR_LOOP_STARTED: {
|
|
361
|
+
interceptorType: I;
|
|
362
|
+
interceptors: Array<VigorParseInterceptorsFunctions[I]>;
|
|
363
|
+
};
|
|
364
|
+
INTERCEPTOR_LOOP_ENDED: {
|
|
365
|
+
interceptorType: I;
|
|
366
|
+
interceptors: Array<VigorParseInterceptorsFunctions[I]>;
|
|
367
|
+
took: number;
|
|
368
|
+
};
|
|
369
|
+
INTERCEPTOR_API_CALLED: {
|
|
370
|
+
[A in VigorParseAllowedApis<I>]: {
|
|
371
|
+
interceptorType: I;
|
|
372
|
+
interceptor: VigorParseInterceptorsFunctions[I];
|
|
373
|
+
method: A;
|
|
374
|
+
args: Parameters<VigorParseInterceptorsApi<any>[A]>;
|
|
375
|
+
};
|
|
376
|
+
}[VigorParseAllowedApis<I>];
|
|
281
377
|
};
|
|
282
378
|
declare class VigorParse extends VigorStatus<VigorParseConfig, VigorParse> {
|
|
283
379
|
constructor(config?: Partial<VigorParseConfig>);
|
|
380
|
+
private _createTimelineHandler;
|
|
381
|
+
private _createInterceptorHandler;
|
|
284
382
|
target(response: VigorParseConfig["target"]): VigorParse;
|
|
285
383
|
settings(func: ((i: VigorParseSettings) => VigorParseSettings) | VigorParseConfig["settings"]): VigorParse;
|
|
286
384
|
strategies(func: ((i: VigorParseStrategies) => VigorParseStrategies) | VigorParseConfig["strategies"]): VigorParse;
|
|
@@ -315,7 +413,9 @@ type VigorFetchOptions<T = Record<string, any>> = {
|
|
|
315
413
|
headers: HeadersInit | Record<string, any>;
|
|
316
414
|
body?: XMLHttpRequestBodyInit | object | null;
|
|
317
415
|
} & T;
|
|
416
|
+
type VigorStringable = string | number | boolean | null | undefined | Date;
|
|
318
417
|
type VigorFetchConfig = {
|
|
418
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE";
|
|
319
419
|
origin: Array<string>;
|
|
320
420
|
path: Array<string>;
|
|
321
421
|
query: Array<Record<string, VigorStringable | Array<VigorStringable>>>;
|
|
@@ -347,16 +447,84 @@ type VigorFetchContext = {
|
|
|
347
447
|
result: unknown;
|
|
348
448
|
error: unknown;
|
|
349
449
|
options: VigorFetchOptions;
|
|
350
|
-
timeline: Array<
|
|
351
|
-
action: string;
|
|
352
|
-
content?: unknown;
|
|
353
|
-
}>;
|
|
450
|
+
timeline: Array<VigorFetchTimelineItem<any, any>>;
|
|
354
451
|
stats: VigorFetchConfig;
|
|
452
|
+
flag: {
|
|
453
|
+
overwritten: boolean;
|
|
454
|
+
restarted: boolean;
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
type VigorFetchTimelineItem<I extends keyof VigorFetchInterceptorsFunctions, H extends keyof VigorFetchProcessHandler> = {
|
|
458
|
+
[K in keyof VigorFetchTimeline<I, H>]: {
|
|
459
|
+
action: K;
|
|
460
|
+
content: VigorFetchTimeline<I, H>[K];
|
|
461
|
+
time: number;
|
|
462
|
+
};
|
|
463
|
+
}[keyof VigorFetchTimeline<I, H>];
|
|
464
|
+
type VigorFetchAllowedApis<I extends keyof VigorFetchInterceptorsFunctions> = VigorFetchInterceptorsFunctions[I] extends VigorFetchInterceptorsFn<infer A, any> ? A : never;
|
|
465
|
+
type VigorFetchProcessHandler = {
|
|
466
|
+
REQUEST_START: {};
|
|
467
|
+
REQUEST_ERROR: {
|
|
468
|
+
error: unknown;
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
type VigorFetchTimeline<I extends keyof VigorFetchInterceptorsFunctions, H extends keyof VigorFetchProcessHandler> = {
|
|
472
|
+
PROCESS_HANDLING: {
|
|
473
|
+
type: H;
|
|
474
|
+
data: VigorFetchProcessHandler[H];
|
|
475
|
+
};
|
|
476
|
+
BUILT_URL: {
|
|
477
|
+
url: ReturnType<VigorFetch["_buildUrl"]>;
|
|
478
|
+
};
|
|
479
|
+
SET_OPTIONS: {
|
|
480
|
+
options: VigorFetchContext["options"];
|
|
481
|
+
};
|
|
482
|
+
ENGINE_CREATED: {
|
|
483
|
+
retryEngine: VigorRetry;
|
|
484
|
+
parseEngine: VigorParse;
|
|
485
|
+
};
|
|
486
|
+
RETRY_STARTED: {
|
|
487
|
+
engine: VigorRetry;
|
|
488
|
+
};
|
|
489
|
+
RETRY_ENDED: {
|
|
490
|
+
engine: VigorRetry;
|
|
491
|
+
timeline: VigorRetryContext["timeline"];
|
|
492
|
+
took: number;
|
|
493
|
+
response: VigorFetchContext["response"];
|
|
494
|
+
};
|
|
495
|
+
PARSE_STARTED: {
|
|
496
|
+
engine: VigorParse;
|
|
497
|
+
};
|
|
498
|
+
PARSE_ENDED: {
|
|
499
|
+
engine: VigorParse;
|
|
500
|
+
timeline: VigorParseContext["timeline"];
|
|
501
|
+
took: number;
|
|
502
|
+
result: VigorFetchContext["result"];
|
|
503
|
+
};
|
|
504
|
+
INTERCEPTOR_LOOP_STARTED: {
|
|
505
|
+
interceptorType: I;
|
|
506
|
+
interceptors: Array<VigorFetchInterceptorsFunctions[I]>;
|
|
507
|
+
};
|
|
508
|
+
INTERCEPTOR_LOOP_ENDED: {
|
|
509
|
+
interceptorType: I;
|
|
510
|
+
interceptors: Array<VigorFetchInterceptorsFunctions[I]>;
|
|
511
|
+
took: number;
|
|
512
|
+
};
|
|
513
|
+
INTERCEPTOR_API_CALLED: {
|
|
514
|
+
[A in VigorFetchAllowedApis<I>]: {
|
|
515
|
+
interceptorType: I;
|
|
516
|
+
interceptor: VigorFetchInterceptorsFunctions[I];
|
|
517
|
+
method: A;
|
|
518
|
+
args: Parameters<VigorFetchInterceptorsApi<any>[A]>;
|
|
519
|
+
};
|
|
520
|
+
}[VigorFetchAllowedApis<I>];
|
|
355
521
|
};
|
|
356
|
-
type VigorStringable = string | number | boolean | null | undefined | Date;
|
|
357
522
|
declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
|
|
358
523
|
constructor(config?: Partial<VigorFetchConfig>);
|
|
524
|
+
private _createTimelineHandler;
|
|
525
|
+
private _createInterceptorHandler;
|
|
359
526
|
private _stringifyList;
|
|
527
|
+
method(str: VigorFetchConfig["method"]): VigorFetch;
|
|
360
528
|
origin(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
361
529
|
path(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
362
530
|
query(...strs: VigorIncludeSpread<VigorFetchConfig["query"][number]>): VigorFetch;
|
|
@@ -382,10 +550,10 @@ declare class VigorAllSettings extends VigorStatus<VigorAllSettingsConfig, Vigor
|
|
|
382
550
|
onlySuccess(num: VigorAllSettingsConfig["onlySuccess"]): VigorAllSettings;
|
|
383
551
|
}
|
|
384
552
|
type VigorAllInterceptorsConfig = {
|
|
385
|
-
before: Array<
|
|
386
|
-
after: Array<
|
|
553
|
+
before: Array<VigorAllEachInterceptorsFunctions["before"]>;
|
|
554
|
+
after: Array<VigorAllEachInterceptorsFunctions["after"]>;
|
|
387
555
|
result: Array<VigorAllInterceptorsFunctions["result"]>;
|
|
388
|
-
onError: Array<
|
|
556
|
+
onError: Array<VigorAllEachInterceptorsFunctions["onError"]>;
|
|
389
557
|
};
|
|
390
558
|
declare class VigorAllInterceptors extends VigorStatus<VigorAllInterceptorsConfig, VigorAllInterceptors> {
|
|
391
559
|
constructor(config?: Partial<VigorAllInterceptorsConfig>);
|
|
@@ -403,37 +571,34 @@ type VigorAllInterceptorsApi<R> = {
|
|
|
403
571
|
setResult: (unk: Array<R>) => void;
|
|
404
572
|
throwError: <E extends Error>(err: E) => never;
|
|
405
573
|
};
|
|
406
|
-
type
|
|
574
|
+
type VigorAllEachInterceptorsApi<R> = {
|
|
407
575
|
setResult: (unk: R) => void;
|
|
408
576
|
throwError: <E extends Error>(err: E) => never;
|
|
409
577
|
};
|
|
410
578
|
type VigorAllInterceptorsFn<A extends keyof VigorAllInterceptorsApi<R>, R = unknown> = (ctx: VigorAllContext, api: Pick<VigorAllInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
411
|
-
type
|
|
579
|
+
type VigorAllEachInterceptorsFn<A extends keyof VigorAllInterceptorsApi<R>, R = unknown> = (ctx: VigorAllEachContext, api: Pick<VigorAllEachInterceptorsApi<R>, A>) => void | Promise<void>;
|
|
412
580
|
type VigorAllInterceptorsFunctions = {
|
|
413
|
-
before: VigorAllInterceptorsEachFn<"throwError">;
|
|
414
|
-
after: VigorAllInterceptorsEachFn<"setResult" | "throwError">;
|
|
415
581
|
result: VigorAllInterceptorsFn<"setResult" | "throwError">;
|
|
416
|
-
|
|
582
|
+
};
|
|
583
|
+
type VigorAllEachInterceptorsFunctions = {
|
|
584
|
+
before: VigorAllEachInterceptorsFn<"throwError">;
|
|
585
|
+
after: VigorAllEachInterceptorsFn<"setResult" | "throwError">;
|
|
586
|
+
onError: VigorAllEachInterceptorsFn<"setResult" | "throwError">;
|
|
417
587
|
};
|
|
418
588
|
type VigorAllContext = {
|
|
419
589
|
result: Array<unknown>;
|
|
420
|
-
timeline: Array<
|
|
421
|
-
action: string;
|
|
422
|
-
content: unknown;
|
|
423
|
-
}>;
|
|
590
|
+
timeline: Array<VigorAllTimelineItem<any, any>>;
|
|
424
591
|
stats: VigorAllConfig;
|
|
425
592
|
queue: Set<Promise<{
|
|
426
593
|
success: boolean;
|
|
427
594
|
value: unknown;
|
|
428
595
|
}>>;
|
|
596
|
+
active: number;
|
|
429
597
|
};
|
|
430
598
|
type VigorAllEachContext = {
|
|
431
599
|
result: unknown;
|
|
432
600
|
error: unknown;
|
|
433
|
-
timeline: Array<
|
|
434
|
-
action: string;
|
|
435
|
-
content: unknown;
|
|
436
|
-
}>;
|
|
601
|
+
timeline: Array<VigorAllEachTimelineItem<any, any>>;
|
|
437
602
|
stats: VigorAllConfig;
|
|
438
603
|
root: VigorAllContext;
|
|
439
604
|
target: VigorAllConfig["target"][number];
|
|
@@ -441,9 +606,110 @@ type VigorAllEachContext = {
|
|
|
441
606
|
acquire: () => Promise<void>;
|
|
442
607
|
release: () => void;
|
|
443
608
|
};
|
|
609
|
+
flag: {
|
|
610
|
+
overwritten: boolean;
|
|
611
|
+
};
|
|
612
|
+
};
|
|
613
|
+
type VigorAllTimelineItem<I extends keyof VigorAllInterceptorsFunctions, H extends keyof VigorAllProcessHandler> = {
|
|
614
|
+
[K in keyof VigorAllTimeline<I, H>]: {
|
|
615
|
+
action: K;
|
|
616
|
+
content: VigorAllTimeline<I, H>[K];
|
|
617
|
+
time: number;
|
|
618
|
+
};
|
|
619
|
+
}[keyof VigorAllTimeline<I, H>];
|
|
620
|
+
type VigorAllAllowedApis<I extends keyof VigorAllInterceptorsFunctions> = VigorAllInterceptorsFunctions[I] extends VigorAllInterceptorsFn<infer A, any> ? A : never;
|
|
621
|
+
type VigorAllProcessHandler = {
|
|
622
|
+
REQUEST_START: {};
|
|
623
|
+
REQUEST_ERROR: {
|
|
624
|
+
error: unknown;
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
type VigorAllTimeline<I extends keyof VigorAllInterceptorsFunctions, H extends keyof VigorAllProcessHandler> = {
|
|
628
|
+
PROCESS_HANDLING: {
|
|
629
|
+
type: H;
|
|
630
|
+
data: VigorAllProcessHandler[H];
|
|
631
|
+
};
|
|
632
|
+
QUEUE_REQUEST_STARTED: {
|
|
633
|
+
queue: VigorAllContext["queue"];
|
|
634
|
+
};
|
|
635
|
+
QUEUE_REQUEST_ENDED: {
|
|
636
|
+
queue: VigorAllContext["queue"];
|
|
637
|
+
took: number;
|
|
638
|
+
};
|
|
639
|
+
INTERCEPTOR_LOOP_STARTED: {
|
|
640
|
+
interceptorType: I;
|
|
641
|
+
interceptors: Array<VigorAllInterceptorsFunctions[I]>;
|
|
642
|
+
};
|
|
643
|
+
INTERCEPTOR_LOOP_ENDED: {
|
|
644
|
+
interceptorType: I;
|
|
645
|
+
interceptors: Array<VigorAllInterceptorsFunctions[I]>;
|
|
646
|
+
took: number;
|
|
647
|
+
};
|
|
648
|
+
INTERCEPTOR_API_CALLED: {
|
|
649
|
+
[A in VigorAllAllowedApis<I>]: {
|
|
650
|
+
interceptorType: I;
|
|
651
|
+
interceptor: VigorAllInterceptorsFunctions[I];
|
|
652
|
+
method: A;
|
|
653
|
+
args: Parameters<VigorAllInterceptorsApi<any>[A]>;
|
|
654
|
+
};
|
|
655
|
+
}[VigorAllAllowedApis<I>];
|
|
656
|
+
};
|
|
657
|
+
type VigorAllEachTimelineItem<I extends keyof VigorAllEachInterceptorsFunctions, H extends keyof VigorAllEachProcessHandler> = {
|
|
658
|
+
[K in keyof VigorAllEachTimeline<I, H>]: {
|
|
659
|
+
action: K;
|
|
660
|
+
content: VigorAllEachTimeline<I, H>[K];
|
|
661
|
+
time: number;
|
|
662
|
+
};
|
|
663
|
+
}[keyof VigorAllEachTimeline<I, H>];
|
|
664
|
+
type VigorAllEachAllowedApis<I extends keyof VigorAllEachInterceptorsFunctions> = VigorAllEachInterceptorsFunctions[I] extends VigorAllEachInterceptorsFn<infer A, any> ? A : never;
|
|
665
|
+
type VigorAllEachProcessHandler = {
|
|
666
|
+
TASK_START: {};
|
|
667
|
+
TASK_ERROR: {
|
|
668
|
+
error: unknown;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
type VigorAllEachTimeline<I extends keyof VigorAllEachInterceptorsFunctions, H extends keyof VigorAllEachProcessHandler> = {
|
|
672
|
+
PROCESS_HANDLING: {
|
|
673
|
+
type: H;
|
|
674
|
+
data: VigorAllEachProcessHandler[H];
|
|
675
|
+
};
|
|
676
|
+
TASK_ACQUIRED: {
|
|
677
|
+
target: VigorAllEachContext["target"];
|
|
678
|
+
};
|
|
679
|
+
TASK_RELEASED: {
|
|
680
|
+
target: VigorAllEachContext["target"];
|
|
681
|
+
};
|
|
682
|
+
TASK_STARTED: {
|
|
683
|
+
target: VigorAllEachContext["target"];
|
|
684
|
+
};
|
|
685
|
+
TASK_ENDED: {
|
|
686
|
+
target: VigorAllEachContext["target"];
|
|
687
|
+
took: number;
|
|
688
|
+
};
|
|
689
|
+
INTERCEPTOR_LOOP_STARTED: {
|
|
690
|
+
interceptorType: I;
|
|
691
|
+
interceptors: Array<VigorAllEachInterceptorsFunctions[I]>;
|
|
692
|
+
};
|
|
693
|
+
INTERCEPTOR_LOOP_ENDED: {
|
|
694
|
+
interceptorType: I;
|
|
695
|
+
interceptors: Array<VigorAllEachInterceptorsFunctions[I]>;
|
|
696
|
+
took: number;
|
|
697
|
+
};
|
|
698
|
+
INTERCEPTOR_API_CALLED: {
|
|
699
|
+
[A in VigorAllEachAllowedApis<I>]: {
|
|
700
|
+
interceptorType: I;
|
|
701
|
+
interceptor: VigorAllEachInterceptorsFunctions[I];
|
|
702
|
+
method: A;
|
|
703
|
+
args: Parameters<VigorAllEachInterceptorsApi<any>[A]>;
|
|
704
|
+
};
|
|
705
|
+
}[VigorAllEachAllowedApis<I>];
|
|
444
706
|
};
|
|
445
707
|
declare class VigorAll extends VigorStatus<VigorAllConfig, VigorAll> {
|
|
446
708
|
constructor(config?: Partial<VigorAllConfig>);
|
|
709
|
+
private _createTimelineHandler;
|
|
710
|
+
private _createInterceptorHandler;
|
|
711
|
+
private _createEachTimelineHandler;
|
|
712
|
+
private _createEachInterceptorHandler;
|
|
447
713
|
target(...funcs: VigorIncludeSpread<VigorAllConfig["target"][number]>): VigorAll;
|
|
448
714
|
settings(func: ((s: VigorAllSettings) => VigorAllSettings) | VigorAllConfig["settings"]): VigorAll;
|
|
449
715
|
interceptors(func: ((s: VigorAllInterceptors) => VigorAllInterceptors) | VigorAllConfig["interceptors"]): VigorAll;
|