Files
opencode/patches/effect@4.0.0-beta.83.patch
Kit Langton 6dbd516466 fix(sdk): type SSE event payloads
Patch Effect OpenAPI generation so data-mode SSE responses expose their JSON payload schema instead of the raw data-line string wrapper. Regenerate legacy SDK types so V2Event and SessionDurableEvent remain the public payload unions.

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
2026-06-27 04:54:23 +00:00

33 lines
1.4 KiB
Diff

diff --git a/dist/unstable/httpapi/OpenApi.js b/dist/unstable/httpapi/OpenApi.js
index 8292ab7..9c4fd5e 100644
--- a/dist/unstable/httpapi/OpenApi.js
+++ b/dist/unstable/httpapi/OpenApi.js
@@ -335,7 +335,7 @@ export function fromApi(api) {
if (HttpApiSchema.isStreamSse(stream)) {
pathOps.push({
_tag: "schema",
- ast: SchemaAST.getAST(stream.events),
+ ast: stream.sseMode === "data" ? streamDataAst(stream.events) : SchemaAST.getAST(stream.events),
path: ["paths", path, method, "responses", String(status), "content", contentType, "schema"]
});
pathOps.push({
@@ -501,6 +501,18 @@ export function fromApi(api) {
return spec;
}
const reservedStreamFailureEvent = "effect/httpapi/stream/failure";
+function streamDataAst(events) {
+ const ast = SchemaAST.getAST(events);
+ if (!SchemaAST.isObjects(ast)) {
+ return ast;
+ }
+ const data = ast.propertySignatures.find(field => field.name === "data")?.type;
+ if (data === undefined) {
+ return ast;
+ }
+ const contentSchema = data.encoding?.at(-1)?.to.annotations?.contentSchema;
+ return SchemaAST.isAST(contentSchema) ? contentSchema : data;
+}
function extractSuccessResponseBodies(endpoint) {
return extractResponseBodies(HttpApiEndpoint.getSuccessSchemas(endpoint), HttpApiSchema.getStatusSuccess, resolveDescriptionOrIdentifier);
}