vigor-fetch 3.1.3 → 3.1.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
@@ -120,6 +120,7 @@ type VigorRetryAlgorithmsConstantConfig = {
120
120
  declare class VigorRetryAlgorithmsConstant extends VigorStatus<VigorRetryAlgorithmsConstantConfig, VigorRetryAlgorithmsConstant> {
121
121
  constructor(config?: Partial<VigorRetryAlgorithmsConstantConfig>);
122
122
  interval(num: VigorRetryAlgorithmsConstantConfig["interval"]): VigorRetryAlgorithmsConstant;
123
+ _calculateDelay(attempt: number): number;
123
124
  }
124
125
  type VigorRetryAlgorithmsLinearConfig = {
125
126
  initial: number;
@@ -133,6 +134,7 @@ declare class VigorRetryAlgorithmsLinear extends VigorStatus<VigorRetryAlgorithm
133
134
  increment(num: VigorRetryAlgorithmsLinearConfig["increment"]): VigorRetryAlgorithmsLinear;
134
135
  minDelay(num: VigorRetryAlgorithmsLinearConfig["minDelay"]): VigorRetryAlgorithmsLinear;
135
136
  maxDelay(num: VigorRetryAlgorithmsLinearConfig["maxDelay"]): VigorRetryAlgorithmsLinear;
137
+ _calculateDelay(attempt: number): number;
136
138
  }
137
139
  type VigorRetryAlgorithmsBackoffConfig = {
138
140
  initial: number;
@@ -148,6 +150,7 @@ declare class VigorRetryAlgorithmsBackoff extends VigorStatus<VigorRetryAlgorith
148
150
  unit(num: VigorRetryAlgorithmsBackoffConfig["unit"]): VigorRetryAlgorithmsBackoff;
149
151
  minDelay(num: VigorRetryAlgorithmsBackoffConfig["minDelay"]): VigorRetryAlgorithmsBackoff;
150
152
  maxDelay(num: VigorRetryAlgorithmsBackoffConfig["maxDelay"]): VigorRetryAlgorithmsBackoff;
153
+ _calculateDelay(attempt: number): number;
151
154
  }
152
155
  type VigorRetryAlgorithmsCustomConfig = {
153
156
  func: VigorRetryAlgorithmsConfig;
@@ -157,6 +160,7 @@ type VigorRetryAlgorithmsCustomConfig = {
157
160
  declare class VigorRetryAlgorithmsCustom extends VigorStatus<VigorRetryAlgorithmsCustomConfig, VigorRetryAlgorithmsCustom> {
158
161
  constructor(config?: Partial<VigorRetryAlgorithmsCustomConfig>);
159
162
  func(num: VigorRetryAlgorithmsCustomConfig["func"]): VigorRetryAlgorithmsCustom;
163
+ _calculateDelay(attempt: number): number;
160
164
  }
161
165
  type VigorRetryAlgorithmsConfig = (attempt: number) => number;
162
166
  type VigorRetryInterceptorsApi<R> = {
@@ -260,9 +264,14 @@ type VigorRetryTimeline<I extends keyof VigorRetryInterceptorsFunctions, H exten
260
264
  };
261
265
  declare class VigorRetry extends VigorStatus<VigorRetryConfig, VigorRetry> {
262
266
  constructor(config?: Partial<VigorRetryConfig>);
263
- private RetryAlgorithms;
264
- private _createTimelineHandler;
265
- private _createInterceptorHandler;
267
+ protected readonly RetryAlgorithms: {
268
+ constant: (config?: Partial<VigorRetryAlgorithmsConstantConfig>) => VigorRetryAlgorithmsConstant;
269
+ linear: (config?: Partial<VigorRetryAlgorithmsLinearConfig>) => VigorRetryAlgorithmsLinear;
270
+ backoff: (config?: Partial<VigorRetryAlgorithmsBackoffConfig>) => VigorRetryAlgorithmsBackoff;
271
+ custom: (config?: Partial<VigorRetryAlgorithmsCustomConfig>) => VigorRetryAlgorithmsCustom;
272
+ };
273
+ protected _createTimelineHandler(timeline: VigorRetryContext["timeline"]): <I extends keyof VigorRetryInterceptorsFunctions, H extends keyof VigorRetryProcessHandler, K extends keyof VigorRetryTimeline<I, H>>(action: K, content: VigorRetryTimeline<I, H>[K]) => void;
274
+ protected _createInterceptorHandler(ctx: VigorRetryContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorRetryInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorRetryInterceptorsFunctions[I]) => Pick<VigorRetryInterceptorsApi<any>, VigorRetryAllowedApis<I>>) => Promise<void>;
266
275
  target(func: VigorRetryConfig["target"]): VigorRetry;
267
276
  settings(func: ((s: VigorRetrySettings) => VigorRetrySettings) | VigorRetrySettings | VigorRetrySettings["_config"]): VigorRetry;
268
277
  interceptors(func: ((i: VigorRetryInterceptors) => VigorRetryInterceptors) | VigorRetryInterceptors | VigorRetryInterceptors["_config"]): VigorRetry;
@@ -286,9 +295,19 @@ type VigorParseStrategiesConfig = {
286
295
  };
287
296
  declare class VigorParseStrategies extends VigorStatus<VigorParseStrategiesConfig, VigorParseStrategies> {
288
297
  constructor(config?: Partial<VigorParseStrategiesConfig>);
289
- private ParseAutoHeaders;
290
- private ParseAutoMethods;
291
- private ParseAutoAlgorithms;
298
+ protected readonly ParseAutoHeaders: {
299
+ header: string;
300
+ regExp: RegExp;
301
+ method: (res: Response) => Promise<any>;
302
+ }[];
303
+ protected readonly ParseAutoMethods: {
304
+ title: string;
305
+ method: (res: Response) => Promise<any>;
306
+ }[];
307
+ protected readonly ParseAutoAlgorithms: {
308
+ contentType: (response: Response) => Promise<any>;
309
+ sniff: (response: Response) => Promise<any>;
310
+ };
292
311
  contentType(): VigorParseStrategies;
293
312
  sniff(): VigorParseStrategies;
294
313
  json(): VigorParseStrategies;
@@ -377,8 +396,8 @@ type VigorParseTimeline<I extends keyof VigorParseInterceptorsFunctions, H exten
377
396
  };
378
397
  declare class VigorParse extends VigorStatus<VigorParseConfig, VigorParse> {
379
398
  constructor(config?: Partial<VigorParseConfig>);
380
- private _createTimelineHandler;
381
- private _createInterceptorHandler;
399
+ protected _createTimelineHandler(timeline: VigorParseContext["timeline"]): <I extends keyof VigorParseInterceptorsFunctions, H extends keyof VigorParseProcessHandler, K extends keyof VigorParseTimeline<I, H>>(action: K, content: VigorParseTimeline<I, H>[K]) => void;
400
+ protected _createInterceptorHandler(ctx: VigorParseContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorParseInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorParseInterceptorsFunctions[I]) => Pick<VigorParseInterceptorsApi<any>, VigorParseAllowedApis<I>>) => Promise<void>;
382
401
  target(response: VigorParseConfig["target"]): VigorParse;
383
402
  settings(func: ((i: VigorParseSettings) => VigorParseSettings) | VigorParseSettings | VigorParseSettings["_config"]): VigorParse;
384
403
  strategies(func: ((i: VigorParseStrategies) => VigorParseStrategies) | VigorParseStrategies | VigorParseStrategies["_config"]): VigorParse;
@@ -521,9 +540,9 @@ type VigorFetchTimeline<I extends keyof VigorFetchInterceptorsFunctions, H exten
521
540
  };
522
541
  declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
523
542
  constructor(config?: Partial<VigorFetchConfig>);
524
- private _createTimelineHandler;
525
- private _createInterceptorHandler;
526
- private _stringifyList;
543
+ protected _createTimelineHandler(timeline: VigorFetchContext["timeline"]): <I extends keyof VigorFetchInterceptorsFunctions, H extends keyof VigorFetchProcessHandler, K extends keyof VigorFetchTimeline<I, H>>(action: K, content: VigorFetchTimeline<I, H>[K]) => void;
544
+ protected _createInterceptorHandler(ctx: VigorFetchContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorFetchInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorFetchInterceptorsFunctions[I]) => Pick<VigorFetchInterceptorsApi<any>, VigorFetchAllowedApis<I>>) => Promise<void>;
545
+ protected _stringifyList(unkList: Array<VigorStringable>): Array<string>;
527
546
  method(str: VigorFetchConfig["method"]): VigorFetch;
528
547
  origin(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
529
548
  path(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
@@ -532,8 +551,12 @@ declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
532
551
  options(obj: VigorFetchConfig["options"]): VigorFetch;
533
552
  headers(obj: VigorFetchConfig["options"]["headers"]): VigorFetch;
534
553
  body(obj: VigorFetchConfig["options"]["body"]): VigorFetch;
535
- private _buildUrl;
536
- private _normalizeOptions;
554
+ protected _buildUrl(origin: VigorFetchConfig["origin"], path: VigorFetchConfig["path"], query: VigorFetchConfig["query"], hash: VigorFetchConfig["hash"]): string;
555
+ protected _normalizeOptions(body: unknown): {
556
+ isJson: boolean;
557
+ headers: Record<string, unknown>;
558
+ body: BodyInit | null | undefined;
559
+ };
537
560
  settings(func: ((s: VigorFetchSettings) => VigorFetchSettings) | VigorFetchSettings | VigorFetchSettings["_config"]): VigorFetch;
538
561
  interceptors(func: ((s: VigorFetchInterceptors) => VigorFetchInterceptors) | VigorFetchInterceptors | VigorFetchInterceptors["_config"]): VigorFetch;
539
562
  retryConfig(func: ((s: VigorRetry) => VigorRetry) | VigorRetry | VigorRetry["_config"]): VigorFetch;
@@ -706,14 +729,20 @@ type VigorAllEachTimeline<I extends keyof VigorAllEachInterceptorsFunctions, H e
706
729
  };
707
730
  declare class VigorAll extends VigorStatus<VigorAllConfig, VigorAll> {
708
731
  constructor(config?: Partial<VigorAllConfig>);
709
- private _createTimelineHandler;
710
- private _createInterceptorHandler;
711
- private _createEachTimelineHandler;
712
- private _createEachInterceptorHandler;
732
+ protected _createTimelineHandler(timeline: VigorAllContext["timeline"]): <I extends keyof VigorAllInterceptorsFunctions, H extends keyof VigorAllProcessHandler, K extends keyof VigorAllTimeline<I, H>>(action: K, content: VigorAllTimeline<I, H>[K]) => void;
733
+ protected _createInterceptorHandler(ctx: VigorAllContext, addTimeline: ReturnType<typeof this._createTimelineHandler>): <I extends keyof VigorAllInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorAllInterceptorsFunctions[I]) => Pick<VigorAllInterceptorsApi<any>, VigorAllAllowedApis<I>>) => Promise<void>;
734
+ protected _createEachTimelineHandler(timeline: VigorAllEachContext["timeline"]): <I extends keyof VigorAllEachInterceptorsFunctions, H extends keyof VigorAllEachProcessHandler, K extends keyof VigorAllEachTimeline<I, H>>(action: K, content: VigorAllEachTimeline<I, H>[K]) => void;
735
+ protected _createEachInterceptorHandler(ctx: VigorAllEachContext, addEachTimeline: ReturnType<typeof this._createEachTimelineHandler>): <I extends keyof VigorAllEachInterceptorsFunctions>(interceptorType: I, api: (interceptorType: I, func: VigorAllEachInterceptorsFunctions[I]) => Pick<VigorAllEachInterceptorsApi<any>, VigorAllEachAllowedApis<I>>) => Promise<void>;
713
736
  target(...funcs: VigorIncludeSpread<VigorAllConfig["target"][number]>): VigorAll;
714
737
  settings(func: ((s: VigorAllSettings) => VigorAllSettings) | VigorAllSettings | VigorAllSettings["_config"]): VigorAll;
715
738
  interceptors(func: ((s: VigorAllInterceptors) => VigorAllInterceptors) | VigorAllInterceptors | VigorAllInterceptors["_config"]): VigorAll;
716
- private runTask;
739
+ protected runTask(task: VigorAllEachContext["target"], { stats, root }: {
740
+ stats: VigorAllEachContext["stats"];
741
+ root: VigorAllEachContext["root"];
742
+ }, semaphore: {
743
+ acquire: VigorAllEachContext["semaphore"]["acquire"];
744
+ release: VigorAllEachContext["semaphore"]["release"];
745
+ }): Promise<unknown>;
717
746
  request<R extends VigorAllContext["result"]>(config?: VigorAllConfig, timeline?: VigorAllContext["timeline"]): Promise<R>;
718
747
  }
719
748
  declare const VigorEntry: {
package/dist/index.js CHANGED
@@ -130,7 +130,6 @@ class VigorRetryAlgorithmsConstant extends VigorStatus {
130
130
  super(config, base, (c) => new VigorRetryAlgorithmsConstant(c));
131
131
  }
132
132
  interval(num) { return this._next({ interval: num }); }
133
- /** @internal */
134
133
  _calculateDelay(attempt) {
135
134
  return this._config.interval;
136
135
  }
@@ -149,7 +148,6 @@ class VigorRetryAlgorithmsLinear extends VigorStatus {
149
148
  increment(num) { return this._next({ increment: num }); }
150
149
  minDelay(num) { return this._next({ minDelay: num }); }
151
150
  maxDelay(num) { return this._next({ maxDelay: num }); }
152
- /** @internal */
153
151
  _calculateDelay(attempt) {
154
152
  const { initial, increment, minDelay, maxDelay } = this._config;
155
153
  return Math.max(minDelay, Math.min(maxDelay, initial + increment * attempt));
@@ -171,7 +169,6 @@ class VigorRetryAlgorithmsBackoff extends VigorStatus {
171
169
  unit(num) { return this._next({ unit: num }); }
172
170
  minDelay(num) { return this._next({ minDelay: num }); }
173
171
  maxDelay(num) { return this._next({ maxDelay: num }); }
174
- /** @internal */
175
172
  _calculateDelay(attempt) {
176
173
  const { initial, multiplier, unit, minDelay, maxDelay } = this._config;
177
174
  return Math.max(minDelay, Math.min(maxDelay, initial + unit * Math.pow(multiplier, attempt)));
@@ -187,7 +184,6 @@ class VigorRetryAlgorithmsCustom extends VigorStatus {
187
184
  super(config, base, (c) => new VigorRetryAlgorithmsCustom(c));
188
185
  }
189
186
  func(num) { return this._next({ func: num }); }
190
- /** @internal */
191
187
  _calculateDelay(attempt) {
192
188
  const { func, minDelay, maxDelay } = this._config;
193
189
  return Math.max(minDelay, Math.min(maxDelay, func(attempt)));
package/dist/index.mjs CHANGED
@@ -126,7 +126,6 @@ class VigorRetryAlgorithmsConstant extends VigorStatus {
126
126
  super(config, base, (c) => new VigorRetryAlgorithmsConstant(c));
127
127
  }
128
128
  interval(num) { return this._next({ interval: num }); }
129
- /** @internal */
130
129
  _calculateDelay(attempt) {
131
130
  return this._config.interval;
132
131
  }
@@ -145,7 +144,6 @@ class VigorRetryAlgorithmsLinear extends VigorStatus {
145
144
  increment(num) { return this._next({ increment: num }); }
146
145
  minDelay(num) { return this._next({ minDelay: num }); }
147
146
  maxDelay(num) { return this._next({ maxDelay: num }); }
148
- /** @internal */
149
147
  _calculateDelay(attempt) {
150
148
  const { initial, increment, minDelay, maxDelay } = this._config;
151
149
  return Math.max(minDelay, Math.min(maxDelay, initial + increment * attempt));
@@ -167,7 +165,6 @@ class VigorRetryAlgorithmsBackoff extends VigorStatus {
167
165
  unit(num) { return this._next({ unit: num }); }
168
166
  minDelay(num) { return this._next({ minDelay: num }); }
169
167
  maxDelay(num) { return this._next({ maxDelay: num }); }
170
- /** @internal */
171
168
  _calculateDelay(attempt) {
172
169
  const { initial, multiplier, unit, minDelay, maxDelay } = this._config;
173
170
  return Math.max(minDelay, Math.min(maxDelay, initial + unit * Math.pow(multiplier, attempt)));
@@ -183,7 +180,6 @@ class VigorRetryAlgorithmsCustom extends VigorStatus {
183
180
  super(config, base, (c) => new VigorRetryAlgorithmsCustom(c));
184
181
  }
185
182
  func(num) { return this._next({ func: num }); }
186
- /** @internal */
187
183
  _calculateDelay(attempt) {
188
184
  const { func, minDelay, maxDelay } = this._config;
189
185
  return Math.max(minDelay, Math.min(maxDelay, func(attempt)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigor-fetch",
3
- "version": "3.1.3",
3
+ "version": "3.1.5",
4
4
  "description": "Smart, zero-dependency HTTP client with self-healing retries for rate-limited servers.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",