{"version":3,"sources":["../src/client.ts"],"sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Action, z } from 'genkit';\nimport {\n  runFlow as baseRunFlow,\n  streamFlow as baseStreamFlow,\n} from 'genkit/beta/client';\n\ntype Input<A extends Action> =\n  A extends Action<infer I extends z.ZodTypeAny, any, any> ? z.infer<I> : never;\ntype Output<A extends Action> =\n  A extends Action<any, infer O extends z.ZodTypeAny, any> ? z.infer<O> : never;\ntype Stream<A extends Action> =\n  A extends Action<any, any, infer S extends z.ZodTypeAny> ? z.infer<S> : never;\ntype InitData<A extends Action> =\n  A extends Action<any, any, any, any, infer Init extends z.ZodTypeAny>\n    ? z.infer<Init>\n    : never;\n\nexport interface RequestData<T, Init = any> {\n  url: string;\n  headers?: Record<string, string>;\n  input?: T;\n  init?: Init;\n  streamId?: string;\n  abortSignal?: AbortSignal;\n}\n\nexport function runFlow<A extends Action = Action>(\n  req: RequestData<Input<A>, InitData<A>>\n): Promise<Output<A>> {\n  return baseRunFlow<Output<A>, InitData<A>>(req);\n}\n\nexport interface StreamResponse<A extends Action> {\n  output: Promise<Output<A>>;\n  stream: AsyncIterable<Stream<A>>;\n  streamId: Promise<string | null>;\n}\n\nexport function streamFlow<A extends Action = Action>(\n  req: RequestData<Input<A>, InitData<A>>\n): StreamResponse<A> {\n  const res = baseStreamFlow<Output<A>, Stream<A>, InitData<A>>(req);\n  return {\n    output: res.output,\n    stream: res.stream,\n    streamId: res.streamId,\n  };\n}\n"],"mappings":"AAiBA;AAAA,EACE,WAAW;AAAA,EACX,cAAc;AAAA,OACT;AAsBA,SAAS,QACd,KACoB;AACpB,SAAO,YAAoC,GAAG;AAChD;AAQO,SAAS,WACd,KACmB;AACnB,QAAM,MAAM,eAAkD,GAAG;AACjE,SAAO;AAAA,IACL,QAAQ,IAAI;AAAA,IACZ,QAAQ,IAAI;AAAA,IACZ,UAAU,IAAI;AAAA,EAChB;AACF;","names":[]}