@lucidtech/las-sdk-core
Advanced tools
Comparing version 1.2.9 to 1.2.10
@@ -8,4 +8,11 @@ import { Credentials } from './credentials'; | ||
getData(): Promise<any>; | ||
postDocuments(content: string, contentType: string, consentId: string): Promise<any>; | ||
postDocuments(content: string, contentType: string, consentId: string, batchId?: string, feedback?: Array<{ | ||
[key: string]: string; | ||
}>): Promise<any>; | ||
getDocuments(batchId: string): Promise<any>; | ||
postDocumentId(documentId: string, feedback: Array<{ | ||
[key: string]: string; | ||
}>): Promise<any>; | ||
postPredictions(documentId: string, modelName: string): Promise<any>; | ||
postBatches(description: string): Promise<any>; | ||
getProcesses(search?: { | ||
@@ -21,3 +28,4 @@ [key: string]: string | Array<string>; | ||
patchTasks(taskId: string, taskResult?: any, taskError?: any): Promise<any>; | ||
makeGetRequest(path: string): Promise<any>; | ||
patchUserId(userId: string, consentHash: string): Promise<any>; | ||
makeGetRequest(path: string, query?: any): Promise<any>; | ||
makeDeleteRequest(path: string): Promise<any>; | ||
@@ -24,0 +32,0 @@ makePostRequest(path: string, body: any): Promise<any>; |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -19,3 +30,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Client.prototype.postDocuments = function (content, contentType, consentId) { | ||
Client.prototype.postDocuments = function (content, contentType, consentId, batchId, feedback) { | ||
var body = { | ||
@@ -26,4 +37,22 @@ content: Buffer.from(content).toString('base64'), | ||
}; | ||
if (!!batchId) { | ||
body = __assign(__assign({}, body), { batchId: batchId }); | ||
} | ||
if (!!feedback) { | ||
body = __assign(__assign({}, body), { feedback: feedback }); | ||
} | ||
return this.makePostRequest('/documents', body); | ||
}; | ||
Client.prototype.getDocuments = function (batchId) { | ||
var query = { | ||
batchId: batchId, | ||
}; | ||
return this.makeGetRequest('/documents', query); | ||
}; | ||
Client.prototype.postDocumentId = function (documentId, feedback) { | ||
var body = { | ||
feedback: feedback, | ||
}; | ||
return this.makePostRequest("/documents/" + documentId, body); | ||
}; | ||
Client.prototype.postPredictions = function (documentId, modelName) { | ||
@@ -36,2 +65,8 @@ var body = { | ||
}; | ||
Client.prototype.postBatches = function (description) { | ||
var body = { | ||
description: description, | ||
}; | ||
return this.makePostRequest('/batches', body); | ||
}; | ||
Client.prototype.getProcesses = function (search) { | ||
@@ -65,5 +100,14 @@ var url = utils_1.buildURL('/processes', search); | ||
}; | ||
Client.prototype.makeGetRequest = function (path) { | ||
return this.makeAuthorizedRequest(axios_1.default.get, path); | ||
Client.prototype.patchUserId = function (userId, consentHash) { | ||
var body = { consentHash: consentHash }; | ||
return this.makePatchRequest("/users/" + userId, body); | ||
}; | ||
Client.prototype.makeGetRequest = function (path, query) { | ||
if (!!query) { | ||
return this.makeAuthorizedRequest(axios_1.default.get, path, query); | ||
} | ||
else { | ||
return this.makeAuthorizedRequest(axios_1.default.get, path); | ||
} | ||
}; | ||
Client.prototype.makeDeleteRequest = function (path) { | ||
@@ -78,3 +122,3 @@ return this.makeAuthorizedRequest(axios_1.default.delete, path); | ||
}; | ||
Client.prototype.makeAuthorizedRequest = function (axiosFn, path, body) { | ||
Client.prototype.makeAuthorizedRequest = function (axiosFn, path, body, query) { | ||
var _this = this; | ||
@@ -85,3 +129,3 @@ return new Promise(function (resolve, reject) { | ||
var config = { headers: headers }; | ||
var handle = body ? function () { return axiosFn(endpoint, body, config); } : function () { return axiosFn(endpoint, config); }; | ||
var handle = body ? function () { return axiosFn(endpoint, body, config); } : query ? function () { return axiosFn(endpoint, query, config); } : function () { return axiosFn(endpoint, config); }; | ||
handle().then(function (response) { | ||
@@ -88,0 +132,0 @@ resolve(response.data); |
{ | ||
"name": "@lucidtech/las-sdk-core", | ||
"version": "1.2.9", | ||
"version": "1.2.10", | ||
"author": "Lucidtech AS <hello@lucidtech.ai>", | ||
@@ -23,3 +23,3 @@ "maintainers": [ | ||
}, | ||
"gitHead": "a7f5a3d0e61053fbddf0812c9c8c214757793e1c" | ||
"gitHead": "9494da0ef4ffa6768456568da094cba9aa79bff9" | ||
} |
@@ -23,4 +23,4 @@ import axios, { AxiosRequestConfig } from 'axios'; | ||
postDocuments(content: string, contentType: string, consentId: string) { | ||
const body = { | ||
postDocuments(content: string, contentType: string, consentId: string, batchId?: string, feedback?: Array<{[key: string]: string}>) { | ||
let body : any = { | ||
content: Buffer.from(content).toString('base64'), | ||
@@ -31,5 +31,28 @@ contentType, | ||
if (!!batchId ) { | ||
body = {...body, batchId}; | ||
} | ||
if (!!feedback) { | ||
body = {...body, feedback}; | ||
} | ||
return this.makePostRequest('/documents', body); | ||
} | ||
getDocuments(batchId: string) { | ||
const query = { | ||
batchId, | ||
}; | ||
return this.makeGetRequest('/documents', query); | ||
} | ||
postDocumentId(documentId: string, feedback: Array<{[key: string]: string}>) { | ||
const body = { | ||
feedback, | ||
}; | ||
return this.makePostRequest(`/documents/${documentId}`, body); | ||
} | ||
postPredictions(documentId: string, modelName: string) { | ||
@@ -44,2 +67,10 @@ const body = { | ||
postBatches(description: string) { | ||
const body = { | ||
description, | ||
}; | ||
return this.makePostRequest('/batches', body); | ||
} | ||
getProcesses(search?: { [key: string]: string|Array<string> }) { | ||
@@ -80,6 +111,16 @@ const url = buildURL('/processes', search); | ||
makeGetRequest(path: string) { | ||
return this.makeAuthorizedRequest(axios.get, path); | ||
patchUserId(userId: string, consentHash: string) { | ||
const body = { consentHash }; | ||
return this.makePatchRequest(`/users/${userId}`, body); | ||
} | ||
makeGetRequest(path: string, query?: any) { | ||
if(!!query) { | ||
return this.makeAuthorizedRequest(axios.get, path, query); | ||
} | ||
else { | ||
return this.makeAuthorizedRequest(axios.get, path); | ||
} | ||
} | ||
makeDeleteRequest(path: string) { | ||
@@ -97,3 +138,3 @@ return this.makeAuthorizedRequest(axios.delete, path); | ||
private makeAuthorizedRequest(axiosFn: (url: string, body?: any, config?: AxiosRequestConfig) => Promise<any>, path: string, body?: any) { | ||
private makeAuthorizedRequest(axiosFn: (url: string, body?: any, query?: any, config?: AxiosRequestConfig) => Promise<any>, path: string, body?: any, query?: any) { | ||
return new Promise<any>((resolve, reject) => { | ||
@@ -103,3 +144,3 @@ const endpoint = `${this.apiEndpoint}${path}`; | ||
const config = { headers }; | ||
const handle = body ? () => axiosFn(endpoint, body, config) : () => axiosFn(endpoint, config); | ||
const handle = body ? () => axiosFn(endpoint, body, config) : query ? () => axiosFn(endpoint, query, config) : () => axiosFn(endpoint, config) | ||
@@ -106,0 +147,0 @@ handle().then((response) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37957
676
39