{"version":3,"file":"contentTypeParsers-D1EBkFFY.mjs","names":[],"sources":["../src/unstable-core-do-not-import/http/contentTypeParsers.ts"],"sourcesContent":["import type { ParserZodEsque } from '../parser';\n\n/**\n * A validator tRPC ships for a special input type.\n * @internal\n */\nexport type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {\n  parse: (input: unknown) => TOutput;\n};\n\n// Should be the same possible types as packages/client/src/links/internals/contentTypes.ts isOctetType\n\n/**\n * A `File`. Node 18 has no `File` type, but a `File` is always a `Blob`.\n * @internal\n */\nexport interface FileLike extends Blob {\n  readonly name: string;\n}\n\n/**\n * The binary inputs a client can send with `octetInputParser`.\n * @internal\n */\nexport type OctetInput = Blob | Uint8Array | FileLike;\n\n/**\n * An input validator for binary data, such as a `File` or `Blob`. The\n * resolver gets the input as a `ReadableStream`.\n * @example\n * ```ts\n * t.procedure.input(octetInputParser).mutation(async ({ input }) => {\n *   const bytes = await new Response(input).arrayBuffer();\n *   return { size: bytes.byteLength };\n * });\n * ```\n * @see https://trpc.io/docs/server/non-json-content-types#file-and-other-binary-type-inputs\n */\nexport const octetInputParser: UtilityParser<OctetInput, ReadableStream> = {\n  _input: null as any as OctetInput,\n  _output: null as any as ReadableStream,\n  parse(input) {\n    if (input instanceof ReadableStream) {\n      return input;\n    }\n\n    throw new Error(\n      `Parsed input was expected to be a ReadableStream but was: ${typeof input}`,\n    );\n  },\n};\n"],"mappings":";;;;;;;;;;;;;AAsCA,MAAa,mBAA8D;CACzE,QAAQ;CACR,SAAS;CACT,MAAM,OAAO;EACX,IAAI,iBAAiB,gBACnB,OAAO;EAGT,MAAM,IAAI,MACR,6DAA6D,OAAO,OACtE;CACF;AACF"}