vigor-fetch 4.0.4 → 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.
package/dist/index.d.ts CHANGED
@@ -43,6 +43,19 @@ declare const VigorEmpty: symbol & {
43
43
  type VigorEmptyType = typeof VigorEmpty;
44
44
  type VigorExcludeEmpty<T> = Exclude<T, VigorEmptyType>;
45
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
+
46
59
  /**
47
60
  * Base class for Vigor's immutable, chainable builder objects.
48
61
  *
@@ -88,236 +101,6 @@ declare abstract class VigorStatus<Base, Config extends Base, TL extends VigorTy
88
101
  get config(): Config;
89
102
  }
90
103
 
91
- type VigorAllPolicySettingsSchema<T extends VigorAllSchema<T>> = {
92
- __brand: VigorBrand<"All", "Policy<Settings<Schema">;
93
- concurrency: number;
94
- onlySuccess: boolean;
95
- };
96
- declare const VigorAllPolicySettingsBase: {
97
- readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
98
- readonly concurrency: 5;
99
- readonly onlySuccess: false;
100
- };
101
- /** Immutable builder for an all-policy's general settings. */
102
- declare class VigorAllPolicySettings<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<any>, T, VigorAllPolicySettingsTypeLambda> {
103
- constructor(config?: T);
104
- protected _create<C>(config: C): VigorApply<VigorAllPolicySettingsTypeLambda, C>;
105
- /** Sets the maximum number of tasks run concurrently. */
106
- concurrency<const N extends VigorAllSchema<any>["policy"]["settings"]["concurrency"]>(num: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
107
- readonly policy: {
108
- readonly settings: {
109
- readonly concurrency: N;
110
- };
111
- };
112
- }>>>;
113
- /** When enabled, filters the final result down to only the tasks that succeeded. */
114
- onlySuccess<const N extends VigorAllSchema<any>["policy"]["settings"]["onlySuccess"]>(bool: N): VigorAllPolicySettings<VigorAllIn<VigorDeepMerge<T, {
115
- readonly policy: {
116
- readonly settings: {
117
- readonly onlySuccess: N;
118
- };
119
- };
120
- }>>>;
121
- }
122
-
123
- type VigorAllTask = () => unknown | Promise<unknown>;
124
- type VigorAllPolicySchema<T extends VigorAllSchema<T>> = {
125
- __brand: VigorBrand<"All", "Policy<Schema">;
126
- target: VigorAllTask[];
127
- settings: VigorAllPolicySettingsSchema<T>;
128
- middlewares: VigorAllPolicyMiddlewaresSchema<T>;
129
- };
130
- declare const VigorAllPolicyBase: {
131
- readonly __brand: VigorBrand<"All", "Policy<Schema">;
132
- readonly target: VigorAllTask[];
133
- readonly settings: {
134
- readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
135
- readonly concurrency: 5;
136
- readonly onlySuccess: false;
137
- };
138
- readonly middlewares: {
139
- readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
140
- readonly before: VigorAllEachMiddlewareFn[];
141
- readonly after: VigorAllEachMiddlewareFn[];
142
- readonly onError: VigorAllEachOnErrorFn[];
143
- };
144
- };
145
-
146
- type VigorAllContextSchema<T extends VigorAllSchema<T>> = {
147
- __brand: VigorBrand<"All", "Context<Schema">;
148
- result: unknown[] | VigorDefaultType;
149
- policy: T["policy"];
150
- record: Record<string, any>;
151
- };
152
- type VigorAllEachContextSchema<T extends VigorAllSchema<T>> = {
153
- __brand: VigorBrand<"All", "EachContext<Schema">;
154
- result: unknown | VigorDefaultType;
155
- error: unknown;
156
- flags: {
157
- overrided: boolean;
158
- };
159
- record: Record<string, any>;
160
- };
161
-
162
- type VigorAllSchema<T extends VigorAllSchema<T>> = {
163
- __brand: VigorBrand<"All", "Schema">;
164
- policy: VigorAllPolicySchema<T>;
165
- context: VigorAllContextSchema<T>;
166
- };
167
- declare const VigorAllBase: {
168
- readonly __brand: VigorBrand<"All", "Schema">;
169
- readonly policy: {
170
- readonly __brand: VigorBrand<"All", "Policy<Schema">;
171
- readonly target: VigorAllTask[];
172
- readonly settings: {
173
- readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
174
- readonly concurrency: 5;
175
- readonly onlySuccess: false;
176
- };
177
- readonly middlewares: {
178
- readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
179
- readonly before: VigorAllEachMiddlewareFn[];
180
- readonly after: VigorAllEachMiddlewareFn[];
181
- readonly onError: VigorAllEachOnErrorFn[];
182
- };
183
- };
184
- readonly context: {
185
- readonly __brand: VigorBrand<"All", "Context<Schema">;
186
- readonly result: symbol & {
187
- __brand: VigorBrand<"Core", "Symbol_Default">;
188
- };
189
- readonly policy: {
190
- readonly __brand: VigorBrand<"All", "Policy<Schema">;
191
- readonly target: VigorAllTask[];
192
- readonly settings: {
193
- readonly __brand: VigorBrand<"All", "Policy<Settings<Schema">;
194
- readonly concurrency: 5;
195
- readonly onlySuccess: false;
196
- };
197
- readonly middlewares: {
198
- readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
199
- readonly before: VigorAllEachMiddlewareFn[];
200
- readonly after: VigorAllEachMiddlewareFn[];
201
- readonly onError: VigorAllEachOnErrorFn[];
202
- };
203
- };
204
- readonly record: {};
205
- };
206
- };
207
- /**
208
- * Immutable builder that runs a list of independent tasks with bounded
209
- * concurrency, per-task middleware, and either an all-results or
210
- * only-successes result mode.
211
- */
212
- declare class VigorAll<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<T>, T, VigorAllTypeLambda> {
213
- constructor(config?: T);
214
- protected _create<C>(config: C): VigorApply<VigorAllTypeLambda, C>;
215
- /** Sets the list of tasks to run. */
216
- target<const N extends VigorAllTask[]>(...funcs: N): VigorAll<VigorAllIn<VigorDeepMerge<T, {
217
- readonly policy: {
218
- readonly target: N;
219
- };
220
- }>>>;
221
- /** Configures the all-policy's general settings (concurrency, onlySuccess). */
222
- settings<const N extends VigorDeepPartial<VigorAllPolicySettingsSchema<T>>, R extends VigorAllSchema<any>>(input: N | ((s: VigorAllPolicySettings<T>) => VigorAllPolicySettings<R>) | VigorAllPolicySettings<R>): VigorAll<VigorAllIn<VigorDeepMerge<T, {
223
- readonly policy: {
224
- readonly settings: VigorAllPolicySettingsSchema<any>;
225
- };
226
- }>>>;
227
- /** Configures the all-policy's per-task middleware pipeline. */
228
- middlewares<const N extends VigorDeepPartial<VigorAllPolicyMiddlewaresSchema<T>>, R extends VigorAllSchema<any>>(input: N | ((s: VigorAllPolicyMiddlewares<T>) => VigorAllPolicyMiddlewares<R>) | VigorAllPolicyMiddlewares<R>): VigorAll<VigorAllIn<VigorDeepMerge<T, {
229
- readonly policy: {
230
- readonly middlewares: VigorAllPolicyMiddlewaresSchema<any>;
231
- };
232
- }>>>;
233
- /** Runs a single task through the before/after/onError middleware pipeline. */
234
- private _runTask;
235
- /** Runs all tasks and returns the results array directly, throwing on final failure. */
236
- request<R extends unknown[] = unknown[]>(): Promise<R>;
237
- /** Runs all tasks and returns a result/error envelope instead of throwing. */
238
- requestVerbose<R extends unknown[] = unknown[]>(): Promise<{
239
- success: false;
240
- data: null;
241
- error: unknown;
242
- } | {
243
- success: true;
244
- data: R;
245
- error: null;
246
- }>;
247
- /** Internal execution loop implementing the bounded-concurrency worker pool. */
248
- private requestRuntime;
249
- }
250
-
251
- type VigorAllIn<T> = T extends VigorAllSchema<any> ? T : never;
252
- interface VigorAllTypeLambda extends VigorTypeLambda {
253
- readonly Target: VigorAll<VigorAllIn<this["In"]>>;
254
- }
255
- interface VigorAllPolicySettingsTypeLambda extends VigorTypeLambda {
256
- readonly Target: VigorAllPolicySettings<VigorAllIn<this["In"]>>;
257
- }
258
- interface VigorAllPolicyMiddlewaresTypeLambda extends VigorTypeLambda {
259
- readonly Target: VigorAllPolicyMiddlewares<VigorAllIn<this["In"]>>;
260
- }
261
-
262
- type VigorAllEachMiddlewareFn = (ctx: VigorAllEachContextSchema<any>) => void | Promise<void>;
263
- type VigorAllEachOnErrorFn = (ctx: VigorAllEachContextSchema<any>, api: {
264
- setResult: (r: unknown) => void;
265
- }) => void | Promise<void>;
266
- type VigorAllPolicyMiddlewaresSchema<T extends VigorAllSchema<T>> = {
267
- __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
268
- before: VigorAllEachMiddlewareFn[];
269
- after: VigorAllEachMiddlewareFn[];
270
- onError: VigorAllEachOnErrorFn[];
271
- };
272
- declare const VigorAllPolicyMiddlewaresBase: {
273
- readonly __brand: VigorBrand<"All", "Policy<Middlewares<Schema">;
274
- readonly before: VigorAllEachMiddlewareFn[];
275
- readonly after: VigorAllEachMiddlewareFn[];
276
- readonly onError: VigorAllEachOnErrorFn[];
277
- };
278
- /** Immutable builder for an all-policy's per-task middleware pipeline (`before`, `after`, `onError`). */
279
- declare class VigorAllPolicyMiddlewares<T extends VigorAllSchema<T> = typeof VigorAllBase> extends VigorStatus<VigorAllSchema<any>, T, VigorAllPolicyMiddlewaresTypeLambda> {
280
- constructor(config?: T);
281
- protected _create<C>(config: C): VigorApply<VigorAllPolicyMiddlewaresTypeLambda, C>;
282
- /** Registers a middleware that runs before each task is invoked. */
283
- before<const N extends VigorAllEachMiddlewareFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
284
- readonly policy: {
285
- readonly middlewares: {
286
- readonly before: readonly [N];
287
- };
288
- };
289
- }>>>;
290
- /** Registers a middleware that runs after each task settles successfully. */
291
- after<const N extends VigorAllEachMiddlewareFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
292
- readonly policy: {
293
- readonly middlewares: {
294
- readonly after: readonly [N];
295
- };
296
- };
297
- }>>>;
298
- /** Registers a middleware that runs when an individual task fails. */
299
- onError<const N extends VigorAllEachOnErrorFn>(func: N): VigorAllPolicyMiddlewares<VigorAllIn<VigorDeepMerge<T, {
300
- readonly policy: {
301
- readonly middlewares: {
302
- readonly onError: readonly [N];
303
- };
304
- };
305
- }>>>;
306
- }
307
-
308
- type VigorParseContextSchema<T extends VigorParseSchema<T>> = {
309
- __brand: VigorBrand<"Parse", "Context<Schema">;
310
- result: unknown | VigorDefaultType;
311
- error: unknown;
312
- response: VigorParsePolicySchema<T>["target"];
313
- flags: {
314
- overrided: boolean;
315
- restarted: boolean;
316
- };
317
- record: Record<string, any>;
318
- policy: T["policy"];
319
- };
320
-
321
104
  type VigorParsePolicySettingsSchema<T extends VigorParseSchema<T>> = {
322
105
  __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
323
106
  raw: boolean;
@@ -1552,8 +1335,8 @@ declare class VigorRetryPolicyAlgorithms<T extends VigorRetrySchema<T> = typeof
1552
1335
  initial: 0;
1553
1336
  minDelay: 500;
1554
1337
  maxDelay: 10000;
1555
- multiplier: 1.7;
1556
1338
  unit: 1000;
1339
+ multiplier: 1.7;
1557
1340
  };
1558
1341
  };
1559
1342
  }>>>;
@@ -1575,14 +1358,231 @@ declare class VigorRetryPolicyAlgorithms<T extends VigorRetrySchema<T> = typeof
1575
1358
  }>>>;
1576
1359
  }
1577
1360
 
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;
1361
+ type VigorAllPolicySettingsSchema<T extends VigorAllSchema<T>> = {
1362
+ __brand: VigorBrand<"All", "Policy<Settings<Schema">;
1363
+ concurrency: number;
1364
+ onlySuccess: boolean;
1584
1365
  };
1585
- declare const VigorFetchPolicySettingsBase: {
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
1586
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
1587
1587
  readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
1588
1588
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
@@ -2201,1339 +2201,68 @@ declare const VigorFetchBase: {
2201
2201
  readonly policy: {
2202
2202
  readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2203
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
- type VigorPlugin<O extends {
2585
- [str: string]: any;
2586
- }> = {
2587
- options: O;
2588
- func: (v: typeof vigor, options: O) => void;
2589
- };
2590
- declare const vigor: {
2591
- readonly use: <P extends VigorPlugin<any>>(plugin: P, options?: P["options"]) => void;
2592
- readonly retry: (task?: Parameters<VigorRetry["target"]>[0]) => VigorRetry<{
2593
- readonly __brand: VigorBrand<"Retry", "Schema">;
2594
- readonly policy: {
2595
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2596
- readonly target: symbol & {
2597
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2598
- };
2599
- readonly abortSignals: [];
2600
- readonly settings: {
2601
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2602
- readonly default: symbol & {
2603
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2604
- };
2605
- readonly maxAttempts: 5;
2606
- readonly maxRestarts: 3;
2607
- readonly timeout: 20000;
2608
- };
2609
- readonly middlewares: {
2610
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2611
- readonly before: [];
2612
- readonly after: [];
2613
- readonly onResult: [];
2614
- readonly retryIf: [];
2615
- readonly onRetry: [];
2616
- readonly onError: [];
2617
- };
2618
- readonly algorithms: {
2619
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2620
- readonly _tag: "constant";
2621
- readonly jitter: 1000;
2622
- readonly interval: 2000;
2623
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2624
- };
2625
- };
2626
- readonly context: {
2627
- readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2628
- readonly result: symbol & {
2629
- __brand: VigorBrand<"Core", "Symbol_Default">;
2630
- };
2631
- readonly error: symbol & {
2632
- __brand: VigorBrand<"Core", "Symbol_Default">;
2633
- };
2634
- readonly system: {
2635
- readonly delay: symbol & {
2636
- __brand: VigorBrand<"Core", "Symbol_Default">;
2637
- };
2638
- readonly attempt: 0;
2639
- };
2640
- readonly flags: {
2641
- readonly doRetry: true;
2642
- readonly doRestart: false;
2643
- readonly brokeRetry: false;
2644
- readonly overridden: false;
2645
- };
2646
- readonly record: {};
2647
- readonly policy: {
2648
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2649
- readonly target: symbol & {
2650
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2651
- };
2652
- readonly abortSignals: [];
2653
- readonly settings: {
2654
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2655
- readonly default: symbol & {
2656
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2657
- };
2658
- readonly maxAttempts: 5;
2659
- readonly maxRestarts: 3;
2660
- readonly timeout: 20000;
2661
- };
2662
- readonly middlewares: {
2663
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2664
- readonly before: [];
2665
- readonly after: [];
2666
- readonly onResult: [];
2667
- readonly retryIf: [];
2668
- readonly onRetry: [];
2669
- readonly onError: [];
2670
- };
2671
- readonly algorithms: {
2672
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2673
- readonly _tag: "constant";
2674
- readonly jitter: 1000;
2675
- readonly interval: 2000;
2676
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2677
- };
2678
- };
2679
- };
2680
- }> | VigorRetry<{
2681
- context: {
2682
- readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2683
- readonly result: symbol & {
2684
- __brand: VigorBrand<"Core", "Symbol_Default">;
2685
- };
2686
- readonly error: symbol & {
2687
- __brand: VigorBrand<"Core", "Symbol_Default">;
2688
- };
2689
- readonly system: {
2690
- readonly delay: symbol & {
2691
- __brand: VigorBrand<"Core", "Symbol_Default">;
2692
- };
2693
- readonly attempt: 0;
2694
- };
2695
- readonly flags: {
2696
- readonly doRetry: true;
2697
- readonly doRestart: false;
2698
- readonly brokeRetry: false;
2699
- readonly overridden: false;
2700
- };
2701
- readonly record: {};
2702
- readonly policy: {
2703
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2704
- readonly target: symbol & {
2705
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2706
- };
2707
- readonly abortSignals: [];
2708
- readonly settings: {
2709
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2710
- readonly default: symbol & {
2711
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2712
- };
2713
- readonly maxAttempts: 5;
2714
- readonly maxRestarts: 3;
2715
- readonly timeout: 20000;
2716
- };
2717
- readonly middlewares: {
2718
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2719
- readonly before: [];
2720
- readonly after: [];
2721
- readonly onResult: [];
2722
- readonly retryIf: [];
2723
- readonly onRetry: [];
2724
- readonly onError: [];
2725
- };
2726
- readonly algorithms: {
2727
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2728
- readonly _tag: "constant";
2729
- readonly jitter: 1000;
2730
- readonly interval: 2000;
2731
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2732
- };
2733
- };
2734
- };
2735
- policy: {
2736
- target: (signal: AbortSignal) => any | Promise<any>;
2737
- 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
- __brand: VigorBrand<"Retry", "Policy<Schema">;
2747
- abortSignals: [];
2748
- settings: {
2749
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2750
- readonly default: symbol & {
2751
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2752
- };
2753
- readonly maxAttempts: 5;
2754
- readonly maxRestarts: 3;
2755
- readonly timeout: 20000;
2756
- };
2757
- algorithms: {
2758
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2759
- readonly _tag: "constant";
2760
- readonly jitter: 1000;
2761
- readonly interval: 2000;
2762
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2763
- };
2764
- };
2765
- __brand: VigorBrand<"Retry", "Schema">;
2766
- }>;
2767
- readonly parse: (response?: Parameters<VigorParse["target"]>[0]) => VigorParse<{
2768
- readonly __brand: VigorBrand<"Parse", "Schema">;
2769
- readonly policy: {
2770
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2771
- readonly target: symbol & {
2772
- __brand: VigorBrand<"Core", "Symbol_Default">;
2773
- };
2774
- readonly settings: {
2775
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2776
- readonly raw: false;
2777
- readonly default: symbol & {
2778
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2779
- };
2780
- readonly maxRestarts: 3;
2781
- };
2782
- readonly middlewares: {
2783
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2784
- readonly before: [];
2785
- readonly after: [];
2786
- readonly onResult: [];
2787
- readonly onError: [];
2788
- };
2789
- readonly strategies: {
2790
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2791
- readonly funcs: VigorParseStrategyFunc[];
2792
- };
2793
- };
2794
- readonly context: {
2795
- readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2796
- readonly result: symbol & {
2797
- __brand: VigorBrand<"Core", "Symbol_Default">;
2798
- };
2799
- readonly error: symbol & {
2800
- __brand: VigorBrand<"Core", "Symbol_Default">;
2801
- };
2802
- readonly response: symbol & {
2803
- __brand: VigorBrand<"Core", "Symbol_Default">;
2804
- };
2805
- readonly flags: {
2806
- readonly overrided: false;
2807
- readonly restarted: false;
2808
- };
2809
- readonly record: {};
2810
- readonly policy: {
2811
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2812
- readonly target: symbol & {
2813
- __brand: VigorBrand<"Core", "Symbol_Default">;
2814
- };
2815
- readonly settings: {
2816
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2817
- readonly raw: false;
2818
- readonly default: symbol & {
2819
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2820
- };
2821
- readonly maxRestarts: 3;
2822
- };
2823
- readonly middlewares: {
2824
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2825
- readonly before: [];
2826
- readonly after: [];
2827
- readonly onResult: [];
2828
- readonly onError: [];
2829
- };
2830
- readonly strategies: {
2831
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2832
- readonly funcs: VigorParseStrategyFunc[];
2833
- };
2834
- };
2835
- };
2836
- }> | VigorParse<{
2837
- context: {
2838
- readonly __brand: VigorBrand<"Parse", "Context<Schema">;
2839
- readonly result: symbol & {
2840
- __brand: VigorBrand<"Core", "Symbol_Default">;
2841
- };
2842
- readonly error: symbol & {
2843
- __brand: VigorBrand<"Core", "Symbol_Default">;
2844
- };
2845
- readonly response: symbol & {
2846
- __brand: VigorBrand<"Core", "Symbol_Default">;
2847
- };
2848
- readonly flags: {
2849
- readonly overrided: false;
2850
- readonly restarted: false;
2851
- };
2852
- readonly record: {};
2853
- readonly policy: {
2854
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
2855
- readonly target: symbol & {
2856
- __brand: VigorBrand<"Core", "Symbol_Default">;
2857
- };
2858
- readonly settings: {
2859
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2860
- readonly raw: false;
2861
- readonly default: symbol & {
2862
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2863
- };
2864
- readonly maxRestarts: 3;
2865
- };
2866
- readonly middlewares: {
2867
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2868
- readonly before: [];
2869
- readonly after: [];
2870
- readonly onResult: [];
2871
- readonly onError: [];
2872
- };
2873
- readonly strategies: {
2874
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2875
- readonly funcs: VigorParseStrategyFunc[];
2876
- };
2877
- };
2878
- };
2879
- policy: {
2880
- target: (symbol & {
2881
- __brand: VigorBrand<"Core", "Symbol_Default">;
2882
- }) | Request | Response;
2883
- middlewares: {
2884
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
2885
- readonly before: [];
2886
- readonly after: [];
2887
- readonly onResult: [];
2888
- readonly onError: [];
2889
- };
2890
- __brand: VigorBrand<"Parse", "Policy<Schema">;
2891
- settings: {
2892
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
2893
- readonly raw: false;
2894
- readonly default: symbol & {
2895
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2896
- };
2897
- readonly maxRestarts: 3;
2898
- };
2899
- strategies: {
2900
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
2901
- readonly funcs: VigorParseStrategyFunc[];
2902
- };
2903
- };
2904
- __brand: VigorBrand<"Parse", "Schema">;
2905
- }>;
2906
- readonly fetch: (origin?: Parameters<VigorFetch["origin"]>[0]) => VigorFetch<{
2907
- readonly __brand: VigorBrand<"Fetch", "Schema">;
2908
- readonly policy: {
2909
- readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
2910
- readonly method: symbol & {
2911
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2912
- };
2913
- readonly origin: symbol & {
2914
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2915
- };
2916
- readonly path: [];
2917
- readonly query: [];
2918
- readonly hash: "";
2919
- readonly headers: {};
2920
- readonly body: symbol & {
2921
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2922
- };
2923
- readonly extra: {};
2924
- readonly settings: {
2925
- readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
2926
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
2927
- readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
2928
- readonly maxRestarts: 3;
2929
- readonly default: symbol & {
2930
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2931
- };
2932
- };
2933
- readonly middlewares: {
2934
- readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2935
- readonly before: [];
2936
- readonly after: [];
2937
- readonly onResult: [];
2938
- readonly onError: [];
2939
- };
2940
- readonly retry: {
2941
- readonly __brand: VigorBrand<"Retry", "Schema">;
2942
- readonly policy: {
2943
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2944
- readonly target: symbol & {
2945
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2946
- };
2947
- readonly abortSignals: [];
2948
- readonly settings: {
2949
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
2950
- readonly default: symbol & {
2951
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2952
- };
2953
- readonly maxAttempts: 5;
2954
- readonly maxRestarts: 3;
2955
- readonly timeout: 20000;
2956
- };
2957
- readonly middlewares: {
2958
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
2959
- readonly before: [];
2960
- readonly after: [];
2961
- readonly onResult: [];
2962
- readonly retryIf: [];
2963
- readonly onRetry: [];
2964
- readonly onError: [];
2965
- };
2966
- readonly algorithms: {
2967
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
2968
- readonly _tag: "constant";
2969
- readonly jitter: 1000;
2970
- readonly interval: 2000;
2971
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
2972
- };
2973
- };
2974
- readonly context: {
2975
- readonly __brand: VigorBrand<"Retry", "Context<Schema">;
2976
- readonly result: symbol & {
2977
- __brand: VigorBrand<"Core", "Symbol_Default">;
2978
- };
2979
- readonly error: symbol & {
2980
- __brand: VigorBrand<"Core", "Symbol_Default">;
2981
- };
2982
- readonly system: {
2983
- readonly delay: symbol & {
2984
- __brand: VigorBrand<"Core", "Symbol_Default">;
2985
- };
2986
- readonly attempt: 0;
2987
- };
2988
- readonly flags: {
2989
- readonly doRetry: true;
2990
- readonly doRestart: false;
2991
- readonly brokeRetry: false;
2992
- readonly overridden: false;
2993
- };
2994
- readonly record: {};
2995
- readonly policy: {
2996
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
2997
- readonly target: symbol & {
2998
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2999
- };
3000
- readonly abortSignals: [];
3001
- readonly settings: {
3002
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3003
- readonly default: symbol & {
3004
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3005
- };
3006
- readonly maxAttempts: 5;
3007
- readonly maxRestarts: 3;
3008
- readonly timeout: 20000;
3009
- };
3010
- readonly middlewares: {
3011
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3012
- readonly before: [];
3013
- readonly after: [];
3014
- readonly onResult: [];
3015
- readonly retryIf: [];
3016
- readonly onRetry: [];
3017
- readonly onError: [];
3018
- };
3019
- readonly algorithms: {
3020
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3021
- readonly _tag: "constant";
3022
- readonly jitter: 1000;
3023
- readonly interval: 2000;
3024
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3025
- };
3026
- };
3027
- };
3028
- };
3029
- readonly parse: {
3030
- readonly __brand: VigorBrand<"Parse", "Schema">;
3031
- readonly policy: {
3032
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3033
- readonly target: symbol & {
3034
- __brand: VigorBrand<"Core", "Symbol_Default">;
3035
- };
3036
- readonly settings: {
3037
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3038
- readonly raw: false;
3039
- readonly default: symbol & {
3040
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3041
- };
3042
- readonly maxRestarts: 3;
3043
- };
3044
- readonly middlewares: {
3045
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3046
- readonly before: [];
3047
- readonly after: [];
3048
- readonly onResult: [];
3049
- readonly onError: [];
3050
- };
3051
- readonly strategies: {
3052
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3053
- readonly funcs: VigorParseStrategyFunc[];
3054
- };
3055
- };
3056
- readonly context: {
3057
- readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3058
- readonly result: symbol & {
3059
- __brand: VigorBrand<"Core", "Symbol_Default">;
3060
- };
3061
- readonly error: symbol & {
3062
- __brand: VigorBrand<"Core", "Symbol_Default">;
3063
- };
3064
- readonly response: symbol & {
3065
- __brand: VigorBrand<"Core", "Symbol_Default">;
3066
- };
3067
- readonly flags: {
3068
- readonly overrided: false;
3069
- readonly restarted: false;
3070
- };
3071
- readonly record: {};
3072
- readonly policy: {
3073
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3074
- readonly target: symbol & {
3075
- __brand: VigorBrand<"Core", "Symbol_Default">;
3076
- };
3077
- readonly settings: {
3078
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3079
- readonly raw: false;
3080
- readonly default: symbol & {
3081
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3082
- };
3083
- readonly maxRestarts: 3;
3084
- };
3085
- readonly middlewares: {
3086
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3087
- readonly before: [];
3088
- readonly after: [];
3089
- readonly onResult: [];
3090
- readonly onError: [];
3091
- };
3092
- readonly strategies: {
3093
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3094
- readonly funcs: VigorParseStrategyFunc[];
3095
- };
3096
- };
3097
- };
3098
- };
3099
- };
3100
- readonly context: {
3101
- readonly __brand: VigorBrand<"Fetch", "Context<Schema">;
3102
- readonly href: "";
3103
- readonly response: symbol & {
3104
- __brand: VigorBrand<"Core", "Symbol_Default">;
3105
- };
3106
- readonly result: symbol & {
3107
- __brand: VigorBrand<"Core", "Symbol_Default">;
3108
- };
3109
- readonly error: symbol & {
3110
- __brand: VigorBrand<"Core", "Symbol_Default">;
3111
- };
3112
- readonly options: symbol & {
3113
- __brand: VigorBrand<"Core", "Symbol_Default">;
3114
- };
3115
- readonly flags: {
3116
- readonly overrided: false;
3117
- readonly restarted: false;
3118
- };
3119
- readonly record: {};
3120
- readonly policy: {
3121
- readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
3122
- readonly method: symbol & {
3123
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3124
- };
3125
- readonly origin: symbol & {
3126
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3127
- };
3128
- readonly path: [];
3129
- readonly query: [];
3130
- readonly hash: "";
3131
- readonly headers: {};
3132
- readonly body: symbol & {
3133
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3134
- };
3135
- readonly extra: {};
3136
- readonly settings: {
3137
- readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
3138
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3139
- readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3140
- readonly maxRestarts: 3;
3141
- readonly default: symbol & {
3142
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3143
- };
3144
- };
3145
- readonly middlewares: {
3146
- readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
3147
- readonly before: [];
3148
- readonly after: [];
3149
- readonly onResult: [];
3150
- readonly onError: [];
3151
- };
3152
- readonly retry: {
3153
- readonly __brand: VigorBrand<"Retry", "Schema">;
3154
- readonly policy: {
3155
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3156
- readonly target: symbol & {
3157
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3158
- };
3159
- readonly abortSignals: [];
3160
- readonly settings: {
3161
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3162
- readonly default: symbol & {
3163
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3164
- };
3165
- readonly maxAttempts: 5;
3166
- readonly maxRestarts: 3;
3167
- readonly timeout: 20000;
3168
- };
3169
- readonly middlewares: {
3170
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3171
- readonly before: [];
3172
- readonly after: [];
3173
- readonly onResult: [];
3174
- readonly retryIf: [];
3175
- readonly onRetry: [];
3176
- readonly onError: [];
3177
- };
3178
- readonly algorithms: {
3179
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3180
- readonly _tag: "constant";
3181
- readonly jitter: 1000;
3182
- readonly interval: 2000;
3183
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3184
- };
3185
- };
3186
- readonly context: {
3187
- readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3188
- readonly result: symbol & {
3189
- __brand: VigorBrand<"Core", "Symbol_Default">;
3190
- };
3191
- readonly error: symbol & {
3192
- __brand: VigorBrand<"Core", "Symbol_Default">;
3193
- };
3194
- readonly system: {
3195
- readonly delay: symbol & {
3196
- __brand: VigorBrand<"Core", "Symbol_Default">;
3197
- };
3198
- readonly attempt: 0;
3199
- };
3200
- readonly flags: {
3201
- readonly doRetry: true;
3202
- readonly doRestart: false;
3203
- readonly brokeRetry: false;
3204
- readonly overridden: false;
3205
- };
3206
- readonly record: {};
3207
- readonly policy: {
3208
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3209
- readonly target: symbol & {
3210
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3211
- };
3212
- readonly abortSignals: [];
3213
- readonly settings: {
3214
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3215
- readonly default: symbol & {
3216
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3217
- };
3218
- readonly maxAttempts: 5;
3219
- readonly maxRestarts: 3;
3220
- readonly timeout: 20000;
3221
- };
3222
- readonly middlewares: {
3223
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3224
- readonly before: [];
3225
- readonly after: [];
3226
- readonly onResult: [];
3227
- readonly retryIf: [];
3228
- readonly onRetry: [];
3229
- readonly onError: [];
3230
- };
3231
- readonly algorithms: {
3232
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3233
- readonly _tag: "constant";
3234
- readonly jitter: 1000;
3235
- readonly interval: 2000;
3236
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3237
- };
3238
- };
3239
- };
3240
- };
3241
- readonly parse: {
3242
- readonly __brand: VigorBrand<"Parse", "Schema">;
3243
- readonly policy: {
3244
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3245
- readonly target: symbol & {
3246
- __brand: VigorBrand<"Core", "Symbol_Default">;
3247
- };
3248
- readonly settings: {
3249
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3250
- readonly raw: false;
3251
- readonly default: symbol & {
3252
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3253
- };
3254
- readonly maxRestarts: 3;
3255
- };
3256
- readonly middlewares: {
3257
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3258
- readonly before: [];
3259
- readonly after: [];
3260
- readonly onResult: [];
3261
- readonly onError: [];
3262
- };
3263
- readonly strategies: {
3264
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3265
- readonly funcs: VigorParseStrategyFunc[];
3266
- };
3267
- };
3268
- readonly context: {
3269
- readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3270
- readonly result: symbol & {
3271
- __brand: VigorBrand<"Core", "Symbol_Default">;
3272
- };
3273
- readonly error: symbol & {
3274
- __brand: VigorBrand<"Core", "Symbol_Default">;
3275
- };
3276
- readonly response: symbol & {
3277
- __brand: VigorBrand<"Core", "Symbol_Default">;
3278
- };
3279
- readonly flags: {
3280
- readonly overrided: false;
3281
- readonly restarted: false;
3282
- };
3283
- readonly record: {};
3284
- readonly policy: {
3285
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3286
- readonly target: symbol & {
3287
- __brand: VigorBrand<"Core", "Symbol_Default">;
3288
- };
3289
- readonly settings: {
3290
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3291
- readonly raw: false;
3292
- readonly default: symbol & {
3293
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3294
- };
3295
- readonly maxRestarts: 3;
3296
- };
3297
- readonly middlewares: {
3298
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3299
- readonly before: [];
3300
- readonly after: [];
3301
- readonly onResult: [];
3302
- readonly onError: [];
3303
- };
3304
- readonly strategies: {
3305
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3306
- readonly funcs: VigorParseStrategyFunc[];
3307
- };
3308
- };
3309
- };
3310
- };
3311
- };
3312
- };
3313
- }> | VigorFetch<{
3314
- context: {
3315
- readonly __brand: VigorBrand<"Fetch", "Context<Schema">;
3316
- readonly href: "";
3317
- readonly response: symbol & {
3318
- __brand: VigorBrand<"Core", "Symbol_Default">;
3319
- };
3320
- readonly result: symbol & {
3321
- __brand: VigorBrand<"Core", "Symbol_Default">;
3322
- };
3323
- readonly error: symbol & {
3324
- __brand: VigorBrand<"Core", "Symbol_Default">;
3325
- };
3326
- readonly options: symbol & {
3327
- __brand: VigorBrand<"Core", "Symbol_Default">;
3328
- };
3329
- readonly flags: {
3330
- readonly overrided: false;
3331
- readonly restarted: false;
3332
- };
3333
- readonly record: {};
3334
- readonly policy: {
3335
- readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
3336
- readonly method: symbol & {
3337
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3338
- };
3339
- readonly origin: symbol & {
3340
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3341
- };
3342
- readonly path: [];
3343
- readonly query: [];
3344
- readonly hash: "";
3345
- readonly headers: {};
3346
- readonly body: symbol & {
3347
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3348
- };
3349
- readonly extra: {};
3350
- readonly settings: {
3351
- readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
3352
- readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3353
- readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
3354
- readonly maxRestarts: 3;
3355
- readonly default: symbol & {
3356
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3357
- };
3358
- };
3359
- readonly middlewares: {
3360
- readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
3361
- readonly before: [];
3362
- readonly after: [];
3363
- readonly onResult: [];
3364
- readonly onError: [];
3365
- };
3366
- readonly retry: {
3367
- readonly __brand: VigorBrand<"Retry", "Schema">;
3368
- readonly policy: {
3369
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3370
- readonly target: symbol & {
3371
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3372
- };
3373
- readonly abortSignals: [];
3374
- readonly settings: {
3375
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3376
- readonly default: symbol & {
3377
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3378
- };
3379
- readonly maxAttempts: 5;
3380
- readonly maxRestarts: 3;
3381
- readonly timeout: 20000;
3382
- };
3383
- readonly middlewares: {
3384
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3385
- readonly before: [];
3386
- readonly after: [];
3387
- readonly onResult: [];
3388
- readonly retryIf: [];
3389
- readonly onRetry: [];
3390
- readonly onError: [];
3391
- };
3392
- readonly algorithms: {
3393
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3394
- readonly _tag: "constant";
3395
- readonly jitter: 1000;
3396
- readonly interval: 2000;
3397
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3398
- };
3399
- };
3400
- readonly context: {
3401
- readonly __brand: VigorBrand<"Retry", "Context<Schema">;
3402
- readonly result: symbol & {
3403
- __brand: VigorBrand<"Core", "Symbol_Default">;
3404
- };
3405
- readonly error: symbol & {
3406
- __brand: VigorBrand<"Core", "Symbol_Default">;
3407
- };
3408
- readonly system: {
3409
- readonly delay: symbol & {
3410
- __brand: VigorBrand<"Core", "Symbol_Default">;
3411
- };
3412
- readonly attempt: 0;
3413
- };
3414
- readonly flags: {
3415
- readonly doRetry: true;
3416
- readonly doRestart: false;
3417
- readonly brokeRetry: false;
3418
- readonly overridden: false;
3419
- };
3420
- readonly record: {};
3421
- readonly policy: {
3422
- readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
3423
- readonly target: symbol & {
3424
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3425
- };
3426
- readonly abortSignals: [];
3427
- readonly settings: {
3428
- readonly __brand: VigorBrand<"Retry", "Policy<Settings<Schema">;
3429
- readonly default: symbol & {
3430
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3431
- };
3432
- readonly maxAttempts: 5;
3433
- readonly maxRestarts: 3;
3434
- readonly timeout: 20000;
3435
- };
3436
- readonly middlewares: {
3437
- readonly __brand: VigorBrand<"Retry", "Policy<Middlewares<Schema">;
3438
- readonly before: [];
3439
- readonly after: [];
3440
- readonly onResult: [];
3441
- readonly retryIf: [];
3442
- readonly onRetry: [];
3443
- readonly onError: [];
3444
- };
3445
- readonly algorithms: {
3446
- readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
3447
- readonly _tag: "constant";
3448
- readonly jitter: 1000;
3449
- readonly interval: 2000;
3450
- readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
3451
- };
3452
- };
3453
- };
3454
- };
3455
- readonly parse: {
3456
- readonly __brand: VigorBrand<"Parse", "Schema">;
3457
- readonly policy: {
3458
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3459
- readonly target: symbol & {
3460
- __brand: VigorBrand<"Core", "Symbol_Default">;
3461
- };
3462
- readonly settings: {
3463
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3464
- readonly raw: false;
3465
- readonly default: symbol & {
3466
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3467
- };
3468
- readonly maxRestarts: 3;
3469
- };
3470
- readonly middlewares: {
3471
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3472
- readonly before: [];
3473
- readonly after: [];
3474
- readonly onResult: [];
3475
- readonly onError: [];
3476
- };
3477
- readonly strategies: {
3478
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3479
- readonly funcs: VigorParseStrategyFunc[];
3480
- };
2204
+ __brand: VigorBrand<"Core", "Symbol_Default">;
3481
2205
  };
3482
- readonly context: {
3483
- readonly __brand: VigorBrand<"Parse", "Context<Schema">;
3484
- readonly result: symbol & {
3485
- __brand: VigorBrand<"Core", "Symbol_Default">;
3486
- };
3487
- readonly error: symbol & {
3488
- __brand: VigorBrand<"Core", "Symbol_Default">;
3489
- };
3490
- readonly response: symbol & {
3491
- __brand: VigorBrand<"Core", "Symbol_Default">;
3492
- };
3493
- readonly flags: {
3494
- readonly overrided: false;
3495
- readonly restarted: false;
3496
- };
3497
- readonly record: {};
3498
- readonly policy: {
3499
- readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
3500
- readonly target: symbol & {
3501
- __brand: VigorBrand<"Core", "Symbol_Default">;
3502
- };
3503
- readonly settings: {
3504
- readonly __brand: VigorBrand<"Parse", "Policy<Settings<Schema">;
3505
- readonly raw: false;
3506
- readonly default: symbol & {
3507
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3508
- };
3509
- readonly maxRestarts: 3;
3510
- };
3511
- readonly middlewares: {
3512
- readonly __brand: VigorBrand<"Parse", "Policy<Middlewares<Schema">;
3513
- readonly before: [];
3514
- readonly after: [];
3515
- readonly onResult: [];
3516
- readonly onError: [];
3517
- };
3518
- readonly strategies: {
3519
- readonly __brand: VigorBrand<"Parse", "Policy<Strategies<Schema">;
3520
- readonly funcs: VigorParseStrategyFunc[];
3521
- };
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">;
3522
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[];
3523
2224
  };
3524
2225
  };
3525
2226
  };
3526
2227
  };
3527
- policy: {
3528
- middlewares: {
3529
- readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
3530
- readonly before: [];
3531
- readonly after: [];
3532
- readonly onResult: [];
3533
- readonly onError: [];
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">;
3534
2263
  };
3535
- __brand: VigorBrand<"Fetch", "Policy<Schema">;
3536
- settings: {
2264
+ readonly extra: {};
2265
+ readonly settings: {
3537
2266
  readonly __brand: VigorBrand<"Fetch", "Policy<Settings<Schema">;
3538
2267
  readonly retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"];
3539
2268
  readonly unretryStatus: [400, 401, 403, 404, 405, 413, 422];
@@ -3542,19 +2271,14 @@ declare const vigor: {
3542
2271
  __brand: VigorBrand<"Core", "Symbol_Empty">;
3543
2272
  };
3544
2273
  };
3545
- headers: {};
3546
- method: symbol & {
3547
- __brand: VigorBrand<"Core", "Symbol_Empty">;
3548
- };
3549
- body: symbol & {
3550
- __brand: VigorBrand<"Core", "Symbol_Empty">;
2274
+ readonly middlewares: {
2275
+ readonly __brand: VigorBrand<"Fetch", "Policy<Middlewares<Schema">;
2276
+ readonly before: [];
2277
+ readonly after: [];
2278
+ readonly onResult: [];
2279
+ readonly onError: [];
3551
2280
  };
3552
- origin: string;
3553
- path: [];
3554
- query: [];
3555
- hash: "";
3556
- extra: {};
3557
- retry: {
2281
+ readonly retry: {
3558
2282
  readonly __brand: VigorBrand<"Retry", "Schema">;
3559
2283
  readonly policy: {
3560
2284
  readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
@@ -3643,7 +2367,7 @@ declare const vigor: {
3643
2367
  };
3644
2368
  };
3645
2369
  };
3646
- parse: {
2370
+ readonly parse: {
3647
2371
  readonly __brand: VigorBrand<"Parse", "Schema">;
3648
2372
  readonly policy: {
3649
2373
  readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
@@ -3714,9 +2438,157 @@ declare const vigor: {
3714
2438
  };
3715
2439
  };
3716
2440
  };
3717
- __brand: VigorBrand<"Fetch", "Schema">;
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;
3718
2579
  }>;
3719
- readonly all: (...tasks: Parameters<VigorAll["target"]>[0][]) => VigorAll<{
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<{
3720
2592
  readonly __brand: VigorBrand<"All", "Schema">;
3721
2593
  readonly policy: {
3722
2594
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
@@ -3756,9 +2628,9 @@ declare const vigor: {
3756
2628
  readonly record: {};
3757
2629
  };
3758
2630
  }>;
3759
- readonly builders: {
3760
- readonly fetch: {
3761
- readonly settings: () => VigorFetchPolicySettings<{
2631
+ builders: {
2632
+ fetch: {
2633
+ settings: () => VigorFetchPolicySettings<{
3762
2634
  readonly __brand: VigorBrand<"Fetch", "Schema">;
3763
2635
  readonly policy: {
3764
2636
  readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
@@ -4166,7 +3038,7 @@ declare const vigor: {
4166
3038
  };
4167
3039
  };
4168
3040
  }>;
4169
- readonly middlewares: () => VigorFetchPolicyMiddlewares<{
3041
+ middlewares: () => VigorFetchPolicyMiddlewares<{
4170
3042
  readonly __brand: VigorBrand<"Fetch", "Schema">;
4171
3043
  readonly policy: {
4172
3044
  readonly __brand: VigorBrand<"Fetch", "Policy<Schema">;
@@ -4575,8 +3447,8 @@ declare const vigor: {
4575
3447
  };
4576
3448
  }>;
4577
3449
  };
4578
- readonly retry: {
4579
- readonly settings: () => VigorRetryPolicySettings<{
3450
+ retry: {
3451
+ settings: () => VigorRetryPolicySettings<{
4580
3452
  readonly __brand: VigorBrand<"Retry", "Schema">;
4581
3453
  readonly policy: {
4582
3454
  readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
@@ -4665,7 +3537,7 @@ declare const vigor: {
4665
3537
  };
4666
3538
  };
4667
3539
  }>;
4668
- readonly middlewares: () => VigorRetryPolicyMiddlewares<{
3540
+ middlewares: () => VigorRetryPolicyMiddlewares<{
4669
3541
  readonly __brand: VigorBrand<"Retry", "Schema">;
4670
3542
  readonly policy: {
4671
3543
  readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
@@ -4754,7 +3626,7 @@ declare const vigor: {
4754
3626
  };
4755
3627
  };
4756
3628
  }>;
4757
- readonly algorithms: () => VigorRetryPolicyAlgorithms<{
3629
+ algorithms: () => VigorRetryPolicyAlgorithms<{
4758
3630
  readonly __brand: VigorBrand<"Retry", "Schema">;
4759
3631
  readonly policy: {
4760
3632
  readonly __brand: VigorBrand<"Retry", "Policy<Schema">;
@@ -4843,15 +3715,15 @@ declare const vigor: {
4843
3715
  };
4844
3716
  };
4845
3717
  }>;
4846
- readonly algorithm: {
4847
- readonly constant: () => VigorRetryPolicyAlgorithmsConstant<{
3718
+ algorithm: {
3719
+ constant: () => VigorRetryPolicyAlgorithmsConstant<{
4848
3720
  readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Constant<Schema">;
4849
3721
  readonly _tag: "constant";
4850
3722
  readonly jitter: 1000;
4851
3723
  readonly interval: 2000;
4852
3724
  readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsConstantSchema<any>) => number;
4853
3725
  }>;
4854
- readonly linear: () => VigorRetryPolicyAlgorithmsLinear<{
3726
+ linear: () => VigorRetryPolicyAlgorithmsLinear<{
4855
3727
  readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Linear<Schema">;
4856
3728
  readonly _tag: "linear";
4857
3729
  readonly jitter: 1000;
@@ -4861,7 +3733,7 @@ declare const vigor: {
4861
3733
  readonly maxDelay: 10000;
4862
3734
  readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsLinearSchema<any>) => number;
4863
3735
  }>;
4864
- readonly backoff: () => VigorRetryPolicyAlgorithmsBackoff<{
3736
+ backoff: () => VigorRetryPolicyAlgorithmsBackoff<{
4865
3737
  readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Backoff<Schema">;
4866
3738
  readonly _tag: "backoff";
4867
3739
  readonly jitter: 800;
@@ -4872,7 +3744,7 @@ declare const vigor: {
4872
3744
  readonly maxDelay: 10000;
4873
3745
  readonly _calculateDelay: (att: number, config: VigorRetryPolicyAlgorithmsBackoffSchema<any>) => number;
4874
3746
  }>;
4875
- readonly custom: () => VigorRetryPolicyAlgorithmsCustom<{
3747
+ custom: () => VigorRetryPolicyAlgorithmsCustom<{
4876
3748
  readonly __brand: VigorBrand<"Retry", "Policy<Algorithms<Custom<Schema">;
4877
3749
  readonly _tag: "custom";
4878
3750
  readonly jitter: 800;
@@ -4885,8 +3757,8 @@ declare const vigor: {
4885
3757
  }>;
4886
3758
  };
4887
3759
  };
4888
- readonly parse: {
4889
- readonly settings: () => VigorParsePolicySettings<{
3760
+ parse: {
3761
+ settings: () => VigorParsePolicySettings<{
4890
3762
  readonly __brand: VigorBrand<"Parse", "Schema">;
4891
3763
  readonly policy: {
4892
3764
  readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
@@ -4956,7 +3828,7 @@ declare const vigor: {
4956
3828
  };
4957
3829
  };
4958
3830
  }>;
4959
- readonly middlewares: () => VigorParsePolicyMiddlewares<{
3831
+ middlewares: () => VigorParsePolicyMiddlewares<{
4960
3832
  readonly __brand: VigorBrand<"Parse", "Schema">;
4961
3833
  readonly policy: {
4962
3834
  readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
@@ -5026,7 +3898,7 @@ declare const vigor: {
5026
3898
  };
5027
3899
  };
5028
3900
  }>;
5029
- readonly strategies: () => VigorParsePolicyStrategies<{
3901
+ strategies: () => VigorParsePolicyStrategies<{
5030
3902
  readonly __brand: VigorBrand<"Parse", "Schema">;
5031
3903
  readonly policy: {
5032
3904
  readonly __brand: VigorBrand<"Parse", "Policy<Schema">;
@@ -5097,8 +3969,8 @@ declare const vigor: {
5097
3969
  };
5098
3970
  }>;
5099
3971
  };
5100
- readonly all: {
5101
- readonly settings: () => VigorAllPolicySettings<{
3972
+ all: {
3973
+ settings: () => VigorAllPolicySettings<{
5102
3974
  readonly __brand: VigorBrand<"All", "Schema">;
5103
3975
  readonly policy: {
5104
3976
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
@@ -5138,7 +4010,7 @@ declare const vigor: {
5138
4010
  readonly record: {};
5139
4011
  };
5140
4012
  }>;
5141
- readonly middlewares: () => VigorAllPolicyMiddlewares<{
4013
+ middlewares: () => VigorAllPolicyMiddlewares<{
5142
4014
  readonly __brand: VigorBrand<"All", "Schema">;
5143
4015
  readonly policy: {
5144
4016
  readonly __brand: VigorBrand<"All", "Policy<Schema">;
@@ -5181,6 +4053,22 @@ declare const vigor: {
5181
4053
  };
5182
4054
  };
5183
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;
5184
4072
 
5185
4073
  type VigorErrorOptions<D, T> = {
5186
4074
  cause?: unknown;
@@ -5317,5 +4205,4 @@ declare class VigorAllError<C extends VigorAllErrorCodes, T extends VigorAllSche
5317
4205
  constructor(code: C, options: VigorErrorOptions<VigorAllErrorDatas<C>, T["context"]>);
5318
4206
  }
5319
4207
 
5320
- export { VigorAll, VigorAllBase, VigorAllError, VigorAllErrorMessageFuncs, VigorAllPolicyBase, VigorAllPolicyMiddlewares, VigorAllPolicyMiddlewaresBase, VigorAllPolicySettings, VigorAllPolicySettingsBase, VigorError, VigorFetch, VigorFetchBase, VigorFetchError, VigorFetchErrorMessageFuncs, VigorFetchPolicyBase, VigorFetchPolicyMiddlewares, VigorFetchPolicyMiddlewaresBase, VigorFetchPolicySettings, VigorFetchPolicySettingsBase, VigorJitter, VigorParse, VigorParseBase, VigorParseContentTypeStrategy, VigorParseError, VigorParseErrorMessageFuncs, VigorParsePolicyBase, VigorParsePolicyMiddlewares, VigorParsePolicyMiddlewaresBase, VigorParsePolicySettings, VigorParsePolicySettingsBase, VigorParsePolicyStrategies, VigorParsePolicyStrategiesBase, VigorParseSniffStrategy, VigorRetry, VigorRetryBase, VigorRetryError, VigorRetryErrorMessageFuncs, VigorRetryPolicyAlgorithms, VigorRetryPolicyAlgorithmsBackoff, VigorRetryPolicyAlgorithmsBackoffBase, VigorRetryPolicyAlgorithmsBase, VigorRetryPolicyAlgorithmsConstant, VigorRetryPolicyAlgorithmsConstantBase, VigorRetryPolicyAlgorithmsCustom, VigorRetryPolicyAlgorithmsCustomBase, VigorRetryPolicyAlgorithmsLinear, VigorRetryPolicyAlgorithmsLinearBase, VigorRetryPolicyBase, VigorRetryPolicyMiddlewares, VigorRetryPolicyMiddlewaresBase, VigorRetryPolicySettings, VigorRetryPolicySettingsBase, VigorStatus, vigor as default, vigor };
5321
- export type { VigorAllEachMiddlewareFn, VigorAllEachOnErrorFn, VigorAllErrorCodes, VigorAllErrorDatas, VigorAllPolicyMiddlewaresSchema, VigorAllPolicySchema, VigorAllPolicySettingsSchema, VigorAllSchema, VigorAllTask, VigorBuiltin, VigorConcat, VigorDeepMerge, VigorDeepPartial, VigorErrorOptions, VigorFetchErrorCodes, VigorFetchErrorDatas, VigorFetchPolicyMiddlewaresApi, VigorFetchPolicyMiddlewaresFluent, VigorFetchPolicyMiddlewaresIntercept, VigorFetchPolicyMiddlewaresSchema, VigorFetchPolicySchema, VigorFetchPolicySettingsSchema, VigorFetchSchema, VigorLastOf, VigorMergeMode, VigorMergeStrategy, VigorParseErrorCodes, VigorParseErrorDatas, VigorParsePolicyMiddlewaresApi, VigorParsePolicyMiddlewaresFluent, VigorParsePolicyMiddlewaresIntercept, VigorParsePolicyMiddlewaresSchema, VigorParsePolicySchema, VigorParsePolicySettingsSchema, VigorParsePolicyStrategiesSchema, VigorParseSchema, VigorParseStrategyFunc, VigorPlugin, VigorPrimitive, VigorReplaceType, VigorRetryErrorCodes, VigorRetryErrorDatas, VigorRetryPipeInitialContext, VigorRetryPipeResult, VigorRetryPipeStepResult, VigorRetryPipeStepRetryIf, VigorRetryPipeStepVoid, VigorRetryPolicyAlgorithmsBackoffSchema, VigorRetryPolicyAlgorithmsConstantSchema, VigorRetryPolicyAlgorithmsCustomSchema, VigorRetryPolicyAlgorithmsLinearSchema, VigorRetryPolicyAlgorithmsSchema, VigorRetryPolicyMiddlewaresApi, VigorRetryPolicyMiddlewaresFluent, VigorRetryPolicyMiddlewaresIntercept, VigorRetryPolicyMiddlewaresPipe, VigorRetryPolicyMiddlewaresSchema, VigorRetryPolicySchema, VigorRetryPolicySettingsSchema, VigorRetrySchema, VigorReturnType, VigorSimplify, VigorStringable };
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 };