Skip to content

Commit baefee4

Browse files
committed
chore: fix grpc interfaces for new method
1 parent 2220b4b commit baefee4

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

src/__tests__/zeebe/integration/Worker-CompleteWithResult.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let bpmnProcessId1: string
1313

1414
beforeAll(async () => {
1515
const res1 = await zbc.deployResource({
16-
processFilename: './src/__tests__/testdata/Worker-JobCorrection.bpmn',
16+
processFilename: './src/__tests__/testdata/Worker-JobResult.bpmn',
1717
})
1818
;({
1919
processDefinitionKey: processDefinitionKey1,
@@ -48,7 +48,9 @@ test('Can complete a task with job corrections', (done) => {
4848
expect(job.processInstanceKey).toBe(wf?.processInstanceKey)
4949
const res1 = await job.completeWithJobResult({
5050
variables: {},
51-
result: {},
51+
result: {
52+
denied: true,
53+
},
5254
})
5355
// @TODO: correction interface
5456
done(null)

src/zeebe/lib/ZBStreamWorker.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import {
1515
ZBGrpc,
1616
ZBWorkerTaskHandler,
1717
} from './interfaces-1.0'
18-
import { ActivatedJob, StreamActivatedJobsRequest } from './interfaces-grpc-1.0'
18+
import {
19+
ActivatedJob,
20+
CompleteJobRequest,
21+
StreamActivatedJobsRequest,
22+
} from './interfaces-grpc-1.0'
1923

2024
import { parseVariablesAndCustomHeadersToJSON } from '.'
2125

@@ -195,13 +199,30 @@ You should call only one job action method in the worker handler. This is a bug
195199
})
196200
}
197201

202+
const correctJob =
203+
(job: Job) => (req: Pick<CompleteJobRequest, 'result' | 'variables'>) =>
204+
this.completeJob(
205+
job.key,
206+
{
207+
result: req.result,
208+
variables: req.variables,
209+
},
210+
taskType
211+
)
212+
198213
const fail = failJob(thisJob)
199214
const succeed = succeedJob(thisJob)
215+
const completeWithResult = correctJob(thisJob)
216+
200217
return {
201218
cancelWorkflow: cancelWorkflow(thisJob),
202219
complete: errorMsgOnPriorMessageCall('job.complete', succeed),
203220
error: errorMsgOnPriorMessageCall('error', errorJob(thisJob)),
204221
fail: errorMsgOnPriorMessageCall('job.fail', fail),
222+
completeWithJobResult: errorMsgOnPriorMessageCall(
223+
'job.completeWithJobResult',
224+
completeWithResult
225+
),
205226
forward: errorMsgOnPriorMessageCall('job.forward', () => {
206227
return JOB_ACTION_ACKNOWLEDGEMENT
207228
}),

src/zeebe/zb/ZBWorker.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ export class ZBWorker<
4949
)(
5050
{
5151
...job,
52-
cancelWorkflow: workerCallback.cancelWorkflow,
53-
complete: workerCallback.complete,
54-
fail: workerCallback.fail,
55-
error: workerCallback.error,
56-
forward: workerCallback.forward,
52+
...workerCallback,
5753
},
5854
this
5955
)

0 commit comments

Comments
 (0)