WorkLensDocs
    Studio
    reference

    SDK API

    Every function the Node.js SDK exports — generate, prove, inspect, read a file, manage packs — with what each returns.

    Last updated 2026-09-17 · Markdown

    Summary

    The Node.js SDK is the same engine the CLI and the MCP server use, as a CommonJS module; the WebAssembly instantiates synchronously when it is required, so every call is an ordinary synchronous function.

    The functions

    • generate(recipe, { rows, seed, scenario }) — one table (the first entity) as rows.
    • generateAll(recipe, { rows, seed, scenario }) — every table; rows[0] of each is the header.
    • generateNested(recipe, { root }) and generateSlice(recipe, { root, keepN }) — a nested document from a root entity, or a referential slice of N root rows with everything they point at.
    • exportFixedWidth(recipe, opts) — byte-positional output for recipes that declare a fixed-width layout.
    • prove(recipe, { rows, seed, scenario }) — the proof report: passed, realism, privacy, receipt.
    • scoreRealism(recipe, opts), privacyScore(recipe, opts), sampleWorld(recipe, { seed }) — inspect a recipe without keeping the data.
    • deriveGraph(bytes, format) — reads a CSV, XLSX, JSON or XML file for its shape and produces a draft recipe.
    • recipeLeakFindings(recipe) — prove a recipe is data-free; this is what worklens check runs.
    • listDomainPacks(), getDomainPack(id), registerPack(pack), packRegistry(), registeredLocales() — packs. registerPack takes a locale, type or format pack, refuses one that carries code, and registered packs are process-local.
    • buildReceipt, verifyReceipt, computeAuditHash, version() — receipts (verifyReceipt recomputes the content hash) and the engine version.

    Common questions

    Is it asynchronous?

    No. The engine loads at require time and every call is synchronous, which keeps a build script or a test fixture simple. A million-row run blocks for as long as it takes.

    What shape do tables come back in?

    generateAll returns { tables: [{ entity, rows }] } where rows is an array of arrays and rows[0] is the header. generate returns one table for the first entity.