Socket
Socket
Sign inDemoInstall

@lucidtech/las-sdk-core

Package Overview
Dependencies
2
Maintainers
2
Versions
113
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.5.0 to 3.6.0

13

lib/client.d.ts

@@ -116,2 +116,3 @@ /// <reference types="node" />

* @param data.error Error from the execution, required when status is 'failed', needs to contain 'message'
* @param data.startTime Utc start time that will replace the original start time of the execution
* @returns Transition execution response from REST API

@@ -132,2 +133,12 @@ */

/**
* Send heartbeat for a manual execution to signal that we are still working on it.
* Must be done at minimum once every 60 seconds or the transition execution will time out.
* Calls the POST /transitions/{transitionId}/executions/{executionId}/heartbeats endpoint.
*
* @param transitionId Id of the transition
* @param transitionExecutionId Id of the transition execution
* @returns Empty response
*/
sendHeartbeat(transitionId: string, transitionExecutionId: string): Promise<unknown>;
/**
* Creates a new workflow, calls the POST /workflows endpoint.

@@ -208,2 +219,4 @@ *

* when running predictions
* @param options.imageQuality: Image quality for prediction ("LOW|HIGH"). High quality could give
* better result but will also take longer time.
* @returns Predicion response from REST API

@@ -210,0 +223,0 @@ */

@@ -252,2 +252,3 @@ "use strict";

* @param data.error Error from the execution, required when status is 'failed', needs to contain 'message'
* @param data.startTime Utc start time that will replace the original start time of the execution
* @returns Transition execution response from REST API

@@ -280,2 +281,18 @@ */

/**
* Send heartbeat for a manual execution to signal that we are still working on it.
* Must be done at minimum once every 60 seconds or the transition execution will time out.
* Calls the POST /transitions/{transitionId}/executions/{executionId}/heartbeats endpoint.
*
* @param transitionId Id of the transition
* @param transitionExecutionId Id of the transition execution
* @returns Empty response
*/
Client.prototype.sendHeartbeat = function (transitionId, transitionExecutionId) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.makePostRequest("/transitions/" + transitionId + "/executions/" + transitionExecutionId + "/heartbeats", {})];
});
});
};
/**
* Creates a new workflow, calls the POST /workflows endpoint.

@@ -416,2 +433,4 @@ *

* when running predictions
* @param options.imageQuality: Image quality for prediction ("LOW|HIGH"). High quality could give
* better result but will also take longer time.
* @returns Predicion response from REST API

@@ -418,0 +437,0 @@ */

2

lib/helpers.js

@@ -10,2 +10,4 @@ "use strict";

return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -12,0 +14,0 @@ function __() { this.constructor = d; }

@@ -7,2 +7,3 @@ /// <reference types="node" />

autoRotate?: boolean;
imageQuality?: 'LOW' | 'HIGH';
}

@@ -45,2 +46,3 @@ export interface PaginationOptions {

};
startTime?: string;
}

@@ -47,0 +49,0 @@ export interface CreateTransitionOptions {

4

package.json
{
"name": "@lucidtech/las-sdk-core",
"version": "3.5.0",
"version": "3.6.0",
"author": "Lucidtech AS <hello@lucidtech.ai>",

@@ -32,3 +32,3 @@ "maintainers": [

},
"gitHead": "a12de87451ad31257a9ad25980d5ecbabd9fc2bb"
"gitHead": "29e841340d74a3d6793fe0588ca5a254e64d8bfa"
}

@@ -8,3 +8,9 @@ /**

import {
ContentType, CreateTransitionOptions, CreateWorkflowOptions, UpdateSecretOptions, UpdateTransitionExecution, TransitionType, WorkflowSpecification,
ContentType,
CreateTransitionOptions,
CreateWorkflowOptions,
UpdateSecretOptions,
UpdateTransitionExecution,
TransitionType,
WorkflowSpecification,
} from './types';

@@ -16,2 +22,3 @@

const transitionId = () => `las:transition:${uuidWithoutDashes()}`;
const transitionExecutionId = () => `las:transition-execution:${uuidWithoutDashes()}`;
const consentId = () => `las:consent:${uuidWithoutDashes()}`;

@@ -21,2 +28,3 @@ const batchId = () => `las:batch:${uuidWithoutDashes()}`;

const workflowId = () => `las:workflow:${uuidWithoutDashes()}`;
const modelId = () => `las:model:${uuidWithoutDashes()}`;

@@ -34,3 +42,6 @@ beforeEach(() => {

const testBatchId = batchId();
const createDocumentPromise = client.createDocument(testContent, testContentType, { consentId: testConsentId, batchId: testBatchId });
const createDocumentPromise = client.createDocument(testContent, testContentType, {
consentId: testConsentId,
batchId: testBatchId,
});
await expect(createDocumentPromise).resolves.toHaveProperty('consentId');

@@ -130,4 +141,4 @@ await expect(createDocumentPromise).resolves.toHaveProperty('contentType');

await expect(getTransitionPromise).resolves.toHaveProperty('transitionId');
})
})
});
});

@@ -162,4 +173,4 @@ describe('listTransitions', () => {

await expect(deleteTransitionPromise).resolves.toHaveProperty('transitionId');
})
})
});
});

@@ -182,10 +193,7 @@ describe('executeTransition', () => {

{ status: 'failed', error: { message: 'test' } },
{ status: 'succeeded', output: { something: 'test' }, startTime: '2020-01-01 09:31:00.002431' },
])('input: %o', async (input) => {
const transitionId = uuidv4();
const executionId = uuidv4();
const updateTransitionExecutionPromise = client.updateTransitionExecution(
transitionId,
executionId,
input,
);
const testTransitionId = transitionId();
const testExecutionId = transitionExecutionId();
const updateTransitionExecutionPromise = client.updateTransitionExecution(testTransitionId, testExecutionId, input);
await expect(updateTransitionExecutionPromise).resolves.toHaveProperty('executionId');

@@ -203,2 +211,12 @@ await expect(updateTransitionExecutionPromise).resolves.toHaveProperty('status');

});
describe('sendHeartbeat', () => {
// Seems like a Prism issue where this will just never resolve or reject, making Jest time out
test.skip('valid request', async () => {
const testTransitionId = transitionId();
const testExecutionId = transitionExecutionId();
const sendHeartbeatPromise = await client.sendHeartbeat(testTransitionId, testExecutionId);
await expect(sendHeartbeatPromise).resolves.toBe('')
})
})
});

@@ -209,15 +227,24 @@

test.each<[string, WorkflowSpecification, CreateWorkflowOptions | undefined]>([
['test', { definition: {} } as WorkflowSpecification, { description: 'test', errorConfig: { email: 'test@test.com' } }],
[
'test',
{ definition: {} } as WorkflowSpecification,
{ description: 'test', errorConfig: { email: 'test@test.com' } },
],
['test', { definition: {} } as WorkflowSpecification, undefined],
['test', { definition: {} } as WorkflowSpecification, { errorConfig: { email: 'test@test.com' } }],
['test', { definition: {}, language: 'ASL', version: '1.0.0' } as WorkflowSpecification, { description: 'test', errorConfig: { email: 'test@test.com' } }],
['test', { definition: {} } as WorkflowSpecification, { description: 'test', errorConfig: { email: 'test@test.com' } }],
])(
'input: %o',
async (name, specification, options) => {
const createWorkflowPromise = client.createWorkflow(name, specification, options);
await expect(createWorkflowPromise).resolves.toHaveProperty('name');
await expect(createWorkflowPromise).resolves.toHaveProperty('workflowId');
},
);
[
'test',
{ definition: {}, language: 'ASL', version: '1.0.0' } as WorkflowSpecification,
{ description: 'test', errorConfig: { email: 'test@test.com' } },
],
[
'test',
{ definition: {} } as WorkflowSpecification,
{ description: 'test', errorConfig: { email: 'test@test.com' } },
],
])('input: %o', async (name, specification, options) => {
const createWorkflowPromise = client.createWorkflow(name, specification, options);
await expect(createWorkflowPromise).resolves.toHaveProperty('name');
await expect(createWorkflowPromise).resolves.toHaveProperty('workflowId');
});
});

@@ -231,3 +258,3 @@

});
})
});

@@ -330,7 +357,7 @@ describe('listWorkflows', () => {

const userId = uuidv4();
const updateUserPromise = client.updateUser(userId, { name: 'I want a new name'});
const updateUserPromise = client.updateUser(userId, { name: 'I want a new name' });
await expect(updateUserPromise).resolves.toHaveProperty('email');
await expect(updateUserPromise).resolves.toHaveProperty('name');
})
})
});
});

@@ -377,3 +404,3 @@ describe('deleteUser', () => {

test.each<[number|undefined, string|undefined]>([
test.each<[number | undefined, string | undefined]>([
[100, 'foo'],

@@ -390,10 +417,9 @@ [undefined, 'foo'],

describe('updateSecret', () => {
test.each<UpdateSecretOptions>([
{ data: { user: 'foo' } },
{ description: 'bar' },
{ name: 'foo' },
])('with input: %o', async (options) => {
const updateSecretPromise = client.updateSecret('foo', options);
await expect(updateSecretPromise).resolves.toHaveProperty('secretId');
});
test.each<UpdateSecretOptions>([{ data: { user: 'foo' } }, { description: 'bar' }, { name: 'foo' }])(
'with input: %o',
async (options) => {
const updateSecretPromise = client.updateSecret('foo', options);
await expect(updateSecretPromise).resolves.toHaveProperty('secretId');
}
);
});

@@ -405,4 +431,4 @@ });

test('valid request', async () => {
const testDocumentId = `las:document:${uuidv4().replace(/-/g, '')}`;
const testModelId = `las:model:${uuidv4().replace(/-/g, '')}`;
const testDocumentId = documentId();
const testModelId = modelId();
const createPredictionPromise = client.createPrediction(testDocumentId, testModelId);

@@ -413,4 +439,16 @@ await expect(createPredictionPromise).resolves.toHaveProperty('documentId');

test('with options', async () => {
const testDocumentId = documentId();
const testModelId = modelId();
const createPredictionPromise = client.createPrediction(testDocumentId, testModelId, {
autoRotate: true,
imageQuality: 'HIGH',
maxPages: 2,
});
await expect(createPredictionPromise).resolves.toHaveProperty('documentId');
await expect(createPredictionPromise).resolves.toHaveProperty('predictions');
});
test('invalid model name', async () => {
const testDocumentId = `las:document:${uuidv4().replace(/-/g, '')}`;
const testDocumentId = documentId();
const testModelId = 'erroneousModelId';

@@ -417,0 +455,0 @@ const createPredictionPromise = client.createPrediction(testDocumentId, testModelId);

@@ -81,3 +81,7 @@ import axios, { AxiosRequestConfig, AxiosResponse } from 'axios';

*/
async createDocument(content: string | Buffer, contentType: ContentType, options?: CreateDocumentOptions): Promise<LasDocument> {
async createDocument(
content: string | Buffer,
contentType: ContentType,
options?: CreateDocumentOptions,
): Promise<LasDocument> {
const encodedContent = typeof content === 'string' ? content : Buffer.from(content).toString('base64');

@@ -154,6 +158,3 @@ let body = {

*/
async createTransition(
transitionType: TransitionType,
options?: CreateTransitionOptions,
): Promise<Transition> {
async createTransition(transitionType: TransitionType, options?: CreateTransitionOptions): Promise<Transition> {
let body = {

@@ -233,2 +234,3 @@ transitionType,

* @param data.error Error from the execution, required when status is 'failed', needs to contain 'message'
* @param data.startTime Utc start time that will replace the original start time of the execution
* @returns Transition execution response from REST API

@@ -262,2 +264,15 @@ */

/**
* Send heartbeat for a manual execution to signal that we are still working on it.
* Must be done at minimum once every 60 seconds or the transition execution will time out.
* Calls the POST /transitions/{transitionId}/executions/{executionId}/heartbeats endpoint.
*
* @param transitionId Id of the transition
* @param transitionExecutionId Id of the transition execution
* @returns Empty response
*/
async sendHeartbeat(transitionId: string, transitionExecutionId: string): Promise<unknown> {
return this.makePostRequest(`/transitions/${transitionId}/executions/${transitionExecutionId}/heartbeats`, {});
}
/**
* Creates a new workflow, calls the POST /workflows endpoint.

@@ -382,2 +397,4 @@ *

* when running predictions
* @param options.imageQuality: Image quality for prediction ("LOW|HIGH"). High quality could give
* better result but will also take longer time.
* @returns Predicion response from REST API

@@ -384,0 +401,0 @@ */

@@ -10,2 +10,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

autoRotate?: boolean;
imageQuality?: 'LOW' | 'HIGH';
}

@@ -54,2 +55,3 @@

error?: { message: string };
startTime?: string;
}

@@ -56,0 +58,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc