Generate typed asynchronous service capability bindings
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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<string>/);
|
||||
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/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user