Skip to content

feat: give a field a source or an api-omit for each target - #84

Draft
moetemp wants to merge 1 commit into
moe/up/python-rpc-optionsfrom
moe/up/source-targets
Draft

moetemp wants to merge 1 commit into
moe/up/python-rpc-optionsfrom
moe/up/source-targets

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR lets @nexus.source and @nexus.api-omit name the generation targets that they apply to.

/// @nexus.source targets="workflow" python="workflow_producer()"
/// @nexus.source targets="client" python="client_producer()"
producer: option<producer>,
  • A field takes one @nexus.source for each target, and two sources can't name the same target. @nexus.api-omit targets= leaves the field out of the API of those targets, and it can't share a target with a source.
  • A Workflow source may read the definition argument of an operation that returns a resource with @nexus.definition. A client source can't.
  • nexgen refuses @nexus.api-omit on a required field that isn't a list<T>, also with no target. A TypeScript or .NET call of a target that omits a required list sends the list empty.
  • Python, TypeScript and .NET read the directives of both targets. Go has only the Workflow target, so it reads its directives.
  • The TypeScript model of a request names a sourced field with its @nexus.name, keeps an optional sourced field optional, and gives a proto-backed 64-bit sourced field the Long type.

The stream sample takes these directives, so publish and close don't take the producer, and the client create doesn't take the owner.

Why?

Both targets share the models, so a Workflow helper as a model default fails in client code. A Stream request's context fields differ per context. The producer is the run in a Workflow, the attempt in an Activity, and the client in a client.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

Python tests fill the sources of a Workflow create, a client append and a resource method from fake contexts. The TypeScript and .NET tests check the requests of the client target. Fixtures cover the refused combinations.

@moetemp

moetemp commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Closing. temporalio#344 already lets @nexus.source name its targets. A source that differs per context can use one helper that checks where it runs, with targets="workflow,client". Letting a source read the definition of a create moves to a small PR on temporalio#346 later.

@moetemp moetemp closed this Oct 30, 2026
@moetemp

moetemp commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Reopened. On top of temporalio#346 we may still need three of its rules: the private request methods fill unset sources, a source can read a create's definition, and @nexus.api-omit can name a target. It needs a rework onto temporalio#346 first.

@moetemp moetemp reopened this Oct 30, 2026
A Stream request fills the producer from a Workflow helper in Workflow code and from an Activity
helper in a client, and the client API leaves the owner unset. A field takes one `@nexus.source`
for each target, and `@nexus.api-omit` takes `targets`.
@moetemp
moetemp force-pushed the moe/up/source-targets branch from 0b8405f to f76c7e1 Compare October 31, 2026 13:08
@moetemp moetemp changed the title feat: let @nexus.source and @nexus.api-omit name their target feat: give a field a source or an api-omit for each target Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant