Repository navigation
fix(httpapi-codegen): emit flat Promise input field types - #58875
Conversation
There was a problem hiding this comment.
The change looks correct. I ran the new generator test against the base code and it fails, printing the nested ({ … })["field"] form; with this PR it passes. Re-running bun run generate in packages/client reproduces the committed types.ts exactly, and no nested input field types are left (the 33 remaining indexed types are the unwrapped outputs you mention as out of scope). The httpapi-codegen and client tests pass, and tsc is clean for httpapi-codegen, client and sdk.
Public API: the generated *Input types in @opencode/client are written in a flat form instead of (Struct)["field"]. They describe the same shapes, so this is backwards compatible and existing callers don't need to change.
No concerns.
2568327 to
b1eaef8
Compare
There was a problem hiding this comment.
This push is a rebase with the generated client rebuilt; the generator change and its test are unchanged. On the new base, bun run generate in packages/client reproduces the committed types.ts exactly, and no nested input field types are left (the base has 378). The httpapi-codegen and client tests pass, and tsc is clean for httpapi-codegen, client and sdk.
Public API: same as before. The generated *Input types in @opencode/client are written flat and describe the same shapes, so existing callers don't need to change.
No concerns.
Problem
The Promise client generator typed each input field by indexing into its whole source struct, so every params, query, headers and payload field came out nested. Dev already has 372 of these in
packages/client/src/promise/generated/types.ts:Structs with several fields repeated the whole struct once per field, which is why the file shrinks by about 2,500 lines.
Change
I render each field from its own property schema instead of
(Struct)["field"]. Indexing an optional property addsundefined, so for optional fields whose schema leaves it out (for exampleoptionalKey) I add| undefinedto keep the type the same:The types only get flatter. I checked that all 134 generated
*Inputtypes are mutually assignable with the old ones. The Effect client already used this flat form, so its output does not change.I added a generator test with an optional
ArrayEnsurequery field, like the one in #58864. Once that PR is rebased on this, itsEventSubscribeInputcomes out flat too.Out of scope
Unwrapped outputs such as
{ data: SessionInfo }["data"]still use indexed access. That is a separate code path.Added by the opencode bot (AI-generated).
Public API: flattens the generated Promise client
*Inputfield types in @opencode/client; the shapes are the same, so it is backwards compatible