mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 18:26:09 +00:00
142 lines
5.8 KiB
TypeScript
142 lines
5.8 KiB
TypeScript
// Generated by @opencode-ai/httpapi-codegen. Do not edit.
|
|
import { Effect, Schema } from "effect"
|
|
import { Sse } from "effect/unstable/encoding"
|
|
import { HttpClientError } from "effect/unstable/http"
|
|
import { HttpApiClient, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi"
|
|
import { ClientError } from "./client-error"
|
|
|
|
const Endpoint0Success = Schema.String
|
|
|
|
const Endpoint1Query = Schema.Struct({ archived: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Undefined])) })
|
|
|
|
const Endpoint1Success = Schema.Array(Schema.String)
|
|
|
|
const Endpoint2Params = Schema.Struct({ sessionID: Schema.String })
|
|
|
|
const Endpoint2Success = Schema.Struct({ data: Schema.String })
|
|
|
|
class Endpoint2Error0Class extends Schema.TaggedErrorClass<Endpoint2Error0Class>("Missing")("Missing", {
|
|
message: Schema.String,
|
|
}) {}
|
|
const Endpoint2Error0 = Endpoint2Error0Class.annotate({ httpApiStatus: 404 })
|
|
|
|
const Endpoint3Params = Schema.Struct({ sessionID: Schema.String })
|
|
|
|
const Endpoint3Success = Schema.Void.annotate({ httpApiStatus: 204 })
|
|
|
|
const Endpoint4Params = Schema.Struct({ sessionID: Schema.String })
|
|
|
|
const Endpoint4Query = Schema.Struct({ dryRun: Schema.optionalKey(Schema.Union([Schema.Boolean, Schema.Undefined])) })
|
|
|
|
const Endpoint4Headers = Schema.Struct({ traceID: Schema.String })
|
|
|
|
const Endpoint4Payload0 = Schema.Union([
|
|
Schema.Struct({ type: Schema.Literal("local"), command: Schema.Array(Schema.String) }),
|
|
Schema.Struct({ type: Schema.Literal("remote"), url: Schema.String }),
|
|
])
|
|
|
|
const Endpoint4Success = Schema.String
|
|
|
|
export const Group0 = HttpApiGroup.make("session", { topLevel: false })
|
|
.add(HttpApiEndpoint.make("GET")("health", "/session/health", { success: Endpoint0Success }))
|
|
.add(HttpApiEndpoint.make("GET")("list", "/session", { query: Endpoint1Query, success: Endpoint1Success }))
|
|
.add(
|
|
HttpApiEndpoint.make("GET")("get", "/session/:sessionID", {
|
|
params: Endpoint2Params,
|
|
success: Endpoint2Success,
|
|
error: Endpoint2Error0,
|
|
}),
|
|
)
|
|
.add(
|
|
HttpApiEndpoint.make("POST")("interrupt", "/session/:sessionID/interrupt", {
|
|
params: Endpoint3Params,
|
|
success: Endpoint3Success,
|
|
}),
|
|
)
|
|
.add(
|
|
HttpApiEndpoint.make("POST")("configure", "/session/:sessionID/configure", {
|
|
params: Endpoint4Params,
|
|
query: Endpoint4Query,
|
|
headers: Endpoint4Headers,
|
|
payload: Endpoint4Payload0,
|
|
success: Endpoint4Success,
|
|
}),
|
|
)
|
|
|
|
type RawGroup = HttpApiClient.Client.Group<typeof Group0, never, never>
|
|
|
|
const Endpoint0DeclaredError = Schema.Never
|
|
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) => () => raw["health"]({}).pipe(Effect.mapError(mapEndpoint0Error))
|
|
|
|
type Endpoint1Input = { readonly archived?: (typeof Endpoint1Query.Type)["archived"] }
|
|
const Endpoint1DeclaredError = Schema.Never
|
|
const mapEndpoint1Error = (error: unknown) =>
|
|
HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error)
|
|
? new ClientError({ cause: error })
|
|
: Schema.is(Endpoint1DeclaredError)(error)
|
|
? error
|
|
: new ClientError({ cause: error })
|
|
const Endpoint1 = (raw: RawGroup) => (input?: Endpoint1Input) =>
|
|
raw["list"]({ query: { archived: input?.["archived"] } }).pipe(Effect.mapError(mapEndpoint1Error))
|
|
|
|
type Endpoint2Input = { readonly sessionID: (typeof Endpoint2Params.Type)["sessionID"] }
|
|
const Endpoint2DeclaredError = Schema.Union([Endpoint2Error0])
|
|
const mapEndpoint2Error = (error: unknown) =>
|
|
HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error)
|
|
? new ClientError({ cause: error })
|
|
: Schema.is(Endpoint2DeclaredError)(error)
|
|
? error
|
|
: new ClientError({ cause: error })
|
|
const Endpoint2 = (raw: RawGroup) => (input: Endpoint2Input) =>
|
|
raw["get"]({ params: { sessionID: input["sessionID"] } }).pipe(
|
|
Effect.mapError(mapEndpoint2Error),
|
|
Effect.map((value) => value.data),
|
|
)
|
|
|
|
type Endpoint3Input = { readonly sessionID: (typeof Endpoint3Params.Type)["sessionID"] }
|
|
const Endpoint3DeclaredError = Schema.Never
|
|
const mapEndpoint3Error = (error: unknown) =>
|
|
HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error)
|
|
? new ClientError({ cause: error })
|
|
: Schema.is(Endpoint3DeclaredError)(error)
|
|
? error
|
|
: new ClientError({ cause: error })
|
|
const Endpoint3 = (raw: RawGroup) => (input: Endpoint3Input) =>
|
|
raw["interrupt"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapEndpoint3Error))
|
|
|
|
type Endpoint4Request = Parameters<RawGroup["configure"]>[0]
|
|
type Endpoint4Input = {
|
|
readonly sessionID: (typeof Endpoint4Params.Type)["sessionID"]
|
|
readonly dryRun?: (typeof Endpoint4Query.Type)["dryRun"]
|
|
readonly traceID: (typeof Endpoint4Headers.Type)["traceID"]
|
|
readonly payload: typeof Endpoint4Payload0.Type
|
|
}
|
|
const Endpoint4DeclaredError = Schema.Never
|
|
const mapEndpoint4Error = (error: unknown) =>
|
|
HttpClientError.isHttpClientError(error) || Schema.isSchemaError(error) || Sse.Retry.is(error)
|
|
? new ClientError({ cause: error })
|
|
: Schema.is(Endpoint4DeclaredError)(error)
|
|
? error
|
|
: new ClientError({ cause: error })
|
|
const Endpoint4 = (raw: RawGroup) => (input: Endpoint4Input) =>
|
|
raw["configure"]({
|
|
params: { sessionID: input["sessionID"] },
|
|
query: { dryRun: input["dryRun"] },
|
|
headers: { traceID: input["traceID"] },
|
|
payload: input["payload"],
|
|
} as Endpoint4Request).pipe(Effect.mapError(mapEndpoint4Error))
|
|
|
|
export const adaptGroup0 = (raw: RawGroup) => ({
|
|
health: Endpoint0(raw),
|
|
list: Endpoint1(raw),
|
|
get: Endpoint2(raw),
|
|
interrupt: Endpoint3(raw),
|
|
configure: Endpoint4(raw),
|
|
})
|