@zayne-labs/callapi 0.0.3 → 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Ikedigwe Ebube
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,9 @@
1
- import { F as FetchConfig, G as GetCallApiResult, B as BaseConfig, H as HTTPError } from './types-Cf2V09St.cjs';
1
+ import { R as ResultStyleUnion, F as FetchConfig, G as GetCallApiResult, B as BaseConfig, H as HTTPError } from './types-B8arQl4O.cjs';
2
2
 
3
3
  declare const callApi: {
4
- <TData = unknown, TErrorData = unknown, TResultMode extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = undefined>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode> | undefined): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
5
- create: <TBaseData, TBaseErrorData, TBaseResultMode extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
6
- <TData_1 = TBaseData, TErrorData_1 = TBaseErrorData, TResultMode_1 extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = TBaseResultMode>(url: string, config?: FetchConfig<TData_1, TErrorData_1, TResultMode_1> | undefined): Promise<GetCallApiResult<TData_1, TErrorData_1, TResultMode_1>>;
4
+ <TData = unknown, TErrorData = unknown, TResultMode extends ResultStyleUnion = undefined>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode> | undefined): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
5
+ create: <TBaseData, TBaseErrorData, TBaseResultMode extends ResultStyleUnion = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
6
+ <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultStyleUnion = TBaseResultMode>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode>): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
7
7
  create: any;
8
8
  isHTTPErrorInfo: (errorInfo: Record<string, unknown> | null) => errorInfo is {
9
9
  errorName: "HTTPError";
@@ -1,9 +1,9 @@
1
- import { F as FetchConfig, G as GetCallApiResult, B as BaseConfig, H as HTTPError } from './types-Cf2V09St.js';
1
+ import { R as ResultStyleUnion, F as FetchConfig, G as GetCallApiResult, B as BaseConfig, H as HTTPError } from './types-B8arQl4O.js';
2
2
 
3
3
  declare const callApi: {
4
- <TData = unknown, TErrorData = unknown, TResultMode extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = undefined>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode> | undefined): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
5
- create: <TBaseData, TBaseErrorData, TBaseResultMode extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
6
- <TData_1 = TBaseData, TErrorData_1 = TBaseErrorData, TResultMode_1 extends "all" | "onlySuccess" | "onlyError" | "onlyResponse" | undefined = TBaseResultMode>(url: string, config?: FetchConfig<TData_1, TErrorData_1, TResultMode_1> | undefined): Promise<GetCallApiResult<TData_1, TErrorData_1, TResultMode_1>>;
4
+ <TData = unknown, TErrorData = unknown, TResultMode extends ResultStyleUnion = undefined>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode> | undefined): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
5
+ create: <TBaseData, TBaseErrorData, TBaseResultMode extends ResultStyleUnion = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
6
+ <TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultStyleUnion = TBaseResultMode>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode>): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
7
7
  create: any;
8
8
  isHTTPErrorInfo: (errorInfo: Record<string, unknown> | null) => errorInfo is {
9
9
  errorName: "HTTPError";
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default as callApi } from './createFetchClient.cjs';
2
- export { B as BaseConfig, F as FetchConfig, H as HTTPError, i as isHTTPErrorInfo, a as isHTTPErrorInstance } from './types-Cf2V09St.cjs';
2
+ export { B as BaseConfig, F as FetchConfig, H as HTTPError, i as isHTTPErrorInfo, a as isHTTPErrorInstance } from './types-B8arQl4O.cjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default as callApi } from './createFetchClient.js';
2
- export { B as BaseConfig, F as FetchConfig, H as HTTPError, i as isHTTPErrorInfo, a as isHTTPErrorInstance } from './types-Cf2V09St.js';
2
+ export { B as BaseConfig, F as FetchConfig, H as HTTPError, i as isHTTPErrorInfo, a as isHTTPErrorInstance } from './types-B8arQl4O.js';
@@ -30,9 +30,9 @@ declare const $resolveErrorResult: <CallApiResult>($info: {
30
30
  error?: unknown;
31
31
  options: ExtraOptions;
32
32
  }) => (info?: {
33
- response?: Response | undefined;
33
+ response?: Response;
34
34
  errorData?: unknown;
35
- message?: string | undefined;
35
+ message?: string;
36
36
  }) => CallApiResult;
37
37
  declare const isHTTPErrorInfo: (errorInfo: Record<string, unknown> | null) => errorInfo is {
38
38
  errorName: "HTTPError";
@@ -54,7 +54,7 @@ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error
54
54
  }
55
55
  declare const isHTTPErrorInstance: <TErrorResponse>(error: unknown) => error is HTTPError<TErrorResponse>;
56
56
  declare const wait: (delay: number) => Promise<unknown> | undefined;
57
- declare const isFormData: (value: unknown) => boolean;
57
+ declare const isFormData: (value: unknown) => value is FormData;
58
58
  declare const isObject: <TObject extends Record<string, unknown>>(value: unknown) => value is TObject;
59
59
  declare const isFunction: <TFunction extends AnyFunction>(value: unknown) => value is TFunction;
60
60
 
@@ -144,4 +144,4 @@ type ResultStyleUnion = {
144
144
  }["_"];
145
145
  type GetCallApiResult<TData, TErrorData, TResultMode> = TResultMode extends NonNullable<ResultStyleUnion> ? ResultStyleMap<TData, TErrorData>[TResultMode] : ResultStyleMap<TData, TErrorData>["all"];
146
146
 
147
- export { $resolveErrorResult as $, type BaseConfig as B, type FetchConfig as F, type GetCallApiResult as G, HTTPError as H, isHTTPErrorInstance as a, defaultRetryMethods as b, isFormData as c, defaultRetryCodes as d, isObject as e, fetchSpecificKeys as f, getResponseData as g, handleResponseType as h, isHTTPErrorInfo as i, isFunction as j, mergeUrlWithParams as m, objectifyHeaders as o, resolveSuccessResult as r, splitConfig as s, wait as w };
147
+ export { $resolveErrorResult as $, type BaseConfig as B, type FetchConfig as F, type GetCallApiResult as G, HTTPError as H, type ResultStyleUnion as R, isHTTPErrorInstance as a, defaultRetryMethods as b, isFormData as c, defaultRetryCodes as d, isObject as e, fetchSpecificKeys as f, getResponseData as g, handleResponseType as h, isHTTPErrorInfo as i, isFunction as j, mergeUrlWithParams as m, objectifyHeaders as o, resolveSuccessResult as r, splitConfig as s, wait as w };
@@ -30,9 +30,9 @@ declare const $resolveErrorResult: <CallApiResult>($info: {
30
30
  error?: unknown;
31
31
  options: ExtraOptions;
32
32
  }) => (info?: {
33
- response?: Response | undefined;
33
+ response?: Response;
34
34
  errorData?: unknown;
35
- message?: string | undefined;
35
+ message?: string;
36
36
  }) => CallApiResult;
37
37
  declare const isHTTPErrorInfo: (errorInfo: Record<string, unknown> | null) => errorInfo is {
38
38
  errorName: "HTTPError";
@@ -54,7 +54,7 @@ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error
54
54
  }
55
55
  declare const isHTTPErrorInstance: <TErrorResponse>(error: unknown) => error is HTTPError<TErrorResponse>;
56
56
  declare const wait: (delay: number) => Promise<unknown> | undefined;
57
- declare const isFormData: (value: unknown) => boolean;
57
+ declare const isFormData: (value: unknown) => value is FormData;
58
58
  declare const isObject: <TObject extends Record<string, unknown>>(value: unknown) => value is TObject;
59
59
  declare const isFunction: <TFunction extends AnyFunction>(value: unknown) => value is TFunction;
60
60
 
@@ -144,4 +144,4 @@ type ResultStyleUnion = {
144
144
  }["_"];
145
145
  type GetCallApiResult<TData, TErrorData, TResultMode> = TResultMode extends NonNullable<ResultStyleUnion> ? ResultStyleMap<TData, TErrorData>[TResultMode] : ResultStyleMap<TData, TErrorData>["all"];
146
146
 
147
- export { $resolveErrorResult as $, type BaseConfig as B, type FetchConfig as F, type GetCallApiResult as G, HTTPError as H, isHTTPErrorInstance as a, defaultRetryMethods as b, isFormData as c, defaultRetryCodes as d, isObject as e, fetchSpecificKeys as f, getResponseData as g, handleResponseType as h, isHTTPErrorInfo as i, isFunction as j, mergeUrlWithParams as m, objectifyHeaders as o, resolveSuccessResult as r, splitConfig as s, wait as w };
147
+ export { $resolveErrorResult as $, type BaseConfig as B, type FetchConfig as F, type GetCallApiResult as G, HTTPError as H, type ResultStyleUnion as R, isHTTPErrorInstance as a, defaultRetryMethods as b, isFormData as c, defaultRetryCodes as d, isObject as e, fetchSpecificKeys as f, getResponseData as g, handleResponseType as h, isHTTPErrorInfo as i, isFunction as j, mergeUrlWithParams as m, objectifyHeaders as o, resolveSuccessResult as r, splitConfig as s, wait as w };
package/dist/utils.d.cts CHANGED
@@ -1 +1 @@
1
- export { $ as $resolveErrorResult, H as HTTPError, d as defaultRetryCodes, b as defaultRetryMethods, f as fetchSpecificKeys, g as getResponseData, h as handleResponseType, c as isFormData, j as isFunction, i as isHTTPErrorInfo, a as isHTTPErrorInstance, e as isObject, m as mergeUrlWithParams, o as objectifyHeaders, r as resolveSuccessResult, s as splitConfig, w as wait } from './types-Cf2V09St.cjs';
1
+ export { $ as $resolveErrorResult, H as HTTPError, d as defaultRetryCodes, b as defaultRetryMethods, f as fetchSpecificKeys, g as getResponseData, h as handleResponseType, c as isFormData, j as isFunction, i as isHTTPErrorInfo, a as isHTTPErrorInstance, e as isObject, m as mergeUrlWithParams, o as objectifyHeaders, r as resolveSuccessResult, s as splitConfig, w as wait } from './types-B8arQl4O.cjs';
package/dist/utils.d.ts CHANGED
@@ -1 +1 @@
1
- export { $ as $resolveErrorResult, H as HTTPError, d as defaultRetryCodes, b as defaultRetryMethods, f as fetchSpecificKeys, g as getResponseData, h as handleResponseType, c as isFormData, j as isFunction, i as isHTTPErrorInfo, a as isHTTPErrorInstance, e as isObject, m as mergeUrlWithParams, o as objectifyHeaders, r as resolveSuccessResult, s as splitConfig, w as wait } from './types-Cf2V09St.js';
1
+ export { $ as $resolveErrorResult, H as HTTPError, d as defaultRetryCodes, b as defaultRetryMethods, f as fetchSpecificKeys, g as getResponseData, h as handleResponseType, c as isFormData, j as isFunction, i as isHTTPErrorInfo, a as isHTTPErrorInstance, e as isObject, m as mergeUrlWithParams, o as objectifyHeaders, r as resolveSuccessResult, s as splitConfig, w as wait } from './types-B8arQl4O.js';
package/package.json CHANGED
@@ -1,23 +1,8 @@
1
1
  {
2
2
  "name": "@zayne-labs/callapi",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "description": "A lightweight wrapper over fetch with quality of life improvements like built-in request cancellation, retries, interceptors and more",
6
- "repository": "ryan-zayne/callApi",
7
- "homepage": "https://github.com/ryan-zayne/callApi#readme",
8
- "license": "MIT",
9
- "author": "Ryan Zayne",
10
- "keywords": [
11
- "fetch",
12
- "api",
13
- "wrapper",
14
- "request cancellation",
15
- "cancel",
16
- "retry",
17
- "interceptor"
18
- ],
19
- "main": "./dist/index.cjs",
20
- "module": "./dist/index.js",
21
6
  "types": "./dist/index.d.ts",
22
7
  "exports": {
23
8
  ".": {
@@ -32,6 +17,22 @@
32
17
  "dist"
33
18
  ],
34
19
  "sideEffects": false,
20
+ "repository": "ryan-zayne/callApi",
21
+ "homepage": "https://github.com/ryan-zayne/callApi#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/ryan-zayne/callApi/issues"
24
+ },
25
+ "license": "MIT",
26
+ "author": "Ryan Zayne",
27
+ "keywords": [
28
+ "fetch",
29
+ "api",
30
+ "wrapper",
31
+ "request",
32
+ "cancel",
33
+ "retry",
34
+ "interceptor"
35
+ ],
35
36
  "devDependencies": {
36
37
  "@changesets/cli": "^2.27.5",
37
38
  "@eslint/js": "^9.5.0",
@@ -47,7 +48,7 @@
47
48
  "lint-staged": "^15.2.7",
48
49
  "prettier": "^3.3.2",
49
50
  "tsup": "^8.1.0",
50
- "typescript": "5.4.5",
51
+ "typescript": "5.5.2",
51
52
  "typescript-eslint": "^7.13.1"
52
53
  },
53
54
  "scripts": {