@vzeta/zeebe-node-test
Version:
The Node.js client library for the Zeebe Workflow Automation Engine.
260 lines (259 loc) • 8.65 kB
TypeScript
/// <reference types="node" />
import { MaybeTimeDuration } from 'typed-duration';
import { IInputVariables, IWorkflowVariables } from './interfaces';
/**
* Request object to send the broker to request jobs for the worker.
*/
export interface ActivateJobsRequest {
/**
* The job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
* type="payment-service" />)
*/
type: string;
/** The name of the worker activating the jobs, mostly used for logging purposes */
worker: string;
/**
* The duration the broker allows for jobs activated by this call to complete
* before timing them out releasing them for retry on the broker.
* The broker checks time outs every 30 seconds, so the broker timeout is guaranteed in at-most timeout + 29s
* be guaranteed.
*/
timeout: MaybeTimeDuration;
/**
* The maximum jobs to activate by this request
*/
maxJobsToActivate: number;
/**
* A list of variables to fetch as the job variables; if empty, all visible variables at
* the time of activation for the scope of the job will be returned
*/
fetchVariable?: string[];
/**
* The request will be completed when atleast one job is activated or after the requestTimeout.
* if the requestTimeout = 0, the request will be completed after a default configured timeout in the broker.
* To immediately complete the request when no job is activated set the requestTimeout to a negative value
*
*/
requestTimeout: MaybeTimeDuration;
}
/**
* @deprecated use ActivatedJob from interfaces-grpc-1.0.ts
*/
export interface ActivatedJob {
/** The key, a unique identifier for the job */
readonly key: string;
/**
* The job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
* type="payment-service" />)
*/
readonly type: string;
/** The job's workflow instance key */
readonly workflowInstanceKey: string;
/** The bpmn process ID of the job workflow definition */
readonly bpmnProcessId: string;
/** The version of the job workflow definition */
readonly workflowDefinitionVersion: number;
/** The key of the job workflow definition */
readonly workflowKey: string;
/** The associated task element ID */
readonly elementId: string;
/**
* The unique key identifying the associated task, unique within the scope of the
* workflow instance
*/
readonly elementInstanceKey: string;
/**
* A set of custom headers defined during modelling
*/
readonly customHeaders: string;
/** The name of the worker that activated this job */
readonly worker: string;
readonly retries: number;
/**
* When the job will timeout on the broker if it is not completed by this worker.
* In epoch milliseconds
*/
readonly deadline: string;
/**
* All visible variables in the task scope, computed at activation time, constrained by any
* fetchVariables value in the ActivateJobRequest.
*/
readonly variables: string;
}
/**
* @deprecated use ActivateJobsResponse from interfaces-grpc-1.0.ts
*/
export interface ActivateJobsResponse {
jobs: ActivatedJob[];
}
/**
* @deprecated use CreateProcessInstanceRequest instead
**/
export interface CreateWorkflowInstanceRequest<Variables = IWorkflowVariables> {
bpmnProcessId: string;
version?: number;
variables: Variables;
}
export interface CreateWorkflowInstanceResponse {
/**
* The unique key identifying the workflow definition (e.g. returned from a workflow
* in the DeployWorkflowResponse message)
*/
readonly workflowKey: string;
/**
* The BPMN process ID of the workflow definition
*/
readonly bpmnProcessId: string;
/**
* The version of the process; set to -1 to use the latest version
*/
readonly version: number;
/**
* Stringified JSON document that will instantiate the variables for the root variable scope of the
* workflow instance; it must be a JSON object, as variables will be mapped in a
* key-value fashion. e.g. { "a": 1, "b": 2 } will create two variables, named "a" and
* "b" respectively, with their associated values. [{ "a": 1, "b": 2 }] would not be a\
* valid argument, as the root of the JSON document is an array and not an object.
*/
readonly workflowInstanceKey: string;
}
/**
* @deprecated use CreateProcessInstanceWithResultRequest in instead
**/
export interface CreateWorkflowInstanceWithResultRequest {
request: CreateWorkflowInstanceRequest;
requestTimeout: number;
fetchVariables?: string[];
}
/**
* @deprecated use CreateProcessInstanceWithResultResponse instead
**/
export interface CreateWorkflowInstanceWithResultResponse<Result> {
workflowKey: string;
bpmnProcessId: string;
version: number;
workflowInstanceKey: string;
variables: Result;
}
export declare enum PartitionBrokerRole {
LEADER = 0,
BROKER = 1,
INACTIVE = 2
}
export declare enum PartitionBrokerHealth {
HEALTHY = 0,
UNHEALTHY = 1
}
export interface Partition {
partitionId: number;
role: PartitionBrokerRole;
health: PartitionBrokerHealth;
}
export interface BrokerInfo {
nodeId: number;
host: string;
port: number;
partitions: Partition[];
}
export interface TopologyResponse {
readonly brokers: BrokerInfo[];
readonly clusterSize: number;
readonly partitionsCount: number;
readonly replicationFactor: number;
readonly gatewayVersion: string;
}
export declare enum ResourceType {
FILE = 0,
BPMN = 1,
YAML = 2
}
/**
* @deprecated use ProcessRequestObject in interfaces-1.0 instead
**/
export interface WorkflowRequestObject {
name?: string;
type?: ResourceType;
definition: Buffer;
}
export interface WorkflowMetadata {
readonly bpmnProcessId: string;
readonly version: number;
readonly workflowKey: string;
readonly resourceName: string;
}
/**
* @deprecated use DeployProcessResponse in interfaces-grpc-1.0 instead
**/
export interface DeployWorkflowResponse {
readonly key: string;
readonly workflows: WorkflowMetadata[];
}
/**
* @deprecated use DeployProcessRequest in interfaces-grpc-1.0 instead
**/
export interface DeployWorkflowRequest {
readonly workflows: WorkflowRequestObject[];
}
export interface PublishMessageRequest<Variables = IInputVariables> {
/** Should match the "Message Name" in a BPMN Message Catch */
name: string;
/** The value to match with the field specified as "Subscription Correlation Key" in BPMN */
correlationKey: string;
/** The number of seconds for the message to buffer on the broker, awaiting correlation. Omit or set to zero for no buffering. */
timeToLive: MaybeTimeDuration;
/** Unique ID for this message */
messageId?: string;
variables: Variables;
}
export interface PublishMessageResponse {
key: number;
}
export interface PublishStartMessageRequest<Variables = IWorkflowVariables> {
/** Should match the "Message Name" in a BPMN Message Catch */
name: string;
/** The number of seconds for the message to buffer on the broker, awaiting correlation. Omit or set to zero for no buffering. */
timeToLive: MaybeTimeDuration;
/** Unique ID for this message */
messageId?: string;
correlationKey?: string;
variables: Variables;
}
export interface UpdateJobRetriesRequest {
readonly jobKey: string;
retries: number;
}
export interface FailJobRequest {
readonly jobKey: string;
retries: number;
errorMessage: string;
}
export interface ThrowErrorRequest {
jobKey: string;
errorCode: string;
errorMessage: string;
}
export interface CompleteJobRequest<Variables = IWorkflowVariables> {
readonly jobKey: string;
variables: Variables;
}
export interface SetVariablesRequest<Variables = IWorkflowVariables> {
readonly elementInstanceKey: string;
variables: Partial<Variables>;
local: boolean;
}
export declare type GetWorkflowRequest = GetWorkflowRequestWithBpmnProcessId | GetWorkflowRequestWithWorkflowKey;
export interface GetWorkflowRequestWithWorkflowKey {
readonly workflowKey: string;
}
export interface GetWorkflowRequestWithBpmnProcessId {
/** by default set version = -1 to indicate to use the latest version */
version?: number;
bpmnProcessId: string;
}
export interface GetWorkflowResponse {
readonly workflowKey: string;
readonly version: number;
readonly bpmnProcessId: string;
readonly resourceName: string;
readonly bpmnXml: string;
}