vigor-fetch 3.1.2 → 3.1.4
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 +55 -30
- package/dist/index.js +38 -5
- package/dist/index.mjs +38 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -260,12 +260,17 @@ type VigorRetryTimeline<I extends keyof VigorRetryInterceptorsFunctions, H exten
|
|
|
260
260
|
};
|
|
261
261
|
declare class VigorRetry extends VigorStatus<VigorRetryConfig, VigorRetry> {
|
|
262
262
|
constructor(config?: Partial<VigorRetryConfig>);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
protected readonly RetryAlgorithms: {
|
|
264
|
+
constant: (config?: Partial<VigorRetryAlgorithmsConstantConfig>) => VigorRetryAlgorithmsConstant;
|
|
265
|
+
linear: (config?: Partial<VigorRetryAlgorithmsLinearConfig>) => VigorRetryAlgorithmsLinear;
|
|
266
|
+
backoff: (config?: Partial<VigorRetryAlgorithmsBackoffConfig>) => VigorRetryAlgorithmsBackoff;
|
|
267
|
+
custom: (config?: Partial<VigorRetryAlgorithmsCustomConfig>) => VigorRetryAlgorithmsCustom;
|
|
268
|
+
};
|
|
269
|
+
protected _createTimelineHandler(timeline: VigorRetryContext["timeline"]): <I extends keyof VigorRetryInterceptorsFunctions, H extends keyof VigorRetryProcessHandler, K extends keyof VigorRetryTimeline<I, H>>(action: K, content: VigorRetryTimeline<I, H>[K]) => void;
|
|
270
|
+
protected _createInterceptorHandler(ctx: VigorRetryContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorRetryInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorRetryInterceptorsFunctions[I]) => Pick<VigorRetryInterceptorsApi<any>, VigorRetryAllowedApis<I>>) => Promise<void>;
|
|
266
271
|
target(func: VigorRetryConfig["target"]): VigorRetry;
|
|
267
|
-
settings(func: ((s: VigorRetrySettings) => VigorRetrySettings) |
|
|
268
|
-
interceptors(func: ((i: VigorRetryInterceptors) => VigorRetryInterceptors) |
|
|
272
|
+
settings(func: ((s: VigorRetrySettings) => VigorRetrySettings) | VigorRetrySettings | VigorRetrySettings["_config"]): VigorRetry;
|
|
273
|
+
interceptors(func: ((i: VigorRetryInterceptors) => VigorRetryInterceptors) | VigorRetryInterceptors | VigorRetryInterceptors["_config"]): VigorRetry;
|
|
269
274
|
algorithms(func: (a: typeof this.RetryAlgorithms) => {
|
|
270
275
|
_calculateDelay: VigorRetryConfig["algorithm"];
|
|
271
276
|
}): VigorRetry;
|
|
@@ -286,9 +291,19 @@ type VigorParseStrategiesConfig = {
|
|
|
286
291
|
};
|
|
287
292
|
declare class VigorParseStrategies extends VigorStatus<VigorParseStrategiesConfig, VigorParseStrategies> {
|
|
288
293
|
constructor(config?: Partial<VigorParseStrategiesConfig>);
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
294
|
+
protected readonly ParseAutoHeaders: {
|
|
295
|
+
header: string;
|
|
296
|
+
regExp: RegExp;
|
|
297
|
+
method: (res: Response) => Promise<any>;
|
|
298
|
+
}[];
|
|
299
|
+
protected readonly ParseAutoMethods: {
|
|
300
|
+
title: string;
|
|
301
|
+
method: (res: Response) => Promise<any>;
|
|
302
|
+
}[];
|
|
303
|
+
protected readonly ParseAutoAlgorithms: {
|
|
304
|
+
contentType: (response: Response) => Promise<any>;
|
|
305
|
+
sniff: (response: Response) => Promise<any>;
|
|
306
|
+
};
|
|
292
307
|
contentType(): VigorParseStrategies;
|
|
293
308
|
sniff(): VigorParseStrategies;
|
|
294
309
|
json(): VigorParseStrategies;
|
|
@@ -355,7 +370,7 @@ type VigorParseProcessHandler = {
|
|
|
355
370
|
type VigorParseTimeline<I extends keyof VigorParseInterceptorsFunctions, H extends keyof VigorParseProcessHandler> = {
|
|
356
371
|
PROCESS_HANDLING: {
|
|
357
372
|
type: H;
|
|
358
|
-
data:
|
|
373
|
+
data: VigorParseProcessHandler[H];
|
|
359
374
|
};
|
|
360
375
|
INTERCEPTOR_LOOP_STARTED: {
|
|
361
376
|
interceptorType: I;
|
|
@@ -377,12 +392,12 @@ type VigorParseTimeline<I extends keyof VigorParseInterceptorsFunctions, H exten
|
|
|
377
392
|
};
|
|
378
393
|
declare class VigorParse extends VigorStatus<VigorParseConfig, VigorParse> {
|
|
379
394
|
constructor(config?: Partial<VigorParseConfig>);
|
|
380
|
-
|
|
381
|
-
|
|
395
|
+
protected _createTimelineHandler(timeline: VigorParseContext["timeline"]): <I extends keyof VigorParseInterceptorsFunctions, H extends keyof VigorParseProcessHandler, K extends keyof VigorParseTimeline<I, H>>(action: K, content: VigorParseTimeline<I, H>[K]) => void;
|
|
396
|
+
protected _createInterceptorHandler(ctx: VigorParseContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorParseInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorParseInterceptorsFunctions[I]) => Pick<VigorParseInterceptorsApi<any>, VigorParseAllowedApis<I>>) => Promise<void>;
|
|
382
397
|
target(response: VigorParseConfig["target"]): VigorParse;
|
|
383
|
-
settings(func: ((i: VigorParseSettings) => VigorParseSettings) |
|
|
384
|
-
strategies(func: ((i: VigorParseStrategies) => VigorParseStrategies) |
|
|
385
|
-
interceptors(func: ((i: VigorParseInterceptors) => VigorParseInterceptors) |
|
|
398
|
+
settings(func: ((i: VigorParseSettings) => VigorParseSettings) | VigorParseSettings | VigorParseSettings["_config"]): VigorParse;
|
|
399
|
+
strategies(func: ((i: VigorParseStrategies) => VigorParseStrategies) | VigorParseStrategies | VigorParseStrategies["_config"]): VigorParse;
|
|
400
|
+
interceptors(func: ((i: VigorParseInterceptors) => VigorParseInterceptors) | VigorParseInterceptors | VigorParseInterceptors["_config"]): VigorParse;
|
|
386
401
|
request<R>(config?: VigorParseConfig, timeline?: VigorParseContext["timeline"]): Promise<R>;
|
|
387
402
|
}
|
|
388
403
|
type VigorFetchSettingsConfig = {
|
|
@@ -521,9 +536,9 @@ type VigorFetchTimeline<I extends keyof VigorFetchInterceptorsFunctions, H exten
|
|
|
521
536
|
};
|
|
522
537
|
declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
|
|
523
538
|
constructor(config?: Partial<VigorFetchConfig>);
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
539
|
+
protected _createTimelineHandler(timeline: VigorFetchContext["timeline"]): <I extends keyof VigorFetchInterceptorsFunctions, H extends keyof VigorFetchProcessHandler, K extends keyof VigorFetchTimeline<I, H>>(action: K, content: VigorFetchTimeline<I, H>[K]) => void;
|
|
540
|
+
protected _createInterceptorHandler(ctx: VigorFetchContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorFetchInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorFetchInterceptorsFunctions[I]) => Pick<VigorFetchInterceptorsApi<any>, VigorFetchAllowedApis<I>>) => Promise<void>;
|
|
541
|
+
protected _stringifyList(unkList: Array<VigorStringable>): Array<string>;
|
|
527
542
|
method(str: VigorFetchConfig["method"]): VigorFetch;
|
|
528
543
|
origin(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
529
544
|
path(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
|
|
@@ -532,12 +547,16 @@ declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
|
|
|
532
547
|
options(obj: VigorFetchConfig["options"]): VigorFetch;
|
|
533
548
|
headers(obj: VigorFetchConfig["options"]["headers"]): VigorFetch;
|
|
534
549
|
body(obj: VigorFetchConfig["options"]["body"]): VigorFetch;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
550
|
+
protected _buildUrl(origin: VigorFetchConfig["origin"], path: VigorFetchConfig["path"], query: VigorFetchConfig["query"], hash: VigorFetchConfig["hash"]): string;
|
|
551
|
+
protected _normalizeOptions(body: unknown): {
|
|
552
|
+
isJson: boolean;
|
|
553
|
+
headers: Record<string, unknown>;
|
|
554
|
+
body: BodyInit | null | undefined;
|
|
555
|
+
};
|
|
556
|
+
settings(func: ((s: VigorFetchSettings) => VigorFetchSettings) | VigorFetchSettings | VigorFetchSettings["_config"]): VigorFetch;
|
|
557
|
+
interceptors(func: ((s: VigorFetchInterceptors) => VigorFetchInterceptors) | VigorFetchInterceptors | VigorFetchInterceptors["_config"]): VigorFetch;
|
|
558
|
+
retryConfig(func: ((s: VigorRetry) => VigorRetry) | VigorRetry | VigorRetry["_config"]): VigorFetch;
|
|
559
|
+
parseConfig(func: ((s: VigorParse) => VigorParse) | VigorParse | VigorParse["_config"]): VigorFetch;
|
|
541
560
|
request<R>(config?: VigorFetchConfig, timeline?: VigorFetchContext["timeline"]): Promise<R>;
|
|
542
561
|
}
|
|
543
562
|
type VigorAllSettingsConfig = {
|
|
@@ -706,14 +725,20 @@ type VigorAllEachTimeline<I extends keyof VigorAllEachInterceptorsFunctions, H e
|
|
|
706
725
|
};
|
|
707
726
|
declare class VigorAll extends VigorStatus<VigorAllConfig, VigorAll> {
|
|
708
727
|
constructor(config?: Partial<VigorAllConfig>);
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
728
|
+
protected _createTimelineHandler(timeline: VigorAllContext["timeline"]): <I extends keyof VigorAllInterceptorsFunctions, H extends keyof VigorAllProcessHandler, K extends keyof VigorAllTimeline<I, H>>(action: K, content: VigorAllTimeline<I, H>[K]) => void;
|
|
729
|
+
protected _createInterceptorHandler(ctx: VigorAllContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorAllInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorAllInterceptorsFunctions[I]) => Pick<VigorAllInterceptorsApi<any>, VigorAllAllowedApis<I>>) => Promise<void>;
|
|
730
|
+
protected _createEachTimelineHandler(timeline: VigorAllEachContext["timeline"]): <I extends keyof VigorAllEachInterceptorsFunctions, H extends keyof VigorAllEachProcessHandler, K extends keyof VigorAllEachTimeline<I, H>>(action: K, content: VigorAllEachTimeline<I, H>[K]) => void;
|
|
731
|
+
protected _createEachInterceptorHandler(ctx: VigorAllEachContext, addEachTimeline: ReturnType<typeof this._createEachTimelineHandler>): <I extends keyof VigorAllEachInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorAllEachInterceptorsFunctions[I]) => Pick<VigorAllEachInterceptorsApi<any>, VigorAllEachAllowedApis<I>>) => Promise<void>;
|
|
713
732
|
target(...funcs: VigorIncludeSpread<VigorAllConfig["target"][number]>): VigorAll;
|
|
714
|
-
settings(func: ((s: VigorAllSettings) => VigorAllSettings) |
|
|
715
|
-
interceptors(func: ((s: VigorAllInterceptors) => VigorAllInterceptors) |
|
|
716
|
-
|
|
733
|
+
settings(func: ((s: VigorAllSettings) => VigorAllSettings) | VigorAllSettings | VigorAllSettings["_config"]): VigorAll;
|
|
734
|
+
interceptors(func: ((s: VigorAllInterceptors) => VigorAllInterceptors) | VigorAllInterceptors | VigorAllInterceptors["_config"]): VigorAll;
|
|
735
|
+
protected runTask(task: VigorAllEachContext["target"], { stats, root }: {
|
|
736
|
+
stats: VigorAllEachContext["stats"];
|
|
737
|
+
root: VigorAllEachContext["root"];
|
|
738
|
+
}, semaphore: {
|
|
739
|
+
acquire: VigorAllEachContext["semaphore"]["acquire"];
|
|
740
|
+
release: VigorAllEachContext["semaphore"]["release"];
|
|
741
|
+
}): Promise<unknown>;
|
|
717
742
|
request<R extends VigorAllContext["result"]>(config?: VigorAllConfig, timeline?: VigorAllContext["timeline"]): Promise<R>;
|
|
718
743
|
}
|
|
719
744
|
declare const VigorEntry: {
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const VigorErrorMessageFuncs = {
|
|
6
6
|
INVALID_TARGET: ({ expected, received }) => `Invalid Task: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
7
|
-
EXHAUSTED: ({ maxAttempts }) => `Retry exhausted
|
|
7
|
+
EXHAUSTED: ({ maxAttempts }) => `Retry exhausted, (max ${maxAttempts})`,
|
|
8
8
|
TIMED_OUT: ({ limit, attempt }) => `Timeout: exceeded ${limit}ms (attempt: ${attempt})`,
|
|
9
9
|
INVALID_CONTENT_TYPE: ({ expected, received, response }) => `Invalid Content Type Header: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
10
10
|
PARSER_NOT_FOUND: ({ expected, received, response }) => `Parser Not Found For Header: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
@@ -242,12 +242,18 @@ class VigorRetry extends VigorStatus {
|
|
|
242
242
|
}
|
|
243
243
|
target(func) { return this._next({ target: func }); }
|
|
244
244
|
settings(func) {
|
|
245
|
+
if (func instanceof VigorRetrySettings) {
|
|
246
|
+
return this._next({ settings: func._getConfig() });
|
|
247
|
+
}
|
|
245
248
|
if (typeof func === 'function') {
|
|
246
249
|
return this._next({ settings: func(new VigorRetrySettings(this._config.settings))._getConfig() });
|
|
247
250
|
}
|
|
248
251
|
return this._next({ settings: func });
|
|
249
252
|
}
|
|
250
253
|
interceptors(func) {
|
|
254
|
+
if (func instanceof VigorRetryInterceptors) {
|
|
255
|
+
return this._next({ interceptors: func._getConfig() });
|
|
256
|
+
}
|
|
251
257
|
if (typeof func === 'function') {
|
|
252
258
|
return this._next({ interceptors: func(new VigorRetryInterceptors(this._config.interceptors))._getConfig() });
|
|
253
259
|
}
|
|
@@ -708,18 +714,27 @@ class VigorParse extends VigorStatus {
|
|
|
708
714
|
}
|
|
709
715
|
target(response) { return this._next({ target: response }); }
|
|
710
716
|
settings(func) {
|
|
717
|
+
if (func instanceof VigorParseSettings) {
|
|
718
|
+
return this._next({ settings: func._getConfig() });
|
|
719
|
+
}
|
|
711
720
|
if (typeof func === 'function') {
|
|
712
721
|
return this._next({ settings: func(new VigorParseSettings(this._config.settings))._getConfig() });
|
|
713
722
|
}
|
|
714
723
|
return this._next({ settings: func });
|
|
715
724
|
}
|
|
716
725
|
strategies(func) {
|
|
726
|
+
if (func instanceof VigorParseStrategies) {
|
|
727
|
+
return this._next({ strategies: func._getConfig() });
|
|
728
|
+
}
|
|
717
729
|
if (typeof func === 'function') {
|
|
718
730
|
return this._next({ strategies: func(new VigorParseStrategies(this._config.strategies))._getConfig() });
|
|
719
731
|
}
|
|
720
732
|
return this._next({ strategies: func });
|
|
721
733
|
}
|
|
722
734
|
interceptors(func) {
|
|
735
|
+
if (func instanceof VigorParseInterceptors) {
|
|
736
|
+
return this._next({ interceptors: func._getConfig() });
|
|
737
|
+
}
|
|
723
738
|
if (typeof func === 'function') {
|
|
724
739
|
return this._next({ interceptors: func(new VigorParseInterceptors(this._config.interceptors))._getConfig() });
|
|
725
740
|
}
|
|
@@ -1032,24 +1047,36 @@ class VigorFetch extends VigorStatus {
|
|
|
1032
1047
|
});
|
|
1033
1048
|
}
|
|
1034
1049
|
settings(func) {
|
|
1050
|
+
if (func instanceof VigorFetchSettings) {
|
|
1051
|
+
return this._next({ settings: func._getConfig() });
|
|
1052
|
+
}
|
|
1035
1053
|
if (typeof func === 'function') {
|
|
1036
1054
|
return this._next({ settings: func(new VigorFetchSettings(this._config.settings))._getConfig() });
|
|
1037
1055
|
}
|
|
1038
1056
|
return this._next({ settings: func });
|
|
1039
1057
|
}
|
|
1040
1058
|
interceptors(func) {
|
|
1059
|
+
if (func instanceof VigorFetchInterceptors) {
|
|
1060
|
+
return this._next({ interceptors: func._getConfig() });
|
|
1061
|
+
}
|
|
1041
1062
|
if (typeof func === 'function') {
|
|
1042
1063
|
return this._next({ interceptors: func(new VigorFetchInterceptors(this._config.interceptors))._getConfig() });
|
|
1043
1064
|
}
|
|
1044
1065
|
return this._next({ interceptors: func });
|
|
1045
1066
|
}
|
|
1046
1067
|
retryConfig(func) {
|
|
1068
|
+
if (func instanceof VigorRetry) {
|
|
1069
|
+
return this._next({ retryConfig: func._getConfig() });
|
|
1070
|
+
}
|
|
1047
1071
|
if (typeof func === 'function') {
|
|
1048
1072
|
return this._next({ retryConfig: func(new VigorRetry(this._config.retryConfig))._getConfig() });
|
|
1049
1073
|
}
|
|
1050
1074
|
return this._next({ retryConfig: func });
|
|
1051
1075
|
}
|
|
1052
1076
|
parseConfig(func) {
|
|
1077
|
+
if (func instanceof VigorParse) {
|
|
1078
|
+
return this._next({ parseConfig: func._getConfig() });
|
|
1079
|
+
}
|
|
1053
1080
|
if (typeof func === 'function') {
|
|
1054
1081
|
return this._next({ parseConfig: func(new VigorParse(this._config.parseConfig))._getConfig() });
|
|
1055
1082
|
}
|
|
@@ -1439,12 +1466,18 @@ class VigorAll extends VigorStatus {
|
|
|
1439
1466
|
}
|
|
1440
1467
|
target(...funcs) { return this._next({ target: funcs.flat() }); }
|
|
1441
1468
|
settings(func) {
|
|
1469
|
+
if (func instanceof VigorAllSettings) {
|
|
1470
|
+
return this._next({ settings: func._getConfig() });
|
|
1471
|
+
}
|
|
1442
1472
|
if (typeof func === 'function') {
|
|
1443
1473
|
return this._next({ settings: func(new VigorAllSettings(this._config.settings))._getConfig() });
|
|
1444
1474
|
}
|
|
1445
1475
|
return this._next({ settings: func });
|
|
1446
1476
|
}
|
|
1447
1477
|
interceptors(func) {
|
|
1478
|
+
if (func instanceof VigorAllInterceptors) {
|
|
1479
|
+
return this._next({ interceptors: func._getConfig() });
|
|
1480
|
+
}
|
|
1448
1481
|
if (typeof func === 'function') {
|
|
1449
1482
|
return this._next({ interceptors: func(new VigorAllInterceptors(this._config.interceptors))._getConfig() });
|
|
1450
1483
|
}
|
|
@@ -1599,10 +1632,10 @@ class VigorAll extends VigorStatus {
|
|
|
1599
1632
|
};
|
|
1600
1633
|
for (const task of stats.target) {
|
|
1601
1634
|
let promise;
|
|
1602
|
-
promise = this.runTask(task, { stats, root: ctx }, { acquire, release })
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1635
|
+
promise = this.runTask(task, { stats, root: ctx }, { acquire, release })
|
|
1636
|
+
.then(res => ({ success: true, value: res }))
|
|
1637
|
+
.catch(err => ({ success: false, value: err }))
|
|
1638
|
+
.finally(() => ctx.queue.delete(promise));
|
|
1606
1639
|
ctx.queue.add(promise);
|
|
1607
1640
|
}
|
|
1608
1641
|
addTimeline("QUEUE_REQUEST_STARTED", {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const VigorErrorMessageFuncs = {
|
|
2
2
|
INVALID_TARGET: ({ expected, received }) => `Invalid Task: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
3
|
-
EXHAUSTED: ({ maxAttempts }) => `Retry exhausted
|
|
3
|
+
EXHAUSTED: ({ maxAttempts }) => `Retry exhausted, (max ${maxAttempts})`,
|
|
4
4
|
TIMED_OUT: ({ limit, attempt }) => `Timeout: exceeded ${limit}ms (attempt: ${attempt})`,
|
|
5
5
|
INVALID_CONTENT_TYPE: ({ expected, received, response }) => `Invalid Content Type Header: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
6
6
|
PARSER_NOT_FOUND: ({ expected, received, response }) => `Parser Not Found For Header: ${typeof received} (expected: ${expected.join(', ')})`,
|
|
@@ -238,12 +238,18 @@ class VigorRetry extends VigorStatus {
|
|
|
238
238
|
}
|
|
239
239
|
target(func) { return this._next({ target: func }); }
|
|
240
240
|
settings(func) {
|
|
241
|
+
if (func instanceof VigorRetrySettings) {
|
|
242
|
+
return this._next({ settings: func._getConfig() });
|
|
243
|
+
}
|
|
241
244
|
if (typeof func === 'function') {
|
|
242
245
|
return this._next({ settings: func(new VigorRetrySettings(this._config.settings))._getConfig() });
|
|
243
246
|
}
|
|
244
247
|
return this._next({ settings: func });
|
|
245
248
|
}
|
|
246
249
|
interceptors(func) {
|
|
250
|
+
if (func instanceof VigorRetryInterceptors) {
|
|
251
|
+
return this._next({ interceptors: func._getConfig() });
|
|
252
|
+
}
|
|
247
253
|
if (typeof func === 'function') {
|
|
248
254
|
return this._next({ interceptors: func(new VigorRetryInterceptors(this._config.interceptors))._getConfig() });
|
|
249
255
|
}
|
|
@@ -704,18 +710,27 @@ class VigorParse extends VigorStatus {
|
|
|
704
710
|
}
|
|
705
711
|
target(response) { return this._next({ target: response }); }
|
|
706
712
|
settings(func) {
|
|
713
|
+
if (func instanceof VigorParseSettings) {
|
|
714
|
+
return this._next({ settings: func._getConfig() });
|
|
715
|
+
}
|
|
707
716
|
if (typeof func === 'function') {
|
|
708
717
|
return this._next({ settings: func(new VigorParseSettings(this._config.settings))._getConfig() });
|
|
709
718
|
}
|
|
710
719
|
return this._next({ settings: func });
|
|
711
720
|
}
|
|
712
721
|
strategies(func) {
|
|
722
|
+
if (func instanceof VigorParseStrategies) {
|
|
723
|
+
return this._next({ strategies: func._getConfig() });
|
|
724
|
+
}
|
|
713
725
|
if (typeof func === 'function') {
|
|
714
726
|
return this._next({ strategies: func(new VigorParseStrategies(this._config.strategies))._getConfig() });
|
|
715
727
|
}
|
|
716
728
|
return this._next({ strategies: func });
|
|
717
729
|
}
|
|
718
730
|
interceptors(func) {
|
|
731
|
+
if (func instanceof VigorParseInterceptors) {
|
|
732
|
+
return this._next({ interceptors: func._getConfig() });
|
|
733
|
+
}
|
|
719
734
|
if (typeof func === 'function') {
|
|
720
735
|
return this._next({ interceptors: func(new VigorParseInterceptors(this._config.interceptors))._getConfig() });
|
|
721
736
|
}
|
|
@@ -1028,24 +1043,36 @@ class VigorFetch extends VigorStatus {
|
|
|
1028
1043
|
});
|
|
1029
1044
|
}
|
|
1030
1045
|
settings(func) {
|
|
1046
|
+
if (func instanceof VigorFetchSettings) {
|
|
1047
|
+
return this._next({ settings: func._getConfig() });
|
|
1048
|
+
}
|
|
1031
1049
|
if (typeof func === 'function') {
|
|
1032
1050
|
return this._next({ settings: func(new VigorFetchSettings(this._config.settings))._getConfig() });
|
|
1033
1051
|
}
|
|
1034
1052
|
return this._next({ settings: func });
|
|
1035
1053
|
}
|
|
1036
1054
|
interceptors(func) {
|
|
1055
|
+
if (func instanceof VigorFetchInterceptors) {
|
|
1056
|
+
return this._next({ interceptors: func._getConfig() });
|
|
1057
|
+
}
|
|
1037
1058
|
if (typeof func === 'function') {
|
|
1038
1059
|
return this._next({ interceptors: func(new VigorFetchInterceptors(this._config.interceptors))._getConfig() });
|
|
1039
1060
|
}
|
|
1040
1061
|
return this._next({ interceptors: func });
|
|
1041
1062
|
}
|
|
1042
1063
|
retryConfig(func) {
|
|
1064
|
+
if (func instanceof VigorRetry) {
|
|
1065
|
+
return this._next({ retryConfig: func._getConfig() });
|
|
1066
|
+
}
|
|
1043
1067
|
if (typeof func === 'function') {
|
|
1044
1068
|
return this._next({ retryConfig: func(new VigorRetry(this._config.retryConfig))._getConfig() });
|
|
1045
1069
|
}
|
|
1046
1070
|
return this._next({ retryConfig: func });
|
|
1047
1071
|
}
|
|
1048
1072
|
parseConfig(func) {
|
|
1073
|
+
if (func instanceof VigorParse) {
|
|
1074
|
+
return this._next({ parseConfig: func._getConfig() });
|
|
1075
|
+
}
|
|
1049
1076
|
if (typeof func === 'function') {
|
|
1050
1077
|
return this._next({ parseConfig: func(new VigorParse(this._config.parseConfig))._getConfig() });
|
|
1051
1078
|
}
|
|
@@ -1435,12 +1462,18 @@ class VigorAll extends VigorStatus {
|
|
|
1435
1462
|
}
|
|
1436
1463
|
target(...funcs) { return this._next({ target: funcs.flat() }); }
|
|
1437
1464
|
settings(func) {
|
|
1465
|
+
if (func instanceof VigorAllSettings) {
|
|
1466
|
+
return this._next({ settings: func._getConfig() });
|
|
1467
|
+
}
|
|
1438
1468
|
if (typeof func === 'function') {
|
|
1439
1469
|
return this._next({ settings: func(new VigorAllSettings(this._config.settings))._getConfig() });
|
|
1440
1470
|
}
|
|
1441
1471
|
return this._next({ settings: func });
|
|
1442
1472
|
}
|
|
1443
1473
|
interceptors(func) {
|
|
1474
|
+
if (func instanceof VigorAllInterceptors) {
|
|
1475
|
+
return this._next({ interceptors: func._getConfig() });
|
|
1476
|
+
}
|
|
1444
1477
|
if (typeof func === 'function') {
|
|
1445
1478
|
return this._next({ interceptors: func(new VigorAllInterceptors(this._config.interceptors))._getConfig() });
|
|
1446
1479
|
}
|
|
@@ -1595,10 +1628,10 @@ class VigorAll extends VigorStatus {
|
|
|
1595
1628
|
};
|
|
1596
1629
|
for (const task of stats.target) {
|
|
1597
1630
|
let promise;
|
|
1598
|
-
promise = this.runTask(task, { stats, root: ctx }, { acquire, release })
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1631
|
+
promise = this.runTask(task, { stats, root: ctx }, { acquire, release })
|
|
1632
|
+
.then(res => ({ success: true, value: res }))
|
|
1633
|
+
.catch(err => ({ success: false, value: err }))
|
|
1634
|
+
.finally(() => ctx.queue.delete(promise));
|
|
1602
1635
|
ctx.queue.add(promise);
|
|
1603
1636
|
}
|
|
1604
1637
|
addTimeline("QUEUE_REQUEST_STARTED", {
|