TypeScript SDK (kalam-link)
kalam-link is the official TypeScript/JavaScript client for KalamDB. It wraps the Rust/WASM client and exposes a typed API for:
- SQL over HTTP
- live subscriptions over WebSocket
- topic consume/ack flows
- FILE column upload/download helpers
Runtime targets: modern browsers and Node.js >= 18.
Architecture in practice
The SDK is layered:
- WASM core (
KalamClient) handles most network operations and protocol behavior. - TypeScript wrapper (
KalamDBClient) provides ergonomic APIs, type-safe helpers, and subscription bookkeeping. - Utility modules (
auth.ts,types.ts,file_ref.ts,query_helpers.ts) provide safer composable building blocks.
Minimal example
import { createClient, Auth, MessageType, ChangeType } from 'kalam-link';
const client = createClient({
url: 'http://localhost:8080',
auth: Auth.basic('root', ''),
});
await client.connect();
const result = await client.query('SELECT 1 AS ok');
console.log(result.results[0]);
const unsubscribe = await client.subscribe('app.messages', (event) => {
if (event.type === MessageType.Change && event.change_type === ChangeType.Insert) {
console.log('New rows:', event.rows);
}
});
await unsubscribe();
await client.disconnect();Read this section by section
- Rust SDK
- Setup & Quick Start
- Examples & Use Cases
- Cookbook
- Authentication
- Client Lifecycle
- Querying & DML
- Realtime Subscriptions
- Topic Consumers & ACK
- FILE Columns & Uploads
- Types & Enums
- WASM Entrypoint
- Transport & Endpoints
Source-backed notes
client.query()uses WASM methodsquery/queryWithParamsdepending on params.queryWithFiles()uses directfetch/XMLHttpRequestmultipart upload to/v1/api/sql.login()andrefreshToken()update the client auth mode to JWT internally.subscribe(table, cb)is sugar forsubscribeWithSql('SELECT * FROM <table>', cb).
Last updated on