~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
main
17 lines · 909 B Raw History
// node compose.ts > example.json
import { composition, policy } from "@publicdomainrelay/atlibs/compose/build.js";
import lock from "./atlibs.lock.json" with { type: "json" };
import { compose } from "./atlibs.modules.js";

// the editor opens the example signed out: each instance names its module by at:// URI, pinned
const toy = { ...compose, key: lock.modules.compose.uri };

const c = composition({ name: "doubler", description: "ui asks lookup to double n, if the even policy allows." });
const n = c.param("n", { type: "integer", maximum: 100, values: { default: 4 } });
const ui = c.instance("ui", toy);
const lookup = c.instance("lookup", toy, { input: { n } });
const even = c.instance("even", toy);
c.route(ui, "com.example.compose.lookup", lookup, "ui needs n doubled", { policies: [policy(even, "even")] });
c.export("com.example.compose.lookup", lookup);

process.stdout.write(await c.json());