Skip to content

Adding documentation for Nexus Client library code generation - #5055

Closed
Evanthx wants to merge 7 commits into
mainfrom
nexus-idl
Closed

Adding documentation for Nexus Client library code generation#5055
Evanthx wants to merge 7 commits into
mainfrom
nexus-idl

Conversation

@Evanthx

@Evanthx Evanthx commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This is documentation for pre-release code, do not merge yet!

┆Attachments: EDU-6905 Adding documentation for Nexus Client library code generation

@Evanthx
Evanthx requested a review from a team as a code owner August 6, 2026 21:39
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview Aug 15, 2026 5:40am

Request Review

@jsundai jsundai self-assigned this Aug 7, 2026
@Duncanma Duncanma added the blocked-on-release These changes are waiting for official release okay label Aug 7, 2026
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
- **A shared runtime validator.** One validator per type, used when a value is parsed off the wire and again when it is serialized onto the wire, so a payload cannot enter or leave your service in a shape the contract forbids.
- **A [Nexus Service Contract](/glossary#nexus-service-contract) definition.** The generated Service and Operation declarations you register on a Worker and call from a caller Workflow.

Constraint failures do not surface one at a time.

@KeithB-Temporal KeithB-Temporal Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting placement because it is not what the generator produces but is a behavior of the generator.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Tweaked the wording, see if you like this better.

Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
```bash
git clone https://github.com/temporalio/nex-gen.git
cd nex-gen
cargo build --release

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is cargo, and how do I get it if I want to use this project.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat clarified - but didn't go into depth. I can, but ... this should be easy to figure out, and if it's not then I'm not sure that person should be trying to build this!

Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
- `string` (the default) keeps every temporal field as the RFC 3339 string that appears on the wire.
It has no runtime dependency and round-trips losslessly, but you parse and compare the strings yourself.
- `date` maps `date-time` fields to a JavaScript `Date`.
This is lossy: a `Date` is a UTC instant, so the original offset is folded away and precision is capped at milliseconds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using ISO-8601? https://en.wikipedia.org/wiki/ISO_8601

I thought the whole world uses ISO-8601... ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked and hopefully clarified ... but yeah, RFC 3339. See this comment in nex-gen:
https://github.com/temporalio/nexgen/blob/main/src/json_schema/format.rs#L38

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also search for the string "because the stdlib emitters disagree" in https://github.com/temporalio/nexgen/blob/main/specs/json-schema/features/format.md, that's why he used the RFC I think

Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
This is lossy: a `Date` is a UTC instant, so the original offset is folded away and precision is capped at milliseconds.
- `temporal` maps to the TC39 Temporal API, preserving offset and sub-second precision, and requires the `Temporal` global or a polyfill.

## Use the generated code

@KeithB-Temporal KeithB-Temporal Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange use generate code talks about how the validation works, and then jumps into the generated code samples. It should do one or the other, either explain how the generated code was generated, or deep dive into a sample. Not both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if you like this better?


## Supported schema features

The generator implements a curated subset of JSON Schema 2020-12 chosen so that every accepted construct lowers identically into all four languages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we so in love with writing out: JSON Schema 2020-12. Is that meaningful to folks rather than just say Json Schema.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, don't say all four languages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON Schema 2020-12 is now in two places ... I think it's OK, seems to make sense to me, but ... I can easily modify this. See how it reads this time.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs PR preview links

Copilot AI balanced review requested due to automatic review settings August 14, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents the pre-release Nexus Client Code Generator and adds it to Nexus navigation.

Changes:

  • Explains schema generation, validation, installation, and language-specific usage.
  • Adds guidance for contract changes, defaults, and supported schema features.
  • Adds the page to the Temporal Nexus sidebar.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
sidebars.js Adds the generator guide to Nexus navigation.
docs/encyclopedia/nexus/nexus-client-code-generator.mdx Introduces the generator documentation and examples.
Suppressed comments (1)

docs/encyclopedia/nexus/nexus-client-code-generator.mdx:458

  • fromIntermediate throws ValidationError, but this handler lets it escape without converting it to a Nexus HandlerError of type BAD_REQUEST. Therefore the sample does not implement the BAD_REQUEST behavior promised on line 38 and described on line 475. Catch the validation error here and throw the SDK's explicit non-retryable BAD_REQUEST handler error while preserving the violations.
const handler = nexus.serviceHandler(chatService, {
  async sendMessage(_ctx, input) {
    const request = new SendMessageInputMapper().fromIntermediate(input);
    const output = { messageId: await store(request) };
    return new SendMessageOutputMapper().toIntermediate(output) as SendMessageOutput;

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx
Comment thread docs/encyclopedia/nexus/nexus-client-code-generator.mdx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-on-release These changes are waiting for official release okay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants