Repository navigation
TypeScript client: wire fixtures, a reserved $ prefix, model generation, queries over HTTP, streams, batches, live queries, commands, binary parts, attachments, cancellation, per-query headers, a Vite plugin, samples, an npm package and a describe tool - #15
Merged
Merged
Conversation
A reader tells a stream's marker ($scry) and a binary placeholder ($bin) from a row by that leading character alone. The argument that no row could collide rested on projected names being C# identifiers, which cannot start with one, but nothing on the server held a client to that: a JavaScript identifier can, and so can an agent writing the wire by hand. A row or a nested object named $scry or $bin would then read as a marker or as a placeholder for a part that was never sent. The validator now refuses such a name wherever a projection, a projected collection or a join result names one, with a 400 saying the wire keeps the character for its own markers. The comments and docs that leaned on C# identifiers now point at the rule instead.
A client in another language has to send the same bytes the C# client does: the cache, the URL form and the audit all key off a request's bytes, so a request that means the same thing but is spelled differently is a different request to each of them. TypeScriptFixtureTests writes what such a client needs as snapshots beside it, so a change on this side reaches that client as a failing test here first. wire.verified.ts is the vocabulary as TypeScript: every envelope, operator, node and projection value as an interface, read from the metadata ScryJson.Options writes with, so names, member order, discriminators and optional members are the ones that travel. A member type with no spelling there throws rather than being guessed at. requests.verified.json is the WireShapeTests corpus as exact compact bytes, each request beside the C# that produced it and what the server made of it over the seeded database. Reusing that corpus keeps its guards: a shape added for a new operator or function reaches this file too. Five shapes are added for the constant tags it never carried and for every escape the encoder writes, and a new test requires every tag to appear. framings.verified.json records what each HTTP endpoint answers, as it arrives: the URL form, a stream, a batch, multipart, the error bodies and a live query's first event. introspection.verified.json and names.verified.json hold the test model's description and the casing every row writes its names in. Values a client treats as opaque, which change from run to run or with the model, are written as placeholders: the schema stamp, page cursors, event ids and multipart boundaries.
The first piece of a TypeScript client, in clients/typescript: a generator that reads the description the query explorer reads and writes what a query is written against. Per model, a query interface whose members are expressions of the values they hold, with a navigation that may be absent making everything read through it nullable, and the row a query projecting nothing returns. Beside them the enums the model names, the sources and commands, and a schema object saying at run time what the types cannot: the name each member travels under, what each value is, and the default projection, by the rule ModelSynthesizer and the C# generator both follow, so every client sends the same request. Values a JavaScript number cannot hold exactly are not numbers: a long is a bigint and a decimal its text, and a DateTime stays a wall clock rather than becoming a Date in the reader's zone. A type display the generator does not know, a display that disagrees with the member's kind, names that camel-case alike and another introspection version are all refused rather than read as something near them. The casing is a port of the server's policy, checked against every name the .NET side recorded. Introspection names an enum of the base class library by its display alone, so its values come from a new fixture of the server's own table. The wire vocabulary snapshot becomes .mts: outside the package, a .ts file is read as CommonJS. Node 23.6 or later runs the package as it is, with no build step; CI checks it in a job of its own, since it reads only committed fixtures.
The query builder for the TypeScript client. A source's members are read off a proxy as paths, and everything read or computed is an expression carrying its wire node and the type of its value; operators and the wire's functions are helpers (eq, and, coalesce, startsWith, addDays, isIn and the rest), a collection is asked about through its own methods, and grouping, joins, set operations, ofType and selectMany follow LINQ's shape. The types follow the server's pipeline grammar, so an ordering it would refuse does not compile, and a row's type is inferred from the projection. A request has to be the C# client's byte-string for the same query, since the cache, the URL form and the audit key off its bytes. The serializer writes each member in wire order, every one of a wire type named so that a field the vocabulary gains fails the type-check, and escapes text as the server's encoder does. A constant is typed by what stands beside it under C#'s rules (an operator widens a char to its code, a uint travels as text, AddDays takes a double unless the date is a DateOnly) and spelled as .NET spells it. A projected key travels capitalized, as a C# member is named. test/corpus.test.ts writes every WireShapeTests shape in TypeScript and compares the bytes: 166 of 169 match, and the other three are C# spellings listed with why, such as an enum literal C# compiles to its number. The corpus gains three shapes returning a collection in a row, and its guard now covers projected values as well as operators and nodes, which it had let through. The generator gives every model its default projection, since flattening a collection projects the element's, types a row collection with its row, and marks an enum of the base class library, since System.DayOfWeek alone travels as its number. Terminals call a Transport the caller supplies and return the payload as it arrives; sending over HTTP and reading rows come next.
The TypeScript client's terminals now go somewhere. httpTransport sends a request to the endpoint MapScry mapped as the C# client does: as a URL where it fits the server's budget and reads nothing sensitive, so a cache between the two can keep the answer, and as a body otherwise. The budget and the schema stamp are read off every response, refusals included. A URL refused before it reached the server is asked again as a body and nothing as long is asked as a URL again, a 405 turns the URL form off, and a refusal saying the request must travel as a body is asked again as one. An answer is read by a plan the query builds alongside its projection, so every member arrives as its type says. A number is read from its own text rather than as a JavaScript number, so a long is a bigint and a decimal keeps every digit; bytes come back from base64; an enum is checked against the model, a renamed value mapped back through the aliases the response carries; and each row is keyed by the names the query wrote. A refusal throws ScryRequestError with the server's code, a policy denial and a stale client are told apart, and a body cut off part way or an answer of another kind throws ScryWireError rather than returning a short answer. A server on another model is told once, through onSchemaStale. Every answer the corpus recorded is read back through the TypeScript query that asks it, which is how a computed day of the week turned out to arrive as its number. The transport is tested against the recorded HTTP exchanges and the refusals a hop in front of the server gives, and test/server.test.ts runs against a live Sample.WebServer when SCRY_SERVER names one.
…ent does stream() posts to the endpoint's stream route and reads the rows a line at a time, split however the body arrives. The begin marker carries the stamp and the aliases; a failure after the first row arrives as an error marker and throws what its status would have thrown; and a body that ends without the closing marker throws ScryWireError, so a cut connection is never taken for the whole answer. Leaving the loop early aborts the fetch. A projection of binary members streams as multipart, which this client does not read yet, so that answer is refused rather than misread. createBatch collects queries by running each terminal against the same sources over a transport that holds the request instead of sending it, then sends them as one request. Each entry settles on its own: a response resolves it, and a refusal rejects it with the status the batch names, so one refused query leaves the others answered. A batch is sent once, and an entry that is not one query ended by its terminal is refused at once. live() and the scalar live terminals subscribe over server-sent events. A connection that ends is opened again naming the last answer held, so an unchanged answer is not sent twice and the consumer sees a pause. The rules for asking again are LivePump's: an execution failure, the subscription limit, a codeless 5xx, 408 or 429 and a failed connection are retried; a rejection, a denial and a stale client end it with their error; an end event saying not to reconnect completes it. The retry option decides the wait, and the default backs off from a second to thirty with a fifth of jitter either way. The tests replay the recorded stream, batch and first live event, feed bodies in small chunks split across a CR LF, and script live connections to check each reconnect and stop rule. test/server.test.ts gains a stream, a batch, and a live query that answers again after a bulk reprice of the orders it reads, all passing against Sample.WebServer.
createCommands gives a client's sources one function per command the model
declares, typed by its payload and its result. A payload is written as a
query's constant is, so a date may be a Date or its text and a [Flags]
value its names, and travels as the server's binder reads it: camel-cased,
a null left out, a long and a decimal as JSON numbers, every enum by its
name. A member the command does not have, or a null it cannot hold, is
refused before anything is sent. The request is the one the C# client
writes, apart from member order, which follows introspection: the server
binds a payload by name, and nothing keys off a command's bytes.
The outcomes are ScryClient's. A receipt decided at once is Completed,
with its result read as the model describes it, or Failed with the reason
the server showed; a target gone by the time the command arrived is a
Failed outcome rather than a refusal; anything else the server would not
accept throws, as a refused query does. One still running when the wait
runs out is Pending, listed as pending work until its outcome lands, and
followed meanwhile: a connection that ends first is asked for again by
the command's id under the retry policy, and one the server no longer
holds, or will not answer for, ends Unknown. Following stops on close()
whatever the transport does, since a transport that ignores its abort
would otherwise hold the follower open. can(), ready and
onCapabilitiesChanged read what the caller may send, read again after a
denial; the per-row can{Command} members were already generated.
TypeScriptFixtureTests.CommandFramings records what the command endpoints
answer over the test model, with handlers that write nothing: a command
decided at once, one failed, one refused, one whose target is not there,
one going pending and then its outcome, the same asked again by id, an id
nobody sent, and the capabilities. The tests replay them, script cut and
failing connections, and pin each value's JSON type. test/server.test.ts
gains a command with a typed result, a validation refusal, a slow rename
that goes pending, and the capability reads, all passing against
Sample.WebServer.
The generator now lets a payload's nullable value be left out, as a C#
client leaves out one it never set. ScryNotServedError says a server maps
no route for live queries or commands.
A [BinaryTransfer] member's values leave the JSON and travel as raw multipart parts before the document that references them, which this client used to refuse. It now reads them: a list's parts, then its envelope; a batch's parts numbered across every entry, then its envelope; and a stream's sections of lines with each row's parts just before it, held a row at a time. A $bin placeholder is read from the part it names. One naming a part the response did not carry, a part whose length disagrees with the one it declared, and a body with no JSON part all fail the read rather than standing for a guess. The parser reads the body as it arrives, so a delimiter split across chunks reads the same. An [Attachment] member never travels with a query. A row returned whole now carries an Attachment handle for each one, made from the key that came back with it, and open() fetches the bytes from the attachment endpoint as a request of its own: the declared type, an advisory length, the body as it arrives, null where the value is null, and a 404 ScryRequestError where the server will not hand them over. A projection may return an attachment beside its row's key, at the top or one navigation down, and travels without it; leaving the key out, filtering, ordering or grouping by one, or carrying one through distinct(), a set operation or selectMany() is refused when the query is written, as the C# translator refuses them. Key values are re-tagged as a constant of the key's type would be, in ordinal order by member name. The generator types the member as AttachmentMember in a query and Attachment in a row. TypeScriptFixtureTests.BinaryFramings records an attachment's bytes, the 204 and 404 answers, a request with no key, and a batch carrying binary parts; the recorder keeps any body that is not text as base64. The tests read the recorded multipart bodies in pieces down to a byte, the stream and the batch included, and fetch handles against the recorded answers. test/server.test.ts gains a binary member listed and streamed, every employee's photo opened, and a department's handbook one navigation down, all passing against Sample.WebServer. Running them there found the default projection binding no handles, since its select was added before the check for a whole row; the unit test now covers both projection modes.
docs/typescript.md is the client's documentation: generating a model from a server's introspection and what is generated, connecting, writing and reading queries, streams, batches, live queries, commands, binary members and attachments, and what has no counterpart. Its examples are snippets the docs build takes from the sample rather than code written into the page, so they are compiled where the sample is. The client's readme becomes a pointer to the page and the notes on running its own tests, so there is one copy of what it does. samples/Sample.TypeScriptClient is Sample.ConsoleClient in TypeScript, on Node: the same tables, --live watching the orders, --reprice sending the command and printing its outcome, and --photos opening each employee's photo, an attachment no query carried. It depends on the client by path, for which the client's package now names its entry point in exports. Its model is generated from the running server, as an app's build would, and is not committed: the sample model's committed description has its stamp scrubbed, and a model generated from it would call itself stale on every run. src/examples.ts holds what the page shows beyond what main.ts runs. The TypeScript CI job installs the sample, generates its model from that committed description, and type-checks it, which compiles every example the page quotes. clients.md, sample.md, the docs index, the readme and source-generator.md now name the TypeScript client beside the F# one.
The guidance named three solution trees and five sample clients, so nothing pointed at clients/typescript or Sample.TypeScriptClient, and nothing warned that a fourth reader of type displays now sits outside the .NET trees. It now places both among the trees, adds the client's check to the build commands, and names the TypeScript generator in the lockstep warning, its committed generated models being the guard. A section of its own covers what the client is, the fixtures the .NET side writes for it and how a changed one is accepted, the generated models, the server tests and what they write, why requests come out as the C# client's bytes and where a command payload departs from that, why the sample's path dependency runs where a registry install would not and why its model is not committed, and what the CI job checks.
A C# client regenerates from the model DLL on every build; a TypeScript client could only be generated from a running server or a saved copy of its description. WriteScryDescription closes that gap from the server's side: a host calls it as it starts, and it writes the document the explorer's introspection endpoint serves, less what only the explorer sets, to a path against the content root. It writes in Development unless told otherwise, since the description is the whole allow-listed surface, and only where the bytes changed, whole and then moved into place, so whatever watches the file runs when the surface moved and never reads half of one. Sample.WebServer writes it into the TypeScript sample where SAMPLE_DESCRIPTION says, which only its launch profile sets: the browser suite starts the server from a throwaway folder, and a relative path there would land outside it. The sample now generates its model from that file. scry-client/vite is a Vite plugin over the same generator: it generates the model as a build or the dev server starts, and in the dev server again whenever the description changes. It writes a real file, since the type-checker and the editor read files, and leaves one alone that already holds what the description generates. A description not there yet keeps the generated file with a warning, and fails the build only where there is none either. It is optional: vite is an optional peer dependency, the plugin uses its types alone, and the package's own entry point does not import it, so an app without Vite runs scry-codegen as before, which now also leaves an unchanged file alone. Driving the plugin with Vite itself found the generator importing the BCL enums from a JSON snapshot carrying Verify's byte-order mark: Node skips it, Vite's bundler refuses it, and a configuration importing the plugin bundles the generator. The fixture is now bcl-enums.verified.mts, a module, as the wire vocabulary is. test/vite.test.ts builds and serves with a real Vite over the configuration docs/typescript.md quotes, and DescriptionFileTests pins what is written, when, and that an unchanged file is left alone. The docs, server.md and CLAUDE.md describe both; the other pages changed only in the line anchors of snippets from Program.cs.
A TypeScript client could be generated only from a description a running server served, or one it wrote as it started. But the surface a description holds is the model's alone: the C# generator reads all of it from the DLL's attributes, commands and stamp included. Only the two limits are the server's configuration. So the description can come from the build, as a C# client's generated code does. src/Scry.Describe is a small console app that does that. It reads the model DLL with the generator's own MetadataModelReader, never loading it, stamps it with the generator's own stamp, and writes what ScryProcessor.Describe() answers, only where the bytes changed. The two limits are options, defaulting to ScryOptions'. ModelDescriber mirrors Schema.DescribeSurface in every order and spelling, and ModelDescriptionTests compares the two byte for byte over the test model. For the sample model it matched the server's in every field but sqlPreview, which only the explorer sets. A missing DLL, which the reader takes as an empty model as the generator wants of an empty ScryModelDll, is refused, as is a model declaring nothing a client could use. It is not packed, as the TypeScript client is not published. Two changes in the generator make that possible. The stamp moves from ScryGenerator into ModelStamp, since ScryGenerator implements Roslyn's generator interface and calling it would load the compiler; the reader called it too. And the reader now records an attachment's ContentType, the one field introspection carries that the generator had no use for, out of the stamp on both sides. The generator's snapshot and lockstep tests are unchanged. Sample.WebServer's build now runs it after every build, into the TypeScript sample, so that client is generated before the server has ever started; the startup write and its SAMPLE_DESCRIPTION are gone, so one file has one writer. WriteScryDescription stays, for a description that carries the limits a host configured. The client's readme no longer says a description can only come from a server's startup. It now says the surface is the model's and only the limits are configuration, and that only a URL input needs a running server; the end-to-end tests are the one part of the client's own suite that need one. docs/typescript.md describes the four ways a description reaches the generator, with a flowchart of them as alternatives meeting at one description and a sequence diagram of the Vite dev loop; the readme has the flowchart too. server.md and CLAUDE.md follow, and other pages moved only in the line anchors of snippets from Program.cs.
Only one of the four ways a description reaches the TypeScript generator, a saved copy, was tested end to end in CI. The build-time and startup descriptions were each proven equal to the server's on the .NET side, but nothing generated a client from them, and the client's server tests, which generate from a running server's introspection URL, ran only when pointed at one by hand. samples/Sample.TypeScriptClient/integration.ps1 runs all of it. It builds Sample.WebServer, whose build writes the description from the model DLL, and starts the built server as the browser suite does: a working folder of its own, a database of its own, and the explorer's introspection endpoint on in Development. It fails unless the description the build wrote and the one the server wrote as it started are byte for byte one, and unless the client generated from each, and from the endpoint, is the same but for the line naming its input. Then it generates, type-checks and runs the sample, and runs the client's server tests against that server. It stops the server alone, never its process tree, since LocalDB's engine is a child of whichever process started the instance. Run here it passed, all sixteen server tests included, and left the instance running normally. For the startup description Sample.WebServer writes one where SAMPLE_STARTUP_DESCRIPTION says, which only the script sets, to a path of its own, so the file the build writes keeps one writer. CI's Windows job, which has LocalDB, sets up Node and runs the script in Release after the suites, gated on the samples build as the model-package steps are. The Vite plugin's URL input had no test. Two now serve a description from a local HTTP server: a build generates the model from it, and with the server gone a build keeps the model it has and fails only where it has none. The readme, docs/typescript.md and CLAUDE.md describe the script; other pages moved only in the line anchors of snippets from Program.cs.
Every test and sample of the TypeScript client ran on Node, so nothing showed it in a browser, and nothing showed the Vite plugin in an app. Its runtime uses fetch, streams and getRandomValues alone; Node's APIs are only in the generator and the plugin, which run at build time. samples/Sample.TypeScriptWeb is the console sample's queries as a Vite page: the tables, each employee's photo drawn from a blob its attachment handle fetched, and a live orders table whose Reprice buttons send the command, each enabled where the server says the row may be repriced. The plugin generates the model from the description Sample.WebServer's build writes beside it; that target now writes both samples' files, one run per file. The page asks its own origin for /api, which Vite's dev server forwards to SCRY_SERVER, so the server needs no cross-origin policy, and live queries and pending commands stream through the forward. SCRY_DESCRIPTION points the plugin at another description. Run here in the browser pane, a reprice moved order 2 from 250.00 to 251.00 on the live table, with nothing on the console. test/browser.test.ts serves the page with Vite and drives it headless in the installed Edge or Chrome through playwright-core, which downloads no browser: the tables load, the photos are drawn from blobs, a reprice reaches the live table, and the console stays empty. That last check found the browser asking for a favicon the page did not have, so it has an empty one. It is skipped without SCRY_SERVER. integration.ps1 now checks the two samples were written one description, builds the browser sample with Vite, type-checks it and runs that test against the server it starts; run here it passed, all sixteen server tests included. CI's Ubuntu job builds the sample from the committed description and type-checks it. .claude/launch.json gains a typescript-web entry, running Vite with node.exe by path, since the app's launcher may not have Node on its PATH. The docs, the samples' tables, the client's readme and CLAUDE.md describe it.
Every C# terminal takes a CancellationToken, but the TypeScript client's
one-shot terminals took no AbortSignal, so a query nobody wanted any more
ran to its end. toList, first, single, last and their OrDefaults,
elementAt, count, longCount, any, all, sum, average, min, max, minBy,
maxBy, page and stream now take { signal } last. It reaches the transport
as the request's signal and never the request, so a query sent with one
is the same bytes as without. Where a condition is optional the options
may stand in its place, so count({ signal }) counts every row, and page
takes them in place of the size or the cursor, as the C# overloads do.
A projection's terminals take no condition, so a function given to one
is still a type error rather than options.
An abort abandons the fetch and the terminal rejects with the signal's
reason. A stream aborted part way used to end as a stream the server cut
off: lines() ends quietly on an aborted signal, which left the closing
marker missing. It now ends with the reason. A stream's own connection
also left a listener on the caller's signal for good, so a signal that
outlives many streams gathered one per stream; it now lets go once the
connection ends, and aborts with the caller's reason rather than a
generic one. A query in a batch goes with the batch, as ScryBatch's
entries do: send(signal) is the one that counts.
test/cancel.test.ts holds every terminal's signal to the transport and
its request to the one sent without, and over a real fetch to a local
server abandons a request in flight, a stream holding a row and one
waiting on its next, and a batch. Run against the old code, the stream
test fails with the cut-off error and the listener test finds two left
behind. test/types.ts pins the overloads. The docs page gains a
Cancelling section, which also covers the signals commands and
attachments already took, with its example compiled by the sample's
type-check; CLAUDE.md notes how the arguments are sorted.
The client's readme had grown into a second docs page. Its section on generating a client was another copy of the docs page's Generating the model, the same table and the same diagram, already worded differently. Its section on developing the client was the only copy, and the docs page's Developing the client was a line pointing back at it. Developing the client now holds that section: running the check, the fixtures the .NET side keeps for the client, the server tests and the end-to-end script, and writing the committed fixture models again. It adds that the server tests write to the sample's database, so what reads the seeded rows after them reads them changed, until Sample.WebServer starts again. The readme is now a pointer to the docs page's sections, the two samples, and the two commands that check the client.
The C# client sends a header with one query through WithHeader and WithHeaders, and reads the response's through OnResponseHeaders. The TypeScript client could only give its transport headers for every request, so a query that needed to be asked afresh, past a 304, had no way to say so. withHeader, withHeaders and onResponseHeaders are those three. They sit on the query's state, not in its request, so a query is the same bytes with them or without and where they are written makes no difference. A terminal writes the headers once and hands them to the transport, so a URL re-asked as a body carries the same ones; a live query writes them for each connection, as the C# client does. httpTransport sends them over its own, a query's winning a name both give, and tells the reader the headers of the response that answered: a refusal's before it is thrown, a stream's before its first row. A query in a batch carrying them is refused when added, as ScryBatch refuses one, since a batch is one request. test/headers.test.ts covers each of those over the HTTP transport and a scripted live one, and test/types.ts that a query keeps its type. The docs page gains a Headers section, its example compiled by the sample's type-check, and CLAUDE.md a note on where the headers live.
The Blazor sample shows paging by offset and by cursor, a cached row policy, a live query read three ways, the commands page with its pending work, and a reload offered when the server's model moves on. The TypeScript samples showed none of it: the browser page had a few tables and one command, and the console sample no paging or loop. The browser sample is now a page for each of the Blazor sample's, built by Vite as several entries and sharing src/client.ts, which holds the one client, the navigation and the banner that offers a reload. The queries page adds a filter on values the page holds, a projection that nests, and what a stale client's refusal shows. Paging and keyset page the employees. The cached-policy page asks its orders with a no-cache header of their own, through withHeader, since a 304 would decide nothing, and its counter stays on a repeat, rises by one for a revised order and by every row when a grant moves. The live page reads one live query through subscribe or with for await, beside a Reprice command and the bulk reprice that is no command. The commands page hires, renames, deactivates and deletes against a live table, each button enabled by what the server says may be sent, and lists pending work, where a slow rename was seen pending, completed, and gone eight seconds later. Rx, MessagePipe, the SignalR switch and the sidecar have no counterpart. The console sample gains --pages, every employee by offset and then by cursor, which integration.ps1 now runs, and --live --loop, the live query read with for await. test/browser.test.ts drives every page in Edge, eight tests in order on one server that leave the data as they found it but for reprices; it rewrites each response's schema stamp to bring up the banner, and checks every policy query carried no-cache. integration.ps1 passed whole: the three clients the same, the console sample with its new flag, the browser tests and the sixteen server tests. The sample also builds and type-checks from the committed snapshot, as CI builds it. The docs page gains a table of the pages, the stale banner and the no-cache query, Paging, and the live loop; the samples' tables and CLAUDE.md follow, the second noting that a page left out of Vite's inputs is missing from the production build.
…brought Carrying on from the last wrapping pass, the console sample's where snippet in examples.ts, and the active-employees and regions queries in main.ts, are wrapped and re-indented to the chain's indent, each object literal closing on a line of its own; docs/typescript.md is regenerated from them. In Scry.Tests, the three files that brought a using of Microsoft.AspNetCore.Hosting drop it, since nothing in them needs it; the activity listeners in ObservabilityTests and SubscriptionTests declare their sampler's parameter as ref _, as C# 14 allows; the two fixture recorders use the CancelSource alias; and the TypeScript vocabulary names DateOnly and TimeOnly by the Date and Time aliases.
The one-shot terminals took a signal, but a live query could be ended
only by leaving its loop or calling the function subscribe returned. A
for await waiting on its next answer could not be ended from outside,
where C# has WithCancellation, and the console sample's loop stopped
only when Ctrl+C killed the process.
live, liveCount, liveLongCount, liveAny, liveFirstOrDefault and
liveSingleOrDefault now take { signal } last, the options standing in
for an optional condition as the one-shot terminals' do. The signal is
bound to the LiveQuery and ends it for good, every connection it holds
closed. A loop over it ends with the signal's reason, whether it was
waiting for an answer or to ask again, and one whose signal has already
aborted opens nothing. A subscription stops as its own stop would and
tells onError nothing, since the caller asked for it. Either way the
signal is let go of once the live query is done with it, and the
request is the same bytes with one or without.
test/cancel.test.ts gains thirteen tests: every live terminal, a loop
ended waiting for an answer and waiting to ask again, an aborted signal,
a subscription, the listener let go of, and a live query over a real
fetch whose server sees the connection close. test/types.ts pins the
overloads. The console sample's --live --loop hands Ctrl+C's signal to
live(), and exits 0 when it aborts; the docs page and CLAUDE.md say how
a live query's signal ends it.
ProjectionPlan.MayBeBytes called itself on a List<T>'s element type as its last act, which the IDE flags as a tail call a loop can replace. It now walks the element types in a loop, answering the same: true where a byte[] could stand behind the type, false at the first type that is neither that nor a List<T>. Scry.Tests passed, the disclosure tests that reach it through ReadsBytes among them.
Scry is consumed by other projects, but the TypeScript client could only be used from inside this repository: it was private TypeScript source, which the samples reach through a file: link. Node strips types from no file under node_modules, so the source would not run from an install, nor would its Vite plugin, which Vite's config loading leaves to Node, and it imports two modules from the .NET tree a package cannot reach. npm run build compiles it into dist/ as JavaScript with declarations, each relative import's .ts rewritten to .js. It copies in the wire vocabulary and the BCL enums it imports from src/Scry.Tests/TypeScript, points those imports at the copies, and refuses an import of the .NET tree it was not told to copy. It writes the package's own package.json (scry-client, which is free on npm and matches the NuGet Scry.Client; the compiled entry points with their types; the scry-codegen bin; Vite as the optional peer it was; Node 22; MIT, as the NuGet packages are) and a readme with absolute links. The version is the NuGet packages', from src/Directory.Build.props, or --version. The source package.json stays private, so the source cannot be published by mistake. No declaration needs Node's types. npm run verify-package installs the packed tarball into a project of its own in the temp folder, where nothing resolves to this repository, and requires that the installed scry-codegen write the model the committed test-model.ts holds, that code written against the package type-check with no Node types, that Node run it and write the recorded C# request bytes, and that a Vite build generate a model through the installed plugin. It installs Vite from the registry, so it is not part of check. It passed here on dist/ and on a tarball built with a CI-style version. CI's typescript job now builds the package, at the tag's version on a tag, packs it, verifies the tarball and uploads it. A publish-npm job, on a tag after the build and typescript jobs, publishes that tarball through npm trusted publishing, as the NuGet job publishes: no stored token, and provenance. It skips a version already published and puts a prerelease under next. Neither job has run yet; trusted publishing needs a publisher configured for the package on npmjs.com. docs/typescript.md gains Installing (the package, its three entry points, Vite optional, the version it shares with the NuGet packages) and The published package under Developing the client; it says why the samples still use the client by path, and that Scry.Describe is not yet a package. The client's readme and CLAUDE.md follow.
The docs read awkwardly: inverted sentences, personified components
("generated from what the server already says about itself"), long
chains of clauses, stacked "as X does" comparisons, and ordinary words
bent out of their meaning (a value "travels", a server "answers with", a
change "moves" a stamp).
The pages in docs/, two of the include sources, the root readme, the
TypeScript client's and the benchmarks' readmes, and all but one of the
package readmes are reworded as plain subject-verb-object English. Code
is untouched apart from mermaid labels, and every link target and heading
is as it was, with one heading added: "What is generated" on the
TypeScript page, whose live-query section also now defines a live query
before its examples.
The aim was to change wording and not meaning. A comparison with the
commit before found no heading or link lost. The wording itself was only
sampled: parts of security.md, disclosure-audit.md and the readme were
read against the originals, and the rest was not. Some sentences were
unclear to begin with and the rewording picks a reading, notably in
annotations.md ([Sensitive], overrides), policies.md (denied rows),
server.md (URL refusals), performance.md (segments) and
disclosure-audit.md (exclusions). A few counts and link texts that did
not match what followed them were corrected on the way.
Rewording the docs turned up claims that were out of date or at odds with each other. - Cursors are sealed with AES-GCM: paging.md described an HMAC whose payload anyone can read. - A request is stamped with the lowest wire version its pipeline needs (WireFormat.RequiredVersion), not the current one, and wire-format.md says what version 2 is. - A [QueryableCollection] can be projected as a list one level deep, a policied one is read through its policy unless the policy refuses it at startup, and a JSON array of complex values has members to read: annotations.md, querying.md, linq-coverage.md and getting-started.md. - querying.md: terminals have predicate overloads, a widening conversion is sent as a function and a narrowing rejected, and the double-only rule does not take in Math.Max and Math.Min. - comparisons.md and the readme account for the TypeScript client. - live-queries.md names ScryOptions.Caller; security.md says the limit watch covers seven of the nine limits; disclosure-audit.md says KeepFor retires segments too; docs/readme.md no longer calls keyset paging pending; the benchmarks readme has two benchmarks needing a database; explorer.md covers the wire strip and all three screenshots. - schema-versioning.md: of the changes it lists, a tightened limit is the one that leaves the stamp alone, and a changed representation is the one other mistake that can pass silently. - performance.md: what a terminal gains from the writer, and what a second record being written costs, now follow from their own tables. Nothing was measured again. - caching.md names the two reasons a query goes to POST, and the two explorer packages' readmes say what they meant about validation and about a host that only reads the record.
The typescript job packed the client into npm/ at the repository root, which nothing creates, and npm pack writes into a folder that exists rather than making one. So every run since the step was added failed at "Pack the package" with ENOENT, the verify and upload steps never ran, and publish-npm would have had no tarball to publish on a tag. The step now makes the folder first. Run locally from clients/typescript as CI runs it, the old command fails with the same ENOENT, and the new one packs scry-client-0.4.0.tgz, which verify-package then installs, generates a model with, type-checks, runs and builds a page with. It has not run on CI yet.
The browser sample reaches its API through Vite's dev server, which forwards /api, and the docs said nothing of what replaces that forward once a build is deployed: nothing does, since it belongs to vite and vite preview alone. docs/typescript.md gains "Hosting a browser app", with three ways to host one. On the API's own host, the build served from wwwroot beside MapScry, the endpoint stays a path and the server needs no CORS. Behind a reverse proxy, the API's responses must pass unbuffered: the server already marks its event streams X-Accel-Buffering: no, no-store and uncompressed, an idle live query is pinged every SubscriptionHeartbeat, and a connection ends after SubscriptionLifetime and is reopened. On another origin, a CORS policy has to allow GET and POST, Content-Type, Last-Event-ID and the app's own headers, and expose Scry-Url-Limit and Scry-Schema-Stamp: unexposed, the first makes the client take every 400 a URL query gets for a refusal in front of the server and shrink its URL budget, and the second leaves a refusal saying nothing of the server's model, as an error response carries the stamp in that header alone. A cookie needs AllowCredentials and a fetch that sends credentials, shown in a snippet from the console sample's examples, which its type-check compiles. The browser sample's section points at the new one. The CORS setup is written from the code and ASP.NET Core's API; it has not been run end to end.
Two statements in code still said what the docs said before they were corrected: that a [QueryableCollection] can be aggregated but never projected, and so that a response never carries a nested collection. A collection now projects as a list one level deep. The comment on Department.Employees in the sample model says so, and that the collection still cannot be stepped through in a member path. SCRY111's description no longer gives the old rule as the reason a GroupJoin cannot return its group: a GroupJoin answers one flat row per outer row, returning the group is refused as the query is translated, and the server refuses a projection reading the inner side other than through an aggregate. Its message, that projecting the group would put a nested collection in the response, is still true and is unchanged.
Scry.Describe writes a server's description from its model DLL with no server running, which is what lets a TypeScript client be generated as the server builds. It was a project only this repository could run: Sample.WebServer's build target reaches it by relative path, and it was not packed, so an app taking Scry from NuGet could describe its model only at startup, from a running server's URL, or from a saved copy. It now packs as a tool, Scry.Describe, command scry-describe, rolling forward to newer runtimes, with a readme. The src Release build already packs every src project into nugets/, so CI uploads it and the tag's publish job pushes it with the rest. The C# compiler the generator references is left out of its output, which nothing the tool calls loads: seven of its eleven megabytes, leaving a 1.6 MB package. Microsoft.CodeAnalysis.dll stays, since a central version for Microsoft.CodeAnalysis.Common, which leaving it out would need, is pinned transitively onto the generator's netstandard2.0 build, whose Roslyn 5.0.0 needs Common 5.0.0 exactly; tried, that build lost Roslyn. CI's Windows job gains a step that installs the packed tool from nugets/ and requires it to write the description the samples build wrote by running the project. Locally the tool, installed into a local tool manifest from the package, wrote the sample's description byte for byte, as did that step's script against the Debug model; ModelDescriptionTests pass and Sample.WebServer's build, which runs the project, still writes its descriptions. The step has not run on CI. docs/typescript.md's "At build time" now installs the tool as a local tool and runs it from an AfterTargets="Build" target, with dotnet tool restore for a fresh clone or CI, and says its version must match the server's packages, as the description carries the schema stamp. The package tables, docs/server.md and CLAUDE.md follow. Whether nuget.org's trusted publishing lets CI create a new package id is unconfirmed; if it does not, the first version has to be pushed by hand.
querying.md's section on deduplicating said a deduplicated query can be paged, and that paging needs an ordering written after the Distinct. It meant Skip and Take, which is what its example uses: ToPageAsync over a Distinct query is refused by the validator. The section now names Skip and Take, and says ToPageAsync is rejected and to slice with them instead, as the operator table and linq-coverage.md already do.
The plain-prose rewrite had to pick a reading for three sentences whose original wording allowed two. - annotations.md: a client that sends a [Sensitive] comparison in a URL now "finds out": it is refused, sends the request again as a body, and reports itself stale, because marking a member changes the schema stamp. The original said only that such a client "says so", which the rewrite had narrowed to its being told. - disclosure-audit.md: leaving a member out is for one like a product's name and code, which a list shows so that a row can be picked, as opposed to the rest of the row; the example above it excludes exactly those two. ScryDisclosureOptions.Exclude's doc comment carried the same unclear phrase and now gives the same example. - performance.md: a question written as one statement per segment is now said to be slower than the view over twenty-four segments, with no figure. The "three times as long, against one segment" it gave could be read as a ratio of times or of slowdowns, and no benchmark here produces it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groundwork for a TypeScript client. The server needs no change to serve one (its additions, a description written to a file at startup and a build-time step writing the same from the model DLL, are for build tooling), but a client in another language has to send the same bytes the C# client does: the cache, the URL form and the audit all key off a request's bytes, so a request that means the same thing but is spelled differently is a different request to each of them. This writes down what such a client is built and tested against, closes the one hole that only a non-C# client could reach, and adds the client: a generator that writes typed models from a server's introspection, a query builder whose requests are the C# client's bytes for the same query, an HTTP transport that sends them and reads each answer back as the types the query said, streams, batches and live queries that reconnect, commands followed to their outcome, binary parts and attachments, cancellation and per-query headers as the C# client has them, its documentation, a sample on Node and one in a browser covering the Blazor sample's scenarios, and a Vite plugin generating the model from a description the server writes, an npm package,
scry-client, built from it and published on a tag, andScry.Describepacked as a .NET tool,scry-describe, so an app outside this repository can write its description at build time too. It also rewrites every docs page in plain prose, correcting the claims the code contradicted.Thirty-seven commits: the
$rule, the fixtures, the generator, the builder, the transport, streams, batches and live queries, commands, binary parts and attachments, the docs and sample,CLAUDE.md, the description file and Vite plugin, the build-time description, the end-to-end tests, the browser sample, cancellation, the readme folded into the docs, per-query headers, the samples' new scenarios, two passes wrapping the long lines in the console sample's snippets (the second also tidying the tests the branch brought), a signal for live queries,ProjectionPlan.MayBeBytesas a loop, the npm package and its publish job, every docs page in plain prose, three commits correcting claims the docs made that the code or another page contradicts (the last also fixing two code comments that made the same claims), single-characterstring.JoinandAppendJoinwith the corpus key and snapshots that change with them,ModelSynthesizerleavingKeysout where a type has none and some wrapping, the folder CI packs the package into, how to host a browser app built with the client, two code statements calling a queryable collection unprojectable,Scry.Describeas a .NET tool, a primary constructor forScryCommandFailedException, Skip and Take named where the Distinct docs said paging, and three doc sentences the rewording had left reading two ways.Refuse a projected name that starts with
$A reader tells a stream marker (
$scry) and a binary placeholder ($bin) from a row by that leading character alone. The collision argument rested on projected names being C# identifiers, which no server rule enforced; a JavaScript identifier can start with$, and so can an agent writing the wire by hand.QueryValidatornow refuses such a name in a projection, a projected collection or a join result, as a400. Tests inSecurityTests;docs/wire-format.mdand the comments that leaned on C# identifiers now point at the rule.TypeScript fixtures
TypeScriptFixtureTestswrites Verify snapshots intosrc/Scry.Tests/TypeScript/, so a change on this side reaches a TypeScript client as a failing test here first:wire.verified.mtsScryJson.Optionswrites with, so names, member order, discriminators and optional members are the ones that travel. A member type with no spelling throws rather than being guessed at.requests.verified.jsonWireShapeTestscorpus (166 shapes) as exact compact request bytes, each beside its C# and the server's answer over the seeded database.framings.verified.jsonrequiresBody, and a live query's first SSE event.introspection.verified.jsonnames.verified.jsonJsonNamingPolicy.CamelCasemakes of every model member name, plus edge cases.commands.verified.jsonTypeScriptFixtureTests.CommandFramingsover the test model, with handlers that write nothing and ids fixed in the test.binary.verified.json204for one holding nothing, the bare404for one the check refuses, the400for a request with no key, and one flat multipart for a batch whose entries carry binary parts, numbered across every entry. Recorded byTypeScriptFixtureTests.BinaryFramings; the shared recorder now keeps any body that is not text as base64, which left the existing framings as they were.bcl-enums.verified.mtsDayOfWeek,DateTimeKind,HttpStatusCode), which introspection names by display alone. A module rather than JSON, as the vocabulary is: see the Vite section.WireShapeTestsgains five shapes, for the constant tags the corpus never carried (Boolean, Int64, DateOnly, Guid) and for every character the encoder escapes, and a new test requires everyClrTypeTagto appear.Generating models:
clients/typescriptA new tree with its own
package.json; no.slnx.scry-codegen --input <file or URL> --output <file>reads a description (a file, or the explorer's{route}/introspect) and writes, per model:{Type}Query, what a query reads: each member anExprof its value, a navigationOptional(everything read through it may be null), a collection aCollectionasked about through a subquery, and an attachment anAttachmentMember, which a query may only return.{Type}Row, what a query projecting nothing returns: the scalar members, a base's first, and anAttachmenthandle for each attachment.Beside them: the enums the model names (
[Flags]ones asFlags),SourcesandCommandsmapping each to its types, and aschemaobject with what the types cannot say at run time: each member's wire name, its value type, sensitivity, capabilities, and each source's default projection, by the ruleModelSynthesizerand the C# generator follow.A
longis abigint, adecimalits text, and aDateTimea branded round-trip string rather than aDate, which would place a wall clock in the reader's zone. An unknown type display, a display disagreeing with the member's kind, names that camel-case alike, two generated declarations of one name, and a description of another introspection version are all refused. The camel-casing port matches all 86 recorded names. The output for the test model and the sample model is committed undertest/generatedand compared on every run;test/types.tsholds type assertions that only compile while they hold.Writing queries
Members are read off a proxy as paths (
_.manager.nameisManager.Name), and everything read or computed is an expression carrying its wire node and the type of its value. Operators and the wire's functions are helpers (eq,and,coalesce,startsWith,addDays,round,isInand the rest), a collection is asked about through its own methods (_.lines.any(...),_.tags.contains(...)), and grouping, joins (inner, left, right, group, composite keys), set operations,ofType,selectManyand every terminal follow LINQ's shape. The types follow the server's pipeline grammar, sothenBywithout an ordering, a filter afterselector a grouped query that never projects does not compile, and a row's type is inferred from the projection.The serializer writes every member in wire order (each writer names every field of its wire type, so one the vocabulary gains fails the type-check) and escapes text as the server's encoder does. A constant is typed by what stands beside it under C#'s rules and spelled as .NET spells it: a
charbeside an operator sends its code as an Int32, auinttravels as text,addDayssends a Double except on aDateOnly, and a decimal keeps its scale. A projected key travels capitalized, as a C# member is named, so{ name: _.name }sends the bare"Name".test/corpus.test.tswrites every corpus shape in TypeScript and compares bytes: 166 of 169 match. The other three are C# spellings, listed with why: an enum literal C# compiles to its number, a C# source handed its own default projection, and a terminal condition after a projection, which the server refuses and the types forbid. The corpus gains three shapes returning a collection in a row, andWireShapeTests' guard now covers projected values as well as operators and nodes, which it had let through.Sending and reading
httpTransport({ endpoint, fetch?, headers? })sends as the C# client does: as a URL where the request fits the server's budget and reads nothing sensitive, as a body otherwise. The budget and the schema stamp are read off every response, refusals included. A URL refused before it reached the server (400, 404, 414 or 431 withoutScry-Url-Limit) is asked again as a body and nothing as long is asked as a URL again; a 405 turns the URL form off; arequiresBodyrefusal is asked again as a body.Each answer is read by a plan the query builds alongside its projection. A number is read from its own text, so a
longis abigintand adecimalkeeps every digit; bytes come back from base64; an enum is checked against the model, a renamed value mapped back through the response's aliases and an unknown one failing as a stale client; each row is keyed by the names the query wrote. A refusal throwsScryRequestErrorwith the server's status and code, withScryPermissionErrorandScryStaleClientErrortold apart; a body cut off part way or an answer of another kind throwsScryWireError. A server on another model is told once, throughonSchemaStale.All 167 answers the corpus recorded are read back through the TypeScript query that asks them, which is how a computed day of the week turned out to arrive as its number. The transport is tested against the recorded HTTP exchanges and scripted refusals, and
test/server.test.ts(skipped unlessSCRY_SERVERis set) passed against a runningSample.WebServer: a model generated from its live introspection, URL and body forms, paging by cursor, a join, a lookup in another source, a grouping, and the stale notice.Streams, batches and live queries
stream()posts to the endpoint's/streamroute and reads rows a line at a time, however the body is split. The begin marker carries the stamp and the aliases; an error marker after the first row throws what its status would have thrown; and a body ending without the closing marker throwsScryWireError, so a cut connection is never taken for the whole answer. Leaving the loop early aborts the fetch.createBatch(scry)collects queries by running each terminal over a transport that holds the request rather than sending it, then posts them to/batchas one request. Each entry settles on its own: a response resolves it, a refusal rejects it with the status the batch names, so one refused query leaves the others answered. A batch is sent once.live(), andliveCount,liveLongCount,liveAny,liveFirstOrDefaultandliveSingleOrDefault, subscribe over server-sent events, as anAsyncIterableor throughsubscribe(onAnswer, onError), which returns its stop. A connection that ends is opened again withLast-Event-ID, so an unchanged answer is not sent twice and the consumer sees a pause. The rules areLivePump's: an execution failure, the subscription limit, a codeless 5xx, 408 or 429 and a failed connection are retried; a rejection, a denial and a stale client end it with their error; anendevent withreconnect: falsecompletes it. Theretryoption decides the wait; the default,backoff, asks at once, then from a second doubling to thirty, with a fifth of jitter either way.The tests replay the recorded stream, batch and first live event, feed bodies in seven-byte chunks with CR LF split across them, and script live connections to check each reconnect and stop rule.
test/server.test.tsgains a stream compared with the same query listed, a batch sent as one POST, and a live query that answers again afterPOST /api/orders/reprice-bulk.Commands
createCommands<Commands>(scry)gives one function per command onsend, typed by its payload and result. A payload is written as a query's constant is (a date as aDateor its text, a[Flags]value as its names) and travels asCommandBinderreads it: camel-cased, a null left out, alongand adecimalas JSON numbers, every enum by name,System.DayOfWeekincluded. A member the command does not have, or a null it cannot hold, is refused before sending. The recorded CreateShift request, with escapes, a date and a flags list, is matched byte for byte once its id is put back.The outcomes are
ScryClient's. A receipt decided at once isCompletedwith its result read typed, orFailedwith the reason shown; a 404 with the endpoint's body (the target gone) is aFailedoutcome; every other refusal throws. One still running afterwait(3 s) isPending, listed incommands.pendinguntil it lands, and followed: a connection that ends first is asked for again by id under the retry policy, a404or a refusal when asked again ends itUnknown, andclose()ends every one still followed asUnknown. A completed entry leaves aftercompletedLinger(8 s); a failed or unknown one stays untilclearFinished().can(),readyandonCapabilitiesChangedread…/capabilities, read again after a denial; the per-rowcan{Command}members were already generated and query as any member.The generator now lets a payload's nullable value be left out.
ScryNotServedErrorsays a server maps no route for live queries or commands.test/server.test.tsgains a command with a typed result, a validation refusal, a slow rename that goes pending and lands, and the capability reads.Binary parts and attachments
A
[BinaryTransfer]member's$binplaceholders are read from the multipart parts before the JSON that references them: a list's parts then its envelope, a batch's numbered across every entry then its envelope, and a stream's sections of lines with each row's parts immediately before it, held a row at a time. A placeholder naming a part the response did not carry, a part whose length disagrees with what it declared, and a body with no JSON part fail the read. The parser reads the body as it arrives; the tests feed the recorded bodies in pieces down to one byte, so a delimiter split across chunks is covered.An
[Attachment]never travels with a query. A row returned whole carries anAttachmenthandle per attachment, made from the key that came back with it, andopen()posts to…/attachment: the declared content type, the advisory length, the body as it arrives withbytes()andblob(),nullfor a204, and a404ScryRequestErrorfor a refusal. A projection may return an attachment beside its row's key, at the top or one navigation down, and leaves it off the wire; leaving the key out, filtering, ordering or grouping by one, or carrying one throughdistinct(), a set operation orselectMany()throws when the query is written, asQueryTranslator.Attachmentsrefuses them. Key values are re-tagged as a constant of the key's type would be, ordinal by member name, and the recorded request is matched byte for byte.test/server.test.tsgains a binary member listed and streamed, every employee's photo opened (one is null), and a department's handbook one navigation down. Running them againstSample.WebServerfound the default projection binding no handles, since itsselectwas added before the whole-row check ran; the unit test now covers both projection modes.Docs and a sample
docs/typescript.mdis the client's documentation: generating a model and what is generated, connecting, writing and reading queries, streams, batches, live queries, commands, binary members and attachments, and what has no counterpart. Its examples are snippets the docs build takes from the samples, so they compile where the samples do. The client's readme is now a pointer to the page, whose "Developing the client" holds what the readme said about the client's own tests, fixtures, server tests and end-to-end run, rather than a second copy of how a model is generated.docs/clients.md(the "Clients that are not C#" section and the samples table),docs/sample.md, the docs index, the readme anddocs/source-generator.mdname it beside the F# client.samples/Sample.TypeScriptClientisSample.ConsoleClientin TypeScript, on Node: the same tables,--live,--reprice <id>, and--photosopening each employee's photo. It ran in every mode againstSample.WebServer, the live watch printing a second table as the reprice landed. It depends on the client by path (file:../../clients/typescript), for which the client'spackage.jsonnow names./src/index.tsinexports. Its model is generated from the descriptionSample.WebServerwrites into its folder as it starts, and neither is committed, since the sample model's committed description has a scrubbed stamp and a model generated from it would call itself stale on every run;src/examples.tsholds what the page shows beyond whatmain.tsruns.A description file, and a Vite plugin
A C# client regenerates from the model DLL on every build; a TypeScript one could only be generated from a running server or a saved copy of its description.
app.WriteScryDescription(path)(ScryServiceExtensions.Description.cs) writesprocessor.Describe(), what/introspectserves less the explorer'ssqlPreview, to a path against the content root as the host starts: in Development unlessalways: true, and only where the bytes changed, whole and then moved into place, so a watcher runs when the surface moved and never reads half a file.DescriptionFileTestspins the content, the environment rule and an unchanged file left alone.Sample.WebServerwrites it into the TypeScript sample whereSAMPLE_DESCRIPTIONsays, which only itslaunchSettings.jsonsets, since the browser suite starts the server from a throwaway folder where a relative path would land outside it; the sample'snpm run generatereads that file. Live, the file matched the endpoint in every field butsqlPreview.scry-client/vite(src/vite.ts) generates the model as a build or the dev server starts, and in the dev server again when the description changes. It writes a real file, since the type-checker and the editor read files, leaves an unchanged one alone, keeps the generated file with a warning where the description is not there yet, and fails only where neither is.viteis an optional peer dependency, the plugin uses its types alone, and the package's own entry point does not import it, so the command line works as before (and now also leaves an unchanged file alone).test/vite.test.tsbuilds and serves with a real Vite 8 overtest/vite/vite.config.ts, which the docs quote.Driving the plugin with Vite found the generator importing the BCL enums from a JSON snapshot carrying Verify's byte-order mark: Node's JSON import skips it, Vite's bundler refuses it, and a configuration importing the plugin bundles the generator. The runtime does not import it, so a browser bundle of the client was unaffected. The fixture is now
bcl-enums.verified.mts.The description at build time, and end to end
The surface a description holds is the model's alone; only
maxPageSizeandqueryUrlLimitare configuration. Sosrc/Scry.Describe(a console app, not packed) writes it from the model DLL with no server: it reads the DLL with the generator's ownMetadataModelReader, never loading it, stamps it with the generator's own stamp, and writes whatScryProcessor.Describe()answers, only where the bytes changed.ModelDescribermirrorsSchema.DescribeSurface, andModelDescriptionTestscompares the two byte for byte over the test model; for the sample model it matched in every field butsqlPreview. For it the stamp moves out ofScryGeneratorintoModelStamp, since calling a class implementing Roslyn's generator interface would load the compiler, and the reader now records an attachment'sContentType, out of the stamp on both sides.Sample.WebServer's build runs it into the TypeScript sample after every build. The client's readme no longer says a description can only come from a server's startup, and the readme anddocs/typescript.mdgain flowcharts of the four ways a description reaches the generator, drawn as alternatives, and a sequence diagram of the Vite dev loop.samples/Sample.TypeScriptClient/integration.ps1runs the client end to end against a realSample.WebServer, started as the browser suite starts it: it requires the build's description and the one the server writes as it starts (whereSAMPLE_STARTUP_DESCRIPTION, set only by the script, says) to be byte for byte one, generates one client from each and from the introspection URL and requires the three to match, then runs the sample and the sixteen server tests. CI's Windows job runs it after the suites. Two more Vite tests cover a URL input, served from a local HTTP server.A browser sample
Every test and sample ran the client on Node.
samples/Sample.TypeScriptWebis the console sample's queries as a Vite page: the tables, each employee's photo drawn from a blob its attachment handle fetched, and a live orders table whose Reprice buttons send the command, each enabled by the row'scanRepriceOrder. The plugin generates its model from the descriptionSample.WebServer's build writes beside it (the target now writes both samples', oneExecper file). The page asks its own origin for/api, which Vite's dev server forwards toSCRY_SERVER, so the server needs no CORS, and live queries and pending commands stream through the forward. The bundle, client included, is 83 KB (26 KB gzipped). In the browser pane a reprice moved order 2 from 250.00 to 251.00 on the live table with nothing on the console.test/browser.test.tsserves the page with Vite and drives it headless in the installed Edge or Chrome throughplaywright-core, which downloads no browser: the tables load, the photos are blobs that loaded, a reprice reaches the live table, and the console stays empty (which is how a missing favicon was found).integration.ps1builds the sample with Vite, type-checks it and runs that test against the server it starts; CI's Ubuntu job builds it from the committed description and type-checks it.Cancellation
Every C# terminal takes a
CancellationToken; the one-shot TypeScript terminals took noAbortSignal.toList,first,single,lastand theirOrDefaults,elementAt,count,longCount,any,all,sum,average,min,max,minBy,maxBy,pageandstreamnow take{ signal }last. It reaches the transport as the request's signal and never the request, so a query is the same bytes with one or without. Where a condition is optional the options may stand in its place (count({ signal })), andpagetakes them in place of the size or the cursor, as the C# overloads do; a projection's terminals take no condition, so a function given to one is still a type error. An abort rejects with the signal's reason. A stream aborted part way used to end as one the server cut off, sincelines()ends quietly on an aborted signal; it now ends with the reason, and its connection no longer leaves a listener on the caller's signal for good.test/cancel.test.ts(31 tests) covers every terminal over a recording fetch and, over a real fetch to a local server, a request abandoned in flight, a stream holding a row and one waiting on its next, and a batch; run against the old code, the stream and listener tests fail as they should.The live terminals (
live,liveCount,liveLongCount,liveAny,liveFirstOrDefault,liveSingleOrDefault) take{ signal }too, bound to theLiveQuery, which it ends for good, every connection closed: a loop over it ends with the reason, whether waiting for an answer or to ask again, and a subscription stops as its own stop would, tellingonErrornothing. Thirteen more tests cover each terminal, both waits, an aborted signal, a subscription, the listener let go of, and a real fetch whose server sees the connection close. The console sample's--live --loophands Ctrl+C's signal tolive()and exits 0 when it aborts.Per-query headers
withHeader,withHeadersandonResponseHeadersare the C# client's three. They sit on the query's state rather than in its request, so the bytes are the same with them or without and their place in the chain makes no difference. A terminal writes the headers once, so a URL re-asked as a body carries the same ones; a live query writes them per connection, asScryClient.Livedoes.httpTransportsends them over its own, a query's winning a name both give, and reads the response that answered: a refusal's headers before it is thrown, a stream's before its first row. A query in a batch carrying them is refused when added, asScryBatchrefuses one. Tested intest/headers.test.ts(8 tests) and the type assertions.The Blazor sample's scenarios
The TypeScript samples showed a few tables and one command. The browser sample is now a page per
Sample.WebClientpage, built by Vite as several entries, sharingsrc/client.ts(the one client, the navigation, and a banner offering a reload when a response shows the server on another model):page()afterskip(), Previous and Next.page(size, cursor), Next and Start over.no-cacheheader of their own throughwithHeader, since a 304 would decide nothing: the decisions counter stays on a repeat, rises by one for a revised order, and by every row when a grant moves.subscribeor withfor await, a Reprice command per row, and the bulk reprice that is no command.In the browser pane a slow rename showed pending at 3.1 s, completed at 5.2 s and left the panel at 13 s, and the counter moved 4, 4, 5, 8. The console sample gains
--pages(by offset, then by cursor), whichintegration.ps1runs, and--live --loop.test/browser.test.tsis now eight tests in order on one server, leaving the data as they found it but for reprices; it brings up the banner by rewriting each response'sScry-Schema-Stampwithpage.route, and checks every policy query carriedno-cache. The docs page gains a table of the pages, Paging, and the live loop.An npm package
The package was private TypeScript source, which only this repository could use: Node strips types from no file under
node_modules, so an install would not run, nor would the Vite plugin, whose config Vite leaves to Node to load; and it imported two modules from the .NET tree.npm run build(scripts/build.ts) compiles it intodist/with its declarations, copies in the wire vocabulary and the BCL enums and points the imports at the copies, refuses an import of the .NET tree it was not told to copy, and writes the package's ownpackage.json(scry-client, the compiled entry points with their types, thescry-codegenbin, Vite as an optional peer, Node 22, MIT) and readme. The version issrc/Directory.Build.props' or--version. The sourcepackage.jsonstays private, so the source cannot be published by mistake.npm run verify-packageinstalls the packed tarball into a project in the temp folder, where nothing resolves to this repository, and requires the installedscry-codegento write the committedtest-model.ts, code written against the package to type-check with no Node types, Node to run it and send the recorded C# request bytes, and a Vite build to generate a model through the installed plugin.CI's
typescriptjob builds, packs, verifies and uploads the tarball.publish-npm, on a tag afterbuildandtypescript, publishes it through npm trusted publishing (environmentnpm,id-token: write, no stored token, with provenance), skipping a version already published and tagging a prereleasenext. The pack step failed on every run until its output folder was made first; on the last push thetypescriptjob passed every step.scry-client0.4.0 is on npm, published by hand from this branch's build, since a trusted publisher can only be added to a package that exists. Its wire code differs from the 0.4.0 release's only in comments. The trusted publisher (Papyrine/Scry,build.yml, environmentnpm,npm publishallowed) is saved and pending validation: npm expires it unless a publish goes through it before Dec 4, 2026, 09:44 UTC.docs/typescript.mdgains Installing and "The published package"; the client's readme andCLAUDE.mdfollow.Scry.Describeas a .NET toolScry.Describewrites a description from the model DLL with no server running, but it was a project only this repository could run:Sample.WebServerreaches it by relative path, and it was not packed. It now packs as the toolScry.Describe, commandscry-describe, rolling forward to newer runtimes, with a readme. The src Release build already packs every src project intonugets/, so CI uploads it and a tag pushes it with the rest.The C# compiler the generator references is left out of its output, since nothing the tool calls loads it: 1.6 MB rather than 11.
Microsoft.CodeAnalysis.dllstays: leaving it out too needs a central version forMicrosoft.CodeAnalysis.Common, which transitive pinning forces onto the generator's netstandard2.0 build, whose Roslyn 5.0.0 needs Common 5.0.0 exactly. Tried, that build lost Roslyn.CI's Windows job gains a step that installs the packed tool from
nugets/and requires it to write the description the samples build wrote by running the project. Locally the tool, installed into a local tool manifest from the package, wrote the sample's description byte for byte.docs/typescript.md's "At build time" now installs it as a local tool and runs it from anAfterTargets="Build"target, withdotnet tool restorefor a fresh clone or CI, and says its version must match the server's packages, since the description carries the schema stamp. The package tables,docs/server.mdandCLAUDE.mdfollow.The docs in plain prose
Every page in
docs/, the include sources, the root readme, the TypeScript client's and the benchmarks' readmes, and the package readmes are reworded as plain subject-verb-object English. The docs had drifted into inverted sentences, personified components, long comma chains and words bent out of their meaning (a value "travels", a change "moves" a stamp). Headings and link targets are unchanged but for one heading added to the TypeScript page, and code is untouched but for mermaid labels.Rewording them turned up claims the code or another page contradicted, corrected over three commits:
[QueryableCollection]can be projected as a list, a policied one is read through its policy, and a JSON array of complex values has members to read;Math.MaxandMath.Min;ScryOptions.Caller, the limit watch covers seven of the nine limits, andKeepForretires segments asKeepdoes;405before it has learned the URL limit is0(or from a gateway that blocksGET), not only when stale;Distinctresult can be sliced withSkipandTakebut not paged withToPageAsync;NavigationPolicyandUrlLimitTestsmade two of the same claims in comments, now corrected, as are the comment onDepartment.Employeesin the sample model andSCRY111's description, which gave "a response never carries a nested collection" as the reason a GroupJoin cannot return its group.Hosting a browser app
The browser sample reaches its API through Vite's dev server, which forwards
/api; a deployed build has no such forward.docs/typescript.mdgains "Hosting a browser app", with three ways to host one:wwwrootbesideMapScry: the endpoint stays a path, and the server needs no CORS.X-Accel-Buffering: noandno-storeand sends them uncompressed; an idle live query is pinged everySubscriptionHeartbeat(15 s), which the proxy's idle timeout has to outlast.GETandPOST,Content-Type,Last-Event-IDand the app's own headers, and exposesScry-Url-LimitandScry-Schema-Stamp. Unexposed, the first makes the client take every400a URL query gets for a refusal in front of the server and shrink its URL budget, and the second leaves a refusal saying nothing of the server's model. A cookie needsAllowCredentialsand afetchthat sends credentials, shown in a snippet from the console sample's examples, which its type-check compiles.For review
Scry.Tests, not in IntegrationTests, so every fixture describes one model. That needsAllowUnmappedSources(the model opts in a source with no table to pin its naming) and aMicrosoft.AspNetCore.TestHostreference inScry.Tests; the version already exists centrally.400message underrefused; one that faults on the seed (Singleover several rows,Asinpast its domain) asfailed.?q={base64url(requestBody)}, because the shared scrubber that decodes base64url queries for readability rewrote the path.JSON.stringify("as\u0022,<,&,'and+, all non-ASCII, surrogate pairs); port the camel-casing per character, sinceJsonNamingPolicy.CamelCaseleavesİas it is wheretoLowerCasemakes it aniand a combining dot; and strip the BOM Verify writes.sbyte,byte,ushort,long,floatanddoublenever appear as member types. The generator's map is written fromSchema.ScalarDisplay; only the displays the two fixtures use are exercised by generation..mts. Outside the package, a.tsfile is read as CommonJS by the compiler.Scry.Testsregistersmtsas a Verify text extension for it.wire.verified.mtsandbcl-enums.verified.mtsare imported fromsrc/Scry.Tests/TypeScriptrather than copied, so they cannot drift;npm run buildcopies them into what npm gets, and refuses a new import of the .NET tree until it is added to its list. The samples still depend on the client byfile:path, a link that resolves outsidenode_modules, so they run the source.stringorbyte[]member may be null, so neither is typed nullable, as the C# generated models do not mark them either.typescriptjob on Ubuntu runsnpm ci, the type-check and the tests, installs the samples, generates the console sample's model from the committed description and type-checks it (which compiles every exampledocs/typescript.mdquotes), builds and type-checks the browser sample, and builds, packs and verifies the npm package. The Windows job also installs the packedscry-describeand holds its output to the samples' description; that step has not run on CI yet. It reads only committed files, so it runs beside the build with no .NET or LocalDB; on the push that fixed its pack step it passed every step. The Windowsbuildjob also sets up Node and runsintegration.ps1in Release after the suites, gated on the samples build, driving the browser sample in the image's Edge.CLAUDE.mdplacesclients/typescriptandSample.TypeScriptClientamong the trees, adds the client's check to the build commands, names the TypeScript generator as a fourth reader in the lockstep warning, and has a section of its own on the fixtures, generated models, server tests, requests, the sample, the description at build time and at startup, the end-to-end script, the browser sample, the Vite plugin, why no snapshot is imported as JSON, and CI, and namesModelDescriberas a mirror ofSchema.DescribeSurfacebeside the lockstep readers.OrDefaultelement terminal throws ("The sequence contains no elements.") where C# returns the default; theOrDefaultforms returnnull.2026-03-04T00:00:00,09:30:15), not in the 7-digit form requests use.private, no-cachewith an ETag, so the Blazor sample'sQueryCacheHandlerhas no counterpart; the exchange itself was not observed, only that the cached-policy page needs itsno-cacheheader.ScryBatch.Enqueuereads no token:send(signal)is the batch's.d0e24f6, the hosting docs. Of the five commits since (the stale code statements, the tool, the primary constructor, the Distinct wording and the three sentences), only thetypescriptjob has run, on5c4f943, and passed; that run's Windows job was cancelled by the next push before its suites and the tool check.Sample.WebServer's changes are a build step and a startup write only the script asks for.Scry.Describewould be a new package id on nuget.org. Whether trusted publishing lets CI create one is unconfirmed; if it does not, the tag's NuGet push could fail at it, and its first version has to be pushed by hand.Program.cssetsMaxPageSize = 200, and the build target passes--max-page-size 200.package-lock.jsongrows with it..claude/launch.jsongains atypescript-webentry for the browser sample's dev server, running Vite withnode.exeby its absolute path, as the file's BlazorQL entry already names a machine's path: the app's launcher had no Node on its PATH.CommandActivity, the sidecar's feed. Of the Blazor sample's pages, the Rx and MessagePipe live tabs, the transport switch and the sidecar have no TypeScript counterpart.integration.ps1beside the previews fails: thesamplepreview'sdotnet runholds the Debug build, and thetypescript-webpreview's Vite holds filesnpm cireplaces (a-4048). Stop both first.close()whatever the transport does. Each receipt is raced against the abort, since a transport that ignores its signal would otherwise hold a follower, and soclose(), open for ever. A test hung on exactly that before the race was added.fetch, notEventSource, which cannot POST or send headers. That keeps the transport's headers (authorization) on every reconnect, and needs a runtime whosefetchstreams a body, as Node and current browsers do. The SignalR hub is not a transport here.HttpStatusCodename where the entry carries one, else from its code, as a single query's would.&&,||,!and? :on an expression cannot be caught at run time (where(_ => a && b)would sendbalone).>,+and template literals throw. The readme recommends@typescript-eslint/strict-boolean-expressions; no lint config ships, to add no dependencies.distinct(), andselectManyover a collection of values.Scry.Describeamong them, andscry-clientat the tag's version, so the next one needs a version past 0.4.0 and a commit that has the pack fix, and, for the trusted publisher to validate, has to publish before Dec 4, 2026, 09:44 UTC. npm also lists a0.0.0-stageversion it made while processing the hand publish.security.md,disclosure-audit.mdand the readme); a script confirmed no heading or link was lost. Where a sentence was unclear the rewording picked a reading; the last three are settled in their own commit: a client sending a[Sensitive]comparison in a URL is refused, re-sends it as a body and reports itself stale (annotations.md), leaving a member out is for a label like a product's name and code (disclosure-audit.md, andScryDisclosureOptions.Exclude's doc comment), and the per-segment statement is said to be slower than the view with no figure, since no benchmark here produces the "three times" it gave (performance.md).Locally: src 2665 (4 skipped: Release-only packaging and Redis), IntegrationTests 281 and samples 198 (both run for the first two commits; the rest touch only
Scry.Testsand the new tree), the TypeScript fixture tests (9) andDescriptionFileTests(4), TypeScript 515 tests plus the type-check, andintegration.ps1against a realSample.WebServer: three identical clients, the console sample with--photosand--pages, the browser sample's eight page tests in headless Edge, and the 16 server tests.