Skip to content

feat: accept a definition object for a resource's type arguments - #80

Closed
moetemp wants to merge 1 commit into
moe/up/resource-type-parametersfrom
moe/up/resource-definition
Closed

moetemp wants to merge 1 commit into
moe/up/resource-type-parametersfrom
moe/up/resource-definition

Conversation

@moetemp

@moetemp moetemp commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR adds @nexus.definition, which names an SDK type that gives the type arguments of a generic resource. An operation that returns the resource takes the definition in place of its runtime types.

/// @nexus.type-parameter "body-t"
/// @nexus.definition python="temporal_support.StreamDefinition"
///   typescript="StreamDefinition" typescript-import="../../../support/temporal_model_converters"
///   dotnet="Nexgen.Support.StreamDefinition"
resource %stream { ... }

So Python's create_stream(Turns, id=...) returns a Stream[Turn], and the TypeScript and .NET Workflow creates take the definition first too. A resource method that binds the operation keeps the runtime types. No SDK has StreamDefinition yet, so the sample names a type of its own support code. nexgen refuses the directive on a resource with no @nexus.type-parameter.

The TypeScript and .NET client targets still take the type argument, and take the definition in a follow-up PR.

Why?

The proposal creates a Stream from a definition, as in client.create_stream(Turns, id=...). The form of a definition is an SDK idiom in each language, like a Workflow definition. So the SDK defines it, and nexgen only names it.

How did you test it?

Link to a test plan if any -

  • Unit Tests
  • Staging
  • End to End Tests

Python and .NET tests create a typed Stream from a definition.

@moetemp
moetemp force-pushed the moe/up/resource-definition branch from cdd698d to a5d352a Compare October 29, 2026 04:00
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch 2 times, most recently from 9791e30 to 5f8ad4f Compare October 31, 2026 13:08
@moetemp
moetemp force-pushed the moe/up/resource-definition branch from a5d352a to 1fd4ea6 Compare October 31, 2026 13:08
@moetemp
moetemp force-pushed the moe/up/resource-definition branch from 1fd4ea6 to 5bd1eef Compare November 3, 2026 15:22
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 5f8ad4f to 1180181 Compare November 3, 2026 15:22
`@nexus.definition` names an SDK type, such as a Stream definition, that gives the type arguments
of a generic resource. An operation that returns the resource takes it in place of runtime types,
unless a resource method binds the operation.
@moetemp
moetemp force-pushed the moe/up/resource-type-parameters branch from 1180181 to de74981 Compare November 4, 2026 09:34
@moetemp
moetemp force-pushed the moe/up/resource-definition branch from 5bd1eef to 5e46777 Compare November 4, 2026 09:34
@moetemp

moetemp commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Not needed anymore. temporalio/api#895 has no Stream definitions now, so a call takes the payload type.

@moetemp moetemp closed this Nov 5, 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