@zayne-labs/callapi 0.7.8 → 0.7.9
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/cjs/{index-BdIHCe8F.d.cts → index-BQKLLrYI.d.cts} +10 -4
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/utils/index.d.cts +1 -1
- package/dist/esm/{index-BdIHCe8F.d.ts → index-BQKLLrYI.d.ts} +10 -4
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -7,13 +7,15 @@ type AnyNumber = number & {
|
|
|
7
7
|
type Prettify<TObject> = {
|
|
8
8
|
[Key in keyof TObject]: TObject[Key];
|
|
9
9
|
} & NonNullable<unknown>;
|
|
10
|
+
type ResponseHeader = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection";
|
|
11
|
+
type BaseMime = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo";
|
|
10
12
|
|
|
11
13
|
type ToQueryStringFn = {
|
|
12
14
|
(params: ExtraOptions["query"]): string | null;
|
|
13
15
|
(params: Required<ExtraOptions>["query"]): string;
|
|
14
16
|
};
|
|
15
17
|
declare const toQueryString: ToQueryStringFn;
|
|
16
|
-
declare const fetchSpecificKeys: ("body" | "
|
|
18
|
+
declare const fetchSpecificKeys: ("body" | "headers" | "method" | "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window")[];
|
|
17
19
|
declare const handleResponseType: <TResponse>(response: Response, parser?: Required<ExtraOptions>["responseParser"]) => {
|
|
18
20
|
arrayBuffer: () => Promise<TResponse>;
|
|
19
21
|
blob: () => Promise<TResponse>;
|
|
@@ -43,6 +45,9 @@ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error
|
|
|
43
45
|
}
|
|
44
46
|
declare const isHTTPErrorInstance: <TErrorResponse>(error: unknown) => error is HTTPError<TErrorResponse>;
|
|
45
47
|
|
|
48
|
+
interface FetchConfig<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = "all"> extends Omit<RequestInit, "body" | "headers" | "method">, ExtraOptions<TData, TErrorData, TResultMode> {
|
|
49
|
+
}
|
|
50
|
+
type BaseConfig<TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = "all"> = FetchConfig<TBaseData, TBaseErrorData, TBaseResultMode>;
|
|
46
51
|
interface $RequestOptions extends Pick<FetchConfig, (typeof fetchSpecificKeys)[number]> {
|
|
47
52
|
}
|
|
48
53
|
interface ExtraOptions<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion> {
|
|
@@ -81,6 +86,10 @@ interface ExtraOptions<TData = unknown, TErrorData = unknown, TResultMode extend
|
|
|
81
86
|
* @default "Failed to fetch data from server!"
|
|
82
87
|
*/
|
|
83
88
|
defaultErrorMessage?: string;
|
|
89
|
+
/**
|
|
90
|
+
* @description Headers to be used in the request.
|
|
91
|
+
*/
|
|
92
|
+
headers?: Record<"Content-Type", BaseMime> | Record<ResponseHeader, string> | RequestInit["headers"];
|
|
84
93
|
/**
|
|
85
94
|
* @description an optional field you can fill with additional information,
|
|
86
95
|
* to associate with the request, typically used for logging or tracing.
|
|
@@ -208,9 +217,6 @@ type ErrorContext<TErrorData> = {
|
|
|
208
217
|
request: $RequestOptions;
|
|
209
218
|
response: Response;
|
|
210
219
|
};
|
|
211
|
-
interface FetchConfig<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = "all"> extends Omit<RequestInit, "body" | "method">, ExtraOptions<TData, TErrorData, TResultMode> {
|
|
212
|
-
}
|
|
213
|
-
type BaseConfig<TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = "all"> = FetchConfig<TBaseData, TBaseErrorData, TBaseResultMode>;
|
|
214
220
|
type ApiSuccessVariant<TData> = {
|
|
215
221
|
data: TData;
|
|
216
222
|
error: null;
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResultModeUnion, B as BaseConfig, F as FetchConfig, G as GetCallApiResult } from './index-
|
|
2
|
-
export { $ as $RequestOptions, c as ErrorContext, E as ExtraOptions, a as ResponseContext, b as ResponseErrorContext } from './index-
|
|
1
|
+
import { R as ResultModeUnion, B as BaseConfig, F as FetchConfig, G as GetCallApiResult } from './index-BQKLLrYI.cjs';
|
|
2
|
+
export { $ as $RequestOptions, c as ErrorContext, E as ExtraOptions, a as ResponseContext, b as ResponseErrorContext } from './index-BQKLLrYI.cjs';
|
|
3
3
|
|
|
4
4
|
declare const createFetchClient: <TBaseData, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
|
|
5
5
|
<TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeUnion = TBaseResultMode>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode>): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { H as HTTPError, i as isHTTPError, d as isHTTPErrorInstance, t as toQueryString } from '../index-
|
|
1
|
+
export { H as HTTPError, i as isHTTPError, d as isHTTPErrorInstance, t as toQueryString } from '../index-BQKLLrYI.cjs';
|
|
@@ -7,13 +7,15 @@ type AnyNumber = number & {
|
|
|
7
7
|
type Prettify<TObject> = {
|
|
8
8
|
[Key in keyof TObject]: TObject[Key];
|
|
9
9
|
} & NonNullable<unknown>;
|
|
10
|
+
type ResponseHeader = "Access-Control-Allow-Credentials" | "Access-Control-Allow-Headers" | "Access-Control-Allow-Methods" | "Access-Control-Allow-Origin" | "Access-Control-Expose-Headers" | "Access-Control-Max-Age" | "Age" | "Allow" | "Cache-Control" | "Clear-Site-Data" | "Content-Disposition" | "Content-Encoding" | "Content-Language" | "Content-Length" | "Content-Location" | "Content-Range" | "Content-Security-Policy-Report-Only" | "Content-Security-Policy" | "Cookie" | "Cross-Origin-Embedder-Policy" | "Cross-Origin-Opener-Policy" | "Cross-Origin-Resource-Policy" | "Date" | "ETag" | "Expires" | "Last-Modified" | "Location" | "Permissions-Policy" | "Pragma" | "Retry-After" | "Save-Data" | "Sec-CH-Prefers-Color-Scheme" | "Sec-CH-Prefers-Reduced-Motion" | "Sec-CH-UA-Arch" | "Sec-CH-UA-Bitness" | "Sec-CH-UA-Form-Factor" | "Sec-CH-UA-Full-Version-List" | "Sec-CH-UA-Full-Version" | "Sec-CH-UA-Mobile" | "Sec-CH-UA-Model" | "Sec-CH-UA-Platform-Version" | "Sec-CH-UA-Platform" | "Sec-CH-UA-WoW64" | "Sec-CH-UA" | "Sec-Fetch-Dest" | "Sec-Fetch-Mode" | "Sec-Fetch-Site" | "Sec-Fetch-User" | "Sec-GPC" | "Server-Timing" | "Server" | "Service-Worker-Navigation-Preload" | "Set-Cookie" | "Strict-Transport-Security" | "Timing-Allow-Origin" | "Trailer" | "Transfer-Encoding" | "Upgrade" | "Vary" | "Warning" | "WWW-Authenticate" | "X-Content-Type-Options" | "X-DNS-Prefetch-Control" | "X-Frame-Options" | "X-Permitted-Cross-Domain-Policies" | "X-Powered-By" | "X-Robots-Tag" | "X-XSS-Protection";
|
|
11
|
+
type BaseMime = "application/epub+zip" | "application/gzip" | "application/json" | "application/ld+json" | "application/octet-stream" | "application/ogg" | "application/pdf" | "application/rtf" | "application/vnd.ms-fontobject" | "application/wasm" | "application/xhtml+xml" | "application/xml" | "application/zip" | "audio/aac" | "audio/mpeg" | "audio/ogg" | "audio/opus" | "audio/webm" | "audio/x-midi" | "font/otf" | "font/ttf" | "font/woff" | "font/woff2" | "image/avif" | "image/bmp" | "image/gif" | "image/jpeg" | "image/png" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/x-icon" | "model/gltf-binary" | "model/gltf+json" | "text/calendar" | "text/css" | "text/csv" | "text/html" | "text/javascript" | "text/plain" | "video/3gpp" | "video/3gpp2" | "video/av1" | "video/mp2t" | "video/mp4" | "video/mpeg" | "video/ogg" | "video/webm" | "video/x-msvideo";
|
|
10
12
|
|
|
11
13
|
type ToQueryStringFn = {
|
|
12
14
|
(params: ExtraOptions["query"]): string | null;
|
|
13
15
|
(params: Required<ExtraOptions>["query"]): string;
|
|
14
16
|
};
|
|
15
17
|
declare const toQueryString: ToQueryStringFn;
|
|
16
|
-
declare const fetchSpecificKeys: ("body" | "
|
|
18
|
+
declare const fetchSpecificKeys: ("body" | "headers" | "method" | "cache" | "credentials" | "integrity" | "keepalive" | "mode" | "priority" | "redirect" | "referrer" | "referrerPolicy" | "signal" | "window")[];
|
|
17
19
|
declare const handleResponseType: <TResponse>(response: Response, parser?: Required<ExtraOptions>["responseParser"]) => {
|
|
18
20
|
arrayBuffer: () => Promise<TResponse>;
|
|
19
21
|
blob: () => Promise<TResponse>;
|
|
@@ -43,6 +45,9 @@ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error
|
|
|
43
45
|
}
|
|
44
46
|
declare const isHTTPErrorInstance: <TErrorResponse>(error: unknown) => error is HTTPError<TErrorResponse>;
|
|
45
47
|
|
|
48
|
+
interface FetchConfig<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = "all"> extends Omit<RequestInit, "body" | "headers" | "method">, ExtraOptions<TData, TErrorData, TResultMode> {
|
|
49
|
+
}
|
|
50
|
+
type BaseConfig<TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = "all"> = FetchConfig<TBaseData, TBaseErrorData, TBaseResultMode>;
|
|
46
51
|
interface $RequestOptions extends Pick<FetchConfig, (typeof fetchSpecificKeys)[number]> {
|
|
47
52
|
}
|
|
48
53
|
interface ExtraOptions<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = ResultModeUnion> {
|
|
@@ -81,6 +86,10 @@ interface ExtraOptions<TData = unknown, TErrorData = unknown, TResultMode extend
|
|
|
81
86
|
* @default "Failed to fetch data from server!"
|
|
82
87
|
*/
|
|
83
88
|
defaultErrorMessage?: string;
|
|
89
|
+
/**
|
|
90
|
+
* @description Headers to be used in the request.
|
|
91
|
+
*/
|
|
92
|
+
headers?: Record<"Content-Type", BaseMime> | Record<ResponseHeader, string> | RequestInit["headers"];
|
|
84
93
|
/**
|
|
85
94
|
* @description an optional field you can fill with additional information,
|
|
86
95
|
* to associate with the request, typically used for logging or tracing.
|
|
@@ -208,9 +217,6 @@ type ErrorContext<TErrorData> = {
|
|
|
208
217
|
request: $RequestOptions;
|
|
209
218
|
response: Response;
|
|
210
219
|
};
|
|
211
|
-
interface FetchConfig<TData = unknown, TErrorData = unknown, TResultMode extends ResultModeUnion = "all"> extends Omit<RequestInit, "body" | "method">, ExtraOptions<TData, TErrorData, TResultMode> {
|
|
212
|
-
}
|
|
213
|
-
type BaseConfig<TBaseData = unknown, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = "all"> = FetchConfig<TBaseData, TBaseErrorData, TBaseResultMode>;
|
|
214
220
|
type ApiSuccessVariant<TData> = {
|
|
215
221
|
data: TData;
|
|
216
222
|
error: null;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ResultModeUnion, B as BaseConfig, F as FetchConfig, G as GetCallApiResult } from './index-
|
|
2
|
-
export { $ as $RequestOptions, c as ErrorContext, E as ExtraOptions, a as ResponseContext, b as ResponseErrorContext } from './index-
|
|
1
|
+
import { R as ResultModeUnion, B as BaseConfig, F as FetchConfig, G as GetCallApiResult } from './index-BQKLLrYI.js';
|
|
2
|
+
export { $ as $RequestOptions, c as ErrorContext, E as ExtraOptions, a as ResponseContext, b as ResponseErrorContext } from './index-BQKLLrYI.js';
|
|
3
3
|
|
|
4
4
|
declare const createFetchClient: <TBaseData, TBaseErrorData = unknown, TBaseResultMode extends ResultModeUnion = undefined>(baseConfig?: BaseConfig<TBaseData, TBaseErrorData, TBaseResultMode>) => {
|
|
5
5
|
<TData = TBaseData, TErrorData = TBaseErrorData, TResultMode extends ResultModeUnion = TBaseResultMode>(url: string, config?: FetchConfig<TData, TErrorData, TResultMode>): Promise<GetCallApiResult<TData, TErrorData, TResultMode>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { H as HTTPError, i as isHTTPError, d as isHTTPErrorInstance, t as toQueryString } from '../index-
|
|
1
|
+
export { H as HTTPError, i as isHTTPError, d as isHTTPErrorInstance, t as toQueryString } from '../index-BQKLLrYI.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/callapi",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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
6
|
"repository": {
|