vigor-fetch 3.1.6 → 3.1.8

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
@@ -1,38 +1,38 @@
1
1
  declare const VigorErrorMessageFuncs: {
2
- INVALID_TARGET: ({ expected, received }: {
2
+ readonly INVALID_TARGET: ({ expected, received }: {
3
3
  expected: Array<string>;
4
4
  received: unknown;
5
5
  }) => string;
6
- EXHAUSTED: ({ maxAttempts }: {
6
+ readonly EXHAUSTED: ({ maxAttempts }: {
7
7
  maxAttempts: number;
8
8
  }) => string;
9
- TIMED_OUT: ({ limit, attempt }: {
9
+ readonly TIMED_OUT: ({ limit, attempt }: {
10
10
  limit: number;
11
11
  attempt: number;
12
12
  }) => string;
13
- INVALID_CONTENT_TYPE: ({ expected, received, response }: {
13
+ readonly INVALID_CONTENT_TYPE: ({ expected, received, response }: {
14
14
  expected: Array<string>;
15
15
  received: unknown;
16
16
  response: Response;
17
17
  }) => string;
18
- PARSER_NOT_FOUND: ({ expected, received, response }: {
18
+ readonly PARSER_NOT_FOUND: ({ expected, received, response }: {
19
19
  expected: Array<string>;
20
20
  received: unknown;
21
21
  response: Response;
22
22
  }) => string;
23
- PARSER_ALL_FAILED: ({ tried, response }: {
23
+ readonly PARSER_ALL_FAILED: ({ tried, response }: {
24
24
  tried: Array<unknown>;
25
25
  response: Response;
26
26
  }) => string;
27
- INVALID_PROTOCOL: ({ expected, received }: {
27
+ readonly INVALID_PROTOCOL: ({ expected, received }: {
28
28
  expected: Array<string>;
29
29
  received: unknown;
30
30
  }) => string;
31
- INVALID_BODY: ({ expected, received }: {
31
+ readonly INVALID_BODY: ({ expected, received }: {
32
32
  expected: Array<string>;
33
33
  received: unknown;
34
34
  }) => string;
35
- FETCH_FAILED: ({ status, response, url, headers, body, statusText }: {
35
+ readonly FETCH_FAILED: ({ status, response, url, headers, body, statusText }: {
36
36
  status: number;
37
37
  response: Response;
38
38
  url: string;
@@ -40,7 +40,7 @@ declare const VigorErrorMessageFuncs: {
40
40
  body: unknown;
41
41
  statusText: string;
42
42
  }) => string;
43
- EMPTY_TARGET: ({}: {}) => string;
43
+ readonly EMPTY_TARGET: ({}: {}) => string;
44
44
  };
45
45
  type VigorErrorCodes = keyof typeof VigorErrorMessageFuncs;
46
46
  type VigorErrorDatas<C extends VigorErrorCodes> = Parameters<typeof VigorErrorMessageFuncs[C]> extends [infer A] ? A : undefined;
@@ -435,7 +435,7 @@ type VigorFetchOptions<T = Record<string, any>> = {
435
435
  type VigorStringable = string | number | boolean | null | undefined | Date;
436
436
  type VigorFetchConfig = {
437
437
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "CONNECT" | "TRACE";
438
- origin: Array<string>;
438
+ origin: string;
439
439
  path: Array<string>;
440
440
  query: Array<Record<string, VigorStringable | Array<VigorStringable>>>;
441
441
  hash: string;
@@ -544,7 +544,7 @@ declare class VigorFetch extends VigorStatus<VigorFetchConfig, VigorFetch> {
544
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
545
  protected _stringifyList(unkList: Array<VigorStringable>): Array<string>;
546
546
  method(str: VigorFetchConfig["method"]): VigorFetch;
547
- origin(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
547
+ origin(str: VigorFetchConfig["origin"]): VigorFetch;
548
548
  path(...strs: VigorIncludeSpread<VigorStringable>): VigorFetch;
549
549
  query(...strs: VigorIncludeSpread<VigorFetchConfig["query"][number]>): VigorFetch;
550
550
  hash(str: VigorFetchConfig["hash"]): VigorFetch;
@@ -778,9 +778,10 @@ declare const VigorEntry: {
778
778
  error: typeof VigorAllError;
779
779
  };
780
780
  };
781
+ type VigorEntryType = typeof VigorEntry;
781
782
  declare const vigor: {
782
783
  use: <C, R>(func: (entry: typeof VigorEntry, config: C) => R | Promise<R>, config: C) => Promise<R>;
783
- fetch: (...strs: Parameters<VigorFetch["origin"]>[0][]) => VigorFetch;
784
+ fetch: (str: Parameters<VigorFetch["origin"]>[0]) => VigorFetch;
784
785
  retry: (target: Parameters<VigorRetry["target"]>[0]) => VigorRetry;
785
786
  parse: (response: Parameters<VigorParse["target"]>[0]) => VigorParse;
786
787
  all: (...funcs: Parameters<VigorAll["target"]>[0][]) => VigorAll;
@@ -804,4 +805,5 @@ declare const vigor: {
804
805
  };
805
806
  };
806
807
 
807
- export { VigorEntry, vigor as default, vigor };
808
+ export { VigorAllError, VigorEntry, VigorFetchError, VigorParseError, VigorRetryError, vigor as default, vigor };
809
+ export type { VigorAllConfig, VigorAllContext, VigorAllEachContext, VigorAllEachInterceptorsApi, VigorAllEachInterceptorsFunctions, VigorAllInterceptorsApi, VigorAllInterceptorsFunctions, VigorAllSettingsConfig, VigorEntryType, VigorFetchConfig, VigorFetchContext, VigorFetchInterceptorsApi, VigorFetchInterceptorsFunctions, VigorFetchSettingsConfig, VigorParseConfig, VigorParseContext, VigorParseInterceptorsApi, VigorParseInterceptorsFunctions, VigorParseSettingsConfig, VigorRetryConfig, VigorRetryContext, VigorRetryInterceptorsApi, VigorRetryInterceptorsFunctions, VigorRetrySettingsConfig };
package/dist/index.js CHANGED
@@ -917,7 +917,7 @@ class VigorFetchInterceptors extends VigorStatus {
917
917
  class VigorFetch extends VigorStatus {
918
918
  constructor(config) {
919
919
  const base = {
920
- origin: [],
920
+ origin: VigorDefault,
921
921
  path: [],
922
922
  query: [],
923
923
  hash: "",
@@ -972,7 +972,7 @@ class VigorFetch extends VigorStatus {
972
972
  });
973
973
  }
974
974
  method(str) { return this._next({ method: str }); }
975
- origin(...strs) { return this._next({ origin: this._stringifyList(strs.flat()) }); }
975
+ origin(str) { return this._next({ origin: str }); }
976
976
  path(...strs) { return this._next({ path: this._stringifyList(strs.flat()) }); }
977
977
  query(...strs) { return this._next({ query: strs.flat() }); }
978
978
  hash(str) { return this._next({ hash: str }); }
@@ -980,7 +980,7 @@ class VigorFetch extends VigorStatus {
980
980
  headers(obj) { return this._next({ options: { headers: obj } }); }
981
981
  body(obj) { return this._next({ options: { headers: this._config.options.headers, body: obj } }); }
982
982
  _buildUrl(origin, path, query, hash) {
983
- const originObj = new URL(origin[0]);
983
+ const originObj = new URL(origin);
984
984
  const baseStr = originObj.origin;
985
985
  const pathObj = [originObj.pathname.replace(/^\/+|\/+$/g, '')];
986
986
  for (const str of path) {
@@ -1708,8 +1708,8 @@ const vigor = {
1708
1708
  use: async (func, config) => {
1709
1709
  return await func(VigorEntry, config);
1710
1710
  },
1711
- fetch: (...strs) => {
1712
- return new VigorFetch().origin(...strs);
1711
+ fetch: (str) => {
1712
+ return new VigorFetch().origin(str);
1713
1713
  },
1714
1714
  retry: (target) => {
1715
1715
  return new VigorRetry().target(target);
@@ -1740,6 +1740,10 @@ const vigor = {
1740
1740
  }
1741
1741
  };
1742
1742
 
1743
+ exports.VigorAllError = VigorAllError;
1743
1744
  exports.VigorEntry = VigorEntry;
1745
+ exports.VigorFetchError = VigorFetchError;
1746
+ exports.VigorParseError = VigorParseError;
1747
+ exports.VigorRetryError = VigorRetryError;
1744
1748
  exports.default = vigor;
1745
1749
  exports.vigor = vigor;
package/dist/index.mjs CHANGED
@@ -913,7 +913,7 @@ class VigorFetchInterceptors extends VigorStatus {
913
913
  class VigorFetch extends VigorStatus {
914
914
  constructor(config) {
915
915
  const base = {
916
- origin: [],
916
+ origin: VigorDefault,
917
917
  path: [],
918
918
  query: [],
919
919
  hash: "",
@@ -968,7 +968,7 @@ class VigorFetch extends VigorStatus {
968
968
  });
969
969
  }
970
970
  method(str) { return this._next({ method: str }); }
971
- origin(...strs) { return this._next({ origin: this._stringifyList(strs.flat()) }); }
971
+ origin(str) { return this._next({ origin: str }); }
972
972
  path(...strs) { return this._next({ path: this._stringifyList(strs.flat()) }); }
973
973
  query(...strs) { return this._next({ query: strs.flat() }); }
974
974
  hash(str) { return this._next({ hash: str }); }
@@ -976,7 +976,7 @@ class VigorFetch extends VigorStatus {
976
976
  headers(obj) { return this._next({ options: { headers: obj } }); }
977
977
  body(obj) { return this._next({ options: { headers: this._config.options.headers, body: obj } }); }
978
978
  _buildUrl(origin, path, query, hash) {
979
- const originObj = new URL(origin[0]);
979
+ const originObj = new URL(origin);
980
980
  const baseStr = originObj.origin;
981
981
  const pathObj = [originObj.pathname.replace(/^\/+|\/+$/g, '')];
982
982
  for (const str of path) {
@@ -1704,8 +1704,8 @@ const vigor = {
1704
1704
  use: async (func, config) => {
1705
1705
  return await func(VigorEntry, config);
1706
1706
  },
1707
- fetch: (...strs) => {
1708
- return new VigorFetch().origin(...strs);
1707
+ fetch: (str) => {
1708
+ return new VigorFetch().origin(str);
1709
1709
  },
1710
1710
  retry: (target) => {
1711
1711
  return new VigorRetry().target(target);
@@ -1736,4 +1736,4 @@ const vigor = {
1736
1736
  }
1737
1737
  };
1738
1738
 
1739
- export { VigorEntry, vigor as default, vigor };
1739
+ export { VigorAllError, VigorEntry, VigorFetchError, VigorParseError, VigorRetryError, vigor as default, vigor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigor-fetch",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
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",