JavaScript Client Type Definitions

Open inAnthropic

The terminusdb package exports its reusable type definitions from the package root, so they can be imported alongside the client and referenced in annotations, casts, and generic type arguments. The same types are also reachable under the typedef namespace.

Example: TypeScript
import TerminusClient, {
  type WOQLQueryResult,
  type WithDataVersion,
} from "terminusdb"

const wrapped: WithDataVersion<WOQLQueryResult<MyRow>> = response

This page documents the shapes the client defines. It describes compile-time types only — none of them are validated at runtime, and fields marked optional may simply be absent on a given response.

Result shapes

TypeDefinitionUsed by
WOQLQueryResult<T>{ bindings: T[]; inserts?: number; deletes?: number; transaction_retry_count?: number }client.query() — one bindings row per solution
WithDataVersion<T>{ result: T; dataVersion: string }Any call with getDataVersion: true
APIErrorBody{ [key: string]: any } — common fields: @type, api:status, api:message, api:error (whose own @type identifies the error, e.g. api:DocumentNotFound)err.data on rejected calls
TerminusDBError{ message: string; name?: string; stack?: string; data?: APIErrorBody; status?: number }All rejected promises from dispatch; client-side validation failures are plain Errors without data/status

Document interface parameters

TypeUsed byPurpose
DocParamsGetgetDocument, queryDocumentGET parameters: query, graph_type, type, id, prefixed, minimized, unfold, skip, count, as_list
DocParamsPostaddDocumentPOST parameters: raw_json, graph_type, full_replace, overwrite, merge_repeats
DocParamsPutupdateDocumentPUT parameters: raw_json, create, graph_type, merge_repeats
DocParamsDeletedeleteDocumentDELETE parameters: graph_type, id, nuke

Connection and resource types

TypeDefinitionPurpose
ParamsObjConnection parametersnew WOQLClient(url, params)
CredentialObj{ type: 'basic' | 'jwt' | 'apikey'; user?: string | boolean; key: string }localAuth, remoteAuth credentials
DbDetails{ label: string; comment?: string; public?: boolean; schema?: boolean }createDatabase details
DbDocDatabase record shapegetDatabase, getDatabases results
RolesObj{ agent_name: string; database_name?: string; organization_name?: string; actions?: array; invitation?: string }Role management calls
NamedResourceData{ filename: string; data: Buffer | string }CSV resources supplied to query()

Enumerations

TypeValues
GraphType"instance" | "schema"
GraphRef"schema/main" | "instance/main" | string
ResourceType"commits" | "meta" | "branch" | "ref" | "repo" | "db"
RepoType"local" | "remote"
ScopeType"database" | "organization"
ActionTypeAPI actions: 'graph', 'db', 'clone', 'triples', 'woql', 'fetch', 'pull', 'rebase', 'branch', 'reset', 'push', 'squash'
DataFormatObj{ type?: "csv" | "turtle"; format_header?: string }
FuntionTypeWOQL update verbs: "add_quad", "delete_quad", "add_triple", "delete_triple", "quad", "triple"

Query-building types

TypeDefinitionPurpose
LocalizeResult[function(WOQLQuery=): WOQLQuery, Object.<string, Var>]Return of WOQLQuery.localize() — localizing wrapper plus unique variables
WOQLJsonanyJSON-LD representation of a WOQL query, as produced by query.json()

The generated declaration files under dist/typescript/ in the terminusdb package are the source of truth; this page mirrors their intent for convenience. The TypeScript guide shows how the generic methods consume these types.

Was this helpful?