Files
ClintchizandClaude Opus 5 69020b2555
Quality / quality (ubuntu-latest) (push) Failing after 10m7s
Quality / quality (windows-latest) (push) Canceled after 0s
docs: make the component sections executable in one pass
Expands 3.1 and 3.2 so the work can be done without re-deriving anything.

3.1 now records what 0.8.6 already fixed, separated into the ten components
that were miswired and the five that gained outputs they had been firing
undeclared, with the caveat that Map's three were converted but never confirmed
in a browser. For the 22 that remain it adds the finding that changes the
decision: all nine are pure scaffolds with no state, functions or handlers, and
five of them duplicate a component that already works -- FileUpload against
FileInput and FileUploadProgress, Toast and ToastNotifications against Toaster,
AdvancedDatePicker against DatePicker, AdvancedRangeSlider against RangeSlider.
Superseding those is a migration entry rather than new code, and leaves Chart,
TreeView, Confetti and CopyMarkup as the only ones needing to be built.

3.2 corrects the scaffold count from 23 to 28; the earlier figure used a looser
rule. Nine of the 28 are the 3.1 components, so the two items must be planned
together, and several of the rest are primitives that need only their styles
moved out of ui.css rather than any behaviour.

Also corrects the dead-output component count from 11 to 9 in both documents.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-09 10:34:22 +05:30

55 lines
2.1 KiB
TypeScript

import { expect, test } from "bun:test";
import { defineService, procedure } from "../src/contract.ts";
import { implementStream, streamClient } from "../src/stream.ts";
import { handleRpcRequest } from "../../dev-server/src/rpc-dispatch.ts";
const numbers = defineService({
name: "numbers",
procedures: { count: procedure.output<number>().build() },
});
test("private streaming RPC authenticates identity and yields SSE frames as an async iterable", async () => {
const oldSecret = process.env.WRNEXUS_RPC_SECRET;
const oldApp = process.env.WRNEXUS_APP_NAME;
const oldOrigins = process.env.WRNEXUS_INTERNAL_ORIGINS;
try {
process.env.WRNEXUS_RPC_SECRET = "test-rpc-secret-at-least-32-chars-long";
process.env.WRNEXUS_APP_NAME = "web";
process.env.WRNEXUS_INTERNAL_ORIGINS = JSON.stringify({ numbers: "http://numbers.internal" });
const service = implementStream(
numbers,
{
async *count(_input, context) {
expect(context.subject?.subjectId).toBe("u1");
yield 1;
yield 2;
},
},
{ selfApp: "numbers" },
);
const client = streamClient(numbers, {
app: "numbers",
as: { user: { id: "u1" }, locals: {} } as never,
fetch: (async (input: RequestInfo | URL, init?: RequestInit) => {
const request = new Request(input, init);
return (await handleRpcRequest(
request,
new URL(request.url),
new Map([["numbers", service]]),
))!;
}) as typeof fetch,
});
const values: number[] = [];
for await (const value of client.count(undefined)) values.push(value);
expect(values).toEqual([1, 2]);
expect(service.metrics.snapshot()).toEqual({ started: 1, completed: 1, failed: 0, active: 0 });
} finally {
if (oldSecret === undefined) delete process.env.WRNEXUS_RPC_SECRET;
else process.env.WRNEXUS_RPC_SECRET = oldSecret;
if (oldApp === undefined) delete process.env.WRNEXUS_APP_NAME;
else process.env.WRNEXUS_APP_NAME = oldApp;
if (oldOrigins === undefined) delete process.env.WRNEXUS_INTERNAL_ORIGINS;
else process.env.WRNEXUS_INTERNAL_ORIGINS = oldOrigins;
}
});