vigor-fetch 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +31 -2498
- package/dist/index.js +36 -14
- package/dist/index.mjs +36 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -240,7 +240,9 @@ class VigorAll extends VigorStatus {
|
|
|
240
240
|
const result = typeof input === 'function'
|
|
241
241
|
? input(new VigorAllPolicySettings())
|
|
242
242
|
: input;
|
|
243
|
-
return this._next(
|
|
243
|
+
return this._next({
|
|
244
|
+
policy: { settings: result.config.policy.settings }
|
|
245
|
+
});
|
|
244
246
|
}
|
|
245
247
|
return this._next({ policy: { settings: input } });
|
|
246
248
|
}
|
|
@@ -250,7 +252,9 @@ class VigorAll extends VigorStatus {
|
|
|
250
252
|
const result = typeof input === 'function'
|
|
251
253
|
? input(new VigorAllPolicyMiddlewares())
|
|
252
254
|
: input;
|
|
253
|
-
return this._next(
|
|
255
|
+
return this._next({
|
|
256
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
257
|
+
});
|
|
254
258
|
}
|
|
255
259
|
return this._next({ policy: { middlewares: input } });
|
|
256
260
|
}
|
|
@@ -804,7 +808,9 @@ class VigorRetry extends VigorStatus {
|
|
|
804
808
|
const result = typeof input === 'function'
|
|
805
809
|
? input(new VigorRetryPolicySettings())
|
|
806
810
|
: input;
|
|
807
|
-
return this._next(
|
|
811
|
+
return this._next({
|
|
812
|
+
policy: { settings: result.config.policy.settings }
|
|
813
|
+
});
|
|
808
814
|
}
|
|
809
815
|
return this._next({
|
|
810
816
|
policy: { settings: input }
|
|
@@ -816,7 +822,9 @@ class VigorRetry extends VigorStatus {
|
|
|
816
822
|
const result = typeof input === 'function'
|
|
817
823
|
? input(new VigorRetryPolicyMiddlewares())
|
|
818
824
|
: input;
|
|
819
|
-
return this._next(
|
|
825
|
+
return this._next({
|
|
826
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
827
|
+
});
|
|
820
828
|
}
|
|
821
829
|
return this._next({
|
|
822
830
|
policy: { middlewares: input }
|
|
@@ -995,8 +1003,10 @@ class VigorRetry extends VigorStatus {
|
|
|
995
1003
|
}
|
|
996
1004
|
throw new VigorRetryError("RETRY_EXHAUSTED", {
|
|
997
1005
|
method: "request",
|
|
1006
|
+
cause: ctx.error,
|
|
998
1007
|
data: {
|
|
999
|
-
maxAttempts: ctx.policy.settings.maxAttempts
|
|
1008
|
+
maxAttempts: ctx.policy.settings.maxAttempts,
|
|
1009
|
+
error: ctx.error
|
|
1000
1010
|
}
|
|
1001
1011
|
});
|
|
1002
1012
|
}
|
|
@@ -1027,8 +1037,10 @@ class VigorRetry extends VigorStatus {
|
|
|
1027
1037
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1028
1038
|
throw new VigorRetryError("RESTART_EXHAUSTED", {
|
|
1029
1039
|
method: "request",
|
|
1040
|
+
cause: ctx.error,
|
|
1030
1041
|
data: {
|
|
1031
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1042
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1043
|
+
error: ctx.error
|
|
1032
1044
|
}
|
|
1033
1045
|
});
|
|
1034
1046
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1283,7 +1295,9 @@ class VigorParse extends VigorStatus {
|
|
|
1283
1295
|
const result = typeof input === 'function'
|
|
1284
1296
|
? input(new VigorParsePolicySettings())
|
|
1285
1297
|
: input;
|
|
1286
|
-
return this._next(
|
|
1298
|
+
return this._next({
|
|
1299
|
+
policy: { settings: result.config.policy.settings }
|
|
1300
|
+
});
|
|
1287
1301
|
}
|
|
1288
1302
|
return this._next({ policy: { settings: input } });
|
|
1289
1303
|
}
|
|
@@ -1293,7 +1307,9 @@ class VigorParse extends VigorStatus {
|
|
|
1293
1307
|
const result = typeof input === 'function'
|
|
1294
1308
|
? input(new VigorParsePolicyMiddlewares())
|
|
1295
1309
|
: input;
|
|
1296
|
-
return this._next(
|
|
1310
|
+
return this._next({
|
|
1311
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
1312
|
+
});
|
|
1297
1313
|
}
|
|
1298
1314
|
return this._next({ policy: { middlewares: input } });
|
|
1299
1315
|
}
|
|
@@ -1303,7 +1319,9 @@ class VigorParse extends VigorStatus {
|
|
|
1303
1319
|
const result = typeof input === 'function'
|
|
1304
1320
|
? input(new VigorParsePolicyStrategies())
|
|
1305
1321
|
: input;
|
|
1306
|
-
return this._next(
|
|
1322
|
+
return this._next({
|
|
1323
|
+
policy: { strategies: result.config.policy.strategies }
|
|
1324
|
+
});
|
|
1307
1325
|
}
|
|
1308
1326
|
return this._next({ policy: { strategies: input } });
|
|
1309
1327
|
}
|
|
@@ -1412,8 +1430,10 @@ class VigorParse extends VigorStatus {
|
|
|
1412
1430
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1413
1431
|
throw new VigorParseError("RESTART_EXHAUSTED", {
|
|
1414
1432
|
method: "request",
|
|
1433
|
+
cause: ctx.error,
|
|
1415
1434
|
data: {
|
|
1416
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1435
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1436
|
+
error: ctx.error
|
|
1417
1437
|
}
|
|
1418
1438
|
});
|
|
1419
1439
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1572,7 +1592,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1572
1592
|
const result = typeof input === 'function'
|
|
1573
1593
|
? input(new VigorFetchPolicySettings())
|
|
1574
1594
|
: input;
|
|
1575
|
-
return this._next(result.config);
|
|
1595
|
+
return this._next({ policy: { settings: result.config.policy.settings } });
|
|
1576
1596
|
}
|
|
1577
1597
|
return this._next({ policy: { settings: input } });
|
|
1578
1598
|
}
|
|
@@ -1582,7 +1602,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1582
1602
|
const result = typeof input === 'function'
|
|
1583
1603
|
? input(new VigorFetchPolicyMiddlewares())
|
|
1584
1604
|
: input;
|
|
1585
|
-
return this._next(result.config);
|
|
1605
|
+
return this._next({ policy: { middlewares: result.config.policy.middlewares } });
|
|
1586
1606
|
}
|
|
1587
1607
|
return this._next({ policy: { middlewares: input } });
|
|
1588
1608
|
}
|
|
@@ -1712,7 +1732,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1712
1732
|
});
|
|
1713
1733
|
ctx.href = this._buildUrl(ctx.policy.origin, ctx.policy.path, ctx.policy.query, ctx.policy.hash);
|
|
1714
1734
|
const hasBody = !isVigorEmpty(ctx.policy.body) && ctx.policy.body !== undefined;
|
|
1715
|
-
const method = ctx.policy.method
|
|
1735
|
+
const method = isVigorEmpty(ctx.policy.method) ? (hasBody ? "POST" : "GET") : ctx.policy.method;
|
|
1716
1736
|
let options = {
|
|
1717
1737
|
...ctx.policy.extra,
|
|
1718
1738
|
method: method,
|
|
@@ -1849,8 +1869,10 @@ class VigorFetch extends VigorStatus {
|
|
|
1849
1869
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1850
1870
|
throw new VigorFetchError("RESTART_EXHAUSTED", {
|
|
1851
1871
|
method: "request",
|
|
1872
|
+
cause: ctx.error,
|
|
1852
1873
|
data: {
|
|
1853
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1874
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1875
|
+
error: ctx.error
|
|
1854
1876
|
}
|
|
1855
1877
|
});
|
|
1856
1878
|
return await this.requestRuntime(restartAttempt + 1);
|
package/dist/index.mjs
CHANGED
|
@@ -236,7 +236,9 @@ class VigorAll extends VigorStatus {
|
|
|
236
236
|
const result = typeof input === 'function'
|
|
237
237
|
? input(new VigorAllPolicySettings())
|
|
238
238
|
: input;
|
|
239
|
-
return this._next(
|
|
239
|
+
return this._next({
|
|
240
|
+
policy: { settings: result.config.policy.settings }
|
|
241
|
+
});
|
|
240
242
|
}
|
|
241
243
|
return this._next({ policy: { settings: input } });
|
|
242
244
|
}
|
|
@@ -246,7 +248,9 @@ class VigorAll extends VigorStatus {
|
|
|
246
248
|
const result = typeof input === 'function'
|
|
247
249
|
? input(new VigorAllPolicyMiddlewares())
|
|
248
250
|
: input;
|
|
249
|
-
return this._next(
|
|
251
|
+
return this._next({
|
|
252
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
253
|
+
});
|
|
250
254
|
}
|
|
251
255
|
return this._next({ policy: { middlewares: input } });
|
|
252
256
|
}
|
|
@@ -800,7 +804,9 @@ class VigorRetry extends VigorStatus {
|
|
|
800
804
|
const result = typeof input === 'function'
|
|
801
805
|
? input(new VigorRetryPolicySettings())
|
|
802
806
|
: input;
|
|
803
|
-
return this._next(
|
|
807
|
+
return this._next({
|
|
808
|
+
policy: { settings: result.config.policy.settings }
|
|
809
|
+
});
|
|
804
810
|
}
|
|
805
811
|
return this._next({
|
|
806
812
|
policy: { settings: input }
|
|
@@ -812,7 +818,9 @@ class VigorRetry extends VigorStatus {
|
|
|
812
818
|
const result = typeof input === 'function'
|
|
813
819
|
? input(new VigorRetryPolicyMiddlewares())
|
|
814
820
|
: input;
|
|
815
|
-
return this._next(
|
|
821
|
+
return this._next({
|
|
822
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
823
|
+
});
|
|
816
824
|
}
|
|
817
825
|
return this._next({
|
|
818
826
|
policy: { middlewares: input }
|
|
@@ -991,8 +999,10 @@ class VigorRetry extends VigorStatus {
|
|
|
991
999
|
}
|
|
992
1000
|
throw new VigorRetryError("RETRY_EXHAUSTED", {
|
|
993
1001
|
method: "request",
|
|
1002
|
+
cause: ctx.error,
|
|
994
1003
|
data: {
|
|
995
|
-
maxAttempts: ctx.policy.settings.maxAttempts
|
|
1004
|
+
maxAttempts: ctx.policy.settings.maxAttempts,
|
|
1005
|
+
error: ctx.error
|
|
996
1006
|
}
|
|
997
1007
|
});
|
|
998
1008
|
}
|
|
@@ -1023,8 +1033,10 @@ class VigorRetry extends VigorStatus {
|
|
|
1023
1033
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1024
1034
|
throw new VigorRetryError("RESTART_EXHAUSTED", {
|
|
1025
1035
|
method: "request",
|
|
1036
|
+
cause: ctx.error,
|
|
1026
1037
|
data: {
|
|
1027
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1038
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1039
|
+
error: ctx.error
|
|
1028
1040
|
}
|
|
1029
1041
|
});
|
|
1030
1042
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1279,7 +1291,9 @@ class VigorParse extends VigorStatus {
|
|
|
1279
1291
|
const result = typeof input === 'function'
|
|
1280
1292
|
? input(new VigorParsePolicySettings())
|
|
1281
1293
|
: input;
|
|
1282
|
-
return this._next(
|
|
1294
|
+
return this._next({
|
|
1295
|
+
policy: { settings: result.config.policy.settings }
|
|
1296
|
+
});
|
|
1283
1297
|
}
|
|
1284
1298
|
return this._next({ policy: { settings: input } });
|
|
1285
1299
|
}
|
|
@@ -1289,7 +1303,9 @@ class VigorParse extends VigorStatus {
|
|
|
1289
1303
|
const result = typeof input === 'function'
|
|
1290
1304
|
? input(new VigorParsePolicyMiddlewares())
|
|
1291
1305
|
: input;
|
|
1292
|
-
return this._next(
|
|
1306
|
+
return this._next({
|
|
1307
|
+
policy: { middlewares: result.config.policy.middlewares }
|
|
1308
|
+
});
|
|
1293
1309
|
}
|
|
1294
1310
|
return this._next({ policy: { middlewares: input } });
|
|
1295
1311
|
}
|
|
@@ -1299,7 +1315,9 @@ class VigorParse extends VigorStatus {
|
|
|
1299
1315
|
const result = typeof input === 'function'
|
|
1300
1316
|
? input(new VigorParsePolicyStrategies())
|
|
1301
1317
|
: input;
|
|
1302
|
-
return this._next(
|
|
1318
|
+
return this._next({
|
|
1319
|
+
policy: { strategies: result.config.policy.strategies }
|
|
1320
|
+
});
|
|
1303
1321
|
}
|
|
1304
1322
|
return this._next({ policy: { strategies: input } });
|
|
1305
1323
|
}
|
|
@@ -1408,8 +1426,10 @@ class VigorParse extends VigorStatus {
|
|
|
1408
1426
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1409
1427
|
throw new VigorParseError("RESTART_EXHAUSTED", {
|
|
1410
1428
|
method: "request",
|
|
1429
|
+
cause: ctx.error,
|
|
1411
1430
|
data: {
|
|
1412
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1431
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1432
|
+
error: ctx.error
|
|
1413
1433
|
}
|
|
1414
1434
|
});
|
|
1415
1435
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1568,7 +1588,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1568
1588
|
const result = typeof input === 'function'
|
|
1569
1589
|
? input(new VigorFetchPolicySettings())
|
|
1570
1590
|
: input;
|
|
1571
|
-
return this._next(result.config);
|
|
1591
|
+
return this._next({ policy: { settings: result.config.policy.settings } });
|
|
1572
1592
|
}
|
|
1573
1593
|
return this._next({ policy: { settings: input } });
|
|
1574
1594
|
}
|
|
@@ -1578,7 +1598,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1578
1598
|
const result = typeof input === 'function'
|
|
1579
1599
|
? input(new VigorFetchPolicyMiddlewares())
|
|
1580
1600
|
: input;
|
|
1581
|
-
return this._next(result.config);
|
|
1601
|
+
return this._next({ policy: { middlewares: result.config.policy.middlewares } });
|
|
1582
1602
|
}
|
|
1583
1603
|
return this._next({ policy: { middlewares: input } });
|
|
1584
1604
|
}
|
|
@@ -1708,7 +1728,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1708
1728
|
});
|
|
1709
1729
|
ctx.href = this._buildUrl(ctx.policy.origin, ctx.policy.path, ctx.policy.query, ctx.policy.hash);
|
|
1710
1730
|
const hasBody = !isVigorEmpty(ctx.policy.body) && ctx.policy.body !== undefined;
|
|
1711
|
-
const method = ctx.policy.method
|
|
1731
|
+
const method = isVigorEmpty(ctx.policy.method) ? (hasBody ? "POST" : "GET") : ctx.policy.method;
|
|
1712
1732
|
let options = {
|
|
1713
1733
|
...ctx.policy.extra,
|
|
1714
1734
|
method: method,
|
|
@@ -1845,8 +1865,10 @@ class VigorFetch extends VigorStatus {
|
|
|
1845
1865
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1846
1866
|
throw new VigorFetchError("RESTART_EXHAUSTED", {
|
|
1847
1867
|
method: "request",
|
|
1868
|
+
cause: ctx.error,
|
|
1848
1869
|
data: {
|
|
1849
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1870
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1871
|
+
error: ctx.error
|
|
1850
1872
|
}
|
|
1851
1873
|
});
|
|
1852
1874
|
return await this.requestRuntime(restartAttempt + 1);
|