@@ -10,7 +10,16 @@ export type Loglevel = 'INFO' | 'DEBUG' | 'NONE' | 'ERROR'
10
10
11
11
export interface CompleteFn < WorkerOutputVariables > {
12
12
( updatedVariables ?: Partial < WorkerOutputVariables > ) : boolean
13
+ /**
14
+ * Complete the job with a success, optionally passing in a state update to merge
15
+ * with the workflow variables on the broker.
16
+ */
13
17
success : ( updatedVariables ?: Partial < WorkerOutputVariables > ) => boolean
18
+ /**
19
+ * Fail the job with an informative message as to the cause. Optionally pass in a
20
+ * value remaining retries. If no value is passed for retries then the current retry
21
+ * count is decremented. Pass in `0`for retries to raise an incident in Operate.
22
+ */
14
23
failure : ( errorMessage : string , retries ?: number ) => void
15
24
}
16
25
@@ -25,14 +34,6 @@ export interface OperationOptionsNoRetry {
25
34
version ?: number
26
35
}
27
36
28
- export function hasRetry ( options ) : options is OperationOptionsWithRetry {
29
- return options . retry === true
30
- }
31
-
32
- export function noRetry ( options ) : options is OperationOptionsNoRetry {
33
- return options . retry === false
34
- }
35
-
36
37
export type OperationOptions =
37
38
| OperationOptionsWithRetry
38
39
| OperationOptionsNoRetry
@@ -85,10 +86,28 @@ export interface ActivateJobsResponse {
85
86
* Request object to send the broker to request jobs for the worker.
86
87
*/
87
88
export interface ActivateJobsRequest {
89
+ /**
90
+ * The job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
91
+ * type="payment-service" />)
92
+ */
88
93
type : string
94
+ /** The name of the worker activating the jobs, mostly used for logging purposes */
89
95
worker : string
96
+ /**
97
+ * The duration the broker allows for jobs activated by this call to complete
98
+ * before timing them out releasing them for retry on the broker.
99
+ * The broker checks time outs every 30 seconds, so the broker timeout is guaranteed in at-most timeout + 29s
100
+ * be guaranteed.
101
+ */
90
102
timeout : number
103
+ /**
104
+ * The maximum jobs to activate by this request
105
+ */
91
106
maxJobsToActivate : number
107
+ /**
108
+ * A list of variables to fetch as the job variables; if empty, all visible variables at
109
+ * the time of activation for the scope of the job will be returned
110
+ */
92
111
fetchVariable ?: string [ ]
93
112
/**
94
113
* The request will be completed when atleast one job is activated or after the requestTimeout.
@@ -100,44 +119,84 @@ export interface ActivateJobsRequest {
100
119
}
101
120
102
121
export interface ActivatedJob {
122
+ /** The key, a unique identifier for the job */
103
123
readonly key : string
124
+ /**
125
+ * The job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
126
+ * type="payment-service" />)
127
+ */
104
128
readonly type : string
129
+ /** The job's workflow instance key */
105
130
readonly workflowInstanceKey : string
131
+ /** The bpmn process ID of the job workflow definition */
106
132
readonly bpmnProcessId : string
133
+ /** The version of the job workflow definition */
107
134
readonly workflowDefinitionVersion : number
135
+ /** The key of the job workflow definition */
108
136
readonly workflowKey : string
137
+ /** The associated task element ID */
109
138
readonly elementId : string
139
+ /**
140
+ * The unique key identifying the associated task, unique within the scope of the
141
+ * workflow instance
142
+ */
110
143
readonly elementInstanceKey : string
111
144
/**
112
- * JSON object as a string
145
+ * A set of custom headers defined during modelling
113
146
*/
114
147
readonly customHeaders : string
148
+ /** The name of the worker that activated this job */
115
149
readonly worker : string
150
+ /* The amount of retries left to this job (should always be positive) */
116
151
readonly retries : number
117
152
/**
118
- * epoch milliseconds
153
+ * When the job will timeout on the broker if it is not completed by this worker.
154
+ * In epoch milliseconds
119
155
*/
120
156
readonly deadline : string
121
157
/**
122
- * JSON object as a string
158
+ * All visible variables in the task scope, computed at activation time, constrained by any
159
+ * fetchVariables value in the ActivateJobRequest.
123
160
*/
124
161
readonly variables : string
125
162
}
126
163
127
164
export interface Job < Variables = KeyedObject , CustomHeaders = KeyedObject > {
165
+ /** The key, a unique identifier for the job */
128
166
readonly key : string
167
+ /**
168
+ * The job type, as defined in the BPMN process (e.g. <zeebe:taskDefinition
169
+ * type="payment-service" />)
170
+ */
129
171
readonly type : string
172
+ /** The job's workflow instance key */
130
173
readonly workflowInstanceKey : string
174
+ /** The bpmn process ID of the job workflow definition */
131
175
readonly bpmnProcessId : string
176
+ /** The version of the job workflow defini` tion */
132
177
readonly workflowDefinitionVersion : number
178
+ /** The key of the job workflow definition */
133
179
readonly workflowKey : string
180
+ /** The associated task element ID */
134
181
readonly elementId : string
182
+ /**
183
+ * The unique key identifying the associated task, unique within the scope of the
184
+ * workflow instance
185
+ */
135
186
readonly elementInstanceKey : string
187
+ /**
188
+ * A set of custom headers defined during modelling
189
+ */
136
190
readonly customHeaders : CustomHeaders
191
+ /** The name of the worker that activated this job */
137
192
readonly worker : string
193
+ /* The amount of retries left to this job (should always be positive) */
138
194
readonly retries : number
139
195
// epoch milliseconds
140
196
readonly deadline : string
197
+ /**
198
+ * All visible variables in the task scope, computed at activation time.
199
+ */
141
200
readonly variables : Variables
142
201
}
143
202
@@ -147,7 +206,8 @@ export interface ZBWorkerOptions {
147
206
*/
148
207
maxJobsToActivate ?: number
149
208
/**
150
- * Max ms to allow before time out of a task given to this worker. Default: 1000ms.
209
+ * Max ms to allow before time out of a task given to this worker. Default: 30000ms.
210
+ * The broker checks deadline timeouts every 30 seconds, so an
151
211
*/
152
212
timeout ?: number
153
213
/**
@@ -179,9 +239,26 @@ export interface CreateWorkflowInstanceRequest<Variables = KeyedObject> {
179
239
}
180
240
181
241
export interface CreateWorkflowInstanceResponse {
242
+ /**
243
+ * The unique key identifying the workflow definition (e.g. returned from a workflow
244
+ * in the DeployWorkflowResponse message)
245
+ */
182
246
readonly workflowKey : string
247
+ /**
248
+ * The BPMN process ID of the workflow definition
249
+ */
183
250
readonly bpmnProcessId : string
251
+ /**
252
+ * The version of the process; set to -1 to use the latest version
253
+ */
184
254
readonly version : number
255
+ /**
256
+ * Stringified JSON document that will instantiate the variables for the root variable scope of the
257
+ * workflow instance; it must be a JSON object, as variables will be mapped in a
258
+ * key-value fashion. e.g. { "a": 1, "b": 2 } will create two variables, named "a" and
259
+ * "b" respectively, with their associated values. [{ "a": 1, "b": 2 }] would not be a\
260
+ * valid argument, as the root of the JSON document is an array and not an object.
261
+ */
185
262
readonly workflowInstanceKey : string
186
263
}
187
264
@@ -319,7 +396,8 @@ export interface ZBClientOptions {
319
396
retry ?: boolean
320
397
maxRetries ?: number
321
398
maxRetryTimeout ?: number
322
- auth ?: OAuthProviderConfig
399
+ oAuth ?: OAuthProviderConfig
400
+ useTLS ?: boolean
323
401
longPoll ?: number
324
402
}
325
403
0 commit comments