mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-19 08:44:22 +01:00
fix sdk types
This commit is contained in:
@@ -30,22 +30,26 @@ export namespace Bus {
|
||||
}
|
||||
|
||||
export function payloads() {
|
||||
return z.discriminatedUnion(
|
||||
"type",
|
||||
registry
|
||||
.entries()
|
||||
.map(([type, def]) => {
|
||||
return z
|
||||
.object({
|
||||
type: z.literal(type),
|
||||
properties: def.properties,
|
||||
})
|
||||
.meta({
|
||||
ref: "Event" + "." + def.type,
|
||||
})
|
||||
})
|
||||
.toArray() as any,
|
||||
)
|
||||
return z
|
||||
.discriminatedUnion(
|
||||
"type",
|
||||
registry
|
||||
.entries()
|
||||
.map(([type, def]) => {
|
||||
return z
|
||||
.object({
|
||||
type: z.literal(type),
|
||||
properties: def.properties,
|
||||
})
|
||||
.meta({
|
||||
ref: "Event" + "." + def.type,
|
||||
})
|
||||
})
|
||||
.toArray() as any,
|
||||
)
|
||||
.meta({
|
||||
ref: "Event",
|
||||
})
|
||||
}
|
||||
|
||||
export async function publish<Definition extends EventDefinition>(
|
||||
|
||||
@@ -129,9 +129,14 @@ export namespace Server {
|
||||
content: {
|
||||
"text/event-stream": {
|
||||
schema: resolver(
|
||||
Bus.payloads().meta({
|
||||
ref: "Event",
|
||||
}),
|
||||
z
|
||||
.object({
|
||||
directory: z.string(),
|
||||
payload: Bus.payloads(),
|
||||
})
|
||||
.meta({
|
||||
ref: "GlobalEvent",
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -1767,11 +1772,7 @@ export namespace Server {
|
||||
description: "Event stream",
|
||||
content: {
|
||||
"text/event-stream": {
|
||||
schema: resolver(
|
||||
Bus.payloads().meta({
|
||||
ref: "Event",
|
||||
}),
|
||||
),
|
||||
schema: resolver(Bus.payloads()),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import type { Options as ClientOptions, TDataShape, Client } from "./client/index.js"
|
||||
import type {
|
||||
GlobalEventButtData,
|
||||
GlobalEventButtResponses,
|
||||
GlobalEventSubscribeData,
|
||||
GlobalEventSubscribeResponses,
|
||||
ProjectListData,
|
||||
ProjectListResponses,
|
||||
ProjectCurrentData,
|
||||
@@ -145,8 +145,6 @@ import type {
|
||||
AuthSetData,
|
||||
AuthSetResponses,
|
||||
AuthSetErrors,
|
||||
EventSubscribeData,
|
||||
EventSubscribeResponses,
|
||||
} from "./types.gen.js"
|
||||
import { client as _heyApiClient } from "./client.gen.js"
|
||||
|
||||
@@ -181,22 +179,12 @@ class Event extends _HeyApiClient {
|
||||
/**
|
||||
* Get events
|
||||
*/
|
||||
public butt<ThrowOnError extends boolean = false>(options?: Options<GlobalEventButtData, ThrowOnError>) {
|
||||
return (options?.client ?? this._client).get.sse<GlobalEventButtResponses, unknown, ThrowOnError>({
|
||||
public subscribe<ThrowOnError extends boolean = false>(options?: Options<GlobalEventSubscribeData, ThrowOnError>) {
|
||||
return (options?.client ?? this._client).get.sse<GlobalEventSubscribeResponses, unknown, ThrowOnError>({
|
||||
url: "/global/event",
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events
|
||||
*/
|
||||
public subscribe<ThrowOnError extends boolean = false>(options?: Options<EventSubscribeData, ThrowOnError>) {
|
||||
return (options?.client ?? this._client).get.sse<EventSubscribeResponses, unknown, ThrowOnError>({
|
||||
url: "/event",
|
||||
...options,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
class Global extends _HeyApiClient {
|
||||
|
||||
@@ -616,6 +616,11 @@ export type Event =
|
||||
| EventServerConnected
|
||||
| EventFileWatcherUpdated
|
||||
|
||||
export type GlobalEvent = {
|
||||
directory: string
|
||||
payload: Event
|
||||
}
|
||||
|
||||
export type Project = {
|
||||
id: string
|
||||
worktree: string
|
||||
@@ -1373,21 +1378,21 @@ export type WellKnownAuth = {
|
||||
|
||||
export type Auth = OAuth | ApiAuth | WellKnownAuth
|
||||
|
||||
export type GlobalEventButtData = {
|
||||
export type GlobalEventSubscribeData = {
|
||||
body?: never
|
||||
path?: never
|
||||
query?: never
|
||||
url: "/global/event"
|
||||
}
|
||||
|
||||
export type GlobalEventButtResponses = {
|
||||
export type GlobalEventSubscribeResponses = {
|
||||
/**
|
||||
* Event stream
|
||||
*/
|
||||
200: Event
|
||||
200: GlobalEvent
|
||||
}
|
||||
|
||||
export type GlobalEventButtResponse = GlobalEventButtResponses[keyof GlobalEventButtResponses]
|
||||
export type GlobalEventSubscribeResponse = GlobalEventSubscribeResponses[keyof GlobalEventSubscribeResponses]
|
||||
|
||||
export type ProjectListData = {
|
||||
body?: never
|
||||
|
||||
Reference in New Issue
Block a user