@camunda8/sdk 8.4.0 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +34 -0
- package/CHANGELOG.md +61 -21
- package/CODE_OF_CONDUCT.md +73 -0
- package/CONTRIBUTING.md +116 -0
- package/LICENSE +3 -3
- package/README.md +229 -33
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +30 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/lib/AdminApiClient.d.ts +121 -0
- package/dist/admin/lib/AdminApiClient.js +254 -0
- package/dist/admin/lib/AdminApiClient.js.map +1 -0
- package/dist/admin/lib/AdminDto.d.ts +98 -0
- package/dist/admin/lib/AdminDto.js +3 -0
- package/dist/admin/lib/AdminDto.js.map +1 -0
- package/dist/c8/index.d.ts +42 -0
- package/dist/c8/index.js +95 -0
- package/dist/c8/index.js.map +1 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.js +14 -16
- package/dist/index.js.map +1 -1
- package/dist/lib/CertificateAuthority.d.ts +2 -0
- package/dist/lib/CertificateAuthority.js +15 -0
- package/dist/lib/CertificateAuthority.js.map +1 -0
- package/dist/lib/ClientConstructor.d.ts +6 -0
- package/dist/lib/ClientConstructor.js +3 -0
- package/dist/lib/ClientConstructor.js.map +1 -0
- package/dist/lib/Configuration.d.ts +113 -0
- package/dist/lib/Configuration.js +367 -0
- package/dist/lib/Configuration.js.map +1 -0
- package/dist/lib/ConstructOAuthProvider.d.ts +3 -0
- package/dist/lib/ConstructOAuthProvider.js +14 -0
- package/dist/lib/ConstructOAuthProvider.js.map +1 -0
- package/dist/lib/CreateUserAgentString.d.ts +2 -0
- package/dist/lib/CreateUserAgentString.js +11 -0
- package/dist/lib/CreateUserAgentString.js.map +1 -0
- package/dist/lib/Delay.d.ts +1 -0
- package/dist/lib/Delay.js +6 -0
- package/dist/lib/Delay.js.map +1 -0
- package/dist/lib/EnvironmentSetup.d.ts +11 -0
- package/dist/lib/EnvironmentSetup.js +35 -0
- package/dist/lib/EnvironmentSetup.js.map +1 -0
- package/dist/lib/GetPackageVersion.d.ts +1 -0
- package/dist/lib/GetPackageVersion.js +32 -0
- package/dist/lib/GetPackageVersion.js.map +1 -0
- package/dist/lib/LosslessJsonParser.d.ts +103 -0
- package/dist/lib/LosslessJsonParser.js +252 -0
- package/dist/lib/LosslessJsonParser.js.map +1 -0
- package/dist/lib/RequireConfiguration.d.ts +2 -0
- package/dist/lib/RequireConfiguration.js +11 -0
- package/dist/lib/RequireConfiguration.js.map +1 -0
- package/dist/lib/SuppressZeebeLogging.d.ts +2 -0
- package/dist/lib/SuppressZeebeLogging.js +14 -0
- package/dist/lib/SuppressZeebeLogging.js.map +1 -0
- package/dist/lib/ValueOrDefault.d.ts +1 -0
- package/dist/lib/ValueOrDefault.js +8 -0
- package/dist/lib/ValueOrDefault.js.map +1 -0
- package/dist/lib/index.d.ts +12 -0
- package/dist/lib/index.js +32 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/modeler/index.d.ts +2 -0
- package/dist/modeler/index.js +30 -0
- package/dist/modeler/index.js.map +1 -0
- package/dist/modeler/lib/ModelerAPIClient.d.ts +210 -0
- package/dist/modeler/lib/ModelerAPIClient.js +417 -0
- package/dist/modeler/lib/ModelerAPIClient.js.map +1 -0
- package/dist/modeler/lib/ModelerDto.d.ts +187 -0
- package/dist/modeler/lib/ModelerDto.js +3 -0
- package/dist/modeler/lib/ModelerDto.js.map +1 -0
- package/dist/oauth/index.d.ts +15 -0
- package/dist/oauth/index.js +8 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/lib/IOAuthProvider.d.ts +4 -0
- package/dist/oauth/lib/IOAuthProvider.js +3 -0
- package/dist/oauth/lib/IOAuthProvider.js.map +1 -0
- package/dist/oauth/lib/NullAuthProvider.d.ts +5 -0
- package/dist/oauth/lib/NullAuthProvider.js +16 -0
- package/dist/oauth/lib/NullAuthProvider.js.map +1 -0
- package/dist/oauth/lib/OAuthProvider.d.ts +44 -0
- package/dist/oauth/lib/OAuthProvider.js +316 -0
- package/dist/oauth/lib/OAuthProvider.js.map +1 -0
- package/dist/operate/index.d.ts +2 -0
- package/dist/operate/index.js +30 -0
- package/dist/operate/index.js.map +1 -0
- package/dist/operate/lib/OperateApiClient.d.ts +204 -0
- package/dist/operate/lib/OperateApiClient.js +440 -0
- package/dist/operate/lib/OperateApiClient.js.map +1 -0
- package/dist/operate/lib/OperateDto.d.ts +126 -0
- package/dist/operate/lib/OperateDto.js +125 -0
- package/dist/operate/lib/OperateDto.js.map +1 -0
- package/dist/operate/lib/TestableOperateApiClient.d.ts +7 -0
- package/dist/operate/lib/TestableOperateApiClient.js +15 -0
- package/dist/operate/lib/TestableOperateApiClient.js.map +1 -0
- package/dist/operate/lib/parseSearchResults.d.ts +4 -0
- package/dist/operate/lib/parseSearchResults.js +26 -0
- package/dist/operate/lib/parseSearchResults.js.map +1 -0
- package/dist/optimize/index.d.ts +2 -0
- package/dist/optimize/index.js +30 -0
- package/dist/optimize/index.js.map +1 -0
- package/dist/optimize/lib/APIObjects.d.ts +191 -0
- package/dist/optimize/lib/APIObjects.js +3 -0
- package/dist/optimize/lib/APIObjects.js.map +1 -0
- package/dist/optimize/lib/OptimizeApiClient.d.ts +269 -0
- package/dist/optimize/lib/OptimizeApiClient.js +410 -0
- package/dist/optimize/lib/OptimizeApiClient.js.map +1 -0
- package/dist/optimize/lib/ReportResults.d.ts +23 -0
- package/dist/optimize/lib/ReportResults.js +28 -0
- package/dist/optimize/lib/ReportResults.js.map +1 -0
- package/dist/proto/zeebe.proto +996 -0
- package/dist/tasklist/index.d.ts +2 -0
- package/dist/tasklist/index.js +30 -0
- package/dist/tasklist/index.js.map +1 -0
- package/dist/tasklist/lib/TasklistApiClient.d.ts +104 -0
- package/dist/tasklist/lib/TasklistApiClient.js +233 -0
- package/dist/tasklist/lib/TasklistApiClient.js.map +1 -0
- package/dist/tasklist/lib/TasklistDto.d.ts +147 -0
- package/dist/tasklist/lib/TasklistDto.js +26 -0
- package/dist/tasklist/lib/TasklistDto.js.map +1 -0
- package/dist/tasklist/lib/utils.d.ts +15 -0
- package/dist/tasklist/lib/utils.js +25 -0
- package/dist/tasklist/lib/utils.js.map +1 -0
- package/dist/zeebe/index.d.ts +21 -0
- package/dist/zeebe/index.js +53 -0
- package/dist/zeebe/index.js.map +1 -0
- package/dist/zeebe/lib/BpmnParser.d.ts +38 -0
- package/dist/zeebe/lib/BpmnParser.js +274 -0
- package/dist/zeebe/lib/BpmnParser.js.map +1 -0
- package/dist/zeebe/lib/ConnectionFactory.d.ts +25 -0
- package/dist/zeebe/lib/ConnectionFactory.js +43 -0
- package/dist/zeebe/lib/ConnectionFactory.js.map +1 -0
- package/dist/zeebe/lib/ConnectionStatusEvent.d.ts +6 -0
- package/dist/zeebe/lib/ConnectionStatusEvent.js +10 -0
- package/dist/zeebe/lib/ConnectionStatusEvent.js.map +1 -0
- package/dist/zeebe/lib/GetPackageVersion.d.ts +1 -0
- package/dist/zeebe/lib/GetPackageVersion.js +32 -0
- package/dist/zeebe/lib/GetPackageVersion.js.map +1 -0
- package/dist/zeebe/lib/GrpcClient.d.ts +75 -0
- package/dist/zeebe/lib/GrpcClient.js +467 -0
- package/dist/zeebe/lib/GrpcClient.js.map +1 -0
- package/dist/zeebe/lib/GrpcError.d.ts +19 -0
- package/dist/zeebe/lib/GrpcError.js +23 -0
- package/dist/zeebe/lib/GrpcError.js.map +1 -0
- package/dist/zeebe/lib/GrpcMiddleware.d.ts +21 -0
- package/dist/zeebe/lib/GrpcMiddleware.js +78 -0
- package/dist/zeebe/lib/GrpcMiddleware.js.map +1 -0
- package/dist/zeebe/lib/MockStdOut.d.ts +7 -0
- package/dist/zeebe/lib/MockStdOut.js +19 -0
- package/dist/zeebe/lib/MockStdOut.js.map +1 -0
- package/dist/zeebe/lib/Queue.d.ts +8 -0
- package/dist/zeebe/lib/Queue.js +15 -0
- package/dist/zeebe/lib/Queue.js.map +1 -0
- package/dist/zeebe/lib/SimpleLogger.d.ts +8 -0
- package/dist/zeebe/lib/SimpleLogger.js +47 -0
- package/dist/zeebe/lib/SimpleLogger.js.map +1 -0
- package/dist/zeebe/lib/StatefulLogInterceptor.d.ts +29 -0
- package/dist/zeebe/lib/StatefulLogInterceptor.js +81 -0
- package/dist/zeebe/lib/StatefulLogInterceptor.js.map +1 -0
- package/dist/zeebe/lib/TypedEmitter.d.ts +16 -0
- package/dist/zeebe/lib/TypedEmitter.js +24 -0
- package/dist/zeebe/lib/TypedEmitter.js.map +1 -0
- package/dist/zeebe/lib/ZBJsonLogger.d.ts +5 -0
- package/dist/zeebe/lib/ZBJsonLogger.js +12 -0
- package/dist/zeebe/lib/ZBJsonLogger.js.map +1 -0
- package/dist/zeebe/lib/ZBLogger.d.ts +20 -0
- package/dist/zeebe/lib/ZBLogger.js +134 -0
- package/dist/zeebe/lib/ZBLogger.js.map +1 -0
- package/dist/zeebe/lib/ZBWorkerBase.d.ts +78 -0
- package/dist/zeebe/lib/ZBWorkerBase.js +417 -0
- package/dist/zeebe/lib/ZBWorkerBase.js.map +1 -0
- package/dist/zeebe/lib/cancelProcesses.d.ts +1 -0
- package/dist/zeebe/lib/cancelProcesses.js +40 -0
- package/dist/zeebe/lib/cancelProcesses.js.map +1 -0
- package/dist/zeebe/lib/createUniqueTaskType.d.ts +0 -0
- package/dist/zeebe/lib/createUniqueTaskType.js +65 -0
- package/dist/zeebe/lib/createUniqueTaskType.js.map +1 -0
- package/dist/zeebe/lib/index.d.ts +2 -0
- package/dist/zeebe/lib/index.js +19 -0
- package/dist/zeebe/lib/index.js.map +1 -0
- package/dist/zeebe/lib/interfaces-1.0.d.ts +303 -0
- package/dist/zeebe/lib/interfaces-1.0.js +5 -0
- package/dist/zeebe/lib/interfaces-1.0.js.map +1 -0
- package/dist/zeebe/lib/interfaces-grpc-1.0.d.ts +679 -0
- package/dist/zeebe/lib/interfaces-grpc-1.0.js +22 -0
- package/dist/zeebe/lib/interfaces-grpc-1.0.js.map +1 -0
- package/dist/zeebe/lib/interfaces-published-contract.d.ts +67 -0
- package/dist/zeebe/lib/interfaces-published-contract.js +3 -0
- package/dist/zeebe/lib/interfaces-published-contract.js.map +1 -0
- package/dist/zeebe/lib/stringifyVariables.d.ts +18 -0
- package/dist/zeebe/lib/stringifyVariables.js +28 -0
- package/dist/zeebe/lib/stringifyVariables.js.map +1 -0
- package/dist/zeebe/lib/utils.d.ts +7 -0
- package/dist/zeebe/lib/utils.js +48 -0
- package/dist/zeebe/lib/utils.js.map +1 -0
- package/dist/zeebe/types.d.ts +3 -0
- package/dist/zeebe/types.js +20 -0
- package/dist/zeebe/types.js.map +1 -0
- package/dist/zeebe/zb/ZBWorker.d.ts +7 -0
- package/dist/zeebe/zb/ZBWorker.js +73 -0
- package/dist/zeebe/zb/ZBWorker.js.map +1 -0
- package/dist/zeebe/zb/ZeebeGrpcClient.d.ts +587 -0
- package/dist/zeebe/zb/ZeebeGrpcClient.js +1021 -0
- package/dist/zeebe/zb/ZeebeGrpcClient.js.map +1 -0
- package/package.json +120 -30
- package/release.config.js +49 -0
- package/renovate.json +9 -0
- package/smoke-test/package-lock.json +29 -0
- package/smoke-test/package.json +15 -0
- package/smoke-test/smoke-test.js +45 -0
- package/test-d/index.test-d.ts +31 -0
- package/.github/workflows/build-docs.yml +0 -39
- package/.github/workflows/tag-and-publish.yml +0 -48
- package/.prettierignore +0 -2
- package/img/video.png +0 -0
- package/jest.config.js +0 -5
- package/src/__tests__/exports.spec.ts +0 -7
- package/src/index.ts +0 -17
- package/tsconfig.build.json +0 -8
- package/tsconfig.json +0 -10
- package/tsconfig.tsbuildinfo +0 -1
- package/typedoc.json +0 -10
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { MaybeTimeDuration } from 'typed-duration';
|
|
3
|
+
import { CamundaPlatform8Configuration, DeepPartial } from '../../lib';
|
|
4
|
+
import { IOAuthProvider } from '../../oauth';
|
|
5
|
+
import { ConnectionStatusEvent } from '../lib/ConnectionStatusEvent';
|
|
6
|
+
import { TypedEmitter } from '../lib/TypedEmitter';
|
|
7
|
+
import * as ZB from '../lib/interfaces-1.0';
|
|
8
|
+
import * as Grpc from '../lib/interfaces-grpc-1.0';
|
|
9
|
+
import { Loglevel } from '../lib/interfaces-published-contract';
|
|
10
|
+
import { ZBWorker } from './ZBWorker';
|
|
11
|
+
/**
|
|
12
|
+
* @description A client for interacting with a Zeebe broker. With the connection credentials set in the environment, you can use a "zero-conf" constructor with no arguments.
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* const zbc = new ZeebeGrpcClient()
|
|
16
|
+
* zbc.topology().then(info =>
|
|
17
|
+
* console.log(JSON.stringify(info, null, 2))
|
|
18
|
+
* )
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class ZeebeGrpcClient extends TypedEmitter<typeof ConnectionStatusEvent> {
|
|
22
|
+
connectionTolerance: MaybeTimeDuration;
|
|
23
|
+
connected?: boolean;
|
|
24
|
+
readied: boolean;
|
|
25
|
+
gatewayAddress: string;
|
|
26
|
+
loglevel: Loglevel;
|
|
27
|
+
onReady?: () => void;
|
|
28
|
+
onConnectionError?: (err: Error) => void;
|
|
29
|
+
private logger;
|
|
30
|
+
private closePromise?;
|
|
31
|
+
private closing;
|
|
32
|
+
private grpc;
|
|
33
|
+
private options;
|
|
34
|
+
private workerCount;
|
|
35
|
+
private workers;
|
|
36
|
+
private retry;
|
|
37
|
+
private maxRetries;
|
|
38
|
+
private maxRetryTimeout;
|
|
39
|
+
private oAuthProvider;
|
|
40
|
+
private useTLS;
|
|
41
|
+
private stdout;
|
|
42
|
+
private customSSL?;
|
|
43
|
+
private tenantId?;
|
|
44
|
+
private config;
|
|
45
|
+
constructor(options?: {
|
|
46
|
+
config?: DeepPartial<CamundaPlatform8Configuration>;
|
|
47
|
+
oAuthProvider?: IOAuthProvider;
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* @description activateJobs allows you to manually activate jobs, effectively building a worker; rather than using the ZBWorker class.
|
|
51
|
+
* @example
|
|
52
|
+
* ```
|
|
53
|
+
* const zbc = new ZeebeGrpcClient()
|
|
54
|
+
* zbc.activateJobs({
|
|
55
|
+
* maxJobsToActivate: 5,
|
|
56
|
+
* requestTimeout: 6000,
|
|
57
|
+
* timeout: 5 * 60 * 1000,
|
|
58
|
+
* type: 'process-payment',
|
|
59
|
+
* worker: 'my-worker-uuid'
|
|
60
|
+
* }).then(jobs =>
|
|
61
|
+
* jobs.forEach(job =>
|
|
62
|
+
* // business logic
|
|
63
|
+
* zbc.completeJob({
|
|
64
|
+
* jobKey: job.key,
|
|
65
|
+
* variables: {}
|
|
66
|
+
* ))
|
|
67
|
+
* )
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
activateJobs<Variables = ZB.IInputVariables, CustomHeaders = ZB.ICustomHeaders>(request: Grpc.ActivateJobsRequest & {
|
|
72
|
+
inputVariableDto?: {
|
|
73
|
+
new (...args: any[]): Readonly<Variables>;
|
|
74
|
+
};
|
|
75
|
+
customHeadersDto?: {
|
|
76
|
+
new (...args: any[]): Readonly<CustomHeaders>;
|
|
77
|
+
};
|
|
78
|
+
}): Promise<ZB.Job<Variables, CustomHeaders>[]>;
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @description Broadcast a Signal
|
|
82
|
+
* @example
|
|
83
|
+
* ```
|
|
84
|
+
* const zbc = new ZeebeGrpcClient()
|
|
85
|
+
*
|
|
86
|
+
* zbc.broadcastSignal({
|
|
87
|
+
* signalName: 'my-signal',
|
|
88
|
+
* variables: { reasonCode: 3 }
|
|
89
|
+
* })
|
|
90
|
+
*/
|
|
91
|
+
broadcastSignal(req: ZB.BroadcastSignalReq): Promise<ZB.BroadcastSignalRes>;
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @description Cancel a process instance by process instance key.
|
|
95
|
+
* @example
|
|
96
|
+
* ```
|
|
97
|
+
* const zbc = new ZeebeGrpcClient()
|
|
98
|
+
*
|
|
99
|
+
* zbc.cancelProcessInstance(processInstanceId)
|
|
100
|
+
* .catch(
|
|
101
|
+
* (e: any) => console.log(`Error cancelling instance: ${e.message}`)
|
|
102
|
+
* )
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
cancelProcessInstance(processInstanceKey: string | number): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* @description Create a worker that polls the gateway for jobs and executes a job handler when units of work are available.
|
|
109
|
+
* @example
|
|
110
|
+
* ```
|
|
111
|
+
* const zbc = new ZB.ZeebeGrpcClient()
|
|
112
|
+
*
|
|
113
|
+
* const zbWorker = zbc.createWorker({
|
|
114
|
+
* taskType: 'demo-service',
|
|
115
|
+
* taskHandler: myTaskHandler,
|
|
116
|
+
* })
|
|
117
|
+
*
|
|
118
|
+
* // A job handler must return one of job.complete, job.fail, job.error, or job.forward
|
|
119
|
+
* // Note: unhandled exceptions in the job handler cause the library to call job.fail
|
|
120
|
+
* async function myTaskHandler(job) {
|
|
121
|
+
* zbWorker.log('Task variables', job.variables)
|
|
122
|
+
*
|
|
123
|
+
* // Task worker business logic goes here
|
|
124
|
+
* const updateToBrokerVariables = {
|
|
125
|
+
* updatedProperty: 'newValue',
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* const res = await callExternalSystem(job.variables)
|
|
129
|
+
*
|
|
130
|
+
* if (res.code === 'SUCCESS') {
|
|
131
|
+
* return job.complete({
|
|
132
|
+
* ...updateToBrokerVariables,
|
|
133
|
+
* ...res.values
|
|
134
|
+
* })
|
|
135
|
+
* }
|
|
136
|
+
* if (res.code === 'BUSINESS_ERROR') {
|
|
137
|
+
* return job.error({
|
|
138
|
+
* code: res.errorCode,
|
|
139
|
+
* message: res.message
|
|
140
|
+
* })
|
|
141
|
+
* }
|
|
142
|
+
* if (res.code === 'ERROR') {
|
|
143
|
+
* return job.fail({
|
|
144
|
+
* errorMessage: res.message,
|
|
145
|
+
* retryBackOff: 2000
|
|
146
|
+
* })
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
createWorker<WorkerInputVariables = ZB.IInputVariables, CustomHeaderShape = ZB.ICustomHeaders, WorkerOutputVariables = ZB.IOutputVariables>(config: ZB.ZBWorkerConfig<WorkerInputVariables, CustomHeaderShape, WorkerOutputVariables>): ZBWorker<WorkerInputVariables, CustomHeaderShape, WorkerOutputVariables>;
|
|
152
|
+
/**
|
|
153
|
+
* @description Gracefully shut down all workers, draining existing tasks, and return when it is safe to exit.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```
|
|
157
|
+
* const zbc = new ZeebeGrpcClient()
|
|
158
|
+
*
|
|
159
|
+
* zbc.createWorker({
|
|
160
|
+
* taskType:
|
|
161
|
+
* })
|
|
162
|
+
*
|
|
163
|
+
* setTimeout(async () => {
|
|
164
|
+
* await zbc.close()
|
|
165
|
+
* console.log('All work completed.')
|
|
166
|
+
* }),
|
|
167
|
+
* 5 * 60 * 1000 // 5 mins
|
|
168
|
+
* )
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
close(timeout?: number): Promise<null>;
|
|
172
|
+
/**
|
|
173
|
+
*
|
|
174
|
+
* @description Explicitly complete a job. The method is useful for manually constructing a worker.
|
|
175
|
+
* @example
|
|
176
|
+
* ```
|
|
177
|
+
* const zbc = new ZeebeGrpcClient()
|
|
178
|
+
* zbc.activateJobs({
|
|
179
|
+
* maxJobsToActivate: 5,
|
|
180
|
+
* requestTimeout: 6000,
|
|
181
|
+
* timeout: 5 * 60 * 1000,
|
|
182
|
+
* type: 'process-payment',
|
|
183
|
+
* worker: 'my-worker-uuid'
|
|
184
|
+
* }).then(jobs =>
|
|
185
|
+
* jobs.forEach(job =>
|
|
186
|
+
* // business logic
|
|
187
|
+
* zbc.completeJob({
|
|
188
|
+
* jobKey: job.key,
|
|
189
|
+
* variables: {}
|
|
190
|
+
* ))
|
|
191
|
+
* )
|
|
192
|
+
* })
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
completeJob(completeJobRequest: Grpc.CompleteJobRequest): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
* @description Create a new process instance. Asynchronously returns a process instance id.
|
|
199
|
+
* @example
|
|
200
|
+
* ```
|
|
201
|
+
* const zbc = new ZeebeGrpcClient()
|
|
202
|
+
*
|
|
203
|
+
* zbc.createProcessInstance({
|
|
204
|
+
* bpmnProcessId: 'onboarding-process',
|
|
205
|
+
* variables: {
|
|
206
|
+
* customerId: 'uuid-3455'
|
|
207
|
+
* },
|
|
208
|
+
* version: 5 // optional, will use latest by default
|
|
209
|
+
* }).then(res => console.log(JSON.stringify(res, null, 2)))
|
|
210
|
+
*
|
|
211
|
+
* zbc.createProcessInstance({
|
|
212
|
+
* bpmnProcessId: 'SkipFirstTask',
|
|
213
|
+
* variables: { id: random },
|
|
214
|
+
* startInstructions: [{elementId: 'second_service_task'}]
|
|
215
|
+
* }).then(res => (id = res.processInstanceKey))
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
createProcessInstance<Variables extends ZB.JSONDoc = ZB.IProcessVariables>(config: ZB.CreateProcessInstanceReq<Variables>): Promise<Grpc.CreateProcessInstanceResponse>;
|
|
219
|
+
/**
|
|
220
|
+
*
|
|
221
|
+
* @description Create a process instance, and return a Promise that returns the outcome of the process.
|
|
222
|
+
* @example
|
|
223
|
+
* ```
|
|
224
|
+
* const zbc = new ZeebeGrpcClient()
|
|
225
|
+
*
|
|
226
|
+
* zbc.createProcessInstanceWithResult({
|
|
227
|
+
* bpmnProcessId: 'order-process',
|
|
228
|
+
* variables: {
|
|
229
|
+
* customerId: 123,
|
|
230
|
+
* invoiceId: 567
|
|
231
|
+
* }
|
|
232
|
+
* })
|
|
233
|
+
* .then(console.log)
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
createProcessInstanceWithResult<Variables extends ZB.JSONDoc = ZB.IProcessVariables, Result = ZB.IOutputVariables>(config: ZB.CreateProcessInstanceWithResultReq<Variables>): Promise<Grpc.CreateProcessInstanceWithResultResponse<Result>>;
|
|
237
|
+
/**
|
|
238
|
+
* Delete a resource.
|
|
239
|
+
* @param resourceId - The key of the resource that should be deleted. This can either be the key of a process definition, the key of a decision requirements definition or the key of a form.
|
|
240
|
+
* @returns
|
|
241
|
+
*/
|
|
242
|
+
deleteResource({ resourceKey, }: {
|
|
243
|
+
resourceKey: string;
|
|
244
|
+
}): Promise<Record<string, never>>;
|
|
245
|
+
/**
|
|
246
|
+
*
|
|
247
|
+
* @description Deploys one or more resources (e.g. processes or decision models) to Zeebe.
|
|
248
|
+
* Note that this is an atomic call, i.e. either all resources are deployed, or none of them are.
|
|
249
|
+
*
|
|
250
|
+
* Errors:
|
|
251
|
+
* PERMISSION_DENIED:
|
|
252
|
+
* - if a deployment to an unauthorized tenant is performed
|
|
253
|
+
* INVALID_ARGUMENT:
|
|
254
|
+
* - no resources given.
|
|
255
|
+
* - if at least one resource is invalid. A resource is considered invalid if:
|
|
256
|
+
* - the content is not deserializable (e.g. detected as BPMN, but it's broken XML)
|
|
257
|
+
* - the content is invalid (e.g. an event-based gateway has an outgoing sequence flow to a task)
|
|
258
|
+
* - if multi-tenancy is enabled, and:
|
|
259
|
+
* - a tenant id is not provided
|
|
260
|
+
* - a tenant id with an invalid format is provided
|
|
261
|
+
* - if multi-tenancy is disabled and a tenant id is provided
|
|
262
|
+
* @example
|
|
263
|
+
* ```
|
|
264
|
+
* import {join} from 'path'
|
|
265
|
+
* const zbc = new ZeebeGrpcClient()
|
|
266
|
+
*
|
|
267
|
+
* zbc.deployResource({ processFilename: join(process.cwd(), 'bpmn', 'onboarding.bpmn' })
|
|
268
|
+
* zbc.deployResource({ decisionFilename: join(process.cwd(), 'dmn', 'approval.dmn')})
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
deployResource(resource: {
|
|
272
|
+
processFilename: string;
|
|
273
|
+
tenantId?: string;
|
|
274
|
+
} | {
|
|
275
|
+
name: string;
|
|
276
|
+
process: Buffer;
|
|
277
|
+
tenantId?: string;
|
|
278
|
+
}): Promise<Grpc.DeployResourceResponse<Grpc.ProcessDeployment>>;
|
|
279
|
+
deployResource(resource: {
|
|
280
|
+
decisionFilename: string;
|
|
281
|
+
tenantId?: string;
|
|
282
|
+
} | {
|
|
283
|
+
name: string;
|
|
284
|
+
decision: Buffer;
|
|
285
|
+
tenantId?: string;
|
|
286
|
+
}): Promise<Grpc.DeployResourceResponse<Grpc.DecisionDeployment>>;
|
|
287
|
+
deployResource(resource: {
|
|
288
|
+
formFilename: string;
|
|
289
|
+
tenantId?: string;
|
|
290
|
+
} | {
|
|
291
|
+
name: string;
|
|
292
|
+
form: Buffer;
|
|
293
|
+
tenantId?: string;
|
|
294
|
+
}): Promise<Grpc.DeployResourceResponse<Grpc.FormDeployment>>;
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @description Evaluates a decision. The decision to evaluate can be specified either by using its unique key (as returned by DeployResource), or using the decision ID. When using the decision ID, the latest deployed version of the decision is used.
|
|
298
|
+
* @example
|
|
299
|
+
* ```
|
|
300
|
+
* const zbc = new ZeebeGrpcClient()
|
|
301
|
+
* zbc.evaluateDecision({
|
|
302
|
+
* decisionId: 'my-decision',
|
|
303
|
+
* variables: { season: "Fall" }
|
|
304
|
+
* }).then(res => console.log(JSON.stringify(res, null, 2)))
|
|
305
|
+
*/
|
|
306
|
+
evaluateDecision(evaluateDecisionRequest: Grpc.EvaluateDecisionRequest): Promise<Grpc.EvaluateDecisionResponse>;
|
|
307
|
+
/**
|
|
308
|
+
*
|
|
309
|
+
* @description Fail a job. This is useful if you are using the decoupled completion pattern or building your own worker.
|
|
310
|
+
* For the retry count, the current count is available in the job metadata.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```
|
|
314
|
+
* const zbc = new ZeebeGrpcClient()
|
|
315
|
+
* zbc.failJob( {
|
|
316
|
+
* jobKey: '345424343451',
|
|
317
|
+
* retries: 3,
|
|
318
|
+
* errorMessage: 'Could not get a response from the order invoicing API',
|
|
319
|
+
* retryBackOff: 30 * 1000 // optional, otherwise available for reactivation immediately
|
|
320
|
+
* })
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
failJob(failJobRequest: Grpc.FailJobRequest): Promise<void>;
|
|
324
|
+
/**
|
|
325
|
+
* @description Return an array of task types contained in a BPMN file or array of BPMN files. This can be useful, for example, to do
|
|
326
|
+
* @example
|
|
327
|
+
* ```
|
|
328
|
+
* const zbc = new ZeebeGrpcClient()
|
|
329
|
+
* zbc.getServiceTypesFromBpmn(['bpmn/onboarding.bpmn', 'bpmn/process-sale.bpmn'])
|
|
330
|
+
* .then(tasktypes => console.log('The task types are:', tasktypes))
|
|
331
|
+
*
|
|
332
|
+
* ```
|
|
333
|
+
*/
|
|
334
|
+
getServiceTypesFromBpmn(files: string | string[]): Promise<string[]>;
|
|
335
|
+
/**
|
|
336
|
+
*
|
|
337
|
+
* @description Modify a running process instance. This allows you to move the execution tokens, and change the variables. Added in 8.1.
|
|
338
|
+
* See the [gRPC protocol documentation](https://docs.camunda.io/docs/apis-clients/grpc/#modifyprocessinstance-rpc).
|
|
339
|
+
* @example
|
|
340
|
+
* ```
|
|
341
|
+
* zbc.createProcessInstance('SkipFirstTask', {}).then(res =>
|
|
342
|
+
* zbc.modifyProcessInstance({
|
|
343
|
+
* processInstanceKey: res.processInstanceKey,
|
|
344
|
+
* activateInstructions: [{
|
|
345
|
+
* elementId: 'second_service_task',
|
|
346
|
+
* ancestorElementInstanceKey: "-1",
|
|
347
|
+
* variableInstructions: [{
|
|
348
|
+
* scopeId: '',
|
|
349
|
+
* variables: { second: 1}
|
|
350
|
+
* }]
|
|
351
|
+
* }]
|
|
352
|
+
* })
|
|
353
|
+
* )
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
modifyProcessInstance(modifyProcessInstanceRequest: Grpc.ModifyProcessInstanceRequest): Promise<Grpc.ModifyProcessInstanceResponse>;
|
|
357
|
+
/**
|
|
358
|
+
*
|
|
359
|
+
* @since 8.5.0
|
|
360
|
+
*/
|
|
361
|
+
migrateProcessInstance(migrateProcessInstanceRequest: Grpc.MigrateProcessInstanceRequest): Promise<Grpc.MigrateProcessInstanceResponse>;
|
|
362
|
+
/**
|
|
363
|
+
* @description Publish a message to the broker for correlation with a workflow instance. See [this tutorial](https://docs.camunda.io/docs/guides/message-correlation/) for a detailed description of message correlation.
|
|
364
|
+
* @example
|
|
365
|
+
* ```
|
|
366
|
+
* const zbc = new ZeebeGrpcClient()
|
|
367
|
+
*
|
|
368
|
+
* zbc.publishMessage({
|
|
369
|
+
* // Should match the "Message Name" in a BPMN Message Catch
|
|
370
|
+
* name: 'order_status',
|
|
371
|
+
* correlationKey: 'uuid-124-532-5432',
|
|
372
|
+
* variables: {
|
|
373
|
+
* event: 'PROCESSED'
|
|
374
|
+
* }
|
|
375
|
+
* })
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
publishMessage<ProcessVariables extends {
|
|
379
|
+
[key: string]: ZB.JSON;
|
|
380
|
+
} = ZB.IProcessVariables>(publishMessageRequest: Grpc.PublishMessageRequest<ProcessVariables>): Promise<Grpc.PublishMessageResponse>;
|
|
381
|
+
/**
|
|
382
|
+
* @description Publish a message to the broker for correlation with a workflow message start event.
|
|
383
|
+
* For a message targeting a start event, the correlation key is not needed to target a specific running process instance.
|
|
384
|
+
* However, the hash of the correlationKey is used to determine the partition where this workflow will start.
|
|
385
|
+
* So we assign a random uuid to balance workflow instances created via start message across partitions.
|
|
386
|
+
*
|
|
387
|
+
* We make the correlationKey optional, because the caller can specify a correlationKey + messageId
|
|
388
|
+
* to guarantee an idempotent message.
|
|
389
|
+
*
|
|
390
|
+
* Multiple messages with the same correlationKey + messageId combination will only start a workflow once.
|
|
391
|
+
* See: https://github.com/zeebe-io/zeebe/issues/1012 and https://github.com/zeebe-io/zeebe/issues/1022
|
|
392
|
+
* @example
|
|
393
|
+
* ```
|
|
394
|
+
* const zbc = new ZeebeGrpcClient()
|
|
395
|
+
* zbc.publishStartMessage({
|
|
396
|
+
* name: 'Start_New_Onboarding_Flow',
|
|
397
|
+
* variables: {
|
|
398
|
+
* customerId: 'uuid-348-234-8908'
|
|
399
|
+
* }
|
|
400
|
+
* })
|
|
401
|
+
*
|
|
402
|
+
* // To do the same in an idempotent fashion - note: only idempotent during the lifetime of the created instance.
|
|
403
|
+
* zbc.publishStartMessage({
|
|
404
|
+
* name: 'Start_New_Onboarding_Flow',
|
|
405
|
+
* messageId: 'uuid-348-234-8908', // use customerId to make process idempotent per customer
|
|
406
|
+
* variables: {
|
|
407
|
+
* customerId: 'uuid-348-234-8908'
|
|
408
|
+
* }
|
|
409
|
+
* })
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
412
|
+
publishStartMessage<ProcessVariables extends ZB.IInputVariables = ZB.IProcessVariables>(publishStartMessageRequest: Grpc.PublishStartMessageRequest<ProcessVariables>): Promise<Grpc.PublishMessageResponse>;
|
|
413
|
+
/**
|
|
414
|
+
*
|
|
415
|
+
* @description Resolve an incident by incident key.
|
|
416
|
+
* @example
|
|
417
|
+
* ```
|
|
418
|
+
* type JSONObject = {[key: string]: string | number | boolean | JSONObject}
|
|
419
|
+
*
|
|
420
|
+
* const zbc = new ZeebeGrpcClient()
|
|
421
|
+
*
|
|
422
|
+
* async updateAndResolveIncident({
|
|
423
|
+
* processInstanceId,
|
|
424
|
+
* incidentKey,
|
|
425
|
+
* variables
|
|
426
|
+
* } : {
|
|
427
|
+
* processInstanceId: string,
|
|
428
|
+
* incidentKey: string,
|
|
429
|
+
* variables: JSONObject
|
|
430
|
+
* }) {
|
|
431
|
+
* await zbc.setVariables({
|
|
432
|
+
* elementInstanceKey: processInstanceId,
|
|
433
|
+
* variables
|
|
434
|
+
* })
|
|
435
|
+
* await zbc.updateRetries()
|
|
436
|
+
* zbc.resolveIncident({
|
|
437
|
+
* incidentKey
|
|
438
|
+
* })
|
|
439
|
+
* zbc.resolveIncident(incidentKey)
|
|
440
|
+
* }
|
|
441
|
+
*
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
resolveIncident(resolveIncidentRequest: Grpc.ResolveIncidentRequest): Promise<void>;
|
|
445
|
+
/**
|
|
446
|
+
*
|
|
447
|
+
* @description Directly modify the variables is a process instance. This can be used with `resolveIncident` to update the process and resolve an incident.
|
|
448
|
+
* @example
|
|
449
|
+
* ```
|
|
450
|
+
* type JSONObject = {[key: string]: string | number | boolean | JSONObject}
|
|
451
|
+
*
|
|
452
|
+
* const zbc = new ZeebeGrpcClient()
|
|
453
|
+
*
|
|
454
|
+
* async function updateAndResolveIncident({
|
|
455
|
+
* incidentKey,
|
|
456
|
+
* processInstanceKey,
|
|
457
|
+
* jobKey,
|
|
458
|
+
* variableUpdate
|
|
459
|
+
* } : {
|
|
460
|
+
* incidentKey: string
|
|
461
|
+
* processInstanceKey: string
|
|
462
|
+
* jobKey: string
|
|
463
|
+
* variableUpdate: JSONObject
|
|
464
|
+
* }) {
|
|
465
|
+
* await zbc.setVariables({
|
|
466
|
+
* elementInstanceKey: processInstanceKey,
|
|
467
|
+
* variables: variableUpdate
|
|
468
|
+
* })
|
|
469
|
+
* await zbc.updateJobRetries({
|
|
470
|
+
* jobKey,
|
|
471
|
+
* retries: 1
|
|
472
|
+
* })
|
|
473
|
+
* return zbc.resolveIncident({
|
|
474
|
+
* incidentKey
|
|
475
|
+
* })
|
|
476
|
+
* }
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
setVariables<Variables = ZB.IProcessVariables>(request: Grpc.SetVariablesRequest<Variables>): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
*
|
|
482
|
+
* @description Fail a job by throwing a business error (i.e. non-technical) that occurs while processing a job.
|
|
483
|
+
* The error is handled in the workflow by an error catch event.
|
|
484
|
+
* If there is no error catch event with the specified `errorCode` then an incident will be raised instead.
|
|
485
|
+
* This method is useful when building a worker, for example for the decoupled completion pattern.
|
|
486
|
+
* @example
|
|
487
|
+
* ```
|
|
488
|
+
* type JSONObject = {[key: string]: string | number | boolean | JSONObject}
|
|
489
|
+
*
|
|
490
|
+
* interface errorResult {
|
|
491
|
+
* resultType: 'ERROR' as 'ERROR'
|
|
492
|
+
* errorCode: string
|
|
493
|
+
* errorMessage: string
|
|
494
|
+
* }
|
|
495
|
+
*
|
|
496
|
+
* interface successResult {
|
|
497
|
+
* resultType: 'SUCCESS' as 'SUCCESS'
|
|
498
|
+
* variableUpdate: JSONObject
|
|
499
|
+
* }
|
|
500
|
+
*
|
|
501
|
+
* type Result = errorResult | successResult
|
|
502
|
+
*
|
|
503
|
+
* const zbc = new ZeebeGrpcClient()
|
|
504
|
+
*
|
|
505
|
+
*
|
|
506
|
+
* // This could be a listener on a return queue from an external system
|
|
507
|
+
* async function handleJob(jobKey: string, result: Result) {
|
|
508
|
+
* if (resultType === 'ERROR') {
|
|
509
|
+
* const { errorMessage, errorCode } = result
|
|
510
|
+
* zbc.throwError({
|
|
511
|
+
* jobKey,
|
|
512
|
+
* errorCode,
|
|
513
|
+
* errorMessage
|
|
514
|
+
* })
|
|
515
|
+
* } else {
|
|
516
|
+
* zbc.completeJob({
|
|
517
|
+
* jobKey,
|
|
518
|
+
* variables: result.variableUpdate
|
|
519
|
+
* })
|
|
520
|
+
* }
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
throwError(throwErrorRequest: Grpc.ThrowErrorRequest): Promise<void>;
|
|
525
|
+
/**
|
|
526
|
+
* @description Return the broker cluster topology.
|
|
527
|
+
* @example
|
|
528
|
+
* ```
|
|
529
|
+
* const zbc = new ZeebeGrpcClient()
|
|
530
|
+
*
|
|
531
|
+
* zbc.topology().then(res => console.res(JSON.stringify(res, null, 2)))
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
topology(): Promise<Grpc.TopologyResponse>;
|
|
535
|
+
/**
|
|
536
|
+
*
|
|
537
|
+
* @description Update the number of retries for a Job. This is useful if a job has zero remaining retries and fails, raising an incident.
|
|
538
|
+
* @example
|
|
539
|
+
* ```
|
|
540
|
+
* type JSONObject = {[key: string]: string | number | boolean | JSONObject}
|
|
541
|
+
*
|
|
542
|
+
* const zbc = new ZeebeGrpcClient()
|
|
543
|
+
*
|
|
544
|
+
* async function updateAndResolveIncident({
|
|
545
|
+
* incidentKey,
|
|
546
|
+
* processInstanceKey,
|
|
547
|
+
* jobKey,
|
|
548
|
+
* variableUpdate
|
|
549
|
+
* } : {
|
|
550
|
+
* incidentKey: string
|
|
551
|
+
* processInstanceKey: string
|
|
552
|
+
* jobKey: string
|
|
553
|
+
* variableUpdate: JSONObject
|
|
554
|
+
* }) {
|
|
555
|
+
* await zbc.setVariables({
|
|
556
|
+
* elementInstanceKey: processInstanceKey,
|
|
557
|
+
* variables: variableUpdate
|
|
558
|
+
* })
|
|
559
|
+
* await zbc.updateJobRetries({
|
|
560
|
+
* jobKey,
|
|
561
|
+
* retries: 1
|
|
562
|
+
* })
|
|
563
|
+
* return zbc.resolveIncident({
|
|
564
|
+
* incidentKey
|
|
565
|
+
* })
|
|
566
|
+
* }
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
569
|
+
updateJobRetries(updateJobRetriesRequest: Grpc.UpdateJobRetriesRequest): Promise<void>;
|
|
570
|
+
private constructGrpcClient;
|
|
571
|
+
/**
|
|
572
|
+
* If this.retry is set true, the operation will be wrapped in an configurable retry on exceptions
|
|
573
|
+
* of gRPC error code 14 - Transient Network Failure.
|
|
574
|
+
* See: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
|
575
|
+
* If this.retry is false, it will be executed with no retry, and the application should handle the exception.
|
|
576
|
+
* @param operation A gRPC command operation
|
|
577
|
+
*/
|
|
578
|
+
private executeOperation;
|
|
579
|
+
private _onConnectionError;
|
|
580
|
+
/**
|
|
581
|
+
* This function takes a gRPC operation that returns a Promise as a function, and invokes it.
|
|
582
|
+
* If the operation throws gRPC error 14, this function will continue to try it until it succeeds
|
|
583
|
+
* or retries are exhausted.
|
|
584
|
+
* @param operation A gRPC command operation that may fail if the broker is not available
|
|
585
|
+
*/
|
|
586
|
+
private retryOnFailure;
|
|
587
|
+
}
|