@trpc/server
Version:
1 lines • 1.3 kB
Source Map (JSON)
{"version":3,"file":"contentTypeParsers-KFMy_fwz.mjs","names":[],"sources":["../src/unstable-core-do-not-import/http/contentTypeParsers.ts"],"sourcesContent":["import type { ParserZodEsque } from '../parser';\n\n/**\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 * @internal\n *\n * File is only available from Node19+ but it always extends Blob so we can use that as a type until we eventually drop Node18\n */\nexport interface FileLike extends Blob {\n readonly name: string;\n}\n\n/**\n * @internal\n */\nexport type OctetInput = Blob | Uint8Array | FileLike;\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":";AAyBA,MAAa,mBAA8D;CACzE,QAAQ;CACR,SAAS;CACT,MAAM,OAAO;EACX,IAAI,iBAAiB,gBACnB,OAAO;EAGT,MAAM,IAAI,MACR,6DAA6D,OAAO,OACtE;CACF;AACF"}