Download packages/httpapi-codegen/test/generated/event.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/eb1202c08d0fcc3e89b18b16bcc802e692e97016/packages/httpapi-codegen/test/generated/event.ts
- Command line
-
hf download hf://SaylorTwift/opencode@eb1202c08d0fcc3e89b18b16bcc802e692e97016/packages/httpapi-codegen/test/generated/event.ts
-
curl -L -o event.ts https://huggingface.co/SaylorTwift/opencode/resolve/eb1202c08d0fcc3e89b18b16bcc802e692e97016/packages/httpapi-codegen/test/generated/event.ts
1.54 kB
| // Generated by @opencode-ai/httpapi-codegen. Do not edit. | |
| import { Effect, Schema, Stream } from "effect" | |
| import { Sse } from "effect/unstable/encoding" | |
| import { HttpClientError } from "effect/unstable/http" | |
| import { HttpApiClient, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/unstable/httpapi" | |
| import { ClientError } from "./client-error" | |
| const Endpoint0SuccessData = Schema.Struct({ type: Schema.String }) | |
| const Endpoint0SuccessError = Schema.Never | |
| export const Group1 = HttpApiGroup.make("event", { topLevel: false }).add( | |
| HttpApiEndpoint.make("GET")("subscribe", "/event", { | |
| success: HttpApiSchema.StreamSse({ | |
| data: Endpoint0SuccessData, | |
| error: Endpoint0SuccessError, | |
| contentType: "text/event-stream", | |
| }).pipe(HttpApiSchema.status(202)), | |
| }), | |
| ) | |
| type RawGroup = HttpApiClient.Client.Group<typeof Group1, "event", never, never> | |
| const Endpoint0DeclaredError = Schema.Union([Endpoint0SuccessError]) | |
| const mapEndpoint0Error = (error: unknown) => | |
| HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error) | |
| ? new ClientError({ cause: error }) | |
| : Schema.is(Endpoint0DeclaredError)(error) | |
| ? error | |
| : new ClientError({ cause: error }) | |
| const Endpoint0 = (raw: RawGroup) => () => | |
| Stream.unwrap( | |
| raw["subscribe"]({}).pipe( | |
| Effect.mapError(mapEndpoint0Error), | |
| Effect.map((stream) => stream.pipe(Stream.mapError(mapEndpoint0Error))), | |
| ), | |
| ) | |
| export const adaptGroup1 = (raw: RawGroup) => ({ subscribe: Endpoint0(raw) }) | |