(schema: Schema.Top, name: string)
| 1088 | } |
| 1089 | |
| 1090 | function renderSuccess(schema: Schema.Top, name: string) { |
| 1091 | if (!isStreamSchema(schema)) return { source: addSlot(schema, name)!.name } |
| 1092 | const status = resolveHttpApiStatus(schema.ast) ?? 200 |
| 1093 | const annotate = status === 200 ? "" : `.pipe(HttpApiSchema.status(${status}))` |
| 1094 | if (schema._tag === "StreamUint8Array") { |
| 1095 | return { |
| 1096 | source: `HttpApiSchema.StreamUint8Array({ contentType: ${JSON.stringify(schema.contentType)} })${annotate}`, |
| 1097 | } |
| 1098 | } |
| 1099 | const value = addSlot( |
| 1100 | schema.sseMode === "data" ? streamDataSchema(schema) : schema.events, |
| 1101 | `${name}${schema.sseMode === "data" ? "Data" : "Events"}`, |
| 1102 | )! |
| 1103 | const error = addSlot(schema.error, `${name}Error`)! |
| 1104 | return { |
| 1105 | source: `HttpApiSchema.StreamSse({ ${schema.sseMode}: ${value.name}, error: ${error.name}, contentType: ${JSON.stringify(schema.contentType)} })${annotate}`, |
| 1106 | streamError: error, |
| 1107 | } |
| 1108 | } |
| 1109 | |
| 1110 | const declarations = renderSchemas(slots) |
| 1111 | const groupSource = `HttpApiGroup.make(${JSON.stringify(group.identifier)}, { topLevel: ${group.endpoints[0]?.topLevel ?? false} })${endpointSources.map((endpoint) => `.add(${endpoint})`).join("")}` |
no test coverage detected