@camunda8/sdk 8.5.0 → 8.5.1-alpha.2
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/CHANGELOG.md +14 -0
- package/QUICKSTART.md +357 -0
- package/README.md +3 -7
- package/dist/admin/lib/AdminApiClient.d.ts +21 -2
- package/dist/admin/lib/AdminApiClient.js +27 -14
- package/dist/admin/lib/AdminApiClient.js.map +1 -1
- package/dist/c8/index.d.ts +2 -2
- package/dist/c8/index.js +4 -4
- package/dist/c8/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/GotErrors.d.ts +6 -0
- package/dist/lib/GotErrors.js +37 -0
- package/dist/lib/GotErrors.js.map +1 -0
- package/dist/lib/GotHooks.d.ts +23 -0
- package/dist/lib/GotHooks.js +51 -0
- package/dist/lib/GotHooks.js.map +1 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/modeler/lib/ModelerAPIClient.d.ts +58 -7
- package/dist/modeler/lib/ModelerAPIClient.js +79 -36
- package/dist/modeler/lib/ModelerAPIClient.js.map +1 -1
- package/dist/oauth/lib/OAuthProvider.d.ts +1 -1
- package/dist/oauth/lib/OAuthProvider.js +10 -8
- package/dist/oauth/lib/OAuthProvider.js.map +1 -1
- package/dist/operate/lib/OperateApiClient.d.ts +41 -2
- package/dist/operate/lib/OperateApiClient.js +50 -16
- package/dist/operate/lib/OperateApiClient.js.map +1 -1
- package/dist/optimize/lib/OptimizeApiClient.d.ts +13 -5
- package/dist/optimize/lib/OptimizeApiClient.js +20 -20
- package/dist/optimize/lib/OptimizeApiClient.js.map +1 -1
- package/dist/tasklist/lib/TasklistApiClient.d.ts +7 -2
- package/dist/tasklist/lib/TasklistApiClient.js +12 -14
- package/dist/tasklist/lib/TasklistApiClient.js.map +1 -1
- package/dist/zeebe/zb/ZeebeGrpcClient.js +12 -3
- package/dist/zeebe/zb/ZeebeGrpcClient.js.map +1 -1
- package/img/process-model.png +0 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [8.5.1-alpha.2](https://github.com/camunda/camunda-8-js-sdk/compare/v8.5.1-alpha.1...v8.5.1-alpha.2) (2024-04-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **repo:** add status code to HTTPError type ([#135](https://github.com/camunda/camunda-8-js-sdk/issues/135)) ([cfea141](https://github.com/camunda/camunda-8-js-sdk/commit/cfea14173c4ddc005df142cc139db961a235cd53)), closes [#125](https://github.com/camunda/camunda-8-js-sdk/issues/125) [#125](https://github.com/camunda/camunda-8-js-sdk/issues/125)
|
|
7
|
+
|
|
8
|
+
## [8.5.1-alpha.1](https://github.com/camunda/camunda-8-js-sdk/compare/v8.5.0...v8.5.1-alpha.1) (2024-04-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **repo:** add stack traces to async REST errors ([#131](https://github.com/camunda/camunda-8-js-sdk/issues/131)) ([ef8d9c6](https://github.com/camunda/camunda-8-js-sdk/commit/ef8d9c6b58a8864d66b6f8f1b008256cc9acf187))
|
|
14
|
+
|
|
1
15
|
# [8.5.0](https://github.com/camunda/camunda-8-js-sdk/compare/v8.4.1...v8.5.0) (2024-04-08)
|
|
2
16
|
|
|
3
17
|
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
## Camunda 8 JS SDK for Node.js Quickstart
|
|
2
|
+
|
|
3
|
+
From 8.5.0, the official [Camunda 8 JS SDK for Node.js](https://github.com/camunda/camunda-8-js-sdk) is available via [NPM](https://www.npmjs.com/package/@camunda8/sdk).
|
|
4
|
+
|
|
5
|
+
It is written in TypeScript and has full type support for IDEs and editors that support intellisense. It can be used in JavaScript or TypeScript projects.
|
|
6
|
+
|
|
7
|
+
It requires Node.js as a runtime environment. It cannot be used in a web browser for a number of [technical reasons](https://github.com/camunda/camunda-8-js-sdk/issues/79).
|
|
8
|
+
|
|
9
|
+
## Quickstart
|
|
10
|
+
|
|
11
|
+
A complete working version of the Quickstart code is available on GitHub [here](https://github.com/camunda-community-hub/c8-sdk-demo).
|
|
12
|
+
|
|
13
|
+
- Create a new Node.js project that uses TypeScript:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm init -y
|
|
17
|
+
npm install -D typescript
|
|
18
|
+
npx tsc --init
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- Install the SDK as a dependency:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i @camunda8/sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Connection configuration
|
|
28
|
+
|
|
29
|
+
You have two choices:
|
|
30
|
+
|
|
31
|
+
- explicit configuration in code
|
|
32
|
+
- zero-configuration constructor with environment variables
|
|
33
|
+
|
|
34
|
+
The best way to do the configuration is via the zero-configuration constructor in code, and all values for configuration supplied via environment variables. This allows you to test the same code against different environments with no code changes.
|
|
35
|
+
|
|
36
|
+
The environment variables that you need to set are the following (replace with your secrets and urls):
|
|
37
|
+
|
|
38
|
+
### Self-Managed configuration
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Self-Managed
|
|
42
|
+
export ZEEBE_ADDRESS='localhost:26500'
|
|
43
|
+
export ZEEBE_CLIENT_ID='zeebe'
|
|
44
|
+
export ZEEBE_CLIENT_SECRET='zecret'
|
|
45
|
+
export CAMUNDA_OAUTH_URL='http://localhost:18080/auth/realms/camunda-platform/protocol/openid-connect/token'
|
|
46
|
+
export CAMUNDA_TASKLIST_BASE_URL='http://localhost:8082'
|
|
47
|
+
export CAMUNDA_OPERATE_BASE_URL='http://localhost:8081'
|
|
48
|
+
export CAMUNDA_OPTIMIZE_BASE_URL='http://localhost:8083'
|
|
49
|
+
export CAMUNDA_MODELER_BASE_URL='http://localhost:8070/api'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you are running with multi-tenancy enabled:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
export CAMUNDA_TENANT_ID='<default>'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If your installation does not have TLS on Zeebe:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
export CAMUNDA_SECURE_CONNECTION=false
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Camunda SaaS configuration
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
export ZEEBE_ADDRESS='5c34c0a7-...-125615f7a9b9.syd-1.zeebe.camunda.io:443'
|
|
68
|
+
export ZEEBE_CLIENT_ID='yvvURO...'
|
|
69
|
+
export ZEEBE_CLIENT_SECRET='iJJu-SHg...'
|
|
70
|
+
export CAMUNDA_TASKLIST_BASE_URL='https://syd-1.tasklist.camunda.io/5c34c0a7-...-125615f7a9b9'
|
|
71
|
+
export CAMUNDA_OPTIMIZE_BASE_URL='https://syd-1.optimize.camunda.io/5c34c0a7-...-125615f7a9b9'
|
|
72
|
+
export CAMUNDA_OPERATE_BASE_URL='https://syd-1.operate.camunda.io/5c34c0a7-...-125615f7a9b9'
|
|
73
|
+
export CAMUNDA_OAUTH_URL='https://login.cloud.camunda.io/oauth/token'
|
|
74
|
+
export CAMUNDA_SECURE_CONNECTION=true
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
If you want to set these explicitly in code, the `Camunda8` constructor takes these values, with the same key names, in the constructor.
|
|
78
|
+
|
|
79
|
+
### Using the SDK
|
|
80
|
+
|
|
81
|
+
- Create a file `index.ts` in your IDE.
|
|
82
|
+
- Import the SDK:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Camunda8 } from '@camunda8/sdk'
|
|
86
|
+
import path from 'path' // we'll use this later
|
|
87
|
+
|
|
88
|
+
const camunda = new Camunda8()
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- Get a Zeebe GRPC API client. This is used to deploy process models and start process instances.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const zeebe = camunda.getZeebeGrpcApiClient()
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- Get an Operate client. This is used to interact with completed processes and deployed process models.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const operate = camunda.getOperateApiClient()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
- Get a Tasklist client. This is used to interact programatically with user tasks.
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const tasklist = camunda.getTasklistApiClient()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Deploy a process model
|
|
110
|
+
|
|
111
|
+
- We will deploy a process model (we'll create the model in a moment). Network operations are asynchronous and methods that operate over the network return Promises, so we will wrap the main function of the program in an `async` function:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
async function main() {
|
|
115
|
+
const deploy = await zeebe.deployResource({
|
|
116
|
+
processFilename: path.join(process.cwd(), 'process.bpmn'),
|
|
117
|
+
})
|
|
118
|
+
console.log(
|
|
119
|
+
`[Zeebe] Deployed process ${deploy.deployments[0].process.bpmnProcessId}`
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
main() // remember to invoke the function
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
- Paste the process model XML below into a file called `process.bpmn`:
|
|
127
|
+
|
|
128
|
+
```xml
|
|
129
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
130
|
+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_14f3xb6" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.8.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.1.0">
|
|
131
|
+
<bpmn:process id="c8-sdk-demo" name="C8 SDK Demo" isExecutable="true">
|
|
132
|
+
<bpmn:startEvent id="StartEvent_1">
|
|
133
|
+
<bpmn:outgoing>Flow_0yqo0wz</bpmn:outgoing>
|
|
134
|
+
</bpmn:startEvent>
|
|
135
|
+
<bpmn:sequenceFlow id="Flow_0yqo0wz" sourceRef="StartEvent_1" targetRef="Activity_1gwbbuy" />
|
|
136
|
+
<bpmn:sequenceFlow id="Flow_0qugen1" sourceRef="Activity_1gwbbuy" targetRef="Activity_0tp91ve" />
|
|
137
|
+
<bpmn:endEvent id="Event_0j28rou">
|
|
138
|
+
<bpmn:incoming>Flow_03qgl0x</bpmn:incoming>
|
|
139
|
+
</bpmn:endEvent>
|
|
140
|
+
<bpmn:sequenceFlow id="Flow_03qgl0x" sourceRef="Activity_0tp91ve" targetRef="Event_0j28rou" />
|
|
141
|
+
<bpmn:serviceTask id="Activity_1gwbbuy" name="Do the service thing">
|
|
142
|
+
<bpmn:extensionElements>
|
|
143
|
+
<zeebe:taskDefinition type="service-task" />
|
|
144
|
+
</bpmn:extensionElements>
|
|
145
|
+
<bpmn:incoming>Flow_0yqo0wz</bpmn:incoming>
|
|
146
|
+
<bpmn:outgoing>Flow_0qugen1</bpmn:outgoing>
|
|
147
|
+
</bpmn:serviceTask>
|
|
148
|
+
<bpmn:userTask id="Activity_0tp91ve" name="Human, do something!">
|
|
149
|
+
<bpmn:incoming>Flow_0qugen1</bpmn:incoming>
|
|
150
|
+
<bpmn:outgoing>Flow_03qgl0x</bpmn:outgoing>
|
|
151
|
+
</bpmn:userTask>
|
|
152
|
+
</bpmn:process>
|
|
153
|
+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
|
154
|
+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="c8-sdk-demo">
|
|
155
|
+
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
|
156
|
+
<dc:Bounds x="179" y="99" width="36" height="36" />
|
|
157
|
+
</bpmndi:BPMNShape>
|
|
158
|
+
<bpmndi:BPMNShape id="Event_0j28rou_di" bpmnElement="Event_0j28rou">
|
|
159
|
+
<dc:Bounds x="592" y="99" width="36" height="36" />
|
|
160
|
+
</bpmndi:BPMNShape>
|
|
161
|
+
<bpmndi:BPMNShape id="Activity_1rvlo9s_di" bpmnElement="Activity_1gwbbuy">
|
|
162
|
+
<dc:Bounds x="270" y="77" width="100" height="80" />
|
|
163
|
+
<bpmndi:BPMNLabel />
|
|
164
|
+
</bpmndi:BPMNShape>
|
|
165
|
+
<bpmndi:BPMNShape id="Activity_1wxn0pq_di" bpmnElement="Activity_0tp91ve">
|
|
166
|
+
<dc:Bounds x="430" y="77" width="100" height="80" />
|
|
167
|
+
<bpmndi:BPMNLabel />
|
|
168
|
+
</bpmndi:BPMNShape>
|
|
169
|
+
<bpmndi:BPMNEdge id="Flow_0yqo0wz_di" bpmnElement="Flow_0yqo0wz">
|
|
170
|
+
<di:waypoint x="215" y="117" />
|
|
171
|
+
<di:waypoint x="270" y="117" />
|
|
172
|
+
</bpmndi:BPMNEdge>
|
|
173
|
+
<bpmndi:BPMNEdge id="Flow_0qugen1_di" bpmnElement="Flow_0qugen1">
|
|
174
|
+
<di:waypoint x="370" y="117" />
|
|
175
|
+
<di:waypoint x="430" y="117" />
|
|
176
|
+
</bpmndi:BPMNEdge>
|
|
177
|
+
<bpmndi:BPMNEdge id="Flow_03qgl0x_di" bpmnElement="Flow_03qgl0x">
|
|
178
|
+
<di:waypoint x="530" y="117" />
|
|
179
|
+
<di:waypoint x="592" y="117" />
|
|
180
|
+
</bpmndi:BPMNEdge>
|
|
181
|
+
</bpmndi:BPMNPlane>
|
|
182
|
+
</bpmndi:BPMNDiagram>
|
|
183
|
+
</bpmn:definitions>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
- This is the model we are using:
|
|
187
|
+
|
|
188
|
+

|
|
189
|
+
|
|
190
|
+
- You can run the program now, and see the process model deploy to Camunda:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npx ts-node index.ts
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If your configuration is correct, you will see the following:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
Deployed process c8-sdk-demo
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Create a service worker
|
|
203
|
+
|
|
204
|
+
- Outside the main function, add the following code:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
console.log('Starting worker...')
|
|
208
|
+
zbc.createWorker({
|
|
209
|
+
taskType: 'service-task',
|
|
210
|
+
taskHandler: (job) => {
|
|
211
|
+
console.log(`[Zeebe Worker] handling job of type ${job.type}`)
|
|
212
|
+
return job.complete({
|
|
213
|
+
serviceTaskOutcome: 'We did it!',
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
This will start a service task worker that runs in an asynchronous loop, invoking the `taskHandler` function whenever a job for the service task type `service-task` is available.
|
|
220
|
+
|
|
221
|
+
The handler must return a job completion function - one of `fail`, `complete` or `forward`. This is enforced by the type system and ensures that you do not write code that does not have code paths that do not respond to Zeebe after taking a job. The `job.complete` function can take an object that represents variables to update.
|
|
222
|
+
|
|
223
|
+
### Create a programatic human task worker
|
|
224
|
+
|
|
225
|
+
Our process has a human task after the service task. The service task worker will complete the service task job, and we will complete the human task using the Tasklist API client.
|
|
226
|
+
|
|
227
|
+
- Add the following code beneath the service worker code:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
console.log(`Starting human task poller...`)
|
|
231
|
+
setInterval(async () => {
|
|
232
|
+
const res = await tasklist.searchTasks({
|
|
233
|
+
state: 'CREATED',
|
|
234
|
+
})
|
|
235
|
+
if (res.length > 0) {
|
|
236
|
+
console.log(`[Tasklist] fetched ${res.length} human tasks`)
|
|
237
|
+
res.forEach(async (task) => {
|
|
238
|
+
console.log(
|
|
239
|
+
`[Tasklist] claiming task ${task.id} from process ${task.processInstanceKey}`
|
|
240
|
+
)
|
|
241
|
+
const t = await tasklist.assignTask({
|
|
242
|
+
taskId: task.id,
|
|
243
|
+
assignee: 'demobot',
|
|
244
|
+
allowOverrideAssignment: true,
|
|
245
|
+
})
|
|
246
|
+
console.log(
|
|
247
|
+
`[Tasklist] servicing human task ${t.id} from process ${t.processInstanceKey}`
|
|
248
|
+
)
|
|
249
|
+
await tasklist.completeTask(t.id, {
|
|
250
|
+
humanTaskStatus: 'Got done',
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
} else {
|
|
254
|
+
console.log('No human tasks found')
|
|
255
|
+
}
|
|
256
|
+
}, 3000)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
We now have an asynchronously polling service worker and an asynchronously polling human task worker.
|
|
260
|
+
|
|
261
|
+
The last step is to create a process instance.
|
|
262
|
+
|
|
263
|
+
### Create a process instance
|
|
264
|
+
|
|
265
|
+
There are two options for creating a process instance.
|
|
266
|
+
|
|
267
|
+
For long-running processes, you will use `createProcessInstance`, which returns as soon as the process instance is created with the process instance id.
|
|
268
|
+
|
|
269
|
+
For the shorter-running process that we are using, we will use `createProcessInstanceWithResult`, which awaits the completion of the process and returns with the final variable values.
|
|
270
|
+
|
|
271
|
+
- Locate the following line in the `main` function:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
console.log(
|
|
275
|
+
`[Zeebe] Deployed process ${res.deployments[0].process.bpmnProcessId}`
|
|
276
|
+
)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
- Directly after that, inside the `main` function, add the following:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
const p = await zbc.createProcessInstanceWithResult({
|
|
283
|
+
bpmnProcessId: `c8-sdk-demo`,
|
|
284
|
+
variables: {
|
|
285
|
+
humanTaskStatus: 'Needs doing',
|
|
286
|
+
},
|
|
287
|
+
})
|
|
288
|
+
console.log(`[Zeebe] Finished Process Instance ${p.processInstanceKey}`)
|
|
289
|
+
console.log(`[Zeebe] humanTaskStatus is "${p.variables.humanTaskStatus}"`)
|
|
290
|
+
console.log(`[Zeebe] serviceTaskOutcome is "${p.variables.serviceTaskOutcome}"`)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Run the program with the following command:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
npx ts-node index.ts
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
You should see output similar to the following:
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
Creating worker...
|
|
303
|
+
Starting human task poller...
|
|
304
|
+
[Zeebe] Deployed process c8-sdk-demo
|
|
305
|
+
[Zeebe Worker] handling job of type service-task
|
|
306
|
+
[Tasklist] fetched 1 human tasks
|
|
307
|
+
[Tasklist] claiming task 2251799814895765 from process 2251799814900881
|
|
308
|
+
[Tasklist] servicing human task 2251799814895765 from process 2251799814900881
|
|
309
|
+
[Zeebe] Finished Process Instance 2251799814900881
|
|
310
|
+
[Zeebe] humanTaskStatus is "Got done"
|
|
311
|
+
[Zeebe] serviceTaskOutcome is "We did it!"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The program will continue running until you hit Ctrl-C. This is because both the service worker and the task poller that we wrote are running in continuous loops.
|
|
315
|
+
|
|
316
|
+
There are a few more things we will do to explore the functionality of the SDK.
|
|
317
|
+
|
|
318
|
+
### Retrieve a process instance
|
|
319
|
+
|
|
320
|
+
When you create a process instance that runs for some time, you will many times do it by creating a process with `createProcessInstance` and getting back the process instance key of the running process, rather than waiting for it to complete.
|
|
321
|
+
|
|
322
|
+
To examine the process instance status, you can use the process instance key to query the Operate API. You can also examine process instances after they complete in the same way. We'll do that with the process instance that we created, after it completes.
|
|
323
|
+
|
|
324
|
+
- Locate the following line in the `main` function:
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
console.log(`[Zeebe] serviceTaskOutcome is "${p.variables.serviceTaskOutcome}"`)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
After that line, inside the `main` function add the following:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
const historicalProcessInstance = await operate.getProcessInstance(
|
|
334
|
+
p.processInstanceKey
|
|
335
|
+
)
|
|
336
|
+
console.log('[Operate]', historicalProcessInstance)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
When you run the program now, you will see additional output similar to the following:
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
{
|
|
343
|
+
key: 2251799814905817,
|
|
344
|
+
processVersion: 1,
|
|
345
|
+
bpmnProcessId: 'c8-sdk-demo',
|
|
346
|
+
startDate: '2024-04-08T09:11:06.157+0000',
|
|
347
|
+
endDate: '2024-04-08T09:11:12.403+0000',
|
|
348
|
+
state: 'COMPLETED',
|
|
349
|
+
processDefinitionKey: 2251799814900879,
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The state may be `ACTIVE` rather than `COMPLETED`. This occurs because the data read over the Operate API is historical data from the Zeebe exporter, and lags behind the actual state of the system. It is _eventually consistent_.
|
|
354
|
+
|
|
355
|
+
## Further steps
|
|
356
|
+
|
|
357
|
+
Consult the complete API documentation for the SDK [here](https://camunda.github.io/camunda-8-js-sdk/).
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
This is the official Camunda 8 JavaScript SDK. It is written in TypeScript and runs on Node.js. See why [this does not run in a web browser](https://github.com/camunda/camunda-8-js-sdk/issues/79).
|
|
8
8
|
|
|
9
|
+
Full API Docs are [here](https://camunda.github.io/camunda-8-js-sdk/). See the QUICKSTART.md file in [the repository](https://github.com/camunda/camunda-8-js-sdk) for a quick start.
|
|
10
|
+
|
|
9
11
|
## What does "supported" mean?
|
|
10
12
|
|
|
11
13
|
This is the official supported-by-Camunda Nodejs SDK for Camunda Platform 8.
|
|
@@ -34,7 +36,7 @@ In this release, the functionality of Camunda 8 is exposed via dedicated clients
|
|
|
34
36
|
import { Camunda8 } from '@camunda8/sdk'
|
|
35
37
|
|
|
36
38
|
const c8 = new Camunda8()
|
|
37
|
-
const zeebe = c8.
|
|
39
|
+
const zeebe = c8.getZeebeGrpcApiClient()
|
|
38
40
|
const operate = c8.getOperateApiClient()
|
|
39
41
|
const optimize = c8.getOptimizeApiClient()
|
|
40
42
|
const tasklist = c8.getTasklistApiClient()
|
|
@@ -110,12 +112,6 @@ const c8 = new Camunda8({
|
|
|
110
112
|
|
|
111
113
|
If the cache directory does not exist, the SDK will attempt to create it (recursively). If the SDK is unable to create it, or the directory exists but is not writeable by your application, the SDK will throw an exception.
|
|
112
114
|
|
|
113
|
-
### Token refresh
|
|
114
|
-
|
|
115
|
-
Token refresh timing relative to expiration is controlled by the `CAMUNDA_OAUTH_TOKEN_REFRESH_THRESHOLD_MS` value. By default, this is 1000ms. Tokens are renewed this amount of time before they expire.
|
|
116
|
-
|
|
117
|
-
If you experience intermittent `401: Unauthorized` errors, this may not be sufficient time to refresh the token before it expires in your infrastructure. Increase this value to force a token to be refreshed before it expires.
|
|
118
|
-
|
|
119
115
|
## Connection configuration examples
|
|
120
116
|
|
|
121
117
|
### Self-Managed
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { CamundaPlatform8Configuration, DeepPartial } from '../../lib';
|
|
2
2
|
import { IOAuthProvider } from '../../oauth';
|
|
3
3
|
import * as Dto from './AdminDto';
|
|
4
|
+
/**
|
|
5
|
+
* This class provides methods to interact with the Camunda Admin API.
|
|
6
|
+
* @throws {RESTError} An error that may occur during API operations.
|
|
7
|
+
*/
|
|
4
8
|
export declare class AdminApiClient {
|
|
5
9
|
private userAgentString;
|
|
6
10
|
private oAuthProvider;
|
|
@@ -13,13 +17,14 @@ export declare class AdminApiClient {
|
|
|
13
17
|
/**
|
|
14
18
|
*
|
|
15
19
|
* @description Get an array of the current API clients for this cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetClients) for more details.
|
|
20
|
+
* @throws {RESTError}
|
|
16
21
|
* @param clusterUuid - The cluster UUID
|
|
17
22
|
*
|
|
18
23
|
*/
|
|
19
24
|
getClients(clusterUuid: string): Promise<Dto.ClusterClient[]>;
|
|
20
25
|
/**
|
|
21
26
|
* @description Create a new API client for a cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/CreateClient) for more details.
|
|
22
|
-
* @
|
|
27
|
+
* @throws {RESTError}
|
|
23
28
|
*/
|
|
24
29
|
createClient(req: {
|
|
25
30
|
clusterUuid: string;
|
|
@@ -30,6 +35,7 @@ export declare class AdminApiClient {
|
|
|
30
35
|
* @description Get the details of an API client. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetClient) for more details.
|
|
31
36
|
* @param clusterUuid
|
|
32
37
|
* @param clientId
|
|
38
|
+
* @throws {RESTError}
|
|
33
39
|
* @returns
|
|
34
40
|
*/
|
|
35
41
|
getClient(clusterUuid: string, clientId: string): Promise<Dto.ClusterClientConnectionDetails>;
|
|
@@ -37,16 +43,19 @@ export declare class AdminApiClient {
|
|
|
37
43
|
* @description See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/DeleteClient) for more details.
|
|
38
44
|
* @param clusterUuid
|
|
39
45
|
* @param clientId
|
|
46
|
+
* @throws {RESTError}
|
|
40
47
|
*/
|
|
41
48
|
deleteClient(clusterUuid: string, clientId: string): Promise<null>;
|
|
42
49
|
/**
|
|
43
50
|
*
|
|
44
51
|
* @description Return an array of clusters. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetClusters) for more details.
|
|
52
|
+
* @throws {RESTError}
|
|
45
53
|
*/
|
|
46
54
|
getClusters(): Promise<Dto.Cluster[]>;
|
|
47
55
|
/**
|
|
48
56
|
*
|
|
49
57
|
* @description Create a new cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/CreateCluster) for more details.
|
|
58
|
+
* @throws {RESTError}
|
|
50
59
|
*/
|
|
51
60
|
createCluster(createClusterRequest: Dto.CreateClusterBody): Promise<{
|
|
52
61
|
clusterId: string;
|
|
@@ -54,23 +63,27 @@ export declare class AdminApiClient {
|
|
|
54
63
|
/**
|
|
55
64
|
*
|
|
56
65
|
* @description Retrieve the metadata for a cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetCluster) for more details.
|
|
66
|
+
* @throws {RESTError}
|
|
57
67
|
*
|
|
58
68
|
*/
|
|
59
69
|
getCluster(clusterUuid: string): Promise<Dto.Cluster>;
|
|
60
70
|
/**
|
|
61
71
|
*
|
|
62
72
|
* @description Delete a cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/DeleteCluster) for more details.
|
|
73
|
+
* @throws {RESTError}
|
|
63
74
|
*
|
|
64
75
|
*/
|
|
65
76
|
deleteCluster(clusterUuid: string): Promise<null>;
|
|
66
77
|
/**
|
|
67
78
|
*
|
|
68
79
|
* @description Retrieve the available parameters for cluster creation. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetParameters) for more details.
|
|
80
|
+
* @throws {RESTError}
|
|
69
81
|
*/
|
|
70
82
|
getParameters(): Promise<Dto.Parameters>;
|
|
71
83
|
/**
|
|
72
84
|
*
|
|
73
85
|
* @description Retrieve the connector secrets. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/GetSecrets) for more details.
|
|
86
|
+
* @throws {RESTError}
|
|
74
87
|
*/
|
|
75
88
|
getSecrets(clusterUuid: string): Promise<{
|
|
76
89
|
[key: string]: string;
|
|
@@ -78,6 +91,7 @@ export declare class AdminApiClient {
|
|
|
78
91
|
/**
|
|
79
92
|
*
|
|
80
93
|
* @description Create a new connector secret. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/CreateSecret) for more details.
|
|
94
|
+
* @throws {RESTError}
|
|
81
95
|
*/
|
|
82
96
|
createSecret({ clusterUuid, secretName, secretValue, }: {
|
|
83
97
|
clusterUuid: string;
|
|
@@ -87,11 +101,13 @@ export declare class AdminApiClient {
|
|
|
87
101
|
/**
|
|
88
102
|
*
|
|
89
103
|
* @description Delete a connector secret. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/DeleteSecret) for more details.
|
|
104
|
+
* @throws {RESTError}
|
|
90
105
|
*/
|
|
91
106
|
deleteSecret(clusterUuid: string, secretName: string): Promise<null>;
|
|
92
107
|
/**
|
|
93
108
|
*
|
|
94
109
|
* @description Add one or more IPs to the whitelist for the cluster. See [the API Documentation](https://console.cloud.camunda.io/customer-api/openapi/docs/#/default/UpdateIpWhitelist) for more details.
|
|
110
|
+
* @throws {RESTError}
|
|
95
111
|
* @param ipwhitelist
|
|
96
112
|
* @returns
|
|
97
113
|
*/
|
|
@@ -100,21 +116,24 @@ export declare class AdminApiClient {
|
|
|
100
116
|
description: string;
|
|
101
117
|
ip: string;
|
|
102
118
|
}
|
|
103
|
-
]): Promise<
|
|
119
|
+
]): Promise<null>;
|
|
104
120
|
/**
|
|
105
121
|
*
|
|
106
122
|
* @description Retrieve a list of members and pending invites for your organisation. See the [API Documentation]() for more details.
|
|
123
|
+
* @throws {RESTError}
|
|
107
124
|
*/
|
|
108
125
|
getUsers(): Promise<Dto.Member[]>;
|
|
109
126
|
/**
|
|
110
127
|
*
|
|
111
128
|
* @description Add a member. See the [API Documentation]() for more details.
|
|
129
|
+
* @throws {RESTError}
|
|
112
130
|
*
|
|
113
131
|
*/
|
|
114
132
|
createMember(email: string, orgRoles: Dto.OrganizationRole[]): Promise<null>;
|
|
115
133
|
/**
|
|
116
134
|
*
|
|
117
135
|
* @description Delete a member from your organization. See the [API Documentation]() for more details.
|
|
136
|
+
* @throws {RESTError}
|
|
118
137
|
*
|
|
119
138
|
*/
|
|
120
139
|
deleteMember(email: string): Promise<null>;
|