Repository navigation
Conversation
`@nexus.flatten-in-api fields="..." fill="<field>=<sibling>"` on a field makes the call take the named fields of its record, and copies sibling fields into the others. The Stream create takes the backend of its ref this way, and the ref copies the id.
This was referenced Oct 28, 2026
Owner
Author
|
Duplicate of #85, which has the same commit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
This PR lets
@nexus.flatten-in-apigo on a field, to flatten only some fields of the field's record.record create-stream-request { /// @nexus.name python="id" typescript="id" dotnet="Id" stream-id: string, /// @nexus.flatten-in-api fields="backend" fill="id=stream-id" %ref: option<stream-ref>, }fieldsnames the fields of the record that become parameters of the call, in that order.fill="<field>=<sibling>"sets a field of the record from a sibling field of the request, after the sibling's parameter or source. A sourced sibling runs once, into a local.ref, since its fill always applies.nexgen refuses a flatten on a field whose type isn't a proto-backed record, an unknown field or argument, a
fillwith no=, a required field of the record that the call doesn't give, a promoted field with the name of a sibling, a fill from an omitted field or of another type, a flatten together with a source or an api-omit, and a flatten of a record that flattens all of its fields already.The Stream create takes
idandbackendnow, as inclient.create_stream(Turns, id="s1", backend="redis"), and the ref copies the id. The Workflow create copies the id from its source. A new sample,worker-shutdown, shows the flatten in all four languages. Its request takes the SDK fields of the worker heartbeat, and the heartbeat copies the worker fields of the request.The TypeScript request of an operation now writes
{ id }in place of{ id: id }.It is for review here before it goes upstream. It sits on the upstream stack temporalio#308, temporalio#310, temporalio#311, temporalio#297, temporalio#296, temporalio#303, temporalio#304, temporalio#309, temporalio#318, temporalio#319, temporalio#320, temporalio#321, temporalio#322, temporalio#323, temporalio#324, temporalio#325, whose head is
review/p3-base, and on #77, #79, #81, #83.Why?
The Stream API of the proposal has
client.create_stream(definition, *, id, backend=None, **options). The create request holds the backend in itsref, and the id twice, instream_idand inref.id. A record-level flatten would promote every field ofStreamReffor every request that holds one.The design also had
param=andkeep=, which flatten a parameter of a resource constructor in a handle factory. They move to the factory PR, since only the factory reads them.How did you test it?
A Python test creates a Stream with a backend and checks
ref=StreamRef(id="s1", backend="redis")in the request, andstream_idand the ref on the wire. The Python and TypeScript tests of the Workflow create check that the ref copies the id from the source. A .NET compile check creates a Stream withBackend. Go, Python and TypeScript tests run theworker-shutdowncall and check the heartbeat, and a .NET compile check calls it. A Go test checks a fill from a sourced sibling, a unit test checks the keys of the flatten, and rejection fixtures cover each refusal.cargo validatepasses.