diff options
| author | Dax Raad <[email protected]> | 2025-05-29 11:32:55 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-29 11:32:55 -0400 |
| commit | 6f604bd0f999a5df4ed6a57aef524f0dcf9eb356 (patch) | |
| tree | efb732ba56257a8f02edea604424821c9b687cf3 /js/src/bus | |
| parent | 42c1cd6a852be5295aedc5c19e1a2aef45a464e3 (diff) | |
| download | opencode-6f604bd0f999a5df4ed6a57aef524f0dcf9eb356.tar.gz opencode-6f604bd0f999a5df4ed6a57aef524f0dcf9eb356.zip | |
remove secondary codegen
Diffstat (limited to 'js/src/bus')
| -rw-r--r-- | js/src/bus/index.ts | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/js/src/bus/index.ts b/js/src/bus/index.ts index 15d2b1107..cf5101b67 100644 --- a/js/src/bus/index.ts +++ b/js/src/bus/index.ts @@ -1,4 +1,4 @@ -import { z, type ZodType } from "zod/v4"; +import { z, type ZodType } from "zod"; import { App } from "../app"; import { Log } from "../util/log"; @@ -30,16 +30,23 @@ export namespace Bus { return result; } - export function specs() { - const children = {} as any; - for (const [type, def] of registry.entries()) { - children["event." + def.type] = def.properties; - } - const result = z.toJSONSchema(z.object(children)) as any; - result.definitions = result.properties; - delete result.properties; - delete result.required; - return result; + export function payloads() { + return z.discriminatedUnion( + "type", + registry + .entries() + .map(([type, def]) => + z + .object({ + type: z.literal(type), + properties: def.properties, + }) + .openapi({ + ref: "Event" + "." + def.type, + }), + ) + .toArray() as any, + ); } export function publish<Definition extends EventDefinition>( |
