@zayne-labs/callapi 1.11.10 → 1.11.11
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/esm/{common-DvPxUh-h.d.ts → common-7RMbhCz1.d.ts} +204 -128
- package/dist/esm/common-CXyKVpND.js +649 -0
- package/dist/esm/common-CXyKVpND.js.map +1 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -423
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/external/index.d.ts +2 -80
- package/dist/esm/utils/external/index.js +2 -2
- package/package.json +1 -1
- package/dist/esm/body-BVMFJoeo.js +0 -228
- package/dist/esm/body-BVMFJoeo.js.map +0 -1
|
@@ -369,23 +369,87 @@ type BaseCallApiSchemaAndConfig = {
|
|
|
369
369
|
declare const fallBackRouteSchemaKey = ".";
|
|
370
370
|
type FallBackRouteSchemaKey = typeof fallBackRouteSchemaKey;
|
|
371
371
|
//#endregion
|
|
372
|
-
//#region src/
|
|
373
|
-
type
|
|
374
|
-
|
|
372
|
+
//#region src/utils/external/body.d.ts
|
|
373
|
+
type ToQueryStringFn = {
|
|
374
|
+
(query: CallApiExtraOptions["query"]): string | null;
|
|
375
|
+
(query: Required<CallApiExtraOptions>["query"]): string;
|
|
376
|
+
};
|
|
377
|
+
declare const toQueryString: ToQueryStringFn;
|
|
378
|
+
type AllowedPrimitives = boolean | number | string | Blob;
|
|
379
|
+
type AllowedValues = AllowedPrimitives | AllowedPrimitives[] | Record<string, AllowedPrimitives>;
|
|
380
|
+
type ToFormDataFn = {
|
|
381
|
+
(data: Record<string, AllowedValues>): FormData;
|
|
382
|
+
<TData extends Record<string, AllowedValues>>(data: TData, options: {
|
|
383
|
+
returnType: "inputType";
|
|
384
|
+
}): TData;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* @description Converts a plain object to FormData.
|
|
388
|
+
*
|
|
389
|
+
* Handles various data types:
|
|
390
|
+
* - **Primitives** (string, number, boolean): Converted to strings
|
|
391
|
+
* - **Blobs/Files**: Added directly to FormData
|
|
392
|
+
* - **Arrays**: Each item is appended (allows multiple values for same key)
|
|
393
|
+
* - **Objects**: JSON stringified before adding to FormData
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* // Basic usage
|
|
398
|
+
* const formData = toFormData({
|
|
399
|
+
* name: "John",
|
|
400
|
+
* age: 30,
|
|
401
|
+
* active: true
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* // With arrays
|
|
405
|
+
* const formData = toFormData({
|
|
406
|
+
* tags: ["javascript", "typescript"],
|
|
407
|
+
* name: "John"
|
|
408
|
+
* });
|
|
409
|
+
*
|
|
410
|
+
* // With files
|
|
411
|
+
* const formData = toFormData({
|
|
412
|
+
* avatar: fileBlob,
|
|
413
|
+
* name: "John"
|
|
414
|
+
* });
|
|
415
|
+
*
|
|
416
|
+
* // With nested objects (one level only)
|
|
417
|
+
* const formData = toFormData({
|
|
418
|
+
* user: { name: "John", age: 30 },
|
|
419
|
+
* settings: { theme: "dark" }
|
|
420
|
+
* });
|
|
421
|
+
*
|
|
422
|
+
* // Type-preserving usage with Zod
|
|
423
|
+
* const schema = z.object({ name: z.string(), file: z.instanceof(Blob) });
|
|
424
|
+
* const data = schema.parse({ name: "John", file: blob });
|
|
425
|
+
* const typedFormData = toFormData(data, { returnType: "inputType" });
|
|
426
|
+
* // Type is { name: string; file: Blob }, runtime is FormData
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
declare const toFormData: ToFormDataFn;
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/types/default-types.d.ts
|
|
432
|
+
type DefaultDataType = unknown;
|
|
433
|
+
type DefaultPluginArray = CallApiPlugin[];
|
|
434
|
+
type DefaultThrowOnError = boolean;
|
|
435
|
+
//#endregion
|
|
436
|
+
//#region src/utils/external/error.d.ts
|
|
437
|
+
type HTTPErrorDetails<TErrorData$1> = Pick<CallApiExtraOptions, "defaultHTTPErrorMessage"> & {
|
|
438
|
+
errorData: TErrorData$1;
|
|
375
439
|
response: Response;
|
|
376
440
|
};
|
|
377
|
-
declare class HTTPError<TErrorData = Record<string, unknown>> extends Error {
|
|
378
|
-
errorData: HTTPErrorDetails<TErrorData>["errorData"];
|
|
441
|
+
declare class HTTPError<TErrorData$1 = Record<string, unknown>> extends Error {
|
|
442
|
+
errorData: HTTPErrorDetails<TErrorData$1>["errorData"];
|
|
379
443
|
readonly httpErrorSymbol: symbol;
|
|
380
444
|
name: "HTTPError";
|
|
381
|
-
response: HTTPErrorDetails<TErrorData>["response"];
|
|
382
|
-
constructor(errorDetails: HTTPErrorDetails<TErrorData>, errorOptions?: ErrorOptions);
|
|
445
|
+
response: HTTPErrorDetails<TErrorData$1>["response"];
|
|
446
|
+
constructor(errorDetails: HTTPErrorDetails<TErrorData$1>, errorOptions?: ErrorOptions);
|
|
383
447
|
/**
|
|
384
448
|
* @description Checks if the given error is an instance of HTTPError
|
|
385
449
|
* @param error - The error to check
|
|
386
450
|
* @returns true if the error is an instance of HTTPError, false otherwise
|
|
387
451
|
*/
|
|
388
|
-
static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData>;
|
|
452
|
+
static isError<TErrorData>(error: unknown): error is HTTPError<TErrorData$1>;
|
|
389
453
|
}
|
|
390
454
|
type SafeExtract<TUnion, TKey extends TUnion> = Extract<TUnion, TKey>;
|
|
391
455
|
type ValidationErrorDetails = {
|
|
@@ -419,6 +483,70 @@ declare class ValidationError extends Error {
|
|
|
419
483
|
static isError(error: unknown): error is ValidationError;
|
|
420
484
|
}
|
|
421
485
|
//#endregion
|
|
486
|
+
//#region src/result.d.ts
|
|
487
|
+
type Parser<TData$1> = (responseString: string) => Awaitable<TData$1>;
|
|
488
|
+
declare const getResponseType: <TResponse>(response: Response, parser: Parser<TResponse>) => {
|
|
489
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
490
|
+
blob: () => Promise<Blob>;
|
|
491
|
+
formData: () => Promise<FormData>;
|
|
492
|
+
json: () => Promise<TResponse>;
|
|
493
|
+
stream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
494
|
+
text: () => Promise<string>;
|
|
495
|
+
};
|
|
496
|
+
type InitResponseTypeMap<TResponse$1 = unknown> = ReturnType<typeof getResponseType<TResponse$1>>;
|
|
497
|
+
type ResponseTypeUnion = keyof InitResponseTypeMap | null;
|
|
498
|
+
type ResponseTypeMap<TResponse$1> = { [Key in keyof InitResponseTypeMap<TResponse$1>]: Awaited<ReturnType<InitResponseTypeMap<TResponse$1>[Key]>> };
|
|
499
|
+
type GetResponseType<TResponse$1, TResponseType extends ResponseTypeUnion, TComputedResponseTypeMap extends ResponseTypeMap<TResponse$1> = ResponseTypeMap<TResponse$1>> = null extends TResponseType ? TComputedResponseTypeMap["json"] : TResponseType extends NonNullable<ResponseTypeUnion> ? TComputedResponseTypeMap[TResponseType] : never;
|
|
500
|
+
type CallApiResultSuccessVariant<TData$1> = {
|
|
501
|
+
data: NoInfer<TData$1>;
|
|
502
|
+
error: null;
|
|
503
|
+
response: Response;
|
|
504
|
+
};
|
|
505
|
+
type PossibleJavaScriptError = UnmaskType<{
|
|
506
|
+
errorData: false;
|
|
507
|
+
message: string;
|
|
508
|
+
name: "AbortError" | "Error" | "SyntaxError" | "TimeoutError" | "TypeError" | AnyString;
|
|
509
|
+
originalError: DOMException | Error | SyntaxError | TypeError;
|
|
510
|
+
}>;
|
|
511
|
+
type PossibleHTTPError<TErrorData$1> = UnmaskType<{
|
|
512
|
+
errorData: NoInfer<TErrorData$1>;
|
|
513
|
+
message: string;
|
|
514
|
+
name: "HTTPError";
|
|
515
|
+
originalError: HTTPError;
|
|
516
|
+
}>;
|
|
517
|
+
type PossibleValidationError = UnmaskType<{
|
|
518
|
+
errorData: ValidationError["errorData"];
|
|
519
|
+
issueCause: ValidationError["issueCause"];
|
|
520
|
+
message: string;
|
|
521
|
+
name: "ValidationError";
|
|
522
|
+
originalError: ValidationError;
|
|
523
|
+
}>;
|
|
524
|
+
type PossibleJavaScriptOrValidationError = UnmaskType<PossibleJavaScriptError | PossibleValidationError>;
|
|
525
|
+
type CallApiResultErrorVariant<TErrorData$1> = {
|
|
526
|
+
data: null;
|
|
527
|
+
error: PossibleHTTPError<TErrorData$1>;
|
|
528
|
+
response: Response;
|
|
529
|
+
} | {
|
|
530
|
+
data: null;
|
|
531
|
+
error: PossibleJavaScriptOrValidationError;
|
|
532
|
+
response: Response | null;
|
|
533
|
+
};
|
|
534
|
+
type CallApiSuccessOrErrorVariant<TData$1, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData$1>;
|
|
535
|
+
type ResultModeMapWithoutException<TData$1, TErrorData$1, TResponseType extends ResponseTypeUnion, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedErrorData = GetResponseType<TErrorData$1, TResponseType>, TComputedResult extends CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData> = CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData>> = UnmaskType<{
|
|
536
|
+
all: TComputedResult;
|
|
537
|
+
onlyData: TComputedResult["data"];
|
|
538
|
+
onlyResponse: TComputedResult["response"];
|
|
539
|
+
}>;
|
|
540
|
+
type ResultModeMapWithException<TData$1, TResponseType extends ResponseTypeUnion, TComputedData = GetResponseType<TData$1, TResponseType>, TComputedResult extends CallApiResultSuccessVariant<TComputedData> = CallApiResultSuccessVariant<TComputedData>> = {
|
|
541
|
+
all: TComputedResult;
|
|
542
|
+
onlyData: TComputedResult["data"];
|
|
543
|
+
onlyResponse: TComputedResult["response"];
|
|
544
|
+
};
|
|
545
|
+
type ResultModeMap<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError> = TThrowOnError extends true ? ResultModeMapWithException<TData$1, TResponseType> : ResultModeMapWithoutException<TData$1, TErrorData$1, TResponseType>;
|
|
546
|
+
type ResultModePlaceholder = null;
|
|
547
|
+
type ResultModeUnion = keyof ResultModeMap | ResultModePlaceholder;
|
|
548
|
+
type GetCallApiResult<TData$1, TErrorData$1, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion, TComputedResultModeMapWithException extends ResultModeMapWithException<TData$1, TResponseType> = ResultModeMapWithException<TData$1, TResponseType>, TComputedResultModeMap extends ResultModeMap<TData$1, TErrorData$1, TResponseType, TThrowOnError> = ResultModeMap<TData$1, TErrorData$1, TResponseType, TThrowOnError>> = TErrorData$1 extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData$1 extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMap["all"] : TResultMode extends Exclude<ResultModeUnion, ResultModePlaceholder> ? TComputedResultModeMap[TResultMode] : never;
|
|
549
|
+
//#endregion
|
|
422
550
|
//#region src/middlewares.d.ts
|
|
423
551
|
type FetchImpl = UnmaskType<(input: string | Request | URL, init?: RequestInit) => Promise<Response>>;
|
|
424
552
|
interface Middlewares {
|
|
@@ -467,7 +595,7 @@ type PluginInitResult = Partial<Omit<PluginSetupContext, "initURL" | "request">
|
|
|
467
595
|
request: CallApiRequestOptions;
|
|
468
596
|
}>;
|
|
469
597
|
type PluginHooksWithMoreOptions<TMoreOptions = unknown> = HooksOrHooksArray<never, never, TMoreOptions>;
|
|
470
|
-
type PluginHooks<TData = never, TErrorData = never, TMoreOptions = unknown> = HooksOrHooksArray<TData, TErrorData, TMoreOptions>;
|
|
598
|
+
type PluginHooks<TData$1 = never, TErrorData$1 = never, TMoreOptions = unknown> = HooksOrHooksArray<TData$1, TErrorData$1, TMoreOptions>;
|
|
471
599
|
interface CallApiPlugin {
|
|
472
600
|
/**
|
|
473
601
|
* Defines additional options that can be passed to callApi
|
|
@@ -507,74 +635,22 @@ interface CallApiPlugin {
|
|
|
507
635
|
version?: string;
|
|
508
636
|
}
|
|
509
637
|
//#endregion
|
|
510
|
-
//#region src/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
//#endregion
|
|
515
|
-
//#region src/result.d.ts
|
|
516
|
-
type Parser<TData> = (responseString: string) => Awaitable<TData>;
|
|
517
|
-
declare const getResponseType: <TResponse>(response: Response, parser: Parser<TResponse>) => {
|
|
518
|
-
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
519
|
-
blob: () => Promise<Blob>;
|
|
520
|
-
formData: () => Promise<FormData>;
|
|
521
|
-
json: () => Promise<TResponse>;
|
|
522
|
-
stream: () => ReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
523
|
-
text: () => Promise<string>;
|
|
524
|
-
};
|
|
525
|
-
type InitResponseTypeMap<TResponse$1 = unknown> = ReturnType<typeof getResponseType<TResponse$1>>;
|
|
526
|
-
type ResponseTypeUnion = keyof InitResponseTypeMap | null;
|
|
527
|
-
type ResponseTypeMap<TResponse$1> = { [Key in keyof InitResponseTypeMap<TResponse$1>]: Awaited<ReturnType<InitResponseTypeMap<TResponse$1>[Key]>> };
|
|
528
|
-
type GetResponseType<TResponse$1, TResponseType extends ResponseTypeUnion, TComputedResponseTypeMap extends ResponseTypeMap<TResponse$1> = ResponseTypeMap<TResponse$1>> = null extends TResponseType ? TComputedResponseTypeMap["json"] : TResponseType extends NonNullable<ResponseTypeUnion> ? TComputedResponseTypeMap[TResponseType] : never;
|
|
529
|
-
type CallApiResultSuccessVariant<TData> = {
|
|
530
|
-
data: NoInfer<TData>;
|
|
531
|
-
error: null;
|
|
532
|
-
response: Response;
|
|
638
|
+
//#region src/utils/external/define.d.ts
|
|
639
|
+
declare const defineSchema: <const TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, const TSchemaConfig extends CallApiSchemaConfig>(routes: TBaseSchemaRoutes, config?: MatchExactObjectType<TSchemaConfig, CallApiSchemaConfig>) => {
|
|
640
|
+
config: NonNullable<Writeable<typeof config, "deep">>;
|
|
641
|
+
routes: Writeable<typeof routes, "deep">;
|
|
533
642
|
};
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}>;
|
|
546
|
-
type PossibleValidationError = UnmaskType<{
|
|
547
|
-
errorData: ValidationError["errorData"];
|
|
548
|
-
issueCause: ValidationError["issueCause"];
|
|
549
|
-
message: string;
|
|
550
|
-
name: "ValidationError";
|
|
551
|
-
originalError: ValidationError;
|
|
552
|
-
}>;
|
|
553
|
-
type PossibleJavaScriptOrValidationError = UnmaskType<PossibleJavaScriptError | PossibleValidationError>;
|
|
554
|
-
type CallApiResultErrorVariant<TErrorData> = {
|
|
555
|
-
data: null;
|
|
556
|
-
error: PossibleHTTPError<TErrorData>;
|
|
557
|
-
response: Response;
|
|
558
|
-
} | {
|
|
559
|
-
data: null;
|
|
560
|
-
error: PossibleJavaScriptOrValidationError;
|
|
561
|
-
response: Response | null;
|
|
562
|
-
};
|
|
563
|
-
type CallApiSuccessOrErrorVariant<TData, TError> = CallApiResultErrorVariant<TError> | CallApiResultSuccessVariant<TData>;
|
|
564
|
-
type ResultModeMapWithoutException<TData, TErrorData, TResponseType extends ResponseTypeUnion, TComputedData = GetResponseType<TData, TResponseType>, TComputedErrorData = GetResponseType<TErrorData, TResponseType>, TComputedResult extends CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData> = CallApiSuccessOrErrorVariant<TComputedData, TComputedErrorData>> = UnmaskType<{
|
|
565
|
-
all: TComputedResult;
|
|
566
|
-
onlyData: TComputedResult["data"];
|
|
567
|
-
onlyResponse: TComputedResult["response"];
|
|
568
|
-
}>;
|
|
569
|
-
type ResultModeMapWithException<TData, TResponseType extends ResponseTypeUnion, TComputedData = GetResponseType<TData, TResponseType>, TComputedResult extends CallApiResultSuccessVariant<TComputedData> = CallApiResultSuccessVariant<TComputedData>> = {
|
|
570
|
-
all: TComputedResult;
|
|
571
|
-
onlyData: TComputedResult["data"];
|
|
572
|
-
onlyResponse: TComputedResult["response"];
|
|
573
|
-
};
|
|
574
|
-
type ResultModeMap<TData = DefaultDataType, TErrorData = DefaultDataType, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError> = TThrowOnError extends true ? ResultModeMapWithException<TData, TResponseType> : ResultModeMapWithoutException<TData, TErrorData, TResponseType>;
|
|
575
|
-
type ResultModePlaceholder = null;
|
|
576
|
-
type ResultModeUnion = keyof ResultModeMap | ResultModePlaceholder;
|
|
577
|
-
type GetCallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion, TComputedResultModeMapWithException extends ResultModeMapWithException<TData, TResponseType> = ResultModeMapWithException<TData, TResponseType>, TComputedResultModeMap extends ResultModeMap<TData, TErrorData, TResponseType, TThrowOnError> = ResultModeMap<TData, TErrorData, TResponseType, TThrowOnError>> = TErrorData extends false ? TComputedResultModeMapWithException["onlyData"] : TErrorData extends false | undefined ? TComputedResultModeMapWithException["onlyData"] : ResultModePlaceholder extends TResultMode ? TComputedResultModeMap["all"] : TResultMode extends Exclude<ResultModeUnion, ResultModePlaceholder> ? TComputedResultModeMap[TResultMode] : never;
|
|
643
|
+
declare const defineSchemaRoutes: <const TSchemaRoutes extends CallApiSchema>(routes: MatchExactObjectType<TSchemaRoutes, CallApiSchema>) => Writeable<typeof routes, "deep">;
|
|
644
|
+
declare const defineSchemaConfig: <const TSchemaConfig extends CallApiSchemaConfig>(config: MatchExactObjectType<TSchemaConfig, CallApiSchemaConfig>) => Writeable<typeof config, "deep">;
|
|
645
|
+
declare const definePlugin: <const TPlugin extends CallApiPlugin>(plugin: TPlugin) => Writeable<typeof plugin, "deep">;
|
|
646
|
+
declare const defineBaseConfig: <const TBaseConfig extends BaseCallApiConfig>(baseConfig: TBaseConfig) => Writeable<typeof baseConfig, "deep">;
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/utils/external/guards.d.ts
|
|
649
|
+
declare const isHTTPError: <TErrorData>(error: CallApiResultErrorVariant<TErrorData>["error"] | null) => error is PossibleHTTPError<TErrorData>;
|
|
650
|
+
declare const isHTTPErrorInstance: <TErrorData>(error: unknown) => error is HTTPError<TErrorData>;
|
|
651
|
+
declare const isValidationError: (error: CallApiResultErrorVariant<unknown>["error"] | null) => error is PossibleValidationError;
|
|
652
|
+
declare const isValidationErrorInstance: (error: unknown) => error is ValidationError;
|
|
653
|
+
declare const isJavascriptError: (error: CallApiResultErrorVariant<unknown>["error"] | null) => error is PossibleJavaScriptError;
|
|
578
654
|
//#endregion
|
|
579
655
|
//#region src/stream.d.ts
|
|
580
656
|
type StreamProgressEvent = {
|
|
@@ -606,7 +682,7 @@ type PluginExtraOptions<TPluginOptions = unknown> = {
|
|
|
606
682
|
/** Plugin-specific options passed to the plugin configuration */
|
|
607
683
|
options: Partial<TPluginOptions>;
|
|
608
684
|
};
|
|
609
|
-
interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOptions = unknown> {
|
|
685
|
+
interface Hooks<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TPluginOptions = unknown> {
|
|
610
686
|
/**
|
|
611
687
|
* Hook called when any error occurs within the request/response lifecycle.
|
|
612
688
|
*
|
|
@@ -617,7 +693,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
617
693
|
* @param context - Error context containing error details, request info, and response (if available)
|
|
618
694
|
* @returns Promise or void - Hook can be async or sync
|
|
619
695
|
*/
|
|
620
|
-
onError?: (context: ErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
696
|
+
onError?: (context: ErrorContext<TErrorData$1> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
621
697
|
/**
|
|
622
698
|
* Hook called before the HTTP request is sent and before any internal processing of the request object begins.
|
|
623
699
|
*
|
|
@@ -669,7 +745,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
669
745
|
* @returns Promise or void - Hook can be async or sync
|
|
670
746
|
*
|
|
671
747
|
*/
|
|
672
|
-
onResponse?: (context: ResponseContext<TData, TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
748
|
+
onResponse?: (context: ResponseContext<TData$1, TErrorData$1> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
673
749
|
/**
|
|
674
750
|
* Hook called when an HTTP error response (4xx, 5xx) is received from the API.
|
|
675
751
|
*
|
|
@@ -680,7 +756,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
680
756
|
* @param context - Response error context with HTTP error details and response
|
|
681
757
|
* @returns Promise or void - Hook can be async or sync
|
|
682
758
|
*/
|
|
683
|
-
onResponseError?: (context: ResponseErrorContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
759
|
+
onResponseError?: (context: ResponseErrorContext<TErrorData$1> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
684
760
|
/**
|
|
685
761
|
* Hook called during download stream progress tracking.
|
|
686
762
|
*
|
|
@@ -704,7 +780,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
704
780
|
* @returns Promise or void - Hook can be async or sync
|
|
705
781
|
*
|
|
706
782
|
*/
|
|
707
|
-
onRetry?: (response: RetryContext<TErrorData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
783
|
+
onRetry?: (response: RetryContext<TErrorData$1> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
708
784
|
/**
|
|
709
785
|
* Hook called when a successful response (2xx status) is received from the API.
|
|
710
786
|
*
|
|
@@ -716,7 +792,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
716
792
|
* @returns Promise or void - Hook can be async or sync
|
|
717
793
|
*
|
|
718
794
|
*/
|
|
719
|
-
onSuccess?: (context: SuccessContext<TData> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
795
|
+
onSuccess?: (context: SuccessContext<TData$1> & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
720
796
|
/**
|
|
721
797
|
* Hook called when a validation error occurs.
|
|
722
798
|
*
|
|
@@ -730,7 +806,7 @@ interface Hooks<TData = DefaultDataType, TErrorData = DefaultDataType, TPluginOp
|
|
|
730
806
|
*/
|
|
731
807
|
onValidationError?: (context: ValidationErrorContext & PluginExtraOptions<TPluginOptions>) => Awaitable<unknown>;
|
|
732
808
|
}
|
|
733
|
-
type HooksOrHooksArray<TData = DefaultDataType, TErrorData = DefaultDataType, TMoreOptions = unknown> = { [Key in keyof Hooks<TData, TErrorData, TMoreOptions>]: Hooks<TData, TErrorData, TMoreOptions>[Key] | Array<Hooks<TData, TErrorData, TMoreOptions>[Key]> };
|
|
809
|
+
type HooksOrHooksArray<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TMoreOptions = unknown> = { [Key in keyof Hooks<TData$1, TErrorData$1, TMoreOptions>]: Hooks<TData$1, TErrorData$1, TMoreOptions>[Key] | Array<Hooks<TData$1, TErrorData$1, TMoreOptions>[Key]> };
|
|
734
810
|
interface HookConfigOptions {
|
|
735
811
|
/**
|
|
736
812
|
* Controls the execution mode of all composed hooks (main + plugin hooks).
|
|
@@ -821,14 +897,14 @@ type ValidationErrorContext = UnmaskType<RequestContext & {
|
|
|
821
897
|
/** HTTP response object if validation failed on response, null if on request */
|
|
822
898
|
response: Response | null;
|
|
823
899
|
}>;
|
|
824
|
-
type SuccessContext<TData> = UnmaskType<RequestContext & {
|
|
900
|
+
type SuccessContext<TData$1> = UnmaskType<RequestContext & {
|
|
825
901
|
/** Parsed response data with the expected success type */
|
|
826
|
-
data: TData;
|
|
902
|
+
data: TData$1;
|
|
827
903
|
/** HTTP response object for the successful request */
|
|
828
904
|
response: Response;
|
|
829
905
|
}>;
|
|
830
|
-
type ResponseContext<TData, TErrorData> = UnmaskType<RequestContext & (Prettify<CallApiResultSuccessVariant<TData>> | Prettify<Extract<CallApiResultErrorVariant<TErrorData>, {
|
|
831
|
-
error: PossibleHTTPError<TErrorData>;
|
|
906
|
+
type ResponseContext<TData$1, TErrorData$1> = UnmaskType<RequestContext & (Prettify<CallApiResultSuccessVariant<TData$1>> | Prettify<Extract<CallApiResultErrorVariant<TErrorData$1>, {
|
|
907
|
+
error: PossibleHTTPError<TErrorData$1>;
|
|
832
908
|
}>>)>;
|
|
833
909
|
type RequestErrorContext = RequestContext & {
|
|
834
910
|
/** Error that occurred during the request (network, timeout, etc.) */
|
|
@@ -836,9 +912,9 @@ type RequestErrorContext = RequestContext & {
|
|
|
836
912
|
/** Always null for request errors since no response was received */
|
|
837
913
|
response: null;
|
|
838
914
|
};
|
|
839
|
-
type ErrorContext<TErrorData> = UnmaskType<RequestContext & ({
|
|
915
|
+
type ErrorContext<TErrorData$1> = UnmaskType<RequestContext & ({
|
|
840
916
|
/** HTTP error with response data */
|
|
841
|
-
error: PossibleHTTPError<TErrorData>;
|
|
917
|
+
error: PossibleHTTPError<TErrorData$1>;
|
|
842
918
|
/** HTTP response object containing error status */
|
|
843
919
|
response: Response;
|
|
844
920
|
} | {
|
|
@@ -847,10 +923,10 @@ type ErrorContext<TErrorData> = UnmaskType<RequestContext & ({
|
|
|
847
923
|
/** Response object if available, null for request errors */
|
|
848
924
|
response: Response | null;
|
|
849
925
|
})>;
|
|
850
|
-
type ResponseErrorContext<TErrorData> = UnmaskType<Extract<ErrorContext<TErrorData>, {
|
|
851
|
-
error: PossibleHTTPError<TErrorData>;
|
|
926
|
+
type ResponseErrorContext<TErrorData$1> = UnmaskType<Extract<ErrorContext<TErrorData$1>, {
|
|
927
|
+
error: PossibleHTTPError<TErrorData$1>;
|
|
852
928
|
}> & RequestContext>;
|
|
853
|
-
type RetryContext<TErrorData> = UnmaskType<ErrorContext<TErrorData> & {
|
|
929
|
+
type RetryContext<TErrorData$1> = UnmaskType<ErrorContext<TErrorData$1> & {
|
|
854
930
|
/** Current retry attempt number (1-based, so 1 = first retry) */
|
|
855
931
|
retryAttemptCount: number;
|
|
856
932
|
}>;
|
|
@@ -1095,10 +1171,10 @@ declare const defaultRetryStatusCodesLookup: () => Readonly<{
|
|
|
1095
1171
|
504: "Gateway Timeout";
|
|
1096
1172
|
}>;
|
|
1097
1173
|
type RetryStatusCodes = UnmaskType<AnyNumber | keyof ReturnType<typeof defaultRetryStatusCodesLookup>>;
|
|
1098
|
-
type RetryCondition<TErrorData> = (context: ErrorContext<TErrorData>) => Awaitable<boolean>;
|
|
1099
|
-
type RetryOptionKeys<TErrorData> = Exclude<keyof RetryOptions<TErrorData>, "~retryAttemptCount" | "retry">;
|
|
1100
|
-
type InnerRetryOptions<TErrorData> = { [Key in RetryOptionKeys<TErrorData> as RemovePrefix<"retry", Key>]?: RetryOptions<TErrorData>[Key] };
|
|
1101
|
-
interface RetryOptions<TErrorData> {
|
|
1174
|
+
type RetryCondition<TErrorData$1> = (context: ErrorContext<TErrorData$1>) => Awaitable<boolean>;
|
|
1175
|
+
type RetryOptionKeys<TErrorData$1> = Exclude<keyof RetryOptions<TErrorData$1>, "~retryAttemptCount" | "retry">;
|
|
1176
|
+
type InnerRetryOptions<TErrorData$1> = { [Key in RetryOptionKeys<TErrorData$1> as RemovePrefix<"retry", Key>]?: RetryOptions<TErrorData$1>[Key] };
|
|
1177
|
+
interface RetryOptions<TErrorData$1> {
|
|
1102
1178
|
/**
|
|
1103
1179
|
* Keeps track of the number of times the request has already been retried
|
|
1104
1180
|
* @internal
|
|
@@ -1108,7 +1184,7 @@ interface RetryOptions<TErrorData> {
|
|
|
1108
1184
|
/**
|
|
1109
1185
|
* All retry options in a single object instead of separate properties
|
|
1110
1186
|
*/
|
|
1111
|
-
retry?: InnerRetryOptions<TErrorData>;
|
|
1187
|
+
retry?: InnerRetryOptions<TErrorData$1>;
|
|
1112
1188
|
/**
|
|
1113
1189
|
* Number of allowed retry attempts on HTTP errors
|
|
1114
1190
|
* @default 0
|
|
@@ -1117,7 +1193,7 @@ interface RetryOptions<TErrorData> {
|
|
|
1117
1193
|
/**
|
|
1118
1194
|
* Callback whose return value determines if a request should be retried or not
|
|
1119
1195
|
*/
|
|
1120
|
-
retryCondition?: RetryCondition<TErrorData>;
|
|
1196
|
+
retryCondition?: RetryCondition<TErrorData$1>;
|
|
1121
1197
|
/**
|
|
1122
1198
|
* Delay between retries in milliseconds
|
|
1123
1199
|
* @default 1000
|
|
@@ -1149,15 +1225,15 @@ interface RetryOptions<TErrorData> {
|
|
|
1149
1225
|
* @description Makes a type partial if the output type of TSchema is not provided or has undefined in the union, otherwise makes it required
|
|
1150
1226
|
*/
|
|
1151
1227
|
type MakeSchemaOptionRequiredIfDefined<TSchemaOption extends CallApiSchema[keyof CallApiSchema], TObject> = undefined extends InferSchemaInputResult<TSchemaOption, undefined> ? TObject : Required<TObject>;
|
|
1152
|
-
type ApplyURLBasedConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["prefix"] extends string ? `${TSchemaConfig["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig["baseURL"] extends string ? `${TSchemaConfig["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
|
|
1153
|
-
type ApplyStrictConfig<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig["strict"] extends true ? TSchemaRouteKeys :
|
|
1228
|
+
type ApplyURLBasedConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["prefix"] extends string ? `${TSchemaConfig$1["prefix"]}${TSchemaRouteKeys}` : TSchemaConfig$1["baseURL"] extends string ? `${TSchemaConfig$1["baseURL"]}${TSchemaRouteKeys}` : TSchemaRouteKeys;
|
|
1229
|
+
type ApplyStrictConfig<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = TSchemaConfig$1["strict"] extends true ? TSchemaRouteKeys :
|
|
1154
1230
|
// eslint-disable-next-line perfectionist/sort-union-types -- Don't sort union types
|
|
1155
1231
|
TSchemaRouteKeys | Exclude<InitURLOrURLObject, RouteKeyMethodsURLUnion>;
|
|
1156
|
-
type ApplySchemaConfiguration<TSchemaConfig extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig, ApplyURLBasedConfig<TSchemaConfig, TSchemaRouteKeys>>;
|
|
1157
|
-
type InferAllRouteKeys<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig, Exclude<Extract<keyof TBaseSchemaRoutes, string>, FallBackRouteSchemaKey>>;
|
|
1158
|
-
type InferInitURL<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TSchemaConfig extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes, TSchemaConfig>;
|
|
1159
|
-
type GetCurrentRouteSchemaKey<TSchemaConfig extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig["baseURL"] extends string ? TPath extends `${TSchemaConfig["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : TPath extends `${TSchemaConfig["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : string : TPath;
|
|
1160
|
-
type GetCurrentRouteSchema<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
|
|
1232
|
+
type ApplySchemaConfiguration<TSchemaConfig$1 extends CallApiSchemaConfig, TSchemaRouteKeys extends string> = ApplyStrictConfig<TSchemaConfig$1, ApplyURLBasedConfig<TSchemaConfig$1, TSchemaRouteKeys>>;
|
|
1233
|
+
type InferAllRouteKeys<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TSchemaConfig$1 extends CallApiSchemaConfig> = ApplySchemaConfiguration<TSchemaConfig$1, Exclude<Extract<keyof TBaseSchemaRoutes$1, string>, FallBackRouteSchemaKey>>;
|
|
1234
|
+
type InferInitURL<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TSchemaConfig$1 extends CallApiSchemaConfig> = keyof TBaseSchemaRoutes$1 extends never ? InitURLOrURLObject : InferAllRouteKeys<TBaseSchemaRoutes$1, TSchemaConfig$1>;
|
|
1235
|
+
type GetCurrentRouteSchemaKey<TSchemaConfig$1 extends CallApiSchemaConfig, TPath> = TPath extends URL ? string : TSchemaConfig$1["baseURL"] extends string ? TPath extends `${TSchemaConfig$1["baseURL"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : TPath extends `${TSchemaConfig$1["prefix"]}${infer TCurrentRoute}` ? TCurrentRoute extends string ? TCurrentRoute : string : string : TPath;
|
|
1236
|
+
type GetCurrentRouteSchema<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TComputedFallBackRouteSchema = TBaseSchemaRoutes$1[FallBackRouteSchemaKey], TComputedCurrentRouteSchema = TBaseSchemaRoutes$1[TCurrentRouteSchemaKey], TComputedRouteSchema extends CallApiSchema = NonNullable<Omit<TComputedFallBackRouteSchema, keyof TComputedCurrentRouteSchema> & TComputedCurrentRouteSchema>> = TComputedRouteSchema extends CallApiSchema ? Writeable<TComputedRouteSchema, "deep"> : CallApiSchema;
|
|
1161
1237
|
type JsonPrimitive = boolean | number | string | null | undefined;
|
|
1162
1238
|
type SerializableObject = Record<keyof object, unknown>;
|
|
1163
1239
|
type SerializableArray = Array<JsonPrimitive | SerializableArray | SerializableObject> | ReadonlyArray<JsonPrimitive | SerializableArray | SerializableObject>;
|
|
@@ -1231,30 +1307,30 @@ type ExtractRouteParamNames<TCurrentRoute$1, TParamNamesAccumulator extends Stri
|
|
|
1231
1307
|
type ConvertParamNamesToRecord<TParamNames extends StringTuple> = Prettify<TParamNames extends (readonly [infer TFirstParamName extends string, ...infer TRemainingParamNames extends StringTuple]) ? Record<TFirstParamName, AllowedQueryParamValues> & ConvertParamNamesToRecord<TRemainingParamNames> : NonNullable<unknown>>;
|
|
1232
1308
|
type ConvertParamNamesToTuple<TParamNames extends StringTuple> = TParamNames extends readonly [string, ...infer TRemainingParamNames extends StringTuple] ? [AllowedQueryParamValues, ...ConvertParamNamesToTuple<TRemainingParamNames>] : [];
|
|
1233
1309
|
type InferParamsFromRoute<TCurrentRoute$1> = ExtractRouteParamNames<TCurrentRoute$1> extends StringTuple ? ExtractRouteParamNames<TCurrentRoute$1> extends EmptyTuple ? Params : ConvertParamNamesToRecord<ExtractRouteParamNames<TCurrentRoute$1>> | ConvertParamNamesToTuple<ExtractRouteParamNames<TCurrentRoute$1>> : Params;
|
|
1234
|
-
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes, TCurrentRouteSchemaKey> ? undefined extends InferSchemaInputResult<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
1235
|
-
type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes, TCurrentRouteSchemaKey, {
|
|
1310
|
+
type MakeParamsOptionRequired<TParamsSchemaOption extends CallApiSchema["params"], TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string, TObject> = MakeSchemaOptionRequiredIfDefined<TParamsSchemaOption, Params extends InferParamsFromRoute<TCurrentRouteSchemaKey> ? TObject : TCurrentRouteSchemaKey extends Extract<keyof TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> ? undefined extends InferSchemaInputResult<TParamsSchemaOption, null> ? TObject : Required<TObject> : TObject>;
|
|
1311
|
+
type InferParamsOption<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = MakeParamsOptionRequired<TSchema$1["params"], TBaseSchemaRoutes$1, TCurrentRouteSchemaKey, {
|
|
1236
1312
|
/**
|
|
1237
1313
|
* Parameters to be appended to the URL (i.e: /:id)
|
|
1238
1314
|
*/
|
|
1239
1315
|
params?: InferSchemaInputResult<TSchema$1["params"], InferParamsFromRoute<TCurrentRouteSchemaKey>>;
|
|
1240
1316
|
}>;
|
|
1241
|
-
type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = InferMetaOption<TSchema$1> & InferParamsOption<TSchema$1, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
|
|
1317
|
+
type InferExtraOptions<TSchema$1 extends CallApiSchema, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = InferMetaOption<TSchema$1> & InferParamsOption<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferQueryOption<TSchema$1>;
|
|
1242
1318
|
type InferPluginOptions<TPluginArray extends CallApiPlugin[]> = UnionToIntersection<TPluginArray extends Array<infer TPlugin> ? TPlugin extends CallApiPlugin ? TPlugin["defineExtraOptions"] extends AnyFunction<infer TReturnedSchema> ? InferSchemaOutputResult<TReturnedSchema> : never : never : never>;
|
|
1243
|
-
type ResultModeOption<TErrorData, TResultMode extends ResultModeUnion> = TErrorData extends false ? {
|
|
1319
|
+
type ResultModeOption<TErrorData$1, TResultMode extends ResultModeUnion> = TErrorData$1 extends false ? {
|
|
1244
1320
|
resultMode: "onlyData";
|
|
1245
|
-
} : TErrorData extends false | undefined ? {
|
|
1321
|
+
} : TErrorData$1 extends false | undefined ? {
|
|
1246
1322
|
resultMode?: "onlyData";
|
|
1247
1323
|
} : {
|
|
1248
1324
|
resultMode?: TResultMode;
|
|
1249
1325
|
};
|
|
1250
1326
|
type ThrowOnErrorUnion = boolean;
|
|
1251
|
-
type ThrowOnErrorType<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TThrowOnError | ((context: ErrorContext<TErrorData>) => TThrowOnError);
|
|
1252
|
-
type ThrowOnErrorOption<TErrorData, TThrowOnError extends ThrowOnErrorUnion> = TErrorData extends false ? {
|
|
1327
|
+
type ThrowOnErrorType<TErrorData$1, TThrowOnError extends ThrowOnErrorUnion> = TThrowOnError | ((context: ErrorContext<TErrorData$1>) => TThrowOnError);
|
|
1328
|
+
type ThrowOnErrorOption<TErrorData$1, TThrowOnError extends ThrowOnErrorUnion> = TErrorData$1 extends false ? {
|
|
1253
1329
|
throwOnError: true;
|
|
1254
|
-
} : TErrorData extends false | undefined ? {
|
|
1330
|
+
} : TErrorData$1 extends false | undefined ? {
|
|
1255
1331
|
throwOnError?: true;
|
|
1256
1332
|
} : {
|
|
1257
|
-
throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
|
|
1333
|
+
throwOnError?: ThrowOnErrorType<TErrorData$1, TThrowOnError>;
|
|
1258
1334
|
};
|
|
1259
1335
|
//#endregion
|
|
1260
1336
|
//#region src/types/common.d.ts
|
|
@@ -1280,7 +1356,7 @@ type CallApiRequestOptions = Prettify<{
|
|
|
1280
1356
|
type CallApiRequestOptionsForHooks = Omit<CallApiRequestOptions, "headers"> & {
|
|
1281
1357
|
headers: Record<string, string | undefined>;
|
|
1282
1358
|
};
|
|
1283
|
-
type SharedExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = DedupeOptions & HookConfigOptions & HooksOrHooksArray<TData, TErrorData, Partial<InferPluginOptions<TPluginArray>>> & Middlewares & Partial<InferPluginOptions<TPluginArray>> & ResultModeOption<TErrorData, TResultMode> & RetryOptions<TErrorData> & ThrowOnErrorOption<TErrorData, TThrowOnError> & URLOptions & {
|
|
1359
|
+
type SharedExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = DedupeOptions & HookConfigOptions & HooksOrHooksArray<TData$1, TErrorData$1, Partial<InferPluginOptions<TPluginArray>>> & Middlewares & Partial<InferPluginOptions<TPluginArray>> & ResultModeOption<TErrorData$1, TResultMode> & RetryOptions<TErrorData$1> & ThrowOnErrorOption<TErrorData$1, TThrowOnError> & URLOptions & {
|
|
1284
1360
|
/**
|
|
1285
1361
|
* Automatically add an Authorization header value.
|
|
1286
1362
|
*
|
|
@@ -1402,7 +1478,7 @@ type SharedExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, T
|
|
|
1402
1478
|
* }
|
|
1403
1479
|
* ```
|
|
1404
1480
|
*/
|
|
1405
|
-
defaultHTTPErrorMessage?: string | ((context: Pick<HTTPError<TErrorData>, "errorData" | "response">) => string);
|
|
1481
|
+
defaultHTTPErrorMessage?: string | ((context: Pick<HTTPError<TErrorData$1>, "errorData" | "response">) => string);
|
|
1406
1482
|
/**
|
|
1407
1483
|
* Forces calculation of total byte size from request/response body streams.
|
|
1408
1484
|
*
|
|
@@ -1493,7 +1569,7 @@ type SharedExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, T
|
|
|
1493
1569
|
*
|
|
1494
1570
|
* ```
|
|
1495
1571
|
*/
|
|
1496
|
-
responseParser?: (responseString: string) => Awaitable<TData>;
|
|
1572
|
+
responseParser?: (responseString: string) => Awaitable<TData$1>;
|
|
1497
1573
|
/**
|
|
1498
1574
|
* Expected response type, determines how the response body is parsed.
|
|
1499
1575
|
*
|
|
@@ -1628,7 +1704,7 @@ type SharedExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, T
|
|
|
1628
1704
|
* }
|
|
1629
1705
|
* ```
|
|
1630
1706
|
*/
|
|
1631
|
-
throwOnError?: ThrowOnErrorType<TErrorData, TThrowOnError>;
|
|
1707
|
+
throwOnError?: ThrowOnErrorType<TErrorData$1, TThrowOnError>;
|
|
1632
1708
|
/**
|
|
1633
1709
|
* Request timeout in milliseconds. Request will be aborted if it takes longer.
|
|
1634
1710
|
*
|
|
@@ -1756,9 +1832,9 @@ type BaseCallApiExtraOptions<TBaseData = DefaultDataType, TBaseErrorData = Defau
|
|
|
1756
1832
|
};
|
|
1757
1833
|
type GetBaseSchemaRoutes<TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig> = Writeable<TBaseSchemaAndConfig["routes"], "deep">;
|
|
1758
1834
|
type GetBaseSchemaConfig<TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig> = Writeable<NonNullable<TBaseSchemaAndConfig["config"]>, "deep">;
|
|
1759
|
-
type InferExtendSchemaContext<TBaseSchemaRoutes extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = {
|
|
1760
|
-
baseSchemaRoutes: TBaseSchemaRoutes;
|
|
1761
|
-
currentRouteSchema: GetCurrentRouteSchema<TBaseSchemaRoutes, TCurrentRouteSchemaKey>;
|
|
1835
|
+
type InferExtendSchemaContext<TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes, TCurrentRouteSchemaKey extends string> = {
|
|
1836
|
+
baseSchemaRoutes: TBaseSchemaRoutes$1;
|
|
1837
|
+
currentRouteSchema: GetCurrentRouteSchema<TBaseSchemaRoutes$1, TCurrentRouteSchemaKey>;
|
|
1762
1838
|
};
|
|
1763
1839
|
type InferExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfig> = {
|
|
1764
1840
|
baseSchemaConfig: TBaseSchemaConfig;
|
|
@@ -1766,7 +1842,7 @@ type InferExtendSchemaConfigContext<TBaseSchemaConfig extends CallApiSchemaConfi
|
|
|
1766
1842
|
type InferExtendPluginContext<TBasePluginArray extends CallApiPlugin[]> = {
|
|
1767
1843
|
basePlugins: TBasePluginArray;
|
|
1768
1844
|
};
|
|
1769
|
-
type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string, TComputedPluginContext = InferExtendPluginContext<TBasePluginArray>, TComputedSchemaContext = InferExtendSchemaContext<TBaseSchemaRoutes, TCurrentRouteSchemaKey>, TComputedSchemaConfigContext = InferExtendSchemaConfigContext<TBaseSchemaConfig>> = SharedExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1845
|
+
type CallApiExtraOptions<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TCurrentRouteSchemaKey extends string = string, TComputedPluginContext = InferExtendPluginContext<TBasePluginArray>, TComputedSchemaContext = InferExtendSchemaContext<TBaseSchemaRoutes$1, TCurrentRouteSchemaKey>, TComputedSchemaConfigContext = InferExtendSchemaConfigContext<TBaseSchemaConfig>> = SharedExtraOptions<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TPluginArray> & {
|
|
1770
1846
|
/**
|
|
1771
1847
|
* Array of instance-specific CallApi plugins or a function to configure plugins.
|
|
1772
1848
|
*
|
|
@@ -1792,7 +1868,7 @@ type CallApiExtraOptions<TData = DefaultDataType, TErrorData = DefaultDataType,
|
|
|
1792
1868
|
* Can override base schema configuration or extend it with instance-specific validation rules.
|
|
1793
1869
|
*
|
|
1794
1870
|
*/
|
|
1795
|
-
schemaConfig?: TSchemaConfig | ((context: TComputedSchemaConfigContext) => TSchemaConfig);
|
|
1871
|
+
schemaConfig?: TSchemaConfig$1 | ((context: TComputedSchemaConfigContext) => TSchemaConfig$1);
|
|
1796
1872
|
};
|
|
1797
1873
|
type CallApiExtraOptionsForHooks = Hooks & Omit<CallApiExtraOptions, keyof Hooks>;
|
|
1798
1874
|
type BaseInstanceContext = {
|
|
@@ -1801,9 +1877,9 @@ type BaseInstanceContext = {
|
|
|
1801
1877
|
request: CallApiRequestOptions;
|
|
1802
1878
|
};
|
|
1803
1879
|
type BaseCallApiConfig<TBaseData = DefaultDataType, TBaseErrorData = DefaultDataType, TBaseResultMode extends ResultModeUnion = ResultModeUnion, TBaseThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TBaseResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaAndConfig extends BaseCallApiSchemaAndConfig = BaseCallApiSchemaAndConfig, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TComputedBaseConfig = BaseCallApiExtraOptions<TBaseData, TBaseErrorData, TBaseResultMode, TBaseThrowOnError, TBaseResponseType, TBasePluginArray, TBaseSchemaAndConfig>> = (CallApiRequestOptions & TComputedBaseConfig) | ((context: BaseInstanceContext) => CallApiRequestOptions & TComputedBaseConfig);
|
|
1804
|
-
type CallApiConfig<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema$1, TBaseSchemaRoutes, TCurrentRouteSchemaKey> & InferRequestOptions<TSchema$1, TInitURL> & Omit<CallApiExtraOptions<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes, TSchema$1, TBaseSchemaConfig, TSchemaConfig, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
|
|
1805
|
-
type CallApiParameters<TData = DefaultDataType, TErrorData = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaRoutes extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [initURL: TInitURL, config?: CallApiConfig<TData, TErrorData, TResultMode, TThrowOnError, TResponseType, TBaseSchemaRoutes, TSchema$1, TBaseSchemaConfig, TSchemaConfig, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>];
|
|
1806
|
-
type CallApiResult<TData, TErrorData, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion> = GetCallApiResult<TData, TErrorData, TResultMode, TThrowOnError, TResponseType>;
|
|
1880
|
+
type CallApiConfig<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = InferExtraOptions<TSchema$1, TBaseSchemaRoutes$1, TCurrentRouteSchemaKey> & InferRequestOptions<TSchema$1, TInitURL> & Omit<CallApiExtraOptions<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TBasePluginArray, TPluginArray, TBaseSchemaRoutes$1, TSchema$1, TBaseSchemaConfig, TSchemaConfig$1, TCurrentRouteSchemaKey>, keyof InferExtraOptions<CallApiSchema, BaseCallApiSchemaRoutes, string>> & Omit<CallApiRequestOptions, keyof InferRequestOptions<CallApiSchema, string>>;
|
|
1881
|
+
type CallApiParameters<TData$1 = DefaultDataType, TErrorData$1 = DefaultDataType, TResultMode extends ResultModeUnion = ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion = DefaultThrowOnError, TResponseType extends ResponseTypeUnion = ResponseTypeUnion, TBaseSchemaRoutes$1 extends BaseCallApiSchemaRoutes = BaseCallApiSchemaRoutes, TSchema$1 extends CallApiSchema = CallApiSchema, TBaseSchemaConfig extends CallApiSchemaConfig = CallApiSchemaConfig, TSchemaConfig$1 extends CallApiSchemaConfig = CallApiSchemaConfig, TInitURL extends InitURLOrURLObject = InitURLOrURLObject, TCurrentRouteSchemaKey extends string = string, TBasePluginArray extends CallApiPlugin[] = DefaultPluginArray, TPluginArray extends CallApiPlugin[] = DefaultPluginArray> = [initURL: TInitURL, config?: CallApiConfig<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType, TBaseSchemaRoutes$1, TSchema$1, TBaseSchemaConfig, TSchemaConfig$1, TInitURL, TCurrentRouteSchemaKey, TBasePluginArray, TPluginArray>];
|
|
1882
|
+
type CallApiResult<TData$1, TErrorData$1, TResultMode extends ResultModeUnion, TThrowOnError extends ThrowOnErrorUnion, TResponseType extends ResponseTypeUnion> = GetCallApiResult<TData$1, TErrorData$1, TResultMode, TThrowOnError, TResponseType>;
|
|
1807
1883
|
//#endregion
|
|
1808
|
-
export {
|
|
1809
|
-
//# sourceMappingURL=common-
|
|
1884
|
+
export { GetResponseType as $, RequestStreamContext as A, defineBaseConfig as B, RetryOptions as C, HooksOrHooksArray as D, Hooks as E, isHTTPError as F, CallApiPlugin as G, defineSchema as H, isHTTPErrorInstance as I, PluginSetupContext as J, PluginHooks as K, isJavascriptError as L, ResponseErrorContext as M, ResponseStreamContext as N, PluginExtraOptions as O, SuccessContext as P, GetCallApiResult as Q, isValidationError as R, ThrowOnErrorUnion as S, AnyString as St, ErrorContext as T, defineSchemaConfig as U, definePlugin as V, defineSchemaRoutes as W, CallApiResultSuccessVariant as X, CallApiResultErrorVariant as Y, CallApiSuccessOrErrorVariant as Z, GetCurrentRouteSchema as _, CallApiSchema as _t, CallApiExtraOptions as a, ResponseTypeUnion as at, InferParamsFromRoute as b, fallBackRouteSchemaKey as bt, CallApiRequestOptions as c, HTTPError as ct, GetBaseSchemaConfig as d, DefaultPluginArray as dt, PossibleHTTPError as et, GetBaseSchemaRoutes as f, DefaultThrowOnError as ft, ApplyURLBasedConfig as g, BaseCallApiSchemaRoutes as gt, ApplyStrictConfig as h, BaseCallApiSchemaAndConfig as ht, CallApiConfig as i, ResponseTypeMap as it, ResponseContext as j, RequestContext as k, CallApiRequestOptionsForHooks as l, ValidationError as lt, InferExtendSchemaContext as m, toQueryString as mt, BaseCallApiExtraOptions as n, PossibleJavaScriptOrValidationError as nt, CallApiExtraOptionsForHooks as o, ResultModeMap as ot, InferExtendSchemaConfigContext as p, toFormData as pt, PluginHooksWithMoreOptions as q, BaseInstanceContext as r, PossibleValidationError as rt, CallApiParameters as s, ResultModeUnion as st, BaseCallApiConfig as t, PossibleJavaScriptError as tt, CallApiResult as u, DefaultDataType as ut, GetCurrentRouteSchemaKey as v, CallApiSchemaConfig as vt, DedupeOptions as w, Register as x, URLOptions as xt, InferInitURL as y, InferSchemaOutputResult as yt, isValidationErrorInstance as z };
|
|
1885
|
+
//# sourceMappingURL=common-7RMbhCz1.d.ts.map
|