@lucidtech/las-sdk-core / Exports
Browser version
$ yarn add @lucidtech/las-sdk-browser$ npm install @lucidtech/las-sdk-browser
Node version
$ yarn add @lucidtech/las-sdk-node$ npm install @lucidtech/las-sdk-node
import { Client } from '@lucidtech/las-sdk-core';import { ClientCredentials } from '@lucidtech/las-sdk-node';const credentials = new ClientCredentials('<apiEndpoint>', '<apiKey>', '<clientId>', '<clientSecret>', '<authEndpoint>');const client = new Client(credentials);const content = '<read image content>'client.createDocument(content, 'image/jpeg').then(documentResponse => {console.log(documentResponse);}).catch(error => {console.log(error);})
Install dependencies
$ npm install && npm run upgrade-lucidtech
Build
$ npm run build
Run tests
$ npm run test test
@lucidtech/las-sdk-core / Exports / client / Client
client.Client
A high-level http client for communicating with the Lucidtech REST API
+ new Client(credentials
: Credentials): Client
Parameters:
credentials
Credentials
Returns: Client
• credentials: Credentials
▸ createAsset(content
: string): Promise<Asset>
Creates an asset handle, calls the POST /assets endpoint.
Parameters:
content
string Content to POST (base64-encoded string | Buffer)
Returns: Promise<Asset>
Asset response from REST API
▸ createBatch(options
: CreateBatchOptions): Promise<Batch>
Creates a batch, calls the POST /batches endpoint.
Parameters:
options
CreateBatchOptions
Returns: Promise<Batch>
Batch response from REST API
▸ createDocument(content
: string | Buffer, contentType
: ContentType, options?
: CreateDocumentOptions): Promise<LasDocument>
Creates a document handle, calls the POST /documents endpoint.
Parameters:
content
string | Buffer Content to POST (base64 string | Buffer)
contentType
ContentType MIME type for the document handle
options?
CreateDocumentOptions -
Returns: Promise<LasDocument>
Document response from REST API
▸ createPrediction(documentId
: string, modelId
: string, options?
: CreatePredictionsOptions): Promise<PredictionResponse>
Create a prediction on a document using specified model, calls the POST /predictions endpoint.
Parameters:
documentId
string Id of the document to run inference and create a prediction on
modelId
string Id of the model to use for inference
options?
CreatePredictionsOptions -
Returns: Promise<PredictionResponse>
Predicion response from REST API
▸ createSecret(data
: Record, options?
: CreateSecretOptions): Promise<Secret>
Creates an secret handle, calls the POST /secrets endpoint.
Parameters:
data
Record Object containing the data you want to keep secret
options?
CreateSecretOptions -
Returns: Promise<Secret>
Secret response from REST API
▸ createTransition(transitionType
: TransitionType, options?
: CreateTransitionOptions): Promise<Transition>
Creates a transition handle, calls the POST /transitions endpoint.
Parameters:
transitionType
TransitionType Type of transition "docker"|"manual"
options?
CreateTransitionOptions -
Returns: Promise<Transition>
Transition response from REST API
▸ createUser(email
: string, data?
: CreateUserOptions): Promise<User>
Creates a new user, calls the POST /users endpoint.
Parameters:
email
string Email to the new user
data?
CreateUserOptions -
Returns: Promise<User>
User response from REST API
▸ createWorkflow(name
: string, specification
: WorkflowSpecification, options?
: CreateWorkflowOptions): Promise<Workflow>
Creates a new workflow, calls the POST /workflows endpoint.
Parameters:
name
string Name of the workflow
specification
WorkflowSpecification Specification of the workflow
options?
CreateWorkflowOptions -
Returns: Promise<Workflow>
Workflow response from REST API
▸ deleteDocuments(options?
: DeleteDocumentOptions): Promise<LasDocumentList>
Delete documents with the provided consentId, calls the DELETE /documents endpoint. Will delete all documents when no consentId is provided.
Parameters:
options?
DeleteDocumentOptions
Returns: Promise<LasDocumentList>
Documents response from REST API
▸ deleteTransition(transitionId
: string): Promise<Transition>
Delete the transition with the provided transitionId, calls the DELETE /transitions/{transitionId} endpoint. Will fail if transition is in use by one or more workflows.
Parameters:
transitionId
string Id of the transition
Returns: Promise<Transition>
Transition response from REST API
▸ deleteUser(userId
: string): Promise<User>
Delete the user with the provided user_id, calls the DELETE /users/{userId} endpoint.
Parameters:
userId
string Id of the user
Returns: Promise<User>
User response from REST API
▸ deleteWorkflow(workflowId
: string): Promise<Workflow>
Delete the workflow with the provided workflowId, calls the DELETE /workflows/{workflowId} endpoint.
Parameters:
workflowId
string Id of the workflow
Returns: Promise<Workflow>
Workflow response from REST API
▸ deleteWorkflowExecution(workflowId
: string, executionId
: string): Promise<WorkflowExecution>
Deletes the execution with the provided execution_id from workflow_id, calls the DELETE /workflows/{workflowId}/executions/{executionId} endpoint.
Parameters:
workflowId
string Id of the workflow
executionId
string Id of the execution
Returns: Promise<WorkflowExecution>
WorkflowExecution response from REST API
▸ executeTransition(transitionId
: string): Promise<TransitionExecution>
Start executing a manual transition, calls the POST /transitions/{transitionId}/executions endpoint.
Parameters:
transitionId
string Id of the transition
Returns: Promise<TransitionExecution>
Transition execution response from REST API
▸ executeWorkflow(workflowId
: string, input
: object): Promise<WorkflowExecution>
Start a workflow execution, calls the POST /workflows/{workflowId}/executions endpoint.
Parameters:
workflowId
string Id of the workflow
input
object Input to the first step of the workflow
Returns: Promise<WorkflowExecution>
Workflow execution response from REST API
▸ getAsset(assetId
: string): Promise<Asset>
Get asset from the REST API, calls the GET /assets/{assetId} endpoint.
Parameters:
assetId
string Id of the asset
Returns: Promise<Asset>
Asset response from REST API
▸ getDocument(documentId
: string): Promise<LasDocument>
Get document from the REST API, calls the GET /documents/{documentId} endpoint.
Parameters:
documentId
string Id of the document
Returns: Promise<LasDocument>
Document response from REST API
▸ getLog(logId
: string): Promise<Log>
Get log, calls the GET /logs/{logId} endpoint.
Parameters:
logId
string Id of the log
Returns: Promise<Log>
Log response from REST API
▸ getTransition(transitionId
: string): Promise<Transition>
Get the transition with the provided transitionId, calls the GET /transitions/{transitionId} endpoint.
Parameters:
transitionId
string Id of the transition
Returns: Promise<Transition>
Transition response from REST API
▸ getUser(userId
: string): Promise<User>
Get information about a specific user, calls the GET /users/{user_id} endpoint.
Parameters:
userId
string Id of the user
Returns: Promise<User>
User response from REST API
▸ getWorkflow(workflowId
: string): Promise<Workflow>
Get the workflow with the provided workflowId, calls the GET /workflows/{workflowId} endpoint.
Parameters:
workflowId
string Id of the workflow
Returns: Promise<Workflow>
Workflow response from REST API
▸ listAssets(options?
: PaginationOptions): Promise<AssetList>
List assets available, calls the GET /assets endpoint.
Parameters:
options?
PaginationOptions
Returns: Promise<AssetList>
Assets response from REST API without the content of each asset
▸ listDocuments(options?
: ListDocumentsOptions): Promise<LasDocumentList>
List documents available for inference, calls the GET /documents endpoint.
Parameters:
options?
ListDocumentsOptions
Returns: Promise<LasDocumentList>
Documents response from REST API
▸ listModels(options?
: PaginationOptions): Promise<ModelList>
List models available, calls the GET /models endpoint.
Parameters:
options?
PaginationOptions
Returns: Promise<ModelList>
Models response from the REST API
▸ listPredictions(options?
: PaginationOptions): Promise<PredictionList>
Parameters:
options?
PaginationOptions
Returns: Promise<PredictionList>
▸ listSecrets(options?
: PaginationOptions): Promise<SecretList>
List secrets available, calls the GET /secrets endpoint.
Parameters:
options?
PaginationOptions
Returns: Promise<SecretList>
Secrets response from REST API without the username of each secret
▸ listTransitionExecutions(transitionId
: string, options?
: TransitionExecutionListOptions): Promise<TransitionExecutionList>
List executions in a transition, calls the GET /transitions/{transitionId}/executions endpoint.
Parameters:
transitionId
string Id of the transition
options?
TransitionExecutionListOptions -
Returns: Promise<TransitionExecutionList>
Transition executions responses from REST API
▸ listTransitions(options?
: ListTransitionOptions): Promise<TransitionList>
List transitions, calls the GET /transitions endpoint.
Parameters:
options?
ListTransitionOptions
Returns: Promise<TransitionList>
Transitions response from REST API
▸ listUsers(options?
: PaginationOptions): Promise<UserList>
List users, calls the GET /users endpoint.
Parameters:
options?
PaginationOptions
Returns: Promise<UserList>
User response from REST API
▸ listWorkflowExecutions(workflowId
: string, options?
: ListWorkflowExecutionsOptions): Promise<WorkflowExecutionList>
List executions in a workflow, calls the GET /workflows/{workflowId}/executions endpoint.
Parameters:
workflowId
string Id of the workflow
options?
ListWorkflowExecutionsOptions -
Returns: Promise<WorkflowExecutionList>
Workflow executions responses from REST API
▸ listWorkflows(options?
: PaginationOptions): Promise<WorkflowList>
List workflows, calls the GET /workflows endpoint.
Parameters:
options?
PaginationOptions
Returns: Promise<WorkflowList>
Workflows response from REST API
▸ makeDeleteRequest(path
: string, query?
: any): Promise
Type parameters:
T
Parameters:
path
string query?
any
Returns: Promise
▸ makeGetRequest(path
: string, query?
: any): Promise
Type parameters:
T
Parameters:
path
string query?
any
Returns: Promise
▸ makePatchRequest(path
: string, body
: any): Promise
Type parameters:
T
Parameters:
path
string body
any
Returns: Promise
▸ makePostRequest(path
: string, body
: any): Promise
Type parameters:
T
Parameters:
path
string body
any
Returns: Promise
▸ updateAsset(assetId
: string, data
: UpdateAssetOptions): Promise<Asset>
Updates an asset, calls the PATCH /assets/assetId endpoint.
Parameters:
assetId
string Id of the asset
data
UpdateAssetOptions -
Returns: Promise<Asset>
Asset response from REST API with content
▸ updateDocument(documentId
: string, data
: UpdateDocumentOptions): Promise<LasDocument>
Post ground truth to the REST API, calls the PATCH /documents/{documentId} endpoint. Posting ground truth means posting the ground truth data for the particular document. This enables the API to learn from past mistakes.
Parameters:
documentId
string Id of the document
data
UpdateDocumentOptions -
Returns: Promise<LasDocument>
Document response from REST API
▸ updateSecret(secretId
: string, data
: UpdateSecretOptions): Promise<Secret>
Updates a secret, calls the PATCH /secrets/secretId endpoint.
Parameters:
secretId
string Id of the secret
data
UpdateSecretOptions -
Returns: Promise<Secret>
▸ updateTransition(transitionId
: string, data
: UpdateTransitionOptions): Promise<Transition>
Updates a transition, calls the PATCH /transitions/transitionId endpoint.
Parameters:
transitionId
string Id of the transition
data
UpdateTransitionOptions Transition fields to PATCH
Returns: Promise<Transition>
Transition response from REST API
▸ updateTransitionExecution(transitionId
: string, executionId
: string, data
: UpdateTransitionExecution): Promise<TransitionExecution>
Ends the processing of the transition execution, calls the PATCH /transitions/{transition_id}/executions/{execution_id} endpoint.
Parameters:
transitionId
string Id of the transition that performs the execution
executionId
string Id of the execution to update
data
UpdateTransitionExecution -
Returns: Promise<TransitionExecution>
Transition execution response from REST API
▸ updateUser(userId
: string, data
: UpdateUserOptions): Promise<User>
Updates a user, calls the PATCH /users/{userId} endpoint.
Parameters:
userId
string Id of the user
data
UpdateUserOptions -
Returns: Promise<User>
User response from REST API
▸ updateWorkflow(workflowId
: string, data
: UpdateWorkflowOptions): Promise<Workflow>
Updates a workflow, calls the PATCH /workflows/workflowId endpoint.
Parameters:
workflowId
string Id of the workflow
data
UpdateWorkflowOptions Workflow fields to PATCH
Returns: Promise<Workflow>
Workflow response from REST API
@lucidtech/las-sdk-core / Exports / credentials / Credentials
credentials.Credentials
Use to fetch and store credentials and to generate/cache an access token
apiKey
• Readonly
apiEndpoint: string
• Readonly
apiKey: string
▸ getAccessToken(): Promise
Method used to get and cache an access token. Algorithm used: 1. Look for a valid token in memory. 2. Look for a valid token in the storage (if provided); 3. Fetch a new token from server and cache it (both in memory and in storage).
Returns: Promise
@lucidtech/las-sdk-core / Exports / credentials / Token
credentials.Token
Wrapper class for an AWS Cognito token
isValid
+ new Token(accessToken
: string, expiration
: number, refreshToken?
: string): Token
Parameters:
accessToken
string expiration
number refreshToken?
string
Returns: Token
• Readonly
accessToken: string
• Readonly
expiration: number
• Optional
Readonly
refreshToken: undefined | string
▸ isValid(): boolean
Checks if current timestamp is larger than token expiration time
Returns: boolean
@lucidtech/las-sdk-core / Exports / index / CreateDocumentOptions
index.CreateDocumentOptions
batchId
• Optional
batchId: undefined | string
• Optional
consentId: undefined | string
• Optional
groundTruth: undefined | GroundTruth[]
@lucidtech/las-sdk-core / Exports / index / CreatePredictionsOptions
index.CreatePredictionsOptions
maxPages
• Optional
autoRotate: undefined | boolean
• Optional
maxPages: undefined | number
@lucidtech/las-sdk-core / Exports / index / CreateSecretOptions
index.CreateSecretOptions
• Optional
description: undefined | string
@lucidtech/las-sdk-core / Exports / index / CreateTransitionOptions
index.CreateTransitionOptions
name
• Optional
description: undefined | null | string
• Optional
inputJsonSchema: undefined | Record
• Optional
name: undefined | null | string
• Optional
outputJsonSchema: undefined | Record
• Optional
parameters: undefined | CreateTransitionDockerParams | CreateTransitionManualParams
@lucidtech/las-sdk-core / Exports / index / DeleteDocumentOptions
index.DeleteDocumentOptions
• Optional
consentId: undefined | string | string[]
@lucidtech/las-sdk-core / Exports / index / PaginationOptions
index.PaginationOptions
• Optional
maxResults: undefined | number
• Optional
nextToken: undefined | string
@lucidtech/las-sdk-core / Exports / index / UpdateAssetOptions
index.UpdateAssetOptions
content
• Optional
content: undefined | string | Buffer
@lucidtech/las-sdk-core / Exports / index / UpdateDocumentOptions
index.UpdateDocumentOptions
• Optional
groundTruth: undefined | GroundTruth[]
@lucidtech/las-sdk-core / Exports / index / UpdateSecretOptions
index.UpdateSecretOptions
• Optional
data: undefined | Record
• Optional
description: undefined | null | string
• Optional
name: undefined | null | string
@lucidtech/las-sdk-core / Exports / index / UpdateTransitionExecution
index.UpdateTransitionExecution
• Optional
error: undefined | { message
: string }
• Optional
output: undefined | Record
• status: succeeded | failed | retry | rejected
@lucidtech/las-sdk-core / Exports / index / UpdateWorkflowOptions
index.UpdateWorkflowOptions
name
• Optional
description: undefined | string
• Optional
name: undefined | string
@lucidtech/las-sdk-core / Exports / storage / TokenStorage
storage.TokenStorage
T
Token
• getPersistentToken: () => null | T
Type declaration:
▸ (): null | T
Returns: null | T
• setPersistentToken: (value
: T) => void
Type declaration:
▸ (value
: T): void
Parameters:
value
T
Returns: void
@lucidtech/las-sdk-core / Exports / types / CreateDocumentOptions
types.CreateDocumentOptions
batchId
• Optional
batchId: undefined | string
• Optional
consentId: undefined | string
• Optional
groundTruth: undefined | GroundTruth[]
@lucidtech/las-sdk-core / Exports / types / CreatePredictionsOptions
types.CreatePredictionsOptions
maxPages
• Optional
autoRotate: undefined | boolean
• Optional
maxPages: undefined | number
@lucidtech/las-sdk-core / Exports / types / CreateSecretOptions
types.CreateSecretOptions
• Optional
description: undefined | string
@lucidtech/las-sdk-core / Exports / types / CreateTransitionOptions
types.CreateTransitionOptions
name
• Optional
description: undefined | null | string
• Optional
inputJsonSchema: undefined | Record
• Optional
name: undefined | null | string
• Optional
outputJsonSchema: undefined | Record
• Optional
parameters: undefined | CreateTransitionDockerParams | CreateTransitionManualParams
@lucidtech/las-sdk-core / Exports / types / DeleteDocumentOptions
types.DeleteDocumentOptions
• Optional
consentId: undefined | string | string[]
@lucidtech/las-sdk-core / Exports / types / PaginationOptions
types.PaginationOptions
• Optional
maxResults: undefined | number
• Optional
nextToken: undefined | string
@lucidtech/las-sdk-core / Exports / types / UpdateAssetOptions
types.UpdateAssetOptions
content
• Optional
content: undefined | string | Buffer
@lucidtech/las-sdk-core / Exports / types / UpdateDocumentOptions
types.UpdateDocumentOptions
• Optional
groundTruth: undefined | GroundTruth[]
@lucidtech/las-sdk-core / Exports / types / UpdateSecretOptions
types.UpdateSecretOptions
• Optional
data: undefined | Record
• Optional
description: undefined | null | string
• Optional
name: undefined | null | string
@lucidtech/las-sdk-core / Exports / types / UpdateTransitionExecution
types.UpdateTransitionExecution
• Optional
error: undefined | { message
: string }
• Optional
output: undefined | Record
• status: succeeded | failed | retry | rejected
@lucidtech/las-sdk-core / Exports / types / UpdateWorkflowOptions
types.UpdateWorkflowOptions
name
• Optional
description: undefined | string
• Optional
name: undefined | string
@lucidtech/las-sdk-core / Exports
@lucidtech/las-sdk-core / Exports / client
default
Client
Renames and exports: Client
@lucidtech/las-sdk-core / Exports / credentials
Token
@lucidtech/las-sdk-core / Exports / index
Re-exports: Client
Re-exports: Credentials
Re-exports: Token
Re-exports: TokenStorage
Ƭ Asset: object
Type declaration:
assetId
string content
string
Ƭ AssetList: object
Type declaration:
assets
AssetWithoutContent[] nextToken
string | null
Ƭ AssetWithoutContent: object
Type declaration:
assetId
string
Ƭ AuthorizationHeaders: object
Type declaration:
Authorization
string X-Api-Key
string
Ƭ AxiosFn: (url
: string, body?
: any, config?
: AxiosRequestConfig) => Promise
Type declaration:
▸ (url
: string, body?
: any, config?
: AxiosRequestConfig): Promise
Type parameters:
T
any R
AxiosResponse
Parameters:
url
string body?
any config?
AxiosRequestConfig
Returns: Promise
Ƭ Batch: object
Type declaration:
batchId
string description
string name
string
Ƭ ContentType: application/pdf | image/jpeg
Ƭ CreateBatchOptions: object
Type declaration:
description
? string name
? string
Ƭ CreateTransitionDockerParams: object
Type declaration:
cpu
? 256 credentials
? object credentials.password
string credentials.username
string environment
? object imageUrl
string memory
? 512 | 1024 | 2048
Ƭ CreateTransitionManualParams: object
Type declaration:
assets
? { jsRemoteComponent?
: string } & Record
Ƭ CreateTransitionParams: CreateTransitionDockerParams | CreateTransitionManualParams
Ƭ CreateUserOptions: object
Type declaration:
avatar
? string | null name
? string | null
Ƭ CreateWorkflowOptions: object
Type declaration:
description
? string errorConfig
? object errorConfig.email
string
Ƭ GroundTruth: object
Type declaration:
label
string maxLength: 36, minLength: 1, pattern: ^[0-9A-Za-z_]+$
value
string | boolean | null maxLength: 64, minLength: 1
Ƭ LasDocument: object
Type declaration:
batchId
? string pattern: ^las:batch:[a-f0-9]{32}$
consentId
? string pattern: ^las:consent:[a-f0-9]{32}$
content
? string minimum: 1
contentType
ContentType - documentId
string pattern: ^las:document:[a-f0-9]{32}$
groundTruth
? GroundTruth[] - inferenceTime
? number minimum: 0
predictions
? Prediction[] - updated
? number minimum: 1
Ƭ LasDocumentList: object
Type declaration:
batchId
? string consentId
? string documents
LasDocument[] nextToken
? string
Ƭ ListAssetsOptions: PaginationOptions
Ƭ ListDocumentsOptions: PaginationOptions & { batchId?
: string | string[] ; consentId?
: string | string[] }
Ƭ ListModelsOptions: PaginationOptions
Ƭ ListPredictionsOptions: PaginationOptions
Ƭ ListSecretsOptions: PaginationOptions
Ƭ ListTransitionOptions: PaginationOptions & { transitionType?
: string | string[] }
Ƭ ListUsersOptions: PaginationOptions
Ƭ ListWorkflowExecutionsOptions: PaginationOptions & { order?
: ascending | descending ; sortBy?
: startTime | endTime ; status?
: string | string[] }
Ƭ ListWorkflowOptions: PaginationOptions
Ƭ Log: object
Type declaration:
events
Record[] logId
string transitionId
? string | null
Ƭ Model: object
Type declaration:
description
string | null height
number modelId
string name
string | null width
number
Ƭ ModelList: object
Type declaration:
models
Model[] nextToken
string | null
Ƭ PostPredictions: CreatePredictionsOptions & { documentId
: string ; modelId
: string }
Ƭ Prediction: GroundTruth & { confidence
: number }
Ƭ PredictionList: object
Type declaration:
nextToken
string | null predictions
PredictionResponse[]
Ƭ PredictionResponse: object
Type declaration:
documentId
string inferenceTime
number modelId
string predictionId
string predictions
Prediction[] timestamp
number
Ƭ Secret: object
Type declaration:
description
string | null name
string | null secredId
string
Ƭ SecretList: object
Type declaration:
nextToken
? string | null secrets
Secret[]
Ƭ Transition: object
Type declaration:
assets
? Record description
string inputJsonSchema
unknown name
string outputJsonSchema
? unknown transitionId
string transitionType
TransitionType
Ƭ TransitionExecution: object
Type declaration:
completedBy
string | null endTime
string | null executionId
string input
Record startTime
string | null status
succeeded | failed | retry | running | rejected transitionId
string
Ƭ TransitionExecutionList: object
Type declaration:
executions
TransitionExecution[] nextToken
string | null transitionId
string
Ƭ TransitionExecutionListOptions: PaginationOptions & { executionId?
: string | string[] ; order?
: ascending | descending ; sortBy?
: startTime | endTime ; status?
: succeeded | failed | retry | running | rejected }
Ƭ TransitionList: object
Type declaration:
nextToken
? string transitions
Transition[]
Ƭ TransitionType: docker | manual
Ƭ UpdateTransitionOptions: object
Type declaration:
description
? string inputJsonSchema
? Record name
? string outputJsonSchema
? Record
Ƭ UpdateUserOptions: object
Type declaration:
avatar
? string | null name
? string | null
Ƭ User: object
Type declaration:
avatar
string | null email
string name
string | null userId
string
Ƭ UserList: object
Type declaration:
nextToken
? string users
User[]