import assert from "node:assert/strict"; import { test } from "node:test"; import { asyncObjectPlan } from "./async-fixture.js"; import { generateRemoteTypeScriptBindings, generatePortableTypeScriptBindings } from "../src/bindings/portable.js"; test("remote adapters expose selected typed calls, lifetimes and explicit transaction identities", async () => { const plan = await asyncObjectPlan(); const schema = plan.definition.bindingSchema; const source = generateRemoteTypeScriptBindings(schema, "async:controller-runtime@1"); assert.match(source, /readonly signal: AbortSignal/); assert.match(source, /readonly "summary.set":.*options: ServerMutationOptions/); assert.match(source, /readonly "summarize.call": \(input: string\) => Promise/); assert.doesNotMatch(source, /readonly "summary.get"|context\.conform|readonly snapshot:/); assert.doesNotMatch( generatePortableTypeScriptBindings(schema, "async:controller-runtime@1", { target: "browser" }), /readonly "refresh"/, ); const entry = schema.packages.find((p) => p.revisionId === "async:controller-runtime@1")!.exports[0]!; entry.dependencyPorts[0]!.requirement = { kind: "state", valueType: { kind: "scalar", name: "string" }, primitives: ["write"], }; assert.throws( () => generateRemoteTypeScriptBindings(schema, "async:controller-runtime@1"), /named transaction capability/, ); });