fix(core): preserve event routing semantics

This commit is contained in:
Kit Langton 2026-06-25 12:41:44 -04:00
commit 603b334b7f
13 changed files with 277 additions and 129 deletions

View file

@ -58,6 +58,17 @@ if (sseTypesPatched === sseTypesSource) {
}
await Bun.write(sseTypesPath, sseTypesPatched)
// OpenAPI represents Schema.Never as `not: {}`, which @hey-api currently
// widens to unknown. Preserve impossible optional event fields as never.
const eventTypesPath = "./src/v2/gen/types.gen.ts"
const eventTypesFile = Bun.file(eventTypesPath)
const eventTypesSource = await eventTypesFile.text()
const eventTypesPatched = eventTypesSource.replaceAll(" durable?: unknown", " durable?: never")
if (eventTypesPatched === eventTypesSource) {
throw new Error(`Event never patch did not apply; @hey-api/openapi-ts output may have changed (${eventTypesPath})`)
}
await Bun.write(eventTypesPath, eventTypesPatched)
await $`bun prettier --write src/gen`
await $`bun prettier --write src/v2`
await $`rm -rf dist`