Typescript HTTP Driver

Connection

Database

class

Fields
Name Type Description

name

string

Driver Params

DriverParams

class

DriverParams: DriverParamsBasic | DriverParamsTranslated

DriverParamsBasic

class

Fields
Name Type Description

addresses

string

password

string

username

string

DriverParamsTranslated

class

Fields
Name Type Description

password

string

translatedAddresses

TranslatedAddress

username

string

TransactionOptions

class

Fields
Name Type Description

schemaLockAcquireTimeoutMillis

number

transactionTimeoutMillis

number

TransactionType

class

TransactionType: "read" | "write" | "schema"

TranslatedAddress

class

Fields
Name Type Description

external

string

internal

string

TypeDBHttpDriver

class

TypeDBHttpDriver

new TypeDBHttpDriver(params: DriverParams): TypeDBHttpDriver
Input parameters
Name Description Type

params

DriverParams

Returns

TypeDBHttpDriver

analyze

analyze( transactionId: string, query: string, analyzeOptions?: AnalyzeOptions, ): Promise<ApiResponse<AnalyzeResponse>>
Input parameters
Name Description Type

transactionId

string

query

string

analyzeOptions

AnalyzeOptions

Returns

Promise<ApiResponse<AnalyzeResponse>>

closeTransaction

closeTransaction(transactionId: string): Promise<ApiResponse>
Input parameters
Name Description Type

transactionId

string

Returns

Promise<ApiResponse>

commitTransaction

commitTransaction(transactionId: string): Promise<ApiResponse>
Input parameters
Name Description Type

transactionId

string

Returns

Promise<ApiResponse>

createDatabase

createDatabase(name: string): Promise<ApiResponse>
Input parameters
Name Description Type

name

string

Returns

Promise<ApiResponse>

createUser

createUser(username: string, password: string): Promise<ApiResponse>
Input parameters
Name Description Type

username

string

password

string

Returns

Promise<ApiResponse>

deleteDatabase

deleteDatabase(name: string): Promise<ApiResponse>
Input parameters
Name Description Type

name

string

Returns

Promise<ApiResponse>

deleteUser

deleteUser(username: string): Promise<ApiResponse>
Input parameters
Name Description Type

username

string

Returns

Promise<ApiResponse>

getCurrentUser

getCurrentUser(): Promise<ApiResponse<User>>
Returns

Promise<ApiResponse<User>>

getDatabase

getDatabase(name: string): Promise<ApiResponse<Database>>
Input parameters
Name Description Type

name

string

Returns

Promise<ApiResponse<Database>>

getDatabaseSchema

getDatabaseSchema(name: string): Promise<ApiResponse<string>>
Input parameters
Name Description Type

name

string

Returns

Promise<ApiResponse<string>>

getDatabaseTypeSchema

getDatabaseTypeSchema(name: string): Promise<ApiResponse<string>>
Input parameters
Name Description Type

name

string

Returns

Promise<ApiResponse<string>>

getDatabases

getDatabases(): Promise<ApiResponse<DatabasesListResponse>>
Returns

Promise<ApiResponse<DatabasesListResponse>>

getUser

getUser(username: string): Promise<ApiResponse<User>>
Input parameters
Name Description Type

username

string

Returns

Promise<ApiResponse<User>>

getUsers

getUsers(): Promise<ApiResponse<UsersListResponse>>
Returns

Promise<ApiResponse<UsersListResponse>>

health

health(): Promise<ApiResponse>
Returns

Promise<ApiResponse>

oneShotQuery

oneShotQuery( query: string, commit: boolean, databaseName: string, transactionType: TransactionType, transactionOptions?: TransactionOptions, queryOptions?: QueryOptions, ): Promise<ApiResponse<QueryResponse>>
Input parameters
Name Description Type

query

string

commit

boolean

databaseName

string

transactionType

TransactionType

transactionOptions

TransactionOptions

queryOptions

QueryOptions

Returns

Promise<ApiResponse<QueryResponse>>

openTransaction

openTransaction( databaseName: string, transactionType: TransactionType, transactionOptions?: TransactionOptions, ): Promise<ApiResponse<TransactionOpenResponse>>
Input parameters
Name Description Type

databaseName

string

transactionType

TransactionType

transactionOptions

TransactionOptions

Returns

Promise<ApiResponse<TransactionOpenResponse>>

query

query( transactionId: string, query: string, queryOptions?: QueryOptions, ): Promise<ApiResponse<QueryResponse>>
Input parameters
Name Description Type

transactionId

string

query

string

queryOptions

QueryOptions

Returns

Promise<ApiResponse<QueryResponse>>

rollbackTransaction

rollbackTransaction(transactionId: string): Promise<ApiResponse>
Input parameters
Name Description Type

transactionId

string

Returns

Promise<ApiResponse>

updateUser

updateUser(username: string, password: string): Promise<ApiResponse>
Input parameters
Name Description Type

username

string

password

string

Returns

Promise<ApiResponse>

version

version(): Promise<ApiResponse<VersionResponse>>
Returns

Promise<ApiResponse<VersionResponse>>

User

class

Fields
Name Type Description

username

string

Static Functions

class

isBasicParams

isBasicParams(params: DriverParams): params is DriverParamsBasic
Input parameters
Name Description Type

params

DriverParams

Returns

params is DriverParamsBasic

isTranslatedParams

isTranslatedParams(params: DriverParams): params is DriverParamsTranslated
Input parameters
Name Description Type

params

DriverParams

Returns

params is DriverParamsTranslated

remoteOrigin

remoteOrigin(params: DriverParams): string
Input parameters
Name Description Type

params

DriverParams

Returns

string

Response

Answer

class

Answer: ConceptRowAnswer | ConceptDocument

AnswerType

class

AnswerType: "ok" | "conceptRows" | "conceptDocuments"

ApiError

class

Fields
Name Type Description

code

string

message

string

ApiErrorResponse

class

Fields
Name Type Description

err

ApiError

status

number

ApiOkResponse<OK_RES>

class

Fields
Name Type Description

ok

OK_RES

ApiResponse<OK_RES>

class

ApiResponse: ApiOkResponse<OK_RES> | ApiErrorResponse

ConceptDocumentsQueryResponse

class

Fields
Name Type Description

answerType

"conceptDocuments"

answers

Object

comment

string

query

AnalyzedPipeline

queryType

QueryType

ConceptRow

class

Fields
Name Type Description

[varName: string]

Concept

ConceptRowAnswer

class

Fields
Name Type Description

data

ConceptRow

involvedBlocks

number

ConceptRowsQueryResponse

class

Fields
Name Type Description

answerType

"conceptRows"

answers

ConceptRowAnswer

comment

string

query

AnalyzedPipeline

queryType

QueryType

DatabasesListResponse

class

Fields
Name Type Description

databases

Database

Distribution

class

Distribution: "TypeDB Cluster" | "TypeDB CE"

OkQueryResponse

class

Fields
Name Type Description

answerType

"ok"

comment

string

query

AnalyzedPipeline

queryType

QueryType

SignInResponse

class

Fields
Name Type Description

token

string

TransactionOpenResponse

class

Fields
Name Type Description

transactionId

string

UsersListResponse

class

Fields
Name Type Description

users

User

VersionResponse

class

Fields
Name Type Description

distribution

Distribution

version

string

Static Functions

class

isApiError

isApiError(err: any): err is ApiError
Input parameters
Name Description Type

err

any

Returns

err is ApiError

isApiErrorResponse

isApiErrorResponse(res: ApiResponse): res is ApiErrorResponse
Input parameters
Name Description Type

res

ApiResponse

Returns

res is ApiErrorResponse

isOkResponse

isOkResponse<OK_RES>(res: ApiResponse<OK_RES>): res is ApiOkResponse<OK_RES>
Input parameters
Name Description Type

res

ApiResponse

Returns

res is ApiOkResponse<OK_RES>

Concept

Attribute

class

Fields
Name Type Description

iid

string

kind

"attribute"

type

AttributeType

value

any

valueType

ValueType

AttributeType

class

Fields
Name Type Description

kind

"attributeType"

label

string

valueType

ValueType

Concept

class

Concept: Type | Entity | Relation | Attribute | Value

ConceptDocument

class

ConceptDocument: Object

EdgeKind

class

EdgeKind:
 | "isa"
 | "has"
 | "links"
 | "sub"
 | "owns"
 | "relates"
 | "plays"
 | "isaExact"
 | "subExact"
 | "assigned"
 | "argument"

Entity

class

Fields
Name Type Description

iid

string

kind

"entity"

type

EntityType

EntityType

class

Fields
Name Type Description

kind

"entityType"

label

string

InstantiableType

class

InstantiableType: EntityType | RelationType | AttributeType

Relation

class

Fields
Name Type Description

iid

string

kind

"relation"

type

RelationType

RelationType

class

Fields
Name Type Description

kind

"relationType"

label

string

RoleType

class

Fields
Name Type Description

kind

"roleType"

label

string

ThingKind

class

ThingKind: "entity" | "relation" | "attribute"

Type

class

Type: InstantiableType | RoleType

TypeKind

class

TypeKind: "entityType" | "relationType" | "attributeType" | "roleType"

Value

class

Fields
Name Type Description

kind

"value"

value

any

valueType

ValueType

ValueKind

class

ValueKind: "value"

ValueType

class

ValueType:
 | "boolean"
 | "integer"
 | "double"
 | "decimal"
 | "date"
 | "datetime"
 | "datetime-tz"
 | "duration"
 | "string"
 | "struct"

Analyze

Static Functions

class

getVariableName

getVariableName( structure: AnalyzedPipeline | QueryStructureLegacy, variable: ConstraintVertexVariable, ): string
Input parameters
Name Description Type

structure

AnalyzedPipeline

variable

ConstraintVertexVariable

Returns

string

AnalyzeOptions

class

Fields
Name Type Description

include_plan

boolean

AnalyzedConjunction

class

Fields
Name Type Description

annotations

ConjunctionAnnotations

constraints

ConstraintAny

AnalyzedFetch

class

AnalyzedFetch:
 | { elements: AnalyzedFetch; tag: "list" }
 | { possibleFields: FetchAnnotationFieldEntry[]; tag: "object" }
 | { tag: "value"; valueTypes: ValueType[] }

AnalyzedFunction

class

Fields
Name Type Description

argumentAnnotations

VariableAnnotations

arguments

string

body

AnalyzedPipeline

returnAnnotations

VariableAnnotations

returns

FunctionReturnStructure

AnalyzedPipeline

class

Fields
Name Type Description

conjunctions

AnalyzedConjunction

outputs

string

stages

PipelineStage

variables

string

ConjunctionAnnotations

class

Fields
Name Type Description

variableAnnotations

string

ConstraintAny

class

ConstraintAny:
 | ConstraintIsa
 | ConstraintIsaExact
 | ConstraintHas
 | ConstraintLinks
 | ConstraintSub
 | ConstraintSubExact
 | ConstraintOwns
 | ConstraintRelates
 | ConstraintPlays
 | ConstraintExpression
 | ConstraintFunction
 | ConstraintComparison
 | ConstraintIs
 | ConstraintIid
 | ConstraintKind
 | ConstraintValue
 | ConstraintLabel
 | ConstraintOr
 | ConstraintNot
 | ConstraintTry

ConstraintComparison

class

Fields
Name Type Description

comparator

string

lhs

ConstraintVertexVariable

rhs

ConstraintVertexVariable

tag

"comparison"

textSpan

ConstraintSpan

ConstraintExpression

class

Fields
Name Type Description

arguments

ConstraintVertexVariable

assigned

ConstraintVertexVariable

tag

"expression"

text

string

textSpan

ConstraintSpan

ConstraintFunction

class

Fields
Name Type Description

arguments

ConstraintVertexVariable

assigned

ConstraintVertexVariable

name

string

tag

"functionCall"

textSpan

ConstraintSpan

ConstraintHas

class

Fields
Name Type Description

attribute

ConstraintVertexVariable

owner

ConstraintVertexVariable

tag

"has"

textSpan

ConstraintSpan

ConstraintIid

class

Fields
Name Type Description

concept

ConstraintVertexVariable

iid

string

tag

"iid"

textSpan

ConstraintSpan

ConstraintIs

class

Fields
Name Type Description

lhs

ConstraintVertexVariable

rhs

ConstraintVertexVariable

tag

"is"

textSpan

ConstraintSpan

ConstraintIsa

class

Fields
Name Type Description

instance

ConstraintVertexVariable

tag

"isa"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintIsaExact

class

Fields
Name Type Description

instance

ConstraintVertexVariable

tag

"isa!"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintKind

class

Fields
Name Type Description

kind

string

tag

"kind"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintLabel

class

Fields
Name Type Description

label

string

tag

"label"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

class

Fields
Name Type Description

player

ConstraintVertexVariable

relation

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"links"

textSpan

ConstraintSpan

ConstraintNot

class

Fields
Name Type Description

conjunction

number

tag

"not"

ConstraintOr

class

Fields
Name Type Description

branches

number

tag

"or"

ConstraintOwns

class

Fields
Name Type Description

attribute

ConstraintVertexVariable

owner

ConstraintVertexVariable

tag

"owns"

textSpan

ConstraintSpan

ConstraintPlays

class

Fields
Name Type Description

player

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"plays"

textSpan

ConstraintSpan

ConstraintRelates

class

Fields
Name Type Description

relation

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"relates"

textSpan

ConstraintSpan

ConstraintSub

class

Fields
Name Type Description

subtype

ConstraintVertexVariable

supertype

ConstraintVertexVariable

tag

"sub"

textSpan

ConstraintSpan

ConstraintSubExact

class

Fields
Name Type Description

subtype

ConstraintVertexVariable

supertype

ConstraintVertexVariable

tag

"sub!"

textSpan

ConstraintSpan

ConstraintTry

class

Fields
Name Type Description

conjunction

number

tag

"try"

ConstraintValue

class

Fields
Name Type Description

attributeType

ConstraintVertexVariable

tag

"value"

textSpan

ConstraintSpan

valueType

string

ConstraintSpan

class

Fields
Name Type Description

begin

number

end

number

ConstraintVertexAny

class

ConstraintVertexAny:
 | ConstraintVertexVariable
 | ConstraintVertexLabel
 | ConstraintVertexValue
 | ConstraintVertexNamedRole

ConstraintVertexLabel

class

Fields
Name Type Description

tag

"label"

type

Type

ConstraintVertexNamedRole

class

Fields
Name Type Description

name

string

tag

"namedRole"

variable

string

ConstraintVertexValue

class

Fields
Name Type Description

kind

"value"

tag

"value"

value

any

valueType

ValueType

ConstraintVertexVariable

class

Fields
Name Type Description

id

string

tag

"variable"

FetchAnnotationFieldEntry

class

FetchAnnotationFieldEntry: AnalyzedFetch & { key: string }

FunctionReturnStructure

class

FunctionReturnStructure:
 | {
 selector: FunctionSingleReturnSelector;
 tag: "single";
 variables: VariableId[];
 }
 | { tag: "stream"; variables: VariableId[] }
 | { tag: "check" }
 | { reducers: Reducer[]; tag: "reduce" }

FunctionSingleReturnSelector

class

FunctionSingleReturnSelector: "first" | "last"

PipelineStage

class

PipelineStage:
 | { block: ConjunctionIndex; tag: "match" }
 | { block: ConjunctionIndex; tag: "insert" }
 | {
 block: ConjunctionIndex;
 deletedVariables: VariableId[];
 tag: "delete";
 }
 | { block: ConjunctionIndex; tag: "put" }
 | { block: ConjunctionIndex; tag: "update" }
 | { tag: "select"; variables: VariableId[] }
 | {
 tag: "sort";
 variables: { tag: "Ascending" | "Descending"; variable: VariableId }[];
 }
 | { tag: "require"; variables: VariableId }
 | { offset: number; tag: "offset" }
 | { limit: number; tag: "limit" }
 | { tag: "distinct" }
 | {
 groupby: VariableId[];
 reducers: { assigned: VariableId; reducer: Reducer }[];
 tag: "reduce";
 }

Reducer

class

Fields
Name Type Description

arguments

VariableId

reducer

string

VariableAnnotations

class

VariableAnnotations: { isOptional: boolean } & (
 | { annotations: Type[]; tag: "instance" }
 | { annotations: Type[]; tag: "type" }
 | { tag: "value"; valueTypes: ValueType[] }
 )

VariableId

class

VariableId: string

VariableInfo

class

Fields
Name Type Description

name

string