Typescript HTTP Driver

Connection

Database

Fields
Name Type Description

name

string

Driver Params

DriverParams

DriverParams: DriverParamsBasic | DriverParamsTranslated

DriverParamsBasic

Fields
Name Type Description

addresses

string

password

string

username

string

DriverParamsTranslated

Fields
Name Type Description

password

string

translatedAddresses

TranslatedAddress

username

string

TransactionOptions

Fields
Name Type Description

schemaLockAcquireTimeoutMillis

number

transactionTimeoutMillis

number

TransactionType

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

TranslatedAddress

Fields
Name Type Description

external

string

internal

string

TypeDBHttpDriver

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

Fields
Name Type Description

username

string

Static Functions

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

Answer: ConceptRowAnswer | ConceptDocument

AnswerType

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

ApiError

Fields
Name Type Description

code

string

message

string

ApiErrorResponse

Fields
Name Type Description

err

ApiError

status

number

ApiOkResponse<OK_RES>

Fields
Name Type Description

ok

OK_RES

ApiResponse<OK_RES>

ApiResponse: ApiOkResponse<OK_RES> | ApiErrorResponse

ConceptDocumentsQueryResponse

Fields
Name Type Description

answerType

"conceptDocuments"

answers

Object

comment

string

query

AnalyzedPipeline

queryType

QueryType

ConceptRow

Fields
Name Type Description

[varName: string]

Concept

ConceptRowAnswer

Fields
Name Type Description

data

ConceptRow

involvedBlocks

number

ConceptRowsQueryResponse

Fields
Name Type Description

answerType

"conceptRows"

answers

ConceptRowAnswer

comment

string

query

AnalyzedPipeline

queryType

QueryType

DatabasesListResponse

Fields
Name Type Description

databases

Database

Distribution

Distribution: "TypeDB Cluster" | "TypeDB CE"

OkQueryResponse

Fields
Name Type Description

answerType

"ok"

comment

string

query

AnalyzedPipeline

queryType

QueryType

SignInResponse

Fields
Name Type Description

token

string

TransactionOpenResponse

Fields
Name Type Description

transactionId

string

UsersListResponse

Fields
Name Type Description

users

User

VersionResponse

Fields
Name Type Description

distribution

Distribution

version

string

Static Functions

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

Fields
Name Type Description

iid

string

kind

"attribute"

type

AttributeType

value

any

valueType

ValueType

AttributeType

Fields
Name Type Description

kind

"attributeType"

label

string

valueType

ValueType

Concept

Concept: Type | Entity | Relation | Attribute | Value

ConceptDocument

ConceptDocument: Object

EdgeKind

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

Entity

Fields
Name Type Description

iid

string

kind

"entity"

type

EntityType

EntityType

Fields
Name Type Description

kind

"entityType"

label

string

InstantiableType

InstantiableType: EntityType | RelationType | AttributeType

Relation

Fields
Name Type Description

iid

string

kind

"relation"

type

RelationType

RelationType

Fields
Name Type Description

kind

"relationType"

label

string

RoleType

Fields
Name Type Description

kind

"roleType"

label

string

ThingKind

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

Type

Type: InstantiableType | RoleType

TypeKind

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

Value

Fields
Name Type Description

kind

"value"

value

any

valueType

ValueType

ValueKind

ValueKind: "value"

ValueType

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

Analyze

Static Functions

getVariableName

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

structure

AnalyzedPipeline

variable

ConstraintVertexVariable

Returns

string

AnalyzeOptions

Fields
Name Type Description

include_plan

boolean

AnalyzedConjunction

Fields
Name Type Description

annotations

ConjunctionAnnotations

constraints

ConstraintAny

AnalyzedFetch

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

AnalyzedFunction

Fields
Name Type Description

argumentAnnotations

VariableAnnotations

arguments

string

body

AnalyzedPipeline

returnAnnotations

VariableAnnotations

returns

FunctionReturnStructure

AnalyzedPipeline

Fields
Name Type Description

conjunctions

AnalyzedConjunction

outputs

string

stages

PipelineStage

variables

string

ConjunctionAnnotations

Fields
Name Type Description

variableAnnotations

string

ConstraintAny

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

ConstraintComparison

Fields
Name Type Description

comparator

string

lhs

ConstraintVertexVariable

rhs

ConstraintVertexVariable

tag

"comparison"

textSpan

ConstraintSpan

ConstraintExpression

Fields
Name Type Description

arguments

ConstraintVertexVariable

assigned

ConstraintVertexVariable

tag

"expression"

text

string

textSpan

ConstraintSpan

ConstraintFunction

Fields
Name Type Description

arguments

ConstraintVertexVariable

assigned

ConstraintVertexVariable

name

string

tag

"functionCall"

textSpan

ConstraintSpan

ConstraintHas

Fields
Name Type Description

attribute

ConstraintVertexVariable

owner

ConstraintVertexVariable

tag

"has"

textSpan

ConstraintSpan

ConstraintIid

Fields
Name Type Description

concept

ConstraintVertexVariable

iid

string

tag

"iid"

textSpan

ConstraintSpan

ConstraintIs

Fields
Name Type Description

lhs

ConstraintVertexVariable

rhs

ConstraintVertexVariable

tag

"is"

textSpan

ConstraintSpan

ConstraintIsa

Fields
Name Type Description

instance

ConstraintVertexVariable

tag

"isa"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintIsaExact

Fields
Name Type Description

instance

ConstraintVertexVariable

tag

"isa!"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintKind

Fields
Name Type Description

kind

string

tag

"kind"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

ConstraintLabel

Fields
Name Type Description

label

string

tag

"label"

textSpan

ConstraintSpan

type

ConstraintVertexVariable

Fields
Name Type Description

player

ConstraintVertexVariable

relation

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"links"

textSpan

ConstraintSpan

ConstraintNot

Fields
Name Type Description

conjunction

number

tag

"not"

ConstraintOr

Fields
Name Type Description

branches

number

tag

"or"

ConstraintOwns

Fields
Name Type Description

attribute

ConstraintVertexVariable

owner

ConstraintVertexVariable

tag

"owns"

textSpan

ConstraintSpan

ConstraintPlays

Fields
Name Type Description

player

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"plays"

textSpan

ConstraintSpan

ConstraintRelates

Fields
Name Type Description

relation

ConstraintVertexVariable

role

ConstraintVertexVariable

tag

"relates"

textSpan

ConstraintSpan

ConstraintSub

Fields
Name Type Description

subtype

ConstraintVertexVariable

supertype

ConstraintVertexVariable

tag

"sub"

textSpan

ConstraintSpan

ConstraintSubExact

Fields
Name Type Description

subtype

ConstraintVertexVariable

supertype

ConstraintVertexVariable

tag

"sub!"

textSpan

ConstraintSpan

ConstraintTry

Fields
Name Type Description

conjunction

number

tag

"try"

ConstraintValue

Fields
Name Type Description

attributeType

ConstraintVertexVariable

tag

"value"

textSpan

ConstraintSpan

valueType

string

ConstraintSpan

Fields
Name Type Description

begin

number

end

number

ConstraintVertexAny

ConstraintVertexAny:
 | ConstraintVertexVariable
 | ConstraintVertexLabel
 | ConstraintVertexValue
 | ConstraintVertexNamedRole

ConstraintVertexLabel

Fields
Name Type Description

tag

"label"

type

Type

ConstraintVertexNamedRole

Fields
Name Type Description

name

string

tag

"namedRole"

variable

string

ConstraintVertexValue

Fields
Name Type Description

kind

"value"

tag

"value"

value

any

valueType

ValueType

ConstraintVertexVariable

Fields
Name Type Description

id

string

tag

"variable"

FetchAnnotationFieldEntry

FetchAnnotationFieldEntry: AnalyzedFetch & { key: string }

FunctionReturnStructure

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

FunctionSingleReturnSelector

FunctionSingleReturnSelector: "first" | "last"

PipelineStage

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

Fields
Name Type Description

arguments

VariableId

reducer

string

VariableAnnotations

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

VariableId

VariableId: string

VariableInfo

Fields
Name Type Description

name

string