vigor-fetch 1.0.16 → 1.0.17
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.map +1 -1
- package/dist/index.js +51 -16
- package/dist/index.mjs +51 -16
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU,iBAAiB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,cAAM,UAAW,SAAQ,KAAK;IAC1B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;gBAEJ,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAevD;AAED,cAAM,eAAgB,SAAQ,UAAU;gBACxB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAIvD;AAED,cAAM,eAAgB,SAAQ,UAAU;gBACxB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAIvD;AAED,cAAM,eAAgB,SAAQ,UAAU;gBACxB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAIvD;AAED,cAAM,aAAc,SAAQ,UAAU;gBACtB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB;CAIvD;AAED;;GAEG;AACH,cAAM,UAAU,CAAC,CAAC,GAAG,GAAG;IACpB,OA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
class VigorAllError extends VigorError {
|
|
39
39
|
constructor(text, options) {
|
|
40
40
|
super(text, options);
|
|
41
|
-
this.message = options.message || `[
|
|
41
|
+
this.message = options.message || `[VigorAllError] ${text}`;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
@@ -62,8 +62,14 @@ class VigorRetry {
|
|
|
62
62
|
return new this.constructor(this._target, this._args, {
|
|
63
63
|
...this._config,
|
|
64
64
|
...changes,
|
|
65
|
-
retry: {
|
|
66
|
-
|
|
65
|
+
retry: {
|
|
66
|
+
...this._config.retry,
|
|
67
|
+
...(changes.retry || {})
|
|
68
|
+
},
|
|
69
|
+
interceptors: {
|
|
70
|
+
...this._config.interceptors,
|
|
71
|
+
...(changes.interceptors || {})
|
|
72
|
+
}
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
75
|
args(...args) { return new this.constructor(this._target, args, this._config); }
|
|
@@ -165,8 +171,14 @@ class VigorParse {
|
|
|
165
171
|
return new this.constructor(this._response, {
|
|
166
172
|
...this._config,
|
|
167
173
|
...changes,
|
|
168
|
-
settings: {
|
|
169
|
-
|
|
174
|
+
settings: {
|
|
175
|
+
...this._config.settings,
|
|
176
|
+
...(changes.settings || {})
|
|
177
|
+
},
|
|
178
|
+
interceptors: {
|
|
179
|
+
...this._config.interceptors,
|
|
180
|
+
...(changes.interceptors || {})
|
|
181
|
+
}
|
|
170
182
|
});
|
|
171
183
|
}
|
|
172
184
|
original(bool) { return this._next({ settings: { original: bool } }); }
|
|
@@ -239,15 +251,24 @@ class VigorFetch {
|
|
|
239
251
|
this._config = {
|
|
240
252
|
request: {
|
|
241
253
|
origin, path: "", query: {},
|
|
242
|
-
method: "", headers: {}, body: null, offset: {}
|
|
254
|
+
method: "", headers: {}, body: null, offset: {},
|
|
255
|
+
...(config.request || {})
|
|
243
256
|
},
|
|
244
257
|
retry: {
|
|
245
258
|
limit: 10000,
|
|
246
259
|
retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"],
|
|
247
260
|
unretry: new Set([400, 401, 403, 404, 406, 409, 410, 411, 413, 414, 415, 422]),
|
|
261
|
+
...(config.retry || {})
|
|
262
|
+
},
|
|
263
|
+
response: {
|
|
264
|
+
retryConfig: undefined,
|
|
265
|
+
parseConfig: undefined,
|
|
266
|
+
...(config.response || {})
|
|
267
|
+
},
|
|
268
|
+
interceptors: {
|
|
269
|
+
before: [], after: [], onError: [], result: [],
|
|
270
|
+
...(config.interceptors || {})
|
|
248
271
|
},
|
|
249
|
-
response: { retryConfig: undefined, parseConfig: undefined },
|
|
250
|
-
interceptors: { before: [], after: [], onError: [], result: [] },
|
|
251
272
|
...config
|
|
252
273
|
};
|
|
253
274
|
}
|
|
@@ -257,7 +278,11 @@ class VigorFetch {
|
|
|
257
278
|
...changes,
|
|
258
279
|
request: { ...this._config.request, ...(changes.request || {}) },
|
|
259
280
|
retry: { ...this._config.retry, ...(changes.retry || {}) },
|
|
260
|
-
|
|
281
|
+
response: { ...this._config.response, ...(changes.response || {}) },
|
|
282
|
+
interceptors: {
|
|
283
|
+
...this._config.interceptors,
|
|
284
|
+
...(changes.interceptors || {})
|
|
285
|
+
}
|
|
261
286
|
});
|
|
262
287
|
}
|
|
263
288
|
origin(str) { return this._next({ request: { origin: str } }); }
|
|
@@ -352,12 +377,13 @@ class VigorFetch {
|
|
|
352
377
|
}
|
|
353
378
|
const parseInstance = new VigorParse(ctx.result, parseConfig);
|
|
354
379
|
ctx.final = await parseInstance.request();
|
|
355
|
-
|
|
380
|
+
const finalInterceptors = this._config.interceptors.result || [];
|
|
381
|
+
for (const func of finalInterceptors) {
|
|
356
382
|
if (typeof func !== 'function')
|
|
357
|
-
|
|
383
|
+
continue;
|
|
358
384
|
const next = await func(ctx.final);
|
|
359
|
-
if (next !== undefined
|
|
360
|
-
ctx.final =
|
|
385
|
+
if (next !== undefined)
|
|
386
|
+
ctx.final = next;
|
|
361
387
|
}
|
|
362
388
|
if (ctx.final instanceof Error)
|
|
363
389
|
throw ctx.final;
|
|
@@ -395,9 +421,18 @@ class VigorAll {
|
|
|
395
421
|
return new this.constructor({
|
|
396
422
|
...this._config,
|
|
397
423
|
...changes,
|
|
398
|
-
settings: {
|
|
399
|
-
|
|
400
|
-
|
|
424
|
+
settings: {
|
|
425
|
+
...this._config.settings,
|
|
426
|
+
...(changes.settings || {})
|
|
427
|
+
},
|
|
428
|
+
request: {
|
|
429
|
+
...this._config.request,
|
|
430
|
+
...(changes.request || {})
|
|
431
|
+
},
|
|
432
|
+
interceptors: {
|
|
433
|
+
...this._config.interceptors,
|
|
434
|
+
...(changes.interceptors || {})
|
|
435
|
+
}
|
|
401
436
|
});
|
|
402
437
|
}
|
|
403
438
|
promises(...func) { return this._next({ request: { promises: [...this._config.request.promises, ...func.flat()] } }); }
|
package/dist/index.mjs
CHANGED
|
@@ -34,7 +34,7 @@ class VigorFetchError extends VigorError {
|
|
|
34
34
|
class VigorAllError extends VigorError {
|
|
35
35
|
constructor(text, options) {
|
|
36
36
|
super(text, options);
|
|
37
|
-
this.message = options.message || `[
|
|
37
|
+
this.message = options.message || `[VigorAllError] ${text}`;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -58,8 +58,14 @@ class VigorRetry {
|
|
|
58
58
|
return new this.constructor(this._target, this._args, {
|
|
59
59
|
...this._config,
|
|
60
60
|
...changes,
|
|
61
|
-
retry: {
|
|
62
|
-
|
|
61
|
+
retry: {
|
|
62
|
+
...this._config.retry,
|
|
63
|
+
...(changes.retry || {})
|
|
64
|
+
},
|
|
65
|
+
interceptors: {
|
|
66
|
+
...this._config.interceptors,
|
|
67
|
+
...(changes.interceptors || {})
|
|
68
|
+
}
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
71
|
args(...args) { return new this.constructor(this._target, args, this._config); }
|
|
@@ -161,8 +167,14 @@ class VigorParse {
|
|
|
161
167
|
return new this.constructor(this._response, {
|
|
162
168
|
...this._config,
|
|
163
169
|
...changes,
|
|
164
|
-
settings: {
|
|
165
|
-
|
|
170
|
+
settings: {
|
|
171
|
+
...this._config.settings,
|
|
172
|
+
...(changes.settings || {})
|
|
173
|
+
},
|
|
174
|
+
interceptors: {
|
|
175
|
+
...this._config.interceptors,
|
|
176
|
+
...(changes.interceptors || {})
|
|
177
|
+
}
|
|
166
178
|
});
|
|
167
179
|
}
|
|
168
180
|
original(bool) { return this._next({ settings: { original: bool } }); }
|
|
@@ -235,15 +247,24 @@ class VigorFetch {
|
|
|
235
247
|
this._config = {
|
|
236
248
|
request: {
|
|
237
249
|
origin, path: "", query: {},
|
|
238
|
-
method: "", headers: {}, body: null, offset: {}
|
|
250
|
+
method: "", headers: {}, body: null, offset: {},
|
|
251
|
+
...(config.request || {})
|
|
239
252
|
},
|
|
240
253
|
retry: {
|
|
241
254
|
limit: 10000,
|
|
242
255
|
retryHeaders: ["retry-after", "ratelimit-reset", "x-ratelimit-reset", "x-retry-after", "x-amz-retry-after", "chrome-proxy-next-link"],
|
|
243
256
|
unretry: new Set([400, 401, 403, 404, 406, 409, 410, 411, 413, 414, 415, 422]),
|
|
257
|
+
...(config.retry || {})
|
|
258
|
+
},
|
|
259
|
+
response: {
|
|
260
|
+
retryConfig: undefined,
|
|
261
|
+
parseConfig: undefined,
|
|
262
|
+
...(config.response || {})
|
|
263
|
+
},
|
|
264
|
+
interceptors: {
|
|
265
|
+
before: [], after: [], onError: [], result: [],
|
|
266
|
+
...(config.interceptors || {})
|
|
244
267
|
},
|
|
245
|
-
response: { retryConfig: undefined, parseConfig: undefined },
|
|
246
|
-
interceptors: { before: [], after: [], onError: [], result: [] },
|
|
247
268
|
...config
|
|
248
269
|
};
|
|
249
270
|
}
|
|
@@ -253,7 +274,11 @@ class VigorFetch {
|
|
|
253
274
|
...changes,
|
|
254
275
|
request: { ...this._config.request, ...(changes.request || {}) },
|
|
255
276
|
retry: { ...this._config.retry, ...(changes.retry || {}) },
|
|
256
|
-
|
|
277
|
+
response: { ...this._config.response, ...(changes.response || {}) },
|
|
278
|
+
interceptors: {
|
|
279
|
+
...this._config.interceptors,
|
|
280
|
+
...(changes.interceptors || {})
|
|
281
|
+
}
|
|
257
282
|
});
|
|
258
283
|
}
|
|
259
284
|
origin(str) { return this._next({ request: { origin: str } }); }
|
|
@@ -348,12 +373,13 @@ class VigorFetch {
|
|
|
348
373
|
}
|
|
349
374
|
const parseInstance = new VigorParse(ctx.result, parseConfig);
|
|
350
375
|
ctx.final = await parseInstance.request();
|
|
351
|
-
|
|
376
|
+
const finalInterceptors = this._config.interceptors.result || [];
|
|
377
|
+
for (const func of finalInterceptors) {
|
|
352
378
|
if (typeof func !== 'function')
|
|
353
|
-
|
|
379
|
+
continue;
|
|
354
380
|
const next = await func(ctx.final);
|
|
355
|
-
if (next !== undefined
|
|
356
|
-
ctx.final =
|
|
381
|
+
if (next !== undefined)
|
|
382
|
+
ctx.final = next;
|
|
357
383
|
}
|
|
358
384
|
if (ctx.final instanceof Error)
|
|
359
385
|
throw ctx.final;
|
|
@@ -391,9 +417,18 @@ class VigorAll {
|
|
|
391
417
|
return new this.constructor({
|
|
392
418
|
...this._config,
|
|
393
419
|
...changes,
|
|
394
|
-
settings: {
|
|
395
|
-
|
|
396
|
-
|
|
420
|
+
settings: {
|
|
421
|
+
...this._config.settings,
|
|
422
|
+
...(changes.settings || {})
|
|
423
|
+
},
|
|
424
|
+
request: {
|
|
425
|
+
...this._config.request,
|
|
426
|
+
...(changes.request || {})
|
|
427
|
+
},
|
|
428
|
+
interceptors: {
|
|
429
|
+
...this._config.interceptors,
|
|
430
|
+
...(changes.interceptors || {})
|
|
431
|
+
}
|
|
397
432
|
});
|
|
398
433
|
}
|
|
399
434
|
promises(...func) { return this._next({ request: { promises: [...this._config.request.promises, ...func.flat()] } }); }
|
package/package.json
CHANGED