( successSchema: StreamSuccessSchema, options: SchemaAST.ParseOptions | undefined, headersOptions: SchemaAST.ParseOptions | undefined )
| 1406 | } |
| 1407 | |
| 1408 | function streamToResponse( |
| 1409 | successSchema: StreamSuccessSchema, |
| 1410 | options: SchemaAST.ParseOptions | undefined, |
| 1411 | headersOptions: SchemaAST.ParseOptions | undefined |
| 1412 | ) { |
| 1413 | const isWithHeaders = isWithHeadersStreamSuccess(successSchema) |
| 1414 | const streamSchema = isWithHeaders ? successSchema.schema : successSchema |
| 1415 | const decodeBody = makeStreamBodyDecoder(streamSchema, options) |
| 1416 | const toStream: ResponseDecoder = (response, sseOptions) => |
| 1417 | Effect.map(Effect.context<never>(), (context) => |
| 1418 | Stream.provideContext( |
| 1419 | decodeBody(response, sseOptions), |
| 1420 | context as Context.Context<unknown> |
| 1421 | )) |
| 1422 | if (!isWithHeaders) return toStream |
| 1423 | |
| 1424 | const decodeHeaders = Schema.decodeUnknownEffect(successSchema.headers, headersOptions) |
| 1425 | return (response: HttpClientResponse.HttpClientResponse, sseOptions?: Sse.DecodeOptions) => |
| 1426 | Effect.flatMap( |
| 1427 | decodeHeaders(response.headers), |
| 1428 | (headers) => Effect.map(toStream(response, sseOptions), (body) => HttpApiSchema.withHeaders({ body, headers })) |
| 1429 | ) |
| 1430 | } |
| 1431 | |
| 1432 | function makeStreamBodyDecoder( |
| 1433 | streamSchema: HttpApiSchema.StreamSchema, |
no test coverage detected