import { IConnection } from "./IConnection"; import { IFetchRoute } from "./IFetchRoute"; /** * Utility class for `fetch` functions used in `@nestia/sdk`. * * `PlainFetcher` is a utility class designed for SDK functions generated by * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote * HTTP server API. In other words, this is a collection of dedicated `fetch()` * functions for `@nestia/sdk`. * * For reference, `PlainFetcher` class does not encrypt or decrypt the body data * at all. It just delivers plain data without any post processing. If you've * defined a controller method through `@EncryptedRoute` or `@EncryptedBody` * decorator, then {@link EncryptedFetcher} class would be used instead. * * @author Jeongho Nam - https://github.com/samchon * @evidence contracts/common.md#principled-implementation The codecs preserve transformed bodies, while FetcherBase owns JSON, form and binary handling. Encrypted metadata is refused before transport. The shared pipeline removes caller Content-Type case-insensitively so multipart boundaries remain fetch-owned, normalizes only host/path separator boundaries, and classifies 200, 201 and the route's configured success status. * @evidence contracts/common.md#clear-and-simple-design Two public operations that mirror `EncryptedFetcher`, with the encryption guard as their only own logic. * @evidence contracts/common.md#prohibited-implementation-shortcuts The refusal is the contract with the generated SDK, which chooses `EncryptedFetcher` for encrypted routes; no route or header is special-cased. * @evidence contracts/common.md#meaningful-documentation The namespace prose says when the generated SDK uses this fetcher and that it does no encryption. */ export declare namespace PlainFetcher { /** * Fetch function only for `HEAD` method. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Nothing because of `HEAD` method * @evidence contracts/common.md#principled-implementation The overloads narrow arguments by method; the implementation refuses encryption metadata and delegates to FetcherBase.request. Failed statuses become HttpError with their original text, successful HEAD has no data, and binary successes transfer response.body unchanged or create a synchronously closed empty stream if absent. Stream consumption and cancellation belong to the caller. * @evidence contracts/common.md#clear-and-simple-design One guard and one delegation, with the overloads only splitting the types. * @evidence contracts/common.md#prohibited-implementation-shortcuts The guard follows the route metadata, not a path or a connection. * @evidence contracts/common.md#meaningful-documentation Each overload documents its parameters and return value. */ function fetch(connection: IConnection, route: IFetchRoute<"HEAD">): Promise; /** * Fetch function only for `GET` method. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Response body data from the remote API */ function fetch(connection: IConnection, route: IFetchRoute<"GET">): Promise; /** * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods. * * @param connection Connection information for the remote HTTP server * @param route Route information about the target API * @returns Response body data from the remote API */ function fetch(connection: IConnection, route: IFetchRoute<"POST" | "PUT" | "PATCH" | "DELETE">, input?: Input, stringify?: (input: Input) => string): Promise; /** * Fetch function that returns every response as an {@link IPropagation}. * * An HTTP failure status is returned as a failed branch instead of being * thrown. A route that declares an encrypted body and a transport failure * still throw. The output must describe numeric status branches with boolean * success and string or string-array headers; its data type remains * caller-owned. * * @evidence contracts/common.md#principled-implementation The implementation refuses an encrypted route and delegates to `FetcherBase.propagate`. Its structural branch constraint accepts numeric literal successes, numeric range failures and unknown-status fallback without instantiating a status map with any, while requiring boolean success and actual numeric status/header shapes. * @evidence contracts/common.md#clear-and-simple-design One guard and one delegation, with the overloads only splitting the types. * @evidence contracts/common.md#prohibited-implementation-shortcuts The function adds no status-specific branch: the success flag comes from the status rules in `FetcherBase`. * @evidence contracts/common.md#meaningful-documentation The comment states what the returned union carries and which failures still throw. */ function propagate; data: unknown; }>(connection: IConnection, route: IFetchRoute<"GET" | "HEAD">): Promise; function propagate; data: unknown; }>(connection: IConnection, route: IFetchRoute<"DELETE" | "GET" | "HEAD" | "PATCH" | "POST" | "PUT">, input?: Input, stringify?: (input: Input) => string): Promise; }