{"version":3,"file":"HttpLlmFunctionFetcher.mjs","sources":["../../src/http/HttpLlmFunctionFetcher.ts"],"sourcesContent":["import type { HttpLlm } from \"../HttpLlm\";\nimport type { HttpMigration } from \"../HttpMigration\";\nimport { IHttpMigrateRoute } from \"../structures/IHttpMigrateRoute\";\nimport { IHttpResponse } from \"../structures/IHttpResponse\";\nimport { HttpMigrateRouteFetcher } from \"./HttpMigrateRouteFetcher\";\n\nexport namespace HttpLlmFunctionFetcher {\n  export const execute = (props: HttpLlm.IFetchProps): Promise<unknown> =>\n    HttpMigrateRouteFetcher.execute(getFetchArguments(\"execute\", props));\n\n  export const propagate = (\n    props: HttpLlm.IFetchProps,\n  ): Promise<IHttpResponse> =>\n    HttpMigrateRouteFetcher.propagate(getFetchArguments(\"propagate\", props));\n\n  const getFetchArguments = (\n    from: string,\n    props: HttpLlm.IFetchProps,\n  ): HttpMigration.IFetchProps => {\n    const route: IHttpMigrateRoute = props.function.route();\n    const input: Record<string, any> = props.input;\n    const valid: boolean = typeof input === \"object\" && input !== null;\n    if (valid === false)\n      throw new Error(\n        `Error on HttpLlmFunctionFetcher.${from}(): keyworded arguments must be an object`,\n      );\n    return {\n      connection: props.connection,\n      route,\n      parameters: Object.fromEntries(\n        route.parameters.map((p) => [p.key, input[p.key]] as const),\n      ),\n      query: input.query,\n      body: input.body,\n    };\n  };\n}\n"],"names":["HttpLlmFunctionFetcher","execute","props","HttpMigrateRouteFetcher","getFetchArguments","propagate","from","route","function","input","valid","Error","connection","parameters","Object","fromEntries","map","p","key","query","body"],"mappings":";;AAMM,IAAWA;;CAAjB,SAAiBA;IACFA,uBAAAC,UAAWC,SACtBC,wBAAwBF,QAAQG,kBAAkB,WAAWF;IAElDF,uBAAAK,YACXH,SAEAC,wBAAwBE,UAAUD,kBAAkB,aAAaF;IAEnE,MAAME,oBAAoB,CACxBE,MACAJ;QAEA,MAAMK,QAA2BL,MAAMM,SAASD;QAChD,MAAME,QAA6BP,MAAMO;QACzC,MAAMC,eAAwBD,UAAU,YAAYA,UAAU;QAC9D,IAAIC,UAAU,OACZ,MAAM,IAAIC,MACR,mCAAmCL;QAEvC,OAAO;YACLM,YAAYV,MAAMU;YAClBL;YACAM,YAAYC,OAAOC,YACjBR,MAAMM,WAAWG,IAAKC,KAAM,EAACA,EAAEC,KAAKT,MAAMQ,EAAEC;YAE9CC,OAAOV,MAAMU;YACbC,MAAMX,MAAMW;;;AAGjB,EA9BD,CAAiBpB,2BAAAA,yBAAsB,CAAA;;"}