vigor-fetch 5.0.0 → 5.2.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/README.md +19 -3
- package/dist/index.cjs +47 -4
- package/dist/index.d.cts +377 -320
- package/dist/index.d.ts +377 -320
- package/dist/index.js +42 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -114,6 +114,48 @@ type VigorMergeMode = "merge" | "replace" | "concat";
|
|
|
114
114
|
type VigorMergeStrategy<T> = T extends VigorBuiltin ? VigorMergeMode | undefined : T extends readonly any[] ? VigorMergeMode : {
|
|
115
115
|
[K in keyof T]?: VigorMergeStrategy<T[K]> | VigorMergeMode;
|
|
116
116
|
};
|
|
117
|
+
/** Whether `A` and `B` are the same type. */
|
|
118
|
+
type VigorIsSame<A, B> = (<X>() => X extends A ? 1 : 2) extends (<X>() => X extends B ? 1 : 2) ? true : false;
|
|
119
|
+
/**
|
|
120
|
+
* What an intercept middleware changed: the keys of the context `A` it
|
|
121
|
+
* returned whose type differs from the context `P` it was given (or that
|
|
122
|
+
* `P` lacks). Returning `ctx` itself — or `{ ...ctx }` — changes nothing, so
|
|
123
|
+
* the pipeline keeps its own, current types instead of the snapshot `P` was
|
|
124
|
+
* computed from when the middleware was registered. An `any` return, or an
|
|
125
|
+
* `any` key, changes nothing either.
|
|
126
|
+
*/
|
|
127
|
+
type VigorContextChanges<P, A> = 0 extends (1 & A) ? {} : VigorIsSame<A, P> extends true ? {} : A extends object ? {
|
|
128
|
+
[K in keyof A as K extends keyof P ? VigorIsSame<A[K], P[K]> extends true ? never : 0 extends (1 & A[K]) ? never : K : K]: A[K];
|
|
129
|
+
} : {};
|
|
130
|
+
/** `Ctx` with `Changes` written over it — `Ctx` itself when nothing changed. */
|
|
131
|
+
type VigorContextApply<Ctx, Changes> = [
|
|
132
|
+
keyof Changes
|
|
133
|
+
] extends [never] ? Ctx : VigorContextReset<Ctx, Changes>;
|
|
134
|
+
/** `Ctx` with `Fresh`'s keys given `Fresh`'s types — what the runtime (re)sets at a stage's start. One mapped type, so it stays cheap. */
|
|
135
|
+
type VigorContextReset<Ctx, Fresh> = {
|
|
136
|
+
[K in keyof Ctx | keyof Fresh]: K extends keyof Fresh ? Fresh[K] : K extends keyof Ctx ? Ctx[K] : never;
|
|
137
|
+
};
|
|
138
|
+
/** One middleware applied to `Ctx` — see {@link VigorContextStage}. */
|
|
139
|
+
type VigorContextStep<Ctx, M, FluentKey extends PropertyKey> = M extends {
|
|
140
|
+
_mode: "intercept";
|
|
141
|
+
func: (ctx: infer P, ...args: any[]) => infer Ret;
|
|
142
|
+
} ? VigorContextApply<Ctx, VigorContextChanges<P, Awaited<Ret>>> : M extends {
|
|
143
|
+
_mode: "fluent";
|
|
144
|
+
func: (...args: any[]) => infer FR;
|
|
145
|
+
} ? [FluentKey] extends [never] ? Ctx : VigorContextApply<Ctx, {
|
|
146
|
+
[K in FluentKey]: Awaited<FR>;
|
|
147
|
+
}> : Ctx;
|
|
148
|
+
/**
|
|
149
|
+
* Folds one stage's middleware list over `Ctx`, the way the runtime runs
|
|
150
|
+
* it: an intercept middleware's returned context (awaited) overwrites the
|
|
151
|
+
* keys it changed (see {@link VigorContextChanges}), and a fluent one's
|
|
152
|
+
* return value (awaited) overwrites `FluentKey` — `never` for a stage whose
|
|
153
|
+
* fluent middlewares return nothing. A list that isn't a tuple, whose order
|
|
154
|
+
* is unknown, leaves `Ctx` as it is. An `any` list — a stage of a
|
|
155
|
+
* `Vigor*Schema<any>`, as in the schemas' own constraints — gives `any`, so
|
|
156
|
+
* any registered middleware satisfies them.
|
|
157
|
+
*/
|
|
158
|
+
type VigorContextStage<Ctx, List, FluentKey extends PropertyKey = never> = 0 extends (1 & List) ? any : List extends readonly [infer Head, ...infer Tail] ? VigorContextStage<VigorContextStep<Ctx, Head, FluentKey>, Tail, FluentKey> : Ctx;
|
|
117
159
|
|
|
118
160
|
/**
|
|
119
161
|
* Base class for Vigor's immutable, chainable builder objects.
|
|
@@ -271,9 +313,7 @@ type VigorParsePolicyMiddlewaresFluent<T extends VigorParseSchema<T>> = {
|
|
|
271
313
|
};
|
|
272
314
|
onResult: {
|
|
273
315
|
_mode: "fluent";
|
|
274
|
-
func: (res: VigorParseOnResultContextSchema<T>
|
|
275
|
-
result: infer R;
|
|
276
|
-
} ? R : never) => VigorParseContextSchema<any>["result"] | Promise<VigorParseContextSchema<any>["result"]>;
|
|
316
|
+
func: (res: VigorParseOnResultContextSchema<T>["result"]) => VigorParseContextSchema<any>["result"] | Promise<VigorParseContextSchema<any>["result"]>;
|
|
277
317
|
};
|
|
278
318
|
onError: {
|
|
279
319
|
_mode: "fluent";
|
|
@@ -302,7 +342,7 @@ type VigorParsePolicyMiddlewaresIntercept<T extends VigorParseSchema<T>> = {
|
|
|
302
342
|
};
|
|
303
343
|
onError: {
|
|
304
344
|
_mode: "intercept";
|
|
305
|
-
func: (ctx:
|
|
345
|
+
func: (ctx: VigorParseOnErrorContextSchema<T>, api: Pick<VigorParsePolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorParseContextSchema<any> | Promise<VigorParseContextSchema<any>>;
|
|
306
346
|
};
|
|
307
347
|
};
|
|
308
348
|
/**
|
|
@@ -399,28 +439,10 @@ declare class VigorParsePolicyMiddlewares<T extends VigorParseSchema<T> = typeof
|
|
|
399
439
|
};
|
|
400
440
|
}>>;
|
|
401
441
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
type
|
|
406
|
-
_mode: "intercept";
|
|
407
|
-
func: (...args: any[]) => infer Ret;
|
|
408
|
-
} ? VigorParsePipeStepVoid<Ret, Tail> : VigorParsePipeStepVoid<Ctx, Tail> : Ctx;
|
|
409
|
-
type VigorParsePipeStepResult<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
|
|
410
|
-
_mode: "intercept";
|
|
411
|
-
func: (...args: any[]) => infer Ret;
|
|
412
|
-
} ? VigorParsePipeStepResult<Ret, Tail> : Head extends {
|
|
413
|
-
_mode: "fluent";
|
|
414
|
-
func: (...args: any[]) => infer FR;
|
|
415
|
-
} ? VigorParsePipeStepResult<VigorDeepMerge<Ctx, {
|
|
416
|
-
result: FR;
|
|
417
|
-
}, {
|
|
418
|
-
result: "replace";
|
|
419
|
-
}>, Tail> : VigorParsePipeStepResult<Ctx, Tail> : Ctx;
|
|
420
|
-
type VigorParsePolicyMiddlewaresPipe<T extends VigorParseSchema<T>> = VigorParsePipeStepVoid<VigorParsePipeStepResult<VigorParsePipeStepResult<VigorParsePipeStepVoid<VigorParsePipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>, T["policy"]["middlewares"]["onResult"]>, T["policy"]["middlewares"]["onError"]>;
|
|
421
|
-
type VigorParsePipeResult<T extends VigorParseSchema<T>> = VigorParsePolicyMiddlewaresPipe<T> extends {
|
|
422
|
-
result: infer R;
|
|
423
|
-
} ? R : never;
|
|
442
|
+
/** The result the success pipeline produces: the parsed one (or `.cast<T>()`'s), through `after` and `onResult`. */
|
|
443
|
+
type VigorParsePipeResult<T extends VigorParseSchema<T>> = VigorParseOnResultContextSchema<T>["result"];
|
|
444
|
+
/** `ctx.result` once the `onError` middlewares ran — what a recovered run (`setResult`) resolves to, as far as types go. */
|
|
445
|
+
type VigorParseErrorPipeResult<T extends VigorParseSchema<T>> = VigorParseOnErrorContextSchema<T>["result"];
|
|
424
446
|
|
|
425
447
|
/**
|
|
426
448
|
* One recorded timeline entry: which `action` happened, its `content`, `now`,
|
|
@@ -611,16 +633,24 @@ type VigorParseContextSchema<T extends VigorParseSchema<T>, R = VigorParsePipeRe
|
|
|
611
633
|
timeline: VigorParseTimeline;
|
|
612
634
|
policy: T["policy"];
|
|
613
635
|
};
|
|
614
|
-
/**
|
|
615
|
-
type
|
|
616
|
-
/**
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
636
|
+
/** The result before any middleware: a `raw` parse's target, else `.cast<T>()`'s (`unknown` without one). */
|
|
637
|
+
type VigorParseNaturalResult<T extends VigorParseSchema<T>> = T["policy"]["settings"]["raw"] extends true ? VigorExcludeDefault<T["policy"]["target"]> : VigorCastResult<T["cast"], unknown>;
|
|
638
|
+
/**
|
|
639
|
+
* Context seen by `before` middlewares — parsing hasn't run yet.
|
|
640
|
+
*
|
|
641
|
+
* Each stage's context is defined on its own — the runtime's view at that
|
|
642
|
+
* point — with whatever the stage's earlier intercept middlewares changed by
|
|
643
|
+
* returning a different context (see `VigorContextStage`).
|
|
644
|
+
*/
|
|
645
|
+
type VigorParseBeforeContextSchema<T extends VigorParseSchema<T>> = VigorContextStage<VigorParseContextSchema<T, VigorDefaultType>, T["policy"]["middlewares"]["before"]>;
|
|
646
|
+
/** Context seen by `after` middlewares — `result` is the parsed one; what `before` changed otherwise carries over. */
|
|
647
|
+
type VigorParseAfterContextSchema<T extends VigorParseSchema<T>> = VigorContextStage<VigorContextReset<VigorParseBeforeContextSchema<T>, {
|
|
648
|
+
result: VigorParseNaturalResult<T>;
|
|
621
649
|
}>, T["policy"]["middlewares"]["after"]>;
|
|
622
|
-
/** Context
|
|
623
|
-
type VigorParseOnResultContextSchema<T extends VigorParseSchema<T>> =
|
|
650
|
+
/** Context seen by `onResult` middlewares — `ctx.result` is what the earlier `onResult` ones left it as. */
|
|
651
|
+
type VigorParseOnResultContextSchema<T extends VigorParseSchema<T>> = VigorContextStage<VigorParseAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"], "result">;
|
|
652
|
+
/** Context seen by `onError` middlewares — every strategy failed (or a middleware threw). */
|
|
653
|
+
type VigorParseOnErrorContextSchema<T extends VigorParseSchema<T>> = VigorContextStage<VigorParseContextSchema<T>, T["policy"]["middlewares"]["onError"]>;
|
|
624
654
|
/** Context shape once the full middleware pipeline (including `onResult`) has run. */
|
|
625
655
|
type VigorParseResultContextSchema<T extends VigorParseSchema<T>> = VigorParseContextSchema<T, VigorParsePipeResult<T>>;
|
|
626
656
|
declare const VigorParseContextBase: {
|
|
@@ -728,6 +758,17 @@ declare abstract class VigorError<C extends string, D, T = unknown> extends Erro
|
|
|
728
758
|
*/
|
|
729
759
|
constructor(code: C, message: string, options: VigorErrorOptions<D, T>);
|
|
730
760
|
}
|
|
761
|
+
/**
|
|
762
|
+
* Finds the first error in `error`'s chain that `match` accepts, from the
|
|
763
|
+
* outside in: the error itself, then the error it wraps (`data.error` of
|
|
764
|
+
* `RETRY_EXHAUSTED` / `RESTART_EXHAUSTED`), then its `cause`. Each wrapped
|
|
765
|
+
* error is searched fully before moving on. Cycles are skipped.
|
|
766
|
+
*
|
|
767
|
+
* This is what the `find` of each `vigor.guards.*` uses, so a caller can ask
|
|
768
|
+
* for the error that actually happened (e.g. `FETCH_FAILED`) without
|
|
769
|
+
* unwrapping the retry layers by hand.
|
|
770
|
+
*/
|
|
771
|
+
declare function findInVigorErrorChain(error: unknown, match: (error: unknown) => boolean): unknown;
|
|
731
772
|
|
|
732
773
|
declare const VigorParseErrorMessageFuncs: {
|
|
733
774
|
readonly VALUE_REQUIRED: ({ key }: {
|
|
@@ -813,6 +854,20 @@ type VigorParseErrorsIn<E, C extends VigorParseErrorCodes = VigorParseErrorCodes
|
|
|
813
854
|
*/
|
|
814
855
|
declare function isVigorParseError<E>(error: E): error is E & VigorParseErrorsIn<E>;
|
|
815
856
|
declare function isVigorParseError<E, const C extends VigorParseErrorCodes>(error: E, ...codes: [C, ...C[]]): error is E & VigorParseErrorsIn<E, C>;
|
|
857
|
+
/**
|
|
858
|
+
* Like `isVigorParseError(error, ...codes)`, but also looks inside the errors
|
|
859
|
+
* `error` wraps — `data.error` of `RETRY_EXHAUSTED` / `RESTART_EXHAUSTED`,
|
|
860
|
+
* then `cause` — and returns the first match, outermost first. Returns
|
|
861
|
+
* `null` when there is none. `error` itself is left as it is.
|
|
862
|
+
*
|
|
863
|
+
* A guard can't do this: it narrows the value you pass, so a `true` for a
|
|
864
|
+
* wrapped match would claim the wrapper has the inner error's `data`.
|
|
865
|
+
*
|
|
866
|
+
* @example
|
|
867
|
+
* const notFound = findVigorParseError(error, "PARSER_NOT_FOUND")
|
|
868
|
+
* if (notFound) notFound.data.expected
|
|
869
|
+
*/
|
|
870
|
+
declare function findVigorParseError<E, const C extends VigorParseErrorCodes>(error: E, ...codes: [C, ...C[]]): VigorParseErrorsIn<E, C> | null;
|
|
816
871
|
|
|
817
872
|
type VigorParsePolicySchema<T extends VigorParseSchema<T>> = {
|
|
818
873
|
__brand: VigorBrand<"Parse", "Policy<Schema">;
|
|
@@ -855,7 +910,7 @@ type VigorParseSchema<T extends VigorParseSchema<T>> = {
|
|
|
855
910
|
cast: unknown;
|
|
856
911
|
};
|
|
857
912
|
/** What `request()` resolves to: the pipeline's result, or what `settings.default` returns. */
|
|
858
|
-
type VigorParseResult<T extends VigorParseSchema<T>> = VigorExcludeDefault<VigorParseContextSchema<T>["result"]> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
913
|
+
type VigorParseResult<T extends VigorParseSchema<T>> = VigorExcludeDefault<VigorParseContextSchema<T>["result"]> | VigorExcludeDefault<VigorParseErrorPipeResult<T>> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
859
914
|
/** The builder `T` becomes after merging `P` in (with strategy tree `S`). */
|
|
860
915
|
type VigorParseNext<T, P, S = undefined> = VigorApply<VigorParseTypeLambda, VigorDeepMerge<T, P, S>>;
|
|
861
916
|
declare const VigorParseBase: {
|
|
@@ -1226,9 +1281,7 @@ type VigorRetryPolicyMiddlewaresFluent<T extends VigorRetrySchema<T>> = {
|
|
|
1226
1281
|
};
|
|
1227
1282
|
onResult: {
|
|
1228
1283
|
_mode: "fluent";
|
|
1229
|
-
func: (res: VigorRetryOnResultContextSchema<T>
|
|
1230
|
-
result: infer R;
|
|
1231
|
-
} ? R : never) => VigorRetryContextSchema<any>["result"] | Promise<VigorRetryContextSchema<any>["result"]>;
|
|
1284
|
+
func: (res: VigorRetryOnResultContextSchema<T>["result"]) => VigorRetryContextSchema<any>["result"] | Promise<VigorRetryContextSchema<any>["result"]>;
|
|
1232
1285
|
};
|
|
1233
1286
|
retryIf: {
|
|
1234
1287
|
_mode: "fluent";
|
|
@@ -1270,15 +1323,15 @@ type VigorRetryPolicyMiddlewaresIntercept<T extends VigorRetrySchema<T>> = {
|
|
|
1270
1323
|
};
|
|
1271
1324
|
retryIf: {
|
|
1272
1325
|
_mode: "intercept";
|
|
1273
|
-
func: (ctx:
|
|
1326
|
+
func: (ctx: VigorRetryRetryIfContextSchema<T>, api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "proceedRetry" | "cancelRetry">) => VigorRetryContextSchema<any> | Promise<VigorRetryContextSchema<any>>;
|
|
1274
1327
|
};
|
|
1275
1328
|
onRetry: {
|
|
1276
1329
|
_mode: "intercept";
|
|
1277
|
-
func: (ctx:
|
|
1330
|
+
func: (ctx: VigorRetryOnRetryContextSchema<T>, api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "throwError" | "setDelay">) => VigorRetryContextSchema<any> | Promise<VigorRetryContextSchema<any>>;
|
|
1278
1331
|
};
|
|
1279
1332
|
onError: {
|
|
1280
1333
|
_mode: "intercept";
|
|
1281
|
-
func: (ctx:
|
|
1334
|
+
func: (ctx: VigorRetryOnErrorContextSchema<T>, api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorRetryContextSchema<any> | Promise<VigorRetryContextSchema<any>>;
|
|
1282
1335
|
};
|
|
1283
1336
|
};
|
|
1284
1337
|
/**
|
|
@@ -1418,43 +1471,10 @@ declare class VigorRetryPolicyMiddlewares<T extends VigorRetrySchema<T> = typeof
|
|
|
1418
1471
|
};
|
|
1419
1472
|
}>>;
|
|
1420
1473
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
type
|
|
1425
|
-
_mode: "intercept";
|
|
1426
|
-
func: (...args: any[]) => infer Ret;
|
|
1427
|
-
} ? VigorRetryPipeStepVoid<Ret, Tail> : VigorRetryPipeStepVoid<Ctx, Tail> : Ctx;
|
|
1428
|
-
type VigorRetryPipeStepResult<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
|
|
1429
|
-
_mode: "intercept";
|
|
1430
|
-
func: (...args: any[]) => infer Ret;
|
|
1431
|
-
} ? VigorRetryPipeStepResult<Ret, Tail> : Head extends {
|
|
1432
|
-
_mode: "fluent";
|
|
1433
|
-
func: (...args: any[]) => infer FR;
|
|
1434
|
-
} ? VigorRetryPipeStepResult<VigorDeepMerge<Ctx, {
|
|
1435
|
-
result: FR;
|
|
1436
|
-
}, {
|
|
1437
|
-
result: "replace";
|
|
1438
|
-
}>, Tail> : VigorRetryPipeStepResult<Ctx, Tail> : Ctx;
|
|
1439
|
-
type VigorRetryPipeStepRetryIf<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
|
|
1440
|
-
_mode: "intercept";
|
|
1441
|
-
func: (...args: any[]) => infer Ret;
|
|
1442
|
-
} ? VigorRetryPipeStepRetryIf<Ret, Tail> : Head extends {
|
|
1443
|
-
_mode: "fluent";
|
|
1444
|
-
func: (...args: any[]) => infer FR;
|
|
1445
|
-
} ? VigorRetryPipeStepRetryIf<VigorDeepMerge<Ctx, {
|
|
1446
|
-
flags: {
|
|
1447
|
-
doRetry: FR;
|
|
1448
|
-
};
|
|
1449
|
-
}, {
|
|
1450
|
-
flags: {
|
|
1451
|
-
doRetry: "replace";
|
|
1452
|
-
};
|
|
1453
|
-
}>, Tail> : VigorRetryPipeStepRetryIf<Ctx, Tail> : Ctx;
|
|
1454
|
-
type VigorRetryPolicyMiddlewaresPipe<T extends VigorRetrySchema<T>> = VigorRetryPipeStepVoid<VigorRetryPipeStepVoid<VigorRetryPipeStepRetryIf<VigorRetryPipeStepResult<VigorRetryPipeStepVoid<VigorRetryPipeStepVoid<VigorRetryPipeInitialContext<T>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>, T["policy"]["middlewares"]["onResult"]>, T["policy"]["middlewares"]["retryIf"]>, T["policy"]["middlewares"]["onRetry"]>, T["policy"]["middlewares"]["onError"]>;
|
|
1455
|
-
type VigorRetryPipeResult<T extends VigorRetrySchema<T>> = VigorRetryPolicyMiddlewaresPipe<T> extends {
|
|
1456
|
-
result: infer R;
|
|
1457
|
-
} ? R : never;
|
|
1474
|
+
/** The result the success pipeline produces: the target's (or `.cast<T>()`'s), through `after` and `onResult`. */
|
|
1475
|
+
type VigorRetryPipeResult<T extends VigorRetrySchema<T>> = VigorRetryOnResultContextSchema<T>["result"];
|
|
1476
|
+
/** `ctx.result` once the `onError` middlewares ran — what a recovered run (`setResult`) resolves to, as far as types go. */
|
|
1477
|
+
type VigorRetryErrorPipeResult<T extends VigorRetrySchema<T>> = VigorRetryOnErrorContextSchema<T>["result"];
|
|
1458
1478
|
|
|
1459
1479
|
type VigorRetryTimelineStages = Omit<VigorRetryPolicyMiddlewaresSchema<any>, "__brand">;
|
|
1460
1480
|
type VigorRetryTimelineApis = {
|
|
@@ -1555,16 +1575,29 @@ type VigorRetryContextSchema<T extends VigorRetrySchema<T>, R = VigorRetryPipeRe
|
|
|
1555
1575
|
timeline: VigorRetryTimeline;
|
|
1556
1576
|
policy: T["policy"];
|
|
1557
1577
|
};
|
|
1558
|
-
/**
|
|
1559
|
-
type
|
|
1560
|
-
/**
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1578
|
+
/** The result before any middleware: `.cast<T>()`'s, else the target's return type. */
|
|
1579
|
+
type VigorRetryNaturalResult<T extends VigorRetrySchema<T>> = VigorCastResult<T["cast"], VigorReturnType<T["policy"]["target"]>>;
|
|
1580
|
+
/**
|
|
1581
|
+
* Context seen by `before` middlewares — the target hasn't run yet, so
|
|
1582
|
+
* there's no result.
|
|
1583
|
+
*
|
|
1584
|
+
* Each stage's context is defined on its own — the runtime's view at that
|
|
1585
|
+
* point — with whatever the stage's earlier intercept middlewares changed by
|
|
1586
|
+
* returning a different context (see `VigorContextStage`).
|
|
1587
|
+
*/
|
|
1588
|
+
type VigorRetryBeforeContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorRetryContextSchema<T, VigorDefaultType>, T["policy"]["middlewares"]["before"]>;
|
|
1589
|
+
/** Context seen by `after` middlewares — `result` is the target's; what `before` changed otherwise carries over. */
|
|
1590
|
+
type VigorRetryAfterContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorContextReset<VigorRetryBeforeContextSchema<T>, {
|
|
1591
|
+
result: VigorRetryNaturalResult<T>;
|
|
1565
1592
|
}>, T["policy"]["middlewares"]["after"]>;
|
|
1566
|
-
/** Context
|
|
1567
|
-
type VigorRetryOnResultContextSchema<T extends VigorRetrySchema<T>> =
|
|
1593
|
+
/** Context seen by `onResult` middlewares — `ctx.result` is what the earlier `onResult` ones left it as. */
|
|
1594
|
+
type VigorRetryOnResultContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorRetryAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"], "result">;
|
|
1595
|
+
/** Context seen by `retryIf` middlewares — an attempt failed. */
|
|
1596
|
+
type VigorRetryRetryIfContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorRetryContextSchema<T>, T["policy"]["middlewares"]["retryIf"]>;
|
|
1597
|
+
/** Context seen by `onRetry` middlewares — `retryIf` decided to retry. */
|
|
1598
|
+
type VigorRetryOnRetryContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorRetryRetryIfContextSchema<T>, T["policy"]["middlewares"]["onRetry"]>;
|
|
1599
|
+
/** Context seen by `onError` middlewares — the run failed. */
|
|
1600
|
+
type VigorRetryOnErrorContextSchema<T extends VigorRetrySchema<T>> = VigorContextStage<VigorRetryContextSchema<T>, T["policy"]["middlewares"]["onError"]>;
|
|
1568
1601
|
/** Context shape once the full middleware pipeline (including `onResult`) has run. */
|
|
1569
1602
|
type VigorRetryResultContextSchema<T extends VigorRetrySchema<T>> = VigorRetryContextSchema<T, VigorRetryPipeResult<T>>;
|
|
1570
1603
|
declare const VigorRetryContextBase: {
|
|
@@ -1706,6 +1739,20 @@ type VigorRetryErrorsIn<E, C extends VigorRetryErrorCodes = VigorRetryErrorCodes
|
|
|
1706
1739
|
*/
|
|
1707
1740
|
declare function isVigorRetryError<E>(error: E): error is E & VigorRetryErrorsIn<E>;
|
|
1708
1741
|
declare function isVigorRetryError<E, const C extends VigorRetryErrorCodes>(error: E, ...codes: [C, ...C[]]): error is E & VigorRetryErrorsIn<E, C>;
|
|
1742
|
+
/**
|
|
1743
|
+
* Like `isVigorRetryError(error, ...codes)`, but also looks inside the errors
|
|
1744
|
+
* `error` wraps — `data.error` of `RETRY_EXHAUSTED` / `RESTART_EXHAUSTED`,
|
|
1745
|
+
* then `cause` — and returns the first match, outermost first. Returns
|
|
1746
|
+
* `null` when there is none. `error` itself is left as it is.
|
|
1747
|
+
*
|
|
1748
|
+
* A guard can't do this: it narrows the value you pass, so a `true` for a
|
|
1749
|
+
* wrapped match would claim the wrapper has the inner error's `data`.
|
|
1750
|
+
*
|
|
1751
|
+
* @example
|
|
1752
|
+
* const timedOut = findVigorRetryError(error, "TIMED_OUT")
|
|
1753
|
+
* if (timedOut) timedOut.data.limit
|
|
1754
|
+
*/
|
|
1755
|
+
declare function findVigorRetryError<E, const C extends VigorRetryErrorCodes>(error: E, ...codes: [C, ...C[]]): VigorRetryErrorsIn<E, C> | null;
|
|
1709
1756
|
|
|
1710
1757
|
type VigorRetryPolicySchema<T extends VigorRetrySchema<T>> = {
|
|
1711
1758
|
__brand: VigorBrand<"Retry", "Policy<Schema">;
|
|
@@ -1756,7 +1803,7 @@ type VigorRetrySchema<T extends VigorRetrySchema<T>> = {
|
|
|
1756
1803
|
cast: unknown;
|
|
1757
1804
|
};
|
|
1758
1805
|
/** What `request()` resolves to: the pipeline's result, or what `settings.default` returns. */
|
|
1759
|
-
type VigorRetryResult<T extends VigorRetrySchema<T>> = VigorExcludeDefault<VigorRetryContextSchema<T>["result"]> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
1806
|
+
type VigorRetryResult<T extends VigorRetrySchema<T>> = VigorExcludeDefault<VigorRetryContextSchema<T>["result"]> | VigorExcludeDefault<VigorRetryErrorPipeResult<T>> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
1760
1807
|
/** The builder `T` becomes after merging `P` in (with strategy tree `S`). */
|
|
1761
1808
|
type VigorRetryNext<T, P, S = undefined> = VigorApply<VigorRetryTypeLambda, VigorDeepMerge<T, P, S>>;
|
|
1762
1809
|
declare const VigorRetryBase: {
|
|
@@ -2237,160 +2284,6 @@ interface VigorAllPolicyMiddlewaresTypeLambda extends VigorTypeLambda {
|
|
|
2237
2284
|
readonly Target: VigorAllPolicyMiddlewares<VigorAllIn<this["In"]>>;
|
|
2238
2285
|
}
|
|
2239
2286
|
|
|
2240
|
-
declare const VigorAllErrorMessageFuncs: {
|
|
2241
|
-
readonly EMPTY_TARGET: (_: {}) => string;
|
|
2242
|
-
readonly TIMED_OUT: ({ limit, index }: {
|
|
2243
|
-
limit: number;
|
|
2244
|
-
index: number;
|
|
2245
|
-
}) => string;
|
|
2246
|
-
};
|
|
2247
|
-
type VigorAllErrorCodes = keyof typeof VigorAllErrorMessageFuncs;
|
|
2248
|
-
type VigorAllErrorDatas<C extends VigorAllErrorCodes> = Parameters<typeof VigorAllErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
|
|
2249
|
-
/**
|
|
2250
|
-
* Every all error code as its own union member, so narrowing by `code`
|
|
2251
|
-
* also narrows `data` to that code's payload.
|
|
2252
|
-
*/
|
|
2253
|
-
type VigorAllErrors<T extends VigorAllSchema<any> = VigorAllSchema<any>> = {
|
|
2254
|
-
[C in VigorAllErrorCodes]: VigorAllError<C, T>;
|
|
2255
|
-
}[VigorAllErrorCodes];
|
|
2256
|
-
/**
|
|
2257
|
-
* `error` of a failed `requestVerbose()` — this module's errors, or anything else that was thrown (e.g. a task's error under `failFast`).
|
|
2258
|
-
*
|
|
2259
|
-
* Typed with the request's own schema `T`, so `context` (and anything else
|
|
2260
|
-
* that depends on the config) is that request's, not a generic one.
|
|
2261
|
-
*/
|
|
2262
|
-
type VigorAllRequestError<T extends VigorAllSchema<any> = any> = VigorResultError<VigorAllErrors<T>>;
|
|
2263
|
-
/** Codes that may be raised without a run context. */
|
|
2264
|
-
type VigorAllErrorCodesWithOptionalContext = never;
|
|
2265
|
-
/** Codes that are never raised with a run context. */
|
|
2266
|
-
type VigorAllErrorCodesWithoutContext = "TIMED_OUT";
|
|
2267
|
-
/**
|
|
2268
|
-
* The `context` of a `VigorAllError` with code `C`: the run context when
|
|
2269
|
-
* the code always has one, `| undefined` when it may not, `undefined` when
|
|
2270
|
-
* it never does. `TIMED_OUT` is raised for a single task (`data.index` says which), not with the batch context.
|
|
2271
|
-
*/
|
|
2272
|
-
type VigorAllErrorContext<C extends VigorAllErrorCodes, T extends VigorAllSchema<any> = any> = VigorErrorContext<C, VigorAllContextSchema<T>, VigorAllErrorCodesWithOptionalContext, VigorAllErrorCodesWithoutContext>;
|
|
2273
|
-
/** Error type thrown by the all module. */
|
|
2274
|
-
declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSchema<T>> extends VigorError<C, VigorAllErrorDatas<C>, VigorAllErrorContext<C, T>> {
|
|
2275
|
-
/**
|
|
2276
|
-
* @param code - One of the all module's error codes.
|
|
2277
|
-
* @param options - Error metadata, including the `data` payload for `code`.
|
|
2278
|
-
*/
|
|
2279
|
-
constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, VigorAllErrorContext<C, T>>);
|
|
2280
|
-
}
|
|
2281
|
-
/**
|
|
2282
|
-
* What `isVigorAllError` narrows `E` to: the typed `VigorAllError` members
|
|
2283
|
-
* already in `E` (so a `requestVerbose()` error keeps its request's
|
|
2284
|
-
* `context` type), limited to codes `C`. For an `unknown` input (a `catch`
|
|
2285
|
-
* binding, a `request()` rejection) there's no request to take types from,
|
|
2286
|
-
* so it's the generic `VigorAllErrors<any>`.
|
|
2287
|
-
*/
|
|
2288
|
-
type VigorAllErrorsIn<E, C extends VigorAllErrorCodes = VigorAllErrorCodes> = [
|
|
2289
|
-
Extract<E, VigorAllError<any, any>>
|
|
2290
|
-
] extends [never] ? Extract<VigorAllErrors<any>, {
|
|
2291
|
-
code: C;
|
|
2292
|
-
}> : Extract<Extract<E, VigorAllError<any, any>>, {
|
|
2293
|
-
code: C;
|
|
2294
|
-
}>;
|
|
2295
|
-
/**
|
|
2296
|
-
* Narrows an error from a failed result envelope to the all module's typed
|
|
2297
|
-
* error union. Prefer this over a bare `instanceof`: the envelope's `{}`
|
|
2298
|
-
* member makes `instanceof` widen `data` back to every code's payload,
|
|
2299
|
-
* while this guard keeps `code` and `data` in sync.
|
|
2300
|
-
*
|
|
2301
|
-
* Pass one or more `codes` to also check the code: the error is then
|
|
2302
|
-
* narrowed to just those codes, so `data` is that code's payload right away.
|
|
2303
|
-
*
|
|
2304
|
-
* @example
|
|
2305
|
-
* if (isVigorAllError(error, "TIMED_OUT")) {
|
|
2306
|
-
* error.data // that code's payload
|
|
2307
|
-
* }
|
|
2308
|
-
*/
|
|
2309
|
-
declare function isVigorAllError<E>(error: E): error is E & VigorAllErrorsIn<E>;
|
|
2310
|
-
declare function isVigorAllError<E, const C extends VigorAllErrorCodes>(error: E, ...codes: [C, ...C[]]): error is E & VigorAllErrorsIn<E, C>;
|
|
2311
|
-
|
|
2312
|
-
/**
|
|
2313
|
-
* A single task. It receives an `AbortSignal` that fires when the task's
|
|
2314
|
-
* `timeout` elapses, the batch's `abortSignals` abort, or `failFast` stops
|
|
2315
|
-
* the batch — tasks that ignore it keep running in the background, but
|
|
2316
|
-
* their result is discarded.
|
|
2317
|
-
*/
|
|
2318
|
-
type VigorAllTask = (signal: AbortSignal) => unknown | Promise<unknown>;
|
|
2319
|
-
/** Extracts (and unwraps `Promise`/`Awaited`) the result type of a single task. */
|
|
2320
|
-
type VigorAllTaskResult<F> = F extends (...args: any[]) => infer R ? Awaited<R> : never;
|
|
2321
|
-
/**
|
|
2322
|
-
* Maps a tuple of tasks to a tuple of their (awaited) result types, in the
|
|
2323
|
-
* same order and length as `N`. If `N` isn't a literal tuple (e.g. the
|
|
2324
|
-
* default, unconfigured `target`), this degrades to a plain array type.
|
|
2325
|
-
*/
|
|
2326
|
-
type VigorAllTasksTuple<N extends readonly VigorAllTask[]> = {
|
|
2327
|
-
[K in keyof N]: VigorAllTaskResult<N[K]>;
|
|
2328
|
-
};
|
|
2329
|
-
type VigorAllPolicySchema<T extends VigorAllSchema<T>> = {
|
|
2330
|
-
__brand: VigorBrand<"All", "Policy<Schema">;
|
|
2331
|
-
target: VigorAllTask[];
|
|
2332
|
-
abortSignals: AbortSignal[];
|
|
2333
|
-
settings: VigorAllPolicySettingsSchema<T>;
|
|
2334
|
-
middlewares: VigorAllPolicyMiddlewaresSchema<T>;
|
|
2335
|
-
};
|
|
2336
|
-
declare const VigorAllPolicyBase: {
|
|
2337
|
-
readonly __brand: VigorBrand<"All", "Policy<Schema">;
|
|
2338
|
-
readonly target: [];
|
|
2339
|
-
readonly abortSignals: [];
|
|
2340
|
-
readonly settings: {
|
|
2341
|
-
readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
|
|
2342
|
-
readonly debug: false;
|
|
2343
|
-
readonly concurrency: 5;
|
|
2344
|
-
readonly onlySuccess: false;
|
|
2345
|
-
readonly timeout: symbol & {
|
|
2346
|
-
__brand: VigorBrand<"Core", "Symbol_Empty">;
|
|
2347
|
-
};
|
|
2348
|
-
readonly failFast: false;
|
|
2349
|
-
};
|
|
2350
|
-
readonly middlewares: {
|
|
2351
|
-
readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
|
|
2352
|
-
readonly before: [];
|
|
2353
|
-
readonly after: [];
|
|
2354
|
-
readonly onResult: [];
|
|
2355
|
-
readonly beforeEach: [];
|
|
2356
|
-
readonly afterEach: [];
|
|
2357
|
-
readonly onErrorEach: [];
|
|
2358
|
-
};
|
|
2359
|
-
};
|
|
2360
|
-
/**
|
|
2361
|
-
* What a failed task's slot holds as `error`: whatever the task threw, or
|
|
2362
|
-
* `VigorAllError("TIMED_OUT")` when it hit `settings.timeout`.
|
|
2363
|
-
*/
|
|
2364
|
-
type VigorAllTaskError = VigorResultError<VigorAllError<"TIMED_OUT", any>>;
|
|
2365
|
-
/**
|
|
2366
|
-
* One task's outcome, shaped like `requestVerbose()`'s envelope: what it
|
|
2367
|
-
* returned (or what `onErrorEach` recovered it with), or what it failed with.
|
|
2368
|
-
*/
|
|
2369
|
-
type VigorAllSettled<V> = {
|
|
2370
|
-
success: true;
|
|
2371
|
-
data: V;
|
|
2372
|
-
error: null;
|
|
2373
|
-
} | {
|
|
2374
|
-
success: false;
|
|
2375
|
-
data: null;
|
|
2376
|
-
error: VigorAllTaskError;
|
|
2377
|
-
};
|
|
2378
|
-
/**
|
|
2379
|
-
* The naturally-inferred (pre-`.cast<T>()`) result type of `.request()`.
|
|
2380
|
-
* When `onlySuccess` is left `false` (the default), every task gets its own
|
|
2381
|
-
* tuple slot holding its outcome — `.target(() => 1 as const, () => "a")`
|
|
2382
|
-
* infers `[VigorAllSettled<1>, VigorAllSettled<"a">]` — so a failed task
|
|
2383
|
-
* can't pass for a result. `onlySuccess: true` keeps only the successful
|
|
2384
|
-
* tasks' values, at runtime an arbitrary length, so it becomes an array of
|
|
2385
|
-
* the tasks' result types (`(1 | "a")[]`). A non-literal `boolean` could be
|
|
2386
|
-
* either, so it gives the union of both.
|
|
2387
|
-
*/
|
|
2388
|
-
type VigorAllNaturalResult<T extends VigorAllSchema<T>> = T["policy"]["target"] extends readonly VigorAllTask[] ? VigorAllResultFor<T["policy"]["settings"]["onlySuccess"], VigorAllTasksTuple<T["policy"]["target"]>> : unknown[];
|
|
2389
|
-
/** Distributes over `boolean`, so a non-literal `onlySuccess` yields both shapes. */
|
|
2390
|
-
type VigorAllResultFor<OnlySuccess, Tuple extends readonly unknown[]> = OnlySuccess extends true ? Tuple[number][] : {
|
|
2391
|
-
[K in keyof Tuple]: VigorAllSettled<Tuple[K]>;
|
|
2392
|
-
};
|
|
2393
|
-
|
|
2394
2287
|
/** Per-task hook (`beforeEach` / `afterEach`) — observes/mutates a single task's context, no return value. */
|
|
2395
2288
|
type VigorAllEachMiddlewareFn = (ctx: VigorAllEachContextSchema<any>) => void | Promise<void>;
|
|
2396
2289
|
/** Per-task failure hook (`onErrorEach`) — can override the task's outcome via `api.setResult`. */
|
|
@@ -2433,9 +2326,7 @@ type VigorAllPolicyMiddlewaresFluent<T extends VigorAllSchema<T>> = {
|
|
|
2433
2326
|
};
|
|
2434
2327
|
onResult: {
|
|
2435
2328
|
_mode: "fluent";
|
|
2436
|
-
func: (res: VigorAllOnResultContextSchema<T>
|
|
2437
|
-
result: infer R;
|
|
2438
|
-
} ? R : never) => VigorAllContextSchema<any>["result"] | Promise<VigorAllContextSchema<any>["result"]>;
|
|
2329
|
+
func: (res: VigorAllOnResultContextSchema<T>["result"]) => VigorAllContextSchema<any>["result"] | Promise<VigorAllContextSchema<any>["result"]>;
|
|
2439
2330
|
};
|
|
2440
2331
|
};
|
|
2441
2332
|
type VigorAllPolicyMiddlewaresApi<T extends VigorAllSchema<T>> = {
|
|
@@ -2558,28 +2449,176 @@ declare class VigorAllPolicyMiddlewares<T extends VigorAllSchema<T> = typeof Vig
|
|
|
2558
2449
|
};
|
|
2559
2450
|
}>>;
|
|
2560
2451
|
}
|
|
2561
|
-
|
|
2562
|
-
|
|
2452
|
+
/** The result the batch-level pipeline produces: the tasks' outcomes (or `.cast<T>()`'s), through `after` and `onResult`. */
|
|
2453
|
+
type VigorAllPipeResult<T extends VigorAllSchema<T>> = VigorAllOnResultContextSchema<T>["result"];
|
|
2454
|
+
|
|
2455
|
+
declare const VigorAllErrorMessageFuncs: {
|
|
2456
|
+
readonly EMPTY_TARGET: (_: {}) => string;
|
|
2457
|
+
readonly TIMED_OUT: ({ limit, index }: {
|
|
2458
|
+
limit: number;
|
|
2459
|
+
index: number;
|
|
2460
|
+
}) => string;
|
|
2461
|
+
};
|
|
2462
|
+
type VigorAllErrorCodes = keyof typeof VigorAllErrorMessageFuncs;
|
|
2463
|
+
type VigorAllErrorDatas<C extends VigorAllErrorCodes> = Parameters<typeof VigorAllErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
|
|
2464
|
+
/**
|
|
2465
|
+
* Every all error code as its own union member, so narrowing by `code`
|
|
2466
|
+
* also narrows `data` to that code's payload.
|
|
2467
|
+
*/
|
|
2468
|
+
type VigorAllErrors<T extends VigorAllSchema<any> = VigorAllSchema<any>> = {
|
|
2469
|
+
[C in VigorAllErrorCodes]: VigorAllError<C, T>;
|
|
2470
|
+
}[VigorAllErrorCodes];
|
|
2471
|
+
/**
|
|
2472
|
+
* `error` of a failed `requestVerbose()` — this module's errors, or anything else that was thrown (e.g. a task's error under `failFast`).
|
|
2473
|
+
*
|
|
2474
|
+
* Typed with the request's own schema `T`, so `context` (and anything else
|
|
2475
|
+
* that depends on the config) is that request's, not a generic one.
|
|
2476
|
+
*/
|
|
2477
|
+
type VigorAllRequestError<T extends VigorAllSchema<any> = any> = VigorResultError<VigorAllErrors<T>>;
|
|
2478
|
+
/** Codes that may be raised without a run context. */
|
|
2479
|
+
type VigorAllErrorCodesWithOptionalContext = never;
|
|
2480
|
+
/** Codes that are never raised with a run context. */
|
|
2481
|
+
type VigorAllErrorCodesWithoutContext = "TIMED_OUT";
|
|
2482
|
+
/**
|
|
2483
|
+
* The `context` of a `VigorAllError` with code `C`: the run context when
|
|
2484
|
+
* the code always has one, `| undefined` when it may not, `undefined` when
|
|
2485
|
+
* it never does. `TIMED_OUT` is raised for a single task (`data.index` says which), not with the batch context.
|
|
2486
|
+
*/
|
|
2487
|
+
type VigorAllErrorContext<C extends VigorAllErrorCodes, T extends VigorAllSchema<any> = any> = VigorErrorContext<C, VigorAllContextSchema<T>, VigorAllErrorCodesWithOptionalContext, VigorAllErrorCodesWithoutContext>;
|
|
2488
|
+
/** Error type thrown by the all module. */
|
|
2489
|
+
declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSchema<T>> extends VigorError<C, VigorAllErrorDatas<C>, VigorAllErrorContext<C, T>> {
|
|
2490
|
+
/**
|
|
2491
|
+
* @param code - One of the all module's error codes.
|
|
2492
|
+
* @param options - Error metadata, including the `data` payload for `code`.
|
|
2493
|
+
*/
|
|
2494
|
+
constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, VigorAllErrorContext<C, T>>);
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* What `isVigorAllError` narrows `E` to: the typed `VigorAllError` members
|
|
2498
|
+
* already in `E` (so a `requestVerbose()` error keeps its request's
|
|
2499
|
+
* `context` type), limited to codes `C`. For an `unknown` input (a `catch`
|
|
2500
|
+
* binding, a `request()` rejection) there's no request to take types from,
|
|
2501
|
+
* so it's the generic `VigorAllErrors<any>`.
|
|
2502
|
+
*/
|
|
2503
|
+
type VigorAllErrorsIn<E, C extends VigorAllErrorCodes = VigorAllErrorCodes> = [
|
|
2504
|
+
Extract<E, VigorAllError<any, any>>
|
|
2505
|
+
] extends [never] ? Extract<VigorAllErrors<any>, {
|
|
2506
|
+
code: C;
|
|
2507
|
+
}> : Extract<Extract<E, VigorAllError<any, any>>, {
|
|
2508
|
+
code: C;
|
|
2563
2509
|
}>;
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2510
|
+
/**
|
|
2511
|
+
* Narrows an error from a failed result envelope to the all module's typed
|
|
2512
|
+
* error union. Prefer this over a bare `instanceof`: the envelope's `{}`
|
|
2513
|
+
* member makes `instanceof` widen `data` back to every code's payload,
|
|
2514
|
+
* while this guard keeps `code` and `data` in sync.
|
|
2515
|
+
*
|
|
2516
|
+
* Pass one or more `codes` to also check the code: the error is then
|
|
2517
|
+
* narrowed to just those codes, so `data` is that code's payload right away.
|
|
2518
|
+
*
|
|
2519
|
+
* @example
|
|
2520
|
+
* if (isVigorAllError(error, "TIMED_OUT")) {
|
|
2521
|
+
* error.data // that code's payload
|
|
2522
|
+
* }
|
|
2523
|
+
*/
|
|
2524
|
+
declare function isVigorAllError<E>(error: E): error is E & VigorAllErrorsIn<E>;
|
|
2525
|
+
declare function isVigorAllError<E, const C extends VigorAllErrorCodes>(error: E, ...codes: [C, ...C[]]): error is E & VigorAllErrorsIn<E, C>;
|
|
2526
|
+
/**
|
|
2527
|
+
* Like `isVigorAllError(error, ...codes)`, but also looks inside the errors
|
|
2528
|
+
* `error` wraps — `data.error` of `RETRY_EXHAUSTED` / `RESTART_EXHAUSTED`,
|
|
2529
|
+
* then `cause` — and returns the first match, outermost first. Returns
|
|
2530
|
+
* `null` when there is none. `error` itself is left as it is.
|
|
2531
|
+
*
|
|
2532
|
+
* A guard can't do this: it narrows the value you pass, so a `true` for a
|
|
2533
|
+
* wrapped match would claim the wrapper has the inner error's `data`.
|
|
2534
|
+
*
|
|
2535
|
+
* @example
|
|
2536
|
+
* const timedOut = findVigorAllError(error, "TIMED_OUT")
|
|
2537
|
+
* if (timedOut) timedOut.data.index
|
|
2538
|
+
*/
|
|
2539
|
+
declare function findVigorAllError<E, const C extends VigorAllErrorCodes>(error: E, ...codes: [C, ...C[]]): VigorAllErrorsIn<E, C> | null;
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* A single task. It receives an `AbortSignal` that fires when the task's
|
|
2543
|
+
* `timeout` elapses, the batch's `abortSignals` abort, or `failFast` stops
|
|
2544
|
+
* the batch — tasks that ignore it keep running in the background, but
|
|
2545
|
+
* their result is discarded.
|
|
2546
|
+
*/
|
|
2547
|
+
type VigorAllTask = (signal: AbortSignal) => unknown | Promise<unknown>;
|
|
2548
|
+
/** Extracts (and unwraps `Promise`/`Awaited`) the result type of a single task. */
|
|
2549
|
+
type VigorAllTaskResult<F> = F extends (...args: any[]) => infer R ? Awaited<R> : never;
|
|
2550
|
+
/**
|
|
2551
|
+
* Maps a tuple of tasks to a tuple of their (awaited) result types, in the
|
|
2552
|
+
* same order and length as `N`. If `N` isn't a literal tuple (e.g. the
|
|
2553
|
+
* default, unconfigured `target`), this degrades to a plain array type.
|
|
2554
|
+
*/
|
|
2555
|
+
type VigorAllTasksTuple<N extends readonly VigorAllTask[]> = {
|
|
2556
|
+
[K in keyof N]: VigorAllTaskResult<N[K]>;
|
|
2557
|
+
};
|
|
2558
|
+
type VigorAllPolicySchema<T extends VigorAllSchema<T>> = {
|
|
2559
|
+
__brand: VigorBrand<"All", "Policy<Schema">;
|
|
2560
|
+
target: VigorAllTask[];
|
|
2561
|
+
abortSignals: AbortSignal[];
|
|
2562
|
+
settings: VigorAllPolicySettingsSchema<T>;
|
|
2563
|
+
middlewares: VigorAllPolicyMiddlewaresSchema<T>;
|
|
2564
|
+
};
|
|
2565
|
+
declare const VigorAllPolicyBase: {
|
|
2566
|
+
readonly __brand: VigorBrand<"All", "Policy<Schema">;
|
|
2567
|
+
readonly target: [];
|
|
2568
|
+
readonly abortSignals: [];
|
|
2569
|
+
readonly settings: {
|
|
2570
|
+
readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
|
|
2571
|
+
readonly debug: false;
|
|
2572
|
+
readonly concurrency: 5;
|
|
2573
|
+
readonly onlySuccess: false;
|
|
2574
|
+
readonly timeout: symbol & {
|
|
2575
|
+
__brand: VigorBrand<"Core", "Symbol_Empty">;
|
|
2576
|
+
};
|
|
2577
|
+
readonly failFast: false;
|
|
2578
|
+
};
|
|
2579
|
+
readonly middlewares: {
|
|
2580
|
+
readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
|
|
2581
|
+
readonly before: [];
|
|
2582
|
+
readonly after: [];
|
|
2583
|
+
readonly onResult: [];
|
|
2584
|
+
readonly beforeEach: [];
|
|
2585
|
+
readonly afterEach: [];
|
|
2586
|
+
readonly onErrorEach: [];
|
|
2587
|
+
};
|
|
2588
|
+
};
|
|
2589
|
+
/**
|
|
2590
|
+
* What a failed task's slot holds as `error`: whatever the task threw, or
|
|
2591
|
+
* `VigorAllError("TIMED_OUT")` when it hit `settings.timeout`.
|
|
2592
|
+
*/
|
|
2593
|
+
type VigorAllTaskError = VigorResultError<VigorAllError<"TIMED_OUT", any>>;
|
|
2594
|
+
/**
|
|
2595
|
+
* One task's outcome, shaped like `requestVerbose()`'s envelope: what it
|
|
2596
|
+
* returned (or what `onErrorEach` recovered it with), or what it failed with.
|
|
2597
|
+
*/
|
|
2598
|
+
type VigorAllSettled<V> = {
|
|
2599
|
+
success: true;
|
|
2600
|
+
data: V;
|
|
2601
|
+
error: null;
|
|
2602
|
+
} | {
|
|
2603
|
+
success: false;
|
|
2604
|
+
data: null;
|
|
2605
|
+
error: VigorAllTaskError;
|
|
2606
|
+
};
|
|
2607
|
+
/**
|
|
2608
|
+
* The naturally-inferred (pre-`.cast<T>()`) result type of `.request()`.
|
|
2609
|
+
* When `onlySuccess` is left `false` (the default), every task gets its own
|
|
2610
|
+
* tuple slot holding its outcome — `.target(() => 1 as const, () => "a")`
|
|
2611
|
+
* infers `[VigorAllSettled<1>, VigorAllSettled<"a">]` — so a failed task
|
|
2612
|
+
* can't pass for a result. `onlySuccess: true` keeps only the successful
|
|
2613
|
+
* tasks' values, at runtime an arbitrary length, so it becomes an array of
|
|
2614
|
+
* the tasks' result types (`(1 | "a")[]`). A non-literal `boolean` could be
|
|
2615
|
+
* either, so it gives the union of both.
|
|
2616
|
+
*/
|
|
2617
|
+
type VigorAllNaturalResult<T extends VigorAllSchema<T>> = T["policy"]["target"] extends readonly VigorAllTask[] ? VigorAllResultFor<T["policy"]["settings"]["onlySuccess"], VigorAllTasksTuple<T["policy"]["target"]>> : unknown[];
|
|
2618
|
+
/** Distributes over `boolean`, so a non-literal `onlySuccess` yields both shapes. */
|
|
2619
|
+
type VigorAllResultFor<OnlySuccess, Tuple extends readonly unknown[]> = OnlySuccess extends true ? Tuple[number][] : {
|
|
2620
|
+
[K in keyof Tuple]: VigorAllSettled<Tuple[K]>;
|
|
2621
|
+
};
|
|
2583
2622
|
|
|
2584
2623
|
type VigorAllTimelineStages = Omit<VigorAllPolicyMiddlewaresSchema<any>, "__brand">;
|
|
2585
2624
|
type VigorAllTimelineApis = {
|
|
@@ -2639,16 +2678,22 @@ type VigorAllContextSchema<T extends VigorAllSchema<T>, R = VigorAllPipeResult<T
|
|
|
2639
2678
|
/** Everything this `requestVerbose()` call has gone through so far. */
|
|
2640
2679
|
timeline: VigorAllTimeline;
|
|
2641
2680
|
};
|
|
2642
|
-
/**
|
|
2643
|
-
type
|
|
2644
|
-
/**
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
type
|
|
2681
|
+
/** The result before any batch-level middleware: `.cast<T>()`'s, else the tasks' outcomes. */
|
|
2682
|
+
type VigorAllCastNaturalResult<T extends VigorAllSchema<T>> = VigorCastResult<T["cast"], VigorAllNaturalResult<T>>;
|
|
2683
|
+
/**
|
|
2684
|
+
* Context seen by `before` middlewares — no task has run yet.
|
|
2685
|
+
*
|
|
2686
|
+
* Each stage's context is defined on its own — the runtime's view at that
|
|
2687
|
+
* point — with whatever the stage's earlier intercept middlewares changed by
|
|
2688
|
+
* returning a different context (see `VigorContextStage`).
|
|
2689
|
+
*/
|
|
2690
|
+
type VigorAllBeforeContextSchema<T extends VigorAllSchema<T>> = VigorContextStage<VigorAllContextSchema<T, VigorDefaultType>, T["policy"]["middlewares"]["before"]>;
|
|
2691
|
+
/** Context seen by `after` middlewares — every task has settled; what `before` changed otherwise carries over. */
|
|
2692
|
+
type VigorAllAfterContextSchema<T extends VigorAllSchema<T>> = VigorContextStage<VigorContextReset<VigorAllBeforeContextSchema<T>, {
|
|
2693
|
+
result: VigorAllCastNaturalResult<T>;
|
|
2694
|
+
}>, T["policy"]["middlewares"]["after"]>;
|
|
2695
|
+
/** Context seen by `onResult` middlewares — `ctx.result` is what the earlier `onResult` ones left it as. */
|
|
2696
|
+
type VigorAllOnResultContextSchema<T extends VigorAllSchema<T>> = VigorContextStage<VigorAllAfterContextSchema<T>, T["policy"]["middlewares"]["onResult"], "result">;
|
|
2652
2697
|
/** Context shape once the full batch-level pipeline (`before`/`after`/`onResult`) has run. */
|
|
2653
2698
|
type VigorAllResultContextSchema<T extends VigorAllSchema<T>> = VigorAllContextSchema<T, VigorAllPipeResult<T>>;
|
|
2654
2699
|
declare const VigorAllContextBase: {
|
|
@@ -3442,9 +3487,7 @@ type VigorFetchPolicyMiddlewaresFluent<T extends VigorFetchSchema<T>> = {
|
|
|
3442
3487
|
};
|
|
3443
3488
|
onResult: {
|
|
3444
3489
|
_mode: "fluent";
|
|
3445
|
-
func: (res: VigorFetchOnResultContextSchema<T>
|
|
3446
|
-
result: infer R;
|
|
3447
|
-
} ? R : never) => VigorFetchContextSchema<any>["result"] | Promise<VigorFetchContextSchema<any>["result"]>;
|
|
3490
|
+
func: (res: VigorFetchOnResultContextSchema<T>["result"]) => VigorFetchContextSchema<any>["result"] | Promise<VigorFetchContextSchema<any>["result"]>;
|
|
3448
3491
|
};
|
|
3449
3492
|
onError: {
|
|
3450
3493
|
_mode: "fluent";
|
|
@@ -3476,7 +3519,7 @@ type VigorFetchPolicyMiddlewaresIntercept<T extends VigorFetchSchema<T>> = {
|
|
|
3476
3519
|
};
|
|
3477
3520
|
onError: {
|
|
3478
3521
|
_mode: "intercept";
|
|
3479
|
-
func: (ctx:
|
|
3522
|
+
func: (ctx: VigorFetchOnErrorContextSchema<T>, api: Pick<VigorFetchPolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorFetchContextSchema<any> | Promise<VigorFetchContextSchema<any>>;
|
|
3480
3523
|
};
|
|
3481
3524
|
};
|
|
3482
3525
|
/**
|
|
@@ -3600,33 +3643,14 @@ type VigorFetchNaturalResult<T extends VigorFetchSchema<T>> = VigorFetchNaturalF
|
|
|
3600
3643
|
* route matched (`VigorApiNoMatchType`) the parse engine's result is used.
|
|
3601
3644
|
*/
|
|
3602
3645
|
type VigorFetchNaturalFor<T extends VigorFetchSchema<T>, D> = T["policy"]["parse"]["policy"]["settings"]["raw"] extends true ? VigorFetchParsedResult<T> : Exclude<D, VigorApiNoMatchType> | (VigorApiNoMatchType extends D ? VigorFetchParsedResult<T> : never);
|
|
3603
|
-
type VigorFetchPipeInitialContext<T extends VigorFetchSchema<T>, R = VigorCastResult<T["cast"], VigorFetchNaturalResult<T>>> = VigorDeepMerge<Omit<VigorFetchContextSchema<T, unknown>, "result">, {
|
|
3604
|
-
result: R;
|
|
3605
|
-
}>;
|
|
3606
|
-
type VigorFetchPipeStepVoid<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
|
|
3607
|
-
_mode: "intercept";
|
|
3608
|
-
func: (...args: any[]) => infer Ret;
|
|
3609
|
-
} ? VigorFetchPipeStepVoid<Ret, Tail> : VigorFetchPipeStepVoid<Ctx, Tail> : Ctx;
|
|
3610
|
-
type VigorFetchPipeStepResult<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
|
|
3611
|
-
_mode: "intercept";
|
|
3612
|
-
func: (...args: any[]) => infer Ret;
|
|
3613
|
-
} ? VigorFetchPipeStepResult<Ret, Tail> : Head extends {
|
|
3614
|
-
_mode: "fluent";
|
|
3615
|
-
func: (...args: any[]) => infer FR;
|
|
3616
|
-
} ? VigorFetchPipeStepResult<VigorDeepMerge<Ctx, {
|
|
3617
|
-
result: FR;
|
|
3618
|
-
}, {
|
|
3619
|
-
result: "replace";
|
|
3620
|
-
}>, Tail> : VigorFetchPipeStepResult<Ctx, Tail> : Ctx;
|
|
3621
|
-
type VigorFetchPolicyMiddlewaresPipe<T extends VigorFetchSchema<T>, Natural = VigorFetchNaturalResult<T>> = VigorFetchPipeStepVoid<VigorFetchPipeStepResult<VigorFetchPipeStepResult<VigorFetchPipeStepVoid<VigorFetchPipeInitialContext<T, VigorCastResult<T["cast"], Natural>>, T["policy"]["middlewares"]["before"]>, T["policy"]["middlewares"]["after"]>, T["policy"]["middlewares"]["onResult"]>, T["policy"]["middlewares"]["onError"]>;
|
|
3622
3646
|
/**
|
|
3623
|
-
* The result the
|
|
3647
|
+
* The result the success pipeline produces. `Natural` is the result it
|
|
3624
3648
|
* starts from (before `.cast<T>()`): by default the API map's whole success
|
|
3625
3649
|
* union, or one status's data to follow that status through the pipeline.
|
|
3626
3650
|
*/
|
|
3627
|
-
type VigorFetchPipeResult<T extends VigorFetchSchema<T>, Natural = VigorFetchNaturalResult<T>> =
|
|
3628
|
-
|
|
3629
|
-
|
|
3651
|
+
type VigorFetchPipeResult<T extends VigorFetchSchema<T>, Natural = VigorFetchNaturalResult<T>> = VigorFetchOnResultContextSchema<T, Natural>["result"];
|
|
3652
|
+
/** `ctx.result` once the `onError` middlewares ran — what a recovered request (`setResult`) resolves to, as far as types go. */
|
|
3653
|
+
type VigorFetchErrorPipeResult<T extends VigorFetchSchema<T>> = VigorFetchOnErrorContextSchema<T>["result"];
|
|
3630
3654
|
|
|
3631
3655
|
type VigorFetchTimelineStages = Omit<VigorFetchPolicyMiddlewaresSchema<any>, "__brand">;
|
|
3632
3656
|
type VigorFetchTimelineApis = {
|
|
@@ -3736,16 +3760,27 @@ type VigorFetchContextSchema<T extends VigorFetchSchema<T>, R = VigorFetchPipeRe
|
|
|
3736
3760
|
timeline: VigorFetchTimeline;
|
|
3737
3761
|
policy: T["policy"];
|
|
3738
3762
|
};
|
|
3739
|
-
/**
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3763
|
+
/**
|
|
3764
|
+
* Context seen by `before` middlewares — the request hasn't been sent yet.
|
|
3765
|
+
*
|
|
3766
|
+
* Each stage's context is defined on its own — the runtime's view at that
|
|
3767
|
+
* point — with whatever the stage's earlier intercept middlewares changed by
|
|
3768
|
+
* returning a different context (see `VigorContextStage`).
|
|
3769
|
+
*/
|
|
3770
|
+
type VigorFetchBeforeContextSchema<T extends VigorFetchSchema<T>> = VigorContextStage<VigorFetchContextSchema<T, VigorDefaultType>, T["policy"]["middlewares"]["before"]>;
|
|
3771
|
+
/**
|
|
3772
|
+
* Context seen by `after` middlewares — `response` and the parsed `result`
|
|
3773
|
+
* are set; what `before` changed otherwise carries over. `Natural` is the
|
|
3774
|
+
* result before `.cast<T>()` (one API-map status's, when followed per status).
|
|
3775
|
+
*/
|
|
3776
|
+
type VigorFetchAfterContextSchema<T extends VigorFetchSchema<T>, Natural = VigorFetchNaturalResult<T>> = VigorContextStage<VigorContextReset<VigorFetchBeforeContextSchema<T>, {
|
|
3777
|
+
result: VigorCastResult<T["cast"], Natural>;
|
|
3778
|
+
response: Response;
|
|
3746
3779
|
}>, T["policy"]["middlewares"]["after"]>;
|
|
3747
|
-
/** Context
|
|
3748
|
-
type VigorFetchOnResultContextSchema<T extends VigorFetchSchema<T>> =
|
|
3780
|
+
/** Context seen by `onResult` middlewares — `ctx.result` is what the earlier `onResult` ones left it as. */
|
|
3781
|
+
type VigorFetchOnResultContextSchema<T extends VigorFetchSchema<T>, Natural = VigorFetchNaturalResult<T>> = VigorContextStage<VigorFetchAfterContextSchema<T, Natural>, T["policy"]["middlewares"]["onResult"], "result">;
|
|
3782
|
+
/** Context seen by `onError` middlewares — the request failed. */
|
|
3783
|
+
type VigorFetchOnErrorContextSchema<T extends VigorFetchSchema<T>> = VigorContextStage<VigorFetchContextSchema<T>, T["policy"]["middlewares"]["onError"]>;
|
|
3749
3784
|
/** Context shape once the full middleware pipeline (including `onResult`) has run. */
|
|
3750
3785
|
type VigorFetchResultContextSchema<T extends VigorFetchSchema<T>> = VigorFetchContextSchema<T, VigorFetchPipeResult<T>>;
|
|
3751
3786
|
declare const VigorFetchContextBase: {
|
|
@@ -4032,6 +4067,20 @@ type VigorFetchErrorsIn<E, C extends VigorFetchErrorCodes = VigorFetchErrorCodes
|
|
|
4032
4067
|
*/
|
|
4033
4068
|
declare function isVigorFetchError<E>(error: E): error is E & VigorFetchErrorsIn<E>;
|
|
4034
4069
|
declare function isVigorFetchError<E, const C extends VigorFetchErrorCodes>(error: E, ...codes: [C, ...C[]]): error is E & VigorFetchErrorsIn<E, C>;
|
|
4070
|
+
/**
|
|
4071
|
+
* Like `isVigorFetchError(error, ...codes)`, but also looks inside the errors
|
|
4072
|
+
* `error` wraps — `data.error` of `RETRY_EXHAUSTED` / `RESTART_EXHAUSTED`,
|
|
4073
|
+
* then `cause` — and returns the first match, outermost first. Returns
|
|
4074
|
+
* `null` when there is none. `error` itself is left as it is.
|
|
4075
|
+
*
|
|
4076
|
+
* A guard can't do this: it narrows the value you pass, so a `true` for a
|
|
4077
|
+
* wrapped match would claim the wrapper has the inner error's `data`.
|
|
4078
|
+
*
|
|
4079
|
+
* @example
|
|
4080
|
+
* const failed = findVigorFetchError(error, "FETCH_FAILED")
|
|
4081
|
+
* if (failed) failed.data.status
|
|
4082
|
+
*/
|
|
4083
|
+
declare function findVigorFetchError<E, const C extends VigorFetchErrorCodes>(error: E, ...codes: [C, ...C[]]): VigorFetchErrorsIn<E, C> | null;
|
|
4035
4084
|
/**
|
|
4036
4085
|
* Re-raises an error of the nested retry/parse engine as a `VigorFetchError`
|
|
4037
4086
|
* with the same `code`, `data`, and `method`, keeping the original as
|
|
@@ -4050,7 +4099,7 @@ type VigorFetchSchema<T extends VigorFetchSchema<T>> = {
|
|
|
4050
4099
|
apiMap: unknown;
|
|
4051
4100
|
};
|
|
4052
4101
|
/** What `request()` resolves to: the pipeline's result, or what `settings.default` returns. */
|
|
4053
|
-
type VigorFetchResult<T extends VigorFetchSchema<T>> = VigorExcludeDefault<VigorFetchContextSchema<T>["result"]> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
4102
|
+
type VigorFetchResult<T extends VigorFetchSchema<T>> = VigorExcludeDefault<VigorFetchContextSchema<T>["result"]> | VigorExcludeDefault<VigorFetchErrorPipeResult<T>> | VigorReturnType<T["policy"]["settings"]["default"]>;
|
|
4054
4103
|
/** The builder `T` becomes after merging `P` in (with strategy tree `S`). */
|
|
4055
4104
|
type VigorFetchNext<T, P, S = undefined> = VigorApply<VigorFetchTypeLambda, VigorDeepMerge<T, P, S>>;
|
|
4056
4105
|
/** `requestVerbose()`'s default type argument: "infer the result per status". Type-only. */
|
|
@@ -4090,7 +4139,7 @@ type VigorFetchVerboseParsed<T extends VigorFetchSchema<T>, R> = VigorFetchIsInf
|
|
|
4090
4139
|
* `onError`'s `setResult` or `settings.default` — so there's no response:
|
|
4091
4140
|
* `status`/`response` are `null`. Only possible when one of them is set.
|
|
4092
4141
|
*/
|
|
4093
|
-
type VigorFetchVerboseRecovered<T extends VigorFetchSchema<T>, R> = (T["policy"]["middlewares"]["onError"] extends readonly [] ? never : VigorExcludeDefault<
|
|
4142
|
+
type VigorFetchVerboseRecovered<T extends VigorFetchSchema<T>, R> = (T["policy"]["middlewares"]["onError"] extends readonly [] ? never : VigorExcludeDefault<VigorFetchErrorPipeResult<T>>) | (T["policy"]["settings"]["default"] extends VigorEmptyType ? never : VigorReturnType<T["policy"]["settings"]["default"]>) extends infer D ? [D] extends [never] ? never : {
|
|
4094
4143
|
success: true;
|
|
4095
4144
|
data: VigorFetchIsInferred<R> extends true ? D : R;
|
|
4096
4145
|
error: null;
|
|
@@ -5432,10 +5481,18 @@ declare const vigorBase: {
|
|
|
5432
5481
|
};
|
|
5433
5482
|
};
|
|
5434
5483
|
guards: {
|
|
5435
|
-
retry: typeof isVigorRetryError
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5484
|
+
retry: typeof isVigorRetryError & {
|
|
5485
|
+
find: typeof findVigorRetryError;
|
|
5486
|
+
};
|
|
5487
|
+
parse: typeof isVigorParseError & {
|
|
5488
|
+
find: typeof findVigorParseError;
|
|
5489
|
+
};
|
|
5490
|
+
fetch: typeof isVigorFetchError & {
|
|
5491
|
+
find: typeof findVigorFetchError;
|
|
5492
|
+
};
|
|
5493
|
+
all: typeof isVigorAllError & {
|
|
5494
|
+
find: typeof findVigorAllError;
|
|
5495
|
+
};
|
|
5439
5496
|
};
|
|
5440
5497
|
};
|
|
5441
5498
|
/** `A` with `B`'s properties replacing same-named ones, like `{ ...A, ...B }`. */
|
|
@@ -5465,4 +5522,4 @@ type VigorPlugin<O extends {
|
|
|
5465
5522
|
};
|
|
5466
5523
|
declare const vigor: VigorInstance;
|
|
5467
5524
|
|
|
5468
|
-
export { VigorAll, type VigorAllAfterContextSchema, VigorAllBase, type VigorAllBeforeContextSchema, VigorAllContextBase, type VigorAllContextSchema, VigorAllEachContextBase, type VigorAllEachContextSchema, type VigorAllEachMiddlewareFn, type VigorAllEachOnErrorFn, VigorAllError, type VigorAllErrorCodes, type VigorAllErrorCodesWithOptionalContext, type VigorAllErrorCodesWithoutContext, type VigorAllErrorContext, type VigorAllErrorDatas, VigorAllErrorMessageFuncs, type VigorAllErrors, type VigorAllErrorsIn, type VigorAllNaturalResult, type VigorAllOnResultContextSchema, type
|
|
5525
|
+
export { VigorAll, type VigorAllAfterContextSchema, VigorAllBase, type VigorAllBeforeContextSchema, type VigorAllCastNaturalResult, VigorAllContextBase, type VigorAllContextSchema, VigorAllEachContextBase, type VigorAllEachContextSchema, type VigorAllEachMiddlewareFn, type VigorAllEachOnErrorFn, VigorAllError, type VigorAllErrorCodes, type VigorAllErrorCodesWithOptionalContext, type VigorAllErrorCodesWithoutContext, type VigorAllErrorContext, type VigorAllErrorDatas, VigorAllErrorMessageFuncs, type VigorAllErrors, type VigorAllErrorsIn, type VigorAllNaturalResult, type VigorAllOnResultContextSchema, type VigorAllPipeResult, VigorAllPolicyBase, VigorAllPolicyMiddlewares, type VigorAllPolicyMiddlewaresApi, VigorAllPolicyMiddlewaresBase, type VigorAllPolicyMiddlewaresFluent, type VigorAllPolicyMiddlewaresIntercept, type VigorAllPolicyMiddlewaresSchema, type VigorAllPolicySchema, VigorAllPolicySettings, VigorAllPolicySettingsBase, type VigorAllPolicySettingsSchema, type VigorAllProcessHandler, type VigorAllRequestError, type VigorAllResult, type VigorAllResultContextSchema, type VigorAllSchema, type VigorAllSettled, type VigorAllTask, type VigorAllTaskError, type VigorAllTaskResult, type VigorAllTasksTuple, type VigorAllTimeline, type VigorAllTimelineEvents, type VigorAllTimelineSnapshot, type VigorApiFailure, type VigorApiKeys, type VigorApiMap, type VigorApiMapSlot, type VigorApiMatch, type VigorApiMatched, type VigorApiMethod, type VigorApiNoMatchType, type VigorApiParamValue, type VigorApiRequestIssue, type VigorApiRequestIssues, type VigorApiResponse, type VigorApiRoute, type VigorApiRouteKey, type VigorApiRouteOf, type VigorApiStatusClass, type VigorApiSuccess, type VigorBrand, type VigorBuiltin, VigorCastPlaceholder, type VigorCastPlaceholderType, type VigorCastResult, type VigorConcat, type VigorContextApply, type VigorContextChanges, type VigorContextReset, type VigorContextStage, type VigorDeepMerge, type VigorDeepPartial, VigorDefault, type VigorDefaultType, VigorEmpty, type VigorEmptyType, VigorError, type VigorErrorContext, type VigorErrorOptions, type VigorExcludeDefault, type VigorExcludeEmpty, VigorFetch, type VigorFetchAfterContextSchema, VigorFetchBase, type VigorFetchBeforeContextSchema, type VigorFetchBodyFor, VigorFetchContextBase, type VigorFetchContextSchema, VigorFetchError, type VigorFetchErrorCodes, type VigorFetchErrorCodesWithOptionalContext, type VigorFetchErrorCodesWithoutContext, type VigorFetchErrorContext, type VigorFetchErrorDatas, VigorFetchErrorMessageFuncs, type VigorFetchErrorPipeResult, type VigorFetchErrors, type VigorFetchErrorsIn, type VigorFetchExtraOptions, type VigorFetchFailedData, type VigorFetchInferResult, type VigorFetchMethodFor, type VigorFetchNaturalFor, type VigorFetchNaturalResult, type VigorFetchOnErrorContextSchema, type VigorFetchOnResultContextSchema, type VigorFetchOptions, type VigorFetchParseSource, type VigorFetchParsedResult, type VigorFetchPipeResult, VigorFetchPolicyBase, VigorFetchPolicyMiddlewares, type VigorFetchPolicyMiddlewaresApi, VigorFetchPolicyMiddlewaresBase, type VigorFetchPolicyMiddlewaresFluent, type VigorFetchPolicyMiddlewaresIntercept, type VigorFetchPolicyMiddlewaresSchema, type VigorFetchPolicySchema, VigorFetchPolicySettings, VigorFetchPolicySettingsBase, type VigorFetchPolicySettingsSchema, type VigorFetchProcessHandler, type VigorFetchRequestError, type VigorFetchRequestThis, type VigorFetchResult, type VigorFetchResultContextSchema, type VigorFetchRouteKeys, type VigorFetchSchema, type VigorFetchTimeline, type VigorFetchTimelineEvents, type VigorFetchTimelineSnapshot, type VigorFetchVerboseResult, type VigorHttpFailureStatus, type VigorHttpStatusOf, type VigorHttpSuccessStatus, type VigorInstance, type VigorIsSame, VigorJitter, type VigorLastOf, type VigorMergeMode, type VigorMergeStrategy, type VigorNoExtraKeys, VigorParse, type VigorParseAfterContextSchema, VigorParseBase, type VigorParseBeforeContextSchema, type VigorParseBody, VigorParseContentTypeStrategy, VigorParseContextBase, type VigorParseContextSchema, VigorParseError, type VigorParseErrorCodes, type VigorParseErrorCodesWithOptionalContext, type VigorParseErrorCodesWithoutContext, type VigorParseErrorContext, type VigorParseErrorDatas, VigorParseErrorMessageFuncs, type VigorParseErrorPipeResult, type VigorParseErrors, type VigorParseErrorsIn, type VigorParseNaturalResult, type VigorParseOnErrorContextSchema, type VigorParseOnResultContextSchema, type VigorParsePipeResult, VigorParsePolicyBase, VigorParsePolicyMiddlewares, type VigorParsePolicyMiddlewaresApi, VigorParsePolicyMiddlewaresBase, type VigorParsePolicyMiddlewaresFluent, type VigorParsePolicyMiddlewaresIntercept, type VigorParsePolicyMiddlewaresSchema, type VigorParsePolicySchema, VigorParsePolicySettings, VigorParsePolicySettingsBase, type VigorParsePolicySettingsSchema, VigorParsePolicyStrategies, VigorParsePolicyStrategiesBase, type VigorParsePolicyStrategiesSchema, type VigorParseProcessHandler, type VigorParseRequestError, type VigorParseResult, type VigorParseResultContextSchema, type VigorParseSchema, VigorParseSniffStrategy, type VigorParseStrategyFunc, type VigorParseTimeline, type VigorParseTimelineEvents, type VigorParseTimelineSnapshot, type VigorPathList, type VigorPathSegments, type VigorPlugin, type VigorPrimitive, type VigorReplaceType, type VigorResolvedMethod, type VigorResultError, type VigorResultOf, VigorRetry, type VigorRetryAfterContextSchema, VigorRetryBase, type VigorRetryBeforeContextSchema, VigorRetryContextBase, type VigorRetryContextSchema, type VigorRetryDecisionReason, VigorRetryError, type VigorRetryErrorCodes, type VigorRetryErrorCodesWithOptionalContext, type VigorRetryErrorCodesWithoutContext, type VigorRetryErrorContext, type VigorRetryErrorDatas, VigorRetryErrorMessageFuncs, type VigorRetryErrorPipeResult, type VigorRetryErrors, type VigorRetryErrorsIn, type VigorRetryNaturalResult, type VigorRetryOnErrorContextSchema, type VigorRetryOnResultContextSchema, type VigorRetryOnRetryContextSchema, type VigorRetryPipeResult, 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 VigorRetryPolicyMiddlewaresSchema, type VigorRetryPolicySchema, VigorRetryPolicySettings, VigorRetryPolicySettingsBase, type VigorRetryPolicySettingsSchema, type VigorRetryProcessHandler, type VigorRetryRequestError, type VigorRetryResult, type VigorRetryResultContextSchema, type VigorRetryRetryIfContextSchema, type VigorRetrySchema, type VigorRetryTimeline, type VigorRetryTimelineEvents, type VigorRetryTimelineSnapshot, type VigorReturnType, type VigorRouteMethod, type VigorRouteParams, type VigorRoutePath, type VigorRoutePathList, type VigorRouteWithParams, type VigorRouteWithoutParams, type VigorSimplify, VigorStatus, type VigorStringable, type VigorTimeline, type VigorTimelineEndEvents, type VigorTimelineItem, type VigorTimelineMiddlewareEvents, type VigorTimelineOutcome, type VigorTimelineProcessEvents, type VigorTimelineSnapshot, adoptVigorFetchError, createBrand, createVigorTimelineRecorder, vigor as default, findInVigorErrorChain, findVigorAllError, findVigorFetchError, findVigorParseError, findVigorRetryError, isVigorAllError, isVigorDefault, isVigorEmpty, isVigorFetchError, isVigorInternalMiddleware, isVigorParseError, isVigorRetryError, markVigorInternal, readVigorParseBody, vigor };
|