@lucidtech/las-sdk-core
Advanced tools
Comparing version 6.0.2-beta.0 to 7.0.0
/// <reference types="node" /> | ||
import { Buffer } from 'buffer'; | ||
import { Credentials } from './credentials'; | ||
import type { AppClient, AppClientList, Asset, AssetList, ContentType, CreateAppClientOptions, CreateAssetOptions, CreateDataBundleOptions, CreateDatasetOptions, CreateDocumentOptions, CreateModelOptions, CreatePredictionsOptions, CreateSecretOptions, CreateTransitionOptions, CreateUserOptions, CreateWorkflowOptions, DataBundle, DataBundleList, Dataset, DatasetList, DeleteAppClientOptions, DeleteAssetOptions, DeleteDataBundleOptions, DeleteDatasetOptions, DeleteDocumentOptions, DeleteDocumentsOptions, DeleteModelOptions, DeleteTransitionOptions, DeleteUserOptions, DeleteWorkflowExecution, DeleteWorkflowOptions, ExecuteTransitionOptions, ExecuteWorkflowOptions, FieldConfig, GetAssetOptions, GetDatasetOptions, GetDocumentOptions, GetLogOptions, GetModelOptions, GetOrganizationOptions, GetTransitionExecutionOptions, GetTransitionOptions, GetUserOptions, GetWorkflowExecutionOptions, GetWorkflowOptions, LasDocument, LasDocumentList, LasDocumentWithoutContent, ListAppClientsOptions, ListAssetsOptions, ListDataBundleOptions, ListDatasetsOptions, ListDocumentsOptions, ListModelsOptions, ListPredictionsOptions, ListSecretsOptions, ListTransitionOptions, ListUsersOptions, ListWorkflowExecutionsOptions, ListWorkflowOptions, Log, Model, ModelList, Organization, PostHeartbeatOptions, PredictionList, PredictionResponse, Secret, SecretList, Transition, TransitionExecution, TransitionExecutionList, TransitionExecutionListOptions, TransitionList, TransitionType, UpdateAppClientOptions, UpdateAssetOptions, UpdateDataBundleOptions, UpdateDatasetOptions, UpdateDocumentOptions, UpdateModelOptions, UpdateOrganizationOptions, UpdateSecretOptions, UpdateTransitionExecution, UpdateTransitionOptions, UpdateUserOptions, UpdateWorkflowExecutionOptions, UpdateWorkflowOptions, User, UserList, Workflow, WorkflowExecution, WorkflowExecutionList, WorkflowList, WorkflowSpecification } from './types'; | ||
import { AppClient, AppClientList, Asset, AssetList, ContentType, CreateAppClientOptions, CreateDataBundleOptions, CreateDatasetOptions, CreateDocumentOptions, CreateModelOptions, CreatePredictionsOptions, CreateSecretOptions, CreateTransitionOptions, CreateUserOptions, CreateWorkflowOptions, DataBundle, DataBundleList, Dataset, DatasetList, DeleteDocumentOptions, FieldConfig, LasDocument, LasDocumentList, LasDocumentWithoutContent, ListAppClientsOptions, ListAssetsOptions, ListDataBundleOptions, ListDatasetsOptions, ListDocumentsOptions, ListModelsOptions, ListPredictionsOptions, ListSecretsOptions, ListTransitionOptions, ListUsersOptions, ListWorkflowExecutionsOptions, ListWorkflowOptions, Log, Model, ModelList, Organization, PredictionList, PredictionResponse, Secret, SecretList, Transition, TransitionExecution, TransitionExecutionList, TransitionExecutionListOptions, TransitionList, TransitionType, UpdateAppClientOptions, UpdateAssetOptions, UpdateDataBundleOptions, UpdateDatasetOptions, UpdateDocumentOptions, UpdateModelOptions, UpdateOrganizationOptions, UpdateSecretOptions, UpdateTransitionExecution, UpdateTransitionOptions, UpdateUserOptions, UpdateWorkflowExecutionOptions, UpdateWorkflowOptions, User, UserList, Workflow, WorkflowExecution, WorkflowExecutionList, WorkflowList, WorkflowSpecification } from './types'; | ||
/** | ||
@@ -26,3 +25,3 @@ * A high-level http client for communicating with the Lucidtech REST API | ||
*/ | ||
getOrganization(organizationId: string, options?: GetOrganizationOptions): Promise<Organization>; | ||
getOrganization(organizationId: string): Promise<Organization>; | ||
/** | ||
@@ -62,3 +61,3 @@ * Creates an app client, calls the POST /appClients endpoint. | ||
*/ | ||
deleteAppClient(appClientId: string, options?: DeleteAppClientOptions): Promise<AppClient>; | ||
deleteAppClient(appClientId: string): Promise<AppClient>; | ||
/** | ||
@@ -80,3 +79,3 @@ * Creates a document, calls the POST /documents endpoint. | ||
*/ | ||
getDocument(documentId: string, options?: GetDocumentOptions): Promise<LasDocument>; | ||
getDocument(documentId: string): Promise<LasDocument>; | ||
/** | ||
@@ -108,3 +107,3 @@ * List documents available for inference, calls the GET /documents endpoint. | ||
*/ | ||
deleteDocuments(options?: DeleteDocumentsOptions): Promise<LasDocumentList>; | ||
deleteDocuments(options?: DeleteDocumentOptions): Promise<LasDocumentList>; | ||
/** | ||
@@ -116,3 +115,3 @@ * Delete an document, calls the DELETE /documents/{documentId} endpoint. | ||
*/ | ||
deleteDocument(documentId: string, options?: DeleteDocumentOptions): Promise<LasDocument>; | ||
deleteDocument(documentId: string): Promise<LasDocument>; | ||
/** | ||
@@ -136,3 +135,3 @@ * Creates a transition, calls the POST /transitions endpoint. | ||
*/ | ||
getTransition(transitionId: string, options?: GetTransitionOptions): Promise<Transition>; | ||
getTransition(transitionId: string): Promise<Transition>; | ||
/** | ||
@@ -162,3 +161,3 @@ * List transitions, calls the GET /transitions endpoint. | ||
*/ | ||
deleteTransition(transitionId: string, options?: DeleteTransitionOptions): Promise<Transition>; | ||
deleteTransition(transitionId: string): Promise<Transition>; | ||
/** | ||
@@ -170,3 +169,3 @@ * Start executing a manual transition, calls the POST /transitions/{transitionId}/executions endpoint. | ||
*/ | ||
executeTransition(transitionId: string, options?: ExecuteTransitionOptions): Promise<TransitionExecution>; | ||
executeTransition(transitionId: string): Promise<TransitionExecution>; | ||
/** | ||
@@ -179,3 +178,3 @@ * Get an execution of a transition, calls the GET /transitions/{transitionId}/executions/{executionId} endpoint | ||
*/ | ||
getTransitionExecution(transitionId: string, transitionExecutionId: string, options?: GetTransitionExecutionOptions): Promise<TransitionExecution>; | ||
getTransitionExecution(transitionId: string, transitionExecutionId: string): Promise<TransitionExecution>; | ||
/** | ||
@@ -214,3 +213,3 @@ * Ends the processing of the transition execution, calls the | ||
*/ | ||
sendHeartbeat(transitionId: string, transitionExecutionId: string, options?: PostHeartbeatOptions): Promise<unknown>; | ||
sendHeartbeat(transitionId: string, transitionExecutionId: string): Promise<unknown>; | ||
/** | ||
@@ -232,3 +231,3 @@ * Creates a new workflow, calls the POST /workflows endpoint. | ||
*/ | ||
getWorkflow(workflowId: string, options?: GetWorkflowOptions): Promise<Workflow>; | ||
getWorkflow(workflowId: string): Promise<Workflow>; | ||
/** | ||
@@ -248,3 +247,3 @@ * List workflows, calls the GET /workflows endpoint. | ||
*/ | ||
deleteWorkflow(workflowId: string, options?: DeleteWorkflowOptions): Promise<Workflow>; | ||
deleteWorkflow(workflowId: string): Promise<Workflow>; | ||
/** | ||
@@ -264,3 +263,3 @@ * Updates a workflow, calls the PATCH /workflows/{workflowId} endpoint. | ||
*/ | ||
executeWorkflow(workflowId: string, input: object, options?: ExecuteWorkflowOptions): Promise<WorkflowExecution>; | ||
executeWorkflow(workflowId: string, input: object): Promise<WorkflowExecution>; | ||
/** | ||
@@ -285,3 +284,3 @@ * List executions in a workflow, calls the GET /workflows/{workflowId}/executions endpoint. | ||
*/ | ||
getWorkflowExecution(workflowId: string, executionId: string, options?: GetWorkflowExecutionOptions): Promise<WorkflowExecution>; | ||
getWorkflowExecution(workflowId: string, executionId: string): Promise<WorkflowExecution>; | ||
/** | ||
@@ -306,3 +305,3 @@ * Retry or end the processing of a workflow execution, | ||
*/ | ||
deleteWorkflowExecution(workflowId: string, executionId: string, options?: DeleteWorkflowExecution): Promise<WorkflowExecution>; | ||
deleteWorkflowExecution(workflowId: string, executionId: string): Promise<WorkflowExecution>; | ||
/** | ||
@@ -328,3 +327,3 @@ * Create a prediction on a document using specified model, calls the POST /predictions endpoint. | ||
*/ | ||
createAsset(content: string, options?: CreateAssetOptions): Promise<Asset>; | ||
createAsset(content: string): Promise<Asset>; | ||
/** | ||
@@ -336,3 +335,3 @@ * Delete an asset, calls the DELETE /assets/{assetId} endpoint. | ||
*/ | ||
deleteAsset(assetId: string, options?: DeleteAssetOptions): Promise<Asset>; | ||
deleteAsset(assetId: string): Promise<Asset>; | ||
/** | ||
@@ -352,3 +351,3 @@ * List assets available, calls the GET /assets endpoint. | ||
*/ | ||
getAsset(assetId: string, options?: GetAssetOptions): Promise<Asset>; | ||
getAsset(assetId: string): Promise<Asset>; | ||
/** | ||
@@ -368,3 +367,3 @@ * Updates an asset, calls the PATCH /assets/{assetId} endpoint. | ||
*/ | ||
getDataset(datasetId: string, options?: GetDatasetOptions): Promise<Dataset>; | ||
getDataset(datasetId: string): Promise<Dataset>; | ||
/** | ||
@@ -403,3 +402,3 @@ * Creates a dataset, calls the POST /datasets endpoint. | ||
*/ | ||
deleteDataset(datasetId: string, deleteDocuments?: boolean, options?: DeleteDatasetOptions): Promise<Dataset>; | ||
deleteDataset(datasetId: string, deleteDocuments?: boolean): Promise<Dataset>; | ||
/** | ||
@@ -422,3 +421,3 @@ * Creates a dataBundle, calls the POST /models/{modelId}/dataBundles endpoint. | ||
*/ | ||
deleteDataBundle(modelId: string, dataBundleId: string, options?: DeleteDataBundleOptions): Promise<DataBundle>; | ||
deleteDataBundle(modelId: string, dataBundleId: string): Promise<DataBundle>; | ||
/** | ||
@@ -468,3 +467,3 @@ * List dataBundles available, calls the GET /dataBundles endpoint. | ||
*/ | ||
getUser(userId: string, options?: GetUserOptions): Promise<User>; | ||
getUser(userId: string): Promise<User>; | ||
/** | ||
@@ -485,3 +484,3 @@ * Updates a user, calls the PATCH /users/{userId} endpoint. | ||
*/ | ||
deleteUser(userId: string, options?: DeleteUserOptions): Promise<User>; | ||
deleteUser(userId: string): Promise<User>; | ||
/** | ||
@@ -521,3 +520,3 @@ * Creates a secret, calls the POST /secrets endpoint. | ||
*/ | ||
getModel(modelId: string, options?: GetModelOptions): Promise<Model>; | ||
getModel(modelId: string): Promise<Model>; | ||
/** | ||
@@ -543,3 +542,3 @@ * Updates a model, calls the PATCH /models/{modelId} endpoint. | ||
*/ | ||
deleteModel(modelId: string, options?: DeleteModelOptions): Promise<Model>; | ||
deleteModel(modelId: string): Promise<Model>; | ||
/** | ||
@@ -559,3 +558,3 @@ * List models available, calls the GET /models endpoint. | ||
*/ | ||
getLog(logId: string, options?: GetLogOptions): Promise<Log>; | ||
getLog(logId: string): Promise<Log>; | ||
/** | ||
@@ -570,10 +569,9 @@ * Updates a secret, calls the PATCH /secrets/{secretId} endpoint. | ||
updateSecret(secretId: string, data: UpdateSecretOptions): Promise<Secret>; | ||
makeGetRequest<T>(path: string, options?: any): Promise<T>; | ||
makeDeleteRequest<T>(path: string, options?: any): Promise<T>; | ||
makePostRequest<T>(path: string, options: any): Promise<T>; | ||
makePatchRequest<T>(path: string, options: any): Promise<T>; | ||
makeGetRequest<T>(path: string, query?: any): Promise<T>; | ||
makeDeleteRequest<T>(path: string, query?: any): Promise<T>; | ||
makePostRequest<T>(path: string, body: any): Promise<T>; | ||
makePatchRequest<T>(path: string, body: any): Promise<T>; | ||
private makeAuthorizedRequest; | ||
private makeAuthorizedBodyRequest; | ||
private getAuthorizationHeaders; | ||
} | ||
export default Client; |
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,23 +22,42 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Client = void 0; | ||
const axios_1 = require("axios"); | ||
const buffer_1 = require("buffer"); | ||
const utils_1 = require("./utils"); | ||
var axios_1 = __importDefault(require("axios")); | ||
var buffer_1 = require("buffer"); | ||
var utils_1 = require("./utils"); | ||
/** | ||
* A high-level http client for communicating with the Lucidtech REST API | ||
*/ | ||
class Client { | ||
constructor(credentials) { | ||
var Client = /** @class */ (function () { | ||
function Client(credentials) { | ||
this.credentials = credentials; | ||
@@ -43,7 +73,9 @@ } | ||
*/ | ||
updateOrganization(organizationId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/organizations/${organizationId}`, options); | ||
Client.prototype.updateOrganization = function (organizationId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/organizations/" + organizationId, options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -55,7 +87,9 @@ * Get organization from the REST API, calls the GET /organizations/{organizationId} endpoint. | ||
*/ | ||
getOrganization(organizationId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/organizations/${organizationId}`, options); | ||
Client.prototype.getOrganization = function (organizationId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/organizations/" + organizationId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -71,7 +105,9 @@ * Creates an app client, calls the POST /appClients endpoint. | ||
*/ | ||
createAppClient(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePostRequest('/appClients', options); | ||
Client.prototype.createAppClient = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePostRequest('/appClients', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -85,7 +121,9 @@ * Updates an appClient, calls the PATCH /appClients/{appClientId} endpoint. | ||
*/ | ||
updateAppClient(appClientId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/appClients/${appClientId}`, options); | ||
Client.prototype.updateAppClient = function (appClientId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/appClients/" + appClientId, options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -98,7 +136,9 @@ * List app clients, calls the GET /appClients endpoint. | ||
*/ | ||
listAppClients(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/appClients', options); | ||
Client.prototype.listAppClients = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/appClients', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -110,7 +150,9 @@ * Delete the app client, calls the DELETE /appClients/{appClientId} endpoint. | ||
*/ | ||
deleteAppClient(appClientId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/appClients/${appClientId}`, options); | ||
Client.prototype.deleteAppClient = function (appClientId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/appClients/" + appClientId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -125,15 +167,18 @@ * Creates a document, calls the POST /documents endpoint. | ||
*/ | ||
createDocument(content, contentType, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const encodedContent = typeof content === 'string' ? content : buffer_1.Buffer.from(content).toString('base64'); | ||
let body = { | ||
content: encodedContent, | ||
contentType, | ||
}; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/documents', body); | ||
Client.prototype.createDocument = function (content, contentType, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var encodedContent, body; | ||
return __generator(this, function (_a) { | ||
encodedContent = typeof content === 'string' ? content : buffer_1.Buffer.from(content).toString('base64'); | ||
body = { | ||
content: encodedContent, | ||
contentType: contentType, | ||
}; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/documents', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -145,7 +190,9 @@ * Get document from the REST API, calls the GET /documents/{documentId} endpoint. | ||
*/ | ||
getDocument(documentId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/documents/${documentId}`, options); | ||
Client.prototype.getDocument = function (documentId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/documents/" + documentId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -159,7 +206,9 @@ * List documents available for inference, calls the GET /documents endpoint. | ||
*/ | ||
listDocuments(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/documents', options); | ||
Client.prototype.listDocuments = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/documents', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -174,7 +223,9 @@ * Post ground truth to the REST API, calls the PATCH /documents/{documentId} endpoint. | ||
*/ | ||
updateDocument(documentId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/documents/${documentId}`, data); | ||
Client.prototype.updateDocument = function (documentId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/documents/" + documentId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -187,7 +238,9 @@ * Delete documents with the provided consentId, calls the DELETE /documents endpoint. | ||
*/ | ||
deleteDocuments(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest('/documents', options); | ||
Client.prototype.deleteDocuments = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest('/documents', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -199,7 +252,9 @@ * Delete an document, calls the DELETE /documents/{documentId} endpoint. | ||
*/ | ||
deleteDocument(documentId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/documents/${documentId}`, options); | ||
Client.prototype.deleteDocument = function (documentId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/documents/" + documentId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -216,13 +271,16 @@ * Creates a transition, calls the POST /transitions endpoint. | ||
*/ | ||
createTransition(transitionType, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { | ||
transitionType, | ||
}; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/transitions', body); | ||
Client.prototype.createTransition = function (transitionType, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { | ||
transitionType: transitionType, | ||
}; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/transitions', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -234,7 +292,9 @@ * Get the transition with the provided transitionId, calls the GET /transitions/{transitionId} endpoint. | ||
*/ | ||
getTransition(transitionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/transitions/${transitionId}`, options); | ||
Client.prototype.getTransition = function (transitionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/transitions/" + transitionId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -248,7 +308,9 @@ * List transitions, calls the GET /transitions endpoint. | ||
*/ | ||
listTransitions(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/transitions', options); | ||
Client.prototype.listTransitions = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/transitions', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -261,7 +323,9 @@ * Updates a transition, calls the PATCH /transitions/{transitionId} endpoint. | ||
*/ | ||
updateTransition(transitionId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/transitions/${transitionId}`, data); | ||
Client.prototype.updateTransition = function (transitionId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/transitions/" + transitionId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -274,7 +338,9 @@ * Delete the transition with the provided transitionId, calls the DELETE /transitions/{transitionId} endpoint. | ||
*/ | ||
deleteTransition(transitionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/transitions/${transitionId}`, options); | ||
Client.prototype.deleteTransition = function (transitionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/transitions/" + transitionId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -286,7 +352,9 @@ * Start executing a manual transition, calls the POST /transitions/{transitionId}/executions endpoint. | ||
*/ | ||
executeTransition(transitionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePostRequest(`/transitions/${transitionId}/executions`, options); | ||
Client.prototype.executeTransition = function (transitionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePostRequest("/transitions/" + transitionId + "/executions", {})]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -299,7 +367,9 @@ * Get an execution of a transition, calls the GET /transitions/{transitionId}/executions/{executionId} endpoint | ||
*/ | ||
getTransitionExecution(transitionId, transitionExecutionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/transitions/${transitionId}/executions/${transitionExecutionId}`, options); | ||
Client.prototype.getTransitionExecution = function (transitionId, transitionExecutionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/transitions/" + transitionId + "/executions/" + transitionExecutionId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -317,7 +387,9 @@ * Ends the processing of the transition execution, calls the | ||
*/ | ||
updateTransitionExecution(transitionId, executionId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/transitions/${transitionId}/executions/${executionId}`, data); | ||
Client.prototype.updateTransitionExecution = function (transitionId, executionId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/transitions/" + transitionId + "/executions/" + executionId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -333,7 +405,9 @@ * List executions in a transition, calls the GET /transitions/{transitionId}/executions endpoint. | ||
*/ | ||
listTransitionExecutions(transitionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/transitions/${transitionId}/executions`, options); | ||
Client.prototype.listTransitionExecutions = function (transitionId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/transitions/" + transitionId + "/executions", options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -348,7 +422,9 @@ * Send heartbeat for a manual execution to signal that we are still working on it. | ||
*/ | ||
sendHeartbeat(transitionId, transitionExecutionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePostRequest(`/transitions/${transitionId}/executions/${transitionExecutionId}/heartbeats`, options); | ||
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", {})]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -363,14 +439,17 @@ * Creates a new workflow, calls the POST /workflows endpoint. | ||
*/ | ||
createWorkflow(name, specification, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { | ||
name, | ||
specification, | ||
}; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/workflows', body); | ||
Client.prototype.createWorkflow = function (name, specification, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { | ||
name: name, | ||
specification: specification, | ||
}; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/workflows', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -382,7 +461,9 @@ * Get the workflow with the provided workflowId, calls the GET /workflows/{workflowId} endpoint. | ||
*/ | ||
getWorkflow(workflowId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/workflows/${workflowId}`, options); | ||
Client.prototype.getWorkflow = function (workflowId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/workflows/" + workflowId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -395,7 +476,9 @@ * List workflows, calls the GET /workflows endpoint. | ||
*/ | ||
listWorkflows(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/workflows', options); | ||
Client.prototype.listWorkflows = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/workflows', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -407,7 +490,9 @@ * Delete the workflow with the provided workflowId, calls the DELETE /workflows/{workflowId} endpoint. | ||
*/ | ||
deleteWorkflow(workflowId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/workflows/${workflowId}`, options); | ||
Client.prototype.deleteWorkflow = function (workflowId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/workflows/" + workflowId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -419,7 +504,9 @@ * Updates a workflow, calls the PATCH /workflows/{workflowId} endpoint. | ||
*/ | ||
updateWorkflow(workflowId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/workflows/${workflowId}`, data); | ||
Client.prototype.updateWorkflow = function (workflowId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/workflows/" + workflowId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -432,8 +519,13 @@ * Start a workflow execution, calls the POST /workflows/{workflowId}/executions endpoint. | ||
*/ | ||
executeWorkflow(workflowId, input, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const body = Object.assign({ input }, options); | ||
return this.makePostRequest(`/workflows/${workflowId}/executions`, body); | ||
Client.prototype.executeWorkflow = function (workflowId, input) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { | ||
input: input, | ||
}; | ||
return [2 /*return*/, this.makePostRequest("/workflows/" + workflowId + "/executions", body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -450,7 +542,9 @@ * List executions in a workflow, calls the GET /workflows/{workflowId}/executions endpoint. | ||
*/ | ||
listWorkflowExecutions(workflowId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/workflows/${workflowId}/executions`, options); | ||
Client.prototype.listWorkflowExecutions = function (workflowId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/workflows/" + workflowId + "/executions", options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -463,7 +557,9 @@ * Get a workflow execution, calls the GET /workflows/{workflowId}/executions/{executionId} endpoint. | ||
*/ | ||
getWorkflowExecution(workflowId, executionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/workflows/${workflowId}/executions/${executionId}`, options); | ||
Client.prototype.getWorkflowExecution = function (workflowId, executionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/workflows/" + workflowId + "/executions/" + executionId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -479,7 +575,9 @@ * Retry or end the processing of a workflow execution, | ||
*/ | ||
updateWorkflowExecution(workflowId, executionId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/workflows/${workflowId}/executions/${executionId}`, data); | ||
Client.prototype.updateWorkflowExecution = function (workflowId, executionId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/workflows/" + workflowId + "/executions/" + executionId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -493,7 +591,9 @@ * Deletes the execution with the provided executionId from workflowId, | ||
*/ | ||
deleteWorkflowExecution(workflowId, executionId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/workflows/${workflowId}/executions/${executionId}`, options); | ||
Client.prototype.deleteWorkflowExecution = function (workflowId, executionId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/workflows/" + workflowId + "/executions/" + executionId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -511,19 +611,24 @@ * Create a prediction on a document using specified model, calls the POST /predictions endpoint. | ||
*/ | ||
createPrediction(documentId, modelId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { | ||
documentId, | ||
modelId, | ||
}; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/predictions', body); | ||
Client.prototype.createPrediction = function (documentId, modelId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { | ||
documentId: documentId, | ||
modelId: modelId, | ||
}; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/predictions', body)]; | ||
}); | ||
}); | ||
} | ||
listPredictions(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/predictions', options); | ||
}; | ||
Client.prototype.listPredictions = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/predictions', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -535,8 +640,11 @@ * Creates an asset, calls the POST /assets endpoint. | ||
*/ | ||
createAsset(content, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const encodedContent = typeof content === 'string' ? content : buffer_1.Buffer.from(content).toString('base64'); | ||
return this.makePostRequest('/assets', Object.assign({ content: encodedContent }, options)); | ||
Client.prototype.createAsset = function (content) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var encodedContent; | ||
return __generator(this, function (_a) { | ||
encodedContent = typeof content === 'string' ? content : buffer_1.Buffer.from(content).toString('base64'); | ||
return [2 /*return*/, this.makePostRequest('/assets', { content: encodedContent })]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -548,7 +656,9 @@ * Delete an asset, calls the DELETE /assets/{assetId} endpoint. | ||
*/ | ||
deleteAsset(assetId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/assets/${assetId}`, options); | ||
Client.prototype.deleteAsset = function (assetId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/assets/" + assetId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -561,7 +671,9 @@ * List assets available, calls the GET /assets endpoint. | ||
*/ | ||
listAssets(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/assets', options); | ||
Client.prototype.listAssets = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/assets', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -573,7 +685,9 @@ * Get asset from the REST API, calls the GET /assets/{assetId} endpoint. | ||
*/ | ||
getAsset(assetId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/assets/${assetId}`, options); | ||
Client.prototype.getAsset = function (assetId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/assets/" + assetId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -586,15 +700,17 @@ * Updates an asset, calls the PATCH /assets/{assetId} endpoint. | ||
*/ | ||
updateAsset(assetId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body; | ||
if (data) { | ||
body = Object.assign({}, data); | ||
if (data.content) { | ||
const encodedContent = typeof data.content === 'string' ? data.content : buffer_1.Buffer.from(data.content).toString('base64'); | ||
body = Object.assign(Object.assign({}, body), { content: encodedContent }); | ||
Client.prototype.updateAsset = function (assetId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body, encodedContent; | ||
return __generator(this, function (_a) { | ||
if (data) { | ||
body = __assign({}, data); | ||
if (data.content) { | ||
encodedContent = typeof data.content === 'string' ? data.content : buffer_1.Buffer.from(data.content).toString('base64'); | ||
body = __assign(__assign({}, body), { content: encodedContent }); | ||
} | ||
} | ||
} | ||
return this.makePatchRequest(`/assets/${assetId}`, body); | ||
return [2 /*return*/, this.makePatchRequest("/assets/" + assetId, body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -606,7 +722,9 @@ * Get dataset from the REST API, calls the GET /datasets/{datasetId} endpoint. | ||
*/ | ||
getDataset(datasetId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/datasets/${datasetId}`, options); | ||
Client.prototype.getDataset = function (datasetId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/datasets/" + datasetId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -620,7 +738,9 @@ * Creates a dataset, calls the POST /datasets endpoint. | ||
*/ | ||
createDataset(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePostRequest('/datasets', options); | ||
Client.prototype.createDataset = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePostRequest('/datasets', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -634,7 +754,9 @@ * Updates a dataset, calls the PATCH /datasets/{datasetId} endpoint. | ||
*/ | ||
updateDataset(datasetId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/datasets/${datasetId}`, options); | ||
Client.prototype.updateDataset = function (datasetId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/datasets/" + datasetId, options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -647,7 +769,9 @@ * List datasets, calls the GET /datasets endpoint. | ||
*/ | ||
listDatasets(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/datasets', options); | ||
Client.prototype.listDatasets = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/datasets', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -660,30 +784,54 @@ * Deletes a dataset, calls the DELETE /datasets/{datasetId} endpoint. | ||
*/ | ||
deleteDataset(datasetId, deleteDocuments = false, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (deleteDocuments) { | ||
let response = yield this.deleteDocuments({ datasetId }); | ||
while (response.nextToken) { | ||
response = yield this.deleteDocuments({ datasetId, nextToken: response.nextToken }); | ||
Client.prototype.deleteDataset = function (datasetId, deleteDocuments) { | ||
if (deleteDocuments === void 0) { deleteDocuments = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, WAIT_MS, TOTAL_WAIT, MAX_WAIT_MS, datasetResponse; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!deleteDocuments) return [3 /*break*/, 11]; | ||
return [4 /*yield*/, this.deleteDocuments({ datasetId: datasetId })]; | ||
case 1: | ||
response = _a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
if (!response.nextToken) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.deleteDocuments({ datasetId: datasetId, nextToken: response.nextToken })]; | ||
case 3: | ||
response = _a.sent(); | ||
return [3 /*break*/, 2]; | ||
case 4: | ||
WAIT_MS = 1000; | ||
TOTAL_WAIT = WAIT_MS; | ||
MAX_WAIT_MS = 10000; | ||
return [4 /*yield*/, utils_1.wait(WAIT_MS)]; | ||
case 5: | ||
_a.sent(); | ||
return [4 /*yield*/, this.getDataset(datasetId)]; | ||
case 6: | ||
datasetResponse = _a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
if (!(datasetResponse.numberOfDocuments > 0 && TOTAL_WAIT < MAX_WAIT_MS)) return [3 /*break*/, 10]; | ||
// exponentially back off | ||
WAIT_MS *= 1.25; | ||
TOTAL_WAIT += WAIT_MS; | ||
return [4 /*yield*/, utils_1.wait(WAIT_MS)]; | ||
case 8: | ||
_a.sent(); | ||
return [4 /*yield*/, this.getDataset(datasetId)]; | ||
case 9: | ||
datasetResponse = _a.sent(); | ||
return [3 /*break*/, 7]; | ||
case 10: | ||
// if the numberOfDocuments has not yet been updated, throw an error | ||
if (datasetResponse.numberOfDocuments > 0) { | ||
throw Error('Dataset numberOfDocuments not updated in time'); | ||
} | ||
_a.label = 11; | ||
case 11: return [2 /*return*/, this.makeDeleteRequest("/datasets/" + datasetId)]; | ||
} | ||
let WAIT_MS = 1000; | ||
let TOTAL_WAIT = WAIT_MS; | ||
const MAX_WAIT_MS = 10000; | ||
yield (0, utils_1.wait)(WAIT_MS); | ||
let datasetResponse = yield this.getDataset(datasetId); | ||
// wait until we get the updated numberOfDocuments, OR we time out | ||
while (datasetResponse.numberOfDocuments > 0 && TOTAL_WAIT < MAX_WAIT_MS) { | ||
// exponentially back off | ||
WAIT_MS *= 1.25; | ||
TOTAL_WAIT += WAIT_MS; | ||
yield (0, utils_1.wait)(WAIT_MS); | ||
datasetResponse = yield this.getDataset(datasetId); | ||
} | ||
// if the numberOfDocuments has not yet been updated, throw an error | ||
if (datasetResponse.numberOfDocuments > 0) { | ||
throw Error('Dataset numberOfDocuments not updated in time'); | ||
} | ||
} | ||
return this.makeDeleteRequest(`/datasets/${datasetId}`, options); | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -698,11 +846,14 @@ * Creates a dataBundle, calls the POST /models/{modelId}/dataBundles endpoint. | ||
*/ | ||
createDataBundle(modelId, datasetIds, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { datasetIds }; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest(`/models/${modelId}/dataBundles`, body); | ||
Client.prototype.createDataBundle = function (modelId, datasetIds, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { datasetIds: datasetIds }; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest("/models/" + modelId + "/dataBundles", body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -715,7 +866,9 @@ * Delete a dataBundle, calls the DELETE /dataBundles/{dataBundleId} endpoint. | ||
*/ | ||
deleteDataBundle(modelId, dataBundleId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/models/${modelId}/dataBundles/${dataBundleId}`, options); | ||
Client.prototype.deleteDataBundle = function (modelId, dataBundleId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/models/" + modelId + "/dataBundles/" + dataBundleId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -729,7 +882,9 @@ * List dataBundles available, calls the GET /dataBundles endpoint. | ||
*/ | ||
listDataBundles(modelId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/models/${modelId}/dataBundles`, options); | ||
Client.prototype.listDataBundles = function (modelId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/models/" + modelId + "/dataBundles", options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -744,7 +899,9 @@ * Updates a dataBundle, calls the PATCH /dataBundles/{dataBundleId} endpoint. | ||
*/ | ||
updateDataBundle(modelId, dataBundleId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/models/${modelId}/dataBundles/${dataBundleId}`, options); | ||
Client.prototype.updateDataBundle = function (modelId, dataBundleId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/models/" + modelId + "/dataBundles/" + dataBundleId, options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -760,11 +917,14 @@ * Creates a new user, calls the POST /users endpoint. | ||
*/ | ||
createUser(email, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { email }; | ||
if (data) { | ||
body = Object.assign(Object.assign({}, body), data); | ||
} | ||
return this.makePostRequest('/users', body); | ||
Client.prototype.createUser = function (email, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { email: email }; | ||
if (data) { | ||
body = __assign(__assign({}, body), data); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/users', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -777,7 +937,9 @@ * List users, calls the GET /users endpoint. | ||
*/ | ||
listUsers(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/users', options); | ||
Client.prototype.listUsers = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/users', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -789,7 +951,9 @@ * Get information about a specific user, calls the GET /users/{userId} endpoint. | ||
*/ | ||
getUser(userId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/users/${userId}`, options); | ||
Client.prototype.getUser = function (userId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/users/" + userId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -803,7 +967,9 @@ * Updates a user, calls the PATCH /users/{userId} endpoint. | ||
*/ | ||
updateUser(userId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/users/${userId}`, data); | ||
Client.prototype.updateUser = function (userId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/users/" + userId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -815,7 +981,9 @@ * Delete a user, calls the DELETE /users/{userId} endpoint. | ||
*/ | ||
deleteUser(userId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/users/${userId}`, options); | ||
Client.prototype.deleteUser = function (userId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/users/" + userId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -828,11 +996,14 @@ * Creates a secret, calls the POST /secrets endpoint. | ||
*/ | ||
createSecret(data, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { data }; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/secrets', body); | ||
Client.prototype.createSecret = function (data, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { data: data }; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/secrets', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -845,7 +1016,9 @@ * List secrets available, calls the GET /secrets endpoint. | ||
*/ | ||
listSecrets(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/secrets', options); | ||
Client.prototype.listSecrets = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/secrets', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -862,11 +1035,14 @@ * Creates a model, calls the POST /models endpoint. | ||
*/ | ||
createModel(fieldConfig, width, height, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let body = { fieldConfig, width, height }; | ||
if (options) { | ||
body = Object.assign(Object.assign({}, body), options); | ||
} | ||
return this.makePostRequest('/models', body); | ||
Client.prototype.createModel = function (fieldConfig, width, height, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var body; | ||
return __generator(this, function (_a) { | ||
body = { fieldConfig: fieldConfig, width: width, height: height }; | ||
if (options) { | ||
body = __assign(__assign({}, body), options); | ||
} | ||
return [2 /*return*/, this.makePostRequest('/models', body)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -878,7 +1054,9 @@ * Get model from the REST API, calls the GET /models/{modelId} endpoint. | ||
*/ | ||
getModel(modelId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/models/${modelId}`, options); | ||
Client.prototype.getModel = function (modelId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/models/" + modelId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -897,7 +1075,9 @@ * Updates a model, calls the PATCH /models/{modelId} endpoint. | ||
*/ | ||
updateModel(modelId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/models/${modelId}`, options); | ||
Client.prototype.updateModel = function (modelId, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/models/" + modelId, options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -909,7 +1089,9 @@ * Delete an model, calls the DELETE /models/{modelId} endpoint. | ||
*/ | ||
deleteModel(modelId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeDeleteRequest(`/models/${modelId}`, options); | ||
Client.prototype.deleteModel = function (modelId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeDeleteRequest("/models/" + modelId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -922,7 +1104,9 @@ * List models available, calls the GET /models endpoint. | ||
*/ | ||
listModels(options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest('/models', options); | ||
Client.prototype.listModels = function (options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest('/models', options)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -934,7 +1118,9 @@ * Get log, calls the GET /logs/{logId} endpoint. | ||
*/ | ||
getLog(logId, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeGetRequest(`/logs/${logId}`, options); | ||
Client.prototype.getLog = function (logId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeGetRequest("/logs/" + logId)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
@@ -948,66 +1134,77 @@ * Updates a secret, calls the PATCH /secrets/{secretId} endpoint. | ||
*/ | ||
updateSecret(secretId, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makePatchRequest(`/secrets/${secretId}`, data); | ||
Client.prototype.updateSecret = function (secretId, data) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makePatchRequest("/secrets/" + secretId, data)]; | ||
}); | ||
}); | ||
} | ||
}; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
makeGetRequest(path, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { requestConfig } = options, query = __rest(options, ["requestConfig"]); | ||
return this.makeAuthorizedRequest(axios_1.default.get, (0, utils_1.buildURL)(path, query), requestConfig); | ||
Client.prototype.makeGetRequest = function (path, query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeAuthorizedRequest(axios_1.default.get, utils_1.buildURL(path, query))]; | ||
}); | ||
}); | ||
} | ||
makeDeleteRequest(path, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { requestConfig } = options, query = __rest(options, ["requestConfig"]); | ||
return this.makeAuthorizedRequest(axios_1.default.delete, (0, utils_1.buildURL)(path, query), requestConfig); | ||
}; | ||
Client.prototype.makeDeleteRequest = function (path, query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeAuthorizedRequest(axios_1.default.delete, utils_1.buildURL(path, query))]; | ||
}); | ||
}); | ||
} | ||
makePostRequest(path, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeAuthorizedBodyRequest(axios_1.default.post, path, options); | ||
}; | ||
Client.prototype.makePostRequest = function (path, body) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeAuthorizedRequest(axios_1.default.post, path, body)]; | ||
}); | ||
}); | ||
} | ||
makePatchRequest(path, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.makeAuthorizedBodyRequest(axios_1.default.patch, path, options); | ||
}; | ||
Client.prototype.makePatchRequest = function (path, body) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.makeAuthorizedRequest(axios_1.default.patch, path, body)]; | ||
}); | ||
}); | ||
} | ||
makeAuthorizedRequest(axiosFn, path, requestConfig = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = `${this.credentials.apiEndpoint}${path}`; | ||
const headers = yield this.getAuthorizationHeaders(); | ||
let config = { headers }; | ||
if (requestConfig) { | ||
config = Object.assign(Object.assign({}, config), requestConfig); | ||
} | ||
const result = yield axiosFn(endpoint, config); | ||
return result.data; | ||
}; | ||
Client.prototype.makeAuthorizedRequest = function (axiosFn, path, body) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var endpoint, headers, config, handle; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
endpoint = "" + this.credentials.apiEndpoint + path; | ||
return [4 /*yield*/, this.getAuthorizationHeaders()]; | ||
case 1: | ||
headers = _a.sent(); | ||
config = { headers: headers }; | ||
handle = body | ||
? function () { return axiosFn(endpoint, body, config); } | ||
: function () { return axiosFn(endpoint, config); }; | ||
return [4 /*yield*/, handle()]; | ||
case 2: return [2 /*return*/, (_a.sent()).data]; | ||
} | ||
}); | ||
}); | ||
} | ||
makeAuthorizedBodyRequest(axiosFn, path, options = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const endpoint = `${this.credentials.apiEndpoint}${path}`; | ||
const headers = yield this.getAuthorizationHeaders(); | ||
const { requestConfig } = options, body = __rest(options, ["requestConfig"]); | ||
let config = { headers }; | ||
if (requestConfig) { | ||
config = Object.assign(Object.assign({}, config), requestConfig); | ||
} | ||
const result = yield axiosFn(endpoint, body, config); | ||
return result.data; | ||
}); | ||
} | ||
}; | ||
/* eslint-enable */ | ||
getAuthorizationHeaders() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const accessToken = yield this.credentials.getAccessToken(); | ||
return { | ||
Authorization: `Bearer ${accessToken}`, | ||
}; | ||
Client.prototype.getAuthorizationHeaders = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var accessToken; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.credentials.getAccessToken()]; | ||
case 1: | ||
accessToken = _a.sent(); | ||
return [2 /*return*/, { | ||
Authorization: "Bearer " + accessToken, | ||
}]; | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
return Client; | ||
}()); | ||
exports.Client = Client; | ||
exports.default = Client; |
@@ -7,3 +7,3 @@ "use strict"; | ||
*/ | ||
class Token { | ||
var Token = /** @class */ (function () { | ||
/** | ||
@@ -14,3 +14,3 @@ * @param {string} accessToken | ||
*/ | ||
constructor(accessToken, expiration, refreshToken) { | ||
function Token(accessToken, expiration, refreshToken) { | ||
this.accessToken = accessToken; | ||
@@ -23,6 +23,7 @@ this.expiration = expiration; | ||
*/ | ||
isValid() { | ||
Token.prototype.isValid = function () { | ||
return Date.now() < this.expiration; | ||
} | ||
} | ||
}; | ||
return Token; | ||
}()); | ||
exports.Token = Token; | ||
@@ -32,4 +33,4 @@ /** | ||
*/ | ||
class Credentials { | ||
constructor(apiEndpoint, storage) { | ||
var Credentials = /** @class */ (function () { | ||
function Credentials(apiEndpoint, storage) { | ||
this.apiEndpoint = apiEndpoint; | ||
@@ -44,6 +45,7 @@ this.storage = storage; | ||
*/ | ||
getAccessToken() { | ||
const { storage } = this; | ||
return new Promise((resolve, reject) => { | ||
let token = this.token || null; | ||
Credentials.prototype.getAccessToken = function () { | ||
var _this = this; | ||
var storage = this.storage; | ||
return new Promise(function (resolve, reject) { | ||
var token = _this.token || null; | ||
if (!(token && token.isValid()) && storage) { | ||
@@ -53,8 +55,7 @@ token = storage.getPersistentToken(); | ||
if (token && token.isValid()) { | ||
this.token = token; | ||
_this.token = token; | ||
return resolve(token.accessToken); | ||
} | ||
this.getToken() | ||
.then((newToken) => { | ||
this.token = newToken; | ||
_this.getToken().then(function (newToken) { | ||
_this.token = newToken; | ||
if (storage) { | ||
@@ -64,9 +65,9 @@ storage.setPersistentToken(newToken); | ||
resolve(newToken.accessToken); | ||
}) | ||
.catch((error) => { | ||
}).catch(function (error) { | ||
reject(error); | ||
}); | ||
}); | ||
} | ||
} | ||
}; | ||
return Credentials; | ||
}()); | ||
exports.Credentials = Credentials; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTestClient = exports.sleep = exports.TestCredentials = void 0; | ||
const credentials_1 = require("./credentials"); | ||
const client_1 = require("./client"); | ||
const endpoint = 'http://localhost:4010'; | ||
class TestCredentials extends credentials_1.Credentials { | ||
constructor(testEndpoint, testAccessToken, testExpiresInSeconds, testRefreshToken) { | ||
super(testEndpoint); | ||
this.testAccessToken = testAccessToken; | ||
this.testExpiration = Date.now() + 1000 * testExpiresInSeconds; | ||
this.testRefreshToken = testRefreshToken; | ||
var credentials_1 = require("./credentials"); | ||
var client_1 = require("./client"); | ||
var endpoint = 'http://localhost:4010'; | ||
var TestCredentials = /** @class */ (function (_super) { | ||
__extends(TestCredentials, _super); | ||
function TestCredentials(testEndpoint, testAccessToken, testExpiresInSeconds, testRefreshToken) { | ||
var _this = _super.call(this, testEndpoint) || this; | ||
_this.testAccessToken = testAccessToken; | ||
_this.testExpiration = Date.now() + 1000 * testExpiresInSeconds; | ||
_this.testRefreshToken = testRefreshToken; | ||
return _this; | ||
} | ||
getToken() { | ||
return new Promise((resolve, _reject) => { | ||
resolve(new credentials_1.Token(this.testAccessToken, this.testExpiration, this.testRefreshToken)); | ||
TestCredentials.prototype.getToken = function () { | ||
var _this = this; | ||
return new Promise(function (resolve, reject) { | ||
resolve(new credentials_1.Token(_this.testAccessToken, _this.testExpiration, _this.testRefreshToken)); | ||
}); | ||
} | ||
} | ||
}; | ||
return TestCredentials; | ||
}(credentials_1.Credentials)); | ||
exports.TestCredentials = TestCredentials; | ||
function sleep(seconds) { | ||
return new Promise((resolve) => setTimeout(resolve, 1000 * seconds)); | ||
return new Promise(function (resolve) { return setTimeout(resolve, 1000 * seconds); }); | ||
} | ||
exports.sleep = sleep; | ||
function getTestClient() { | ||
const testAccessToken = 'testAccessToken'; | ||
const testExpiresInSeconds = 3600; | ||
const testRefreshToken = 'testRefreshToken'; | ||
const credentials = new TestCredentials(endpoint, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
var testAccessToken = 'testAccessToken'; | ||
var testExpiresInSeconds = 3600; | ||
var testRefreshToken = 'testRefreshToken'; | ||
var credentials = new TestCredentials(endpoint, testAccessToken, testExpiresInSeconds, testRefreshToken); | ||
return new client_1.Client(credentials); | ||
} | ||
exports.getTestClient = getTestClient; |
/// <reference types="node" /> | ||
import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
export declare type RequestConfig = { | ||
requestConfig?: Pick<AxiosRequestConfig, 'signal'>; | ||
}; | ||
export declare type ContentType = 'application/pdf' | 'image/jpeg' | 'image/png' | 'image/tiff'; | ||
@@ -27,3 +24,3 @@ export declare type GroundTruth = { | ||
export declare type LasDocumentWithoutContent = Omit<LasDocument, 'content'>; | ||
export declare type CreateDocumentOptions = RequestConfig & { | ||
export interface CreateDocumentOptions { | ||
consentId?: string; | ||
@@ -33,17 +30,15 @@ datasetId?: string; | ||
retentionInDays?: number; | ||
}; | ||
export declare type UpdateDocumentOptions = RequestConfig & { | ||
} | ||
export interface UpdateDocumentOptions { | ||
groundTruth?: Array<GroundTruth>; | ||
retentionInDays?: number; | ||
}; | ||
export declare type GetDocumentOptions = RequestConfig; | ||
export declare type DeleteDocumentsOptions = RequestConfig & PaginationOptions & { | ||
} | ||
export declare type DeleteDocumentOptions = PaginationOptions & { | ||
consentId?: string | Array<string>; | ||
datasetId?: string | Array<string>; | ||
}; | ||
export declare type ListDocumentsOptions = RequestConfig & PaginationOptions & { | ||
export declare type ListDocumentsOptions = PaginationOptions & { | ||
consentId?: string | Array<string>; | ||
datasetId?: string | Array<string>; | ||
}; | ||
export declare type DeleteDocumentOptions = RequestConfig; | ||
export declare type LasDocumentList = { | ||
@@ -64,3 +59,3 @@ documents: Array<LasDocumentWithoutContent>; | ||
export declare type PostprocessConfig = BestFirst | BestNPages; | ||
export declare type CreatePredictionsOptions = RequestConfig & { | ||
export interface CreatePredictionsOptions { | ||
maxPages?: number; | ||
@@ -70,3 +65,3 @@ autoRotate?: boolean; | ||
postprocessConfig?: PostprocessConfig; | ||
}; | ||
} | ||
export interface PaginationOptions { | ||
@@ -76,3 +71,3 @@ maxResults?: number; | ||
} | ||
export declare type ListTransitionOptions = RequestConfig & PaginationOptions & { | ||
export declare type ListTransitionOptions = PaginationOptions & { | ||
transitionType?: string | Array<string>; | ||
@@ -96,3 +91,3 @@ }; | ||
}; | ||
export declare type TransitionExecutionListOptions = RequestConfig & PaginationOptions & { | ||
export declare type TransitionExecutionListOptions = PaginationOptions & { | ||
status?: TransitionExecutionStatus | Array<TransitionExecutionStatus>; | ||
@@ -103,3 +98,3 @@ executionId?: string | Array<string>; | ||
}; | ||
export declare type UpdateTransitionExecution = RequestConfig & { | ||
export interface UpdateTransitionExecution { | ||
status: Exclude<TransitionExecutionStatus, 'running'>; | ||
@@ -111,4 +106,4 @@ output?: Record<any, any>; | ||
startTime?: string; | ||
}; | ||
export declare type CreateTransitionOptions = RequestConfig & { | ||
} | ||
export interface CreateTransitionOptions { | ||
name?: string | null; | ||
@@ -119,3 +114,3 @@ inputJsonSchema?: Record<any, any>; | ||
parameters?: CreateTransitionParams; | ||
}; | ||
} | ||
export declare type CreateTransitionDockerParams = { | ||
@@ -139,4 +134,3 @@ environment?: object; | ||
export declare type TransitionType = 'docker' | 'manual'; | ||
export declare type GetTransitionOptions = RequestConfig; | ||
export declare type UpdateTransitionOptions = RequestConfig & { | ||
export declare type UpdateTransitionOptions = { | ||
name?: string; | ||
@@ -157,3 +151,2 @@ description?: string; | ||
}; | ||
export declare type DeleteTransitionOptions = RequestConfig; | ||
export declare type TransitionList = { | ||
@@ -163,5 +156,2 @@ transitions: Array<Transition>; | ||
}; | ||
export declare type ExecuteTransitionOptions = RequestConfig; | ||
export declare type GetTransitionExecutionOptions = RequestConfig; | ||
export declare type PostHeartbeatOptions = RequestConfig; | ||
export declare type WorkflowSpecification = { | ||
@@ -190,4 +180,4 @@ definition: object; | ||
}; | ||
export declare type ListWorkflowOptions = RequestConfig & PaginationOptions; | ||
export declare type ListWorkflowExecutionsOptions = RequestConfig & PaginationOptions & { | ||
export declare type ListWorkflowOptions = PaginationOptions; | ||
export declare type ListWorkflowExecutionsOptions = PaginationOptions & { | ||
status?: string | Array<string>; | ||
@@ -197,3 +187,3 @@ sortBy?: 'startTime' | 'endTime'; | ||
}; | ||
export declare type CreateWorkflowOptions = RequestConfig & { | ||
export declare type CreateWorkflowOptions = { | ||
description?: string | null; | ||
@@ -203,3 +193,3 @@ errorConfig?: WorkflowErrorConfig; | ||
}; | ||
export declare type UpdateWorkflowOptions = RequestConfig & { | ||
export interface UpdateWorkflowOptions { | ||
name?: string | null; | ||
@@ -209,14 +199,9 @@ description?: string | null; | ||
completedConfig?: WorkflowCompletedConfig; | ||
}; | ||
export declare type GetWorkflowOptions = RequestConfig; | ||
export declare type DeleteWorkflowOptions = RequestConfig; | ||
export declare type ExecuteWorkflowOptions = RequestConfig; | ||
export declare type GetWorkflowExecutionOptions = RequestConfig; | ||
export declare type UpdateWorkflowExecutionOptions = RequestConfig & { | ||
} | ||
export interface UpdateWorkflowExecutionOptions { | ||
nextTransitionId: string; | ||
}; | ||
} | ||
export declare type WorkflowList = { | ||
workflows: Array<Workflow>; | ||
}; | ||
export declare type DeleteWorkflowExecution = RequestConfig; | ||
export declare type WorkflowExecution = { | ||
@@ -256,3 +241,3 @@ executionId: string; | ||
}; | ||
export declare type ListPredictionsOptions = RequestConfig & PaginationOptions; | ||
export declare type ListPredictionsOptions = PaginationOptions; | ||
export declare type PredictionList = { | ||
@@ -262,4 +247,2 @@ predictions: Array<PredictionResponse>; | ||
}; | ||
export declare type CreateAssetOptions = RequestConfig; | ||
export declare type DeleteAssetOptions = RequestConfig; | ||
export declare type Dataset = { | ||
@@ -280,3 +263,3 @@ containsPersonallyIdentifiableInformation: boolean; | ||
}; | ||
export declare type CreateDatasetOptions = RequestConfig & { | ||
export declare type CreateDatasetOptions = { | ||
name?: string; | ||
@@ -287,3 +270,3 @@ description?: string; | ||
}; | ||
export declare type UpdateDatasetOptions = RequestConfig & { | ||
export declare type UpdateDatasetOptions = { | ||
description?: string; | ||
@@ -296,5 +279,3 @@ name?: string; | ||
}; | ||
export declare type GetDatasetOptions = RequestConfig; | ||
export declare type ListDatasetsOptions = RequestConfig & PaginationOptions; | ||
export declare type DeleteDatasetOptions = RequestConfig; | ||
export declare type ListDatasetsOptions = PaginationOptions; | ||
export declare type DataBundle = { | ||
@@ -308,3 +289,3 @@ createdBy: string | null; | ||
name: string | null; | ||
status: 'ready' | 'processing' | 'failed'; | ||
status: 'succeeded' | 'running' | 'failed'; | ||
summary: Record<string, any>; | ||
@@ -314,8 +295,7 @@ updatedBy: string | null; | ||
}; | ||
export declare type CreateDataBundleOptions = RequestConfig & { | ||
export declare type CreateDataBundleOptions = { | ||
name?: string; | ||
description?: string; | ||
}; | ||
export declare type DeleteDataBundleOptions = RequestConfig; | ||
export declare type UpdateDataBundleOptions = RequestConfig & { | ||
export declare type UpdateDataBundleOptions = { | ||
description?: string; | ||
@@ -328,3 +308,3 @@ name?: string; | ||
}; | ||
export declare type ListDataBundleOptions = RequestConfig & PaginationOptions; | ||
export declare type ListDataBundleOptions = PaginationOptions; | ||
export declare type User = { | ||
@@ -340,3 +320,3 @@ avatar: string | null; | ||
}; | ||
export declare type CreateUserOptions = RequestConfig & { | ||
export declare type CreateUserOptions = { | ||
name?: string; | ||
@@ -346,9 +326,7 @@ avatar?: string; | ||
}; | ||
export declare type UpdateUserOptions = RequestConfig & { | ||
export declare type UpdateUserOptions = { | ||
name?: string | null; | ||
avatar?: string | null; | ||
}; | ||
export declare type ListUsersOptions = RequestConfig & PaginationOptions; | ||
export declare type GetUserOptions = RequestConfig; | ||
export declare type DeleteUserOptions = RequestConfig; | ||
export declare type ListUsersOptions = PaginationOptions; | ||
export declare type UserList = { | ||
@@ -363,3 +341,3 @@ users: Array<User>; | ||
}; | ||
export declare type ListSecretsOptions = RequestConfig & PaginationOptions; | ||
export declare type ListSecretsOptions = PaginationOptions; | ||
export declare type SecretList = { | ||
@@ -369,12 +347,11 @@ secrets: Array<Secret>; | ||
}; | ||
export declare type CreateSecretOptions = RequestConfig & { | ||
export interface CreateSecretOptions { | ||
description?: string; | ||
}; | ||
export declare type UpdateSecretOptions = RequestConfig & { | ||
} | ||
export interface UpdateSecretOptions { | ||
data?: Record<any, any>; | ||
description?: string | null; | ||
name?: string | null; | ||
}; | ||
export declare type GetOrganizationOptions = RequestConfig; | ||
export declare type UpdateOrganizationOptions = RequestConfig & { | ||
} | ||
export declare type UpdateOrganizationOptions = { | ||
description?: string; | ||
@@ -416,3 +393,3 @@ name?: string; | ||
}; | ||
export declare type CreateAppClientOptions = RequestConfig & { | ||
export declare type CreateAppClientOptions = { | ||
callbackUrls?: Array<string>; | ||
@@ -426,3 +403,3 @@ description?: string; | ||
}; | ||
export declare type UpdateAppClientOptions = RequestConfig & { | ||
export declare type UpdateAppClientOptions = { | ||
defaultLoginUrl?: string; | ||
@@ -453,4 +430,3 @@ description?: string; | ||
}; | ||
export declare type ListAppClientsOptions = RequestConfig & PaginationOptions; | ||
export declare type DeleteAppClientOptions = RequestConfig; | ||
export declare type ListAppClientsOptions = PaginationOptions; | ||
export declare type Asset = { | ||
@@ -476,3 +452,3 @@ assetId: string; | ||
export declare type FieldConfig = Record<string, Field>; | ||
export declare type CreateModelOptions = RequestConfig & { | ||
export declare type CreateModelOptions = { | ||
description?: string; | ||
@@ -482,4 +458,3 @@ name?: string; | ||
}; | ||
export declare type GetModelOptions = RequestConfig; | ||
export declare type UpdateModelOptions = RequestConfig & { | ||
export declare type UpdateModelOptions = { | ||
description?: string; | ||
@@ -490,6 +465,4 @@ fieldConfig?: FieldConfig; | ||
preprocessConfig?: PreprocessConfig; | ||
status?: 'training'; | ||
width?: number; | ||
}; | ||
export declare type DeleteModelOptions = RequestConfig; | ||
export declare type Model = { | ||
@@ -505,3 +478,3 @@ createdBy: string | null; | ||
preprocessConfig: PreprocessConfig; | ||
status: 'active' | 'inactive' | 'training'; | ||
status: 'active' | 'inactive'; | ||
updatedBy: string | null; | ||
@@ -511,3 +484,3 @@ updatedTime: string | null; | ||
}; | ||
export declare type ListModelsOptions = RequestConfig & PaginationOptions; | ||
export declare type ListModelsOptions = PaginationOptions; | ||
export declare type ModelList = { | ||
@@ -517,7 +490,6 @@ models: Array<Model>; | ||
}; | ||
export declare type UpdateAssetOptions = RequestConfig & { | ||
export interface UpdateAssetOptions { | ||
content?: string | Buffer; | ||
}; | ||
export declare type ListAssetsOptions = RequestConfig & PaginationOptions; | ||
export declare type GetAssetOptions = RequestConfig; | ||
} | ||
export declare type ListAssetsOptions = PaginationOptions; | ||
export declare type Log = { | ||
@@ -528,3 +500,2 @@ logId: string; | ||
}; | ||
export declare type GetLogOptions = RequestConfig; | ||
export declare type AuthorizationHeaders = { | ||
@@ -531,0 +502,0 @@ Authorization: string; |
@@ -8,5 +8,5 @@ "use strict"; | ||
} | ||
const searchParams = new URLSearchParams(); | ||
Object.entries(params).forEach((param) => { | ||
const [key, value] = param; | ||
var searchParams = new URLSearchParams(); | ||
Object.entries(params).forEach(function (param) { | ||
var key = param[0], value = param[1]; | ||
if (value === undefined) { | ||
@@ -24,3 +24,3 @@ return; | ||
if (Array.isArray(value)) { | ||
value.forEach((val) => { | ||
value.forEach(function (val) { | ||
searchParams.append(key, val); | ||
@@ -30,8 +30,8 @@ }); | ||
}); | ||
return `${url}?${searchParams}`; | ||
return url + "?" + searchParams; | ||
} | ||
exports.buildURL = buildURL; | ||
function wait(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
return new Promise(function (resolve) { return setTimeout(resolve, ms); }); | ||
} | ||
exports.wait = wait; |
{ | ||
"name": "@lucidtech/las-sdk-core", | ||
"version": "6.0.2-beta.0", | ||
"version": "7.0.0", | ||
"author": "Lucidtech AS <hello@lucidtech.ai>", | ||
@@ -16,16 +16,20 @@ "maintainers": [ | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"compile": "tsc", | ||
"upgrade": "npm update", | ||
"lint": "eslint ./src/**/*", | ||
"test": "jest src" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.24.0", | ||
"buffer": "^6.0.3" | ||
"axios": "^0.21.1" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.11.9", | ||
"@types/uuid": "^8.3.0", | ||
"uuid": "^8.3.1" | ||
}, | ||
"scripts": { | ||
"build": "tsc --project tsconfig.build.json", | ||
"lint": "eslint ./src/**/*", | ||
"test": "jest src" | ||
} | ||
} | ||
"gitHead": "f08a027432ea4b2ec4a04f08e452526690d130a1" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
223618
1
2
28
4950
0
2
0
+ Addedaxios@0.21.4(transitive)
- Removedbuffer@^6.0.3
- Removedaxios@0.24.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedieee754@1.2.1(transitive)
Updatedaxios@^0.21.1