@io-orkes/conductor-javascript
Version:
Typescript Client for Netflix Conductor
1,967 lines (1,952 loc) • 117 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// index.ts
var conductor_javascript_exports = {};
__export(conductor_javascript_exports, {
ApiError: () => ApiError,
AuthConductorClient: () => AuthConductorClient,
BaseHttpRequest: () => BaseHttpRequest,
CancelError: () => CancelError,
CancelablePromise: () => CancelablePromise,
ConductorClient: () => ConductorClient,
ConductorError: () => ConductorError,
DefaultLogger: () => DefaultLogger,
EventResourceService: () => EventResourceService,
HealthCheckResourceService: () => HealthCheckResourceService,
HumanExecutor: () => HumanExecutor,
MAX_RETRIES: () => MAX_RETRIES,
MetadataClient: () => MetadataClient,
MetadataResourceService: () => MetadataResourceService,
SchedulerClient: () => SchedulerClient,
SchedulerResourceService: () => SchedulerResourceService,
TaskClient: () => TaskClient,
TaskManager: () => TaskManager,
TaskResourceService: () => TaskResourceService,
TaskRunner: () => TaskRunner,
TaskType: () => TaskType,
TemplateClient: () => TemplateClient,
TokenResourceService: () => TokenResourceService,
WorkflowBulkResourceService: () => WorkflowBulkResourceService,
WorkflowExecutor: () => WorkflowExecutor,
WorkflowResourceService: () => WorkflowResourceService,
baseOrkesConductorClient: () => baseOrkesConductorClient,
completedTaskMatchingType: () => completedTaskMatchingType,
conductorEventTask: () => conductorEventTask,
doWhileTask: () => doWhileTask,
dynamicForkTask: () => dynamicForkTask,
eventTask: () => eventTask,
forkTask: () => forkTask,
forkTaskJoin: () => forkTaskJoin,
generate: () => generate,
generateDoWhileTask: () => generateDoWhileTask2,
generateEventTask: () => generateEventTask,
generateForkJoinTask: () => generateForkJoinTask2,
generateHTTPTask: () => generateHTTPTask,
generateInlineTask: () => generateInlineTask,
generateJQTransformTask: () => generateJQTransformTask,
generateJoinTask: () => generateJoinTask,
generateKafkaPublishTask: () => generateKafkaPublishTask,
generateSetVariableTask: () => generateSetVariableTask,
generateSimpleTask: () => generateSimpleTask,
generateSubWorkflowTask: () => generateSubWorkflowTask,
generateSwitchTask: () => generateSwitchTask2,
generateTerminateTask: () => generateTerminateTask,
generateWaitTask: () => generateWaitTask,
httpTask: () => httpTask,
inlineTask: () => inlineTask,
joinTask: () => joinTask,
jsonJqTask: () => jsonJqTask,
kafkaPublishTask: () => kafkaPublishTask,
newLoopTask: () => newLoopTask,
noopErrorHandler: () => noopErrorHandler,
noopLogger: () => noopLogger,
orkesConductorClient: () => orkesConductorClient,
request: () => request2,
setVariableTask: () => setVariableTask,
simpleTask: () => simpleTask,
sqsEventTask: () => sqsEventTask,
subWorkflowTask: () => subWorkflowTask,
switchTask: () => switchTask,
taskDefinition: () => taskDefinition,
taskGenMapper: () => taskGenMapper,
terminateTask: () => terminateTask,
waitTaskDuration: () => waitTaskDuration,
waitTaskUntil: () => waitTaskUntil,
workflow: () => workflow
});
module.exports = __toCommonJS(conductor_javascript_exports);
// src/common/ConductorLogger.ts
var LOG_LEVELS = {
DEBUG: 10,
INFO: 30,
ERROR: 60
};
var DefaultLogger = class {
tags;
level;
constructor(config = {}) {
const { level, tags = [] } = config;
this.tags = tags;
if (level && level in LOG_LEVELS) {
this.level = LOG_LEVELS[level];
} else {
this.level = LOG_LEVELS.INFO;
}
}
log(level, ...args) {
let resolvedLevel;
let name = level;
if (level in LOG_LEVELS) {
resolvedLevel = LOG_LEVELS[level];
} else {
name = "INFO";
resolvedLevel = LOG_LEVELS.INFO;
}
if (resolvedLevel >= this.level) {
console.log(name, ...this.tags, ...args);
}
}
info = (...args) => {
this.log("INFO", ...args);
};
debug = (...args) => {
this.log("DEBUG", ...args);
};
error = (...args) => {
this.log("ERROR", ...args);
};
};
var noopLogger = {
//eslint-disable-next-line
debug: (...args) => {
},
//eslint-disable-next-line
info: (...args) => {
},
//eslint-disable-next-line
error: (...args) => {
}
};
// src/common/types.ts
var TaskType = /* @__PURE__ */ ((TaskType2) => {
TaskType2["START"] = "START";
TaskType2["SIMPLE"] = "SIMPLE";
TaskType2["DYNAMIC"] = "DYNAMIC";
TaskType2["FORK_JOIN"] = "FORK_JOIN";
TaskType2["FORK_JOIN_DYNAMIC"] = "FORK_JOIN_DYNAMIC";
TaskType2["DECISION"] = "DECISION";
TaskType2["SWITCH"] = "SWITCH";
TaskType2["JOIN"] = "JOIN";
TaskType2["DO_WHILE"] = "DO_WHILE";
TaskType2["SUB_WORKFLOW"] = "SUB_WORKFLOW";
TaskType2["EVENT"] = "EVENT";
TaskType2["WAIT"] = "WAIT";
TaskType2["USER_DEFINED"] = "USER_DEFINED";
TaskType2["HTTP"] = "HTTP";
TaskType2["LAMBDA"] = "LAMBDA";
TaskType2["INLINE"] = "INLINE";
TaskType2["EXCLUSIVE_JOIN"] = "EXCLUSIVE_JOIN";
TaskType2["TERMINAL"] = "TERMINAL";
TaskType2["TERMINATE"] = "TERMINATE";
TaskType2["KAFKA_PUBLISH"] = "KAFKA_PUBLISH";
TaskType2["JSON_JQ_TRANSFORM"] = "JSON_JQ_TRANSFORM";
TaskType2["SET_VARIABLE"] = "SET_VARIABLE";
return TaskType2;
})(TaskType || {});
// src/common/open-api/services/EventResourceService.ts
var EventResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Get queue config by name
* @param queueType
* @param queueName
* @returns any OK
* @throws ApiError
*/
getQueueConfig(queueType, queueName) {
return this.httpRequest.request({
method: "GET",
url: "/event/queue/config/{queueType}/{queueName}",
path: {
"queueType": queueType,
"queueName": queueName
}
});
}
/**
* Create or update queue config by name
* @param queueType
* @param queueName
* @param requestBody
* @returns any OK
* @throws ApiError
*/
putQueueConfig(queueType, queueName, requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/event/queue/config/{queueType}/{queueName}",
path: {
"queueType": queueType,
"queueName": queueName
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Delete queue config by name
* @param queueType
* @param queueName
* @returns any OK
* @throws ApiError
*/
deleteQueueConfig(queueType, queueName) {
return this.httpRequest.request({
method: "DELETE",
url: "/event/queue/config/{queueType}/{queueName}",
path: {
"queueType": queueType,
"queueName": queueName
}
});
}
/**
* Get all the event handlers
* @returns EventHandler OK
* @throws ApiError
*/
getEventHandlers() {
return this.httpRequest.request({
method: "GET",
url: "/event"
});
}
/**
* Update an existing event handler.
* @param requestBody
* @returns any OK
* @throws ApiError
*/
updateEventHandler(requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/event",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Add a new event handler.
* @param requestBody
* @returns any OK
* @throws ApiError
*/
addEventHandler(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/event",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Get all queue configs
* @returns any OK
* @throws ApiError
*/
getQueueNames() {
return this.httpRequest.request({
method: "GET",
url: "/event/queue/config"
});
}
/**
* Remove an event handler
* @param name
* @returns any OK
* @throws ApiError
*/
removeEventHandlerStatus(name) {
return this.httpRequest.request({
method: "DELETE",
url: "/event/{name}",
path: {
"name": name
}
});
}
/**
* Get event handlers for a given event
* @param event
* @param activeOnly
* @returns EventHandler OK
* @throws ApiError
*/
getEventHandlersForEvent(event, activeOnly = true) {
return this.httpRequest.request({
method: "GET",
url: "/event/{event}",
path: {
"event": event
},
query: {
"activeOnly": activeOnly
}
});
}
};
// src/common/open-api/services/HealthCheckResourceService.ts
var HealthCheckResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* @returns any OK
* @throws ApiError
*/
doCheck() {
return this.httpRequest.request({
method: "GET",
url: "/health"
});
}
};
// src/common/open-api/services/MetadataResourceService.ts
var MetadataResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Gets the task definition
* @param tasktype
* @param metadata
* @returns TaskDef OK
* @throws ApiError
*/
getTaskDef(tasktype, metadata = false) {
return this.httpRequest.request({
method: "GET",
url: "/metadata/taskdefs/{tasktype}",
path: {
"tasktype": tasktype
},
query: {
"metadata": metadata
}
});
}
/**
* Remove a task definition
* @param tasktype
* @returns any OK
* @throws ApiError
*/
unregisterTaskDef(tasktype) {
return this.httpRequest.request({
method: "DELETE",
url: "/metadata/taskdefs/{tasktype}",
path: {
"tasktype": tasktype
}
});
}
/**
* Retrieves all workflow definition along with blueprint
* @param access
* @param metadata
* @param tagKey
* @param tagValue
* @returns WorkflowDef OK
* @throws ApiError
*/
getAllWorkflows(access = "READ", metadata = false, tagKey, tagValue) {
return this.httpRequest.request({
method: "GET",
url: "/metadata/workflow",
query: {
"access": access,
"metadata": metadata,
"tagKey": tagKey,
"tagValue": tagValue
}
});
}
/**
* Create or update workflow definition(s)
* @param requestBody
* @param overwrite
* @returns any OK
* @throws ApiError
*/
update(requestBody, overwrite = true) {
return this.httpRequest.request({
method: "PUT",
url: "/metadata/workflow",
query: {
"overwrite": overwrite
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Create a new workflow definition
* @param requestBody
* @param overwrite
* @returns any OK
* @throws ApiError
*/
create(requestBody, overwrite = false) {
return this.httpRequest.request({
method: "POST",
url: "/metadata/workflow",
query: {
"overwrite": overwrite
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Gets all task definition
* @param access
* @param metadata
* @param tagKey
* @param tagValue
* @returns TaskDef OK
* @throws ApiError
*/
getTaskDefs(access = "READ", metadata = false, tagKey, tagValue) {
return this.httpRequest.request({
method: "GET",
url: "/metadata/taskdefs",
query: {
"access": access,
"metadata": metadata,
"tagKey": tagKey,
"tagValue": tagValue
}
});
}
/**
* Update an existing task
* @param requestBody
* @returns any OK
* @throws ApiError
*/
updateTaskDef(requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/metadata/taskdefs",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Create or update task definition(s)
* @param requestBody
* @returns any OK
* @throws ApiError
*/
registerTaskDef(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/metadata/taskdefs",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Removes workflow definition. It does not remove workflows associated with the definition.
* @param name
* @param version
* @returns any OK
* @throws ApiError
*/
unregisterWorkflowDef(name, version) {
return this.httpRequest.request({
method: "DELETE",
url: "/metadata/workflow/{name}/{version}",
path: {
"name": name,
"version": version
}
});
}
/**
* Retrieves workflow definition along with blueprint
* @param name
* @param version
* @param metadata
* @returns WorkflowDef OK
* @throws ApiError
*/
get(name, version, metadata = false) {
return this.httpRequest.request({
method: "GET",
url: "/metadata/workflow/{name}",
path: {
"name": name
},
query: {
"version": version,
"metadata": metadata
}
});
}
};
// src/common/open-api/services/SchedulerResourceService.ts
var SchedulerResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Get an existing workflow schedule by name
* @param name
* @returns any OK
* @throws ApiError
*/
getSchedule(name) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/schedules/{name}",
path: {
"name": name
}
});
}
/**
* Deletes an existing workflow schedule by name
* @param name
* @returns any OK
* @throws ApiError
*/
deleteSchedule(name) {
return this.httpRequest.request({
method: "DELETE",
url: "/scheduler/schedules/{name}",
path: {
"name": name
}
});
}
/**
* Get list of the next x (default 3, max 5) execution times for a scheduler
* @param cronExpression
* @param scheduleStartTime
* @param scheduleEndTime
* @param limit
* @returns number OK
* @throws ApiError
*/
getNextFewSchedules(cronExpression, scheduleStartTime, scheduleEndTime, limit = 3) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/nextFewSchedules",
query: {
"cronExpression": cronExpression,
"scheduleStartTime": scheduleStartTime,
"scheduleEndTime": scheduleEndTime,
"limit": limit
}
});
}
/**
* Pauses an existing schedule by name
* @param name
* @returns any OK
* @throws ApiError
*/
pauseSchedule(name) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/schedules/{name}/pause",
path: {
"name": name
}
});
}
/**
* Pause all scheduling in a single conductor server instance (for debugging only)
* @returns any OK
* @throws ApiError
*/
pauseAllSchedules() {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/admin/pause"
});
}
/**
* Resume a paused schedule by name
* @param name
* @returns any OK
* @throws ApiError
*/
resumeSchedule(name) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/schedules/{name}/resume",
path: {
"name": name
}
});
}
/**
* Requeue all execution records
* @returns any OK
* @throws ApiError
*/
requeueAllExecutionRecords() {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/admin/requeue"
});
}
/**
* Resume all scheduling
* @returns any OK
* @throws ApiError
*/
resumeAllSchedules() {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/admin/resume"
});
}
/**
* Get all existing workflow schedules and optionally filter by workflow name
* @param workflowName
* @returns WorkflowSchedule OK
* @throws ApiError
*/
getAllSchedules(workflowName) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/schedules",
query: {
"workflowName": workflowName
}
});
}
/**
* Create or update a schedule for a specified workflow with a corresponding start workflow request
* @param requestBody
* @returns any OK
* @throws ApiError
*/
saveSchedule(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/scheduler/schedules",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Test timeout - do not use in production
* @returns any OK
* @throws ApiError
*/
testTimeout() {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/test/timeout"
});
}
/**
* Search for workflows based on payload and other parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultWorkflowScheduleExecutionModel OK
* @throws ApiError
*/
searchV21(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/scheduler/search/executions",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
};
// src/common/open-api/services/TaskResourceService.ts
var TaskResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Poll for a task of a certain type
* @param tasktype
* @param workerid
* @param domain
* @returns Task OK
* @throws ApiError
*/
poll(tasktype, workerid, domain) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/poll/{tasktype}",
path: {
"tasktype": tasktype
},
query: {
"workerid": workerid,
"domain": domain
}
});
}
/**
* Get the details about each queue
* @returns number OK
* @throws ApiError
*/
allVerbose() {
return this.httpRequest.request({
method: "GET",
url: "/tasks/queue/all/verbose"
});
}
/**
* Update a task By Ref Name
* @param workflowId
* @param taskRefName
* @param status
* @param requestBody
* @returns string OK
* @throws ApiError
*/
updateTask(workflowId, taskRefName, status, requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/tasks/{workflowId}/{taskRefName}/{status}",
path: {
"workflowId": workflowId,
"taskRefName": taskRefName,
"status": status
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Get task by Id
* @param taskId
* @returns Task OK
* @throws ApiError
*/
getTask(taskId) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/{taskId}",
path: {
"taskId": taskId
}
});
}
/**
* Get the details about each queue
* @returns number OK
* @throws ApiError
*/
all() {
return this.httpRequest.request({
method: "GET",
url: "/tasks/queue/all"
});
}
/**
* Requeue pending tasks
* @param taskType
* @returns string OK
* @throws ApiError
*/
requeuePendingTask(taskType) {
return this.httpRequest.request({
method: "POST",
url: "/tasks/queue/requeue/{taskType}",
path: {
"taskType": taskType
}
});
}
/**
* Search for tasks based in payload and other parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultTaskSummary OK
* @throws ApiError
*/
search(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/search",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
/**
* Search for tasks based in payload and other parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultTask OK
* @throws ApiError
*/
searchV22(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/search-v2",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
/**
* Get the last poll data for a given task type
* @param taskType
* @returns PollData OK
* @throws ApiError
*/
getPollData(taskType) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/queue/polldata",
query: {
"taskType": taskType
}
});
}
/**
* Get Task Execution Logs
* @param taskId
* @returns TaskExecLog OK
* @throws ApiError
*/
getTaskLogs(taskId) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/{taskId}/log",
path: {
"taskId": taskId
}
});
}
/**
* Log Task Execution Details
* @param taskId
* @param requestBody
* @returns any OK
* @throws ApiError
*/
log(taskId, requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/tasks/{taskId}/log",
path: {
"taskId": taskId
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Get the last poll data for all task types
* @returns PollData OK
* @throws ApiError
*/
getAllPollData() {
return this.httpRequest.request({
method: "GET",
url: "/tasks/queue/polldata/all"
});
}
/**
* Batch poll for a task of a certain type
* @param tasktype
* @param workerid
* @param domain
* @param count
* @param timeout
* @returns Task OK
* @throws ApiError
*/
batchPoll(tasktype, workerid, domain, count = 1, timeout = 100) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/poll/batch/{tasktype}",
path: {
"tasktype": tasktype
},
query: {
"workerid": workerid,
"domain": domain,
"count": count,
"timeout": timeout
}
});
}
/**
* Update a task
* @param requestBody
* @returns string OK
* @throws ApiError
*/
updateTask1(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/tasks",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Get Task type queue sizes
* @param taskType
* @returns number OK
* @throws ApiError
*/
size1(taskType) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/queue/sizes",
query: {
"taskType": taskType
}
});
}
/**
* Get the external uri where the task payload is to be stored
* @param path
* @param operation
* @param payloadType
* @returns ExternalStorageLocation OK
* @throws ApiError
*/
getExternalStorageLocation1(path, operation, payloadType) {
return this.httpRequest.request({
method: "GET",
url: "/tasks/externalstoragelocation",
query: {
"path": path,
"operation": operation,
"payloadType": payloadType
}
});
}
};
// src/common/open-api/services/TokenResourceService.ts
var TokenResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Generate JWT with the given access key
* @param requestBody
* @returns Response OK
* @throws ApiError
*/
generateToken(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/token",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Get the user info from the token
* @returns any OK
* @throws ApiError
*/
getUserInfo() {
return this.httpRequest.request({
method: "GET",
url: "/token/userInfo"
});
}
};
// src/common/open-api/services/WorkflowBulkResourceService.ts
var WorkflowBulkResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Retry the last failed task for each workflow from the list
* @param requestBody
* @returns BulkResponse OK
* @throws ApiError
*/
retry(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/bulk/retry",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Restart the list of completed workflow
* @param requestBody
* @param useLatestDefinitions
* @returns BulkResponse OK
* @throws ApiError
*/
restart(requestBody, useLatestDefinitions = false) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/bulk/restart",
query: {
"useLatestDefinitions": useLatestDefinitions
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Terminate workflows execution
* @param requestBody
* @param reason
* @returns BulkResponse OK
* @throws ApiError
*/
terminate(requestBody, reason) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/bulk/terminate",
query: {
"reason": reason
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Resume the list of workflows
* @param requestBody
* @returns BulkResponse OK
* @throws ApiError
*/
resumeWorkflow(requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/bulk/resume",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Pause the list of workflows
* @param requestBody
* @returns BulkResponse OK
* @throws ApiError
*/
pauseWorkflow1(requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/bulk/pause",
body: requestBody,
mediaType: "application/json"
});
}
};
// src/common/open-api/services/WorkflowResourceService.ts
var WorkflowResourceService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* Retrieve all the running workflows
* @param name
* @param version
* @param startTime
* @param endTime
* @returns string OK
* @throws ApiError
*/
getRunningWorkflow(name, version = 1, startTime, endTime) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/running/{name}",
path: {
"name": name
},
query: {
"version": version,
"startTime": startTime,
"endTime": endTime
}
});
}
/**
* Execute a workflow synchronously
* @param body
* @param name
* @param version
* @param requestId
* @param waitUntilTaskRef
* @param callback
* @returns workflowRun
* @throws ApiError
*/
executeWorkflow(body, name, version, requestId, waitUntilTaskRef) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/execute/{name}/{version}",
path: {
"name": name,
"version": version
},
query: {
"requestId": requestId,
"waitUntilTaskRef": waitUntilTaskRef
},
body,
mediaType: "application/json"
});
}
/**
* Start a new workflow with StartWorkflowRequest, which allows task to be executed in a domain
* @param requestBody
* @returns string OK
* @throws ApiError
*/
startWorkflow(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/workflow",
body: requestBody,
mediaType: "application/json"
});
}
/**
* Starts the decision task for a workflow
* @param workflowId
* @returns any OK
* @throws ApiError
*/
decide(workflowId) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/decide/{workflowId}",
path: {
"workflowId": workflowId
}
});
}
/**
* Reruns the workflow from a specific task
* @param workflowId
* @param requestBody
* @returns string OK
* @throws ApiError
*/
rerun(workflowId, requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{workflowId}/rerun",
path: {
"workflowId": workflowId
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Search for workflows based on payload and other parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultWorkflow OK
* @throws ApiError
*/
searchV21(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/search-v2",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
/**
* Pauses the workflow
* @param workflowId
* @returns any OK
* @throws ApiError
*/
pauseWorkflow(workflowId) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/{workflowId}/pause",
path: {
"workflowId": workflowId
}
});
}
/**
* Skips a given task from a current running workflow
* @param workflowId
* @param taskReferenceName
* @param requestBody
* @returns any OK
* @throws ApiError
*/
skipTaskFromWorkflow(workflowId, taskReferenceName, requestBody) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/{workflowId}/skiptask/{taskReferenceName}",
path: {
"workflowId": workflowId,
"taskReferenceName": taskReferenceName
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Lists workflows for the given correlation id list
* @param name
* @param requestBody
* @param includeClosed
* @param includeTasks
* @returns Workflow OK
* @throws ApiError
*/
getWorkflows(name, requestBody, includeClosed = false, includeTasks = false) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{name}/correlated",
path: {
"name": name
},
query: {
"includeClosed": includeClosed,
"includeTasks": includeTasks
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Gets the workflow by workflow id
* @param workflowId
* @param includeOutput
* @param includeVariables
* @returns WorkflowStatus OK
* @throws ApiError
*/
getWorkflowStatusSummary(workflowId, includeOutput = false, includeVariables = false) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/{workflowId}/status",
path: {
"workflowId": workflowId
},
query: {
"includeOutput": includeOutput,
"includeVariables": includeVariables
}
});
}
/**
* Lists workflows for the given correlation id
* @param name
* @param correlationId
* @param includeClosed
* @param includeTasks
* @returns Workflow OK
* @throws ApiError
*/
getWorkflows1(name, correlationId, includeClosed = false, includeTasks = false) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/{name}/correlated/{correlationId}",
path: {
"name": name,
"correlationId": correlationId
},
query: {
"includeClosed": includeClosed,
"includeTasks": includeTasks
}
});
}
/**
* Retries the last failed task
* @param workflowId
* @param resumeSubworkflowTasks
* @returns void
* @throws ApiError
*/
retry1(workflowId, resumeSubworkflowTasks = false) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{workflowId}/retry",
path: {
"workflowId": workflowId
},
query: {
"resumeSubworkflowTasks": resumeSubworkflowTasks
}
});
}
/**
* Gets the workflow by workflow id
* @param workflowId
* @param includeTasks
* @returns Workflow OK
* @throws ApiError
*/
getExecutionStatus(workflowId, includeTasks = true) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/{workflowId}",
path: {
"workflowId": workflowId
},
query: {
"includeTasks": includeTasks
}
});
}
/**
* Terminate workflow execution
* @param workflowId
* @param reason
* @returns any OK
* @throws ApiError
*/
terminate1(workflowId, reason) {
return this.httpRequest.request({
method: "DELETE",
url: "/workflow/{workflowId}",
path: {
"workflowId": workflowId
},
query: {
"reason": reason
}
});
}
/**
* Resumes the workflow
* @param workflowId
* @returns any OK
* @throws ApiError
*/
resumeWorkflow(workflowId) {
return this.httpRequest.request({
method: "PUT",
url: "/workflow/{workflowId}/resume",
path: {
"workflowId": workflowId
}
});
}
/**
* Removes the workflow from the system
* @param workflowId
* @param archiveWorkflow
* @returns any OK
* @throws ApiError
*/
delete(workflowId, archiveWorkflow = true) {
return this.httpRequest.request({
method: "DELETE",
url: "/workflow/{workflowId}/remove",
path: {
"workflowId": workflowId
},
query: {
"archiveWorkflow": archiveWorkflow
}
});
}
/**
* Search for workflows based on task parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultWorkflowSummary OK
* @throws ApiError
*/
searchWorkflowsByTasks(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/search-by-tasks",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
/**
* Get the uri and path of the external storage where the workflow payload is to be stored
* @param path
* @param operation
* @param payloadType
* @returns ExternalStorageLocation OK
* @throws ApiError
*/
getExternalStorageLocation(path, operation, payloadType) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/externalstoragelocation",
query: {
"path": path,
"operation": operation,
"payloadType": payloadType
}
});
}
/**
* Start a new workflow. Returns the ID of the workflow instance that can be later used for tracking
* @param name
* @param requestBody
* @param version
* @param correlationId
* @param priority
* @returns string OK
* @throws ApiError
*/
startWorkflow1(name, requestBody, version, correlationId, priority) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{name}",
path: {
"name": name
},
query: {
"version": version,
"correlationId": correlationId,
"priority": priority
},
body: requestBody,
mediaType: "application/json"
});
}
/**
* Restarts a completed workflow
* @param workflowId
* @param useLatestDefinitions
* @returns void
* @throws ApiError
*/
restart1(workflowId, useLatestDefinitions = false) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{workflowId}/restart",
path: {
"workflowId": workflowId
},
query: {
"useLatestDefinitions": useLatestDefinitions
}
});
}
/**
* Search for workflows based on payload and other parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC.
* @param queryId
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @param skipCache
* @returns ScrollableSearchResultWorkflowSummary OK
* @throws ApiError
*/
search1(queryId, start, size = 100, sort, freeText = "*", query, skipCache = false) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/search",
query: {
"queryId": queryId,
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query,
"skipCache": skipCache
}
});
}
/**
* Search for workflows based on task parameters
* use sort options as sort=<field>:ASC|DESC e.g. sort=name&sort=workflowId:DESC. If order is not specified, defaults to ASC
* @param start
* @param size
* @param sort
* @param freeText
* @param query
* @returns SearchResultWorkflow OK
* @throws ApiError
*/
searchWorkflowsByTasksV2(start, size = 100, sort, freeText = "*", query) {
return this.httpRequest.request({
method: "GET",
url: "/workflow/search-by-tasks-v2",
query: {
"start": start,
"size": size,
"sort": sort,
"freeText": freeText,
"query": query
}
});
}
/**
* Resets callback times of all non-terminal SIMPLE tasks to 0
* @param workflowId
* @returns void
* @throws ApiError
*/
resetWorkflow(workflowId) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/{workflowId}/resetcallbacks",
path: {
"workflowId": workflowId
}
});
}
/**
* Test workflow execution using mock data
* @param requestBody
* @returns Workflow OK
* @throws ApiError
*/
testWorkflow(requestBody) {
return this.httpRequest.request({
method: "POST",
url: "/workflow/test",
body: requestBody,
mediaType: "application/json"
});
}
};
// src/common/open-api/core/ApiError.ts
var ApiError = class extends Error {
url;
status;
statusText;
body;
request;
constructor(request3, response, message) {
super(message);
this.name = "ApiError";
this.url = response.url;
this.status = response.status;
this.statusText = response.statusText;
this.body = response.body;
this.request = request3;
}
};
// src/common/open-api/core/CancelablePromise.ts
var CancelError = class extends Error {
constructor(message) {
super(message);
this.name = "CancelError";
}
get isCancelled() {
return true;
}
};
var CancelablePromise = class {
[Symbol.toStringTag];
_isResolved;
_isRejected;
_isCancelled;
_cancelHandlers;
_promise;
_resolve;
_reject;
constructor(executor) {
this._isResolved = false;
this._isRejected = false;
this._isCancelled = false;
this._cancelHandlers = [];
this._promise = new Promise((resolve3, reject) => {
this._resolve = resolve3;
this._reject = reject;
const onResolve = (value) => {
if (this._isResolved || this._isRejected || this._isCancelled) {
return;
}
this._isResolved = true;
this._resolve?.(value);
};
const onReject = (reason) => {
if (this._isResolved || this._isRejected || this._isCancelled) {
return;
}
this._isRejected = true;
this._reject?.(reason);
};
const onCancel = (cancelHandler) => {
if (this._isResolved || this._isRejected || this._isCancelled) {
return;
}
this._cancelHandlers.push(cancelHandler);
};
Object.defineProperty(onCancel, "isResolved", {
get: () => this._isResolved
});
Object.defineProperty(onCancel, "isRejected", {
get: () => this._isRejected
});
Object.defineProperty(onCancel, "isCancelled", {
get: () => this._isCancelled
});
return executor(onResolve, onReject, onCancel);
});
}
then(onFulfilled, onRejected) {
return this._promise.then(onFulfilled, onRejected);
}
catch(onRejected) {
return this._promise.catch(onRejected);
}
finally(onFinally) {
return this._promise.finally(onFinally);
}
cancel() {
if (this._isResolved || this._isRejected || this._isCancelled) {
return;
}
this._isCancelled = true;
if (this._cancelHandlers.length) {
try {
for (const cancelHandler of this._cancelHandlers) {
cancelHandler();
}
} catch (error) {
console.warn("Cancellation threw an error", error);
return;
}
}
this._cancelHandlers.length = 0;
this._reject?.(new CancelError("Request aborted"));
}
get isCancelled() {
return this._isCancelled;
}
};
// src/common/open-api/core/request.ts
var isDefined = (value) => {
return value !== void 0 && value !== null;
};
var isString = (value) => {
return typeof value === "string";
};
var isStringWithValue = (value) => {
return isString(value) && value !== "";
};
var isBlob = (value) => {
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
};
var isFormData = (value) => {
return value instanceof FormData;
};
var base64 = (str) => {
try {
return btoa(str);
} catch (err) {
return Buffer.from(str).toString("base64");
}
};
var getQueryString = (params) => {
const qs = [];
const append = (key, value) => {
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
};
const process2 = (key, value) => {
if (isDefined(value)) {
if (Array.isArray(value)) {
value.forEach((v) => {
process2(key, v);
});
} else if (typeof value === "object") {
Object.entries(value).forEach(([k, v]) => {
process2(`${key}[${k}]`, v);
});
} else {
append(key, value);
}
}
};
Object.entries(params).forEach(([key, value]) => {
process2(key, value);
});
if (qs.length > 0) {
return `?${qs.join("&")}`;
}
return "";
};
var getUrl = (config, options) => {
const encoder = config.ENCODE_PATH || encodeURI;
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
if (options.path?.hasOwnProperty(group)) {
return encoder(String(options.path[group]));
}
return substring;
});
const url = `${config.BASE}${path}`;
if (options.query) {
return `${url}${getQueryString(options.query)}`;
}
return url;
};
var getFormData = (options) => {
if (options.formData) {
const formData = new FormData();
const process2 = (key, value) => {
if (isString(value) || isBlob(value)) {
formData.append(key, value);
} else {
formData.append(key, JSON.stringify(value));
}
};
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
if (Array.isArray(value)) {
value.forEach((v) => process2(key, v));
} else {
process2(key, value);
}
});
return formData;
}
return void 0;
};
var resolve = async (options, resolver) => {
if (typeof resolver === "function") {
return resolver(options);
}
return resolver;
};
var getHeaders = async (config, options) => {
const token = await resolve(options, config.TOKEN);
const username = await resolve(options, config.USERNAME);
const password = await resolve(options, config.PASSWORD);
const additionalHeaders = await resolve(options, config.HEADERS);
const headers = Object.entries({
Accept: "application/json",
...additionalHeaders,
...options.headers
}).filter(([_, value]) => isDefined(value)).reduce(
(headers2, [key, value]) => ({
...headers2,
[key]: String(value)
}),
{}
);
if (isStringWithValue(token)) {
headers["X-AUTHORIZATION"] = token;
}
if (isStringWithValue(username) && isStringWithValue(password)) {
const credentials = base64(`${username}:${password}`);
headers["Authorization"] = `Basic ${credentials}`;
}
if (options.body) {
if (options.mediaType) {
headers["Content-Type"] = options.mediaType;
} else if (isBlob(options.body)) {
headers["Content-Type"] = "application/octet-stream";
} else if (isString(options.body)) {
headers["Content-Type"] = "text/plain";
} else if (!isFormData(options.body)) {
headers["Content-Type"] = "application/json";
}
}
return new Headers(headers);
};
var getRequestBody = (options) => {
if (options.body) {
if (options.mediaType?.includes("/json")) {
return JSON.stringify(options.body);
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
return options.body;
} else {
return JSON.stringify(options.body);
}
}
return void 0;
};
var sendRequest = async (options, url, body, formData, headers, onCancel) => {
const controller = new AbortController();
const request3 = {
headers,
method: options.method,
body: body ?? formData,
signal: controller.signal
};
onCancel(() => controller.abort());
return await fetch(url, request3);
};
var getResponseHeader = (response, responseHeader) => {
if (responseHeader) {
const content = response.headers.get(responseHeader);
if (isString(content)) {
return content;
}
}
return void 0;
};
var getResponseBody = async (response) => {
if (response.status !== 204) {
try {
const contentType = response.headers.get("Content-Type");
if (contentType) {
const isJSON = contentType.toLowerCase().startsWith("application/json");
if (isJSON) {
return await response.json();
} else {
return await response.text();
}
}
} catch (error) {
console.error(error);
}
}
return void 0;
};
var catchErrorCodes = (options, result) => {
const errors = {
400: "Bad Request",
401: "Unauthorized",
403: "Forbidden",
404: "Not Found",
500: "Internal Server Error",
502: "Bad Gateway",
503: "Service Unavailable",
...options.errors
};
const error = errors[result.status];
if (error) {
throw new ApiError(options, result, error);
}
if (!result.ok) {
throw new ApiError(options, result, "Generic Error");
}
};
var request = (config, options) => {
return new CancelablePromise(async (resolve3, reject, onCancel) => {
try {
const url = getUrl(config, options);
const formData = getFormData(options);
const body = getRequestBody(options);
const headers = await getHeaders(config, options);
if (!onCancel.isCancelled) {
const response = await sendRequest(
options,
url,
body,
formData,
headers,
onCancel
);
const responseBody = await getResponseBody(response);
const responseHeader = getResponseHeader(
response,
options.responseHeader
);
const result = {
url,
ok: response.ok,
status: response.status,
statusText: response.statusText,
body: responseHeader ?? responseBody
};
catchErrorCodes(options, result);
resolve3(result.body);
}
} catch (error) {
reject(error);
}
});
};
// src/common/open-api/services/HumanTaskService.ts
var HumanTaskService = class {
constructor(httpRequest) {
this.httpRequest = httpRequest;
}
/**
* If the workflow is disconnected from tasks, this API can be used to clean up (in bulk)
* @param requestBody
* @returns any OK
* @throws ApiError
*/
deleteTaskFromHumanTaskRecords(requestBody) {
return this.httpRequest.request({
method: "DELETE",
url: "/human/tasks/delete",
body: requestBody,
mediaType: "applicatio