MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeSseDecoder

Function makeSseDecoder

packages/effect/src/http-api/HttpApiClient.ts:1481–1496  ·  view source on GitHub ↗
(
  declaration: HttpApiSchema.StreamSse<Sse.EventCodec, Schema.Constraint, unknown>,
  parseOptions: SchemaAST.ParseOptions | undefined
)

Source from the content-addressed store, hash-verified

1479 )
1480
1481function makeSseDecoder(
1482 declaration: HttpApiSchema.StreamSse<Sse.EventCodec, Schema.Constraint, unknown>,
1483 parseOptions: SchemaAST.ParseOptions | undefined
1484) {
1485 const Event = Schema.Union([
1486 Schema.Struct({
1487 id: Schema.optional(Schema.String),
1488 event: Schema.Literal(reservedStreamFailureEvent),
1489 data: Schema.fromJsonString(Schema.toCodecJson(Schema.Cause(declaration.error, Schema.Defect())))
1490 }),
1491 declaration.events
1492 ])
1493 const defaultDecoder = Sse.decodeSchema(Event, undefined, parseOptions)
1494 return (options?: Sse.DecodeOptions) =>
1495 options === undefined ? defaultDecoder : Sse.decodeSchema(Event, options, parseOptions)
1496}
1497
1498function decodeSseStream(
1499 stream: Stream.Stream<Uint8Array, HttpClientError.HttpClientError>,

Callers 1

makeStreamBodyDecoderFunction · 0.85

Calls 2

optionalMethod · 0.80
toCodecJsonMethod · 0.65

Tested by

no test coverage detected