vigor-fetch 4.0.10 → 4.1.0

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
@@ -92,9 +92,11 @@ declare abstract class VigorStatus<Base, Config extends Base, TL extends VigorTy
92
92
  /**
93
93
  * Deep-merges `target` onto `source`, honoring an optional per-path
94
94
  * `strategy` tree. Objects merge key by key, arrays concatenate (unless
95
- * `"replace"` is specified), and any other value is overwritten.
95
+ * `"replace"` is specified, or `arrayMode` is `"replace"`), and any other
96
+ * value — including `null` — is overwritten. Only `undefined` keeps the
97
+ * source value.
96
98
  */
97
- protected _merge<A, B>(source: A, target: B, strategy?: unknown): VigorDeepMerge<A, B>;
99
+ protected _merge<A, B>(source: A, target: B, strategy?: unknown, arrayMode?: "concat" | "replace"): VigorDeepMerge<A, B>;
98
100
  /** The default/base config this builder was constructed with. */
99
101
  get base(): Base;
100
102
  /** The current, merged config for this builder instance. */
@@ -105,11 +107,19 @@ type VigorAllPolicySettingsSchema<T extends VigorAllSchema<T>> = {
105
107
  __brand: VigorBrand<"All", "Policy<Settings<Schema">;
106
108
  concurrency: number;
107
109
  onlySuccess: boolean;
110
+ /** Per-task timeout in milliseconds. `VigorEmpty` (the default) disables it. */
111
+ timeout: number | VigorEmptyType;
112
+ /** When `true`, the first task failure (not recovered by `onErrorEach`) aborts the remaining tasks and fails the batch. */
113
+ failFast: boolean;
108
114
  };
109
115
  declare const VigorAllPolicySettingsBase: {
110
116
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
111
117
  readonly concurrency: 5;
112
118
  readonly onlySuccess: false;
119
+ readonly timeout: symbol & {
120
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
121
+ };
122
+ readonly failFast: false;
113
123
  };
114
124
  /** Immutable builder for an all-policy's general settings. */
115
125
  declare class VigorAllPolicySettings<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<any>, T, VigorAllPolicySettingsTypeLambda> {
@@ -131,11 +141,33 @@ declare class VigorAllPolicySettings<T extends VigorAllSchema<T> = typeof VigorA
131
141
  };
132
142
  };
133
143
  }>>>;
144
+ /** Sets the per-task timeout, in milliseconds. A task exceeding it fails with `TIMED_OUT`. */
145
+ timeout<const N extends VigorExcludeEmpty<VigorAllSchema<any>["policy"]["settings"]["timeout"]>>(num: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
146
+ readonly policy: {
147
+ readonly settings: {
148
+ readonly timeout: N;
149
+ };
150
+ };
151
+ }>>>;
152
+ /** When enabled, the first unrecovered task failure aborts the remaining tasks and fails the batch with that error. */
153
+ failFast<const N extends VigorAllSchema<any>["policy"]["settings"]["failFast"]>(bool: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
154
+ readonly policy: {
155
+ readonly settings: {
156
+ readonly failFast: N;
157
+ };
158
+ };
159
+ }>>>;
134
160
  }
135
161
 
136
- type VigorAllTask = () => unknown | Promise<unknown>;
162
+ /**
163
+ * A single task. It receives an `AbortSignal` that fires when the task's
164
+ * `timeout` elapses, the batch's `abortSignals` abort, or `failFast` stops
165
+ * the batch — tasks that ignore it keep running in the background, but
166
+ * their result is discarded.
167
+ */
168
+ type VigorAllTask = (signal: AbortSignal) => unknown | Promise<unknown>;
137
169
  /** Extracts (and unwraps `Promise`/`Awaited`) the result type of a single task. */
138
- type VigorAllTaskResult<F> = F extends () => infer R ? Awaited<R> : never;
170
+ type VigorAllTaskResult<F> = F extends (...args: any[]) => infer R ? Awaited<R> : never;
139
171
  /**
140
172
  * Maps a tuple of tasks to a tuple of their (awaited) result types, in the
141
173
  * same order and length as `N`. If `N` isn't a literal tuple (e.g. the
@@ -147,16 +179,22 @@ type VigorAllTasksTuple<N extends readonly VigorAllTask[]> = {
147
179
  type VigorAllPolicySchema<T extends VigorAllSchema<T>> = {
148
180
  __brand: VigorBrand<"All", "Policy<Schema">;
149
181
  target: VigorAllTask[];
182
+ abortSignals: AbortSignal[];
150
183
  settings: VigorAllPolicySettingsSchema<T>;
151
184
  middlewares: VigorAllPolicyMiddlewaresSchema<T>;
152
185
  };
153
186
  declare const VigorAllPolicyBase: {
154
187
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
155
188
  readonly target: [];
189
+ readonly abortSignals: [];
156
190
  readonly settings: {
157
191
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
158
192
  readonly concurrency: 5;
159
193
  readonly onlySuccess: false;
194
+ readonly timeout: symbol & {
195
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
196
+ };
197
+ readonly failFast: false;
160
198
  };
161
199
  readonly middlewares: {
162
200
  readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
@@ -380,20 +418,99 @@ type VigorAllContextSchema<T extends VigorAllSchema<T>, R = VigorAllPipeResult<T
380
418
  /** Context shape seen by `before` middlewares — no task has run yet. */
381
419
  type VigorAllBeforeContextSchema<T extends VigorAllSchema<T>> = VigorAllContextSchema<T, VigorDefaultType>;
382
420
  /** Context shape seen by `after` middlewares — every task has settled, reflecting whatever `before` changed. */
383
- type VigorAllAfterContextSchema<T extends VigorAllSchema<T>> = VigorAllPipeStepVoid<VigorAllPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>;
421
+ type VigorAllAfterContextSchema<T extends VigorAllSchema<T>> = VigorDeepMerge<VigorAllPipeStepVoid<VigorAllPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, {
422
+ result: VigorAllPipeInitialContext<T>["result"];
423
+ }>;
384
424
  /** Context shape seen by `onResult` middlewares — additionally threads any `onResult` middlewares already registered earlier in the same chain, so `ctx.result` reflects what the previous `onResult` returned. */
385
425
  type VigorAllOnResultContextSchema<T extends VigorAllSchema<T>> = VigorAllPipeStepResult<VigorAllPipeStepVoid<VigorAllAfterContextSchema<T>, T["policy"]["middlewares"]["after"]>, T["policy"]["middlewares"]["onResult"]>;
386
426
  /** Per-task context, seen by `beforeEach` / `afterEach` / `onErrorEach`. */
387
427
  type VigorAllEachContextSchema<T extends VigorAllSchema<T>> = {
388
428
  __brand: VigorBrand<"All", "EachContext<Schema">;
429
+ /** Position of this task in the `target` list. */
430
+ index: number;
389
431
  result: unknown | VigorDefaultType;
390
432
  error: unknown;
391
433
  flags: {
392
- overrided: boolean;
434
+ overridden: boolean;
393
435
  };
394
436
  record: Record<string, any>;
395
437
  };
396
438
 
439
+ /**
440
+ * The `error` of a failed result envelope: `E` is the module's own typed
441
+ * errors, and `{} | null | undefined` stands for anything else that reached
442
+ * the caller — an error thrown by your own target/middleware, an abort
443
+ * reason, a network `TypeError`, even a bare `throw null`.
444
+ *
445
+ * Because of that tail, reading `error.code` directly doesn't compile. Narrow
446
+ * first (`isVigorRetryError(err)`), and `code` then narrows `data` to that
447
+ * code's payload.
448
+ */
449
+ type VigorResultError<E> = E | {} | null | undefined;
450
+ type VigorErrorOptions<D, T> = {
451
+ cause?: unknown;
452
+ data: D;
453
+ method: string;
454
+ context?: T;
455
+ };
456
+ /**
457
+ * Base class for all Vigor error types. Subclasses (`VigorRetryError`,
458
+ * `VigorFetchError`, `VigorParseError`, `VigorAllError`) fix `C`, `D`, and
459
+ * `T` to their own error-code union, data shape, and context shape.
460
+ *
461
+ * @typeParam C - Union of error codes for the subclass.
462
+ * @typeParam D - Shape of the structured error data.
463
+ * @typeParam T - Shape of the domain context.
464
+ */
465
+ declare abstract class VigorError<C extends string, D, T> extends Error {
466
+ readonly timestamp: Date;
467
+ readonly cause?: unknown;
468
+ readonly code: C;
469
+ readonly data: D;
470
+ readonly method: string;
471
+ readonly context: T | undefined;
472
+ /**
473
+ * @param code - Machine-readable error code.
474
+ * @param message - Human-readable message (rendered after the `[code]` prefix).
475
+ * @param options - Additional error metadata (cause, data, method, context).
476
+ */
477
+ constructor(code: C, message: string, options: VigorErrorOptions<D, T>);
478
+ }
479
+
480
+ declare const VigorAllErrorMessageFuncs: {
481
+ readonly EMPTY_TARGET: (_: {}) => string;
482
+ readonly TIMED_OUT: ({ limit, index }: {
483
+ limit: number;
484
+ index: number;
485
+ }) => string;
486
+ };
487
+ type VigorAllErrorCodes = keyof typeof VigorAllErrorMessageFuncs;
488
+ type VigorAllErrorDatas<C extends VigorAllErrorCodes> = Parameters<typeof VigorAllErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
489
+ /**
490
+ * Every all error code as its own union member, so narrowing by `code`
491
+ * also narrows `data` to that code's payload.
492
+ */
493
+ type VigorAllErrors<T extends VigorAllSchema<any> = VigorAllSchema<any>> = {
494
+ [C in VigorAllErrorCodes]: VigorAllError<C, T>;
495
+ }[VigorAllErrorCodes];
496
+ /** `error` of a failed `requestVerbose()` — this module's errors, or anything else that was thrown (e.g. a task's error under `failFast`). */
497
+ type VigorAllRequestError<T extends VigorAllSchema<any> = any> = VigorResultError<VigorAllErrors<T>>;
498
+ /** Error type thrown by the all module. */
499
+ declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSchema<T>> extends VigorError<C, VigorAllErrorDatas<C>, VigorAllContextSchema<T>> {
500
+ /**
501
+ * @param code - One of the all module's error codes.
502
+ * @param options - Error metadata, including the `data` payload for `code`.
503
+ */
504
+ constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, VigorAllContextSchema<T>>);
505
+ }
506
+ /**
507
+ * Narrows an error from a failed result envelope to the all module's typed
508
+ * error union. Prefer this over a bare `instanceof`: the envelope's `{}`
509
+ * member makes `instanceof` widen `data` back to every code's payload,
510
+ * while this guard keeps `code` and `data` in sync.
511
+ */
512
+ declare const isVigorAllError: (error: unknown) => error is VigorAllErrors;
513
+
397
514
  type VigorAllSchema<T extends VigorAllSchema<T>> = {
398
515
  __brand: VigorBrand<"All", "Schema">;
399
516
  policy: VigorAllPolicySchema<T>;
@@ -405,10 +522,15 @@ declare const VigorAllBase: {
405
522
  readonly policy: {
406
523
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
407
524
  readonly target: [];
525
+ readonly abortSignals: [];
408
526
  readonly settings: {
409
527
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
410
528
  readonly concurrency: 5;
411
529
  readonly onlySuccess: false;
530
+ readonly timeout: symbol & {
531
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
532
+ };
533
+ readonly failFast: false;
412
534
  };
413
535
  readonly middlewares: {
414
536
  readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
@@ -438,6 +560,12 @@ declare class VigorAll<T extends VigorAllSchema<T> = typeof VigorAllBase> extend
438
560
  readonly target: N;
439
561
  };
440
562
  }>>>;
563
+ /** Sets external abort signals that, when aborted, cancel the remaining tasks and fail the batch. */
564
+ abortSignals<const N extends VigorAllSchema<T>["policy"]["abortSignals"]>(...sig: N): VigorAll<VigorAllIn<VigorDeepMerge<T, {
565
+ readonly policy: {
566
+ readonly abortSignals: N;
567
+ };
568
+ }>>>;
441
569
  /** Configures the all-policy's general settings (concurrency, onlySuccess). */
442
570
  settings<const N extends VigorDeepPartial<VigorAllPolicySettingsSchema<T>>>(input: N): VigorApply<VigorAllTypeLambda, VigorDeepMerge<T, {
443
571
  policy: {
@@ -485,13 +613,13 @@ declare class VigorAll<T extends VigorAllSchema<T> = typeof VigorAllBase> extend
485
613
  request<R = VigorExcludeDefault<VigorAllContextSchema<T>["result"]>>(): Promise<R>;
486
614
  /** Runs all tasks and returns a result/error envelope instead of throwing. */
487
615
  requestVerbose<R = VigorExcludeDefault<VigorAllContextSchema<T>["result"]>>(): Promise<{
488
- success: false;
489
- data: null;
490
- error: unknown;
491
- } | {
492
616
  success: true;
493
617
  data: R;
494
618
  error: null;
619
+ } | {
620
+ success: false;
621
+ data: null;
622
+ error: VigorAllRequestError<T>;
495
623
  }>;
496
624
  /** Internal execution loop implementing the bounded-concurrency worker pool and the batch-level before/after/onResult pipeline. */
497
625
  private requestRuntime;
@@ -715,7 +843,9 @@ type VigorFetchContextSchema<T extends VigorFetchSchema<T>, R = VigorFetchPipeRe
715
843
  /** Context shape seen by `before` middlewares — the request hasn't been sent yet. */
716
844
  type VigorFetchBeforeContextSchema<T extends VigorFetchSchema<T>> = VigorFetchContextSchema<T, VigorDefaultType>;
717
845
  /** Context shape seen by `after` middlewares — reflects the result after `before` has run. */
718
- type VigorFetchAfterContextSchema<T extends VigorFetchSchema<T>> = VigorFetchPipeStepResult<VigorFetchPipeStepVoid<VigorFetchPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>;
846
+ type VigorFetchAfterContextSchema<T extends VigorFetchSchema<T>> = VigorFetchPipeStepResult<VigorDeepMerge<VigorFetchPipeStepVoid<VigorFetchPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, {
847
+ result: VigorFetchPipeInitialContext<T>["result"];
848
+ }>, T["policy"]["middlewares"]["after"]>;
719
849
  /** Context shape seen by `onResult` middlewares — additionally threads any `onResult` middlewares already registered earlier in the same chain, so `ctx.result` reflects what the previous `onResult` returned. */
720
850
  type VigorFetchOnResultContextSchema<T extends VigorFetchSchema<T>> = VigorFetchPipeStepResult<VigorFetchAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"]>;
721
851
 
@@ -723,13 +853,21 @@ type VigorFetchPolicySettingsSchema<T extends VigorFetchSchema<T>> = {
723
853
  __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
724
854
  retryHeaders: string[];
725
855
  unretryStatus: number[];
856
+ /**
857
+ * When `true` (the default), a `3xx` response carrying a `Location`
858
+ * header navigates the page to that URL via `window.location.href`.
859
+ * Outside a browser (no `window.location`) this does nothing, exactly
860
+ * like `false`.
861
+ */
862
+ redirect: boolean;
726
863
  maxRestarts: number;
727
864
  default: ((ctx: VigorFetchContextSchema<T>) => any | Promise<any>) | VigorEmptyType;
728
865
  };
729
866
  declare const VigorFetchPolicySettingsBase: {
730
867
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
731
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
868
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
732
869
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
870
+ readonly redirect: true;
733
871
  readonly maxRestarts: 3;
734
872
  readonly default: symbol & {
735
873
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -739,7 +877,7 @@ declare const VigorFetchPolicySettingsBase: {
739
877
  declare class VigorFetchPolicySettings<T extends VigorFetchSchema<T> = typeof VigorFetchBase> extends VigorStatus<VigorFetchSchema<any>, T, VigorFetchPolicySettingsTypeLambda> {
740
878
  constructor(config?: T);
741
879
  protected _create<C>(config: C): VigorApply<VigorFetchPolicySettingsTypeLambda, C>;
742
- /** Sets response headers consulted to compute a server-suggested retry delay. */
880
+ /** Sets (replaces) the response headers consulted to compute a server-suggested retry delay. */
743
881
  retryHeaders<const N extends VigorFetchSchema<any>["policy"]["settings"]["retryHeaders"]>(...strs: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
744
882
  readonly policy: {
745
883
  readonly settings: {
@@ -747,7 +885,7 @@ declare class VigorFetchPolicySettings<T extends VigorFetchSchema<T> = typeof Vi
747
885
  };
748
886
  };
749
887
  }>>>;
750
- /** Sets HTTP status codes that should never be retried. */
888
+ /** Sets (replaces) the HTTP status codes that should never be retried. */
751
889
  unretryStatus<const N extends VigorFetchSchema<any>["policy"]["settings"]["unretryStatus"]>(...nums: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
752
890
  readonly policy: {
753
891
  readonly settings: {
@@ -755,6 +893,18 @@ declare class VigorFetchPolicySettings<T extends VigorFetchSchema<T> = typeof Vi
755
893
  };
756
894
  };
757
895
  }>>>;
896
+ /**
897
+ * When enabled, a `3xx` response with a `Location` header navigates the
898
+ * page to that URL (`window.location.href`). Without `window.location`
899
+ * — e.g. in Node — this behaves like `false`.
900
+ */
901
+ redirect<const N extends VigorFetchSchema<any>["policy"]["settings"]["redirect"]>(bool: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
902
+ readonly policy: {
903
+ readonly settings: {
904
+ readonly redirect: N;
905
+ };
906
+ };
907
+ }>>>;
758
908
  /** Sets the maximum number of full restarts allowed. */
759
909
  maxRestarts<const N extends VigorFetchSchema<any>["policy"]["settings"]["maxRestarts"]>(num: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
760
910
  readonly policy: {
@@ -1302,7 +1452,9 @@ type VigorRetryContextSchema<T extends VigorRetrySchema<T>, R = VigorRetryPipeRe
1302
1452
  /** Context shape seen by `before` middlewares — the target hasn't run yet, so there's no result. */
1303
1453
  type VigorRetryBeforeContextSchema<T extends VigorRetrySchema<T>> = VigorRetryContextSchema<T, VigorDefaultType>;
1304
1454
  /** Context shape seen by `after` middlewares — reflects the result after `before` has run. */
1305
- type VigorRetryAfterContextSchema<T extends VigorRetrySchema<T>> = VigorRetryPipeStepResult<VigorRetryPipeStepVoid<VigorRetryPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>;
1455
+ type VigorRetryAfterContextSchema<T extends VigorRetrySchema<T>> = VigorRetryPipeStepResult<VigorDeepMerge<VigorRetryPipeStepVoid<VigorRetryPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, {
1456
+ result: VigorRetryPipeInitialContext<T>["result"];
1457
+ }>, T["policy"]["middlewares"]["after"]>;
1306
1458
  /** Context shape seen by `onResult` middlewares — additionally threads any `onResult` middlewares already registered earlier in the same chain, so `ctx.result` reflects what the previous `onResult` returned. */
1307
1459
  type VigorRetryOnResultContextSchema<T extends VigorRetrySchema<T>> = VigorRetryPipeStepResult<VigorRetryAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"]>;
1308
1460
 
@@ -1551,18 +1703,61 @@ declare class VigorRetry<T extends VigorRetrySchema<T> = typeof VigorRetryBase>
1551
1703
  request<R = VigorExcludeDefault<VigorRetryContextSchema<T>["result"]>>(): Promise<R>;
1552
1704
  /** Runs the target and returns a result/error envelope instead of throwing. */
1553
1705
  requestVerbose<R = VigorExcludeDefault<VigorRetryContextSchema<T>["result"]>>(): Promise<{
1554
- success: false;
1555
- data: null;
1556
- error: unknown;
1557
- } | {
1558
1706
  success: true;
1559
1707
  data: R;
1560
1708
  error: null;
1709
+ } | {
1710
+ success: false;
1711
+ data: null;
1712
+ error: VigorRetryRequestError<T>;
1561
1713
  }>;
1562
1714
  /** Internal execution loop implementing the attempt/retry/restart lifecycle. */
1563
1715
  private requestRuntime;
1564
1716
  }
1565
1717
 
1718
+ declare const VigorRetryErrorMessageFuncs: {
1719
+ readonly VALUE_REQUIRED: ({ key }: {
1720
+ key: string;
1721
+ }) => string;
1722
+ readonly RETRY_EXHAUSTED: ({ maxAttempts }: {
1723
+ maxAttempts: number;
1724
+ error: unknown;
1725
+ }) => string;
1726
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
1727
+ maxAttempts: number;
1728
+ error: unknown;
1729
+ }) => string;
1730
+ readonly TIMED_OUT: ({ limit }: {
1731
+ limit: number;
1732
+ }) => string;
1733
+ };
1734
+ type VigorRetryErrorCodes = keyof typeof VigorRetryErrorMessageFuncs;
1735
+ type VigorRetryErrorDatas<C extends VigorRetryErrorCodes> = Parameters<typeof VigorRetryErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
1736
+ /**
1737
+ * Every retry error code as its own union member, so narrowing by `code`
1738
+ * also narrows `data` to that code's payload.
1739
+ */
1740
+ type VigorRetryErrors<T extends VigorRetrySchema<any> = VigorRetrySchema<any>> = {
1741
+ [C in VigorRetryErrorCodes]: VigorRetryError<C, T>;
1742
+ }[VigorRetryErrorCodes];
1743
+ /** `error` of a failed `requestVerbose()` — this module's errors, or anything else that was thrown. */
1744
+ type VigorRetryRequestError<T extends VigorRetrySchema<any> = any> = VigorResultError<VigorRetryErrors<T>>;
1745
+ /** Error type thrown by the retry module. */
1746
+ declare class VigorRetryError<C extends VigorRetryErrorCodes, T extends VigorRetrySchema<T>> extends VigorError<C, VigorRetryErrorDatas<C>, VigorRetryContextSchema<T>> {
1747
+ /**
1748
+ * @param code - One of the retry module's error codes.
1749
+ * @param options - Error metadata, including the `data` payload for `code`.
1750
+ */
1751
+ constructor(code: C, options: VigorErrorOptions<VigorRetryErrorDatas<C>, VigorRetryContextSchema<T>>);
1752
+ }
1753
+ /**
1754
+ * Narrows an error from a failed result envelope to the retry module's typed
1755
+ * error union. Prefer this over a bare `instanceof`: the envelope's `{}`
1756
+ * member makes `instanceof` widen `data` back to every code's payload,
1757
+ * while this guard keeps `code` and `data` in sync.
1758
+ */
1759
+ declare const isVigorRetryError: (error: unknown) => error is VigorRetryErrors;
1760
+
1566
1761
  type VigorParseStrategyFunc = (response: Response) => Promise<any>;
1567
1762
  type VigorParsePolicyStrategiesSchema<T extends VigorParseSchema<T>> = {
1568
1763
  __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
@@ -1572,7 +1767,11 @@ declare const VigorParsePolicyStrategiesBase: {
1572
1767
  readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
1573
1768
  readonly funcs: VigorParseStrategyFunc[];
1574
1769
  };
1575
- /** Parses a response by matching its `Content-Type` header against a known parser table. */
1770
+ /**
1771
+ * Parses a response by matching its `Content-Type` header against a known
1772
+ * parser table. A response without a body (e.g. `204 No Content`) resolves to
1773
+ * `null`, and one without a `Content-Type` is read as text (`null` if empty).
1774
+ */
1576
1775
  declare const VigorParseContentTypeStrategy: VigorParseStrategyFunc;
1577
1776
  /** Parses a response by trying a sequence of body-reading methods until one succeeds. */
1578
1777
  declare const VigorParseSniffStrategy: VigorParseStrategyFunc;
@@ -1851,7 +2050,7 @@ type VigorParseContextSchema<T extends VigorParseSchema<T>, R = VigorParsePipeRe
1851
2050
  error: unknown;
1852
2051
  response: VigorParsePolicySchema<T>["target"];
1853
2052
  flags: {
1854
- overrided: boolean;
2053
+ overridden: boolean;
1855
2054
  restarted: boolean;
1856
2055
  };
1857
2056
  record: Record<string, any>;
@@ -1860,7 +2059,9 @@ type VigorParseContextSchema<T extends VigorParseSchema<T>, R = VigorParsePipeRe
1860
2059
  /** Context shape seen by `before` middlewares — parsing hasn't run yet. */
1861
2060
  type VigorParseBeforeContextSchema<T extends VigorParseSchema<T>> = VigorParseContextSchema<T, VigorDefaultType>;
1862
2061
  /** Context shape seen by `after` middlewares — reflects the result after `before` has run. */
1863
- type VigorParseAfterContextSchema<T extends VigorParseSchema<T>> = VigorParsePipeStepResult<VigorParsePipeStepVoid<VigorParsePipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>;
2062
+ type VigorParseAfterContextSchema<T extends VigorParseSchema<T>> = VigorParsePipeStepResult<VigorDeepMerge<VigorParsePipeStepVoid<VigorParsePipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, {
2063
+ result: VigorParsePipeInitialContext<T>["result"];
2064
+ }>, T["policy"]["middlewares"]["after"]>;
1864
2065
  /** Context shape seen by `onResult` middlewares — additionally threads any `onResult` middlewares already registered earlier in the same chain, so `ctx.result` reflects what the previous `onResult` returned. */
1865
2066
  type VigorParseOnResultContextSchema<T extends VigorParseSchema<T>> = VigorParsePipeStepResult<VigorParseAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"]>;
1866
2067
 
@@ -2067,18 +2268,125 @@ declare class VigorParse<T extends VigorParseSchema<T> = typeof VigorParseBase>
2067
2268
  request<R = VigorExcludeDefault<VigorParseContextSchema<T>["result"]>>(): Promise<R>;
2068
2269
  /** Runs parsing and returns a result/error envelope instead of throwing. */
2069
2270
  requestVerbose<R = VigorExcludeDefault<VigorParseContextSchema<T>["result"]>>(): Promise<{
2070
- success: false;
2071
- data: null;
2072
- error: unknown;
2073
- } | {
2074
2271
  success: true;
2075
2272
  data: R;
2076
2273
  error: null;
2274
+ } | {
2275
+ success: false;
2276
+ data: null;
2277
+ error: VigorParseRequestError<T>;
2077
2278
  }>;
2078
2279
  /** Internal execution loop implementing the strategy fallback and restart handling. */
2079
2280
  private requestRuntime;
2080
2281
  }
2081
2282
 
2283
+ declare const VigorParseErrorMessageFuncs: {
2284
+ readonly VALUE_REQUIRED: ({ key }: {
2285
+ key: string;
2286
+ }) => string;
2287
+ readonly INVALID_CONTENT_TYPE: ({ received }: {
2288
+ received: unknown;
2289
+ }) => string;
2290
+ readonly PARSER_NOT_FOUND: ({ received, expected }: {
2291
+ received: unknown;
2292
+ expected: Array<string>;
2293
+ }) => string;
2294
+ readonly PARSER_ALL_FAILED: ({ tried }: {
2295
+ tried: Array<string>;
2296
+ }) => string;
2297
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
2298
+ maxAttempts: number;
2299
+ error: unknown;
2300
+ }) => string;
2301
+ };
2302
+ type VigorParseErrorCodes = keyof typeof VigorParseErrorMessageFuncs;
2303
+ type VigorParseErrorDatas<C extends VigorParseErrorCodes> = Parameters<typeof VigorParseErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
2304
+ /**
2305
+ * Every parse error code as its own union member, so narrowing by `code`
2306
+ * also narrows `data` to that code's payload.
2307
+ */
2308
+ type VigorParseErrors<T extends VigorParseSchema<any> = VigorParseSchema<any>> = {
2309
+ [C in VigorParseErrorCodes]: VigorParseError<C, T>;
2310
+ }[VigorParseErrorCodes];
2311
+ /** `error` of a failed `requestVerbose()` — this module's errors, or anything else that was thrown. */
2312
+ type VigorParseRequestError<T extends VigorParseSchema<any> = any> = VigorResultError<VigorParseErrors<T>>;
2313
+ /** Error type thrown by the parse module. */
2314
+ declare class VigorParseError<C extends VigorParseErrorCodes, T extends VigorParseSchema<T>> extends VigorError<C, VigorParseErrorDatas<C>, VigorParseContextSchema<T>> {
2315
+ /**
2316
+ * @param code - One of the parse module's error codes.
2317
+ * @param options - Error metadata, including the `data` payload for `code`.
2318
+ */
2319
+ constructor(code: C, options: VigorErrorOptions<VigorParseErrorDatas<C>, VigorParseContextSchema<T>>);
2320
+ }
2321
+ /**
2322
+ * Narrows an error from a failed result envelope to the parse module's typed
2323
+ * error union. Prefer this over a bare `instanceof`: the envelope's `{}`
2324
+ * member makes `instanceof` widen `data` back to every code's payload,
2325
+ * while this guard keeps `code` and `data` in sync.
2326
+ */
2327
+ declare const isVigorParseError: (error: unknown) => error is VigorParseErrors;
2328
+
2329
+ declare const VigorFetchErrorMessageFuncs: {
2330
+ readonly VALUE_REQUIRED: ({ key }: {
2331
+ key: string;
2332
+ }) => string;
2333
+ readonly INVALID_BODY: ({ received }: {
2334
+ received: unknown;
2335
+ }) => string;
2336
+ readonly INVALID_PROTOCOL: ({ origin, base }: {
2337
+ origin: string;
2338
+ base: string | undefined;
2339
+ }) => string;
2340
+ readonly FETCH_FAILED: ({ status, statusText }: {
2341
+ status: number;
2342
+ statusText: string;
2343
+ response: Response;
2344
+ url: string;
2345
+ parsed: unknown;
2346
+ }) => string;
2347
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
2348
+ maxAttempts: number;
2349
+ error: unknown;
2350
+ }) => string;
2351
+ readonly REDIRECTED: ({ url, status }: {
2352
+ url: string;
2353
+ status: number;
2354
+ response: Response;
2355
+ }) => string;
2356
+ };
2357
+ type VigorFetchErrorCodes = keyof typeof VigorFetchErrorMessageFuncs;
2358
+ type VigorFetchErrorDatas<C extends VigorFetchErrorCodes> = Parameters<typeof VigorFetchErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
2359
+ /**
2360
+ * Every fetch error code as its own union member, so narrowing by `code`
2361
+ * also narrows `data` to that code's payload.
2362
+ */
2363
+ type VigorFetchErrors<T extends VigorFetchSchema<any> = VigorFetchSchema<any>> = {
2364
+ [C in VigorFetchErrorCodes]: VigorFetchError<C, T>;
2365
+ }[VigorFetchErrorCodes];
2366
+ /**
2367
+ * `error` of a failed `requestVerbose()`. Includes the nested engines'
2368
+ * errors, since fetch surfaces them as-is: a retried-out request fails with
2369
+ * `VigorRetryError("RETRY_EXHAUSTED")` (its `cause` holding the last
2370
+ * `VigorFetchError`), and a body that can't be parsed fails with a
2371
+ * `VigorParseError`.
2372
+ */
2373
+ type VigorFetchRequestError<T extends VigorFetchSchema<any> = any> = VigorResultError<VigorFetchErrors<T> | VigorRetryErrors | VigorParseErrors>;
2374
+ /** Error type thrown by the fetch module. */
2375
+ declare class VigorFetchError<C extends VigorFetchErrorCodes, T extends VigorFetchSchema<T>> extends VigorError<C, VigorFetchErrorDatas<C>, VigorFetchContextSchema<T>> {
2376
+ /**
2377
+ * @param code - One of the fetch module's error codes.
2378
+ * @param options - Error metadata, including the `data` payload for `code`.
2379
+ */
2380
+ constructor(code: C, options: VigorErrorOptions<VigorFetchErrorDatas<C>, VigorFetchContextSchema<T>>);
2381
+ }
2382
+ /**
2383
+ * Narrows an error from a failed result envelope to the fetch module's typed
2384
+ * error union. Prefer this over a bare `instanceof`: the envelope's `{}`
2385
+ * member makes `instanceof` widen `data` back to every code's payload,
2386
+ * while this guard keeps `code` and `data` in sync.
2387
+ */
2388
+ declare const isVigorFetchError: (error: unknown) => error is VigorFetchErrors;
2389
+
2082
2390
  type VigorStringable = string | number | boolean | null | undefined | Date;
2083
2391
  type VigorFetchPolicySchema<T extends VigorFetchSchema<T>> = {
2084
2392
  __brand: VigorBrand<"Fetch", "Policy<Schema">;
@@ -2113,8 +2421,9 @@ declare const VigorFetchPolicyBase: {
2113
2421
  readonly extra: {};
2114
2422
  readonly settings: {
2115
2423
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2116
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2424
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
2117
2425
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2426
+ readonly redirect: true;
2118
2427
  readonly maxRestarts: 3;
2119
2428
  readonly default: symbol & {
2120
2429
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -2224,8 +2533,9 @@ declare const VigorFetchBase: {
2224
2533
  readonly extra: {};
2225
2534
  readonly settings: {
2226
2535
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2227
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2536
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
2228
2537
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2538
+ readonly redirect: true;
2229
2539
  readonly maxRestarts: 3;
2230
2540
  readonly default: symbol & {
2231
2541
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -2477,6 +2787,25 @@ declare class VigorFetch<T extends VigorFetchSchema<T> = typeof VigorFetchBase>
2477
2787
  headers: Record<string, string>;
2478
2788
  body: BodyInit | null | undefined;
2479
2789
  };
2790
+ /**
2791
+ * Returns the absolute URL a `3xx` response points at, or `null` when the
2792
+ * response isn't a redirect or carries no usable `Location` header. A
2793
+ * relative `Location` is resolved against the responding URL.
2794
+ */
2795
+ protected _resolveRedirect(response: Response, href: string): string | null;
2796
+ /** The browser's `location`, or `null` in environments without one (e.g. Node). */
2797
+ protected _browserLocation(): {
2798
+ href: string;
2799
+ } | null;
2800
+ /** Assigns `source` headers onto `target`, replacing any existing key that differs only in case. */
2801
+ protected _assignHeaders(target: Record<string, string>, source: Record<string, string>): void;
2802
+ /**
2803
+ * Converts a rate-limit header value into a delay in milliseconds, or
2804
+ * `null` if it can't be used. Accepts delta seconds (`Retry-After: 120`),
2805
+ * Unix epoch seconds or milliseconds (`X-RateLimit-Reset: 1735689600`),
2806
+ * and HTTP dates.
2807
+ */
2808
+ protected _parseRetryHeader(value: string | null): number | null;
2480
2809
  /**
2481
2810
  * Overrides the resolved result type with `T`, taking priority over the
2482
2811
  * default `unknown` result. Can be called before or after `parse()` (or
@@ -2490,13 +2819,13 @@ declare class VigorFetch<T extends VigorFetchSchema<T> = typeof VigorFetchBase>
2490
2819
  request<R = VigorExcludeDefault<VigorFetchContextSchema<T>["result"]>>(): Promise<R>;
2491
2820
  /** Runs the request and returns a result/error envelope instead of throwing. */
2492
2821
  requestVerbose<R = VigorExcludeDefault<VigorFetchContextSchema<T>["result"]>>(): Promise<{
2493
- success: false;
2494
- data: null;
2495
- error: unknown;
2496
- } | {
2497
2822
  success: true;
2498
2823
  data: R;
2499
2824
  error: null;
2825
+ } | {
2826
+ success: false;
2827
+ data: null;
2828
+ error: VigorFetchRequestError<T>;
2500
2829
  }>;
2501
2830
  /** Internal execution loop implementing URL building, retry, parsing, and restart handling. */
2502
2831
  private requestRuntime;
@@ -2590,8 +2919,9 @@ declare function fetchWithOrigin<const F extends Parameters<VigorFetch["origin"]
2590
2919
  __brand: VigorBrand<"Fetch", "Policy<Schema">;
2591
2920
  settings: {
2592
2921
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2593
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2922
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
2594
2923
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2924
+ readonly redirect: true;
2595
2925
  readonly maxRestarts: 3;
2596
2926
  readonly default: symbol & {
2597
2927
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -2695,10 +3025,15 @@ declare function allWithTargets<const F extends VigorAllTask[]>(tasks: F): Vigor
2695
3025
  policy: {
2696
3026
  target: F extends VigorBuiltin ? F : F extends readonly any[] ? [...F] : F;
2697
3027
  __brand: VigorBrand<"All", "Policy<Schema">;
3028
+ abortSignals: [];
2698
3029
  settings: {
2699
3030
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
2700
3031
  readonly concurrency: 5;
2701
3032
  readonly onlySuccess: false;
3033
+ readonly timeout: symbol & {
3034
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3035
+ };
3036
+ readonly failFast: false;
2702
3037
  };
2703
3038
  middlewares: {
2704
3039
  readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
@@ -2765,8 +3100,9 @@ declare const vigorBase: {
2765
3100
  readonly extra: {};
2766
3101
  readonly settings: {
2767
3102
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2768
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3103
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
2769
3104
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3105
+ readonly redirect: true;
2770
3106
  readonly maxRestarts: 3;
2771
3107
  readonly default: symbol & {
2772
3108
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -2873,8 +3209,9 @@ declare const vigorBase: {
2873
3209
  readonly extra: {};
2874
3210
  readonly settings: {
2875
3211
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2876
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3212
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after"];
2877
3213
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3214
+ readonly redirect: true;
2878
3215
  readonly maxRestarts: 3;
2879
3216
  readonly default: symbol & {
2880
3217
  __brand: VigorBrand<"Core", "Symbol_Empty">;
@@ -3220,10 +3557,15 @@ declare const vigorBase: {
3220
3557
  readonly policy: {
3221
3558
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
3222
3559
  readonly target: [];
3560
+ readonly abortSignals: [];
3223
3561
  readonly settings: {
3224
3562
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
3225
3563
  readonly concurrency: 5;
3226
3564
  readonly onlySuccess: false;
3565
+ readonly timeout: symbol & {
3566
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3567
+ };
3568
+ readonly failFast: false;
3227
3569
  };
3228
3570
  readonly middlewares: {
3229
3571
  readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
@@ -3244,10 +3586,15 @@ declare const vigorBase: {
3244
3586
  readonly policy: {
3245
3587
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
3246
3588
  readonly target: [];
3589
+ readonly abortSignals: [];
3247
3590
  readonly settings: {
3248
3591
  readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
3249
3592
  readonly concurrency: 5;
3250
3593
  readonly onlySuccess: false;
3594
+ readonly timeout: symbol & {
3595
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3596
+ };
3597
+ readonly failFast: false;
3251
3598
  };
3252
3599
  readonly middlewares: {
3253
3600
  readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
@@ -3266,8 +3613,9 @@ declare const vigorBase: {
3266
3613
  };
3267
3614
  };
3268
3615
  };
3269
- type VigorInstance = typeof vigorBase & {
3270
- use: <P extends VigorPlugin<any, any>>(plugin: P, options?: P["options"]) => VigorInstance & ReturnType<P["func"]>;
3616
+ /** `Ext` accumulates every plugin extension applied so far, so `use().use()` keeps all of them. */
3617
+ type VigorInstance<Ext = {}> = typeof vigorBase & Ext & {
3618
+ use: <P extends VigorPlugin<any, any>>(plugin: P, options?: P["options"]) => VigorInstance<Ext & ReturnType<P["func"]>>;
3271
3619
  };
3272
3620
  /**
3273
3621
  * A plugin never mutates the `VigorInstance` it receives — it reads from it
@@ -3283,139 +3631,4 @@ type VigorPlugin<O extends {
3283
3631
  };
3284
3632
  declare const vigor: VigorInstance;
3285
3633
 
3286
- type VigorErrorOptions<D, T> = {
3287
- cause?: unknown;
3288
- data: D;
3289
- method: string;
3290
- context?: T;
3291
- };
3292
- /**
3293
- * Base class for all Vigor error types. Subclasses (`VigorRetryError`,
3294
- * `VigorFetchError`, `VigorParseError`, `VigorAllError`) fix `C`, `D`, and
3295
- * `T` to their own error-code union, data shape, and context shape.
3296
- *
3297
- * @typeParam C - Union of error codes for the subclass.
3298
- * @typeParam D - Shape of the structured error data.
3299
- * @typeParam T - Shape of the domain context.
3300
- */
3301
- declare abstract class VigorError<C extends string, D, T> extends Error {
3302
- readonly timestamp: Date;
3303
- readonly cause?: unknown;
3304
- readonly code: C;
3305
- readonly data: D;
3306
- readonly method: string;
3307
- readonly context: T | undefined;
3308
- /**
3309
- * @param code - Machine-readable error code.
3310
- * @param message - Human-readable message (rendered after the `[code]` prefix).
3311
- * @param options - Additional error metadata (cause, data, method, context).
3312
- */
3313
- constructor(code: C, message: string, options: VigorErrorOptions<D, T>);
3314
- }
3315
-
3316
- declare const VigorRetryErrorMessageFuncs: {
3317
- readonly VALUE_REQUIRED: ({ key }: {
3318
- key: string;
3319
- }) => string;
3320
- readonly RETRY_EXHAUSTED: ({ maxAttempts }: {
3321
- maxAttempts: number;
3322
- error: unknown;
3323
- }) => string;
3324
- readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
3325
- maxAttempts: number;
3326
- error: unknown;
3327
- }) => string;
3328
- readonly TIMED_OUT: ({ limit }: {
3329
- limit: number;
3330
- }) => string;
3331
- };
3332
- type VigorRetryErrorCodes = keyof typeof VigorRetryErrorMessageFuncs;
3333
- type VigorRetryErrorDatas<C extends VigorRetryErrorCodes> = Parameters<typeof VigorRetryErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
3334
- /** Error type thrown by the retry module. */
3335
- declare class VigorRetryError<C extends VigorRetryErrorCodes, T extends VigorRetrySchema<T>> extends VigorError<C, VigorRetryErrorDatas<C>, VigorRetryContextSchema<T>> {
3336
- /**
3337
- * @param code - One of the retry module's error codes.
3338
- * @param options - Error metadata, including the `data` payload for `code`.
3339
- */
3340
- constructor(code: C, options: VigorErrorOptions<VigorRetryErrorDatas<C>, VigorRetryContextSchema<T>>);
3341
- }
3342
-
3343
- declare const VigorParseErrorMessageFuncs: {
3344
- readonly VALUE_REQUIRED: ({ key }: {
3345
- key: string;
3346
- }) => string;
3347
- readonly INVALID_CONTENT_TYPE: ({ received }: {
3348
- received: unknown;
3349
- }) => string;
3350
- readonly PARSER_NOT_FOUND: ({ received, expected }: {
3351
- received: unknown;
3352
- expected: Array<string>;
3353
- }) => string;
3354
- readonly PARSER_ALL_FAILED: ({ tried }: {
3355
- tried: Array<string>;
3356
- }) => string;
3357
- readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
3358
- maxAttempts: number;
3359
- error: unknown;
3360
- }) => string;
3361
- };
3362
- type VigorParseErrorCodes = keyof typeof VigorParseErrorMessageFuncs;
3363
- type VigorParseErrorDatas<C extends VigorParseErrorCodes> = Parameters<typeof VigorParseErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
3364
- /** Error type thrown by the parse module. */
3365
- declare class VigorParseError<C extends VigorParseErrorCodes, T extends VigorParseSchema<T>> extends VigorError<C, VigorParseErrorDatas<C>, VigorParseContextSchema<T>> {
3366
- /**
3367
- * @param code - One of the parse module's error codes.
3368
- * @param options - Error metadata, including the `data` payload for `code`.
3369
- */
3370
- constructor(code: C, options: VigorErrorOptions<VigorParseErrorDatas<C>, VigorParseContextSchema<T>>);
3371
- }
3372
-
3373
- declare const VigorFetchErrorMessageFuncs: {
3374
- readonly VALUE_REQUIRED: ({ key }: {
3375
- key: string;
3376
- }) => string;
3377
- readonly INVALID_BODY: ({ received }: {
3378
- received: unknown;
3379
- }) => string;
3380
- readonly INVALID_PROTOCOL: ({ origin, base }: {
3381
- origin: string;
3382
- base: string | undefined;
3383
- }) => string;
3384
- readonly FETCH_FAILED: ({ status, statusText }: {
3385
- status: number;
3386
- statusText: string;
3387
- response: Response;
3388
- url: string;
3389
- parsed: unknown;
3390
- }) => string;
3391
- readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
3392
- maxAttempts: number;
3393
- error: unknown;
3394
- }) => string;
3395
- };
3396
- type VigorFetchErrorCodes = keyof typeof VigorFetchErrorMessageFuncs;
3397
- type VigorFetchErrorDatas<C extends VigorFetchErrorCodes> = Parameters<typeof VigorFetchErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
3398
- /** Error type thrown by the fetch module. */
3399
- declare class VigorFetchError<C extends VigorFetchErrorCodes, T extends VigorFetchSchema<T>> extends VigorError<C, VigorFetchErrorDatas<C>, VigorFetchContextSchema<T>> {
3400
- /**
3401
- * @param code - One of the fetch module's error codes.
3402
- * @param options - Error metadata, including the `data` payload for `code`.
3403
- */
3404
- constructor(code: C, options: VigorErrorOptions<VigorFetchErrorDatas<C>, VigorFetchContextSchema<T>>);
3405
- }
3406
-
3407
- declare const VigorAllErrorMessageFuncs: {
3408
- readonly EMPTY_TARGET: (_: {}) => string;
3409
- };
3410
- type VigorAllErrorCodes = keyof typeof VigorAllErrorMessageFuncs;
3411
- type VigorAllErrorDatas<C extends VigorAllErrorCodes> = Parameters<typeof VigorAllErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
3412
- /** Error type thrown by the all module. */
3413
- declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSchema<T>> extends VigorError<C, VigorAllErrorDatas<C>, VigorAllContextSchema<T>> {
3414
- /**
3415
- * @param code - One of the all module's error codes.
3416
- * @param options - Error metadata, including the `data` payload for `code`.
3417
- */
3418
- constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, VigorAllContextSchema<T>>);
3419
- }
3420
-
3421
- export { VigorAll, VigorAllBase, type VigorAllEachMiddlewareFn, type VigorAllEachOnErrorFn, VigorAllError, type VigorAllErrorCodes, type VigorAllErrorDatas, VigorAllErrorMessageFuncs, type VigorAllNaturalResult, type VigorAllPipeInitialContext, type VigorAllPipeResult, type VigorAllPipeStepResult, type VigorAllPipeStepVoid, VigorAllPolicyBase, VigorAllPolicyMiddlewares, type VigorAllPolicyMiddlewaresApi, VigorAllPolicyMiddlewaresBase, type VigorAllPolicyMiddlewaresFluent, type VigorAllPolicyMiddlewaresIntercept, type VigorAllPolicyMiddlewaresPipe, type VigorAllPolicyMiddlewaresSchema, type VigorAllPolicySchema, VigorAllPolicySettings, VigorAllPolicySettingsBase, type VigorAllPolicySettingsSchema, type VigorAllSchema, type VigorAllTask, type VigorAllTaskResult, type VigorAllTasksTuple, type VigorBuiltin, type VigorCastResult, type VigorConcat, type VigorDeepMerge, type VigorDeepPartial, VigorError, type VigorErrorOptions, VigorFetch, VigorFetchBase, VigorFetchError, type VigorFetchErrorCodes, type VigorFetchErrorDatas, VigorFetchErrorMessageFuncs, type VigorFetchPipeInitialContext, type VigorFetchPipeResult, type VigorFetchPipeStepResult, type VigorFetchPipeStepVoid, VigorFetchPolicyBase, VigorFetchPolicyMiddlewares, type VigorFetchPolicyMiddlewaresApi, VigorFetchPolicyMiddlewaresBase, type VigorFetchPolicyMiddlewaresFluent, type VigorFetchPolicyMiddlewaresIntercept, type VigorFetchPolicyMiddlewaresPipe, type VigorFetchPolicyMiddlewaresSchema, type VigorFetchPolicySchema, VigorFetchPolicySettings, VigorFetchPolicySettingsBase, type VigorFetchPolicySettingsSchema, type VigorFetchSchema, type VigorInstance, VigorJitter, type VigorLastOf, type VigorMergeMode, type VigorMergeStrategy, VigorParse, VigorParseBase, VigorParseContentTypeStrategy, VigorParseError, type VigorParseErrorCodes, type VigorParseErrorDatas, VigorParseErrorMessageFuncs, type VigorParsePipeInitialContext, type VigorParsePipeResult, type VigorParsePipeStepResult, type VigorParsePipeStepVoid, VigorParsePolicyBase, VigorParsePolicyMiddlewares, type VigorParsePolicyMiddlewaresApi, VigorParsePolicyMiddlewaresBase, type VigorParsePolicyMiddlewaresFluent, type VigorParsePolicyMiddlewaresIntercept, type VigorParsePolicyMiddlewaresPipe, type VigorParsePolicyMiddlewaresSchema, type VigorParsePolicySchema, VigorParsePolicySettings, VigorParsePolicySettingsBase, type VigorParsePolicySettingsSchema, VigorParsePolicyStrategies, VigorParsePolicyStrategiesBase, type VigorParsePolicyStrategiesSchema, type VigorParseSchema, VigorParseSniffStrategy, type VigorParseStrategyFunc, type VigorPlugin, type VigorPrimitive, type VigorReplaceType, VigorRetry, VigorRetryBase, VigorRetryError, type VigorRetryErrorCodes, type VigorRetryErrorDatas, VigorRetryErrorMessageFuncs, type VigorRetryPipeInitialContext, type VigorRetryPipeResult, type VigorRetryPipeStepResult, type VigorRetryPipeStepRetryIf, type VigorRetryPipeStepVoid, VigorRetryPolicyAlgorithms, VigorRetryPolicyAlgorithmsBackoff, VigorRetryPolicyAlgorithmsBackoffBase, type VigorRetryPolicyAlgorithmsBackoffSchema, VigorRetryPolicyAlgorithmsBase, VigorRetryPolicyAlgorithmsConstant, VigorRetryPolicyAlgorithmsConstantBase, type VigorRetryPolicyAlgorithmsConstantSchema, VigorRetryPolicyAlgorithmsCustom, VigorRetryPolicyAlgorithmsCustomBase, type VigorRetryPolicyAlgorithmsCustomSchema, VigorRetryPolicyAlgorithmsLinear, VigorRetryPolicyAlgorithmsLinearBase, type VigorRetryPolicyAlgorithmsLinearSchema, type VigorRetryPolicyAlgorithmsSchema, VigorRetryPolicyBase, VigorRetryPolicyMiddlewares, type VigorRetryPolicyMiddlewaresApi, VigorRetryPolicyMiddlewaresBase, type VigorRetryPolicyMiddlewaresFluent, type VigorRetryPolicyMiddlewaresIntercept, type VigorRetryPolicyMiddlewaresPipe, type VigorRetryPolicyMiddlewaresSchema, type VigorRetryPolicySchema, VigorRetryPolicySettings, VigorRetryPolicySettingsBase, type VigorRetryPolicySettingsSchema, type VigorRetrySchema, type VigorReturnType, type VigorSimplify, VigorStatus, type VigorStringable, vigor as default, vigor };
3634
+ export { VigorAll, VigorAllBase, type VigorAllEachMiddlewareFn, type VigorAllEachOnErrorFn, VigorAllError, type VigorAllErrorCodes, type VigorAllErrorDatas, VigorAllErrorMessageFuncs, type VigorAllErrors, type VigorAllNaturalResult, type VigorAllPipeInitialContext, type VigorAllPipeResult, type VigorAllPipeStepResult, type VigorAllPipeStepVoid, VigorAllPolicyBase, VigorAllPolicyMiddlewares, type VigorAllPolicyMiddlewaresApi, VigorAllPolicyMiddlewaresBase, type VigorAllPolicyMiddlewaresFluent, type VigorAllPolicyMiddlewaresIntercept, type VigorAllPolicyMiddlewaresPipe, type VigorAllPolicyMiddlewaresSchema, type VigorAllPolicySchema, VigorAllPolicySettings, VigorAllPolicySettingsBase, type VigorAllPolicySettingsSchema, type VigorAllRequestError, type VigorAllSchema, type VigorAllTask, type VigorAllTaskResult, type VigorAllTasksTuple, type VigorBuiltin, type VigorCastResult, type VigorConcat, type VigorDeepMerge, type VigorDeepPartial, VigorError, type VigorErrorOptions, VigorFetch, VigorFetchBase, VigorFetchError, type VigorFetchErrorCodes, type VigorFetchErrorDatas, VigorFetchErrorMessageFuncs, type VigorFetchErrors, type VigorFetchPipeInitialContext, type VigorFetchPipeResult, type VigorFetchPipeStepResult, type VigorFetchPipeStepVoid, VigorFetchPolicyBase, VigorFetchPolicyMiddlewares, type VigorFetchPolicyMiddlewaresApi, VigorFetchPolicyMiddlewaresBase, type VigorFetchPolicyMiddlewaresFluent, type VigorFetchPolicyMiddlewaresIntercept, type VigorFetchPolicyMiddlewaresPipe, type VigorFetchPolicyMiddlewaresSchema, type VigorFetchPolicySchema, VigorFetchPolicySettings, VigorFetchPolicySettingsBase, type VigorFetchPolicySettingsSchema, type VigorFetchRequestError, type VigorFetchSchema, type VigorInstance, VigorJitter, type VigorLastOf, type VigorMergeMode, type VigorMergeStrategy, VigorParse, VigorParseBase, VigorParseContentTypeStrategy, VigorParseError, type VigorParseErrorCodes, type VigorParseErrorDatas, VigorParseErrorMessageFuncs, type VigorParseErrors, type VigorParsePipeInitialContext, type VigorParsePipeResult, type VigorParsePipeStepResult, type VigorParsePipeStepVoid, VigorParsePolicyBase, VigorParsePolicyMiddlewares, type VigorParsePolicyMiddlewaresApi, VigorParsePolicyMiddlewaresBase, type VigorParsePolicyMiddlewaresFluent, type VigorParsePolicyMiddlewaresIntercept, type VigorParsePolicyMiddlewaresPipe, type VigorParsePolicyMiddlewaresSchema, type VigorParsePolicySchema, VigorParsePolicySettings, VigorParsePolicySettingsBase, type VigorParsePolicySettingsSchema, VigorParsePolicyStrategies, VigorParsePolicyStrategiesBase, type VigorParsePolicyStrategiesSchema, type VigorParseRequestError, type VigorParseSchema, VigorParseSniffStrategy, type VigorParseStrategyFunc, type VigorPlugin, type VigorPrimitive, type VigorReplaceType, type VigorResultError, VigorRetry, VigorRetryBase, VigorRetryError, type VigorRetryErrorCodes, type VigorRetryErrorDatas, VigorRetryErrorMessageFuncs, type VigorRetryErrors, type VigorRetryPipeInitialContext, type VigorRetryPipeResult, type VigorRetryPipeStepResult, type VigorRetryPipeStepRetryIf, type VigorRetryPipeStepVoid, VigorRetryPolicyAlgorithms, VigorRetryPolicyAlgorithmsBackoff, VigorRetryPolicyAlgorithmsBackoffBase, type VigorRetryPolicyAlgorithmsBackoffSchema, VigorRetryPolicyAlgorithmsBase, VigorRetryPolicyAlgorithmsConstant, VigorRetryPolicyAlgorithmsConstantBase, type VigorRetryPolicyAlgorithmsConstantSchema, VigorRetryPolicyAlgorithmsCustom, VigorRetryPolicyAlgorithmsCustomBase, type VigorRetryPolicyAlgorithmsCustomSchema, VigorRetryPolicyAlgorithmsLinear, VigorRetryPolicyAlgorithmsLinearBase, type VigorRetryPolicyAlgorithmsLinearSchema, type VigorRetryPolicyAlgorithmsSchema, VigorRetryPolicyBase, VigorRetryPolicyMiddlewares, type VigorRetryPolicyMiddlewaresApi, VigorRetryPolicyMiddlewaresBase, type VigorRetryPolicyMiddlewaresFluent, type VigorRetryPolicyMiddlewaresIntercept, type VigorRetryPolicyMiddlewaresPipe, type VigorRetryPolicyMiddlewaresSchema, type VigorRetryPolicySchema, VigorRetryPolicySettings, VigorRetryPolicySettingsBase, type VigorRetryPolicySettingsSchema, type VigorRetryRequestError, type VigorRetrySchema, type VigorReturnType, type VigorSimplify, VigorStatus, type VigorStringable, vigor as default, isVigorAllError, isVigorFetchError, isVigorParseError, isVigorRetryError, vigor };