Skip to content

[UPSTREAM-15] fix(typescript): build a returned proto-wire resource in an endpoint-less client - #73

Closed
moetemp wants to merge 1 commit into
moe/up/python-client-record-importsfrom
moe/up/ts-endpointless-resource-return
Closed

moetemp wants to merge 1 commit into
moe/up/python-client-record-importsfrom
moe/up/ts-endpointless-resource-return

Conversation

@moetemp

@moetemp moetemp commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

What changed?

This PR builds a resource that an operation returns on a proto wire type, in the TypeScript <Service>Client class of a service with no @nexus.endpoint.

  • services.ts imports the resource class as a value and adds the requiredField helper.
  • A 64-bit resource field converts from Long in an answer. temporalio/nexgen#296 converts one to Long in a request.

Depends on #69 (UPSTREAM-13), and on temporalio/nexgen#297 and #296, which the base holds.
Part of the Brook review series.

Why?

services.ts used the class from an import type, called a missing requiredField, and put a Long in a number field. So tsc failed.

The Python <Service>Client in services.py has the same bug. It imports the returned resource class only under TYPE_CHECKING, so the call fails at run time. #75 (UPSTREAM-17) fixes it.

How did you test it?

Brook's open-writer returns the writer resource, which has a u64 writer-id. Without the fix, the writer's services.ts fails tsc, so the samples leave it out of the TypeScript build. This PR turns it on. Brook's WIT already has the case, so it's one commit.
cargo validate passes and cargo clippy adds no warnings.

moetemp added a commit to temporalio/nexgen that referenced this pull request Oct 23, 2026
)

## What changed?

This PR adds a `stream-service` sample for Python and TypeScript, with today's output. #272 adds .NET with its fix. It has a `stream` resource built from a ref, `create-stream`, append, read, describe and close, with 64-bit offsets, payloads and durations.

Its records are proto-backed, as a stream service's are. Upstream has no stream protos, so the sample has its own small proto in `descriptors/streamsample/v1/`, with checked-in bindings. The samples README has the commands that regenerate them. `build_examples` now loads every `*.bin` under `descriptors/`.

## Why?

Later fixes show their effect as a golden diff on this sample.

## How did you test it?

The goldens. A TypeScript test sends a full `ReadRecordsRequest` through the converter, so the TypeScript type file can't drift from the proto.

## What comes next

These fixes are ready, in this order. Each one adds its shape to this sample, then the fix.

- #272: adds .NET, where the `stream` field of the `Stream` class fails with CS0542, then the fix.
- [moetemp#52](moetemp#52): Check required resource fields of a response. Adds `create-stream` returning the `stream` resource.
- [moetemp#56](moetemp#56): Allow a result record to hold a resource. Adds a `create-stream-result` holder record.
- [moetemp#53](moetemp#53): Emit `@nexus.doc` on resources and methods as Python docstrings.
- [moetemp#70](moetemp#70): Convert 64-bit resource method values to `Long` for a proto request in TypeScript. Adds 64-bit method parameters. Needs #265.
- [moetemp#54](moetemp#54): Generate a Python caller per service over a transport. Turns on the client for the sample.
- [moetemp#55](moetemp#55): Add `@nexus.long-poll` to the Python caller. Marks `read-records` as a long poll.
- [moetemp#57](moetemp#57): Add Python client classes for resources with methods.
- [moetemp#71](moetemp#71): Drop the bare keyword marker from a Python signature with no parameters. Adds a `stream-writer` interface with no endpoint.
- [moetemp#60](moetemp#60): Indent the docstrings of Python caller methods. Adds a doc on a writer operation.
- [moetemp#69](moetemp#69): Import record types that an endpoint-less Python client uses in unpacked parameters. Adds `open-writer`.
- [moetemp#72](moetemp#72): Plan proto unsigned integers as unsigned. Adds a `uint64` writer id.
- [moetemp#73](moetemp#73): Build a returned proto-wire resource in an endpoint-less TypeScript client. Makes `open-writer` return the `writer` resource.

#262 adds a `status` enum to the holder record once it merges.
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from 4605c8f to 737cb59 Compare October 25, 2026 22:19
@moetemp
moetemp force-pushed the moe/up/proto-unsigned-ints branch from 3870c97 to 3e44798 Compare October 25, 2026 22:19
@moetemp
moetemp changed the base branch from moe/up/proto-unsigned-ints to moe/up/python-client-record-imports October 25, 2026 22:19
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from 737cb59 to ae82054 Compare October 25, 2026 23:49
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from c3c1da4 to 8077f09 Compare October 25, 2026 23:49
@moetemp
moetemp marked this pull request as ready for review October 25, 2026 23:49
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from ae82054 to e60c196 Compare October 26, 2026 20:56
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from 8077f09 to 5a96423 Compare October 26, 2026 20:56
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from e60c196 to f6020bb Compare October 26, 2026 22:34
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch 2 times, most recently from a85def5 to d6df728 Compare October 26, 2026 22:37
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch 2 times, most recently from 20b8c18 to 2475c32 Compare October 26, 2026 23:01
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from d6df728 to 10b1a85 Compare October 26, 2026 23:01
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from 2475c32 to f8cecee Compare October 27, 2026 01:06
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from 207f3e6 to 993cf8a Compare October 27, 2026 09:08
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch 2 times, most recently from 6f89d5e to c56987c Compare October 27, 2026 18:07
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from 993cf8a to 8d54083 Compare October 27, 2026 18:07
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from c56987c to bd6ed47 Compare October 27, 2026 19:00
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from 8d54083 to 9401eef Compare October 27, 2026 19:00
The client of a service with no endpoint built a returned resource from a type-only import,
without the `requiredField` helper, and passed a `Long` to a number field. So `tsc` failed.
Brook's writer now type-checks.
@moetemp
moetemp force-pushed the moe/up/python-client-record-imports branch from 9401eef to b4b1ed3 Compare October 28, 2026 00:24
@moetemp
moetemp force-pushed the moe/up/ts-endpointless-resource-return branch from bd6ed47 to 7ca79da Compare October 28, 2026 00:24
@moetemp

moetemp commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Closing this. The Streams stack doesn't need it.

@moetemp moetemp closed this Oct 29, 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