Reference·JavaScript · @sascom/jsclientJavaScript

Client

Class in @sascom/jsclient.

API catalogue · @sascom/jsclient · Class

TypeScript#
class Client

Members#

Member Kind Description
constructor Method
auth Property The login of this client, null before a login; change it with setAuth()
status Property
addConnectionRestoredListener Method
download Method Starts a browser download of such a stream
followJob Method Follows a job through the app's follow task (input job_uuid): a live task, it attaches again after a reconnect.
getDownloadUrl Method The URL that downloads a stream the server returned (a descriptor from a task's response, or a URL)
getServerInfo Method
getTask Method
isExpired Method
onNodeChanged Method When a reconnect lands on another node, or on a restarted one: tasks that ran there were lost (TASK_LOST_NODE_CHANGED).
post Method
post Method
post Method
setAuth Method
setDefaultErrorHandler Method Where the error of a task without an error callback goes; the client calls its error(error, request, response)
validateAndSetAuth Method

constructor#

TypeScript#
constructor(clientFactory: ClientFactory, settings: ClientFactorySettings)

Parameters#

Name Type Description
clientFactory ClientFactory
settings ClientFactorySettings

auth#

TypeScript#
public readonly auth: AuthToken | null

The login of this client, null before a login; change it with setAuth()

status#

TypeScript#
public readonly status: "closed" | "new" | "open"

addConnectionRestoredListener#

TypeScript#
public addConnectionRestoredListener(listener: () => void): void

Parameters#

Name Type Description
listener () => void

download#

TypeScript#
public download(streamDescriptor: string | { filename?: string; type: string; [key: string]: unknown }): void

Starts a browser download of such a stream

Parameters#

Name Type Description
streamDescriptor string | { filename?: string; type: string; [key: string]: unknown }

followJob#

TypeScript#
public followJob(projectName: string, taskName: string, jobId: string, input?: Record<string, unknown>): Task

Follows a job through the app's follow task (input job_uuid): a live task, it attaches again after a reconnect.

Parameters#

Name Type Description
projectName string
taskName string
jobId string
input Record<string, unknown>

getDownloadUrl#

TypeScript#
public getDownloadUrl(streamDescriptor: string | { filename?: string; type: string; [key: string]: unknown }): string

The URL that downloads a stream the server returned (a descriptor from a task's response, or a URL)

Parameters#

Name Type Description
streamDescriptor string | { filename?: string; type: string; [key: string]: unknown }

getServerInfo#

TypeScript#
public getServerInfo(): ServerInfo | null

getTask#

TypeScript#
public getTask(id: string, name: string, nodeId?: string): Task

Parameters#

Name Type Description
id string
name string
nodeId string

isExpired#

TypeScript#
public isExpired(auth: AuthToken): boolean

Parameters#

Name Type Description
auth AuthToken

onNodeChanged#

TypeScript#
public onNodeChanged(listener: (current: ServerInfo, previous: ServerInfo | null) => void): void

When a reconnect lands on another node, or on a restarted one: tasks that ran there were lost (TASK_LOST_NODE_CHANGED).

Parameters#

Name Type Description
listener (current: ServerInfo, previous: ServerInfo | null) => void

post#

TypeScript#
public post(projectName: string, taskName: string, input?: unknown, auth?: AuthToken): Task

Parameters#

Name Type Description
projectName string
taskName string
input unknown
auth AuthToken

post#

TypeScript#
public post(projectName: string, input?: unknown, auth?: AuthToken): Task

Parameters#

Name Type Description
projectName string
input unknown
auth AuthToken

post#

TypeScript#
public post(projectName: string, taskName: string, input?: unknown, auth?: AuthToken): Task

Parameters#

Name Type Description
projectName string
taskName string
input unknown
auth AuthToken

setAuth#

TypeScript#
public setAuth(auth: AuthToken): Promise<void>

Parameters#

Name Type Description
auth AuthToken

setDefaultErrorHandler#

TypeScript#
public setDefaultErrorHandler(defaultErrorHandler: { error: (error: unknown, request: unknown, response: unknown) => void }): void

Where the error of a task without an error callback goes; the client calls its error(error, request, response)

Parameters#

Name Type Description
defaultErrorHandler { error: (error: unknown, request: unknown, response: unknown) => void }

validateAndSetAuth#

TypeScript#
public validateAndSetAuth(auth: AuthToken): Promise<void>

Parameters#

Name Type Description
auth AuthToken