Skip to content

TypeScript client

Package: @eelden/client (clients/typescript).

Export paths

ImportRole
@eelden/clienteelden tagged template, EeldenQuery, EeldenParam, EeldenExecutor
@eelden/client/moneyMoney class
@eelden/client/shapeTypecheck JSON contract (EeldenType, EeldenShape, decode)
@eelden/client/codegenEscape-hatch tagged-template codegen (generateTypes)
@eelden/client/named-codegenNamed-query codegen (generateNamedQueryModules)
@eelden/client/configeelden.config.json parse + glob helper (parseConfig, DEFAULT_CONFIG)

CLI bin: eelden-codegen (also registered as weft-codegen for one release).

Deprecated weft* aliases (weft, WeftQuery, WeftExecutor, WeftParam, WeftShape, …) remain for one release — prefer the eelden / Eelden* names.

Preferred path — named queries

  1. Write schemas + named queries as .eel
  2. Run eelden-codegen --config eelden.config.json
  3. Import generated functions; pass them to an EeldenExecutor
ts
import { GetPaid } from "./generated/users.queries";
import { Money } from "@eelden/client/money";

const rows = await exec.execute(
  GetPaid({ min_balance: Money.minor(50_00n, "USD") }),
);
// rows typed from the query's select shape

Money constructors that exist today:

ts
import { Money } from "@eelden/client/money";

Money.minor(4999n, "USD");     // minor units (cents)
Money.parse("49.99", "USD");   // decimal string only — not a number

There is no Money.usd. Cross-currency arithmetic is rejected at runtime — same doctrine as the language.

See Named queries and Examples (examples/eelden.config.json).

Config

eelden.config.json fields (@eelden/client/config):

FieldMeaningDefault
schemasSchema .eel paths (merged in order)["schemas.eel"]
queriesGlob(s) for named-query .eel files["src/queries/**/*.eel"]
outDirGenerated TypeScript modules"src/generated"
moneyImportOptional Money import path override@eelden/client/money

Codegen shells out to the eelden binary (typecheck-queries). Set EELDEN_BINARY if it is not on PATH. WEFT_BINARY is deprecated (honored for one release).

Escape hatch

ts
import { eelden } from "@eelden/client";
import type { EeldenExecutor, EeldenQuery } from "@eelden/client";

const q: EeldenQuery = eelden`users |> select { id, name }`;
// await exec.execute(q)

Tagged-template codegen (legacy):

bash
eelden-codegen <schemas.eel> <output.ts> <src1.ts> [src2.ts ...]

Use for one-offs and tests — not day-to-day app queries. Until a build plugin lands, the bare eelden…`` template returns EeldenQuery with result types defaulting to unknown[] unless escape-hatch codegen wraps them.

EeldenExecutor

ts
interface EeldenExecutor {
  execute<TRows>(
    q: EeldenQuery<TRows>,
    opts?: { tenant?: string },
  ): Promise<TRows[]>;
  atomic<TRowses extends unknown[]>(
    qs: { [K in keyof TRowses]: EeldenQuery<TRowses[K]> },
    opts?: { tenant?: string },
  ): Promise<TRowses>;
}

Transport reality

EeldenExecutor is the contract. A shipping HTTP/IPC driver is not in the package yet. Today you:

  • drive the engine via eelden run / Studio / wasm ABI, or
  • implement EeldenExecutor against eelden serve's /query for experiments.

See Status.

Pre-alpha. Local-first. Stdlib-only Rust engine. Tenant concerns shifted left into the database.