@zayne-labs/callapi 1.7.0 → 1.7.1
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/README.md +2 -2
- package/dist/cjs/{error-C7M77J6L.d.cts → error-B0rQm6WQ.d.cts} +47 -37
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/utils/index.cjs.map +1 -1
- package/dist/cjs/utils/index.d.cts +1 -1
- package/dist/esm/{chunk-PAYXYIB5.js → chunk-MMZRXEXE.js} +2 -2
- package/dist/esm/chunk-MMZRXEXE.js.map +1 -0
- package/dist/esm/{error-C7M77J6L.d.ts → error-B0rQm6WQ.d.ts} +47 -37
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/package.json +4 -4
- package/dist/esm/chunk-PAYXYIB5.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<h1 align="center">CallApi - Advanced Fetch Client</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img src="
|
|
4
|
+
<img src="https://github.com/zayne-labs/call-api/blob/main/packages/callapi/assets/logo.png" alt="CallApi Logo" width="30%">
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<a href="https://deno.bundlejs.com/badge?q=@zayne-labs/callapi,@zayne-labs/callapi&treeshake=%5B*%5D,%5B%7B+createFetchClient+%7D%5D&config=%7B%22compression%22:%7B%22type%22:%22brotli%22,%22quality%22:11%7D%7D"><img src="https://deno.bundlejs.com/badge?q=@zayne-labs/callapi,@zayne-labs/callapi&treeshake=%5B*%5D,%5B%7B+createFetchClient+%7D%5D&config=%7B%22compression%22:%7B%22type%22:%22brotli%22,%22quality%22:11%7D%7D" alt="bundle size"></a>
|
|
8
|
+
<!-- <a href="https://deno.bundlejs.com/badge?q=@zayne-labs/callapi,@zayne-labs/callapi&treeshake=%5B*%5D,%5B%7B+createFetchClient+%7D%5D&config=%7B%22compression%22:%7B%22type%22:%22brotli%22,%22quality%22:11%7D%7D"><img src="https://deno.bundlejs.com/badge?q=@zayne-labs/callapi,@zayne-labs/callapi&treeshake=%5B*%5D,%5B%7B+createFetchClient+%7D%5D&config=%7B%22compression%22:%7B%22type%22:%22brotli%22,%22quality%22:11%7D%7D" alt="bundle size"></a> -->
|
|
9
9
|
<a href="https://www.npmjs.com/package/@zayne-labs/callapi"><img src="https://img.shields.io/npm/v/@zayne-labs/callapi?style=flat&color=EFBA5F" alt="npm version"></a>
|
|
10
10
|
<a href="https://github.com/zayne-labs/call-api/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@zayne-labs/callapi?style=flat&color=EFBA5F" alt="license"></a>
|
|
11
11
|
<a href="https://github.com/zayne-labs/call-api/graphs/commit-activity"><img src="https://img.shields.io/github/commit-activity/m/zayne-labs/call-api?style=flat&color=EFBA5F" alt="commit activity"></a>
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
-
type StreamProgressEvent = {
|
|
4
|
-
/**
|
|
5
|
-
* Current chunk of data being streamed
|
|
6
|
-
*/
|
|
7
|
-
chunk: Uint8Array;
|
|
8
|
-
/**
|
|
9
|
-
* Progress in percentage
|
|
10
|
-
*/
|
|
11
|
-
progress: number;
|
|
12
|
-
/**
|
|
13
|
-
* Total size of data in bytes
|
|
14
|
-
*/
|
|
15
|
-
totalBytes: number;
|
|
16
|
-
/**
|
|
17
|
-
* Amount of data transferred so far
|
|
18
|
-
*/
|
|
19
|
-
transferredBytes: number;
|
|
20
|
-
};
|
|
21
|
-
type RequestStreamContext = {
|
|
22
|
-
event: StreamProgressEvent;
|
|
23
|
-
options: CombinedCallApiExtraOptions;
|
|
24
|
-
request: CallApiRequestOptionsForHooks;
|
|
25
|
-
requestInstance: Request;
|
|
26
|
-
};
|
|
27
|
-
type ResponseStreamContext = {
|
|
28
|
-
event: StreamProgressEvent;
|
|
29
|
-
options: CombinedCallApiExtraOptions;
|
|
30
|
-
request: CallApiRequestOptionsForHooks;
|
|
31
|
-
response: Response;
|
|
32
|
-
};
|
|
33
|
-
declare global {
|
|
34
|
-
interface ReadableStream<R> {
|
|
35
|
-
[Symbol.asyncIterator]: () => AsyncIterableIterator<R>;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
3
|
type ValueOrFunctionResult<TValue> = TValue | (() => TValue);
|
|
40
4
|
/**
|
|
41
5
|
* Bearer Or Token authentication
|
|
@@ -233,6 +197,42 @@ type ResponseTypeMap<TResponse> = {
|
|
|
233
197
|
};
|
|
234
198
|
type GetResponseType<TResponse, TResponseType extends ResponseTypeUnion, TComputedMap extends ResponseTypeMap<TResponse> = ResponseTypeMap<TResponse>> = undefined extends TResponseType ? TComputedMap["json"] : TResponseType extends NonNullable<ResponseTypeUnion> ? TComputedMap[TResponseType] : never;
|
|
235
199
|
|
|
200
|
+
type StreamProgressEvent = {
|
|
201
|
+
/**
|
|
202
|
+
* Current chunk of data being streamed
|
|
203
|
+
*/
|
|
204
|
+
chunk: Uint8Array;
|
|
205
|
+
/**
|
|
206
|
+
* Progress in percentage
|
|
207
|
+
*/
|
|
208
|
+
progress: number;
|
|
209
|
+
/**
|
|
210
|
+
* Total size of data in bytes
|
|
211
|
+
*/
|
|
212
|
+
totalBytes: number;
|
|
213
|
+
/**
|
|
214
|
+
* Amount of data transferred so far
|
|
215
|
+
*/
|
|
216
|
+
transferredBytes: number;
|
|
217
|
+
};
|
|
218
|
+
type RequestStreamContext = {
|
|
219
|
+
event: StreamProgressEvent;
|
|
220
|
+
options: CombinedCallApiExtraOptions;
|
|
221
|
+
request: CallApiRequestOptionsForHooks;
|
|
222
|
+
requestInstance: Request;
|
|
223
|
+
};
|
|
224
|
+
type ResponseStreamContext = {
|
|
225
|
+
event: StreamProgressEvent;
|
|
226
|
+
options: CombinedCallApiExtraOptions;
|
|
227
|
+
request: CallApiRequestOptionsForHooks;
|
|
228
|
+
response: Response;
|
|
229
|
+
};
|
|
230
|
+
declare global {
|
|
231
|
+
interface ReadableStream<R> {
|
|
232
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<R>;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
236
|
type UnionToIntersection<TUnion> = (TUnion extends unknown ? (param: TUnion) => void : never) extends (param: infer TParam) => void ? TParam : never;
|
|
237
237
|
type InferSchema<TResult> = TResult extends StandardSchemaV1 ? InferSchemaResult<TResult, NonNullable<unknown>> : TResult;
|
|
238
238
|
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<InferSchema<ReturnType<NonNullable<TPluginArray[number]["createExtraOptions"]>>>>;
|
|
@@ -535,7 +535,17 @@ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType,
|
|
|
535
535
|
extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>, (typeof optionsEnumToExtendFromBase)[number]>;
|
|
536
536
|
};
|
|
537
537
|
declare const optionsEnumToOmitFromBase: ("dedupeKey" | "extend")[];
|
|
538
|
-
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>>, (typeof optionsEnumToOmitFromBase)[number]
|
|
538
|
+
type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>>, (typeof optionsEnumToOmitFromBase)[number]> & {
|
|
539
|
+
/**
|
|
540
|
+
* If true, the base options will not be merged with the main options by default.
|
|
541
|
+
*
|
|
542
|
+
* It's recommended to set this to true when you want to handle the options merge manually from the createFetchClient config function signature.
|
|
543
|
+
*
|
|
544
|
+
* This helps prevent main options from overriding base options by default.
|
|
545
|
+
* @default false
|
|
546
|
+
*/
|
|
547
|
+
mergeMainOptionsManuallyFromBase?: boolean;
|
|
548
|
+
};
|
|
539
549
|
type CombinedCallApiExtraOptions = Interceptors & Omit<BaseCallApiExtraOptions & CallApiExtraOptions, keyof Interceptors>;
|
|
540
550
|
type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions> = (CallApiRequestOptions<TBaseSchemas> & BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemas>) | ((context: {
|
|
541
551
|
initURL: string;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -784,7 +784,7 @@ var createFetchClient = (baseConfig = {}) => {
|
|
|
784
784
|
const mergedExtraOptions = {
|
|
785
785
|
...defaultExtraOptions,
|
|
786
786
|
...baseExtraOptions,
|
|
787
|
-
|
|
787
|
+
...!baseExtraOptions.mergeMainOptionsManuallyFromBase && extraOptions
|
|
788
788
|
};
|
|
789
789
|
const mergedRequestOptions = {
|
|
790
790
|
...defaultRequestOptions,
|