vigor-fetch 4.0.3 → 4.0.5

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.
@@ -0,0 +1,4208 @@
1
+ interface VigorTypeLambda {
2
+ readonly In?: unknown;
3
+ readonly Target: unknown;
4
+ }
5
+ type VigorApply<F extends VigorTypeLambda, In> = F extends {
6
+ readonly Target: unknown;
7
+ } ? (F & {
8
+ readonly In: In;
9
+ })["Target"] : never;
10
+
11
+ type VigorPrimitive = string | number | bigint | boolean | symbol | null | undefined;
12
+ type VigorBuiltin = VigorPrimitive | Date | RegExp | Function | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any>;
13
+ type VigorDeepPartial<T> = unknown extends T ? T : T extends VigorBuiltin ? T : T extends readonly (infer U)[] ? readonly VigorDeepPartial<U>[] : {
14
+ [K in keyof T]?: VigorDeepPartial<T[K]>;
15
+ };
16
+ type VigorSimplify<T> = {
17
+ [K in keyof T]: T[K];
18
+ } & {};
19
+ type VigorDeepMerge<A, B> = A extends VigorBuiltin ? B : B extends VigorBuiltin ? B : A extends readonly any[] ? B extends readonly any[] ? [...A, ...B] : B : A extends object ? B extends object ? VigorSimplify<{
20
+ [K in keyof A | keyof B]: K extends keyof B ? K extends keyof A ? VigorDeepMerge<A[K], B[K]> : B[K] : K extends keyof A ? A[K] : never;
21
+ }> : B : B;
22
+ type VigorReplaceType<T, K extends keyof T, V> = VigorSimplify<{
23
+ [P in keyof T]: P extends K ? V : T[P];
24
+ }>;
25
+ type VigorConcat<T extends readonly any[], U extends readonly any[]> = [...T, ...U];
26
+ type VigorLastOf<T extends readonly any[]> = T extends [...infer _, infer L] ? L : never;
27
+ type VigorReturnType<T> = T extends (...args: Array<any>) => any ? Awaited<ReturnType<T>> : never;
28
+ type VigorMergeMode = "merge" | "replace" | "concat";
29
+ type VigorMergeStrategy<T> = T extends VigorBuiltin ? VigorMergeMode | undefined : T extends readonly any[] ? VigorMergeMode : {
30
+ [K in keyof T]?: VigorMergeStrategy<T[K]> | VigorMergeMode;
31
+ };
32
+
33
+ type VigorBrand<Branch extends string, Name extends string> = string & {
34
+ __brand: `@vigor-fetch:::${Branch} <- ${Name}`;
35
+ };
36
+ declare const VigorDefault: symbol & {
37
+ __brand: VigorBrand<"Core", "Symbol_Default">;
38
+ };
39
+ type VigorDefaultType = typeof VigorDefault;
40
+ declare const VigorEmpty: symbol & {
41
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
42
+ };
43
+ type VigorEmptyType = typeof VigorEmpty;
44
+ type VigorExcludeEmpty<T> = Exclude<T, VigorEmptyType>;
45
+
46
+ type VigorParseContextSchema<T extends VigorParseSchema<T>> = {
47
+ __brand: VigorBrand<"Parse", "Context<Schema">;
48
+ result: unknown | VigorDefaultType;
49
+ error: unknown;
50
+ response: VigorParsePolicySchema<T>["target"];
51
+ flags: {
52
+ overrided: boolean;
53
+ restarted: boolean;
54
+ };
55
+ record: Record<string, any>;
56
+ policy: T["policy"];
57
+ };
58
+
59
+ /**
60
+ * Base class for Vigor's immutable, chainable builder objects.
61
+ *
62
+ * Each subclass holds a `base` config and a current `config`, and exposes
63
+ * `_next()` to derive a new instance with a patch merged in. Subclasses
64
+ * implement `_create()` to construct the concrete instance type, and the
65
+ * return type of `_next()` is computed through the `TL` type lambda so
66
+ * chained calls stay precisely typed.
67
+ *
68
+ * @typeParam Base - Shape of the full config for this builder.
69
+ * @typeParam Config - Concrete config type held by this instance (extends `Base`).
70
+ * @typeParam TL - Type lambda mapping a config type to the concrete instance type.
71
+ */
72
+ declare abstract class VigorStatus<Base, Config extends Base, TL extends VigorTypeLambda> {
73
+ private readonly _base;
74
+ private readonly _config;
75
+ /**
76
+ * @param base - The default/base config for this builder.
77
+ * @param config - The (possibly partial) config to merge onto `base`.
78
+ */
79
+ constructor(base: Base, config: Config | VigorDeepPartial<Config>);
80
+ /** Constructs a concrete instance of this builder from a merged config. */
81
+ protected abstract _create<C>(config: C): VigorApply<TL, C>;
82
+ /**
83
+ * Derives a new instance by merging `patch` onto the current config.
84
+ *
85
+ * @param patch - Values to overwrite/merge in for this step.
86
+ * @param strategy - Optional tree mirroring the shape of `patch`, whose
87
+ * leaves may be `"replace" | "concat" | "merge"` to force the merge
88
+ * behavior at that path. Paths without a strategy fall back to the
89
+ * default behavior (deep merge for objects, concat for arrays).
90
+ */
91
+ protected _next<const Patch extends VigorDeepPartial<Base>>(patch: Patch, strategy?: VigorMergeStrategy<Patch>): VigorApply<TL, VigorDeepMerge<Config, Patch>>;
92
+ /**
93
+ * Deep-merges `target` onto `source`, honoring an optional per-path
94
+ * `strategy` tree. Objects merge key by key, arrays concatenate (unless
95
+ * `"replace"` is specified), and any other value is overwritten.
96
+ */
97
+ protected _merge<A, B>(source: A, target: B, strategy?: unknown): VigorDeepMerge<A, B>;
98
+ /** The default/base config this builder was constructed with. */
99
+ get base(): Base;
100
+ /** The current, merged config for this builder instance. */
101
+ get config(): Config;
102
+ }
103
+
104
+ type VigorParsePolicySettingsSchema<T extends VigorParseSchema<T>> = {
105
+ __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
106
+ raw: boolean;
107
+ default: ((ctx: T["context"]) => any | Promise<any>) | VigorEmptyType;
108
+ maxRestarts: number;
109
+ };
110
+ declare const VigorParsePolicySettingsBase: {
111
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
112
+ readonly raw: false;
113
+ readonly default: symbol & {
114
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
115
+ };
116
+ readonly maxRestarts: 3;
117
+ };
118
+ /** Immutable builder for a parse policy's general settings. */
119
+ declare class VigorParsePolicySettings<T extends VigorParseSchema<T> = typeof VigorParseBase> extends VigorStatus<VigorParseSchema<any>, T, VigorParsePolicySettingsTypeLambda> {
120
+ constructor(config?: T);
121
+ protected _create<C>(config: C): VigorApply<VigorParsePolicySettingsTypeLambda, C>;
122
+ /** When enabled, skips content-type based parsing and returns the raw response. */
123
+ raw<const N extends VigorParseSchema<any>["policy"]["settings"]["raw"]>(bool: N): VigorParsePolicySettings<VigorParseIn<VigorDeepMerge<T, {
124
+ readonly policy: {
125
+ readonly settings: {
126
+ readonly raw: N;
127
+ };
128
+ };
129
+ }>>>;
130
+ /** Sets the fallback value/factory used when parsing ultimately fails. */
131
+ default<const N extends VigorExcludeEmpty<VigorParseSchema<any>["policy"]["settings"]["default"]>>(func: N): VigorParsePolicySettings<VigorParseIn<VigorDeepMerge<T, {
132
+ readonly policy: {
133
+ readonly settings: {
134
+ readonly default: N;
135
+ };
136
+ };
137
+ }>>>;
138
+ /** Sets the maximum number of full restarts allowed. */
139
+ maxRestarts<const N extends VigorParseSchema<any>["policy"]["settings"]["maxRestarts"]>(num: N): VigorParsePolicySettings<VigorParseIn<VigorDeepMerge<T, {
140
+ readonly policy: {
141
+ readonly settings: {
142
+ readonly maxRestarts: N;
143
+ };
144
+ };
145
+ }>>>;
146
+ }
147
+
148
+ type VigorParsePolicyMiddlewaresSchema<T extends VigorParseSchema<T>> = {
149
+ __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
150
+ before: (VigorParsePolicyMiddlewaresFluent<T>["before"] | VigorParsePolicyMiddlewaresIntercept<T>["before"])[];
151
+ after: (VigorParsePolicyMiddlewaresFluent<T>["after"] | VigorParsePolicyMiddlewaresIntercept<T>["after"])[];
152
+ onResult: (VigorParsePolicyMiddlewaresFluent<T>["onResult"] | VigorParsePolicyMiddlewaresIntercept<T>["onResult"])[];
153
+ onError: (VigorParsePolicyMiddlewaresFluent<T>["onError"] | VigorParsePolicyMiddlewaresIntercept<T>["onError"])[];
154
+ };
155
+ declare const VigorParsePolicyMiddlewaresBase: {
156
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
157
+ readonly before: [];
158
+ readonly after: [];
159
+ readonly onResult: [];
160
+ readonly onError: [];
161
+ };
162
+ type VigorParsePolicyMiddlewaresFluent<T extends VigorParseSchema<T>> = {
163
+ __brand: VigorBrand<"Parse", "Policy<Middlewares<Fluent<Schema">;
164
+ before: {
165
+ _mode: "fluent";
166
+ func: (ctx: T["context"]) => void;
167
+ };
168
+ after: {
169
+ _mode: "fluent";
170
+ func: (ctx: T["context"]) => void;
171
+ };
172
+ onResult: {
173
+ _mode: "fluent";
174
+ func: (res: T["context"]["result"]) => VigorParseSchema<any>["context"]["result"];
175
+ };
176
+ onError: {
177
+ _mode: "fluent";
178
+ func: (err: T["context"]["error"]) => void;
179
+ };
180
+ };
181
+ type VigorParsePolicyMiddlewaresApi<T extends VigorParseSchema<T>> = {
182
+ setResult: (res: VigorParseSchema<any>["context"]["result"]) => void;
183
+ throwError: (err: VigorParseSchema<any>["context"]["error"]) => void;
184
+ proceedRestart: () => void;
185
+ cancelRestart: () => void;
186
+ };
187
+ type VigorParsePolicyMiddlewaresIntercept<T extends VigorParseSchema<T>> = {
188
+ __brand: VigorBrand<"Parse", "Policy<Middlewares<Intercept<Schema">;
189
+ before: {
190
+ _mode: "intercept";
191
+ func: (ctx: T["context"], api: Pick<VigorParsePolicyMiddlewaresApi<T>, "throwError">) => VigorParseSchema<any>["context"] | Promise<VigorParseSchema<any>["context"]>;
192
+ };
193
+ after: {
194
+ _mode: "intercept";
195
+ func: (ctx: T["context"], api: Pick<VigorParsePolicyMiddlewaresApi<T>, "setResult" | "throwError">) => VigorParseSchema<any>["context"] | Promise<VigorParseSchema<any>["context"]>;
196
+ };
197
+ onResult: {
198
+ _mode: "intercept";
199
+ func: (ctx: T["context"], api: Pick<VigorParsePolicyMiddlewaresApi<T>, "setResult" | "throwError">) => VigorParseSchema<any>["context"] | Promise<VigorParseSchema<any>["context"]>;
200
+ };
201
+ onError: {
202
+ _mode: "intercept";
203
+ func: (ctx: T["context"], api: Pick<VigorParsePolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorParseSchema<any>["context"] | Promise<VigorParseSchema<any>["context"]>;
204
+ };
205
+ };
206
+ /**
207
+ * Immutable builder for a parse policy's middleware pipeline (`before`,
208
+ * `after`, `onResult`, `onError`). Each stage accepts either "fluent"
209
+ * middleware (returns a plain value merged into the context) or
210
+ * "intercept" middleware (receives an explicit API to mutate control flow).
211
+ */
212
+ declare class VigorParsePolicyMiddlewares<T extends VigorParseSchema<T> = typeof VigorParseBase> extends VigorStatus<VigorParseSchema<any>, T, VigorParsePolicyMiddlewaresTypeLambda> {
213
+ constructor(config?: T);
214
+ protected _create<C>(config: C): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, C>;
215
+ /** Registers a middleware that runs before the response is parsed. */
216
+ before<const N extends VigorParsePolicyMiddlewaresFluent<any>["before"]["func"]>(type: "fluent", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
217
+ policy: {
218
+ middlewares: {
219
+ before: [{
220
+ _mode: "fluent";
221
+ func: N;
222
+ }];
223
+ };
224
+ };
225
+ }>>;
226
+ before<const N extends VigorParsePolicyMiddlewaresIntercept<any>["before"]["func"]>(type: "intercept", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
227
+ policy: {
228
+ middlewares: {
229
+ before: [{
230
+ _mode: "intercept";
231
+ func: N;
232
+ }];
233
+ };
234
+ };
235
+ }>>;
236
+ /** Registers a middleware that runs after the response has been parsed. */
237
+ after<const N extends VigorParsePolicyMiddlewaresFluent<any>["after"]["func"]>(type: "fluent", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
238
+ policy: {
239
+ middlewares: {
240
+ after: [{
241
+ _mode: "fluent";
242
+ func: N;
243
+ }];
244
+ };
245
+ };
246
+ }>>;
247
+ after<const N extends VigorParsePolicyMiddlewaresIntercept<any>["after"]["func"]>(type: "intercept", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
248
+ policy: {
249
+ middlewares: {
250
+ after: [{
251
+ _mode: "intercept";
252
+ func: N;
253
+ }];
254
+ };
255
+ };
256
+ }>>;
257
+ /** Registers a middleware that transforms or validates the parsed result. */
258
+ onResult<const N extends VigorParsePolicyMiddlewaresFluent<any>["onResult"]["func"]>(type: "fluent", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
259
+ policy: {
260
+ middlewares: {
261
+ onResult: [{
262
+ _mode: "fluent";
263
+ func: N;
264
+ }];
265
+ };
266
+ };
267
+ }>>;
268
+ onResult<const N extends VigorParsePolicyMiddlewaresIntercept<any>["onResult"]["func"]>(type: "intercept", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
269
+ policy: {
270
+ middlewares: {
271
+ onResult: [{
272
+ _mode: "intercept";
273
+ func: N;
274
+ }];
275
+ };
276
+ };
277
+ }>>;
278
+ /** Registers a middleware that runs when parsing ultimately fails. */
279
+ onError<const N extends VigorParsePolicyMiddlewaresFluent<any>["onError"]["func"]>(type: "fluent", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
280
+ policy: {
281
+ middlewares: {
282
+ onError: [{
283
+ _mode: "fluent";
284
+ func: N;
285
+ }];
286
+ };
287
+ };
288
+ }>>;
289
+ onError<const N extends VigorParsePolicyMiddlewaresIntercept<any>["onError"]["func"]>(type: "intercept", func: N): VigorApply<VigorParsePolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
290
+ policy: {
291
+ middlewares: {
292
+ onError: [{
293
+ _mode: "intercept";
294
+ func: N;
295
+ }];
296
+ };
297
+ };
298
+ }>>;
299
+ }
300
+
301
+ type VigorParsePolicySchema<T extends VigorParseSchema<T>> = {
302
+ __brand: VigorBrand<"Parse", "Policy<Schema">;
303
+ target: Request | Response | VigorDefaultType;
304
+ settings: VigorParsePolicySettingsSchema<T>;
305
+ middlewares: VigorParsePolicyMiddlewaresSchema<T>;
306
+ strategies: VigorParsePolicyStrategiesSchema<T>;
307
+ };
308
+ declare const VigorParsePolicyBase: {
309
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
310
+ readonly target: symbol & {
311
+ __brand: VigorBrand<"Core", "Symbol_Default">;
312
+ };
313
+ readonly settings: {
314
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
315
+ readonly raw: false;
316
+ readonly default: symbol & {
317
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
318
+ };
319
+ readonly maxRestarts: 3;
320
+ };
321
+ readonly middlewares: {
322
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
323
+ readonly before: [];
324
+ readonly after: [];
325
+ readonly onResult: [];
326
+ readonly onError: [];
327
+ };
328
+ readonly strategies: {
329
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
330
+ readonly funcs: VigorParseStrategyFunc[];
331
+ };
332
+ };
333
+
334
+ type VigorParseSchema<T extends VigorParseSchema<T>> = {
335
+ __brand: VigorBrand<"Parse", "Schema">;
336
+ policy: VigorParsePolicySchema<T>;
337
+ context: VigorParseContextSchema<T>;
338
+ };
339
+ declare const VigorParseBase: {
340
+ readonly __brand: VigorBrand<"Parse", "Schema">;
341
+ readonly policy: {
342
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
343
+ readonly target: symbol & {
344
+ __brand: VigorBrand<"Core", "Symbol_Default">;
345
+ };
346
+ readonly settings: {
347
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
348
+ readonly raw: false;
349
+ readonly default: symbol & {
350
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
351
+ };
352
+ readonly maxRestarts: 3;
353
+ };
354
+ readonly middlewares: {
355
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
356
+ readonly before: [];
357
+ readonly after: [];
358
+ readonly onResult: [];
359
+ readonly onError: [];
360
+ };
361
+ readonly strategies: {
362
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
363
+ readonly funcs: VigorParseStrategyFunc[];
364
+ };
365
+ };
366
+ readonly context: {
367
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
368
+ readonly result: symbol & {
369
+ __brand: VigorBrand<"Core", "Symbol_Default">;
370
+ };
371
+ readonly error: symbol & {
372
+ __brand: VigorBrand<"Core", "Symbol_Default">;
373
+ };
374
+ readonly response: symbol & {
375
+ __brand: VigorBrand<"Core", "Symbol_Default">;
376
+ };
377
+ readonly flags: {
378
+ readonly overrided: false;
379
+ readonly restarted: false;
380
+ };
381
+ readonly record: {};
382
+ readonly policy: {
383
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
384
+ readonly target: symbol & {
385
+ __brand: VigorBrand<"Core", "Symbol_Default">;
386
+ };
387
+ readonly settings: {
388
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
389
+ readonly raw: false;
390
+ readonly default: symbol & {
391
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
392
+ };
393
+ readonly maxRestarts: 3;
394
+ };
395
+ readonly middlewares: {
396
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
397
+ readonly before: [];
398
+ readonly after: [];
399
+ readonly onResult: [];
400
+ readonly onError: [];
401
+ };
402
+ readonly strategies: {
403
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
404
+ readonly funcs: VigorParseStrategyFunc[];
405
+ };
406
+ };
407
+ };
408
+ };
409
+ /**
410
+ * Immutable builder that parses an HTTP response into a result value,
411
+ * trying each configured strategy in sequence with an optional middleware
412
+ * pipeline and restart-on-failure support.
413
+ */
414
+ declare class VigorParse<T extends VigorParseSchema<T> = typeof VigorParseBase> extends VigorStatus<VigorParseSchema<T>, T, VigorParseTypeLambda> {
415
+ constructor(config?: T);
416
+ protected _create<C>(config: C): VigorApply<VigorParseTypeLambda, C>;
417
+ /** Sets the `Response` object to parse. */
418
+ target<const N extends VigorParseSchema<T>["policy"]["target"]>(response: N): VigorParse<VigorParseIn<VigorDeepMerge<T, {
419
+ readonly policy: {
420
+ readonly target: N;
421
+ };
422
+ }>>>;
423
+ /** Configures the parse policy's general settings. */
424
+ settings<const N extends VigorDeepPartial<VigorParsePolicySettingsSchema<T>>, R extends VigorParseSchema<any>>(input: N | ((s: VigorParsePolicySettings<T>) => VigorParsePolicySettings<R>) | VigorParsePolicySettings<R>): VigorParse<VigorParseIn<VigorDeepMerge<T, {
425
+ readonly policy: {
426
+ readonly settings: VigorParsePolicySettingsSchema<any>;
427
+ };
428
+ }>>>;
429
+ /** Configures the parse policy's middleware pipeline. */
430
+ middlewares<const N extends VigorDeepPartial<VigorParsePolicyMiddlewaresSchema<T>>, R extends VigorParseSchema<any>>(input: N | ((s: VigorParsePolicyMiddlewares<T>) => VigorParsePolicyMiddlewares<R>) | VigorParsePolicyMiddlewares<R>): VigorParse<VigorParseIn<VigorDeepMerge<T, {
431
+ readonly policy: {
432
+ readonly middlewares: VigorParsePolicyMiddlewaresSchema<any>;
433
+ };
434
+ }>>>;
435
+ /** Configures the parse policy's fallback chain of parsing strategies. */
436
+ strategies<const N extends VigorDeepPartial<VigorParsePolicyStrategiesSchema<T>>, R extends VigorParseSchema<any>>(input: N | ((s: VigorParsePolicyStrategies<T>) => VigorParsePolicyStrategies<R>) | VigorParsePolicyStrategies<R>): VigorParse<VigorParseIn<VigorDeepMerge<T, {
437
+ readonly policy: {
438
+ readonly strategies: VigorParsePolicyStrategiesSchema<any>;
439
+ };
440
+ }>>>;
441
+ /** Runs parsing and returns the result directly, throwing on final failure. */
442
+ request<R = T["context"]["result"]>(): Promise<R>;
443
+ /** Runs parsing and returns a result/error envelope instead of throwing. */
444
+ requestVerbose<R = T["context"]["result"]>(): Promise<{
445
+ success: false;
446
+ data: null;
447
+ error: unknown;
448
+ } | {
449
+ success: true;
450
+ data: R;
451
+ error: null;
452
+ }>;
453
+ /** Internal execution loop implementing the strategy fallback and restart handling. */
454
+ private requestRuntime;
455
+ }
456
+
457
+ type VigorParseIn<T> = T extends VigorParseSchema<any> ? T : never;
458
+ interface VigorParseTypeLambda extends VigorTypeLambda {
459
+ readonly Target: VigorParse<VigorParseIn<this["In"]>>;
460
+ }
461
+ interface VigorParsePolicySettingsTypeLambda extends VigorTypeLambda {
462
+ readonly Target: VigorParsePolicySettings<VigorParseIn<this["In"]>>;
463
+ }
464
+ interface VigorParsePolicyMiddlewaresTypeLambda extends VigorTypeLambda {
465
+ readonly Target: VigorParsePolicyMiddlewares<VigorParseIn<this["In"]>>;
466
+ }
467
+ interface VigorParsePolicyStrategiesTypeLambda extends VigorTypeLambda {
468
+ readonly Target: VigorParsePolicyStrategies<VigorParseIn<this["In"]>>;
469
+ }
470
+
471
+ type VigorParseStrategyFunc = (response: Response) => Promise<any>;
472
+ type VigorParsePolicyStrategiesSchema<T extends VigorParseSchema<T>> = {
473
+ __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
474
+ funcs: Array<VigorParseStrategyFunc>;
475
+ };
476
+ declare const VigorParsePolicyStrategiesBase: {
477
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
478
+ readonly funcs: VigorParseStrategyFunc[];
479
+ };
480
+ /** Parses a response by matching its `Content-Type` header against a known parser table. */
481
+ declare const VigorParseContentTypeStrategy: VigorParseStrategyFunc;
482
+ /** Parses a response by trying a sequence of body-reading methods until one succeeds. */
483
+ declare const VigorParseSniffStrategy: VigorParseStrategyFunc;
484
+ /** Immutable builder for a parse policy's fallback chain of parsing strategies. */
485
+ declare class VigorParsePolicyStrategies<T extends VigorParseSchema<T> = typeof VigorParseBase> extends VigorStatus<VigorParseSchema<any>, T, VigorParsePolicyStrategiesTypeLambda> {
486
+ constructor(config?: T);
487
+ protected _create<C>(config: C): VigorApply<VigorParsePolicyStrategiesTypeLambda, C>;
488
+ /**
489
+ * Adds strategy functions to the fallback chain.
490
+ *
491
+ * @param replace - When `true`, replaces the existing chain instead of
492
+ * appending to it (the default is to concat, since strategies are
493
+ * tried in sequence as a fallback chain).
494
+ */
495
+ private _set;
496
+ /** Adds the content-type based parsing strategy. */
497
+ contentType(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
498
+ readonly policy: {
499
+ readonly strategies: {
500
+ readonly funcs: VigorParseStrategyFunc[];
501
+ };
502
+ };
503
+ }>>>;
504
+ /** Adds the sniffing (try-each-method) parsing strategy. */
505
+ sniff(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
506
+ readonly policy: {
507
+ readonly strategies: {
508
+ readonly funcs: VigorParseStrategyFunc[];
509
+ };
510
+ };
511
+ }>>>;
512
+ /** Adds a strategy that always parses the response as JSON. */
513
+ json(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
514
+ readonly policy: {
515
+ readonly strategies: {
516
+ readonly funcs: VigorParseStrategyFunc[];
517
+ };
518
+ };
519
+ }>>>;
520
+ /** Adds a strategy that always parses the response as text. */
521
+ text(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
522
+ readonly policy: {
523
+ readonly strategies: {
524
+ readonly funcs: VigorParseStrategyFunc[];
525
+ };
526
+ };
527
+ }>>>;
528
+ /** Adds a strategy that always parses the response as an `ArrayBuffer`. */
529
+ arrayBuffer(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
530
+ readonly policy: {
531
+ readonly strategies: {
532
+ readonly funcs: VigorParseStrategyFunc[];
533
+ };
534
+ };
535
+ }>>>;
536
+ /** Adds a strategy that always parses the response as a `Blob`. */
537
+ blob(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
538
+ readonly policy: {
539
+ readonly strategies: {
540
+ readonly funcs: VigorParseStrategyFunc[];
541
+ };
542
+ };
543
+ }>>>;
544
+ /** Adds a strategy that always parses the response as a `Uint8Array`. */
545
+ bytes(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
546
+ readonly policy: {
547
+ readonly strategies: {
548
+ readonly funcs: VigorParseStrategyFunc[];
549
+ };
550
+ };
551
+ }>>>;
552
+ /** Adds a strategy that always parses the response as `FormData`. */
553
+ formData(replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
554
+ readonly policy: {
555
+ readonly strategies: {
556
+ readonly funcs: VigorParseStrategyFunc[];
557
+ };
558
+ };
559
+ }>>>;
560
+ /** Adds a user-supplied custom parsing strategy. */
561
+ custom<const N extends VigorParseStrategyFunc>(func: N, replace?: boolean): VigorParsePolicyStrategies<VigorParseIn<VigorDeepMerge<T, {
562
+ readonly policy: {
563
+ readonly strategies: {
564
+ readonly funcs: VigorParseStrategyFunc[];
565
+ };
566
+ };
567
+ }>>>;
568
+ }
569
+
570
+ type VigorRetryPolicyMiddlewaresSchema<T extends VigorRetrySchema<T>> = {
571
+ __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
572
+ before: (VigorRetryPolicyMiddlewaresFluent<T>["before"] | VigorRetryPolicyMiddlewaresIntercept<T>["before"])[];
573
+ after: (VigorRetryPolicyMiddlewaresFluent<T>["after"] | VigorRetryPolicyMiddlewaresIntercept<T>["after"])[];
574
+ onResult: (VigorRetryPolicyMiddlewaresFluent<T>["onResult"] | VigorRetryPolicyMiddlewaresIntercept<T>["onResult"])[];
575
+ retryIf: (VigorRetryPolicyMiddlewaresFluent<T>["retryIf"] | VigorRetryPolicyMiddlewaresIntercept<T>["retryIf"])[];
576
+ onRetry: (VigorRetryPolicyMiddlewaresFluent<T>["onRetry"] | VigorRetryPolicyMiddlewaresIntercept<T>["onRetry"])[];
577
+ onError: (VigorRetryPolicyMiddlewaresFluent<T>["onError"] | VigorRetryPolicyMiddlewaresIntercept<T>["onError"])[];
578
+ };
579
+ declare const VigorRetryPolicyMiddlewaresBase: {
580
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
581
+ readonly before: [];
582
+ readonly after: [];
583
+ readonly onResult: [];
584
+ readonly retryIf: [];
585
+ readonly onRetry: [];
586
+ readonly onError: [];
587
+ };
588
+ type VigorRetryPolicyMiddlewaresFluent<T extends VigorRetrySchema<T>> = {
589
+ __brand: VigorBrand<"Retry", "Policy<Middlewares<Fluent<Schema">;
590
+ before: {
591
+ _mode: "fluent";
592
+ func: (ctx: T["context"]) => void;
593
+ };
594
+ after: {
595
+ _mode: "fluent";
596
+ func: (ctx: T["context"]) => void;
597
+ };
598
+ onResult: {
599
+ _mode: "fluent";
600
+ func: (res: T["context"]["result"]) => VigorRetrySchema<any>["context"]["result"];
601
+ };
602
+ retryIf: {
603
+ _mode: "fluent";
604
+ func: (err: T["context"]["error"]) => VigorRetrySchema<any>["context"]["flags"]["doRetry"];
605
+ };
606
+ onRetry: {
607
+ _mode: "fluent";
608
+ func: (err: T["context"]["error"]) => void;
609
+ };
610
+ onError: {
611
+ _mode: "fluent";
612
+ func: (err: T["context"]["error"]) => void;
613
+ };
614
+ };
615
+ type VigorRetryPolicyMiddlewaresApi<T extends VigorRetrySchema<T>> = {
616
+ setResult: (res: VigorRetrySchema<any>["context"]["result"]) => void;
617
+ throwError: (err: VigorRetrySchema<any>["context"]["error"]) => void;
618
+ abort: (err: VigorRetrySchema<any>["context"]["error"]) => void;
619
+ breakRetry: (err: VigorRetrySchema<any>["context"]["error"]) => void;
620
+ proceedRetry: () => void;
621
+ cancelRetry: () => void;
622
+ setDelay: (num: VigorRetrySchema<any>["context"]["system"]["delay"]) => void;
623
+ proceedRestart: () => void;
624
+ cancelRestart: () => void;
625
+ };
626
+ type VigorRetryPolicyMiddlewaresIntercept<T extends VigorRetrySchema<T>> = {
627
+ __brand: VigorBrand<"Retry", "Policy<Middlewares<Intercept<Schema">;
628
+ before: {
629
+ _mode: "intercept";
630
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "abort" | "throwError" | "breakRetry">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
631
+ };
632
+ after: {
633
+ _mode: "intercept";
634
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "throwError">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
635
+ };
636
+ onResult: {
637
+ _mode: "intercept";
638
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "setResult" | "throwError">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
639
+ };
640
+ retryIf: {
641
+ _mode: "intercept";
642
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "proceedRetry" | "cancelRetry">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
643
+ };
644
+ onRetry: {
645
+ _mode: "intercept";
646
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "throwError" | "setDelay">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
647
+ };
648
+ onError: {
649
+ _mode: "intercept";
650
+ func: (ctx: T["context"], api: Pick<VigorRetryPolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorRetrySchema<any>["context"] | Promise<VigorRetrySchema<any>["context"]>;
651
+ };
652
+ };
653
+ /**
654
+ * Immutable builder for a retry policy's middleware pipeline (`before`,
655
+ * `after`, `onResult`, `retryIf`, `onRetry`, `onError`). Each stage accepts
656
+ * either "fluent" middleware (returns a plain value merged into the
657
+ * context) or "intercept" middleware (receives an explicit API to mutate
658
+ * control flow).
659
+ */
660
+ declare class VigorRetryPolicyMiddlewares<T extends VigorRetrySchema<T> = typeof VigorRetryBase> extends VigorStatus<VigorRetrySchema<any>, T, VigorRetryPolicyMiddlewaresTypeLambda> {
661
+ constructor(config?: T);
662
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, C>;
663
+ /** Registers a middleware that runs before the retried target is invoked. */
664
+ before<const N extends VigorRetryPolicyMiddlewaresFluent<any>["before"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
665
+ policy: {
666
+ middlewares: {
667
+ before: [{
668
+ _mode: "fluent";
669
+ func: N;
670
+ }];
671
+ };
672
+ };
673
+ }>>;
674
+ before<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["before"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
675
+ policy: {
676
+ middlewares: {
677
+ before: [{
678
+ _mode: "intercept";
679
+ func: N;
680
+ }];
681
+ };
682
+ };
683
+ }>>;
684
+ /** Registers a middleware that runs after the retried target settles. */
685
+ after<const N extends VigorRetryPolicyMiddlewaresFluent<any>["after"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
686
+ policy: {
687
+ middlewares: {
688
+ after: [{
689
+ _mode: "fluent";
690
+ func: N;
691
+ }];
692
+ };
693
+ };
694
+ }>>;
695
+ after<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["after"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
696
+ policy: {
697
+ middlewares: {
698
+ after: [{
699
+ _mode: "intercept";
700
+ func: N;
701
+ }];
702
+ };
703
+ };
704
+ }>>;
705
+ /** Registers a middleware to transform or validate the retry's result. */
706
+ onResult<const N extends VigorRetryPolicyMiddlewaresFluent<any>["onResult"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
707
+ policy: {
708
+ middlewares: {
709
+ onResult: [{
710
+ _mode: "fluent";
711
+ func: N;
712
+ }];
713
+ };
714
+ };
715
+ }>>;
716
+ onResult<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["onResult"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
717
+ policy: {
718
+ middlewares: {
719
+ onResult: [{
720
+ _mode: "intercept";
721
+ func: N;
722
+ }];
723
+ };
724
+ };
725
+ }>>;
726
+ /** Registers a middleware that decides whether a failed attempt should be retried. */
727
+ retryIf<const N extends VigorRetryPolicyMiddlewaresFluent<any>["retryIf"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
728
+ policy: {
729
+ middlewares: {
730
+ retryIf: [{
731
+ _mode: "fluent";
732
+ func: N;
733
+ }];
734
+ };
735
+ };
736
+ }>>;
737
+ retryIf<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["retryIf"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
738
+ policy: {
739
+ middlewares: {
740
+ retryIf: [{
741
+ _mode: "intercept";
742
+ func: N;
743
+ }];
744
+ };
745
+ };
746
+ }>>;
747
+ /** Registers a middleware invoked right before a retry attempt is scheduled. */
748
+ onRetry<const N extends VigorRetryPolicyMiddlewaresFluent<any>["onRetry"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
749
+ policy: {
750
+ middlewares: {
751
+ onRetry: [{
752
+ _mode: "fluent";
753
+ func: N;
754
+ }];
755
+ };
756
+ };
757
+ }>>;
758
+ onRetry<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["onRetry"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
759
+ policy: {
760
+ middlewares: {
761
+ onRetry: [{
762
+ _mode: "intercept";
763
+ func: N;
764
+ }];
765
+ };
766
+ };
767
+ }>>;
768
+ /** Registers a middleware invoked when retries/restarts are exhausted. */
769
+ onError<const N extends VigorRetryPolicyMiddlewaresFluent<any>["onError"]["func"]>(type: "fluent", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
770
+ policy: {
771
+ middlewares: {
772
+ onError: [{
773
+ _mode: "fluent";
774
+ func: N;
775
+ }];
776
+ };
777
+ };
778
+ }>>;
779
+ onError<const N extends VigorRetryPolicyMiddlewaresIntercept<any>["onError"]["func"]>(type: "intercept", func: N): VigorApply<VigorRetryPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
780
+ policy: {
781
+ middlewares: {
782
+ onError: [{
783
+ _mode: "intercept";
784
+ func: N;
785
+ }];
786
+ };
787
+ };
788
+ }>>;
789
+ }
790
+ type VigorRetryPipeInitialContext<T extends VigorRetrySchema<T>, R = VigorReturnType<T["policy"]["target"]>> = VigorDeepMerge<Omit<T["context"], "result">, {
791
+ result: R;
792
+ }>;
793
+ type VigorRetryPipeStepVoid<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
794
+ _mode: "intercept";
795
+ func: (...args: any[]) => infer Ret;
796
+ } ? VigorRetryPipeStepVoid<Ret, Tail> : VigorRetryPipeStepVoid<Ctx, Tail> : Ctx;
797
+ type VigorRetryPipeStepResult<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
798
+ _mode: "intercept";
799
+ func: (...args: any[]) => infer Ret;
800
+ } ? VigorRetryPipeStepResult<Ret, Tail> : Head extends {
801
+ _mode: "fluent";
802
+ func: (...args: any[]) => infer FR;
803
+ } ? VigorRetryPipeStepResult<VigorDeepMerge<Ctx, {
804
+ result: FR;
805
+ }>, Tail> : VigorRetryPipeStepResult<Ctx, Tail> : Ctx;
806
+ type VigorRetryPipeStepRetryIf<Ctx, Arr> = Arr extends [infer Head, ...infer Tail] ? Head extends {
807
+ _mode: "intercept";
808
+ func: (...args: any[]) => infer Ret;
809
+ } ? VigorRetryPipeStepRetryIf<Ret, Tail> : Head extends {
810
+ _mode: "fluent";
811
+ func: (...args: any[]) => infer FR;
812
+ } ? VigorRetryPipeStepRetryIf<VigorDeepMerge<Ctx, {
813
+ flags: {
814
+ doRetry: FR;
815
+ };
816
+ }>, Tail> : VigorRetryPipeStepRetryIf<Ctx, Tail> : Ctx;
817
+ 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"]>;
818
+ type VigorRetryPipeResult<T extends VigorRetrySchema<T>> = VigorRetryPolicyMiddlewaresPipe<T> extends {
819
+ result: infer R;
820
+ } ? R : never;
821
+
822
+ type VigorRetryContextSchema<T extends VigorRetrySchema<T>> = {
823
+ __brand: VigorBrand<"Retry", "Context<Schema">;
824
+ result: VigorRetryPipeResult<T> | VigorDefaultType;
825
+ error: unknown;
826
+ system: {
827
+ delay: number | VigorDefaultType;
828
+ attempt: number;
829
+ };
830
+ flags: {
831
+ doRetry: boolean;
832
+ doRestart: boolean;
833
+ brokeRetry: boolean;
834
+ overridden: boolean;
835
+ };
836
+ record: Record<string, any>;
837
+ policy: T["policy"];
838
+ };
839
+
840
+ type VigorRetryPolicySettingsSchema<T extends VigorRetrySchema<T>> = {
841
+ __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
842
+ default: ((ctx: T["context"]) => any | Promise<any>) | VigorEmptyType;
843
+ maxAttempts: number;
844
+ maxRestarts: number;
845
+ timeout: number;
846
+ };
847
+ declare const VigorRetryPolicySettingsBase: {
848
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
849
+ readonly default: symbol & {
850
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
851
+ };
852
+ readonly maxAttempts: 5;
853
+ readonly maxRestarts: 3;
854
+ readonly timeout: 20000;
855
+ };
856
+ /** Immutable builder for a retry policy's general settings. */
857
+ declare class VigorRetryPolicySettings<T extends VigorRetrySchema<T> = typeof VigorRetryBase> extends VigorStatus<VigorRetrySchema<any>, T, VigorRetryPolicySettingsTypeLambda> {
858
+ constructor(config?: T);
859
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicySettingsTypeLambda, C>;
860
+ /** Sets the fallback value/factory used when the target ultimately fails. */
861
+ default<const N extends VigorExcludeEmpty<VigorRetrySchema<any>["policy"]["settings"]["default"]>>(func: N): VigorRetryPolicySettings<VigorRetryIn<VigorDeepMerge<T, {
862
+ readonly policy: {
863
+ readonly settings: {
864
+ readonly default: N;
865
+ };
866
+ };
867
+ }>>>;
868
+ /** Sets the maximum number of retry attempts before giving up. */
869
+ maxAttempts<const N extends VigorRetrySchema<any>["policy"]["settings"]["maxAttempts"]>(num: N): VigorRetryPolicySettings<VigorRetryIn<VigorDeepMerge<T, {
870
+ readonly policy: {
871
+ readonly settings: {
872
+ readonly maxAttempts: N;
873
+ };
874
+ };
875
+ }>>>;
876
+ /** Sets the maximum number of full restarts allowed. */
877
+ maxRestarts<const N extends VigorRetrySchema<any>["policy"]["settings"]["maxRestarts"]>(num: N): VigorRetryPolicySettings<VigorRetryIn<VigorDeepMerge<T, {
878
+ readonly policy: {
879
+ readonly settings: {
880
+ readonly maxRestarts: N;
881
+ };
882
+ };
883
+ }>>>;
884
+ /** Sets the timeout, in milliseconds, for a single attempt. */
885
+ timeout<const N extends VigorRetrySchema<any>["policy"]["settings"]["timeout"]>(num: N): VigorRetryPolicySettings<VigorRetryIn<VigorDeepMerge<T, {
886
+ readonly policy: {
887
+ readonly settings: {
888
+ readonly timeout: N;
889
+ };
890
+ };
891
+ }>>>;
892
+ }
893
+
894
+ type VigorRetryPolicySchema<T extends VigorRetrySchema<T>> = {
895
+ __brand: VigorBrand<"Retry", "Policy<Schema">;
896
+ target: ((signal: AbortSignal) => any | Promise<any>) | VigorEmptyType;
897
+ abortSignals: AbortSignal[];
898
+ settings: VigorRetryPolicySettingsSchema<T>;
899
+ middlewares: VigorRetryPolicyMiddlewaresSchema<T>;
900
+ algorithms: VigorRetryPolicyAlgorithmsSchema<T>;
901
+ };
902
+ declare const VigorRetryPolicyBase: {
903
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
904
+ readonly target: symbol & {
905
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
906
+ };
907
+ readonly abortSignals: [];
908
+ readonly settings: {
909
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
910
+ readonly default: symbol & {
911
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
912
+ };
913
+ readonly maxAttempts: 5;
914
+ readonly maxRestarts: 3;
915
+ readonly timeout: 20000;
916
+ };
917
+ readonly middlewares: {
918
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
919
+ readonly before: [];
920
+ readonly after: [];
921
+ readonly onResult: [];
922
+ readonly retryIf: [];
923
+ readonly onRetry: [];
924
+ readonly onError: [];
925
+ };
926
+ readonly algorithms: {
927
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
928
+ readonly _tag: "constant";
929
+ readonly jitter: 1000;
930
+ readonly interval: 2000;
931
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
932
+ };
933
+ };
934
+
935
+ type VigorRetrySchema<T extends VigorRetrySchema<T>> = {
936
+ __brand: VigorBrand<"Retry", "Schema">;
937
+ policy: VigorRetryPolicySchema<T>;
938
+ context: VigorRetryContextSchema<T>;
939
+ };
940
+ declare const VigorRetryBase: {
941
+ readonly __brand: VigorBrand<"Retry", "Schema">;
942
+ readonly policy: {
943
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
944
+ readonly target: symbol & {
945
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
946
+ };
947
+ readonly abortSignals: [];
948
+ readonly settings: {
949
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
950
+ readonly default: symbol & {
951
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
952
+ };
953
+ readonly maxAttempts: 5;
954
+ readonly maxRestarts: 3;
955
+ readonly timeout: 20000;
956
+ };
957
+ readonly middlewares: {
958
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
959
+ readonly before: [];
960
+ readonly after: [];
961
+ readonly onResult: [];
962
+ readonly retryIf: [];
963
+ readonly onRetry: [];
964
+ readonly onError: [];
965
+ };
966
+ readonly algorithms: {
967
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
968
+ readonly _tag: "constant";
969
+ readonly jitter: 1000;
970
+ readonly interval: 2000;
971
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
972
+ };
973
+ };
974
+ readonly context: {
975
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
976
+ readonly result: symbol & {
977
+ __brand: VigorBrand<"Core", "Symbol_Default">;
978
+ };
979
+ readonly error: symbol & {
980
+ __brand: VigorBrand<"Core", "Symbol_Default">;
981
+ };
982
+ readonly system: {
983
+ readonly delay: symbol & {
984
+ __brand: VigorBrand<"Core", "Symbol_Default">;
985
+ };
986
+ readonly attempt: 0;
987
+ };
988
+ readonly flags: {
989
+ readonly doRetry: true;
990
+ readonly doRestart: false;
991
+ readonly brokeRetry: false;
992
+ readonly overridden: false;
993
+ };
994
+ readonly record: {};
995
+ readonly policy: {
996
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
997
+ readonly target: symbol & {
998
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
999
+ };
1000
+ readonly abortSignals: [];
1001
+ readonly settings: {
1002
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
1003
+ readonly default: symbol & {
1004
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1005
+ };
1006
+ readonly maxAttempts: 5;
1007
+ readonly maxRestarts: 3;
1008
+ readonly timeout: 20000;
1009
+ };
1010
+ readonly middlewares: {
1011
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
1012
+ readonly before: [];
1013
+ readonly after: [];
1014
+ readonly onResult: [];
1015
+ readonly retryIf: [];
1016
+ readonly onRetry: [];
1017
+ readonly onError: [];
1018
+ };
1019
+ readonly algorithms: {
1020
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1021
+ readonly _tag: "constant";
1022
+ readonly jitter: 1000;
1023
+ readonly interval: 2000;
1024
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1025
+ };
1026
+ };
1027
+ };
1028
+ };
1029
+ /**
1030
+ * Immutable builder that executes a target function with retry, restart,
1031
+ * timeout, and abort support, driven by a configurable delay algorithm and
1032
+ * middleware pipeline.
1033
+ */
1034
+ declare class VigorRetry<T extends VigorRetrySchema<T> = typeof VigorRetryBase> extends VigorStatus<VigorRetrySchema<T>, T, VigorRetryTypeLambda> {
1035
+ constructor(config?: T);
1036
+ protected _create<C>(config: C): VigorApply<VigorRetryTypeLambda, C>;
1037
+ /** Sets the target function to invoke, with retry/timeout applied. */
1038
+ target<const N extends VigorExcludeEmpty<VigorRetrySchema<T>["policy"]["target"]>>(func: N): VigorRetry<VigorRetryIn<VigorDeepMerge<T, {
1039
+ readonly policy: {
1040
+ readonly target: N;
1041
+ };
1042
+ }>>>;
1043
+ /** Sets external abort signals that, when aborted, stop retrying. */
1044
+ abortSignals<const N extends VigorRetrySchema<T>["policy"]["abortSignals"]>(...sig: N): VigorRetry<VigorRetryIn<VigorDeepMerge<T, {
1045
+ readonly policy: {
1046
+ readonly abortSignals: N;
1047
+ };
1048
+ }>>>;
1049
+ /** Configures the retry policy's general settings (max attempts, timeout, etc). */
1050
+ settings<const N extends VigorDeepPartial<VigorRetryPolicySettingsSchema<T>>, R extends VigorRetrySchema<any>>(input: N | ((s: VigorRetryPolicySettings<T>) => VigorRetryPolicySettings<R>) | VigorRetryPolicySettings<R>): VigorRetry<VigorRetryIn<VigorDeepMerge<T, {
1051
+ readonly policy: {
1052
+ readonly settings: VigorRetryPolicySettingsSchema<any>;
1053
+ };
1054
+ }>>>;
1055
+ /** Configures the retry policy's middleware pipeline. */
1056
+ middlewares<const N extends VigorDeepPartial<VigorRetryPolicyMiddlewaresSchema<T>>, R extends VigorRetrySchema<any>>(input: N | ((s: VigorRetryPolicyMiddlewares<T>) => VigorRetryPolicyMiddlewares<R>) | VigorRetryPolicyMiddlewares<R>): VigorRetry<VigorRetryIn<VigorDeepMerge<T, {
1057
+ readonly policy: {
1058
+ readonly middlewares: VigorRetryPolicyMiddlewaresSchema<any>;
1059
+ };
1060
+ }>>>;
1061
+ /** Configures the retry policy's delay algorithm. */
1062
+ algorithms<const N extends VigorDeepPartial<VigorRetryPolicyAlgorithmsSchema<T>>, R extends VigorRetrySchema<any>>(input: N | ((a: VigorRetryPolicyAlgorithms<T>) => VigorRetryPolicyAlgorithms<R> | VigorRetryPolicyAlgorithmsConstant<any>)): VigorRetry<VigorRetryIn<VigorDeepMerge<T, {
1063
+ readonly policy: {
1064
+ readonly algorithms: any;
1065
+ };
1066
+ }>>>;
1067
+ /** Runs the target and returns its result directly, throwing on final failure. */
1068
+ request<R = T["context"]["result"]>(): Promise<R>;
1069
+ /** Runs the target and returns a result/error envelope instead of throwing. */
1070
+ requestVerbose<R = T["context"]["result"]>(): Promise<{
1071
+ success: false;
1072
+ data: null;
1073
+ error: unknown;
1074
+ } | {
1075
+ success: true;
1076
+ data: R;
1077
+ error: null;
1078
+ }>;
1079
+ /** Internal execution loop implementing the attempt/retry/restart lifecycle. */
1080
+ private requestRuntime;
1081
+ }
1082
+
1083
+ type VigorRetryIn<T> = T extends VigorRetrySchema<any> ? T : never;
1084
+ type VigorRetryAlgorithmsConstantIn<T> = T extends VigorRetryPolicyAlgorithmsConstantSchema<any> ? T : never;
1085
+ type VigorRetryAlgorithmsLinearIn<T> = T extends VigorRetryPolicyAlgorithmsLinearSchema<any> ? T : never;
1086
+ type VigorRetryAlgorithmsBackoffIn<T> = T extends VigorRetryPolicyAlgorithmsBackoffSchema<any> ? T : never;
1087
+ type VigorRetryAlgorithmsCustomIn<T> = T extends VigorRetryPolicyAlgorithmsCustomSchema<any> ? T : never;
1088
+ interface VigorRetryTypeLambda extends VigorTypeLambda {
1089
+ readonly Target: VigorRetry<VigorRetryIn<this["In"]>>;
1090
+ }
1091
+ interface VigorRetryPolicySettingsTypeLambda extends VigorTypeLambda {
1092
+ readonly Target: VigorRetryPolicySettings<VigorRetryIn<this["In"]>>;
1093
+ }
1094
+ interface VigorRetryPolicyMiddlewaresTypeLambda extends VigorTypeLambda {
1095
+ readonly Target: VigorRetryPolicyMiddlewares<VigorRetryIn<this["In"]>>;
1096
+ }
1097
+ interface VigorRetryPolicyAlgorithmsTypeLambda extends VigorTypeLambda {
1098
+ readonly Target: VigorRetryPolicyAlgorithms<VigorRetryIn<this["In"]>>;
1099
+ }
1100
+ interface VigorRetryPolicyAlgorithmsConstantTypeLambda extends VigorTypeLambda {
1101
+ readonly Target: VigorRetryPolicyAlgorithmsConstant<VigorRetryAlgorithmsConstantIn<this["In"]>>;
1102
+ }
1103
+ interface VigorRetryPolicyAlgorithmsLinearTypeLambda extends VigorTypeLambda {
1104
+ readonly Target: VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<this["In"]>>;
1105
+ }
1106
+ interface VigorRetryPolicyAlgorithmsBackoffTypeLambda extends VigorTypeLambda {
1107
+ readonly Target: VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<this["In"]>>;
1108
+ }
1109
+ interface VigorRetryPolicyAlgorithmsCustomTypeLambda extends VigorTypeLambda {
1110
+ readonly Target: VigorRetryPolicyAlgorithmsCustom<VigorRetryAlgorithmsCustomIn<this["In"]>>;
1111
+ }
1112
+
1113
+ /** Returns a random offset in the range `[-jitter, +jitter]` to randomize a computed delay. */
1114
+ declare function VigorJitter(jitter: number): number;
1115
+ type VigorRetryPolicyAlgorithmsConstantSchema<T extends VigorRetryPolicyAlgorithmsConstantSchema<T>> = {
1116
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1117
+ _tag: "constant";
1118
+ jitter: number;
1119
+ interval: number;
1120
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<T>) => number;
1121
+ };
1122
+ declare const VigorRetryPolicyAlgorithmsConstantBase: {
1123
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1124
+ readonly _tag: "constant";
1125
+ readonly jitter: 1000;
1126
+ readonly interval: 2000;
1127
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1128
+ };
1129
+ /** Immutable builder for the constant-interval retry delay algorithm. */
1130
+ declare class VigorRetryPolicyAlgorithmsConstant<T extends VigorRetryPolicyAlgorithmsConstantSchema<T> = typeof VigorRetryPolicyAlgorithmsConstantBase> extends VigorStatus<VigorRetryPolicyAlgorithmsConstantSchema<any>, T, VigorRetryPolicyAlgorithmsConstantTypeLambda> {
1131
+ constructor(config?: T);
1132
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyAlgorithmsConstantTypeLambda, C>;
1133
+ /** Sets the amount of random jitter added to the computed delay. */
1134
+ jitter<const N extends VigorRetryPolicyAlgorithmsConstantSchema<any>["jitter"]>(num: N): VigorRetryPolicyAlgorithmsConstant<VigorRetryAlgorithmsConstantIn<VigorDeepMerge<T, {
1135
+ readonly jitter: N;
1136
+ }>>>;
1137
+ /** Sets the fixed delay interval, in milliseconds. */
1138
+ interval<const N extends VigorRetryPolicyAlgorithmsConstantSchema<any>["interval"]>(num: N): VigorRetryPolicyAlgorithmsConstant<VigorRetryAlgorithmsConstantIn<VigorDeepMerge<T, {
1139
+ readonly interval: N;
1140
+ }>>>;
1141
+ }
1142
+ type VigorRetryPolicyAlgorithmsLinearSchema<T extends VigorRetryPolicyAlgorithmsLinearSchema<T>> = {
1143
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Linear<Schema">;
1144
+ _tag: "linear";
1145
+ jitter: number;
1146
+ initial: number;
1147
+ increment: number;
1148
+ minDelay: number;
1149
+ maxDelay: number;
1150
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsLinearSchema<T>) => number;
1151
+ };
1152
+ declare const VigorRetryPolicyAlgorithmsLinearBase: {
1153
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Linear<Schema">;
1154
+ readonly _tag: "linear";
1155
+ readonly jitter: 1000;
1156
+ readonly initial: 500;
1157
+ readonly increment: 1000;
1158
+ readonly minDelay: 0;
1159
+ readonly maxDelay: 10000;
1160
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsLinearSchema<any>) => number;
1161
+ };
1162
+ /** Immutable builder for the linearly-increasing retry delay algorithm. */
1163
+ declare class VigorRetryPolicyAlgorithmsLinear<T extends VigorRetryPolicyAlgorithmsLinearSchema<T> = typeof VigorRetryPolicyAlgorithmsLinearBase> extends VigorStatus<VigorRetryPolicyAlgorithmsLinearSchema<any>, T, VigorRetryPolicyAlgorithmsLinearTypeLambda> {
1164
+ constructor(config?: T);
1165
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyAlgorithmsLinearTypeLambda, C>;
1166
+ /** Sets the amount of random jitter added to the computed delay. */
1167
+ jitter<const N extends VigorRetryPolicyAlgorithmsLinearSchema<any>["jitter"]>(num: N): VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<VigorDeepMerge<T, {
1168
+ readonly jitter: N;
1169
+ }>>>;
1170
+ /** Sets the initial delay, in milliseconds, before the first retry. */
1171
+ initial<const N extends VigorRetryPolicyAlgorithmsLinearSchema<any>["initial"]>(num: N): VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<VigorDeepMerge<T, {
1172
+ readonly initial: N;
1173
+ }>>>;
1174
+ /** Sets how much the delay grows, in milliseconds, per attempt. */
1175
+ increment<const N extends VigorRetryPolicyAlgorithmsLinearSchema<any>["increment"]>(num: N): VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<VigorDeepMerge<T, {
1176
+ readonly increment: N;
1177
+ }>>>;
1178
+ /** Sets the minimum allowed delay, in milliseconds. */
1179
+ minDelay<const N extends VigorRetryPolicyAlgorithmsLinearSchema<any>["minDelay"]>(num: N): VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<VigorDeepMerge<T, {
1180
+ readonly minDelay: N;
1181
+ }>>>;
1182
+ /** Sets the maximum allowed delay, in milliseconds. */
1183
+ maxDelay<const N extends VigorRetryPolicyAlgorithmsLinearSchema<any>["maxDelay"]>(num: N): VigorRetryPolicyAlgorithmsLinear<VigorRetryAlgorithmsLinearIn<VigorDeepMerge<T, {
1184
+ readonly maxDelay: N;
1185
+ }>>>;
1186
+ }
1187
+ type VigorRetryPolicyAlgorithmsBackoffSchema<T extends VigorRetryPolicyAlgorithmsBackoffSchema<T>> = {
1188
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Backoff<Schema">;
1189
+ _tag: "backoff";
1190
+ jitter: number;
1191
+ initial: number;
1192
+ multiplier: number;
1193
+ unit: number;
1194
+ minDelay: number;
1195
+ maxDelay: number;
1196
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsBackoffSchema<T>) => number;
1197
+ };
1198
+ declare const VigorRetryPolicyAlgorithmsBackoffBase: {
1199
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Backoff<Schema">;
1200
+ readonly _tag: "backoff";
1201
+ readonly jitter: 800;
1202
+ readonly initial: 0;
1203
+ readonly multiplier: 1.7;
1204
+ readonly unit: 1000;
1205
+ readonly minDelay: 500;
1206
+ readonly maxDelay: 10000;
1207
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsBackoffSchema<any>) => number;
1208
+ };
1209
+ /** Immutable builder for the exponential-backoff retry delay algorithm. */
1210
+ declare class VigorRetryPolicyAlgorithmsBackoff<T extends VigorRetryPolicyAlgorithmsBackoffSchema<T> = typeof VigorRetryPolicyAlgorithmsBackoffBase> extends VigorStatus<VigorRetryPolicyAlgorithmsBackoffSchema<any>, T, VigorRetryPolicyAlgorithmsBackoffTypeLambda> {
1211
+ constructor(config?: T);
1212
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyAlgorithmsBackoffTypeLambda, C>;
1213
+ /** Sets the amount of random jitter added to the computed delay. */
1214
+ jitter<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["jitter"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1215
+ readonly jitter: N;
1216
+ }>>>;
1217
+ /** Sets the initial delay, in milliseconds, before backoff growth is applied. */
1218
+ initial<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["initial"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1219
+ readonly initial: N;
1220
+ }>>>;
1221
+ /** Sets the exponential growth factor applied per attempt. */
1222
+ multiplier<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["multiplier"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1223
+ readonly multiplier: N;
1224
+ }>>>;
1225
+ /** Sets the base unit, in milliseconds, the multiplier is scaled by. */
1226
+ unit<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["unit"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1227
+ readonly unit: N;
1228
+ }>>>;
1229
+ /** Sets the minimum allowed delay, in milliseconds. */
1230
+ minDelay<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["minDelay"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1231
+ readonly minDelay: N;
1232
+ }>>>;
1233
+ /** Sets the maximum allowed delay, in milliseconds. */
1234
+ maxDelay<const N extends VigorRetryPolicyAlgorithmsBackoffSchema<any>["maxDelay"]>(num: N): VigorRetryPolicyAlgorithmsBackoff<VigorRetryAlgorithmsBackoffIn<VigorDeepMerge<T, {
1235
+ readonly maxDelay: N;
1236
+ }>>>;
1237
+ }
1238
+ type VigorRetryPolicyAlgorithmsCustomSchema<T extends VigorRetryPolicyAlgorithmsCustomSchema<T>> = {
1239
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Custom<Schema">;
1240
+ _tag: "custom";
1241
+ jitter: number;
1242
+ minDelay: number;
1243
+ maxDelay: number;
1244
+ target: ((att: number) => number) | VigorEmptyType;
1245
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsCustomSchema<T>) => number;
1246
+ };
1247
+ declare const VigorRetryPolicyAlgorithmsCustomBase: {
1248
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Custom<Schema">;
1249
+ readonly _tag: "custom";
1250
+ readonly jitter: 800;
1251
+ readonly minDelay: 500;
1252
+ readonly maxDelay: 10000;
1253
+ readonly target: symbol & {
1254
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1255
+ };
1256
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsCustomSchema<any>) => number;
1257
+ };
1258
+ /** Immutable builder for a user-supplied custom retry delay algorithm. */
1259
+ declare class VigorRetryPolicyAlgorithmsCustom<T extends VigorRetryPolicyAlgorithmsCustomSchema<T> = typeof VigorRetryPolicyAlgorithmsCustomBase> extends VigorStatus<VigorRetryPolicyAlgorithmsCustomSchema<any>, T, VigorRetryPolicyAlgorithmsCustomTypeLambda> {
1260
+ constructor(config?: T);
1261
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyAlgorithmsCustomTypeLambda, C>;
1262
+ /** Sets the amount of random jitter added to the computed delay. */
1263
+ jitter<const N extends VigorRetryPolicyAlgorithmsCustomSchema<any>["jitter"]>(num: N): VigorRetryPolicyAlgorithmsCustom<VigorRetryAlgorithmsCustomIn<VigorDeepMerge<T, {
1264
+ readonly jitter: N;
1265
+ }>>>;
1266
+ /** Sets the minimum allowed delay, in milliseconds. */
1267
+ minDelay<const N extends VigorRetryPolicyAlgorithmsCustomSchema<any>["minDelay"]>(num: N): VigorRetryPolicyAlgorithmsCustom<VigorRetryAlgorithmsCustomIn<VigorDeepMerge<T, {
1268
+ readonly minDelay: N;
1269
+ }>>>;
1270
+ /** Sets the maximum allowed delay, in milliseconds. */
1271
+ maxDelay<const N extends VigorRetryPolicyAlgorithmsCustomSchema<any>["maxDelay"]>(num: N): VigorRetryPolicyAlgorithmsCustom<VigorRetryAlgorithmsCustomIn<VigorDeepMerge<T, {
1272
+ readonly maxDelay: N;
1273
+ }>>>;
1274
+ /** Sets the user-supplied function computing the raw delay for an attempt. */
1275
+ target<const N extends VigorExcludeEmpty<VigorRetryPolicyAlgorithmsCustomSchema<any>["target"]>>(func: N): VigorRetryPolicyAlgorithmsCustom<VigorRetryAlgorithmsCustomIn<VigorDeepMerge<T, {
1276
+ readonly target: N;
1277
+ }>>>;
1278
+ }
1279
+ type VigorRetryPolicyAlgorithmsSchema<T extends VigorRetrySchema<T>> = (VigorRetryPolicyAlgorithmsConstantSchema<any> | VigorRetryPolicyAlgorithmsLinearSchema<any> | VigorRetryPolicyAlgorithmsBackoffSchema<any> | VigorRetryPolicyAlgorithmsCustomSchema<any>) & {
1280
+ _calculateDelay: (att: number, config: any) => number;
1281
+ };
1282
+ declare const VigorRetryPolicyAlgorithmsBase: {
1283
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1284
+ readonly _tag: "constant";
1285
+ readonly jitter: 1000;
1286
+ readonly interval: 2000;
1287
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1288
+ };
1289
+ /**
1290
+ * Immutable builder for selecting a retry policy's delay algorithm.
1291
+ *
1292
+ * Switching algorithms (`constant`/`linear`/`backoff`/`custom`) always
1293
+ * replaces the previous algorithm's config wholesale via the `"replace"`
1294
+ * merge strategy, since the different algorithms' fields are not
1295
+ * compatible with one another.
1296
+ */
1297
+ declare class VigorRetryPolicyAlgorithms<T extends VigorRetrySchema<T> = typeof VigorRetryBase> extends VigorStatus<VigorRetrySchema<any>, T, VigorRetryPolicyAlgorithmsTypeLambda> {
1298
+ constructor(config?: T);
1299
+ protected _create<C>(config: C): VigorApply<VigorRetryPolicyAlgorithmsTypeLambda, C>;
1300
+ /** Switches to the constant-interval delay algorithm. */
1301
+ constant<const N extends VigorDeepPartial<Omit<VigorRetryPolicyAlgorithmsConstantSchema<any>, "_tag" | "__brand">>>(input?: N): VigorRetryPolicyAlgorithms<VigorRetryIn<VigorDeepMerge<T, {
1302
+ readonly policy: {
1303
+ readonly algorithms: {
1304
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1305
+ _tag: "constant";
1306
+ jitter: 1000;
1307
+ interval: 2000;
1308
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1309
+ };
1310
+ };
1311
+ }>>>;
1312
+ /** Switches to the linearly-increasing delay algorithm. */
1313
+ linear<const N extends VigorDeepPartial<Omit<VigorRetryPolicyAlgorithmsLinearSchema<any>, "_tag" | "__brand">>>(input?: N): VigorRetryPolicyAlgorithms<VigorRetryIn<VigorDeepMerge<T, {
1314
+ readonly policy: {
1315
+ readonly algorithms: {
1316
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Linear<Schema">;
1317
+ _tag: "linear";
1318
+ jitter: 1000;
1319
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsLinearSchema<any>) => number;
1320
+ initial: 500;
1321
+ increment: 1000;
1322
+ minDelay: 0;
1323
+ maxDelay: 10000;
1324
+ };
1325
+ };
1326
+ }>>>;
1327
+ /** Switches to the exponential-backoff delay algorithm. */
1328
+ backoff<const N extends VigorDeepPartial<Omit<VigorRetryPolicyAlgorithmsBackoffSchema<any>, "_tag" | "__brand">>>(input?: N): VigorRetryPolicyAlgorithms<VigorRetryIn<VigorDeepMerge<T, {
1329
+ readonly policy: {
1330
+ readonly algorithms: {
1331
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Backoff<Schema">;
1332
+ _tag: "backoff";
1333
+ jitter: 800;
1334
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsBackoffSchema<any>) => number;
1335
+ initial: 0;
1336
+ minDelay: 500;
1337
+ maxDelay: 10000;
1338
+ unit: 1000;
1339
+ multiplier: 1.7;
1340
+ };
1341
+ };
1342
+ }>>>;
1343
+ /** Switches to a user-supplied custom delay algorithm. */
1344
+ custom<const N extends VigorDeepPartial<Omit<VigorRetryPolicyAlgorithmsCustomSchema<any>, "_tag" | "__brand">>>(input?: N): VigorRetryPolicyAlgorithms<VigorRetryIn<VigorDeepMerge<T, {
1345
+ readonly policy: {
1346
+ readonly algorithms: {
1347
+ target: symbol & {
1348
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1349
+ };
1350
+ __brand: VigorBrand<"Retry", "Policy<Algorithms<Custom<Schema">;
1351
+ _tag: "custom";
1352
+ jitter: 800;
1353
+ _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsCustomSchema<any>) => number;
1354
+ minDelay: 500;
1355
+ maxDelay: 10000;
1356
+ };
1357
+ };
1358
+ }>>>;
1359
+ }
1360
+
1361
+ type VigorAllPolicySettingsSchema<T extends VigorAllSchema<T>> = {
1362
+ __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1363
+ concurrency: number;
1364
+ onlySuccess: boolean;
1365
+ };
1366
+ declare const VigorAllPolicySettingsBase: {
1367
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1368
+ readonly concurrency: 5;
1369
+ readonly onlySuccess: false;
1370
+ };
1371
+ /** Immutable builder for an all-policy's general settings. */
1372
+ declare class VigorAllPolicySettings<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<any>, T, VigorAllPolicySettingsTypeLambda> {
1373
+ constructor(config?: T);
1374
+ protected _create<C>(config: C): VigorApply<VigorAllPolicySettingsTypeLambda, C>;
1375
+ /** Sets the maximum number of tasks run concurrently. */
1376
+ concurrency<const N extends VigorAllSchema<any>["policy"]["settings"]["concurrency"]>(num: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
1377
+ readonly policy: {
1378
+ readonly settings: {
1379
+ readonly concurrency: N;
1380
+ };
1381
+ };
1382
+ }>>>;
1383
+ /** When enabled, filters the final result down to only the tasks that succeeded. */
1384
+ onlySuccess<const N extends VigorAllSchema<any>["policy"]["settings"]["onlySuccess"]>(bool: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
1385
+ readonly policy: {
1386
+ readonly settings: {
1387
+ readonly onlySuccess: N;
1388
+ };
1389
+ };
1390
+ }>>>;
1391
+ }
1392
+
1393
+ type VigorAllTask = () => unknown | Promise<unknown>;
1394
+ type VigorAllPolicySchema<T extends VigorAllSchema<T>> = {
1395
+ __brand: VigorBrand<"All", "Policy<Schema">;
1396
+ target: VigorAllTask[];
1397
+ settings: VigorAllPolicySettingsSchema<T>;
1398
+ middlewares: VigorAllPolicyMiddlewaresSchema<T>;
1399
+ };
1400
+ declare const VigorAllPolicyBase: {
1401
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
1402
+ readonly target: VigorAllTask[];
1403
+ readonly settings: {
1404
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1405
+ readonly concurrency: 5;
1406
+ readonly onlySuccess: false;
1407
+ };
1408
+ readonly middlewares: {
1409
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
1410
+ readonly before: VigorAllEachMiddlewareFn[];
1411
+ readonly after: VigorAllEachMiddlewareFn[];
1412
+ readonly onError: VigorAllEachOnErrorFn[];
1413
+ };
1414
+ };
1415
+
1416
+ type VigorAllContextSchema<T extends VigorAllSchema<T>> = {
1417
+ __brand: VigorBrand<"All", "Context<Schema">;
1418
+ result: unknown[] | VigorDefaultType;
1419
+ policy: T["policy"];
1420
+ record: Record<string, any>;
1421
+ };
1422
+ type VigorAllEachContextSchema<T extends VigorAllSchema<T>> = {
1423
+ __brand: VigorBrand<"All", "EachContext<Schema">;
1424
+ result: unknown | VigorDefaultType;
1425
+ error: unknown;
1426
+ flags: {
1427
+ overrided: boolean;
1428
+ };
1429
+ record: Record<string, any>;
1430
+ };
1431
+
1432
+ type VigorAllSchema<T extends VigorAllSchema<T>> = {
1433
+ __brand: VigorBrand<"All", "Schema">;
1434
+ policy: VigorAllPolicySchema<T>;
1435
+ context: VigorAllContextSchema<T>;
1436
+ };
1437
+ declare const VigorAllBase: {
1438
+ readonly __brand: VigorBrand<"All", "Schema">;
1439
+ readonly policy: {
1440
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
1441
+ readonly target: VigorAllTask[];
1442
+ readonly settings: {
1443
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1444
+ readonly concurrency: 5;
1445
+ readonly onlySuccess: false;
1446
+ };
1447
+ readonly middlewares: {
1448
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
1449
+ readonly before: VigorAllEachMiddlewareFn[];
1450
+ readonly after: VigorAllEachMiddlewareFn[];
1451
+ readonly onError: VigorAllEachOnErrorFn[];
1452
+ };
1453
+ };
1454
+ readonly context: {
1455
+ readonly __brand: VigorBrand<"All", "Context<Schema">;
1456
+ readonly result: symbol & {
1457
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1458
+ };
1459
+ readonly policy: {
1460
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
1461
+ readonly target: VigorAllTask[];
1462
+ readonly settings: {
1463
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1464
+ readonly concurrency: 5;
1465
+ readonly onlySuccess: false;
1466
+ };
1467
+ readonly middlewares: {
1468
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
1469
+ readonly before: VigorAllEachMiddlewareFn[];
1470
+ readonly after: VigorAllEachMiddlewareFn[];
1471
+ readonly onError: VigorAllEachOnErrorFn[];
1472
+ };
1473
+ };
1474
+ readonly record: {};
1475
+ };
1476
+ };
1477
+ /**
1478
+ * Immutable builder that runs a list of independent tasks with bounded
1479
+ * concurrency, per-task middleware, and either an all-results or
1480
+ * only-successes result mode.
1481
+ */
1482
+ declare class VigorAll<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<T>, T, VigorAllTypeLambda> {
1483
+ constructor(config?: T);
1484
+ protected _create<C>(config: C): VigorApply<VigorAllTypeLambda, C>;
1485
+ /** Sets the list of tasks to run. */
1486
+ target<const N extends VigorAllTask[]>(...funcs: N): VigorAll<VigorAllIn<VigorDeepMerge<T, {
1487
+ readonly policy: {
1488
+ readonly target: N;
1489
+ };
1490
+ }>>>;
1491
+ /** Configures the all-policy's general settings (concurrency, onlySuccess). */
1492
+ settings<const N extends VigorDeepPartial<VigorAllPolicySettingsSchema<T>>, R extends VigorAllSchema<any>>(input: N | ((s: VigorAllPolicySettings<T>) => VigorAllPolicySettings<R>) | VigorAllPolicySettings<R>): VigorAll<VigorAllIn<VigorDeepMerge<T, {
1493
+ readonly policy: {
1494
+ readonly settings: VigorAllPolicySettingsSchema<any>;
1495
+ };
1496
+ }>>>;
1497
+ /** Configures the all-policy's per-task middleware pipeline. */
1498
+ middlewares<const N extends VigorDeepPartial<VigorAllPolicyMiddlewaresSchema<T>>, R extends VigorAllSchema<any>>(input: N | ((s: VigorAllPolicyMiddlewares<T>) => VigorAllPolicyMiddlewares<R>) | VigorAllPolicyMiddlewares<R>): VigorAll<VigorAllIn<VigorDeepMerge<T, {
1499
+ readonly policy: {
1500
+ readonly middlewares: VigorAllPolicyMiddlewaresSchema<any>;
1501
+ };
1502
+ }>>>;
1503
+ /** Runs a single task through the before/after/onError middleware pipeline. */
1504
+ private _runTask;
1505
+ /** Runs all tasks and returns the results array directly, throwing on final failure. */
1506
+ request<R extends unknown[] = unknown[]>(): Promise<R>;
1507
+ /** Runs all tasks and returns a result/error envelope instead of throwing. */
1508
+ requestVerbose<R extends unknown[] = unknown[]>(): Promise<{
1509
+ success: false;
1510
+ data: null;
1511
+ error: unknown;
1512
+ } | {
1513
+ success: true;
1514
+ data: R;
1515
+ error: null;
1516
+ }>;
1517
+ /** Internal execution loop implementing the bounded-concurrency worker pool. */
1518
+ private requestRuntime;
1519
+ }
1520
+
1521
+ type VigorAllIn<T> = T extends VigorAllSchema<any> ? T : never;
1522
+ interface VigorAllTypeLambda extends VigorTypeLambda {
1523
+ readonly Target: VigorAll<VigorAllIn<this["In"]>>;
1524
+ }
1525
+ interface VigorAllPolicySettingsTypeLambda extends VigorTypeLambda {
1526
+ readonly Target: VigorAllPolicySettings<VigorAllIn<this["In"]>>;
1527
+ }
1528
+ interface VigorAllPolicyMiddlewaresTypeLambda extends VigorTypeLambda {
1529
+ readonly Target: VigorAllPolicyMiddlewares<VigorAllIn<this["In"]>>;
1530
+ }
1531
+
1532
+ type VigorAllEachMiddlewareFn = (ctx: VigorAllEachContextSchema<any>) => void | Promise<void>;
1533
+ type VigorAllEachOnErrorFn = (ctx: VigorAllEachContextSchema<any>, api: {
1534
+ setResult: (r: unknown) => void;
1535
+ }) => void | Promise<void>;
1536
+ type VigorAllPolicyMiddlewaresSchema<T extends VigorAllSchema<T>> = {
1537
+ __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
1538
+ before: VigorAllEachMiddlewareFn[];
1539
+ after: VigorAllEachMiddlewareFn[];
1540
+ onError: VigorAllEachOnErrorFn[];
1541
+ };
1542
+ declare const VigorAllPolicyMiddlewaresBase: {
1543
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
1544
+ readonly before: VigorAllEachMiddlewareFn[];
1545
+ readonly after: VigorAllEachMiddlewareFn[];
1546
+ readonly onError: VigorAllEachOnErrorFn[];
1547
+ };
1548
+ /** Immutable builder for an all-policy's per-task middleware pipeline (`before`, `after`, `onError`). */
1549
+ declare class VigorAllPolicyMiddlewares<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<any>, T, VigorAllPolicyMiddlewaresTypeLambda> {
1550
+ constructor(config?: T);
1551
+ protected _create<C>(config: C): VigorApply<VigorAllPolicyMiddlewaresTypeLambda, C>;
1552
+ /** Registers a middleware that runs before each task is invoked. */
1553
+ before<const N extends VigorAllEachMiddlewareFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
1554
+ readonly policy: {
1555
+ readonly middlewares: {
1556
+ readonly before: readonly [N];
1557
+ };
1558
+ };
1559
+ }>>>;
1560
+ /** Registers a middleware that runs after each task settles successfully. */
1561
+ after<const N extends VigorAllEachMiddlewareFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
1562
+ readonly policy: {
1563
+ readonly middlewares: {
1564
+ readonly after: readonly [N];
1565
+ };
1566
+ };
1567
+ }>>>;
1568
+ /** Registers a middleware that runs when an individual task fails. */
1569
+ onError<const N extends VigorAllEachOnErrorFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
1570
+ readonly policy: {
1571
+ readonly middlewares: {
1572
+ readonly onError: readonly [N];
1573
+ };
1574
+ };
1575
+ }>>>;
1576
+ }
1577
+
1578
+ type VigorFetchPolicySettingsSchema<T extends VigorFetchSchema<T>> = {
1579
+ __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
1580
+ retryHeaders: string[];
1581
+ unretryStatus: number[];
1582
+ maxRestarts: number;
1583
+ default: ((ctx: T["context"]) => any | Promise<any>) | VigorEmptyType;
1584
+ };
1585
+ declare const VigorFetchPolicySettingsBase: {
1586
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
1587
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
1588
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
1589
+ readonly maxRestarts: 3;
1590
+ readonly default: symbol & {
1591
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1592
+ };
1593
+ };
1594
+ /** Immutable builder for a fetch policy's general settings. */
1595
+ declare class VigorFetchPolicySettings<T extends VigorFetchSchema<T> = typeof VigorFetchBase> extends VigorStatus<VigorFetchSchema<any>, T, VigorFetchPolicySettingsTypeLambda> {
1596
+ constructor(config?: T);
1597
+ protected _create<C>(config: C): VigorApply<VigorFetchPolicySettingsTypeLambda, C>;
1598
+ /** Sets response headers consulted to compute a server-suggested retry delay. */
1599
+ retryHeaders<const N extends VigorFetchSchema<any>["policy"]["settings"]["retryHeaders"]>(...strs: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
1600
+ readonly policy: {
1601
+ readonly settings: {
1602
+ readonly retryHeaders: N;
1603
+ };
1604
+ };
1605
+ }>>>;
1606
+ /** Sets HTTP status codes that should never be retried. */
1607
+ unretryStatus<const N extends VigorFetchSchema<any>["policy"]["settings"]["unretryStatus"]>(...nums: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
1608
+ readonly policy: {
1609
+ readonly settings: {
1610
+ readonly unretryStatus: N;
1611
+ };
1612
+ };
1613
+ }>>>;
1614
+ /** Sets the maximum number of full restarts allowed. */
1615
+ maxRestarts<const N extends VigorFetchSchema<any>["policy"]["settings"]["maxRestarts"]>(num: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
1616
+ readonly policy: {
1617
+ readonly settings: {
1618
+ readonly maxRestarts: N;
1619
+ };
1620
+ };
1621
+ }>>>;
1622
+ /** Sets the fallback value/factory used when the request ultimately fails. */
1623
+ default<const N extends VigorExcludeEmpty<VigorFetchSchema<any>["policy"]["settings"]["default"]>>(func: N): VigorFetchPolicySettings<VigorFetchIn<VigorDeepMerge<T, {
1624
+ readonly policy: {
1625
+ readonly settings: {
1626
+ readonly default: N;
1627
+ };
1628
+ };
1629
+ }>>>;
1630
+ }
1631
+
1632
+ type VigorFetchExtraOptions = Omit<RequestInit, "method" | "headers" | "body" | "signal">;
1633
+ type VigorFetchOptions = VigorFetchExtraOptions & {
1634
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE";
1635
+ headers: Record<string, string>;
1636
+ body?: BodyInit | null;
1637
+ signal?: AbortSignal;
1638
+ };
1639
+ type VigorFetchContextSchema<T extends VigorFetchSchema<T>> = {
1640
+ __brand: VigorBrand<"Fetch", "Context<Schema">;
1641
+ href: string;
1642
+ response: Response | VigorDefaultType;
1643
+ result: unknown | VigorDefaultType;
1644
+ error: unknown;
1645
+ options: VigorFetchOptions | VigorDefaultType;
1646
+ flags: {
1647
+ overrided: boolean;
1648
+ restarted: boolean;
1649
+ };
1650
+ record: Record<string, any>;
1651
+ policy: T["policy"];
1652
+ };
1653
+
1654
+ type VigorFetchPolicyMiddlewaresSchema<T extends VigorFetchSchema<T>> = {
1655
+ __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
1656
+ before: (VigorFetchPolicyMiddlewaresFluent<T>["before"] | VigorFetchPolicyMiddlewaresIntercept<T>["before"])[];
1657
+ after: (VigorFetchPolicyMiddlewaresFluent<T>["after"] | VigorFetchPolicyMiddlewaresIntercept<T>["after"])[];
1658
+ onResult: (VigorFetchPolicyMiddlewaresFluent<T>["onResult"] | VigorFetchPolicyMiddlewaresIntercept<T>["onResult"])[];
1659
+ onError: (VigorFetchPolicyMiddlewaresFluent<T>["onError"] | VigorFetchPolicyMiddlewaresIntercept<T>["onError"])[];
1660
+ };
1661
+ declare const VigorFetchPolicyMiddlewaresBase: {
1662
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
1663
+ readonly before: [];
1664
+ readonly after: [];
1665
+ readonly onResult: [];
1666
+ readonly onError: [];
1667
+ };
1668
+ type VigorFetchPolicyMiddlewaresFluent<T extends VigorFetchSchema<T>> = {
1669
+ __brand: VigorBrand<"Fetch", "Policy<Middlewares<Fluent<Schema">;
1670
+ before: {
1671
+ _mode: "fluent";
1672
+ func: (ctx: T["context"]) => void;
1673
+ };
1674
+ after: {
1675
+ _mode: "fluent";
1676
+ func: (ctx: T["context"]) => void;
1677
+ };
1678
+ onResult: {
1679
+ _mode: "fluent";
1680
+ func: (res: T["context"]["result"]) => VigorFetchSchema<any>["context"]["result"];
1681
+ };
1682
+ onError: {
1683
+ _mode: "fluent";
1684
+ func: (err: T["context"]["error"]) => void;
1685
+ };
1686
+ };
1687
+ type VigorFetchPolicyMiddlewaresApi<T extends VigorFetchSchema<T>> = {
1688
+ setResult: (res: VigorFetchSchema<any>["context"]["result"]) => void;
1689
+ throwError: (err: VigorFetchSchema<any>["context"]["error"]) => void;
1690
+ setOptions: (opts: VigorFetchOptions) => void;
1691
+ setHeaders: (headers: VigorFetchOptions["headers"]) => void;
1692
+ setBody: (body: VigorFetchOptions["body"]) => void;
1693
+ proceedRestart: () => void;
1694
+ cancelRestart: () => void;
1695
+ };
1696
+ type VigorFetchPolicyMiddlewaresIntercept<T extends VigorFetchSchema<T>> = {
1697
+ __brand: VigorBrand<"Fetch", "Policy<Middlewares<Intercept<Schema">;
1698
+ before: {
1699
+ _mode: "intercept";
1700
+ func: (ctx: T["context"], api: Pick<VigorFetchPolicyMiddlewaresApi<T>, "throwError" | "setOptions" | "setHeaders" | "setBody">) => VigorFetchSchema<any>["context"] | Promise<VigorFetchSchema<any>["context"]>;
1701
+ };
1702
+ after: {
1703
+ _mode: "intercept";
1704
+ func: (ctx: T["context"], api: Pick<VigorFetchPolicyMiddlewaresApi<T>, "setResult" | "throwError">) => VigorFetchSchema<any>["context"] | Promise<VigorFetchSchema<any>["context"]>;
1705
+ };
1706
+ onResult: {
1707
+ _mode: "intercept";
1708
+ func: (ctx: T["context"], api: Pick<VigorFetchPolicyMiddlewaresApi<T>, "setResult" | "throwError">) => VigorFetchSchema<any>["context"] | Promise<VigorFetchSchema<any>["context"]>;
1709
+ };
1710
+ onError: {
1711
+ _mode: "intercept";
1712
+ func: (ctx: T["context"], api: Pick<VigorFetchPolicyMiddlewaresApi<T>, "setResult" | "throwError" | "proceedRestart" | "cancelRestart">) => VigorFetchSchema<any>["context"] | Promise<VigorFetchSchema<any>["context"]>;
1713
+ };
1714
+ };
1715
+ /**
1716
+ * Immutable builder for a fetch policy's middleware pipeline (`before`,
1717
+ * `after`, `onResult`, `onError`). Each stage accepts either "fluent"
1718
+ * middleware (returns a plain value merged into the context) or
1719
+ * "intercept" middleware (receives an explicit API to mutate control flow).
1720
+ */
1721
+ declare class VigorFetchPolicyMiddlewares<T extends VigorFetchSchema<T> = typeof VigorFetchBase> extends VigorStatus<VigorFetchSchema<any>, T, VigorFetchPolicyMiddlewaresTypeLambda> {
1722
+ constructor(config?: T);
1723
+ protected _create<C>(config: C): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, C>;
1724
+ /** Registers a middleware that runs before the request is sent. */
1725
+ before<const N extends VigorFetchPolicyMiddlewaresFluent<any>["before"]["func"]>(type: "fluent", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1726
+ policy: {
1727
+ middlewares: {
1728
+ before: [{
1729
+ _mode: "fluent";
1730
+ func: N;
1731
+ }];
1732
+ };
1733
+ };
1734
+ }>>;
1735
+ before<const N extends VigorFetchPolicyMiddlewaresIntercept<any>["before"]["func"]>(type: "intercept", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1736
+ policy: {
1737
+ middlewares: {
1738
+ before: [{
1739
+ _mode: "intercept";
1740
+ func: N;
1741
+ }];
1742
+ };
1743
+ };
1744
+ }>>;
1745
+ /** Registers a middleware that runs after the response is received. */
1746
+ after<const N extends VigorFetchPolicyMiddlewaresFluent<any>["after"]["func"]>(type: "fluent", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1747
+ policy: {
1748
+ middlewares: {
1749
+ after: [{
1750
+ _mode: "fluent";
1751
+ func: N;
1752
+ }];
1753
+ };
1754
+ };
1755
+ }>>;
1756
+ after<const N extends VigorFetchPolicyMiddlewaresIntercept<any>["after"]["func"]>(type: "intercept", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1757
+ policy: {
1758
+ middlewares: {
1759
+ after: [{
1760
+ _mode: "intercept";
1761
+ func: N;
1762
+ }];
1763
+ };
1764
+ };
1765
+ }>>;
1766
+ /** Registers a middleware that transforms or validates the parsed result. */
1767
+ onResult<const N extends VigorFetchPolicyMiddlewaresFluent<any>["onResult"]["func"]>(type: "fluent", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1768
+ policy: {
1769
+ middlewares: {
1770
+ onResult: [{
1771
+ _mode: "fluent";
1772
+ func: N;
1773
+ }];
1774
+ };
1775
+ };
1776
+ }>>;
1777
+ onResult<const N extends VigorFetchPolicyMiddlewaresIntercept<any>["onResult"]["func"]>(type: "intercept", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1778
+ policy: {
1779
+ middlewares: {
1780
+ onResult: [{
1781
+ _mode: "intercept";
1782
+ func: N;
1783
+ }];
1784
+ };
1785
+ };
1786
+ }>>;
1787
+ /** Registers a middleware that runs when the request ultimately fails. */
1788
+ onError<const N extends VigorFetchPolicyMiddlewaresFluent<any>["onError"]["func"]>(type: "fluent", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1789
+ policy: {
1790
+ middlewares: {
1791
+ onError: [{
1792
+ _mode: "fluent";
1793
+ func: N;
1794
+ }];
1795
+ };
1796
+ };
1797
+ }>>;
1798
+ onError<const N extends VigorFetchPolicyMiddlewaresIntercept<any>["onError"]["func"]>(type: "intercept", func: N): VigorApply<VigorFetchPolicyMiddlewaresTypeLambda, VigorDeepMerge<T, {
1799
+ policy: {
1800
+ middlewares: {
1801
+ onError: [{
1802
+ _mode: "intercept";
1803
+ func: N;
1804
+ }];
1805
+ };
1806
+ };
1807
+ }>>;
1808
+ }
1809
+
1810
+ type VigorFetchIn<T> = T extends VigorFetchSchema<any> ? T : never;
1811
+ interface VigorFetchTypeLambda extends VigorTypeLambda {
1812
+ readonly Target: VigorFetch<VigorFetchIn<this["In"]>>;
1813
+ }
1814
+ interface VigorFetchPolicySettingsTypeLambda extends VigorTypeLambda {
1815
+ readonly Target: VigorFetchPolicySettings<VigorFetchIn<this["In"]>>;
1816
+ }
1817
+ interface VigorFetchPolicyMiddlewaresTypeLambda extends VigorTypeLambda {
1818
+ readonly Target: VigorFetchPolicyMiddlewares<VigorFetchIn<this["In"]>>;
1819
+ }
1820
+
1821
+ type VigorStringable = string | number | boolean | null | undefined | Date;
1822
+ type VigorFetchPolicySchema<T extends VigorFetchSchema<T>> = {
1823
+ __brand: VigorBrand<"Fetch", "Policy<Schema">;
1824
+ method: VigorFetchOptions["method"] | VigorEmptyType;
1825
+ origin: string | VigorEmptyType;
1826
+ path: string[];
1827
+ query: Record<string, VigorStringable | VigorStringable[]>[];
1828
+ hash: string;
1829
+ headers: Record<string, string>;
1830
+ body: BodyInit | object | null | VigorEmptyType;
1831
+ extra: VigorFetchExtraOptions;
1832
+ settings: VigorFetchPolicySettingsSchema<T>;
1833
+ middlewares: VigorFetchPolicyMiddlewaresSchema<T>;
1834
+ retry: VigorRetrySchema<any>;
1835
+ parse: VigorParseSchema<any>;
1836
+ };
1837
+ declare const VigorFetchPolicyBase: {
1838
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
1839
+ readonly method: symbol & {
1840
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1841
+ };
1842
+ readonly origin: symbol & {
1843
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1844
+ };
1845
+ readonly path: [];
1846
+ readonly query: [];
1847
+ readonly hash: "";
1848
+ readonly headers: {};
1849
+ readonly body: symbol & {
1850
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1851
+ };
1852
+ readonly extra: {};
1853
+ readonly settings: {
1854
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
1855
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
1856
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
1857
+ readonly maxRestarts: 3;
1858
+ readonly default: symbol & {
1859
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1860
+ };
1861
+ };
1862
+ readonly middlewares: {
1863
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
1864
+ readonly before: [];
1865
+ readonly after: [];
1866
+ readonly onResult: [];
1867
+ readonly onError: [];
1868
+ };
1869
+ readonly retry: {
1870
+ readonly __brand: VigorBrand<"Retry", "Schema">;
1871
+ readonly policy: {
1872
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
1873
+ readonly target: symbol & {
1874
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1875
+ };
1876
+ readonly abortSignals: [];
1877
+ readonly settings: {
1878
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
1879
+ readonly default: symbol & {
1880
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1881
+ };
1882
+ readonly maxAttempts: 5;
1883
+ readonly maxRestarts: 3;
1884
+ readonly timeout: 20000;
1885
+ };
1886
+ readonly middlewares: {
1887
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
1888
+ readonly before: [];
1889
+ readonly after: [];
1890
+ readonly onResult: [];
1891
+ readonly retryIf: [];
1892
+ readonly onRetry: [];
1893
+ readonly onError: [];
1894
+ };
1895
+ readonly algorithms: {
1896
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1897
+ readonly _tag: "constant";
1898
+ readonly jitter: 1000;
1899
+ readonly interval: 2000;
1900
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1901
+ };
1902
+ };
1903
+ readonly context: {
1904
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
1905
+ readonly result: symbol & {
1906
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1907
+ };
1908
+ readonly error: symbol & {
1909
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1910
+ };
1911
+ readonly system: {
1912
+ readonly delay: symbol & {
1913
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1914
+ };
1915
+ readonly attempt: 0;
1916
+ };
1917
+ readonly flags: {
1918
+ readonly doRetry: true;
1919
+ readonly doRestart: false;
1920
+ readonly brokeRetry: false;
1921
+ readonly overridden: false;
1922
+ };
1923
+ readonly record: {};
1924
+ readonly policy: {
1925
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
1926
+ readonly target: symbol & {
1927
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1928
+ };
1929
+ readonly abortSignals: [];
1930
+ readonly settings: {
1931
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
1932
+ readonly default: symbol & {
1933
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1934
+ };
1935
+ readonly maxAttempts: 5;
1936
+ readonly maxRestarts: 3;
1937
+ readonly timeout: 20000;
1938
+ };
1939
+ readonly middlewares: {
1940
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
1941
+ readonly before: [];
1942
+ readonly after: [];
1943
+ readonly onResult: [];
1944
+ readonly retryIf: [];
1945
+ readonly onRetry: [];
1946
+ readonly onError: [];
1947
+ };
1948
+ readonly algorithms: {
1949
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
1950
+ readonly _tag: "constant";
1951
+ readonly jitter: 1000;
1952
+ readonly interval: 2000;
1953
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
1954
+ };
1955
+ };
1956
+ };
1957
+ };
1958
+ readonly parse: {
1959
+ readonly __brand: VigorBrand<"Parse", "Schema">;
1960
+ readonly policy: {
1961
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
1962
+ readonly target: symbol & {
1963
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1964
+ };
1965
+ readonly settings: {
1966
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
1967
+ readonly raw: false;
1968
+ readonly default: symbol & {
1969
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
1970
+ };
1971
+ readonly maxRestarts: 3;
1972
+ };
1973
+ readonly middlewares: {
1974
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
1975
+ readonly before: [];
1976
+ readonly after: [];
1977
+ readonly onResult: [];
1978
+ readonly onError: [];
1979
+ };
1980
+ readonly strategies: {
1981
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
1982
+ readonly funcs: VigorParseStrategyFunc[];
1983
+ };
1984
+ };
1985
+ readonly context: {
1986
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
1987
+ readonly result: symbol & {
1988
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1989
+ };
1990
+ readonly error: symbol & {
1991
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1992
+ };
1993
+ readonly response: symbol & {
1994
+ __brand: VigorBrand<"Core", "Symbol_Default">;
1995
+ };
1996
+ readonly flags: {
1997
+ readonly overrided: false;
1998
+ readonly restarted: false;
1999
+ };
2000
+ readonly record: {};
2001
+ readonly policy: {
2002
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2003
+ readonly target: symbol & {
2004
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2005
+ };
2006
+ readonly settings: {
2007
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2008
+ readonly raw: false;
2009
+ readonly default: symbol & {
2010
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2011
+ };
2012
+ readonly maxRestarts: 3;
2013
+ };
2014
+ readonly middlewares: {
2015
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2016
+ readonly before: [];
2017
+ readonly after: [];
2018
+ readonly onResult: [];
2019
+ readonly onError: [];
2020
+ };
2021
+ readonly strategies: {
2022
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2023
+ readonly funcs: VigorParseStrategyFunc[];
2024
+ };
2025
+ };
2026
+ };
2027
+ };
2028
+ };
2029
+
2030
+ type VigorFetchSchema<T extends VigorFetchSchema<T>> = {
2031
+ __brand: VigorBrand<"Fetch", "Schema">;
2032
+ policy: VigorFetchPolicySchema<T>;
2033
+ context: VigorFetchContextSchema<T>;
2034
+ };
2035
+ declare const VigorFetchBase: {
2036
+ readonly __brand: VigorBrand<"Fetch", "Schema">;
2037
+ readonly policy: {
2038
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
2039
+ readonly method: symbol & {
2040
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2041
+ };
2042
+ readonly origin: symbol & {
2043
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2044
+ };
2045
+ readonly path: [];
2046
+ readonly query: [];
2047
+ readonly hash: "";
2048
+ readonly headers: {};
2049
+ readonly body: symbol & {
2050
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2051
+ };
2052
+ readonly extra: {};
2053
+ readonly settings: {
2054
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2055
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2056
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2057
+ readonly maxRestarts: 3;
2058
+ readonly default: symbol & {
2059
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2060
+ };
2061
+ };
2062
+ readonly middlewares: {
2063
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2064
+ readonly before: [];
2065
+ readonly after: [];
2066
+ readonly onResult: [];
2067
+ readonly onError: [];
2068
+ };
2069
+ readonly retry: {
2070
+ readonly __brand: VigorBrand<"Retry", "Schema">;
2071
+ readonly policy: {
2072
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2073
+ readonly target: symbol & {
2074
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2075
+ };
2076
+ readonly abortSignals: [];
2077
+ readonly settings: {
2078
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2079
+ readonly default: symbol & {
2080
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2081
+ };
2082
+ readonly maxAttempts: 5;
2083
+ readonly maxRestarts: 3;
2084
+ readonly timeout: 20000;
2085
+ };
2086
+ readonly middlewares: {
2087
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2088
+ readonly before: [];
2089
+ readonly after: [];
2090
+ readonly onResult: [];
2091
+ readonly retryIf: [];
2092
+ readonly onRetry: [];
2093
+ readonly onError: [];
2094
+ };
2095
+ readonly algorithms: {
2096
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2097
+ readonly _tag: "constant";
2098
+ readonly jitter: 1000;
2099
+ readonly interval: 2000;
2100
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2101
+ };
2102
+ };
2103
+ readonly context: {
2104
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2105
+ readonly result: symbol & {
2106
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2107
+ };
2108
+ readonly error: symbol & {
2109
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2110
+ };
2111
+ readonly system: {
2112
+ readonly delay: symbol & {
2113
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2114
+ };
2115
+ readonly attempt: 0;
2116
+ };
2117
+ readonly flags: {
2118
+ readonly doRetry: true;
2119
+ readonly doRestart: false;
2120
+ readonly brokeRetry: false;
2121
+ readonly overridden: false;
2122
+ };
2123
+ readonly record: {};
2124
+ readonly policy: {
2125
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2126
+ readonly target: symbol & {
2127
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2128
+ };
2129
+ readonly abortSignals: [];
2130
+ readonly settings: {
2131
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2132
+ readonly default: symbol & {
2133
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2134
+ };
2135
+ readonly maxAttempts: 5;
2136
+ readonly maxRestarts: 3;
2137
+ readonly timeout: 20000;
2138
+ };
2139
+ readonly middlewares: {
2140
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2141
+ readonly before: [];
2142
+ readonly after: [];
2143
+ readonly onResult: [];
2144
+ readonly retryIf: [];
2145
+ readonly onRetry: [];
2146
+ readonly onError: [];
2147
+ };
2148
+ readonly algorithms: {
2149
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2150
+ readonly _tag: "constant";
2151
+ readonly jitter: 1000;
2152
+ readonly interval: 2000;
2153
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2154
+ };
2155
+ };
2156
+ };
2157
+ };
2158
+ readonly parse: {
2159
+ readonly __brand: VigorBrand<"Parse", "Schema">;
2160
+ readonly policy: {
2161
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2162
+ readonly target: symbol & {
2163
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2164
+ };
2165
+ readonly settings: {
2166
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2167
+ readonly raw: false;
2168
+ readonly default: symbol & {
2169
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2170
+ };
2171
+ readonly maxRestarts: 3;
2172
+ };
2173
+ readonly middlewares: {
2174
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2175
+ readonly before: [];
2176
+ readonly after: [];
2177
+ readonly onResult: [];
2178
+ readonly onError: [];
2179
+ };
2180
+ readonly strategies: {
2181
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2182
+ readonly funcs: VigorParseStrategyFunc[];
2183
+ };
2184
+ };
2185
+ readonly context: {
2186
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2187
+ readonly result: symbol & {
2188
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2189
+ };
2190
+ readonly error: symbol & {
2191
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2192
+ };
2193
+ readonly response: symbol & {
2194
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2195
+ };
2196
+ readonly flags: {
2197
+ readonly overrided: false;
2198
+ readonly restarted: false;
2199
+ };
2200
+ readonly record: {};
2201
+ readonly policy: {
2202
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2203
+ readonly target: symbol & {
2204
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2205
+ };
2206
+ readonly settings: {
2207
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2208
+ readonly raw: false;
2209
+ readonly default: symbol & {
2210
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2211
+ };
2212
+ readonly maxRestarts: 3;
2213
+ };
2214
+ readonly middlewares: {
2215
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2216
+ readonly before: [];
2217
+ readonly after: [];
2218
+ readonly onResult: [];
2219
+ readonly onError: [];
2220
+ };
2221
+ readonly strategies: {
2222
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2223
+ readonly funcs: VigorParseStrategyFunc[];
2224
+ };
2225
+ };
2226
+ };
2227
+ };
2228
+ };
2229
+ readonly context: {
2230
+ readonly __brand: VigorBrand<"Fetch", "Context<Schema">;
2231
+ readonly href: "";
2232
+ readonly response: symbol & {
2233
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2234
+ };
2235
+ readonly result: symbol & {
2236
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2237
+ };
2238
+ readonly error: symbol & {
2239
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2240
+ };
2241
+ readonly options: symbol & {
2242
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2243
+ };
2244
+ readonly flags: {
2245
+ readonly overrided: false;
2246
+ readonly restarted: false;
2247
+ };
2248
+ readonly record: {};
2249
+ readonly policy: {
2250
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
2251
+ readonly method: symbol & {
2252
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2253
+ };
2254
+ readonly origin: symbol & {
2255
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2256
+ };
2257
+ readonly path: [];
2258
+ readonly query: [];
2259
+ readonly hash: "";
2260
+ readonly headers: {};
2261
+ readonly body: symbol & {
2262
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2263
+ };
2264
+ readonly extra: {};
2265
+ readonly settings: {
2266
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2267
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2268
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2269
+ readonly maxRestarts: 3;
2270
+ readonly default: symbol & {
2271
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2272
+ };
2273
+ };
2274
+ readonly middlewares: {
2275
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2276
+ readonly before: [];
2277
+ readonly after: [];
2278
+ readonly onResult: [];
2279
+ readonly onError: [];
2280
+ };
2281
+ readonly retry: {
2282
+ readonly __brand: VigorBrand<"Retry", "Schema">;
2283
+ readonly policy: {
2284
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2285
+ readonly target: symbol & {
2286
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2287
+ };
2288
+ readonly abortSignals: [];
2289
+ readonly settings: {
2290
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2291
+ readonly default: symbol & {
2292
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2293
+ };
2294
+ readonly maxAttempts: 5;
2295
+ readonly maxRestarts: 3;
2296
+ readonly timeout: 20000;
2297
+ };
2298
+ readonly middlewares: {
2299
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2300
+ readonly before: [];
2301
+ readonly after: [];
2302
+ readonly onResult: [];
2303
+ readonly retryIf: [];
2304
+ readonly onRetry: [];
2305
+ readonly onError: [];
2306
+ };
2307
+ readonly algorithms: {
2308
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2309
+ readonly _tag: "constant";
2310
+ readonly jitter: 1000;
2311
+ readonly interval: 2000;
2312
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2313
+ };
2314
+ };
2315
+ readonly context: {
2316
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2317
+ readonly result: symbol & {
2318
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2319
+ };
2320
+ readonly error: symbol & {
2321
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2322
+ };
2323
+ readonly system: {
2324
+ readonly delay: symbol & {
2325
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2326
+ };
2327
+ readonly attempt: 0;
2328
+ };
2329
+ readonly flags: {
2330
+ readonly doRetry: true;
2331
+ readonly doRestart: false;
2332
+ readonly brokeRetry: false;
2333
+ readonly overridden: false;
2334
+ };
2335
+ readonly record: {};
2336
+ readonly policy: {
2337
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2338
+ readonly target: symbol & {
2339
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2340
+ };
2341
+ readonly abortSignals: [];
2342
+ readonly settings: {
2343
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2344
+ readonly default: symbol & {
2345
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2346
+ };
2347
+ readonly maxAttempts: 5;
2348
+ readonly maxRestarts: 3;
2349
+ readonly timeout: 20000;
2350
+ };
2351
+ readonly middlewares: {
2352
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2353
+ readonly before: [];
2354
+ readonly after: [];
2355
+ readonly onResult: [];
2356
+ readonly retryIf: [];
2357
+ readonly onRetry: [];
2358
+ readonly onError: [];
2359
+ };
2360
+ readonly algorithms: {
2361
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2362
+ readonly _tag: "constant";
2363
+ readonly jitter: 1000;
2364
+ readonly interval: 2000;
2365
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2366
+ };
2367
+ };
2368
+ };
2369
+ };
2370
+ readonly parse: {
2371
+ readonly __brand: VigorBrand<"Parse", "Schema">;
2372
+ readonly policy: {
2373
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2374
+ readonly target: symbol & {
2375
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2376
+ };
2377
+ readonly settings: {
2378
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2379
+ readonly raw: false;
2380
+ readonly default: symbol & {
2381
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2382
+ };
2383
+ readonly maxRestarts: 3;
2384
+ };
2385
+ readonly middlewares: {
2386
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2387
+ readonly before: [];
2388
+ readonly after: [];
2389
+ readonly onResult: [];
2390
+ readonly onError: [];
2391
+ };
2392
+ readonly strategies: {
2393
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2394
+ readonly funcs: VigorParseStrategyFunc[];
2395
+ };
2396
+ };
2397
+ readonly context: {
2398
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2399
+ readonly result: symbol & {
2400
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2401
+ };
2402
+ readonly error: symbol & {
2403
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2404
+ };
2405
+ readonly response: symbol & {
2406
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2407
+ };
2408
+ readonly flags: {
2409
+ readonly overrided: false;
2410
+ readonly restarted: false;
2411
+ };
2412
+ readonly record: {};
2413
+ readonly policy: {
2414
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2415
+ readonly target: symbol & {
2416
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2417
+ };
2418
+ readonly settings: {
2419
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2420
+ readonly raw: false;
2421
+ readonly default: symbol & {
2422
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2423
+ };
2424
+ readonly maxRestarts: 3;
2425
+ };
2426
+ readonly middlewares: {
2427
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2428
+ readonly before: [];
2429
+ readonly after: [];
2430
+ readonly onResult: [];
2431
+ readonly onError: [];
2432
+ };
2433
+ readonly strategies: {
2434
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2435
+ readonly funcs: VigorParseStrategyFunc[];
2436
+ };
2437
+ };
2438
+ };
2439
+ };
2440
+ };
2441
+ };
2442
+ };
2443
+ /**
2444
+ * Immutable builder that performs an HTTP request, composing an internal
2445
+ * {@link VigorRetry} engine (for retry/timeout/backoff) and a
2446
+ * {@link VigorParse} engine (for response parsing), with a configurable
2447
+ * middleware pipeline around request building and response handling.
2448
+ */
2449
+ declare class VigorFetch<T extends VigorFetchSchema<T> = typeof VigorFetchBase> extends VigorStatus<VigorFetchSchema<T>, T, VigorFetchTypeLambda> {
2450
+ constructor(config?: T);
2451
+ protected _create<C>(config: C): VigorApply<VigorFetchTypeLambda, C>;
2452
+ /** Sets the HTTP method. Defaults to `POST` when a body is set, otherwise `GET`. */
2453
+ method<const N extends VigorFetchOptions["method"]>(str: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2454
+ readonly policy: {
2455
+ readonly method: N;
2456
+ };
2457
+ }>>>;
2458
+ /** Sets the request origin, either an absolute URL or a path relative to the current page. */
2459
+ origin<const N extends string>(str: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2460
+ readonly policy: {
2461
+ readonly origin: N;
2462
+ };
2463
+ }>>>;
2464
+ /** Appends path segments to the request URL. */
2465
+ path<const N extends VigorStringable[]>(...strs: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2466
+ readonly policy: {
2467
+ readonly path: string[];
2468
+ };
2469
+ }>>>;
2470
+ /** Adds query-string parameter objects to the request URL. */
2471
+ query<const N extends VigorFetchPolicySchema<any>["query"][number]>(...objs: N[]): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2472
+ readonly policy: {
2473
+ readonly query: N[];
2474
+ };
2475
+ }>>>;
2476
+ /** Sets the URL fragment ("hash"), replacing any previous value. */
2477
+ hash<const N extends string>(str: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2478
+ readonly policy: {
2479
+ readonly hash: N;
2480
+ };
2481
+ }>>>;
2482
+ /**
2483
+ * Sets request headers.
2484
+ *
2485
+ * @param mode - `"overwrite"` discards all previously configured headers
2486
+ * and keeps only the ones passed here. `"merge"` behaves like
2487
+ * `Object.assign`, overwriting only the keys that overlap and keeping
2488
+ * the rest.
2489
+ */
2490
+ headers<const N extends Record<string, string>>(mode: "overwrite" | "merge", obj: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2491
+ readonly policy: {
2492
+ readonly headers: N;
2493
+ };
2494
+ }>>>;
2495
+ /**
2496
+ * Sets the request body.
2497
+ *
2498
+ * @param mode - `"overwrite"` discards the previous body and fully
2499
+ * replaces it with this value. `"merge"` shallow-merges (via
2500
+ * `Object.assign`) when both the previous and new body are plain
2501
+ * objects; for any other body type (string/Blob/FormData/etc) it is
2502
+ * simply replaced.
2503
+ */
2504
+ body<const N extends BodyInit | object | null>(mode: "overwrite" | "merge", obj: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2505
+ readonly policy: {
2506
+ readonly body: N;
2507
+ };
2508
+ }>>>;
2509
+ /**
2510
+ * Sets additional `RequestInit` options other than headers/body/method/signal
2511
+ * (e.g. `credentials`, `mode`, `cache`, `redirect`, `referrer`,
2512
+ * `referrerPolicy`, `keepalive`, `integrity`).
2513
+ *
2514
+ * @param mode - `"overwrite"` discards all previously configured options
2515
+ * and replaces them with this value. `"merge"` shallow-merges this
2516
+ * value onto the previous options.
2517
+ */
2518
+ options<const N extends VigorFetchPolicySchema<any>["extra"]>(mode: "overwrite" | "merge", obj: N): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2519
+ readonly policy: {
2520
+ readonly extra: N;
2521
+ };
2522
+ }>>>;
2523
+ /** Configures the fetch policy's general settings. */
2524
+ settings<const N extends VigorDeepPartial<VigorFetchPolicySettingsSchema<T>>, R extends VigorFetchSchema<any>>(input: N | ((s: VigorFetchPolicySettings<T>) => VigorFetchPolicySettings<R>) | VigorFetchPolicySettings<R>): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2525
+ readonly policy: {
2526
+ readonly settings: VigorFetchPolicySettingsSchema<any>;
2527
+ };
2528
+ }>>>;
2529
+ /** Configures the fetch policy's middleware pipeline. */
2530
+ middlewares<const N extends VigorDeepPartial<VigorFetchPolicyMiddlewaresSchema<T>>, R extends VigorFetchSchema<any>>(input: N | ((s: VigorFetchPolicyMiddlewares<T>) => VigorFetchPolicyMiddlewares<R>) | VigorFetchPolicyMiddlewares<R>): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2531
+ readonly policy: {
2532
+ readonly middlewares: VigorFetchPolicyMiddlewaresSchema<any>;
2533
+ };
2534
+ }>>>;
2535
+ /** Configures the retry engine used to send the underlying request. */
2536
+ retry<const N extends VigorDeepPartial<VigorRetrySchema<any>>, R extends VigorRetrySchema<any>>(input: N | ((r: VigorRetry) => VigorRetry<R>) | VigorRetry<R>): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2537
+ readonly policy: {
2538
+ readonly retry: R;
2539
+ };
2540
+ }>>>;
2541
+ /** Configures the parse engine used to interpret the response. */
2542
+ parse<const N extends VigorDeepPartial<VigorParseSchema<any>>, R extends VigorParseSchema<any>>(input: N | ((p: VigorParse) => VigorParse<R>) | VigorParse<R>): VigorFetch<VigorFetchIn<VigorDeepMerge<T, {
2543
+ readonly policy: {
2544
+ readonly parse: R;
2545
+ };
2546
+ }>>>;
2547
+ /** Converts a list of stringable values into strings, dropping `null`/`undefined` entries. */
2548
+ protected _stringifyList(unkList: VigorStringable[]): string[];
2549
+ /**
2550
+ * Resolves the base URL used to interpret a relative `origin`. In a
2551
+ * browser environment this is the current page location; in
2552
+ * environments without `location` (e.g. Node), no base is available and
2553
+ * `origin` must be an absolute URL.
2554
+ */
2555
+ protected _resolveBase(): string | undefined;
2556
+ /**
2557
+ * Builds the final request URL from the configured origin, path
2558
+ * segments, query parameters, and hash. An absolute `origin` ignores
2559
+ * the resolved base (per the `URL` spec); a relative `origin` is
2560
+ * resolved against it. Throws `INVALID_PROTOCOL` if neither is possible.
2561
+ */
2562
+ protected _buildUrl(origin: string, path: string[], query: VigorFetchPolicySchema<any>["query"], hash: string): string;
2563
+ /** Infers the `Content-Type` header and serializes `body` into a `BodyInit`. */
2564
+ protected _normalizeBody(body: unknown): {
2565
+ headers: Record<string, string>;
2566
+ body: BodyInit | null | undefined;
2567
+ };
2568
+ /** Runs the request and returns its parsed result directly, throwing on final failure. */
2569
+ request<R = T["context"]["result"]>(): Promise<R>;
2570
+ /** Runs the request and returns a result/error envelope instead of throwing. */
2571
+ requestVerbose<R = T["context"]["result"]>(): Promise<{
2572
+ success: false;
2573
+ data: null;
2574
+ error: unknown;
2575
+ } | {
2576
+ success: true;
2577
+ data: R;
2578
+ error: null;
2579
+ }>;
2580
+ /** Internal execution loop implementing URL building, retry, parsing, and restart handling. */
2581
+ private requestRuntime;
2582
+ }
2583
+
2584
+ /** Everything `vigor` exposes except `use` — kept separate so `VigorInstance` (below) can self-reference without a circular-inference error. */
2585
+ declare const vigorBase: {
2586
+ retry: (task?: ((signal: AbortSignal) => any | Promise<any>) | undefined) => VigorRetry<any>;
2587
+ parse: (response?: (symbol & {
2588
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2589
+ }) | Request | Response | undefined) => VigorParse<any>;
2590
+ fetch: (origin?: string | undefined) => VigorFetch<any>;
2591
+ all: (...tasks: Parameters<VigorAll["target"]>) => VigorAll<{
2592
+ readonly __brand: VigorBrand<"All", "Schema">;
2593
+ readonly policy: {
2594
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
2595
+ readonly target: VigorAllTask[];
2596
+ readonly settings: {
2597
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
2598
+ readonly concurrency: 5;
2599
+ readonly onlySuccess: false;
2600
+ };
2601
+ readonly middlewares: {
2602
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
2603
+ readonly before: VigorAllEachMiddlewareFn[];
2604
+ readonly after: VigorAllEachMiddlewareFn[];
2605
+ readonly onError: VigorAllEachOnErrorFn[];
2606
+ };
2607
+ };
2608
+ readonly context: {
2609
+ readonly __brand: VigorBrand<"All", "Context<Schema">;
2610
+ readonly result: symbol & {
2611
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2612
+ };
2613
+ readonly policy: {
2614
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
2615
+ readonly target: VigorAllTask[];
2616
+ readonly settings: {
2617
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
2618
+ readonly concurrency: 5;
2619
+ readonly onlySuccess: false;
2620
+ };
2621
+ readonly middlewares: {
2622
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
2623
+ readonly before: VigorAllEachMiddlewareFn[];
2624
+ readonly after: VigorAllEachMiddlewareFn[];
2625
+ readonly onError: VigorAllEachOnErrorFn[];
2626
+ };
2627
+ };
2628
+ readonly record: {};
2629
+ };
2630
+ }>;
2631
+ builders: {
2632
+ fetch: {
2633
+ settings: () => VigorFetchPolicySettings<{
2634
+ readonly __brand: VigorBrand<"Fetch", "Schema">;
2635
+ readonly policy: {
2636
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
2637
+ readonly method: symbol & {
2638
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2639
+ };
2640
+ readonly origin: symbol & {
2641
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2642
+ };
2643
+ readonly path: [];
2644
+ readonly query: [];
2645
+ readonly hash: "";
2646
+ readonly headers: {};
2647
+ readonly body: symbol & {
2648
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2649
+ };
2650
+ readonly extra: {};
2651
+ readonly settings: {
2652
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2653
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2654
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2655
+ readonly maxRestarts: 3;
2656
+ readonly default: symbol & {
2657
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2658
+ };
2659
+ };
2660
+ readonly middlewares: {
2661
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2662
+ readonly before: [];
2663
+ readonly after: [];
2664
+ readonly onResult: [];
2665
+ readonly onError: [];
2666
+ };
2667
+ readonly retry: {
2668
+ readonly __brand: VigorBrand<"Retry", "Schema">;
2669
+ readonly policy: {
2670
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2671
+ readonly target: symbol & {
2672
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2673
+ };
2674
+ readonly abortSignals: [];
2675
+ readonly settings: {
2676
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2677
+ readonly default: symbol & {
2678
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2679
+ };
2680
+ readonly maxAttempts: 5;
2681
+ readonly maxRestarts: 3;
2682
+ readonly timeout: 20000;
2683
+ };
2684
+ readonly middlewares: {
2685
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2686
+ readonly before: [];
2687
+ readonly after: [];
2688
+ readonly onResult: [];
2689
+ readonly retryIf: [];
2690
+ readonly onRetry: [];
2691
+ readonly onError: [];
2692
+ };
2693
+ readonly algorithms: {
2694
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2695
+ readonly _tag: "constant";
2696
+ readonly jitter: 1000;
2697
+ readonly interval: 2000;
2698
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2699
+ };
2700
+ };
2701
+ readonly context: {
2702
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2703
+ readonly result: symbol & {
2704
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2705
+ };
2706
+ readonly error: symbol & {
2707
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2708
+ };
2709
+ readonly system: {
2710
+ readonly delay: symbol & {
2711
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2712
+ };
2713
+ readonly attempt: 0;
2714
+ };
2715
+ readonly flags: {
2716
+ readonly doRetry: true;
2717
+ readonly doRestart: false;
2718
+ readonly brokeRetry: false;
2719
+ readonly overridden: false;
2720
+ };
2721
+ readonly record: {};
2722
+ readonly policy: {
2723
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2724
+ readonly target: symbol & {
2725
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2726
+ };
2727
+ readonly abortSignals: [];
2728
+ readonly settings: {
2729
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2730
+ readonly default: symbol & {
2731
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2732
+ };
2733
+ readonly maxAttempts: 5;
2734
+ readonly maxRestarts: 3;
2735
+ readonly timeout: 20000;
2736
+ };
2737
+ readonly middlewares: {
2738
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2739
+ readonly before: [];
2740
+ readonly after: [];
2741
+ readonly onResult: [];
2742
+ readonly retryIf: [];
2743
+ readonly onRetry: [];
2744
+ readonly onError: [];
2745
+ };
2746
+ readonly algorithms: {
2747
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2748
+ readonly _tag: "constant";
2749
+ readonly jitter: 1000;
2750
+ readonly interval: 2000;
2751
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2752
+ };
2753
+ };
2754
+ };
2755
+ };
2756
+ readonly parse: {
2757
+ readonly __brand: VigorBrand<"Parse", "Schema">;
2758
+ readonly policy: {
2759
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2760
+ readonly target: symbol & {
2761
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2762
+ };
2763
+ readonly settings: {
2764
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2765
+ readonly raw: false;
2766
+ readonly default: symbol & {
2767
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2768
+ };
2769
+ readonly maxRestarts: 3;
2770
+ };
2771
+ readonly middlewares: {
2772
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2773
+ readonly before: [];
2774
+ readonly after: [];
2775
+ readonly onResult: [];
2776
+ readonly onError: [];
2777
+ };
2778
+ readonly strategies: {
2779
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2780
+ readonly funcs: VigorParseStrategyFunc[];
2781
+ };
2782
+ };
2783
+ readonly context: {
2784
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2785
+ readonly result: symbol & {
2786
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2787
+ };
2788
+ readonly error: symbol & {
2789
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2790
+ };
2791
+ readonly response: symbol & {
2792
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2793
+ };
2794
+ readonly flags: {
2795
+ readonly overrided: false;
2796
+ readonly restarted: false;
2797
+ };
2798
+ readonly record: {};
2799
+ readonly policy: {
2800
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2801
+ readonly target: symbol & {
2802
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2803
+ };
2804
+ readonly settings: {
2805
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2806
+ readonly raw: false;
2807
+ readonly default: symbol & {
2808
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2809
+ };
2810
+ readonly maxRestarts: 3;
2811
+ };
2812
+ readonly middlewares: {
2813
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2814
+ readonly before: [];
2815
+ readonly after: [];
2816
+ readonly onResult: [];
2817
+ readonly onError: [];
2818
+ };
2819
+ readonly strategies: {
2820
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2821
+ readonly funcs: VigorParseStrategyFunc[];
2822
+ };
2823
+ };
2824
+ };
2825
+ };
2826
+ };
2827
+ readonly context: {
2828
+ readonly __brand: VigorBrand<"Fetch", "Context<Schema">;
2829
+ readonly href: "";
2830
+ readonly response: symbol & {
2831
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2832
+ };
2833
+ readonly result: symbol & {
2834
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2835
+ };
2836
+ readonly error: symbol & {
2837
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2838
+ };
2839
+ readonly options: symbol & {
2840
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2841
+ };
2842
+ readonly flags: {
2843
+ readonly overrided: false;
2844
+ readonly restarted: false;
2845
+ };
2846
+ readonly record: {};
2847
+ readonly policy: {
2848
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
2849
+ readonly method: symbol & {
2850
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2851
+ };
2852
+ readonly origin: symbol & {
2853
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2854
+ };
2855
+ readonly path: [];
2856
+ readonly query: [];
2857
+ readonly hash: "";
2858
+ readonly headers: {};
2859
+ readonly body: symbol & {
2860
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2861
+ };
2862
+ readonly extra: {};
2863
+ readonly settings: {
2864
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2865
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2866
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2867
+ readonly maxRestarts: 3;
2868
+ readonly default: symbol & {
2869
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2870
+ };
2871
+ };
2872
+ readonly middlewares: {
2873
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2874
+ readonly before: [];
2875
+ readonly after: [];
2876
+ readonly onResult: [];
2877
+ readonly onError: [];
2878
+ };
2879
+ readonly retry: {
2880
+ readonly __brand: VigorBrand<"Retry", "Schema">;
2881
+ readonly policy: {
2882
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2883
+ readonly target: symbol & {
2884
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2885
+ };
2886
+ readonly abortSignals: [];
2887
+ readonly settings: {
2888
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2889
+ readonly default: symbol & {
2890
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2891
+ };
2892
+ readonly maxAttempts: 5;
2893
+ readonly maxRestarts: 3;
2894
+ readonly timeout: 20000;
2895
+ };
2896
+ readonly middlewares: {
2897
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2898
+ readonly before: [];
2899
+ readonly after: [];
2900
+ readonly onResult: [];
2901
+ readonly retryIf: [];
2902
+ readonly onRetry: [];
2903
+ readonly onError: [];
2904
+ };
2905
+ readonly algorithms: {
2906
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2907
+ readonly _tag: "constant";
2908
+ readonly jitter: 1000;
2909
+ readonly interval: 2000;
2910
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2911
+ };
2912
+ };
2913
+ readonly context: {
2914
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2915
+ readonly result: symbol & {
2916
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2917
+ };
2918
+ readonly error: symbol & {
2919
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2920
+ };
2921
+ readonly system: {
2922
+ readonly delay: symbol & {
2923
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2924
+ };
2925
+ readonly attempt: 0;
2926
+ };
2927
+ readonly flags: {
2928
+ readonly doRetry: true;
2929
+ readonly doRestart: false;
2930
+ readonly brokeRetry: false;
2931
+ readonly overridden: false;
2932
+ };
2933
+ readonly record: {};
2934
+ readonly policy: {
2935
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2936
+ readonly target: symbol & {
2937
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2938
+ };
2939
+ readonly abortSignals: [];
2940
+ readonly settings: {
2941
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2942
+ readonly default: symbol & {
2943
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2944
+ };
2945
+ readonly maxAttempts: 5;
2946
+ readonly maxRestarts: 3;
2947
+ readonly timeout: 20000;
2948
+ };
2949
+ readonly middlewares: {
2950
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2951
+ readonly before: [];
2952
+ readonly after: [];
2953
+ readonly onResult: [];
2954
+ readonly retryIf: [];
2955
+ readonly onRetry: [];
2956
+ readonly onError: [];
2957
+ };
2958
+ readonly algorithms: {
2959
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2960
+ readonly _tag: "constant";
2961
+ readonly jitter: 1000;
2962
+ readonly interval: 2000;
2963
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2964
+ };
2965
+ };
2966
+ };
2967
+ };
2968
+ readonly parse: {
2969
+ readonly __brand: VigorBrand<"Parse", "Schema">;
2970
+ readonly policy: {
2971
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2972
+ readonly target: symbol & {
2973
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2974
+ };
2975
+ readonly settings: {
2976
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2977
+ readonly raw: false;
2978
+ readonly default: symbol & {
2979
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
2980
+ };
2981
+ readonly maxRestarts: 3;
2982
+ };
2983
+ readonly middlewares: {
2984
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2985
+ readonly before: [];
2986
+ readonly after: [];
2987
+ readonly onResult: [];
2988
+ readonly onError: [];
2989
+ };
2990
+ readonly strategies: {
2991
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2992
+ readonly funcs: VigorParseStrategyFunc[];
2993
+ };
2994
+ };
2995
+ readonly context: {
2996
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2997
+ readonly result: symbol & {
2998
+ __brand: VigorBrand<"Core", "Symbol_Default">;
2999
+ };
3000
+ readonly error: symbol & {
3001
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3002
+ };
3003
+ readonly response: symbol & {
3004
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3005
+ };
3006
+ readonly flags: {
3007
+ readonly overrided: false;
3008
+ readonly restarted: false;
3009
+ };
3010
+ readonly record: {};
3011
+ readonly policy: {
3012
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3013
+ readonly target: symbol & {
3014
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3015
+ };
3016
+ readonly settings: {
3017
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3018
+ readonly raw: false;
3019
+ readonly default: symbol & {
3020
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3021
+ };
3022
+ readonly maxRestarts: 3;
3023
+ };
3024
+ readonly middlewares: {
3025
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3026
+ readonly before: [];
3027
+ readonly after: [];
3028
+ readonly onResult: [];
3029
+ readonly onError: [];
3030
+ };
3031
+ readonly strategies: {
3032
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3033
+ readonly funcs: VigorParseStrategyFunc[];
3034
+ };
3035
+ };
3036
+ };
3037
+ };
3038
+ };
3039
+ };
3040
+ }>;
3041
+ middlewares: () => VigorFetchPolicyMiddlewares<{
3042
+ readonly __brand: VigorBrand<"Fetch", "Schema">;
3043
+ readonly policy: {
3044
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
3045
+ readonly method: symbol & {
3046
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3047
+ };
3048
+ readonly origin: symbol & {
3049
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3050
+ };
3051
+ readonly path: [];
3052
+ readonly query: [];
3053
+ readonly hash: "";
3054
+ readonly headers: {};
3055
+ readonly body: symbol & {
3056
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3057
+ };
3058
+ readonly extra: {};
3059
+ readonly settings: {
3060
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
3061
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3062
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3063
+ readonly maxRestarts: 3;
3064
+ readonly default: symbol & {
3065
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3066
+ };
3067
+ };
3068
+ readonly middlewares: {
3069
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
3070
+ readonly before: [];
3071
+ readonly after: [];
3072
+ readonly onResult: [];
3073
+ readonly onError: [];
3074
+ };
3075
+ readonly retry: {
3076
+ readonly __brand: VigorBrand<"Retry", "Schema">;
3077
+ readonly policy: {
3078
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3079
+ readonly target: symbol & {
3080
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3081
+ };
3082
+ readonly abortSignals: [];
3083
+ readonly settings: {
3084
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3085
+ readonly default: symbol & {
3086
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3087
+ };
3088
+ readonly maxAttempts: 5;
3089
+ readonly maxRestarts: 3;
3090
+ readonly timeout: 20000;
3091
+ };
3092
+ readonly middlewares: {
3093
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3094
+ readonly before: [];
3095
+ readonly after: [];
3096
+ readonly onResult: [];
3097
+ readonly retryIf: [];
3098
+ readonly onRetry: [];
3099
+ readonly onError: [];
3100
+ };
3101
+ readonly algorithms: {
3102
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3103
+ readonly _tag: "constant";
3104
+ readonly jitter: 1000;
3105
+ readonly interval: 2000;
3106
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3107
+ };
3108
+ };
3109
+ readonly context: {
3110
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3111
+ readonly result: symbol & {
3112
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3113
+ };
3114
+ readonly error: symbol & {
3115
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3116
+ };
3117
+ readonly system: {
3118
+ readonly delay: symbol & {
3119
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3120
+ };
3121
+ readonly attempt: 0;
3122
+ };
3123
+ readonly flags: {
3124
+ readonly doRetry: true;
3125
+ readonly doRestart: false;
3126
+ readonly brokeRetry: false;
3127
+ readonly overridden: false;
3128
+ };
3129
+ readonly record: {};
3130
+ readonly policy: {
3131
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3132
+ readonly target: symbol & {
3133
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3134
+ };
3135
+ readonly abortSignals: [];
3136
+ readonly settings: {
3137
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3138
+ readonly default: symbol & {
3139
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3140
+ };
3141
+ readonly maxAttempts: 5;
3142
+ readonly maxRestarts: 3;
3143
+ readonly timeout: 20000;
3144
+ };
3145
+ readonly middlewares: {
3146
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3147
+ readonly before: [];
3148
+ readonly after: [];
3149
+ readonly onResult: [];
3150
+ readonly retryIf: [];
3151
+ readonly onRetry: [];
3152
+ readonly onError: [];
3153
+ };
3154
+ readonly algorithms: {
3155
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3156
+ readonly _tag: "constant";
3157
+ readonly jitter: 1000;
3158
+ readonly interval: 2000;
3159
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3160
+ };
3161
+ };
3162
+ };
3163
+ };
3164
+ readonly parse: {
3165
+ readonly __brand: VigorBrand<"Parse", "Schema">;
3166
+ readonly policy: {
3167
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3168
+ readonly target: symbol & {
3169
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3170
+ };
3171
+ readonly settings: {
3172
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3173
+ readonly raw: false;
3174
+ readonly default: symbol & {
3175
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3176
+ };
3177
+ readonly maxRestarts: 3;
3178
+ };
3179
+ readonly middlewares: {
3180
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3181
+ readonly before: [];
3182
+ readonly after: [];
3183
+ readonly onResult: [];
3184
+ readonly onError: [];
3185
+ };
3186
+ readonly strategies: {
3187
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3188
+ readonly funcs: VigorParseStrategyFunc[];
3189
+ };
3190
+ };
3191
+ readonly context: {
3192
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3193
+ readonly result: symbol & {
3194
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3195
+ };
3196
+ readonly error: symbol & {
3197
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3198
+ };
3199
+ readonly response: symbol & {
3200
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3201
+ };
3202
+ readonly flags: {
3203
+ readonly overrided: false;
3204
+ readonly restarted: false;
3205
+ };
3206
+ readonly record: {};
3207
+ readonly policy: {
3208
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3209
+ readonly target: symbol & {
3210
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3211
+ };
3212
+ readonly settings: {
3213
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3214
+ readonly raw: false;
3215
+ readonly default: symbol & {
3216
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3217
+ };
3218
+ readonly maxRestarts: 3;
3219
+ };
3220
+ readonly middlewares: {
3221
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3222
+ readonly before: [];
3223
+ readonly after: [];
3224
+ readonly onResult: [];
3225
+ readonly onError: [];
3226
+ };
3227
+ readonly strategies: {
3228
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3229
+ readonly funcs: VigorParseStrategyFunc[];
3230
+ };
3231
+ };
3232
+ };
3233
+ };
3234
+ };
3235
+ readonly context: {
3236
+ readonly __brand: VigorBrand<"Fetch", "Context<Schema">;
3237
+ readonly href: "";
3238
+ readonly response: symbol & {
3239
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3240
+ };
3241
+ readonly result: symbol & {
3242
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3243
+ };
3244
+ readonly error: symbol & {
3245
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3246
+ };
3247
+ readonly options: symbol & {
3248
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3249
+ };
3250
+ readonly flags: {
3251
+ readonly overrided: false;
3252
+ readonly restarted: false;
3253
+ };
3254
+ readonly record: {};
3255
+ readonly policy: {
3256
+ readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
3257
+ readonly method: symbol & {
3258
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3259
+ };
3260
+ readonly origin: symbol & {
3261
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3262
+ };
3263
+ readonly path: [];
3264
+ readonly query: [];
3265
+ readonly hash: "";
3266
+ readonly headers: {};
3267
+ readonly body: symbol & {
3268
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3269
+ };
3270
+ readonly extra: {};
3271
+ readonly settings: {
3272
+ readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
3273
+ readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3274
+ readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3275
+ readonly maxRestarts: 3;
3276
+ readonly default: symbol & {
3277
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3278
+ };
3279
+ };
3280
+ readonly middlewares: {
3281
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
3282
+ readonly before: [];
3283
+ readonly after: [];
3284
+ readonly onResult: [];
3285
+ readonly onError: [];
3286
+ };
3287
+ readonly retry: {
3288
+ readonly __brand: VigorBrand<"Retry", "Schema">;
3289
+ readonly policy: {
3290
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3291
+ readonly target: symbol & {
3292
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3293
+ };
3294
+ readonly abortSignals: [];
3295
+ readonly settings: {
3296
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3297
+ readonly default: symbol & {
3298
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3299
+ };
3300
+ readonly maxAttempts: 5;
3301
+ readonly maxRestarts: 3;
3302
+ readonly timeout: 20000;
3303
+ };
3304
+ readonly middlewares: {
3305
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3306
+ readonly before: [];
3307
+ readonly after: [];
3308
+ readonly onResult: [];
3309
+ readonly retryIf: [];
3310
+ readonly onRetry: [];
3311
+ readonly onError: [];
3312
+ };
3313
+ readonly algorithms: {
3314
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3315
+ readonly _tag: "constant";
3316
+ readonly jitter: 1000;
3317
+ readonly interval: 2000;
3318
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3319
+ };
3320
+ };
3321
+ readonly context: {
3322
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3323
+ readonly result: symbol & {
3324
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3325
+ };
3326
+ readonly error: symbol & {
3327
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3328
+ };
3329
+ readonly system: {
3330
+ readonly delay: symbol & {
3331
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3332
+ };
3333
+ readonly attempt: 0;
3334
+ };
3335
+ readonly flags: {
3336
+ readonly doRetry: true;
3337
+ readonly doRestart: false;
3338
+ readonly brokeRetry: false;
3339
+ readonly overridden: false;
3340
+ };
3341
+ readonly record: {};
3342
+ readonly policy: {
3343
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3344
+ readonly target: symbol & {
3345
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3346
+ };
3347
+ readonly abortSignals: [];
3348
+ readonly settings: {
3349
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3350
+ readonly default: symbol & {
3351
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3352
+ };
3353
+ readonly maxAttempts: 5;
3354
+ readonly maxRestarts: 3;
3355
+ readonly timeout: 20000;
3356
+ };
3357
+ readonly middlewares: {
3358
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3359
+ readonly before: [];
3360
+ readonly after: [];
3361
+ readonly onResult: [];
3362
+ readonly retryIf: [];
3363
+ readonly onRetry: [];
3364
+ readonly onError: [];
3365
+ };
3366
+ readonly algorithms: {
3367
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3368
+ readonly _tag: "constant";
3369
+ readonly jitter: 1000;
3370
+ readonly interval: 2000;
3371
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3372
+ };
3373
+ };
3374
+ };
3375
+ };
3376
+ readonly parse: {
3377
+ readonly __brand: VigorBrand<"Parse", "Schema">;
3378
+ readonly policy: {
3379
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3380
+ readonly target: symbol & {
3381
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3382
+ };
3383
+ readonly settings: {
3384
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3385
+ readonly raw: false;
3386
+ readonly default: symbol & {
3387
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3388
+ };
3389
+ readonly maxRestarts: 3;
3390
+ };
3391
+ readonly middlewares: {
3392
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3393
+ readonly before: [];
3394
+ readonly after: [];
3395
+ readonly onResult: [];
3396
+ readonly onError: [];
3397
+ };
3398
+ readonly strategies: {
3399
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3400
+ readonly funcs: VigorParseStrategyFunc[];
3401
+ };
3402
+ };
3403
+ readonly context: {
3404
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3405
+ readonly result: symbol & {
3406
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3407
+ };
3408
+ readonly error: symbol & {
3409
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3410
+ };
3411
+ readonly response: symbol & {
3412
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3413
+ };
3414
+ readonly flags: {
3415
+ readonly overrided: false;
3416
+ readonly restarted: false;
3417
+ };
3418
+ readonly record: {};
3419
+ readonly policy: {
3420
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3421
+ readonly target: symbol & {
3422
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3423
+ };
3424
+ readonly settings: {
3425
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3426
+ readonly raw: false;
3427
+ readonly default: symbol & {
3428
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3429
+ };
3430
+ readonly maxRestarts: 3;
3431
+ };
3432
+ readonly middlewares: {
3433
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3434
+ readonly before: [];
3435
+ readonly after: [];
3436
+ readonly onResult: [];
3437
+ readonly onError: [];
3438
+ };
3439
+ readonly strategies: {
3440
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3441
+ readonly funcs: VigorParseStrategyFunc[];
3442
+ };
3443
+ };
3444
+ };
3445
+ };
3446
+ };
3447
+ };
3448
+ }>;
3449
+ };
3450
+ retry: {
3451
+ settings: () => VigorRetryPolicySettings<{
3452
+ readonly __brand: VigorBrand<"Retry", "Schema">;
3453
+ readonly policy: {
3454
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3455
+ readonly target: symbol & {
3456
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3457
+ };
3458
+ readonly abortSignals: [];
3459
+ readonly settings: {
3460
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3461
+ readonly default: symbol & {
3462
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3463
+ };
3464
+ readonly maxAttempts: 5;
3465
+ readonly maxRestarts: 3;
3466
+ readonly timeout: 20000;
3467
+ };
3468
+ readonly middlewares: {
3469
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3470
+ readonly before: [];
3471
+ readonly after: [];
3472
+ readonly onResult: [];
3473
+ readonly retryIf: [];
3474
+ readonly onRetry: [];
3475
+ readonly onError: [];
3476
+ };
3477
+ readonly algorithms: {
3478
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3479
+ readonly _tag: "constant";
3480
+ readonly jitter: 1000;
3481
+ readonly interval: 2000;
3482
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3483
+ };
3484
+ };
3485
+ readonly context: {
3486
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3487
+ readonly result: symbol & {
3488
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3489
+ };
3490
+ readonly error: symbol & {
3491
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3492
+ };
3493
+ readonly system: {
3494
+ readonly delay: symbol & {
3495
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3496
+ };
3497
+ readonly attempt: 0;
3498
+ };
3499
+ readonly flags: {
3500
+ readonly doRetry: true;
3501
+ readonly doRestart: false;
3502
+ readonly brokeRetry: false;
3503
+ readonly overridden: false;
3504
+ };
3505
+ readonly record: {};
3506
+ readonly policy: {
3507
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3508
+ readonly target: symbol & {
3509
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3510
+ };
3511
+ readonly abortSignals: [];
3512
+ readonly settings: {
3513
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3514
+ readonly default: symbol & {
3515
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3516
+ };
3517
+ readonly maxAttempts: 5;
3518
+ readonly maxRestarts: 3;
3519
+ readonly timeout: 20000;
3520
+ };
3521
+ readonly middlewares: {
3522
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3523
+ readonly before: [];
3524
+ readonly after: [];
3525
+ readonly onResult: [];
3526
+ readonly retryIf: [];
3527
+ readonly onRetry: [];
3528
+ readonly onError: [];
3529
+ };
3530
+ readonly algorithms: {
3531
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3532
+ readonly _tag: "constant";
3533
+ readonly jitter: 1000;
3534
+ readonly interval: 2000;
3535
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3536
+ };
3537
+ };
3538
+ };
3539
+ }>;
3540
+ middlewares: () => VigorRetryPolicyMiddlewares<{
3541
+ readonly __brand: VigorBrand<"Retry", "Schema">;
3542
+ readonly policy: {
3543
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3544
+ readonly target: symbol & {
3545
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3546
+ };
3547
+ readonly abortSignals: [];
3548
+ readonly settings: {
3549
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3550
+ readonly default: symbol & {
3551
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3552
+ };
3553
+ readonly maxAttempts: 5;
3554
+ readonly maxRestarts: 3;
3555
+ readonly timeout: 20000;
3556
+ };
3557
+ readonly middlewares: {
3558
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3559
+ readonly before: [];
3560
+ readonly after: [];
3561
+ readonly onResult: [];
3562
+ readonly retryIf: [];
3563
+ readonly onRetry: [];
3564
+ readonly onError: [];
3565
+ };
3566
+ readonly algorithms: {
3567
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3568
+ readonly _tag: "constant";
3569
+ readonly jitter: 1000;
3570
+ readonly interval: 2000;
3571
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3572
+ };
3573
+ };
3574
+ readonly context: {
3575
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3576
+ readonly result: symbol & {
3577
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3578
+ };
3579
+ readonly error: symbol & {
3580
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3581
+ };
3582
+ readonly system: {
3583
+ readonly delay: symbol & {
3584
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3585
+ };
3586
+ readonly attempt: 0;
3587
+ };
3588
+ readonly flags: {
3589
+ readonly doRetry: true;
3590
+ readonly doRestart: false;
3591
+ readonly brokeRetry: false;
3592
+ readonly overridden: false;
3593
+ };
3594
+ readonly record: {};
3595
+ readonly policy: {
3596
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3597
+ readonly target: symbol & {
3598
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3599
+ };
3600
+ readonly abortSignals: [];
3601
+ readonly settings: {
3602
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3603
+ readonly default: symbol & {
3604
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3605
+ };
3606
+ readonly maxAttempts: 5;
3607
+ readonly maxRestarts: 3;
3608
+ readonly timeout: 20000;
3609
+ };
3610
+ readonly middlewares: {
3611
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3612
+ readonly before: [];
3613
+ readonly after: [];
3614
+ readonly onResult: [];
3615
+ readonly retryIf: [];
3616
+ readonly onRetry: [];
3617
+ readonly onError: [];
3618
+ };
3619
+ readonly algorithms: {
3620
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3621
+ readonly _tag: "constant";
3622
+ readonly jitter: 1000;
3623
+ readonly interval: 2000;
3624
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3625
+ };
3626
+ };
3627
+ };
3628
+ }>;
3629
+ algorithms: () => VigorRetryPolicyAlgorithms<{
3630
+ readonly __brand: VigorBrand<"Retry", "Schema">;
3631
+ readonly policy: {
3632
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3633
+ readonly target: symbol & {
3634
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3635
+ };
3636
+ readonly abortSignals: [];
3637
+ readonly settings: {
3638
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3639
+ readonly default: symbol & {
3640
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3641
+ };
3642
+ readonly maxAttempts: 5;
3643
+ readonly maxRestarts: 3;
3644
+ readonly timeout: 20000;
3645
+ };
3646
+ readonly middlewares: {
3647
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3648
+ readonly before: [];
3649
+ readonly after: [];
3650
+ readonly onResult: [];
3651
+ readonly retryIf: [];
3652
+ readonly onRetry: [];
3653
+ readonly onError: [];
3654
+ };
3655
+ readonly algorithms: {
3656
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3657
+ readonly _tag: "constant";
3658
+ readonly jitter: 1000;
3659
+ readonly interval: 2000;
3660
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3661
+ };
3662
+ };
3663
+ readonly context: {
3664
+ readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3665
+ readonly result: symbol & {
3666
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3667
+ };
3668
+ readonly error: symbol & {
3669
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3670
+ };
3671
+ readonly system: {
3672
+ readonly delay: symbol & {
3673
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3674
+ };
3675
+ readonly attempt: 0;
3676
+ };
3677
+ readonly flags: {
3678
+ readonly doRetry: true;
3679
+ readonly doRestart: false;
3680
+ readonly brokeRetry: false;
3681
+ readonly overridden: false;
3682
+ };
3683
+ readonly record: {};
3684
+ readonly policy: {
3685
+ readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3686
+ readonly target: symbol & {
3687
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3688
+ };
3689
+ readonly abortSignals: [];
3690
+ readonly settings: {
3691
+ readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3692
+ readonly default: symbol & {
3693
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3694
+ };
3695
+ readonly maxAttempts: 5;
3696
+ readonly maxRestarts: 3;
3697
+ readonly timeout: 20000;
3698
+ };
3699
+ readonly middlewares: {
3700
+ readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3701
+ readonly before: [];
3702
+ readonly after: [];
3703
+ readonly onResult: [];
3704
+ readonly retryIf: [];
3705
+ readonly onRetry: [];
3706
+ readonly onError: [];
3707
+ };
3708
+ readonly algorithms: {
3709
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3710
+ readonly _tag: "constant";
3711
+ readonly jitter: 1000;
3712
+ readonly interval: 2000;
3713
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3714
+ };
3715
+ };
3716
+ };
3717
+ }>;
3718
+ algorithm: {
3719
+ constant: () => VigorRetryPolicyAlgorithmsConstant<{
3720
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3721
+ readonly _tag: "constant";
3722
+ readonly jitter: 1000;
3723
+ readonly interval: 2000;
3724
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3725
+ }>;
3726
+ linear: () => VigorRetryPolicyAlgorithmsLinear<{
3727
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Linear<Schema">;
3728
+ readonly _tag: "linear";
3729
+ readonly jitter: 1000;
3730
+ readonly initial: 500;
3731
+ readonly increment: 1000;
3732
+ readonly minDelay: 0;
3733
+ readonly maxDelay: 10000;
3734
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsLinearSchema<any>) => number;
3735
+ }>;
3736
+ backoff: () => VigorRetryPolicyAlgorithmsBackoff<{
3737
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Backoff<Schema">;
3738
+ readonly _tag: "backoff";
3739
+ readonly jitter: 800;
3740
+ readonly initial: 0;
3741
+ readonly multiplier: 1.7;
3742
+ readonly unit: 1000;
3743
+ readonly minDelay: 500;
3744
+ readonly maxDelay: 10000;
3745
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsBackoffSchema<any>) => number;
3746
+ }>;
3747
+ custom: () => VigorRetryPolicyAlgorithmsCustom<{
3748
+ readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Custom<Schema">;
3749
+ readonly _tag: "custom";
3750
+ readonly jitter: 800;
3751
+ readonly minDelay: 500;
3752
+ readonly maxDelay: 10000;
3753
+ readonly target: symbol & {
3754
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3755
+ };
3756
+ readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsCustomSchema<any>) => number;
3757
+ }>;
3758
+ };
3759
+ };
3760
+ parse: {
3761
+ settings: () => VigorParsePolicySettings<{
3762
+ readonly __brand: VigorBrand<"Parse", "Schema">;
3763
+ readonly policy: {
3764
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3765
+ readonly target: symbol & {
3766
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3767
+ };
3768
+ readonly settings: {
3769
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3770
+ readonly raw: false;
3771
+ readonly default: symbol & {
3772
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3773
+ };
3774
+ readonly maxRestarts: 3;
3775
+ };
3776
+ readonly middlewares: {
3777
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3778
+ readonly before: [];
3779
+ readonly after: [];
3780
+ readonly onResult: [];
3781
+ readonly onError: [];
3782
+ };
3783
+ readonly strategies: {
3784
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3785
+ readonly funcs: VigorParseStrategyFunc[];
3786
+ };
3787
+ };
3788
+ readonly context: {
3789
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3790
+ readonly result: symbol & {
3791
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3792
+ };
3793
+ readonly error: symbol & {
3794
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3795
+ };
3796
+ readonly response: symbol & {
3797
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3798
+ };
3799
+ readonly flags: {
3800
+ readonly overrided: false;
3801
+ readonly restarted: false;
3802
+ };
3803
+ readonly record: {};
3804
+ readonly policy: {
3805
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3806
+ readonly target: symbol & {
3807
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3808
+ };
3809
+ readonly settings: {
3810
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3811
+ readonly raw: false;
3812
+ readonly default: symbol & {
3813
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3814
+ };
3815
+ readonly maxRestarts: 3;
3816
+ };
3817
+ readonly middlewares: {
3818
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3819
+ readonly before: [];
3820
+ readonly after: [];
3821
+ readonly onResult: [];
3822
+ readonly onError: [];
3823
+ };
3824
+ readonly strategies: {
3825
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3826
+ readonly funcs: VigorParseStrategyFunc[];
3827
+ };
3828
+ };
3829
+ };
3830
+ }>;
3831
+ middlewares: () => VigorParsePolicyMiddlewares<{
3832
+ readonly __brand: VigorBrand<"Parse", "Schema">;
3833
+ readonly policy: {
3834
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3835
+ readonly target: symbol & {
3836
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3837
+ };
3838
+ readonly settings: {
3839
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3840
+ readonly raw: false;
3841
+ readonly default: symbol & {
3842
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3843
+ };
3844
+ readonly maxRestarts: 3;
3845
+ };
3846
+ readonly middlewares: {
3847
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3848
+ readonly before: [];
3849
+ readonly after: [];
3850
+ readonly onResult: [];
3851
+ readonly onError: [];
3852
+ };
3853
+ readonly strategies: {
3854
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3855
+ readonly funcs: VigorParseStrategyFunc[];
3856
+ };
3857
+ };
3858
+ readonly context: {
3859
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3860
+ readonly result: symbol & {
3861
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3862
+ };
3863
+ readonly error: symbol & {
3864
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3865
+ };
3866
+ readonly response: symbol & {
3867
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3868
+ };
3869
+ readonly flags: {
3870
+ readonly overrided: false;
3871
+ readonly restarted: false;
3872
+ };
3873
+ readonly record: {};
3874
+ readonly policy: {
3875
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3876
+ readonly target: symbol & {
3877
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3878
+ };
3879
+ readonly settings: {
3880
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3881
+ readonly raw: false;
3882
+ readonly default: symbol & {
3883
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3884
+ };
3885
+ readonly maxRestarts: 3;
3886
+ };
3887
+ readonly middlewares: {
3888
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3889
+ readonly before: [];
3890
+ readonly after: [];
3891
+ readonly onResult: [];
3892
+ readonly onError: [];
3893
+ };
3894
+ readonly strategies: {
3895
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3896
+ readonly funcs: VigorParseStrategyFunc[];
3897
+ };
3898
+ };
3899
+ };
3900
+ }>;
3901
+ strategies: () => VigorParsePolicyStrategies<{
3902
+ readonly __brand: VigorBrand<"Parse", "Schema">;
3903
+ readonly policy: {
3904
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3905
+ readonly target: symbol & {
3906
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3907
+ };
3908
+ readonly settings: {
3909
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3910
+ readonly raw: false;
3911
+ readonly default: symbol & {
3912
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3913
+ };
3914
+ readonly maxRestarts: 3;
3915
+ };
3916
+ readonly middlewares: {
3917
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3918
+ readonly before: [];
3919
+ readonly after: [];
3920
+ readonly onResult: [];
3921
+ readonly onError: [];
3922
+ };
3923
+ readonly strategies: {
3924
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3925
+ readonly funcs: VigorParseStrategyFunc[];
3926
+ };
3927
+ };
3928
+ readonly context: {
3929
+ readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3930
+ readonly result: symbol & {
3931
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3932
+ };
3933
+ readonly error: symbol & {
3934
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3935
+ };
3936
+ readonly response: symbol & {
3937
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3938
+ };
3939
+ readonly flags: {
3940
+ readonly overrided: false;
3941
+ readonly restarted: false;
3942
+ };
3943
+ readonly record: {};
3944
+ readonly policy: {
3945
+ readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3946
+ readonly target: symbol & {
3947
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3948
+ };
3949
+ readonly settings: {
3950
+ readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3951
+ readonly raw: false;
3952
+ readonly default: symbol & {
3953
+ __brand: VigorBrand<"Core", "Symbol_Empty">;
3954
+ };
3955
+ readonly maxRestarts: 3;
3956
+ };
3957
+ readonly middlewares: {
3958
+ readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3959
+ readonly before: [];
3960
+ readonly after: [];
3961
+ readonly onResult: [];
3962
+ readonly onError: [];
3963
+ };
3964
+ readonly strategies: {
3965
+ readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3966
+ readonly funcs: VigorParseStrategyFunc[];
3967
+ };
3968
+ };
3969
+ };
3970
+ }>;
3971
+ };
3972
+ all: {
3973
+ settings: () => VigorAllPolicySettings<{
3974
+ readonly __brand: VigorBrand<"All", "Schema">;
3975
+ readonly policy: {
3976
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
3977
+ readonly target: VigorAllTask[];
3978
+ readonly settings: {
3979
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
3980
+ readonly concurrency: 5;
3981
+ readonly onlySuccess: false;
3982
+ };
3983
+ readonly middlewares: {
3984
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
3985
+ readonly before: VigorAllEachMiddlewareFn[];
3986
+ readonly after: VigorAllEachMiddlewareFn[];
3987
+ readonly onError: VigorAllEachOnErrorFn[];
3988
+ };
3989
+ };
3990
+ readonly context: {
3991
+ readonly __brand: VigorBrand<"All", "Context<Schema">;
3992
+ readonly result: symbol & {
3993
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3994
+ };
3995
+ readonly policy: {
3996
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
3997
+ readonly target: VigorAllTask[];
3998
+ readonly settings: {
3999
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
4000
+ readonly concurrency: 5;
4001
+ readonly onlySuccess: false;
4002
+ };
4003
+ readonly middlewares: {
4004
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
4005
+ readonly before: VigorAllEachMiddlewareFn[];
4006
+ readonly after: VigorAllEachMiddlewareFn[];
4007
+ readonly onError: VigorAllEachOnErrorFn[];
4008
+ };
4009
+ };
4010
+ readonly record: {};
4011
+ };
4012
+ }>;
4013
+ middlewares: () => VigorAllPolicyMiddlewares<{
4014
+ readonly __brand: VigorBrand<"All", "Schema">;
4015
+ readonly policy: {
4016
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
4017
+ readonly target: VigorAllTask[];
4018
+ readonly settings: {
4019
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
4020
+ readonly concurrency: 5;
4021
+ readonly onlySuccess: false;
4022
+ };
4023
+ readonly middlewares: {
4024
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
4025
+ readonly before: VigorAllEachMiddlewareFn[];
4026
+ readonly after: VigorAllEachMiddlewareFn[];
4027
+ readonly onError: VigorAllEachOnErrorFn[];
4028
+ };
4029
+ };
4030
+ readonly context: {
4031
+ readonly __brand: VigorBrand<"All", "Context<Schema">;
4032
+ readonly result: symbol & {
4033
+ __brand: VigorBrand<"Core", "Symbol_Default">;
4034
+ };
4035
+ readonly policy: {
4036
+ readonly __brand: VigorBrand<"All", "Policy<Schema">;
4037
+ readonly target: VigorAllTask[];
4038
+ readonly settings: {
4039
+ readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
4040
+ readonly concurrency: 5;
4041
+ readonly onlySuccess: false;
4042
+ };
4043
+ readonly middlewares: {
4044
+ readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
4045
+ readonly before: VigorAllEachMiddlewareFn[];
4046
+ readonly after: VigorAllEachMiddlewareFn[];
4047
+ readonly onError: VigorAllEachOnErrorFn[];
4048
+ };
4049
+ };
4050
+ readonly record: {};
4051
+ };
4052
+ }>;
4053
+ };
4054
+ };
4055
+ };
4056
+ type VigorInstance = typeof vigorBase & {
4057
+ use: <P extends VigorPlugin<any, any>>(plugin: P, options?: P["options"]) => VigorInstance & ReturnType<P["func"]>;
4058
+ };
4059
+ /**
4060
+ * A plugin never mutates the `VigorInstance` it receives — it reads from it
4061
+ * (e.g. to wrap an existing method) and returns `Ext`, the properties to
4062
+ * merge into a *new* instance. `use()` owns cloning/merging, so plugins stay
4063
+ * pure and `vigor` itself is never touched.
4064
+ */
4065
+ type VigorPlugin<O extends {
4066
+ [str: string]: any;
4067
+ } = {}, Ext extends Record<string, any> = Record<string, any>> = {
4068
+ options: O;
4069
+ func: (v: VigorInstance, options: O) => Ext;
4070
+ };
4071
+ declare const vigor: VigorInstance;
4072
+
4073
+ type VigorErrorOptions<D, T> = {
4074
+ cause?: unknown;
4075
+ data: D;
4076
+ method: string;
4077
+ context?: T;
4078
+ };
4079
+ /**
4080
+ * Base class for all Vigor error types. Subclasses (`VigorRetryError`,
4081
+ * `VigorFetchError`, `VigorParseError`, `VigorAllError`) fix `C`, `D`, and
4082
+ * `T` to their own error-code union, data shape, and context shape.
4083
+ *
4084
+ * @typeParam C - Union of error codes for the subclass.
4085
+ * @typeParam D - Shape of the structured error data.
4086
+ * @typeParam T - Shape of the domain context.
4087
+ */
4088
+ declare abstract class VigorError<C extends string, D, T> extends Error {
4089
+ readonly timestamp: Date;
4090
+ readonly cause?: unknown;
4091
+ readonly code: C;
4092
+ readonly data: D;
4093
+ readonly method: string;
4094
+ readonly context: T | undefined;
4095
+ /**
4096
+ * @param code - Machine-readable error code.
4097
+ * @param message - Human-readable message (rendered after the `[code]` prefix).
4098
+ * @param options - Additional error metadata (cause, data, method, context).
4099
+ */
4100
+ constructor(code: C, message: string, options: VigorErrorOptions<D, T>);
4101
+ }
4102
+
4103
+ declare const VigorRetryErrorMessageFuncs: {
4104
+ readonly VALUE_REQUIRED: ({ key }: {
4105
+ key: string;
4106
+ }) => string;
4107
+ readonly RETRY_EXHAUSTED: ({ maxAttempts }: {
4108
+ maxAttempts: number;
4109
+ error: unknown;
4110
+ }) => string;
4111
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
4112
+ maxAttempts: number;
4113
+ error: unknown;
4114
+ }) => string;
4115
+ readonly TIMED_OUT: ({ limit }: {
4116
+ limit: number;
4117
+ }) => string;
4118
+ };
4119
+ type VigorRetryErrorCodes = keyof typeof VigorRetryErrorMessageFuncs;
4120
+ type VigorRetryErrorDatas<C extends VigorRetryErrorCodes> = Parameters<typeof VigorRetryErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
4121
+ /** Error type thrown by the retry module. */
4122
+ declare class VigorRetryError<C extends VigorRetryErrorCodes, T extends VigorRetrySchema<T>> extends VigorError<C, VigorRetryErrorDatas<C>, T["context"]> {
4123
+ /**
4124
+ * @param code - One of the retry module's error codes.
4125
+ * @param options - Error metadata, including the `data` payload for `code`.
4126
+ */
4127
+ constructor(code: C, options: VigorErrorOptions<VigorRetryErrorDatas<C>, T["context"]>);
4128
+ }
4129
+
4130
+ declare const VigorParseErrorMessageFuncs: {
4131
+ readonly VALUE_REQUIRED: ({ key }: {
4132
+ key: string;
4133
+ }) => string;
4134
+ readonly INVALID_CONTENT_TYPE: ({ received }: {
4135
+ received: unknown;
4136
+ }) => string;
4137
+ readonly PARSER_NOT_FOUND: ({ received, expected }: {
4138
+ received: unknown;
4139
+ expected: Array<string>;
4140
+ }) => string;
4141
+ readonly PARSER_ALL_FAILED: ({ tried }: {
4142
+ tried: Array<string>;
4143
+ }) => string;
4144
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
4145
+ maxAttempts: number;
4146
+ error: unknown;
4147
+ }) => string;
4148
+ };
4149
+ type VigorParseErrorCodes = keyof typeof VigorParseErrorMessageFuncs;
4150
+ type VigorParseErrorDatas<C extends VigorParseErrorCodes> = Parameters<typeof VigorParseErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
4151
+ /** Error type thrown by the parse module. */
4152
+ declare class VigorParseError<C extends VigorParseErrorCodes, T extends VigorParseSchema<T>> extends VigorError<C, VigorParseErrorDatas<C>, T["context"]> {
4153
+ /**
4154
+ * @param code - One of the parse module's error codes.
4155
+ * @param options - Error metadata, including the `data` payload for `code`.
4156
+ */
4157
+ constructor(code: C, options: VigorErrorOptions<VigorParseErrorDatas<C>, T["context"]>);
4158
+ }
4159
+
4160
+ declare const VigorFetchErrorMessageFuncs: {
4161
+ readonly VALUE_REQUIRED: ({ key }: {
4162
+ key: string;
4163
+ }) => string;
4164
+ readonly INVALID_BODY: ({ received }: {
4165
+ received: unknown;
4166
+ }) => string;
4167
+ readonly INVALID_PROTOCOL: ({ origin, base }: {
4168
+ origin: string;
4169
+ base: string | undefined;
4170
+ }) => string;
4171
+ readonly FETCH_FAILED: ({ status, statusText }: {
4172
+ status: number;
4173
+ statusText: string;
4174
+ response: Response;
4175
+ url: string;
4176
+ parsed: unknown;
4177
+ }) => string;
4178
+ readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
4179
+ maxAttempts: number;
4180
+ error: unknown;
4181
+ }) => string;
4182
+ };
4183
+ type VigorFetchErrorCodes = keyof typeof VigorFetchErrorMessageFuncs;
4184
+ type VigorFetchErrorDatas<C extends VigorFetchErrorCodes> = Parameters<typeof VigorFetchErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
4185
+ /** Error type thrown by the fetch module. */
4186
+ declare class VigorFetchError<C extends VigorFetchErrorCodes, T extends VigorFetchSchema<T>> extends VigorError<C, VigorFetchErrorDatas<C>, T["context"]> {
4187
+ /**
4188
+ * @param code - One of the fetch module's error codes.
4189
+ * @param options - Error metadata, including the `data` payload for `code`.
4190
+ */
4191
+ constructor(code: C, options: VigorErrorOptions<VigorFetchErrorDatas<C>, T["context"]>);
4192
+ }
4193
+
4194
+ declare const VigorAllErrorMessageFuncs: {
4195
+ readonly EMPTY_TARGET: (_: {}) => string;
4196
+ };
4197
+ type VigorAllErrorCodes = keyof typeof VigorAllErrorMessageFuncs;
4198
+ type VigorAllErrorDatas<C extends VigorAllErrorCodes> = Parameters<typeof VigorAllErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
4199
+ /** Error type thrown by the all module. */
4200
+ declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSchema<T>> extends VigorError<C, VigorAllErrorDatas<C>, T["context"]> {
4201
+ /**
4202
+ * @param code - One of the all module's error codes.
4203
+ * @param options - Error metadata, including the `data` payload for `code`.
4204
+ */
4205
+ constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, T["context"]>);
4206
+ }
4207
+
4208
+ export { VigorAll, VigorAllBase, type VigorAllEachMiddlewareFn, type VigorAllEachOnErrorFn, VigorAllError, type VigorAllErrorCodes, type VigorAllErrorDatas, VigorAllErrorMessageFuncs, VigorAllPolicyBase, VigorAllPolicyMiddlewares, VigorAllPolicyMiddlewaresBase, type VigorAllPolicyMiddlewaresSchema, type VigorAllPolicySchema, VigorAllPolicySettings, VigorAllPolicySettingsBase, type VigorAllPolicySettingsSchema, type VigorAllSchema, type VigorAllTask, type VigorBuiltin, type VigorConcat, type VigorDeepMerge, type VigorDeepPartial, VigorError, type VigorErrorOptions, VigorFetch, VigorFetchBase, VigorFetchError, type VigorFetchErrorCodes, type VigorFetchErrorDatas, VigorFetchErrorMessageFuncs, VigorFetchPolicyBase, VigorFetchPolicyMiddlewares, type VigorFetchPolicyMiddlewaresApi, VigorFetchPolicyMiddlewaresBase, type VigorFetchPolicyMiddlewaresFluent, type VigorFetchPolicyMiddlewaresIntercept, 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, VigorParsePolicyBase, VigorParsePolicyMiddlewares, type VigorParsePolicyMiddlewaresApi, VigorParsePolicyMiddlewaresBase, type VigorParsePolicyMiddlewaresFluent, type VigorParsePolicyMiddlewaresIntercept, 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 };