@svatah/yam-sdk
v0.2.0
Published
The typed TypeScript client for the Yam local service, generated from its OpenAPI description (REQ-SDK-1)
Readme
@svatah/yam-sdk
The typed TypeScript client for the Yam local service (REQ-SDK-1, LLD §13.8).
import { connect } from "@svatah/yam-sdk";
const client = connect(); // YAM_SERVICE_URL / _TOKEN
const project = await client.getProject();
const { runId } = (await client.postRun({ flows: ["flows/simple.flow"] })) as { runId: string };
const stop = client.subscribe((event) => {
if (event.kind === "run.summary") stop();
});
await client.run("bindings.verify", {}); // the screen model's actionsFour things, and only the first is generated:
GeneratedClient— one method per route, written bynode scripts/generate-clients.mjsfrompackages/service/openapi.json.tools/repo-checks/test/client-drift.test.tsregenerates and diffs, so a route the service renamed is a red build.subscribe()— the event stream over SSE (default) or WebSocket, which an OpenAPI description cannot express as anything but "a string".fetchrather thanEventSource, becauseEventSourcecannot send anAuthorizationheader and the token is not going in a URL.actions—@svatah/yam-screens's registry, so an agent out of process runs the same action a person clicks, by the same id.connect()—YAM_SERVICE_URLandYAM_SERVICE_TOKEN, then the lock fileYAM_SERVICE_LOCKnames. Never a model credential.
Bodies are unknown. Their types are @svatah/yam-schema's — StepResult,
Summary, BindingFile — and re-deriving them from a JSON Schema round-trip
would make a second, subtly different set of the same types (REQ-STD-1).
YamClient satisfies @svatah/yam-screens's ScreenService structurally, so
every screen loads against it with nothing to adapt.
