(schemas: readonly [Schema.Constraint, ...Array<Schema.Constraint>])
| 727 | } |
| 728 | |
| 729 | function schemasToResponse(schemas: readonly [Schema.Constraint, ...Array<Schema.Constraint>]) { |
| 730 | const hasWithHeaders = schemas.some((schema) => |
| 731 | HttpApiSchema.isWithHeaders(schema) || HttpApiSchema.getWithHeadersAnnotation(schema.ast) !== undefined |
| 732 | ) |
| 733 | const codec = hasWithHeaders |
| 734 | ? Schema.Union(schemas.map(toCodecArrayBufferWithHeaders)) |
| 735 | : toCodecArrayBuffer(schemas) |
| 736 | const decode = Schema.decodeEffect(codec) |
| 737 | return (response: HttpClientResponse.HttpClientResponse) => |
| 738 | Effect.flatMap( |
| 739 | response.arrayBuffer, |
| 740 | hasWithHeaders |
| 741 | ? (body) => decode({ body, headers: response.headers }) |
| 742 | : decode |
| 743 | ) |
| 744 | } |
| 745 | |
| 746 | function toCodecArrayBufferWithHeaders(schema: Schema.Constraint): Schema.Top { |
| 747 | const isWithHeaders = HttpApiSchema.isWithHeaders(schema) |
no test coverage detected