@zayne-labs/callapi 1.6.14 → 1.6.15

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  CallApi Fetch is an extra-lightweight wrapper over fetch that provides quality of life improvements beyond the bare fetch api, while keeping the API familiar.
6
6
 
7
- It takes in a url and a request options object, just like fetch, but with some additional options to make your life easier. Check out the [API Reference](https://zayne-labs-callapi.netlify.app/docs/v1/all-options) for a quick look at each option.
7
+ It takes in a url and a request options object, just like fetch, but with some additional options to make your life easier. Check out the [API Reference](https://zayne-labs-callapi.netlify.app/docs/latest/all-options) for a quick look at each option.
8
8
 
9
9
  # Docs
10
10
 
@@ -139,7 +139,7 @@ interface RetryOptions<TErrorData> {
139
139
  * Keeps track of the number of times the request has already been retried
140
140
  * @deprecated This property is used internally to track retries. Please abstain from modifying it.
141
141
  */
142
- readonly "~retryCount"?: number;
142
+ readonly ["~retryCount"]?: number;
143
143
  /**
144
144
  * Number of allowed retry attempts on HTTP errors
145
145
  * @default 0
@@ -355,7 +355,7 @@ type InterceptorsOrInterceptorArray<TData = DefaultDataType, TErrorData = Defaul
355
355
  [Key in keyof Interceptors<TData, TErrorData, TMoreOptions>]: Interceptors<TData, TErrorData, TMoreOptions>[Key] | Array<Interceptors<TData, TErrorData, TMoreOptions>[Key]>;
356
356
  };
357
357
  type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
358
- type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = {
358
+ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = {
359
359
  /**
360
360
  * Authorization header value.
361
361
  */
@@ -451,18 +451,18 @@ type ExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResult
451
451
  validators?: CallApiValidators<TData, TErrorData>;
452
452
  } & InterceptorsOrInterceptorArray<TData, TErrorData> & Partial<InferPluginOptions<TPluginArray>> & MetaOption<TSchemas> & RetryOptions<TErrorData> & ResultModeOption<TErrorData, TResultMode> & UrlOptions<TSchemas>;
453
453
  declare const optionsEnumToExtendFromBase: ("plugins" | "schemas" | "validators")[];
454
- type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = CallApiRequestOptions<TSchemas> & ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TSchemas, TPluginArray> & {
454
+ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = CallApiRequestOptions<TSchemas> & ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas> & {
455
455
  /**
456
456
  * Options that should extend the base options.
457
457
  */
458
- extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TSchemas, TPluginArray>, (typeof optionsEnumToExtendFromBase)[number]>;
458
+ extend?: Pick<ExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>, (typeof optionsEnumToExtendFromBase)[number]>;
459
459
  };
460
460
  declare const optionsEnumToOmitFromBase: ("dedupeKey" | "extend")[];
461
- type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends boolean = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemas extends CallApiSchemas = DefaultMoreOptions, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray> = Omit<Partial<CallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBaseSchemas, TBasePluginArray>>, (typeof optionsEnumToOmitFromBase)[number]>;
461
+ 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]>;
462
462
  type CombinedCallApiExtraOptions = BaseCallApiExtraOptions & CallApiExtraOptions;
463
- type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TSchemas extends CallApiSchemas = DefaultMoreOptions, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [
463
+ type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends boolean = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TSchemas extends CallApiSchemas = DefaultMoreOptions> = [
464
464
  initURL: InferSchemaResult<TSchemas["initURL"], InitURL>,
465
- config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TSchemas, TPluginArray>
465
+ config?: CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray, TSchemas>
466
466
  ];
467
467
  type RequestContext = UnmaskType<{
468
468
  options: CombinedCallApiExtraOptions;
@@ -546,6 +546,22 @@ type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TRespo
546
546
  onlySuccessWithException: CallApiResultSuccessVariant<TComputedData>["data"];
547
547
  }>;
548
548
  type ResultModeUnion = keyof ResultModeMap | undefined;
549
- type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends boolean, TResponseType extends ResponseTypeUnion> = TErrorData extends false | undefined ? ResultModeMap<TData, TErrorData, TResponseType>["onlySuccessWithException"] : ResultModeUnion | undefined extends TResultMode ? TThrowOnError extends true ? ResultModeMap<TData, TErrorData, TResponseType>["allWithException"] : ResultModeMap<TData, TErrorData, TResponseType>["all"] : TResultMode extends NonNullable<ResultModeUnion> ? ResultModeMap<TData, TErrorData, TResponseType>[TResultMode] : never;
549
+ type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends boolean, TResponseType extends ResponseTypeUnion> = TErrorData extends false | undefined ? ResultModeMap<TData, TErrorData, TResponseType>["onlySuccessWithException"] : ResultModeUnion | undefined extends TResultMode ? TThrowOnError extends true ? ResultModeMap<TData, TErrorData, TResponseType>["allWithException"] : ResultModeMap<TData, TErrorData, TResponseType>["all"] : TResultMode extends NonNullable<ResultModeUnion> ? TResultMode extends "onlySuccess" ? ResultModeMap<TData, TErrorData, TResponseType>["onlySuccessWithException"] : TResultMode extends "onlyResponse" ? ResultModeMap<TData, TErrorData, TResponseType>["onlyResponseWithException"] : ResultModeMap<TData, TErrorData, TResponseType>[TResultMode] : never;
550
550
 
551
- export { type BaseCallApiExtraOptions as B, type CallApiSchemas as C, type DefaultPluginArray as D, type ErrorContext as E, type GetCallApiResult as G, type InferSchemaResult as I, type PluginInitContext as P, type ResultModeUnion as R, type SuccessContext as S, type ResponseTypeUnion as a, type CallApiPlugin as b, type CallApiExtraOptions as c, type DefaultDataType as d, type DefaultThrowOnError as e, type DefaultMoreOptions as f, definePlugin as g, type PossibleJavaScriptError as h, type PossibleHTTPError as i, type CallApiParameters as j, type CallApiRequestOptions as k, type CallApiRequestOptionsForHooks as l, type CallApiResultErrorVariant as m, type CallApiResultSuccessVariant as n, type CombinedCallApiExtraOptions as o, type Interceptors as p, type InterceptorsOrInterceptorArray as q, type PossibleJavascriptErrorNames as r, type Register as s, type RequestContext as t, type RequestErrorContext as u, type ResponseContext as v, type ResponseErrorContext as w, type InitURL as x, defaultRetryMethods as y, defaultRetryStatusCodes as z };
551
+ type ErrorDetails<TErrorResponse> = {
552
+ defaultErrorMessage: string;
553
+ errorData: TErrorResponse;
554
+ response: Response;
555
+ };
556
+ type ErrorOptions = {
557
+ cause?: unknown;
558
+ };
559
+ declare class HTTPError<TErrorResponse = Record<string, unknown>> extends Error {
560
+ errorData: ErrorDetails<TErrorResponse>["errorData"];
561
+ isHTTPError: boolean;
562
+ name: "HTTPError";
563
+ response: ErrorDetails<TErrorResponse>["response"];
564
+ constructor(errorDetails: ErrorDetails<TErrorResponse>, errorOptions?: ErrorOptions);
565
+ }
566
+
567
+ export { type BaseCallApiExtraOptions as B, type CallApiPlugin as C, type DefaultPluginArray as D, type ErrorContext as E, type GetCallApiResult as G, HTTPError as H, type InferSchemaResult as I, type PluginInitContext as P, type ResultModeUnion as R, type SuccessContext as S, type ResponseTypeUnion as a, type CallApiSchemas as b, type CallApiExtraOptions as c, type DefaultDataType as d, type DefaultThrowOnError as e, type DefaultMoreOptions as f, type CallApiParameters as g, definePlugin as h, type PossibleJavaScriptError as i, type PossibleHTTPError as j, type CallApiRequestOptions as k, type CallApiRequestOptionsForHooks as l, type CallApiResultErrorVariant as m, type CallApiResultSuccessVariant as n, type CombinedCallApiExtraOptions as o, type Interceptors as p, type InterceptorsOrInterceptorArray as q, type PossibleJavascriptErrorNames as r, type Register as s, type RequestContext as t, type RequestErrorContext as u, type ResponseContext as v, type ResponseErrorContext as w, defaultRetryMethods as x, defaultRetryStatusCodes as y };