{"version":3,"file":"PlainFetcher.mjs","names":[],"sources":["../src/PlainFetcher.ts"],"sourcesContent":["import { IConnection } from \"./IConnection\";\nimport { IFetchRoute } from \"./IFetchRoute\";\nimport { IPropagation } from \"./IPropagation\";\nimport { FetcherBase } from \"./internal/FetcherBase\";\n\n/**\n * Utility class for `fetch` functions used in `@nestia/sdk`.\n *\n * `PlainFetcher` is a utility class designed for SDK functions generated by\n * [`@nestia/sdk`](https://nestia.io/docs/sdk/sdk), interacting with the remote\n * HTTP sever API. In other words, this is a collection of dedicated `fetch()`\n * functions for `@nestia/sdk`.\n *\n * For reference, `PlainFetcher` class does not encrypt or decrypt the body data\n * at all. It just delivers plain data without any post processing. If you've\n * defined a controller method through `@EncryptedRoute` or `@EncryptedBody`\n * decorator, then {@liink EncryptedFetcher} class would be used instead.\n *\n * @author Jeongho Nam - https://github.com/samchon\n */\nexport namespace PlainFetcher {\n  /**\n   * Fetch function only for `HEAD` method.\n   *\n   * @param connection Connection information for the remote HTTP server\n   * @param route Route information about the target API\n   * @returns Nothing because of `HEAD` method\n   */\n  export function fetch(\n    connection: IConnection,\n    route: IFetchRoute<\"HEAD\">,\n  ): Promise<void>;\n\n  /**\n   * Fetch function only for `GET` method.\n   *\n   * @param connection Connection information for the remote HTTP server\n   * @param route Route information about the target API\n   * @returns Response body data from the remote API\n   */\n  export function fetch<Output>(\n    connection: IConnection,\n    route: IFetchRoute<\"GET\">,\n  ): Promise<Output>;\n\n  /**\n   * Fetch function for the `POST`, `PUT`, `PATCH` and `DELETE` methods.\n   *\n   * @param connection Connection information for the remote HTTP server\n   * @param route Route information about the target API\n   * @returns Response body data from the remote API\n   */\n  export function fetch<Input, Output>(\n    connection: IConnection,\n    route: IFetchRoute<\"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\">,\n    input?: Input,\n    stringify?: (input: Input) => string,\n  ): Promise<Output>;\n\n  export async function fetch<Input, Output>(\n    connection: IConnection,\n    route: IFetchRoute<\"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\">,\n    input?: Input,\n    stringify?: (input: Input) => string,\n  ): Promise<Output> {\n    if (route.request?.encrypted === true || route.response?.encrypted === true)\n      throw new Error(\n        \"Error on PlainFetcher.fetch(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.\",\n      );\n    return FetcherBase.request({\n      className: \"PlainFetcher\",\n      encode: (input) => input,\n      decode: (input) => input,\n    })(connection, route, input, stringify);\n  }\n\n  export function propagate<Output extends IPropagation<any, any>>(\n    connection: IConnection,\n    route: IFetchRoute<\"GET\" | \"HEAD\">,\n  ): Promise<Output>;\n\n  export function propagate<Input, Output extends IPropagation<any, any>>(\n    connection: IConnection,\n    route: IFetchRoute<\"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\">,\n    input?: Input,\n    stringify?: (input: Input) => string,\n  ): Promise<Output>;\n\n  export async function propagate<Input, Output extends IPropagation<any, any>>(\n    connection: IConnection,\n    route: IFetchRoute<\"DELETE\" | \"GET\" | \"HEAD\" | \"PATCH\" | \"POST\" | \"PUT\">,\n    input?: Input,\n    stringify?: (input: Input) => string,\n  ): Promise<Output> {\n    if (route.request?.encrypted === true || route.response?.encrypted === true)\n      throw new Error(\n        \"Error on PlainFetcher.propagate(): PlainFetcher doesn't have encryption ability. Use EncryptedFetcher instead.\",\n      );\n    return FetcherBase.propagate({\n      className: \"PlainFetcher\",\n      encode: (input) => input,\n      decode: (input) => input,\n    })(connection, route, input, stringify) as Promise<Output>;\n  }\n}\n"],"mappings":";;AAoBO,IAAA;;CAuCE,eAAe,MACpB,YACA,OACA,OACA,WACiB;EACjB,IAAI,MAAM,SAAS,cAAc,QAAQ,MAAM,UAAU,cAAc,MACrE,MAAM,IAAI,MACR,4GACF;EACF,OAAO,YAAY,QAAQ;GACzB,WAAW;GACX,SAAS,UAAU;GACnB,SAAS,UAAU;EACrB,CAAC,CAAC,CAAC,YAAY,OAAO,OAAO,SAAS;CACxC;;CAcO,eAAe,UACpB,YACA,OACA,OACA,WACiB;EACjB,IAAI,MAAM,SAAS,cAAc,QAAQ,MAAM,UAAU,cAAc,MACrE,MAAM,IAAI,MACR,gHACF;EACF,OAAO,YAAY,UAAU;GAC3B,WAAW;GACX,SAAS,UAAU;GACnB,SAAS,UAAU;EACrB,CAAC,CAAC,CAAC,YAAY,OAAO,OAAO,SAAS;CACxC;;GACD,iBAAA,eAAA,CAAA,EAAD"}