Skip to Content

Types & Enums

kalam-link exports both runtime enums and rich TypeScript types.

Runtime enums

import { MessageType, ChangeType } from 'kalam-link';
enum MessageType { SubscriptionAck = 'subscription_ack', InitialDataBatch = 'initial_data_batch', Change = 'change', Error = 'error', } enum ChangeType { Insert = 'insert', Update = 'update', Delete = 'delete', }

Auth types

type AuthCredentials = | { type: 'basic'; username: string; password: string } | { type: 'jwt'; token: string } | { type: 'none' };

ClientOptions (construction)

createClient({ ... }) accepts a ClientOptions object. Common fields:

  • url: string — server base URL
  • auth?: AuthCredentials — static auth (Basic/JWT/none)
  • authProvider?: () => Promise<AuthCredentials> — recommended for refreshable JWTs
  • autoConnect?: boolean — default true; when enabled, subscription calls connect automatically
  • pingIntervalMs?: number — default 30000; WebSocket ping interval
  • disableCompression?: boolean — dev-only debugging (?compress=false)
  • wasmUrl?: string | BufferSource — override WASM loading

Query response model

interface QueryResponse { status: 'success' | 'error'; results?: QueryResult[]; took?: number; error?: ErrorDetail; } interface QueryResult { schema?: SchemaField[]; rows?: unknown[][]; row_count: number; message?: string; }

Subscription and consumer types

  • ServerMessage
  • SubscriptionOptions
  • SubscriptionCallback
  • ConsumeRequest
  • ConsumeResponse
  • ConsumeMessage
  • ConsumeContext
  • ConsumerHandle
  • AckResponse

ServerMessage from generated declarations includes:

  • auth events (auth_success, auth_error)
  • subscription events (subscription_ack, initial_data_batch, change, error)

Username branded type

types.ts defines a branded Username:

type Username = string & { readonly __brand: unique symbol }; function Username(value: string): Username;

Use this in consumer pipelines when you want stricter domain typing.

Row parsing helper

import { parseRows } from 'kalam-link'; interface UserRow { id: string; name: string } const rows = parseRows<UserRow>(response);

Type-only imports

Prefer import type for large type sets in app code:

import type { QueryResponse, ServerMessage, ConsumeRequest } from 'kalam-link';
Last updated on