@chimp-labs/keel/sdk exposes every Keel primitive through standard TypeScript: Promise<T>, T | undefined, AsyncIterable<T> with AbortSignal, and DisposableHandle (stop() and Symbol.asyncDispose).
Bound resources and k.* builders
Pass your descriptors once to createKeel({ resources }), or bind them locally with keel.bind(desc):
import { createKeel, k } from "@chimp-labs/keel/sdk"
const resources = {
users: k.table("users", {
id: k.uuid().primaryKey(),
email: k.text().unique(),
bio: k.text().nullable(),
createdAt: k.datetime().defaultNow(),
}),
orderPlaced: k.topic("orders.placed", k.object({ orderId: k.string() })),
}
const keel = await createKeel({
backend: "postgres", // "memory" | "sqlite" | "postgres" | "surreal"
postgres: { fromEnv: true }, // or { url: "postgresql://keel:[email protected]:5439/keel" }
// Or SurrealDB 4:
// backend: "surreal",
// surreal: { fromEnv: true },
resources,
ensureAll: true,
})
// Bound handles work directly on `keel`, `tx`, and `session`:
await keel.transaction(async (tx) => {
const user = await tx.users.insert({ email: "[email protected]" })
await tx.orderPlaced.enqueueOutbox({ orderId: user.id })
})
Standard Schema v1 (Zod, Valibot, ArkType)
Every k.* builder accepts Effect Schema definitions, k.* schema helpers, or any Standard Schema v1 (~standard) validator with no extra dependencies.
Direct Effect access
keel wraps a single ManagedRuntime, and k.* builders produce native Keel descriptors. You can drop into Effect anywhere via keel.runEffect(...) or keel.runtime. Both share the same PostgreSQL 17 pool and LISTEN client, SurrealDB 4 WebSocket, SQLite handle, S3 client, and Tracer.