(schema: Extract<HttpApiSchema.StreamSchema, { readonly _tag: "StreamSse" }>)
| 984 | } |
| 985 | |
| 986 | function streamEncodedDataSchema(schema: Extract<HttpApiSchema.StreamSchema, { readonly _tag: "StreamSse" }>) { |
| 987 | const data = streamDataAst(schema.events.ast) |
| 988 | const encodedAst = data.encoding?.at(-1)?.to |
| 989 | if (encodedAst === undefined) throw new GenerationError({ reason: "Invalid SSE data schema" }) |
| 990 | const encoded = resolveContentSchema(encodedAst) |
| 991 | if (!SchemaAST.isAST(encoded)) throw new GenerationError({ reason: "Invalid SSE data schema" }) |
| 992 | return Schema.make(encoded) |
| 993 | } |
| 994 | |
| 995 | function streamDataAst(ast: SchemaAST.AST) { |
| 996 | if (!SchemaAST.isObjects(ast)) throw new GenerationError({ reason: "Invalid SSE data schema" }) |
no test coverage detected