Skip to Content
Transport & Endpoints

Transport & Endpoints

@kalamdb/client, @kalamdb/orm, and @kalamdb/consumer share auth and SQL concepts, but they do not own the same transport surface.

  • @kalamdb/client owns HTTP SQL, auth endpoints, and the shared WebSocket used for realtime queries.
  • @kalamdb/orm layers Drizzle schemas, table helpers, generated schema files, and table-level live helpers on top of @kalamdb/client.
  • @kalamdb/consumer layers topic polling and ACK APIs on top of the base client, using its own worker-focused WASM bundle.

Understanding that split helps when debugging networking, tracing, and deployment issues.

Base URL

text snippetTEXT
http://localhost:2900

HTTP endpoints used by @kalamdb/client

MethodPathUsed by
POST/v1/api/sqlquery, queryWithFiles, convenience DML helpers
POST/v1/api/auth/loginlogin()
POST/v1/api/auth/refreshrefreshToken()
GET/v1/files/{namespace}/{table}/{sub}/{stored_name}FileRef.getDownloadUrl(), KalamCellValue.asFileUrl(), row.file(...).downloadUrl()

FILE download helpers return owner-scoped URLs. For user tables, the server allows the row owner to fetch the file directly; only dba and system roles can append user_id for an authorized cross-user byte download.

HTTP endpoints used by @kalamdb/consumer

MethodPathUsed by
POST/v1/api/topics/consumeconsumeBatch(), consumer().run(), runConsumer()
POST/v1/api/topics/ackack(), consumer().run(), runConsumer()

WebSocket endpoint used by @kalamdb/client

MethodPathUsed by
GET/v1/wsinternal shared-socket connection for live, liveTable, and liveEvents

@kalamdb/consumer does not add a second application-level WebSocket API. Its worker surface is topic-oriented and uses the topic HTTP endpoints.

@kalamdb/client method-to-transport mapping

SDK methodTransport
query()WASM-backed HTTP call to POST /v1/api/sql
queryWithFiles()direct multipart HTTP POST /v1/api/sql
queryOne() / queryAll()wrapper over query() plus local KalamCellValue wrapping
queryRows()wrapper over query() plus local KalamRow / bound FILE helpers
insert() / update() / delete()SQL helper methods backed by POST /v1/api/sql
executeAsUser()SQL wrapper over query()
login()direct HTTP POST /v1/api/auth/login and in-memory auth upgrade to JWT
refreshToken()HTTP POST /v1/api/auth/refresh
liveEvents()shared WebSocket low-level live event stream
live() / liveTable()shared WebSocket live-row materialization
connect()explicitly opens or restores the shared WebSocket
disconnect()closes the shared WebSocket
shutdown()disconnects, frees the WASM client, and resets SDK state

@kalamdb/orm method-to-transport mapping

SDK methodTransport
kalamDriver(client) query executiondelegated to the provided @kalamdb/client query() method
generateSchema(client)delegated to query('SHOW TABLES') and best-effort DESCRIBE <table> calls
liveTable()delegated to the provided @kalamdb/client live-row API
file() / bytes() / embedding()local Drizzle custom-column mapping only

@kalamdb/consumer method-to-transport mapping

SDK methodTransport
query() / queryOne() / queryAll()delegated to the internal @kalamdb/client SQL client
executeAsUser()delegated to the internal @kalamdb/client SQL client
login() / refreshToken()delegated to the internal @kalamdb/client auth flow
consumeBatch()HTTP POST /v1/api/topics/consume
ack()HTTP POST /v1/api/topics/ack
consumer().run()repeated consumeBatch() calls plus optional ack()
runConsumer()built on consumer().run() with retry and failure hooks
disconnect()clears topic auth cache and disconnects the internal base client

Connection and auth flow

@kalamdb/client

  1. Create the client with Auth.basic(...), Auth.jwt(...), or Auth.none() through authProvider.
  2. The client initializes lazily on first use and resolves authProvider.
  3. Optional login() exchanges basic credentials for JWT early.
  4. The first live(), liveTable(), or liveEvents() call opens the shared WebSocket automatically.
  5. query() and queryWithFiles() continue to run over HTTP.

@kalamdb/consumer

  1. Create the worker client with the same authProvider contract.
  2. Topic requests resolve auth on demand and build the correct Authorization header.
  3. consumeBatch() and ack() call the topic HTTP endpoints directly.
  4. runConsumer() keeps ack timing in the worker runtime, not in the topic transport.

The high-level TypeScript app client exposes connect() for eager connection and manual reconnect flows. Most applications can still rely on lazy WebSocket connection from the first live call.

References

Last updated on