fix sdk types

This commit is contained in:
Dax Raad
2025-11-14 12:35:44 -05:00
parent 986c60353e
commit 2520780846
4 changed files with 42 additions and 44 deletions

View File

@@ -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>(

View File

@@ -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()),
},
},
},

View File

@@ -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 {

View File

@@ -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