Files
SnowLuma/.pnpm-store/v11/files/e3/4ca7018146dfef27e5456d5aa2d647a80c56dc9c64a2f097cd533a94a50fb0e98bee70e02d9488092e9087d443e227d8b4982b65bda3327393c55ceda80a29
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

20 lines
1.6 KiB
Plaintext

import { ClientErrorStatusCode, ContentfulStatusCode, ServerErrorStatusCode } from "../utils/http-status.js";
import { ClientResponse, FilterClientResponseByStatusCode } from "./types.js";
import { DetailedError } from "./fetch-result-please.js";
//#region src/client/utils.d.ts
export declare const mergePath: (base: string, path: string) => string;
export declare const replaceUrlParam: (urlString: string, params: Record<string, string | undefined>) => string;
export declare const buildSearchParams: (query: Record<string, string | string[]>) => URLSearchParams;
export declare const replaceUrlProtocol: (urlString: string, protocol: "ws" | "http") => string;
export declare const removeIndexString: (urlString: string) => string;
export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
/**
* Shortcut to get a consumable response from `hc`'s fetch calls (Response), with types inference.
*
* Smartly parse the response data, throwing a structured error if the response is not `ok`. ({@link DetailedError})
*
* @example const result = await parseResponse(client.posts.$get())
*/
export declare function parseResponse<T extends ClientResponse<any>>(fetchRes: T | Promise<T>): Promise<FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends never ? undefined : FilterClientResponseByStatusCode<T, Exclude<ContentfulStatusCode, ClientErrorStatusCode | ServerErrorStatusCode>> extends ClientResponse<infer RT, infer _, infer RF> ? RF extends 'json' ? RT : RT extends string ? RT : string : undefined>;
//#endregion
export { DetailedError };